summaryrefslogtreecommitdiff
path: root/riscos/gifread.h
blob: 5cefede2955eb3b2f0694e522a5cfb611bd135d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * This file is part of NetSurf, http://netsurf.sourceforge.net/
 * Licensed under the GNU General Public License,
 *                http://www.opensource.org/licenses/gpl-license
 * Copyright 2004 Richard Wilson <not_ginger_matt@sourceforge.net>
 */

#ifndef _NETSURF_RISCOS_GIFREAD_H_
#define _NETSURF_RISCOS_GIFREAD_H_

#include "oslib/osspriteop.h"

/*	Error return values
*/
#define GIF_INSUFFICIENT_DATA -1
#define GIF_DATA_ERROR -2
#define GIF_INSUFFICIENT_MEMORY -3
#define GIF_INSUFFICIENT_FRAME_DATA -4
#define GIF_FRAME_DATA_ERROR -5

/*	Colour map size constant. Because we don't want to allocate
	memory each time we decode a frame we get enough so all frames
	will fit in there.
*/
#define GIF_MAX_COLOURS 256

/*	Maximum LZW bits available
*/
#define GIF_MAX_LZW 12

/*	A simple hold-all for our GIF data
*/
struct gif_animation {
	/*	Encoded GIF data
	*/
	unsigned char *gif_data;
	unsigned int buffer_position;
	unsigned int buffer_size;
	
	/*	Progressive decoding data
	*/
	unsigned int global_colours;
	unsigned int frame_holders;
	unsigned int colour_table_size;
	unsigned int *frame_pointers;

	/*	Animation data
	*/
	unsigned int current_frame;
	unsigned int decoded_frame;
	unsigned int loop_count;
	unsigned int *frame_delays;

	/*	Decoded GIF data
	*/
	unsigned int width;
	unsigned int height;
	unsigned int frame_count;
	unsigned int frame_count_partial;
	unsigned int background_colour;
	unsigned int aspect_ratio;
	unsigned int *global_colour_table;
	unsigned int *local_colour_table;

	/*	Decoded frame data
	*/
	unsigned int frame_offset_x;
	unsigned int frame_offset_y;
	unsigned int frame_width;
	unsigned int frame_height;
	unsigned int background_action;
	osspriteop_header *frame_image;
};

/*	Function declarations
*/
int gif_initialise(struct gif_animation *gif);
int gif_decode_frame(struct gif_animation *gif, int frame);
void gif_finalise(struct gif_animation *gif);

#endif