|
1 #ifndef AVCODEC_H |
|
2 #define AVCODEC_H |
|
3 |
|
4 /** |
|
5 * @file avcodec.h |
|
6 * external api header. |
|
7 */ |
|
8 |
|
9 |
|
10 #ifdef __cplusplus |
|
11 extern "C" { |
|
12 #endif |
|
13 |
|
14 //#include "_stdint.h" |
|
15 |
|
16 #include <sys/types.h> /* size_t */ |
|
17 |
|
18 #define FFMPEG_VERSION_INT 0x000409 |
|
19 #define FFMPEG_VERSION "0.4.9-pre1" |
|
20 #define LIBAVCODEC_BUILD 4728 |
|
21 |
|
22 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT |
|
23 #define LIBAVCODEC_VERSION FFMPEG_VERSION |
|
24 |
|
25 #define AV_STRINGIFY(s) AV_TOSTRING(s) |
|
26 #define AV_TOSTRING(s) #s |
|
27 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD) |
|
28 |
|
29 enum CodecType { |
|
30 CODEC_TYPE_UNKNOWN = -1, |
|
31 CODEC_TYPE_VIDEO, |
|
32 CODEC_TYPE_AUDIO, |
|
33 CODEC_TYPE_DATA, |
|
34 }; |
|
35 |
|
36 /* |
|
37 * Pixel format. Notes: |
|
38 * |
|
39 * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA |
|
40 * color is put together as: |
|
41 * (A << 24) | (R << 16) | (G << 8) | B |
|
42 * This is stored as BGRA on little endian CPU architectures and ARGB on |
|
43 * big endian CPUs. |
|
44 * |
|
45 * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized |
|
46 * image data is stored in AVFrame.data[0]. The palette is transported in |
|
47 * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is |
|
48 * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is |
|
49 * also endian-specific). Note also that the individual RGB palette |
|
50 * components stored in AVFrame.data[1] should be in the range 0..255. |
|
51 * This is important as many custom PAL8 video codecs that were designed |
|
52 * to run on the IBM VGA graphics adapter use 6-bit palette components. |
|
53 */ |
|
54 enum PixelFormat { |
|
55 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) (I420) |
|
56 PIX_FMT_YVU420P, ///< Planar YUV 4:2:0 (1 Cb & Cr sample per 2x2 Y samples) (YV12) |
|
57 PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr |
|
58 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB... |
|
59 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR... |
|
60 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples) |
|
61 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples) |
|
62 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness |
|
63 PIX_FMT_BGRA32, ///< Packed pixel, 4 bytes per pixel, ARGBARGB... |
|
64 PIX_FMT_ARGB32, ///< Packed pixel, 4 bytes per pixel, ABGRABGR..., stored in cpu endianness |
|
65 PIX_FMT_ABGR32, ///< Packed pixel, 4 bytes per pixel, RGBARGBA... |
|
66 PIX_FMT_RGB32, ///< Packed pixel, 4 bytes per pixel, BGRxBGRx..., stored in cpu endianness |
|
67 PIX_FMT_xRGB32, ///< Packed pixel, 4 bytes per pixel, xBGRxBGR..., stored in cpu endianness |
|
68 PIX_FMT_BGR32, ///< Packed pixel, 4 bytes per pixel, xRGBxRGB... |
|
69 PIX_FMT_BGRx32, ///< Packed pixel, 4 bytes per pixel, RGBxRGBx... |
|
70 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples) |
|
71 PIX_FMT_YVU410P, ///< Planar YVU 4:1:0 (1 Cr & Cb sample per 4x4 Y samples) |
|
72 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples) |
|
73 PIX_FMT_RGB565, ///< always stored in cpu endianness |
|
74 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1 |
|
75 PIX_FMT_GRAY8, |
|
76 PIX_FMT_MONOWHITE, ///< 0 is white |
|
77 PIX_FMT_MONOBLACK, ///< 0 is black |
|
78 PIX_FMT_PAL8, ///< 8 bit with RGBA palette |
|
79 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg) |
|
80 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg) |
|
81 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg) |
|
82 PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h) |
|
83 PIX_FMT_XVMC_MPEG2_IDCT, |
|
84 PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1 |
|
85 PIX_FMT_UYVY411, ///< Packed pixel, Cb Y0 Y1 Cr Y2 Y3 |
|
86 |
|
87 PIX_FMT_AYUV4444, ///< Packed pixel, A0 Y0 Cb Cr |
|
88 PIX_FMT_NB |
|
89 }; |
|
90 |
|
91 /* currently unused, may be used if 24/32 bits samples ever supported */ |
|
92 enum SampleFormat { |
|
93 SAMPLE_FMT_S16 = 0, ///< signed 16 bits |
|
94 }; |
|
95 |
|
96 /* thomas: extracted from imgconvert.c since it's also used in |
|
97 * gstffmpegcodecmap.c */ |
|
98 |
|
99 /* start of extract */ |
|
100 |
|
101 #define FF_COLOR_RGB 0 /* RGB color space */ |
|
102 #define FF_COLOR_GRAY 1 /* gray color space */ |
|
103 #define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ |
|
104 #define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ |
|
105 |
|
106 #define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */ |
|
107 #define FF_PIXEL_PACKED 1 /* only one components containing all the channels */ |
|
108 #define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */ |
|
109 |
|
110 typedef struct PixFmtInfo |
|
111 { |
|
112 enum PixelFormat format; |
|
113 const char *name; |
|
114 uint8_t nb_channels; /* number of channels (including alpha) */ |
|
115 uint8_t color_type; /* color type (see FF_COLOR_xxx constants) */ |
|
116 uint8_t pixel_type; /* pixel storage type (see FF_PIXEL_xxx constants) */ |
|
117 uint8_t is_alpha:1; /* true if alpha can be specified */ |
|
118 uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */ |
|
119 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */ |
|
120 uint8_t depth; /* bit depth of the color components */ |
|
121 } PixFmtInfo; |
|
122 #ifdef __SYMBIAN32__ |
|
123 IMPORT_C |
|
124 #endif |
|
125 |
|
126 |
|
127 PixFmtInfo * get_pix_fmt_info (enum PixelFormat format); |
|
128 /* end of extract */ |
|
129 |
|
130 /** |
|
131 * main external api structure. |
|
132 */ |
|
133 typedef struct AVCodecContext { |
|
134 /* video only */ |
|
135 /** |
|
136 * frames per sec multiplied by frame_rate_base. |
|
137 * for variable fps this is the precission, so if the timestamps |
|
138 * can be specified in msec precssion then this is 1000*frame_rate_base |
|
139 * - encoding: MUST be set by user |
|
140 * - decoding: set by lavc. 0 or the frame_rate if available |
|
141 */ |
|
142 int frame_rate; |
|
143 |
|
144 /** |
|
145 * frame_rate_base. |
|
146 * for variable fps this is 1 |
|
147 * - encoding: set by user. |
|
148 * - decoding: set by lavc. |
|
149 */ |
|
150 |
|
151 int frame_rate_base; |
|
152 /** |
|
153 * picture width / height. |
|
154 * - encoding: MUST be set by user. |
|
155 * - decoding: set by lavc. |
|
156 * Note, for compatibility its possible to set this instead of |
|
157 * coded_width/height before decoding |
|
158 */ |
|
159 int width, height; |
|
160 |
|
161 /** |
|
162 * pixel format, see PIX_FMT_xxx. |
|
163 * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt |
|
164 * conversion is in order. This only works for |
|
165 * codecs with one supported pix_fmt, we should |
|
166 * do something for a generic case as well. |
|
167 * - decoding: set by lavc. |
|
168 */ |
|
169 enum PixelFormat pix_fmt; |
|
170 |
|
171 /* audio only */ |
|
172 int sample_rate; ///< samples per sec |
|
173 int channels; |
|
174 int sample_fmt; ///< sample format, currenly unused |
|
175 |
|
176 /** |
|
177 * Palette control structure |
|
178 * - encoding: ??? (no palette-enabled encoder yet) |
|
179 * - decoding: set by user. |
|
180 */ |
|
181 struct AVPaletteControl *palctrl; |
|
182 } AVCodecContext; |
|
183 |
|
184 /** |
|
185 * four components are given, that's all. |
|
186 * the last component is alpha |
|
187 */ |
|
188 typedef struct AVPicture { |
|
189 uint8_t *data[4]; |
|
190 int linesize[4]; ///< number of bytes per line |
|
191 } AVPicture; |
|
192 |
|
193 /** |
|
194 * AVPaletteControl |
|
195 * This structure defines a method for communicating palette changes |
|
196 * between and demuxer and a decoder. |
|
197 */ |
|
198 #define AVPALETTE_SIZE 1024 |
|
199 #define AVPALETTE_COUNT 256 |
|
200 typedef struct AVPaletteControl { |
|
201 |
|
202 /* demuxer sets this to 1 to indicate the palette has changed; |
|
203 * decoder resets to 0 */ |
|
204 int palette_changed; |
|
205 |
|
206 /* 4-byte ARGB palette entries, stored in native byte order; note that |
|
207 * the individual palette components should be on a 8-bit scale; if |
|
208 * the palette data comes from a IBM VGA native format, the component |
|
209 * data is probably 6 bits in size and needs to be scaled */ |
|
210 unsigned int palette[AVPALETTE_COUNT]; |
|
211 |
|
212 } AVPaletteControl; |
|
213 #ifdef __SYMBIAN32__ |
|
214 IMPORT_C |
|
215 #endif |
|
216 |
|
217 |
|
218 int avpicture_get_size(int pix_fmt, int width, int height); |
|
219 #ifdef __SYMBIAN32__ |
|
220 IMPORT_C |
|
221 #endif |
|
222 |
|
223 |
|
224 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift); |
|
225 #ifdef __SYMBIAN32__ |
|
226 IMPORT_C |
|
227 #endif |
|
228 |
|
229 const char *avcodec_get_pix_fmt_name(int pix_fmt); |
|
230 void avcodec_set_dimensions(AVCodecContext *s, int width, int height); |
|
231 #ifdef __SYMBIAN32__ |
|
232 IMPORT_C |
|
233 #endif |
|
234 |
|
235 enum PixelFormat avcodec_get_pix_fmt(const char* name); |
|
236 |
|
237 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */ |
|
238 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */ |
|
239 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */ |
|
240 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */ |
|
241 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */ |
|
242 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */ |
|
243 #ifdef __SYMBIAN32__ |
|
244 IMPORT_C |
|
245 #endif |
|
246 |
|
247 |
|
248 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, |
|
249 int has_alpha); |
|
250 #ifdef __SYMBIAN32__ |
|
251 IMPORT_C |
|
252 #endif |
|
253 |
|
254 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt, |
|
255 int has_alpha, int *loss_ptr); |
|
256 |
|
257 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ |
|
258 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ |
|
259 #ifdef __SYMBIAN32__ |
|
260 IMPORT_C |
|
261 #endif |
|
262 |
|
263 int img_get_alpha_info(const AVPicture *src, |
|
264 int pix_fmt, int width, int height); |
|
265 |
|
266 /* convert among pixel formats */ |
|
267 #ifdef __SYMBIAN32__ |
|
268 IMPORT_C |
|
269 #endif |
|
270 |
|
271 int img_convert(AVPicture *dst, int dst_pix_fmt, |
|
272 const AVPicture *src, int pix_fmt, |
|
273 int width, int height); |
|
274 #ifdef __SYMBIAN32__ |
|
275 IMPORT_C |
|
276 #endif |
|
277 |
|
278 |
|
279 void avcodec_init(void); |
|
280 #ifdef __SYMBIAN32__ |
|
281 IMPORT_C |
|
282 #endif |
|
283 |
|
284 |
|
285 void avcodec_get_context_defaults(AVCodecContext *s); |
|
286 #ifdef __SYMBIAN32__ |
|
287 IMPORT_C |
|
288 #endif |
|
289 |
|
290 AVCodecContext *avcodec_alloc_context(void); |
|
291 |
|
292 /* memory */ |
|
293 #ifdef __SYMBIAN32__ |
|
294 IMPORT_C |
|
295 #endif |
|
296 |
|
297 void *av_malloc(unsigned int size); |
|
298 #ifdef __SYMBIAN32__ |
|
299 IMPORT_C |
|
300 #endif |
|
301 |
|
302 void *av_mallocz(unsigned int size); |
|
303 #ifdef __SYMBIAN32__ |
|
304 IMPORT_C |
|
305 #endif |
|
306 |
|
307 void *av_realloc(void *ptr, unsigned int size); |
|
308 #ifdef __SYMBIAN32__ |
|
309 IMPORT_C |
|
310 #endif |
|
311 |
|
312 void av_free(void *ptr); |
|
313 #ifdef __SYMBIAN32__ |
|
314 IMPORT_C |
|
315 #endif |
|
316 |
|
317 char *av_strdup(const char *s); |
|
318 #ifdef __SYMBIAN32__ |
|
319 IMPORT_C |
|
320 #endif |
|
321 |
|
322 void av_freep(void *ptr); |
|
323 #ifdef __SYMBIAN32__ |
|
324 IMPORT_C |
|
325 #endif |
|
326 |
|
327 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); |
|
328 /* for static data only */ |
|
329 /* call av_free_static to release all staticaly allocated tables */ |
|
330 #ifdef __SYMBIAN32__ |
|
331 IMPORT_C |
|
332 #endif |
|
333 |
|
334 void av_free_static(void); |
|
335 #ifdef __SYMBIAN32__ |
|
336 IMPORT_C |
|
337 #endif |
|
338 |
|
339 void *av_mallocz_static(unsigned int size); |
|
340 |
|
341 /* endian macros */ |
|
342 #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32) |
|
343 #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) |
|
344 #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ |
|
345 (((uint8_t*)(x))[1] << 16) | \ |
|
346 (((uint8_t*)(x))[2] << 8) | \ |
|
347 ((uint8_t*)(x))[3]) |
|
348 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
|
349 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ |
|
350 (((uint8_t*)(x))[2] << 16) | \ |
|
351 (((uint8_t*)(x))[1] << 8) | \ |
|
352 ((uint8_t*)(x))[0]) |
|
353 #endif |
|
354 |
|
355 #ifdef __cplusplus |
|
356 } |
|
357 #endif |
|
358 |
|
359 #endif /* AVCODEC_H */ |