Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / flx / flx_fmt.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_FLX_FMT__H__
22 #define __GST_FLX_FMT_H__
23
24 #include <gst/gst.h>
25
26 G_BEGIN_DECLS
27
28 enum Flx_TypeChunk
29 {
30         /* frame chunks */
31         FLX_PREFIX_TYPE         = 0xf100,
32         FLX_SCRIPT_CHUNK        = 0xf1e0,
33         FLX_FRAME_TYPE          = 0xf1fa,
34         FLX_SEGMENT_TABLE       = 0xf1fb,
35         FLX_HUFFMAN_TABLE       = 0xf1fc,
36
37         /* sub chunks */
38         FLX_CEL_DATA            = 3,
39         FLX_COLOR256            = 4,
40         FLX_SS2                 = 7,
41         FLX_COLOR64             = 11,
42         FLX_LC                  = 12,
43         FLX_BLACK               = 13,
44         FLX_BRUN                = 15,
45         FLX_COPY                = 16,
46         FLX_MINI                = 18,
47         FLX_DTA_RUN             = 25,
48         FLX_DTA_COPY            = 26,
49         FLX_DTA_LC              = 27,
50         FLX_LABEL               = 31,
51         FLX_BMP_MASK            = 32,
52         FLX_MLEV_MASK           = 33,
53         FLX_SEGMENT             = 34,
54         FLX_KEY_IMAGE           = 35,
55         FLX_KEY_PAL             = 36,
56         FLX_REGION              = 37,
57         FLX_WAVE                = 38,
58         FLX_USERSTRING          = 39,
59         FLX_RGN_MASK            = 40
60
61 };
62
63 enum Flx_MagicHdr
64 {
65         FLX_MAGICHDR_FLI        = 0xaf11,
66         FLX_MAGICHDR_FLC        = 0xaf12,
67         FLX_MAGICHDR_FLX        = 0xaf44,
68         FLX_MAGICHDR_HUFFBWT    = 0xaf30
69 };
70
71 typedef struct _FlxHeader 
72 {
73         guint32 size;
74         guint16 type;
75         guint16 frames;
76         guint16 width,height,depth,flags;
77         guint32 speed;
78         guint16 reserved1;
79         /* FLC */ 
80         guint32 created,creator,updated,updater;
81         guint16 aspect_dx, aspect_dy;
82         /* EGI */
83         guint16 ext_flags,keyframes,totalframes;
84         guint32 req_memory;
85         guint16 max_regions,transp_num;
86         guchar  reserved2[24];
87         /* FLC */
88         guint32 oframe1,oframe2;
89         guchar  reserved3[40];
90 } FlxHeader;
91 #define FlxHeaderSize 128
92
93 typedef struct _FlxFrameChunk
94 {
95         guint32 size;
96         guint16 id;
97 } FlxFrameChunk;
98 #define FlxFrameChunkSize 6
99
100 typedef struct _FlxPrefixChunk
101 {
102         guint16 chunks;
103         guchar  reserved[8];
104 } FlxPrefixChunk;
105
106 typedef struct _FlxSegmentTable
107 {
108         guint16 segments;
109 } FlxSegmentTable;
110
111 typedef struct _FlxHuffmanTable
112 {
113         guint16 codelength;
114         guint16 numcodes;
115         guchar  reserved[6];
116 } FlxHuffmanTable;
117
118 typedef struct _FlxFrameType
119 {
120         guint16 chunks;
121         guint16 delay;
122         guchar  reserved[6];
123 } FlxFrameType;
124 #define FlxFrameTypeSize 10
125
126 #if G_BYTE_ORDER == G_BIG_ENDIAN 
127 #define LE_TO_BE_16(i16) ((guint16) (((i16) << 8) | ((i16) >> 8)))
128 #define LE_TO_BE_32(i32) \
129     (((guint32) (LE_TO_BE_16((guint16) (i32))) << 16) | (LE_TO_BE_16((i32) >> 16)))
130
131 #define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p) \
132     do { \
133      (frm_type_p)->chunks = LE_TO_BE_16((frm_type_p)->chunks); \
134      (frm_type_p)->delay = LE_TO_BE_16((frm_type_p)->delay); \
135     } while(0)
136
137 #define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p) \
138     do { \
139      (hffmn_table_p)->codelength = \
140         LE_TO_BE_16((hffmn_table_p)->codelength); \
141      (hffmn_table_p)->numcodes = LE_TO_BE_16((hffmn_table_p)->numcodes); \
142     } while(0)
143
144 #define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p) \
145      ((sgmnt_table_p)->segments = LE_TO_BE_16((sgmnt_table_p)->segments))
146
147 #define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p) \
148     do { \
149      (prfx_chnk_p)->chunks = LE_TO_BE_16((prfx_chnk_p)->chunks); \
150     } while(0)
151
152 #define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p) \
153     do { \
154      (frm_chnk_p)->size = LE_TO_BE_32((frm_chnk_p)->size); \
155      (frm_chnk_p)->id = LE_TO_BE_16((frm_chnk_p)->id); \
156     } while(0)
157
158 #define FLX_HDR_FIX_ENDIANNESS(hdr_p) \
159     do { \
160      (hdr_p)->size = LE_TO_BE_32((hdr_p)->size); \
161      (hdr_p)->type = LE_TO_BE_16((hdr_p)->type); \
162      (hdr_p)->frames = LE_TO_BE_16((hdr_p)->frames); \
163      (hdr_p)->width = LE_TO_BE_16((hdr_p)->width); \
164      (hdr_p)->height = LE_TO_BE_16((hdr_p)->height); \
165      (hdr_p)->depth = LE_TO_BE_16((hdr_p)->depth); \
166      (hdr_p)->flags = LE_TO_BE_16((hdr_p)->flags); \
167      (hdr_p)->speed = LE_TO_BE_32((hdr_p)->speed); \
168      (hdr_p)->reserved1 = LE_TO_BE_16((hdr_p)->reserved1); \
169      (hdr_p)->created = LE_TO_BE_32((hdr_p)->created); \
170      (hdr_p)->creator = LE_TO_BE_32((hdr_p)->creator); \
171      (hdr_p)->updated = LE_TO_BE_32((hdr_p)->updated); \
172      (hdr_p)->updater = LE_TO_BE_32((hdr_p)->updater); \
173      (hdr_p)->aspect_dx = LE_TO_BE_16((hdr_p)->aspect_dx); \
174      (hdr_p)->aspect_dy = LE_TO_BE_16((hdr_p)->aspect_dy); \
175      (hdr_p)->ext_flags = LE_TO_BE_16((hdr_p)->ext_flags); \
176      (hdr_p)->keyframes = LE_TO_BE_16((hdr_p)->keyframes); \
177      (hdr_p)->totalframes = LE_TO_BE_16((hdr_p)->totalframes); \
178      (hdr_p)->req_memory = LE_TO_BE_32((hdr_p)->req_memory); \
179      (hdr_p)->max_regions = LE_TO_BE_16((hdr_p)->max_regions); \
180      (hdr_p)->transp_num = LE_TO_BE_16((hdr_p)->transp_num); \
181      (hdr_p)->oframe1 = LE_TO_BE_32((hdr_p)->oframe1); \
182      (hdr_p)->oframe2 = LE_TO_BE_32((hdr_p)->oframe2); \
183     } while(0)
184 #else
185
186 #define LE_TO_BE_16(i16) ((i16))
187 #define LE_TO_BE_32(i32) ((i32))
188
189 #define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p)
190 #define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p)
191 #define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p)
192 #define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p)
193 #define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p)
194 #define FLX_HDR_FIX_ENDIANNESS(hdr_p)
195
196 #endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
197
198 G_END_DECLS
199
200 #endif /* __GST_FLX_FMT_H__ */