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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
/*
* libmedia-thumbnail
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Hyunjun Ko <zzoon.ko@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _IMGCODEC_COMMON_H_
#define _IMGCODEC_COMMON_H_
#include "img-codec-config.h"
#include "img-codec-osal.h"
#include <stdio.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
//////////////////////////////////////////////////////////////
/* Maximum Image File Size Supported */
#define IMG_MAX_IMAGE_FILE_SIZE (10 * 1024 * 1024)
//////////////////////////////////////////////////////////////
#define ImgDebug(type, fmt, arg...) \
do { \
fprintf(stderr, "[Media-SVC]"fmt, ##arg); \
}while(0)
#if 1
#define SysRequireEx(expr, retValue) \
if (!(expr)) { \
fprintf(stderr, "[Media-SVC][%s] INVALID_PARAM (%d lines in %s)\n",__FUNCTION__, __LINE__, __FILE__); \
return (retValue); \
}
#define SysDebug(X) ImgDebug X
#define SysAssert(expr)
#else
#define SysRequireEx(expr, retValue)
#define SysDebug(expr, retValue)
#define SysAssert(expr)
#endif
//////////////////////////////////////////////////////////////
typedef enum
{
IMG_INFO_DECODING_FAIL = 0,
IMG_INFO_DECODING_SUCCESS = 1,
IMG_INFO_AGIF_LAST_FRAME = 2,
IMG_INFO_TOO_BIG_FILE_SIZE = -1,
IMG_INFO_TOO_LARGE_SCALE = -2,
IMG_INFO_TOO_BIG_PROGRESSIVE= -3,
IMG_INFO_UNKNOWN_FORMAT = -4,
IMG_INFO_FILE_ERR = -5,
IMG_INFO_MEM_ALLOC_FAIL = -6
}ImgFastCodecInfo;
typedef enum
{
IMG_CODEC_UNKNOWN_TYPE = -2,
IMG_CODEC_BIG_PROGRESSIVE_JPEG = -1,
IMG_CODEC_NONE = 0,
IMG_CODEC_GIF = ( 1 << 0),
IMG_CODEC_PNG = ( 1 << 1),
IMG_CODEC_WBMP = ( 1 << 2),
IMG_CODEC_JPEG = ( 1 << 3),
IMG_CODEC_BMP = ( 1 << 4),
IMG_CODEC_TIF = ( 1 << 5),
IMG_CODEC_AGIF = ( 1 << 6),
IMG_CODEC_PROGRESSIVE_JPEG = ( 1 << 7),
IMG_CODEC_DRM = ( 1 << 8),
} ImgCodecType;
typedef enum inputFlag
{
IMG_RGB_888_OUTPUT = 0x0001,
IMG_RGB_OUTPUT = 0x0002,
IMG_YUV_OUTPUT = 0x0005
}ImgInputFlag;
typedef enum resize
{
/* During resizing aspect ratio will be maintained */
IMG_RESIZE_MAINTAIN_ASPECT_RATIO = 0x0001,
IMG_RESIZE = 0x0002
} ImgResizeInput;
typedef struct tagImgImageInfo
{
unsigned int width;
unsigned int height;
unsigned int numberOfFrame;
unsigned int delay; //deprecated.
unsigned int bOrientation; //deprecated.
}ImgImageInfo;
typedef struct tagImgBitmap
{
int width;
int height;
UCHAR bitsPerPixel; /* For TIF it should be 8 or 4 or 1 always
* If coming directly from camera and
* bitsperpixel is 16 then its assumed as 8
* & color type as RGBC and compression
* type as NO_COMP and encode it.
*/
void *pBits;
BOOL bChromaKeyFlag; /* Flag to indicate chroma key
* Default: FALSE
*/
ULONG chromaKey; /* This is the colour which needs to be (or is) transparent.
* This colour will be in 5, 5, 5 RGB format as below.
* First 16 MS Bits 0, R (5), G (5), 0 (1), B (5)
*/
UCHAR disposal; /* Disposal action to take during
* display of current flag
* Default: 0
*/
USHORT delay; /* Delay before display of
* next frame. Default: 0
*/
BOOL inputFlag; /* User input required befflag used
* Default: FALSE
*/
BOOL interlace; /* Interlace indicator flag
* Default: FALSE
*/
BYTE *pLocalColorMap;/* Local color palette pointer
* Default: NULL
*/
/* For TIF :Should be given if PALETTE color type.
*/
USHORT localColorMapSize;
/* Local color palette size */
/* In TIF: Should be given if PALETTE color type.
*/
void *pAlphaChannel; /* An alpha channel, representing transparency
* information on a per-pixel basis
*/
BYTE colorType ; /* Indicates the color type of image. It can be
* GRAY, COLOR, PALETTED, GRAY_WITH_ALPHA_CHANNEL or
* COLOR_WITH_ALPHA_CHANNEL
*/
/* For TIF: IT could be TIF_COLORTYPE_BILEVEL,
* TIF_COLORTYPE_GRAY ,TIF_COLORTYPE_RGB,
* TIF_COLORTYPE_PALETTE or
* TIF_COLORTYPE_RGBPALETTE.
*/
BYTE filter ; /* Type of filter to apply. Could be one of NONE,
* SUB, UP, AVERAGE or PAETH
*/
BYTE compressionMethod ; /* Type of compression in zLib to apply. Could be
* one of NONE, FIXED or DYANMIC
*/
/* For TIF : IT could be TIF_COMP_NOCOMP ,
* TIF_COMP_PACKBIT or TIF_COMP_HUFFMAN (only for bilevel)
*/
UCHAR colorConversion; /* Indicates whether color conversion has to
* be done or not
*/
/* For TIF :This represents white is zero or
* black is zero in case of bilevel & gray.
*/
UCHAR downSampling; /* Indicates whether down sampling needs to
* be done or not
*/
UCHAR downSamplingMethod[3];
/* Down sampling offsets for every component. Possible
* combinations are
* 1, 1, 1
* 1, 2, 1
* 1, 2, 2
*/
} ImgBitmap;
typedef struct tagImgCodecColor
{
UINT16 red;
UINT16 green;
UINT16 blue;
} ImgCodecColor;
typedef struct
{
int width, height, bpp;
BOOL tRNSFlag;
ImgCodecColor tRNSColor;
BOOL bKGDFlag;
ImgCodecColor bKGDColor;
BOOL AlphaChannelFlag;
unsigned short *pAlphaChannel;
} ImgTrnsInfo;
typedef struct tagImgBitmapElem ImgBitmapElem;
struct tagImgBitmapElem
{
int x;
int y;
ImgBitmap *pbmBitmap;
ImgBitmapElem *pNext;
};
typedef struct gifDecode ImgGIFFrame ;
typedef struct tagImgImage
{
int dataSize; /* Holds the total number of bytes required
* to hold the image
*/
int width;
int height;
USHORT flag; /* This contains flags as defined
* in ImgCodecFlagType
*/
ULONG backGroundColor; /* The backgroundColor specifies a default background
* color to present the image against.
* Note that viewers are not bound to honor this color.
* A viewer can choose to use a different background.
*/
BYTE *pGlobalColorMap; /* Global color palette pointer
* Default: NULL
*/
USHORT globalColorMapSize; /* Local color palette size */
ULONG gamma; /* The value is encoded as a 4-byte unsigned integer,
* representing gamma times 100000. For example, a
* gamma of 0.45 would be stored as the integer 45000.
*/
int bitmapCount; /* This will hold the number of bitmaps in the
* ImgImage structure
*/
BYTE function ; /* This will be set as TRUE if this structure is
* used for encoder
*/
ImgBitmapElem *pHead;
ImgBitmapElem *pTail;
ULONG decodedSize ; /* 1 => Same as in the encoded stream
* 0 => Resize to QQVGA if size is more
* than 176 x 144
*/
BOOL memAllocEx ; /* TRUE => MemAllocEx is used,
* FALSE => MemAlloc is used
*/
USHORT loopCount ; /* This will contain the number of times to repeat
* the animation
*/
BOOL bLoopCount ; /* If GIF LoopCount is present then this will be
* TRUE, otherwise it will be false
*/
ImgGIFFrame *pGifFrame ; /* Stores the intermediate GIF Frame */
ImgInputFlag inputFlag;
ImgResizeInput resizeMethod ;
/* Flag to identify whether image is AGIF or not */
BOOL bAGIFImage ;
unsigned char *pEncodedData ;
INT32 cFileSize ;
BOOL bFirstFrame ;
BOOL bReservedMemoryFlag;
unsigned int offset ;
} ImgImage;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // _IMGCODEC_COMMON_H_
|