878
|
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 "common.h"
|
|
15 #include <sys/types.h> /* size_t */
|
|
16
|
|
17 #define FFMPEG_VERSION_INT 0x000408
|
|
18 #define FFMPEG_VERSION "0.4.8"
|
|
19 #define LIBAVCODEC_BUILD 4701
|
|
20
|
|
21 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
|
|
22 #define LIBAVCODEC_VERSION FFMPEG_VERSION
|
|
23
|
|
24 #define AV_STRINGIFY(s) AV_TOSTRING(s)
|
|
25 #define AV_TOSTRING(s) #s
|
|
26 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
|
|
27
|
|
28 enum CodecID {
|
|
29 CODEC_ID_NONE,
|
|
30 CODEC_ID_WMAV1,
|
|
31 CODEC_ID_WMAV2,
|
|
32
|
|
33 /* various pcm "codecs" */
|
|
34 CODEC_ID_PCM_S16LE,
|
|
35 CODEC_ID_PCM_S16BE,
|
|
36 CODEC_ID_PCM_U16LE,
|
|
37 CODEC_ID_PCM_U16BE,
|
|
38 CODEC_ID_PCM_S8,
|
|
39 CODEC_ID_PCM_U8,
|
|
40 CODEC_ID_PCM_MULAW,
|
|
41 CODEC_ID_PCM_ALAW,
|
|
42 };
|
|
43
|
|
44
|
|
45 enum CodecType {
|
|
46 CODEC_TYPE_UNKNOWN = -1,
|
|
47 CODEC_TYPE_AUDIO,
|
|
48 CODEC_TYPE_DATA,
|
|
49 };
|
|
50
|
|
51 enum PixelFormat {
|
|
52 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
|
|
53 PIX_FMT_YUV422,
|
|
54 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
|
|
55 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
|
|
56 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
|
|
57 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
|
|
58 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
|
|
59 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
|
|
60 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
|
|
61 PIX_FMT_RGB565, ///< always stored in cpu endianness
|
|
62 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
|
|
63 PIX_FMT_GRAY8,
|
|
64 PIX_FMT_MONOWHITE, ///< 0 is white
|
|
65 PIX_FMT_MONOBLACK, ///< 0 is black
|
|
66 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
|
|
67 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
|
|
68 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
|
|
69 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
|
|
70 PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
|
|
71 PIX_FMT_XVMC_MPEG2_IDCT,
|
|
72 PIX_FMT_NB,
|
|
73 };
|
|
74
|
|
75 /* currently unused, may be used if 24/32 bits samples ever supported */
|
|
76 enum SampleFormat {
|
|
77 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
|
|
78 };
|
|
79
|
|
80 /* in bytes */
|
|
81 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
|
|
82
|
|
83 /**
|
|
84 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
|
|
85 * this is mainly needed because some optimized bitstream readers read
|
|
86 * 32 or 64 bit at once and could read over the end<br>
|
|
87 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
|
|
88 * MPEG bitstreams could cause overread and segfault
|
|
89 */
|
|
90 #define FF_INPUT_BUFFER_PADDING_SIZE 8
|
|
91
|
|
92 /* motion estimation type, EPZS by default */
|
|
93 enum Motion_Est_ID {
|
|
94 ME_ZERO = 1,
|
|
95 ME_FULL,
|
|
96 ME_LOG,
|
|
97 ME_PHODS,
|
|
98 ME_EPZS,
|
|
99 ME_X1
|
|
100 };
|
|
101
|
|
102 typedef struct RcOverride{
|
|
103 int start_frame;
|
|
104 int end_frame;
|
|
105 int qscale; // if this is 0 then quality_factor will be used instead
|
|
106 float quality_factor;
|
|
107 } RcOverride;
|
|
108
|
|
109 /* only for ME compatiblity with old apps */
|
|
110 extern int motion_estimation_method;
|
|
111
|
|
112 #define FF_MAX_B_FRAMES 8
|
|
113
|
|
114 /* encoding support
|
|
115 these flags can be passed in AVCodecContext.flags before initing
|
|
116 Note: note not everything is supported yet
|
|
117 */
|
|
118
|
|
119 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
|
|
120 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
|
|
121 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
|
|
122 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
|
|
123 #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
|
|
124 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
|
|
125 /* parent program gurantees that the input for b-frame containing streams is not written to
|
|
126 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
|
|
127 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
|
|
128 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
|
|
129 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
|
|
130 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
|
|
131 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
|
|
132 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
|
|
133 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
|
|
134 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
|
|
135 of only at frame boundaries */
|
|
136 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
|
|
137 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
|
|
138 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
|
|
139 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
|
|
140 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
|
|
141 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
|
|
142 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
|
|
143 /* Fx : Flag for h263+ extra options */
|
|
144 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
|
|
145 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
|
|
146 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
|
|
147 #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
|
|
148 #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
|
|
149 #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
|
|
150 #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
|
|
151 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
|
|
152 #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
|
|
153 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
|
|
154 #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
|
|
155 #define CODEC_FLAG_CLOSED_GOP 0x80000000
|
|
156 /* Unsupported options :
|
|
157 * Syntax Arithmetic coding (SAC)
|
|
158 * Reference Picture Selection
|
|
159 * Independant Segment Decoding */
|
|
160 /* /Fx */
|
|
161 /* codec capabilities */
|
|
162
|
|
163 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
|
|
164 /**
|
|
165 * Codec uses get_buffer() for allocating buffers.
|
|
166 * direct rendering method 1
|
|
167 */
|
|
168 #define CODEC_CAP_DR1 0x0002
|
|
169 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
|
|
170 used */
|
|
171 #define CODEC_CAP_PARSE_ONLY 0x0004
|
|
172 #define CODEC_CAP_TRUNCATED 0x0008
|
|
173
|
|
174 //the following defines might change, so dont expect compatibility if u use them
|
|
175 #define MB_TYPE_INTRA4x4 0x0001
|
|
176 #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
|
|
177 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
|
|
178 #define MB_TYPE_16x16 0x0008
|
|
179 #define MB_TYPE_16x8 0x0010
|
|
180 #define MB_TYPE_8x16 0x0020
|
|
181 #define MB_TYPE_8x8 0x0040
|
|
182 #define MB_TYPE_INTERLACED 0x0080
|
|
183 #define MB_TYPE_DIRECT2 0x0100 //FIXME
|
|
184 #define MB_TYPE_ACPRED 0x0200
|
|
185 #define MB_TYPE_GMC 0x0400
|
|
186 #define MB_TYPE_SKIP 0x0800
|
|
187 #define MB_TYPE_P0L0 0x1000
|
|
188 #define MB_TYPE_P1L0 0x2000
|
|
189 #define MB_TYPE_P0L1 0x4000
|
|
190 #define MB_TYPE_P1L1 0x8000
|
|
191 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
|
|
192 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
|
|
193 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
|
|
194 #define MB_TYPE_QUANT 0x00010000
|
|
195 #define MB_TYPE_CBP 0x00020000
|
|
196 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
|
|
197
|
|
198 /**
|
|
199 * Pan Scan area.
|
|
200 * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
|
|
201 */
|
|
202 typedef struct AVPanScan{
|
|
203 /**
|
|
204 * id.
|
|
205 * - encoding: set by user.
|
|
206 * - decoding: set by lavc
|
|
207 */
|
|
208 int id;
|
|
209
|
|
210 /**
|
|
211 * width and height in 1/16 pel
|
|
212 * - encoding: set by user.
|
|
213 * - decoding: set by lavc
|
|
214 */
|
|
215 int width;
|
|
216 int height;
|
|
217
|
|
218 /**
|
|
219 * position of the top left corner in 1/16 pel for up to 3 fields/frames.
|
|
220 * - encoding: set by user.
|
|
221 * - decoding: set by lavc
|
|
222 */
|
|
223 int16_t position[3][2];
|
|
224 }AVPanScan;
|
|
225
|
|
226 #define FF_COMMON_FRAME \
|
|
227 /**\
|
|
228 * pointer to the picture planes.\
|
|
229 * this might be different from the first allocated byte\
|
|
230 * - encoding: \
|
|
231 * - decoding: \
|
|
232 */\
|
|
233 uint8_t *data[4];\
|
|
234 int linesize[4];\
|
|
235 /**\
|
|
236 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
|
|
237 * this isnt used by lavc unless the default get/release_buffer() is used\
|
|
238 * - encoding: \
|
|
239 * - decoding: \
|
|
240 */\
|
|
241 uint8_t *base[4];\
|
|
242 /**\
|
|
243 * 1 -> keyframe, 0-> not\
|
|
244 * - encoding: set by lavc\
|
|
245 * - decoding: set by lavc\
|
|
246 */\
|
|
247 int key_frame;\
|
|
248 \
|
|
249 /**\
|
|
250 * picture type of the frame, see ?_TYPE below.\
|
|
251 * - encoding: set by lavc for coded_picture (and set by user for input)\
|
|
252 * - decoding: set by lavc\
|
|
253 */\
|
|
254 int pict_type;\
|
|
255 \
|
|
256 /**\
|
|
257 * presentation timestamp in micro seconds (time when frame should be shown to user)\
|
|
258 * if 0 then the frame_rate will be used as reference\
|
|
259 * - encoding: MUST be set by user\
|
|
260 * - decoding: set by lavc\
|
|
261 */\
|
|
262 int64_t pts;\
|
|
263 \
|
|
264 /**\
|
|
265 * picture number in bitstream order.\
|
|
266 * - encoding: set by\
|
|
267 * - decoding: set by lavc\
|
|
268 */\
|
|
269 int coded_picture_number;\
|
|
270 /**\
|
|
271 * picture number in display order.\
|
|
272 * - encoding: set by\
|
|
273 * - decoding: set by lavc\
|
|
274 */\
|
|
275 int display_picture_number;\
|
|
276 \
|
|
277 /**\
|
|
278 * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
|
|
279 * - encoding: set by lavc for coded_picture (and set by user for input)\
|
|
280 * - decoding: set by lavc\
|
|
281 */\
|
|
282 int quality; \
|
|
283 \
|
|
284 /**\
|
|
285 * buffer age (1->was last buffer and dint change, 2->..., ...).\
|
|
286 * set to INT_MAX if the buffer has not been used yet \
|
|
287 * - encoding: unused\
|
|
288 * - decoding: MUST be set by get_buffer()\
|
|
289 */\
|
|
290 int age;\
|
|
291 \
|
|
292 /**\
|
|
293 * is this picture used as reference\
|
|
294 * - encoding: unused\
|
|
295 * - decoding: set by lavc (before get_buffer() call))\
|
|
296 */\
|
|
297 int reference;\
|
|
298 \
|
|
299 /**\
|
|
300 * QP table\
|
|
301 * - encoding: unused\
|
|
302 * - decoding: set by lavc\
|
|
303 */\
|
|
304 int8_t *qscale_table;\
|
|
305 /**\
|
|
306 * QP store stride\
|
|
307 * - encoding: unused\
|
|
308 * - decoding: set by lavc\
|
|
309 */\
|
|
310 int qstride;\
|
|
311 \
|
|
312 /**\
|
|
313 * mbskip_table[mb]>=1 if MB didnt change\
|
|
314 * stride= mb_width = (width+15)>>4\
|
|
315 * - encoding: unused\
|
|
316 * - decoding: set by lavc\
|
|
317 */\
|
|
318 uint8_t *mbskip_table;\
|
|
319 \
|
|
320 /**\
|
|
321 * Motion vector table\
|
|
322 * - encoding: unused\
|
|
323 * - decoding: set by lavc\
|
|
324 */\
|
|
325 int16_t (*motion_val[2])[2];\
|
|
326 \
|
|
327 /**\
|
|
328 * Macroblock type table\
|
|
329 * mb_type_base + mb_width + 2\
|
|
330 * - encoding: unused\
|
|
331 * - decoding: set by lavc\
|
|
332 */\
|
|
333 uint32_t *mb_type;\
|
|
334 \
|
|
335 /**\
|
|
336 * Macroblock size: (0->16x16, 1->8x8, 2-> 4x4, 3-> 2x2)\
|
|
337 * - encoding: unused\
|
|
338 * - decoding: set by lavc\
|
|
339 */\
|
|
340 uint8_t motion_subsample_log2;\
|
|
341 \
|
|
342 /**\
|
|
343 * for some private data of the user\
|
|
344 * - encoding: unused\
|
|
345 * - decoding: set by user\
|
|
346 */\
|
|
347 void *opaque;\
|
|
348 \
|
|
349 /**\
|
|
350 * error\
|
|
351 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
|
|
352 * - decoding: unused\
|
|
353 */\
|
|
354 uint64_t error[4];\
|
|
355 \
|
|
356 /**\
|
|
357 * type of the buffer (to keep track of who has to dealloc data[*])\
|
|
358 * - encoding: set by the one who allocs it\
|
|
359 * - decoding: set by the one who allocs it\
|
|
360 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
|
|
361 */\
|
|
362 int type;\
|
|
363 \
|
|
364 /**\
|
|
365 * when decoding, this signal how much the picture must be delayed.\
|
|
366 * extra_delay = repeat_pict / (2*fps)\
|
|
367 * - encoding: unused\
|
|
368 * - decoding: set by lavc\
|
|
369 */\
|
|
370 int repeat_pict;\
|
|
371 \
|
|
372 /**\
|
|
373 * \
|
|
374 */\
|
|
375 int qscale_type;\
|
|
376 \
|
|
377 /**\
|
|
378 * The content of the picture is interlaced.\
|
|
379 * - encoding: set by user\
|
|
380 * - decoding: set by lavc (default 0)\
|
|
381 */\
|
|
382 int interlaced_frame;\
|
|
383 \
|
|
384 /**\
|
|
385 * if the content is interlaced, is top field displayed first.\
|
|
386 * - encoding: set by user\
|
|
387 * - decoding: set by lavc\
|
|
388 */\
|
|
389 int top_field_first;\
|
|
390 \
|
|
391 /**\
|
|
392 * Pan scan.\
|
|
393 * - encoding: set by user\
|
|
394 * - decoding: set by lavc\
|
|
395 */\
|
|
396 AVPanScan *pan_scan;\
|
|
397 \
|
|
398 /**\
|
|
399 * tell user application that palette has changed from previous frame.\
|
|
400 * - encoding: ??? (no palette-enabled encoder yet)\
|
|
401 * - decoding: set by lavc (default 0)\
|
|
402 */\
|
|
403 int palette_has_changed;\
|
|
404 \
|
|
405 /**\
|
|
406 * Codec suggestion on buffer type if != 0\
|
|
407 * - encoding: unused\
|
|
408 * - decoding: set by lavc (before get_buffer() call))\
|
|
409 */\
|
|
410 int buffer_hints;\
|
|
411
|
|
412 #define FF_QSCALE_TYPE_MPEG1 0
|
|
413 #define FF_QSCALE_TYPE_MPEG2 1
|
|
414
|
|
415 #define FF_BUFFER_TYPE_INTERNAL 1
|
|
416 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
|
|
417 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base)
|
|
418 #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
|
|
419
|
|
420
|
|
421 #define FF_I_TYPE 1 // Intra
|
|
422 #define FF_P_TYPE 2 // Predicted
|
|
423 #define FF_B_TYPE 3 // Bi-dir predicted
|
|
424 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
|
|
425 #define FF_SI_TYPE 5
|
|
426 #define FF_SP_TYPE 6
|
|
427
|
|
428 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
|
|
429 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
|
|
430 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
|
|
431 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
|
|
432
|
|
433 /**
|
|
434 * Audio Video Frame.
|
|
435 */
|
|
436 typedef struct AVFrame {
|
|
437 FF_COMMON_FRAME
|
|
438 } AVFrame;
|
|
439
|
|
440 #define DEFAULT_FRAME_RATE_BASE 1001000
|
|
441
|
|
442 /**
|
|
443 * main external api structure.
|
|
444 */
|
|
445 typedef struct AVCodecContext {
|
|
446 /**
|
|
447 * the average bitrate.
|
|
448 * - encoding: set by user. unused for constant quantizer encoding
|
|
449 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
|
|
450 */
|
|
451 int bit_rate;
|
|
452
|
|
453 /**
|
|
454 * number of bits the bitstream is allowed to diverge from the reference.
|
|
455 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
|
|
456 * - encoding: set by user. unused for constant quantizer encoding
|
|
457 * - decoding: unused
|
|
458 */
|
|
459 int bit_rate_tolerance;
|
|
460
|
|
461 /**
|
|
462 * CODEC_FLAG_*.
|
|
463 * - encoding: set by user.
|
|
464 * - decoding: set by user.
|
|
465 */
|
|
466 int flags;
|
|
467
|
|
468 /**
|
|
469 * some codecs needs additionnal format info. It is stored here
|
|
470 * - encoding: set by user.
|
|
471 * - decoding: set by lavc. (FIXME is this ok?)
|
|
472 */
|
|
473 int sub_id;
|
|
474
|
|
475 /**
|
|
476 * motion estimation algorithm used for video coding.
|
|
477 * - encoding: MUST be set by user.
|
|
478 * - decoding: unused
|
|
479 */
|
|
480 int me_method;
|
|
481
|
|
482 /**
|
|
483 * some codecs need / can use extra-data like huffman tables.
|
|
484 * mjpeg: huffman tables
|
|
485 * rv10: additional flags
|
|
486 * mpeg4: global headers (they can be in the bitstream or here)
|
|
487 * - encoding: set/allocated/freed by lavc.
|
|
488 * - decoding: set/allocated/freed by user.
|
|
489 */
|
|
490 void *extradata;
|
|
491 int extradata_size;
|
|
492
|
|
493 /* video only */
|
|
494 /**
|
|
495 * frames per sec multiplied by frame_rate_base.
|
|
496 * for variable fps this is the precission, so if the timestamps
|
|
497 * can be specified in msec precssion then this is 1000*frame_rate_base
|
|
498 * - encoding: MUST be set by user
|
|
499 * - decoding: set by lavc. 0 or the frame_rate if available
|
|
500 */
|
|
501 int frame_rate;
|
|
502
|
|
503 /**
|
|
504 * width / height.
|
|
505 * - encoding: MUST be set by user.
|
|
506 * - decoding: set by user if known, codec should override / dynamically change if needed
|
|
507 */
|
|
508 int width, height;
|
|
509
|
|
510 #define FF_ASPECT_SQUARE 1
|
|
511 #define FF_ASPECT_4_3_625 2
|
|
512 #define FF_ASPECT_4_3_525 3
|
|
513 #define FF_ASPECT_16_9_625 4
|
|
514 #define FF_ASPECT_16_9_525 5
|
|
515 #define FF_ASPECT_EXTENDED 15
|
|
516
|
|
517 /**
|
|
518 * the number of pictures in a group of pitures, or 0 for intra_only.
|
|
519 * - encoding: set by user.
|
|
520 * - decoding: unused
|
|
521 */
|
|
522 int gop_size;
|
|
523
|
|
524 /**
|
|
525 * pixel format, see PIX_FMT_xxx.
|
|
526 * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
|
|
527 * conversion is in order. This only works for
|
|
528 * codecs with one supported pix_fmt, we should
|
|
529 * do something for a generic case as well.
|
|
530 * - decoding: set by lavc.
|
|
531 */
|
|
532 enum PixelFormat pix_fmt;
|
|
533
|
|
534 /**
|
|
535 * Frame rate emulation. If not zero lower layer (i.e. format handler)
|
|
536 * has to read frames at native frame rate.
|
|
537 * - encoding: set by user.
|
|
538 * - decoding: unused.
|
|
539 */
|
|
540 int rate_emu;
|
|
541
|
|
542 /**
|
|
543 * if non NULL, 'draw_horiz_band' is called by the libavcodec
|
|
544 * decoder to draw an horizontal band. It improve cache usage. Not
|
|
545 * all codecs can do that. You must check the codec capabilities
|
|
546 * before
|
|
547 * - encoding: unused
|
|
548 * - decoding: set by user.
|
|
549 * @param height the height of the slice
|
|
550 * @param y the y position of the slice
|
|
551 * @param type 1->top field, 2->bottom field, 3->frame
|
|
552 * @param offset offset into the AVFrame.data from which the slice should be read
|
|
553 */
|
|
554 void (*draw_horiz_band)(struct AVCodecContext *s,
|
|
555 const AVFrame *src, int offset[4],
|
|
556 int y, int type, int height);
|
|
557
|
|
558 /* audio only */
|
|
559 int sample_rate; ///< samples per sec
|
|
560 int channels;
|
|
561 int sample_fmt; ///< sample format, currenly unused
|
|
562
|
|
563 /* the following data should not be initialized */
|
|
564 int frame_size; ///< in samples, initialized when calling 'init'
|
|
565 int frame_number; ///< audio or video frame number
|
|
566 int real_pict_num; ///< returns the real picture number of previous encoded frame
|
|
567
|
|
568 /**
|
|
569 * number of frames the decoded output will be delayed relative to
|
|
570 * the encoded input.
|
|
571 * - encoding: set by lavc.
|
|
572 * - decoding: unused
|
|
573 */
|
|
574 int delay;
|
|
575
|
|
576 /* - encoding parameters */
|
|
577 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
|
|
578 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
|
|
579
|
|
580 /**
|
|
581 * minimum quantizer.
|
|
582 * - encoding: set by user.
|
|
583 * - decoding: unused
|
|
584 */
|
|
585 int qmin;
|
|
586
|
|
587 /**
|
|
588 * maximum quantizer.
|
|
589 * - encoding: set by user.
|
|
590 * - decoding: unused
|
|
591 */
|
|
592 int qmax;
|
|
593
|
|
594 /**
|
|
595 * maximum quantizer difference etween frames.
|
|
596 * - encoding: set by user.
|
|
597 * - decoding: unused
|
|
598 */
|
|
599 int max_qdiff;
|
|
600
|
|
601 /**
|
|
602 * maximum number of b frames between non b frames.
|
|
603 * note: the output will be delayed by max_b_frames+1 relative to the input
|
|
604 * - encoding: set by user.
|
|
605 * - decoding: unused
|
|
606 */
|
|
607 int max_b_frames;
|
|
608
|
|
609 /**
|
|
610 * qscale factor between ip and b frames.
|
|
611 * - encoding: set by user.
|
|
612 * - decoding: unused
|
|
613 */
|
|
614 float b_quant_factor;
|
|
615
|
|
616 /** obsolete FIXME remove */
|
|
617 int rc_strategy;
|
|
618 int b_frame_strategy;
|
|
619
|
|
620 /**
|
|
621 * hurry up amount.
|
|
622 * - encoding: unused
|
|
623 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
|
|
624 */
|
|
625 int hurry_up;
|
|
626
|
|
627 struct AVCodec *codec;
|
|
628
|
|
629 void *priv_data;
|
|
630
|
|
631 /* unused, FIXME remove*/
|
|
632 int rtp_mode;
|
|
633
|
|
634 int rtp_payload_size; /* The size of the RTP payload, the coder will */
|
|
635 /* do it's best to deliver a chunk with size */
|
|
636 /* below rtp_payload_size, the chunk will start */
|
|
637 /* with a start code on some codecs like H.263 */
|
|
638 /* This doesn't take account of any particular */
|
|
639 /* headers inside the transmited RTP payload */
|
|
640
|
|
641
|
|
642 /* The RTP callcack: This function is called */
|
|
643 /* every time the encoder as a packet to send */
|
|
644 /* Depends on the encoder if the data starts */
|
|
645 /* with a Start Code (it should) H.263 does */
|
|
646 void (*rtp_callback)(void *data, int size, int packet_number);
|
|
647
|
|
648 /* statistics, used for 2-pass encoding */
|
|
649 int mv_bits;
|
|
650 int header_bits;
|
|
651 int i_tex_bits;
|
|
652 int p_tex_bits;
|
|
653 int i_count;
|
|
654 int p_count;
|
|
655 int skip_count;
|
|
656 int misc_bits;
|
|
657
|
|
658 /**
|
|
659 * number of bits used for the previously encoded frame.
|
|
660 * - encoding: set by lavc
|
|
661 * - decoding: unused
|
|
662 */
|
|
663 int frame_bits;
|
|
664
|
|
665 /**
|
|
666 * private data of the user, can be used to carry app specific stuff.
|
|
667 * - encoding: set by user
|
|
668 * - decoding: set by user
|
|
669 */
|
|
670 void *opaque;
|
|
671
|
|
672 char codec_name[32];
|
|
673 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
|
|
674 enum CodecID codec_id; /* see CODEC_ID_xxx */
|
|
675
|
|
676 /**
|
|
677 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
|
|
678 * this is used to workaround some encoder bugs
|
|
679 * - encoding: set by user, if not then the default based on codec_id will be used
|
|
680 * - decoding: set by user, will be converted to upper case by lavc during init
|
|
681 */
|
|
682 unsigned int codec_tag;
|
|
683
|
|
684 /**
|
|
685 * workaround bugs in encoders which sometimes cannot be detected automatically.
|
|
686 * - encoding: unused
|
|
687 * - decoding: set by user
|
|
688 */
|
|
689 int workaround_bugs;
|
|
690 #define FF_BUG_AUTODETECT 1 ///< autodetection
|
|
691 #define FF_BUG_OLD_MSMPEG4 2
|
|
692 #define FF_BUG_XVID_ILACE 4
|
|
693 #define FF_BUG_UMP4 8
|
|
694 #define FF_BUG_NO_PADDING 16
|
|
695 #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
|
|
696 #define FF_BUG_QPEL_CHROMA 64
|
|
697 #define FF_BUG_STD_QPEL 128
|
|
698 #define FF_BUG_QPEL_CHROMA2 256
|
|
699 #define FF_BUG_DIRECT_BLOCKSIZE 512
|
|
700 #define FF_BUG_EDGE 1024
|
|
701 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
|
|
702
|
|
703 /**
|
|
704 * luma single coeff elimination threshold.
|
|
705 * - encoding: set by user
|
|
706 * - decoding: unused
|
|
707 */
|
|
708 int luma_elim_threshold;
|
|
709
|
|
710 /**
|
|
711 * chroma single coeff elimination threshold.
|
|
712 * - encoding: set by user
|
|
713 * - decoding: unused
|
|
714 */
|
|
715 int chroma_elim_threshold;
|
|
716
|
|
717 /**
|
|
718 * strictly follow the std (MPEG4, ...).
|
|
719 * - encoding: set by user
|
|
720 * - decoding: unused
|
|
721 */
|
|
722 int strict_std_compliance;
|
|
723
|
|
724 /**
|
|
725 * qscale offset between ip and b frames.
|
|
726 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
|
|
727 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
|
|
728 * - encoding: set by user.
|
|
729 * - decoding: unused
|
|
730 */
|
|
731 float b_quant_offset;
|
|
732
|
|
733 /**
|
|
734 * error resilience higher values will detect more errors but may missdetect
|
|
735 * some more or less valid parts as errors.
|
|
736 * - encoding: unused
|
|
737 * - decoding: set by user
|
|
738 */
|
|
739 int error_resilience;
|
|
740 #define FF_ER_CAREFULL 1
|
|
741 #define FF_ER_COMPLIANT 2
|
|
742 #define FF_ER_AGGRESSIVE 3
|
|
743 #define FF_ER_VERY_AGGRESSIVE 4
|
|
744
|
|
745 /**
|
|
746 * called at the beginning of each frame to get a buffer for it.
|
|
747 * if pic.reference is set then the frame will be read later by lavc
|
|
748 * width and height should be rounded up to the next multiple of 16
|
|
749 * - encoding: unused
|
|
750 * - decoding: set by lavc, user can override
|
|
751 */
|
|
752 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
753
|
|
754 /**
|
|
755 * called to release buffers which where allocated with get_buffer.
|
|
756 * a released buffer can be reused in get_buffer()
|
|
757 * pic.data[*] must be set to NULL
|
|
758 * - encoding: unused
|
|
759 * - decoding: set by lavc, user can override
|
|
760 */
|
|
761 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
762
|
|
763 /**
|
|
764 * is 1 if the decoded stream contains b frames, 0 otherwise.
|
|
765 * - encoding: unused
|
|
766 * - decoding: set by lavc
|
|
767 */
|
|
768 int has_b_frames;
|
|
769
|
|
770 int block_align; ///< used by some WAV based audio codecs
|
|
771
|
|
772 int parse_only; /* - decoding only: if true, only parsing is done
|
|
773 (function avcodec_parse_frame()). The frame
|
|
774 data is returned. Only MPEG codecs support this now. */
|
|
775
|
|
776 /**
|
|
777 * 0-> h263 quant 1-> mpeg quant.
|
|
778 * - encoding: set by user.
|
|
779 * - decoding: unused
|
|
780 */
|
|
781 int mpeg_quant;
|
|
782
|
|
783 /**
|
|
784 * pass1 encoding statistics output buffer.
|
|
785 * - encoding: set by lavc
|
|
786 * - decoding: unused
|
|
787 */
|
|
788 char *stats_out;
|
|
789
|
|
790 /**
|
|
791 * pass2 encoding statistics input buffer.
|
|
792 * concatenated stuff from stats_out of pass1 should be placed here
|
|
793 * - encoding: allocated/set/freed by user
|
|
794 * - decoding: unused
|
|
795 */
|
|
796 char *stats_in;
|
|
797
|
|
798 /**
|
|
799 * ratecontrol qmin qmax limiting method.
|
|
800 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
|
|
801 * - encoding: set by user.
|
|
802 * - decoding: unused
|
|
803 */
|
|
804 float rc_qsquish;
|
|
805
|
|
806 float rc_qmod_amp;
|
|
807 int rc_qmod_freq;
|
|
808
|
|
809 /**
|
|
810 * ratecontrol override, see RcOverride.
|
|
811 * - encoding: allocated/set/freed by user.
|
|
812 * - decoding: unused
|
|
813 */
|
|
814 RcOverride *rc_override;
|
|
815 int rc_override_count;
|
|
816
|
|
817 /**
|
|
818 * rate control equation.
|
|
819 * - encoding: set by user
|
|
820 * - decoding: unused
|
|
821 */
|
|
822 char *rc_eq;
|
|
823
|
|
824 /**
|
|
825 * maximum bitrate.
|
|
826 * - encoding: set by user.
|
|
827 * - decoding: unused
|
|
828 */
|
|
829 int rc_max_rate;
|
|
830
|
|
831 /**
|
|
832 * minimum bitrate.
|
|
833 * - encoding: set by user.
|
|
834 * - decoding: unused
|
|
835 */
|
|
836 int rc_min_rate;
|
|
837
|
|
838 /**
|
|
839 * decoder bitstream buffer size.
|
|
840 * - encoding: set by user.
|
|
841 * - decoding: unused
|
|
842 */
|
|
843 int rc_buffer_size;
|
|
844 float rc_buffer_aggressivity;
|
|
845
|
|
846 /**
|
|
847 * qscale factor between p and i frames.
|
|
848 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
|
|
849 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
|
|
850 * - encoding: set by user.
|
|
851 * - decoding: unused
|
|
852 */
|
|
853 float i_quant_factor;
|
|
854
|
|
855 /**
|
|
856 * qscale offset between p and i frames.
|
|
857 * - encoding: set by user.
|
|
858 * - decoding: unused
|
|
859 */
|
|
860 float i_quant_offset;
|
|
861
|
|
862 /**
|
|
863 * initial complexity for pass1 ratecontrol.
|
|
864 * - encoding: set by user.
|
|
865 * - decoding: unused
|
|
866 */
|
|
867 float rc_initial_cplx;
|
|
868
|
|
869 /**
|
|
870 * dct algorithm, see FF_DCT_* below.
|
|
871 * - encoding: set by user
|
|
872 * - decoding: unused
|
|
873 */
|
|
874 int dct_algo;
|
|
875 #define FF_DCT_AUTO 0
|
|
876 #define FF_DCT_FASTINT 1
|
|
877 #define FF_DCT_INT 2
|
|
878 #define FF_DCT_MMX 3
|
|
879 #define FF_DCT_MLIB 4
|
|
880 #define FF_DCT_ALTIVEC 5
|
|
881 #define FF_DCT_FAAN 6
|
|
882
|
|
883 /**
|
|
884 * luminance masking (0-> disabled).
|
|
885 * - encoding: set by user
|
|
886 * - decoding: unused
|
|
887 */
|
|
888 float lumi_masking;
|
|
889
|
|
890 /**
|
|
891 * temporary complexity masking (0-> disabled).
|
|
892 * - encoding: set by user
|
|
893 * - decoding: unused
|
|
894 */
|
|
895 float temporal_cplx_masking;
|
|
896
|
|
897 /**
|
|
898 * spatial complexity masking (0-> disabled).
|
|
899 * - encoding: set by user
|
|
900 * - decoding: unused
|
|
901 */
|
|
902 float spatial_cplx_masking;
|
|
903
|
|
904 /**
|
|
905 * p block masking (0-> disabled).
|
|
906 * - encoding: set by user
|
|
907 * - decoding: unused
|
|
908 */
|
|
909 float p_masking;
|
|
910
|
|
911 /**
|
|
912 * darkness masking (0-> disabled).
|
|
913 * - encoding: set by user
|
|
914 * - decoding: unused
|
|
915 */
|
|
916 float dark_masking;
|
|
917
|
|
918
|
|
919 /* for binary compatibility */
|
|
920 int unused;
|
|
921
|
|
922 /**
|
|
923 * idct algorithm, see FF_IDCT_* below.
|
|
924 * - encoding: set by user
|
|
925 * - decoding: set by user
|
|
926 */
|
|
927 int idct_algo;
|
|
928 #define FF_IDCT_AUTO 0
|
|
929 #define FF_IDCT_INT 1
|
|
930 #define FF_IDCT_SIMPLE 2
|
|
931 #define FF_IDCT_SIMPLEMMX 3
|
|
932 #define FF_IDCT_LIBMPEG2MMX 4
|
|
933 #define FF_IDCT_PS2 5
|
|
934 #define FF_IDCT_MLIB 6
|
|
935 #define FF_IDCT_ARM 7
|
|
936 #define FF_IDCT_ALTIVEC 8
|
|
937 #define FF_IDCT_SH4 9
|
|
938 #define FF_IDCT_SIMPLEARM 10
|
|
939
|
|
940 /**
|
|
941 * slice count.
|
|
942 * - encoding: set by lavc
|
|
943 * - decoding: set by user (or 0)
|
|
944 */
|
|
945 int slice_count;
|
|
946 /**
|
|
947 * slice offsets in the frame in bytes.
|
|
948 * - encoding: set/allocated by lavc
|
|
949 * - decoding: set/allocated by user (or NULL)
|
|
950 */
|
|
951 int *slice_offset;
|
|
952
|
|
953 /**
|
|
954 * error concealment flags.
|
|
955 * - encoding: unused
|
|
956 * - decoding: set by user
|
|
957 */
|
|
958 int error_concealment;
|
|
959 #define FF_EC_GUESS_MVS 1
|
|
960 #define FF_EC_DEBLOCK 2
|
|
961
|
|
962 /**
|
|
963 * dsp_mask could be add used to disable unwanted CPU features
|
|
964 * CPU features (i.e. MMX, SSE. ...)
|
|
965 *
|
|
966 * with FORCE flag you may instead enable given CPU features
|
|
967 * (Dangerous: usable in case of misdetection, improper usage however will
|
|
968 * result into program crash)
|
|
969 */
|
|
970 unsigned dsp_mask;
|
|
971 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
|
972 /* lower 16 bits - CPU features */
|
|
973 #ifdef HAVE_MMX
|
|
974 #define FF_MM_MMX 0x0001 /* standard MMX */
|
|
975 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
|
|
976 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
|
|
977 #define FF_MM_SSE 0x0008 /* SSE functions */
|
|
978 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
|
|
979 #endif /* HAVE_MMX */
|
|
980
|
|
981 /**
|
|
982 * bits per sample/pixel from the demuxer (needed for huffyuv).
|
|
983 * - encoding: set by lavc
|
|
984 * - decoding: set by user
|
|
985 */
|
|
986 int bits_per_sample;
|
|
987
|
|
988 /**
|
|
989 * prediction method (needed for huffyuv).
|
|
990 * - encoding: set by user
|
|
991 * - decoding: unused
|
|
992 */
|
|
993 int prediction_method;
|
|
994 #define FF_PRED_LEFT 0
|
|
995 #define FF_PRED_PLANE 1
|
|
996 #define FF_PRED_MEDIAN 2
|
|
997
|
|
998 /**
|
|
999 * sample aspect ratio (0 if unknown).
|
|
1000 * numerator and denominator must be relative prime and smaller then 256 for some video standards
|
|
1001 * - encoding: set by user.
|
|
1002 * - decoding: set by lavc.
|
|
1003 */
|
|
1004 //AVRational sample_aspect_ratio;
|
|
1005
|
|
1006 /**
|
|
1007 * the picture in the bitstream.
|
|
1008 * - encoding: set by lavc
|
|
1009 * - decoding: set by lavc
|
|
1010 */
|
|
1011 AVFrame *coded_frame;
|
|
1012
|
|
1013 /**
|
|
1014 * debug.
|
|
1015 * - encoding: set by user.
|
|
1016 * - decoding: set by user.
|
|
1017 */
|
|
1018 int debug;
|
|
1019 #define FF_DEBUG_PICT_INFO 1
|
|
1020 #define FF_DEBUG_RC 2
|
|
1021 #define FF_DEBUG_BITSTREAM 4
|
|
1022 #define FF_DEBUG_MB_TYPE 8
|
|
1023 #define FF_DEBUG_QP 16
|
|
1024 #define FF_DEBUG_MV 32
|
|
1025 //#define FF_DEBUG_VIS_MV 0x00000040
|
|
1026 #define FF_DEBUG_SKIP 0x00000080
|
|
1027 #define FF_DEBUG_STARTCODE 0x00000100
|
|
1028 #define FF_DEBUG_PTS 0x00000200
|
|
1029 #define FF_DEBUG_ER 0x00000400
|
|
1030 #define FF_DEBUG_MMCO 0x00000800
|
|
1031 #define FF_DEBUG_BUGS 0x00001000
|
|
1032 #define FF_DEBUG_VIS_QP 0x00002000
|
|
1033 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
|
|
1034
|
|
1035 /**
|
|
1036 * debug.
|
|
1037 * - encoding: set by user.
|
|
1038 * - decoding: set by user.
|
|
1039 */
|
|
1040 int debug_mv;
|
|
1041 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
|
|
1042 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
|
|
1043 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
|
|
1044
|
|
1045 /**
|
|
1046 * error.
|
|
1047 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
|
|
1048 * - decoding: unused
|
|
1049 */
|
|
1050 uint64_t error[4];
|
|
1051
|
|
1052 /**
|
|
1053 * minimum MB quantizer.
|
|
1054 * - encoding: set by user.
|
|
1055 * - decoding: unused
|
|
1056 */
|
|
1057 int mb_qmin;
|
|
1058
|
|
1059 /**
|
|
1060 * maximum MB quantizer.
|
|
1061 * - encoding: set by user.
|
|
1062 * - decoding: unused
|
|
1063 */
|
|
1064 int mb_qmax;
|
|
1065
|
|
1066 /**
|
|
1067 * motion estimation compare function.
|
|
1068 * - encoding: set by user.
|
|
1069 * - decoding: unused
|
|
1070 */
|
|
1071 int me_cmp;
|
|
1072 /**
|
|
1073 * subpixel motion estimation compare function.
|
|
1074 * - encoding: set by user.
|
|
1075 * - decoding: unused
|
|
1076 */
|
|
1077 int me_sub_cmp;
|
|
1078 /**
|
|
1079 * macroblock compare function (not supported yet).
|
|
1080 * - encoding: set by user.
|
|
1081 * - decoding: unused
|
|
1082 */
|
|
1083 int mb_cmp;
|
|
1084 /**
|
|
1085 * interlaced dct compare function
|
|
1086 * - encoding: set by user.
|
|
1087 * - decoding: unused
|
|
1088 */
|
|
1089 int ildct_cmp;
|
|
1090 #define FF_CMP_SAD 0
|
|
1091 #define FF_CMP_SSE 1
|
|
1092 #define FF_CMP_SATD 2
|
|
1093 #define FF_CMP_DCT 3
|
|
1094 #define FF_CMP_PSNR 4
|
|
1095 #define FF_CMP_BIT 5
|
|
1096 #define FF_CMP_RD 6
|
|
1097 #define FF_CMP_ZERO 7
|
|
1098 #define FF_CMP_VSAD 8
|
|
1099 #define FF_CMP_VSSE 9
|
|
1100 #define FF_CMP_CHROMA 256
|
|
1101
|
|
1102 /**
|
|
1103 * ME diamond size & shape.
|
|
1104 * - encoding: set by user.
|
|
1105 * - decoding: unused
|
|
1106 */
|
|
1107 int dia_size;
|
|
1108
|
|
1109 /**
|
|
1110 * amount of previous MV predictors (2a+1 x 2a+1 square).
|
|
1111 * - encoding: set by user.
|
|
1112 * - decoding: unused
|
|
1113 */
|
|
1114 int last_predictor_count;
|
|
1115
|
|
1116 /**
|
|
1117 * pre pass for motion estimation.
|
|
1118 * - encoding: set by user.
|
|
1119 * - decoding: unused
|
|
1120 */
|
|
1121 int pre_me;
|
|
1122
|
|
1123 /**
|
|
1124 * motion estimation pre pass compare function.
|
|
1125 * - encoding: set by user.
|
|
1126 * - decoding: unused
|
|
1127 */
|
|
1128 int me_pre_cmp;
|
|
1129
|
|
1130 /**
|
|
1131 * ME pre pass diamond size & shape.
|
|
1132 * - encoding: set by user.
|
|
1133 * - decoding: unused
|
|
1134 */
|
|
1135 int pre_dia_size;
|
|
1136
|
|
1137 /**
|
|
1138 * subpel ME quality.
|
|
1139 * - encoding: set by user.
|
|
1140 * - decoding: unused
|
|
1141 */
|
|
1142 int me_subpel_quality;
|
|
1143
|
|
1144 /**
|
|
1145 * callback to negotiate the pixelFormat.
|
|
1146 * @param fmt is the list of formats which are supported by the codec,
|
|
1147 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
|
|
1148 * the first is allways the native one
|
|
1149 * @return the choosen format
|
|
1150 * - encoding: unused
|
|
1151 * - decoding: set by user, if not set then the native format will always be choosen
|
|
1152 */
|
|
1153 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
|
|
1154
|
|
1155 /**
|
|
1156 * DTG active format information (additionnal aspect ratio
|
|
1157 * information only used in DVB MPEG2 transport streams). 0 if
|
|
1158 * not set.
|
|
1159 *
|
|
1160 * - encoding: unused.
|
|
1161 * - decoding: set by decoder
|
|
1162 */
|
|
1163 int dtg_active_format;
|
|
1164 #define FF_DTG_AFD_SAME 8
|
|
1165 #define FF_DTG_AFD_4_3 9
|
|
1166 #define FF_DTG_AFD_16_9 10
|
|
1167 #define FF_DTG_AFD_14_9 11
|
|
1168 #define FF_DTG_AFD_4_3_SP_14_9 13
|
|
1169 #define FF_DTG_AFD_16_9_SP_14_9 14
|
|
1170 #define FF_DTG_AFD_SP_4_3 15
|
|
1171
|
|
1172 /**
|
|
1173 * Maximum motion estimation search range in subpel units.
|
|
1174 * if 0 then no limit
|
|
1175 *
|
|
1176 * - encoding: set by user.
|
|
1177 * - decoding: unused.
|
|
1178 */
|
|
1179 int me_range;
|
|
1180
|
|
1181 /**
|
|
1182 * frame_rate_base.
|
|
1183 * for variable fps this is 1
|
|
1184 * - encoding: set by user.
|
|
1185 * - decoding: set by lavc.
|
|
1186 * @todo move this after frame_rate
|
|
1187 */
|
|
1188
|
|
1189 int frame_rate_base;
|
|
1190 /**
|
|
1191 * intra quantizer bias.
|
|
1192 * - encoding: set by user.
|
|
1193 * - decoding: unused
|
|
1194 */
|
|
1195 int intra_quant_bias;
|
|
1196 #define FF_DEFAULT_QUANT_BIAS 999999
|
|
1197
|
|
1198 /**
|
|
1199 * inter quantizer bias.
|
|
1200 * - encoding: set by user.
|
|
1201 * - decoding: unused
|
|
1202 */
|
|
1203 int inter_quant_bias;
|
|
1204
|
|
1205 /**
|
|
1206 * color table ID.
|
|
1207 * - encoding: unused.
|
|
1208 * - decoding: which clrtable should be used for 8bit RGB images
|
|
1209 * table have to be stored somewhere FIXME
|
|
1210 */
|
|
1211 int color_table_id;
|
|
1212
|
|
1213 /**
|
|
1214 * internal_buffer count.
|
|
1215 * Dont touch, used by lavc default_get_buffer()
|
|
1216 */
|
|
1217 int internal_buffer_count;
|
|
1218
|
|
1219 /**
|
|
1220 * internal_buffers.
|
|
1221 * Dont touch, used by lavc default_get_buffer()
|
|
1222 */
|
|
1223 void *internal_buffer;
|
|
1224
|
|
1225 #define FF_LAMBDA_SHIFT 7
|
|
1226 #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
|
|
1227 #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
|
|
1228 #define FF_LAMBDA_MAX (256*128-1)
|
|
1229
|
|
1230 #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
|
|
1231 /**
|
|
1232 * global quality for codecs which cannot change it per frame.
|
|
1233 * this should be proportional to MPEG1/2/4 qscale.
|
|
1234 * - encoding: set by user.
|
|
1235 * - decoding: unused
|
|
1236 */
|
|
1237 int global_quality;
|
|
1238
|
|
1239 #define FF_CODER_TYPE_VLC 0
|
|
1240 #define FF_CODER_TYPE_AC 1
|
|
1241 /**
|
|
1242 * coder type
|
|
1243 * - encoding: set by user.
|
|
1244 * - decoding: unused
|
|
1245 */
|
|
1246 int coder_type;
|
|
1247
|
|
1248 /**
|
|
1249 * context model
|
|
1250 * - encoding: set by user.
|
|
1251 * - decoding: unused
|
|
1252 */
|
|
1253 int context_model;
|
|
1254
|
|
1255 /**
|
|
1256 * slice flags
|
|
1257 * - encoding: unused
|
|
1258 * - decoding: set by user.
|
|
1259 */
|
|
1260 int slice_flags;
|
|
1261 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
|
|
1262 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
|
|
1263 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
|
|
1264
|
|
1265 /**
|
|
1266 * XVideo Motion Acceleration
|
|
1267 * - encoding: forbidden
|
|
1268 * - decoding: set by decoder
|
|
1269 */
|
|
1270 int xvmc_acceleration;
|
|
1271
|
|
1272 /**
|
|
1273 * macroblock decision mode
|
|
1274 * - encoding: set by user.
|
|
1275 * - decoding: unused
|
|
1276 */
|
|
1277 int mb_decision;
|
|
1278 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
|
|
1279 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
|
|
1280 #define FF_MB_DECISION_RD 2 ///< rate distoration
|
|
1281
|
|
1282 /**
|
|
1283 * custom intra quantization matrix
|
|
1284 * - encoding: set by user, can be NULL
|
|
1285 * - decoding: set by lavc
|
|
1286 */
|
|
1287 uint16_t *intra_matrix;
|
|
1288
|
|
1289 /**
|
|
1290 * custom inter quantization matrix
|
|
1291 * - encoding: set by user, can be NULL
|
|
1292 * - decoding: set by lavc
|
|
1293 */
|
|
1294 uint16_t *inter_matrix;
|
|
1295
|
|
1296 /**
|
|
1297 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
|
|
1298 * this is used to workaround some encoder bugs
|
|
1299 * - encoding: unused
|
|
1300 * - decoding: set by user, will be converted to upper case by lavc during init
|
|
1301 */
|
|
1302 unsigned int stream_codec_tag;
|
|
1303
|
|
1304 /**
|
|
1305 * scene change detection threshold.
|
|
1306 * 0 is default, larger means fewer detected scene changes
|
|
1307 * - encoding: set by user.
|
|
1308 * - decoding: unused
|
|
1309 */
|
|
1310 int scenechange_threshold;
|
|
1311
|
|
1312 /**
|
|
1313 * minimum lagrange multipler
|
|
1314 * - encoding: set by user.
|
|
1315 * - decoding: unused
|
|
1316 */
|
|
1317 int lmin;
|
|
1318
|
|
1319 /**
|
|
1320 * maximum lagrange multipler
|
|
1321 * - encoding: set by user.
|
|
1322 * - decoding: unused
|
|
1323 */
|
|
1324 int lmax;
|
|
1325
|
|
1326 /**
|
|
1327 * Palette control structure
|
|
1328 * - encoding: ??? (no palette-enabled encoder yet)
|
|
1329 * - decoding: set by user.
|
|
1330 */
|
|
1331 struct AVPaletteControl *palctrl;
|
|
1332
|
|
1333 /**
|
|
1334 * noise reduction strength
|
|
1335 * - encoding: set by user.
|
|
1336 * - decoding: unused
|
|
1337 */
|
|
1338 int noise_reduction;
|
|
1339
|
|
1340 /**
|
|
1341 * called at the beginning of a frame to get cr buffer for it.
|
|
1342 * buffer type (size, hints) must be the same. lavc won't check it.
|
|
1343 * lavc will pass previous buffer in pic, function should return
|
|
1344 * same buffer or new buffer with old frame "painted" into it.
|
|
1345 * if pic.data[0] == NULL must behave like get_buffer().
|
|
1346 * - encoding: unused
|
|
1347 * - decoding: set by lavc, user can override
|
|
1348 */
|
|
1349 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
1350
|
|
1351 /**
|
|
1352 * number of bits which should be loaded into the rc buffer before decoding starts
|
|
1353 * - encoding: set by user.
|
|
1354 * - decoding: unused
|
|
1355 */
|
|
1356 int rc_initial_buffer_occupancy;
|
|
1357
|
|
1358 /**
|
|
1359 *
|
|
1360 * - encoding: set by user.
|
|
1361 * - decoding: unused
|
|
1362 */
|
|
1363 int inter_threshold;
|
|
1364
|
|
1365 /**
|
|
1366 * CODEC_FLAG2_*.
|
|
1367 * - encoding: set by user.
|
|
1368 * - decoding: set by user.
|
|
1369 */
|
|
1370 int flags2;
|
|
1371
|
|
1372 /**
|
|
1373 * simulates errors in the bitstream to test error concealment.
|
|
1374 * - encoding: set by user.
|
|
1375 * - decoding: unused.
|
|
1376 */
|
|
1377 int error_rate;
|
|
1378
|
|
1379 /**
|
|
1380 * MP3 antialias algorithm, see FF_AA_* below.
|
|
1381 * - encoding: unused
|
|
1382 * - decoding: set by user
|
|
1383 */
|
|
1384 int antialias_algo;
|
|
1385 #define FF_AA_AUTO 0
|
|
1386 #define FF_AA_FASTINT 1 //not implemented yet
|
|
1387 #define FF_AA_INT 2
|
|
1388 #define FF_AA_FLOAT 3
|
|
1389 /**
|
|
1390 * Quantizer noise shaping.
|
|
1391 * - encoding: set by user
|
|
1392 * - decoding: unused
|
|
1393 */
|
|
1394 int quantizer_noise_shaping;
|
|
1395 } AVCodecContext;
|
|
1396
|
|
1397 /**
|
|
1398 * Parse option(s) and sets fields in passed structure
|
|
1399 * @param strct structure where the parsed results will be written
|
|
1400 * @param list list with AVOptions
|
|
1401 * @param opts string with options for parsing
|
|
1402 */
|
|
1403 int avoption_parse(void* strct, const AVOption* list, const char* opts);
|
|
1404
|
|
1405
|
|
1406 /**
|
|
1407 * AVCodec.
|
|
1408 */
|
|
1409 typedef struct AVCodec {
|
|
1410 const char *name;
|
|
1411 enum CodecType type;
|
|
1412 int id;
|
|
1413 int priv_data_size;
|
|
1414 int (*init)(AVCodecContext *);
|
|
1415 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
|
|
1416 int (*close)(AVCodecContext *);
|
|
1417 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
|
|
1418 uint8_t *buf, int buf_size);
|
|
1419 int capabilities;
|
|
1420 const AVOption *options;
|
|
1421 struct AVCodec *next;
|
|
1422 void (*flush)(AVCodecContext *);
|
|
1423 } AVCodec;
|
|
1424
|
|
1425 /**
|
|
1426 * four components are given, that's all.
|
|
1427 * the last component is alpha
|
|
1428 */
|
|
1429 typedef struct AVPicture {
|
|
1430 uint8_t *data[4];
|
|
1431 int linesize[4]; ///< number of bytes per line
|
|
1432 } AVPicture;
|
|
1433
|
|
1434 /**
|
|
1435 * AVPaletteControl
|
|
1436 * This structure defines a method for communicating palette changes
|
|
1437 * between and demuxer and a decoder.
|
|
1438 */
|
|
1439 #define AVPALETTE_SIZE 1024
|
|
1440 #define AVPALETTE_COUNT 256
|
|
1441 typedef struct AVPaletteControl {
|
|
1442
|
|
1443 /* demuxer sets this to 1 to indicate the palette has changed;
|
|
1444 * decoder resets to 0 */
|
|
1445 int palette_changed;
|
|
1446
|
|
1447 /* 4-byte ARGB palette entries, stored in native byte order; note that
|
|
1448 * the individual palette components should be on a 8-bit scale; if
|
|
1449 * the palette data comes from a IBM VGA native format, the component
|
|
1450 * data is probably 6 bits in size and needs to be scaled */
|
|
1451 unsigned int palette[AVPALETTE_COUNT];
|
|
1452
|
|
1453 } AVPaletteControl;
|
|
1454
|
|
1455 extern AVCodec wmav1_decoder;
|
|
1456 extern AVCodec wmav2_decoder;
|
|
1457
|
|
1458 /* pcm codecs */
|
|
1459 #define PCM_CODEC(id, name) \
|
|
1460 extern AVCodec name ## _decoder; \
|
|
1461 extern AVCodec name ## _encoder
|
|
1462
|
|
1463 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
|
|
1464 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
|
|
1465 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
|
|
1466 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
|
|
1467 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
|
|
1468 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
|
|
1469 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
|
|
1470 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
|
|
1471
|
|
1472 /* adpcm codecs */
|
|
1473
|
|
1474 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
|
|
1475 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
|
|
1476 PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
|
|
1477 PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
|
|
1478 PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
|
|
1479 PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
|
|
1480 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
|
|
1481 PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
|
|
1482 PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
|
|
1483 PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
|
|
1484 PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
|
|
1485
|
|
1486 #undef PCM_CODEC
|
|
1487
|
|
1488
|
|
1489
|
|
1490 /* resample.c */
|
|
1491
|
|
1492 struct ReSampleContext;
|
|
1493
|
|
1494 typedef struct ReSampleContext ReSampleContext;
|
|
1495
|
|
1496 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
|
|
1497 int output_rate, int input_rate);
|
|
1498 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
|
|
1499 void audio_resample_close(ReSampleContext *s);
|
|
1500
|
|
1501 /* YUV420 format is assumed ! */
|
|
1502
|
|
1503 struct ImgReSampleContext;
|
|
1504
|
|
1505 typedef struct ImgReSampleContext ImgReSampleContext;
|
|
1506
|
|
1507 ImgReSampleContext *img_resample_init(int output_width, int output_height,
|
|
1508 int input_width, int input_height);
|
|
1509
|
|
1510 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
|
|
1511 int iwidth, int iheight,
|
|
1512 int topBand, int bottomBand,
|
|
1513 int leftBand, int rightBand);
|
|
1514
|
|
1515 void img_resample(ImgReSampleContext *s,
|
|
1516 AVPicture *output, const AVPicture *input);
|
|
1517
|
|
1518 void img_resample_close(ImgReSampleContext *s);
|
|
1519
|
|
1520 /**
|
|
1521 * Allocate memory for a picture. Call avpicture_free to free it.
|
|
1522 *
|
|
1523 * @param picture the picture to be filled in.
|
|
1524 * @param pix_fmt the format of the picture.
|
|
1525 * @param width the width of the picture.
|
|
1526 * @param height the height of the picture.
|
|
1527 * @return 0 if successful, -1 if not.
|
|
1528 */
|
|
1529 int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
|
|
1530
|
|
1531 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
|
|
1532 const char *avcodec_get_pix_fmt_name(int pix_fmt);
|
|
1533 enum PixelFormat avcodec_get_pix_fmt(const char* name);
|
|
1534
|
|
1535 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
|
|
1536 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
|
|
1537 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
|
|
1538 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
|
|
1539 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
|
|
1540 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
|
|
1541
|
|
1542 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
|
|
1543 int has_alpha);
|
|
1544 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
|
|
1545 int has_alpha, int *loss_ptr);
|
|
1546
|
|
1547 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
|
|
1548 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
|
|
1549 int img_get_alpha_info(const AVPicture *src,
|
|
1550 int pix_fmt, int width, int height);
|
|
1551
|
|
1552 /* convert among pixel formats */
|
|
1553 int img_convert(AVPicture *dst, int dst_pix_fmt,
|
|
1554 const AVPicture *src, int pix_fmt,
|
|
1555 int width, int height);
|
|
1556
|
|
1557 /* deinterlace a picture */
|
|
1558 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
|
|
1559 int pix_fmt, int width, int height);
|
|
1560
|
|
1561 /* external high level API */
|
|
1562
|
|
1563 extern AVCodec *first_avcodec;
|
|
1564
|
|
1565 /* returns LIBAVCODEC_VERSION_INT constant */
|
|
1566 unsigned avcodec_version(void);
|
|
1567 /* returns LIBAVCODEC_BUILD constant */
|
|
1568 unsigned avcodec_build(void);
|
|
1569 void avcodec_init(void);
|
|
1570
|
|
1571 void register_avcodec(AVCodec *format);
|
|
1572 AVCodec *avcodec_find_encoder(enum CodecID id);
|
|
1573 AVCodec *avcodec_find_encoder_by_name(const char *name);
|
|
1574 AVCodec *avcodec_find_decoder(enum CodecID id);
|
|
1575 AVCodec *avcodec_find_decoder_by_name(const char *name);
|
|
1576 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
|
|
1577
|
|
1578 void avcodec_get_context_defaults(AVCodecContext *s);
|
|
1579 AVCodecContext *avcodec_alloc_context(void);
|
|
1580 AVFrame *avcodec_alloc_frame(void);
|
|
1581
|
|
1582 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
|
|
1583 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
|
|
1584 void avcodec_default_free_buffers(AVCodecContext *s);
|
|
1585
|
|
1586 /**
|
|
1587 * opens / inits the AVCodecContext.
|
|
1588 * not thread save!
|
|
1589 */
|
|
1590 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
|
|
1591
|
|
1592 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
|
|
1593 int *frame_size_ptr,
|
|
1594 uint8_t *buf, int buf_size);
|
|
1595 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
|
|
1596 int *data_size_ptr,
|
|
1597 uint8_t *buf, int buf_size);
|
|
1598 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
|
|
1599 const short *samples);
|
|
1600
|
|
1601 int avcodec_close(AVCodecContext *avctx);
|
|
1602
|
|
1603 void avcodec_register_all(void);
|
|
1604
|
|
1605 void avcodec_flush_buffers(AVCodecContext *avctx);
|
|
1606
|
|
1607 /* misc usefull functions */
|
|
1608
|
|
1609 /**
|
|
1610 * returns a single letter to describe the picture type
|
|
1611 */
|
|
1612 char av_get_pict_type_char(int pict_type);
|
|
1613
|
|
1614 /**
|
|
1615 * reduce a fraction.
|
|
1616 * this is usefull for framerate calculations
|
|
1617 * @param max the maximum allowed for dst_nom & dst_den
|
|
1618 * @return 1 if exact, 0 otherwise
|
|
1619 */
|
|
1620 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
|
|
1621
|
|
1622 /**
|
|
1623 * rescale a 64bit integer.
|
|
1624 * a simple a*b/c isnt possible as it can overflow
|
|
1625 */
|
|
1626 int64_t av_rescale(int64_t a, int b, int c);
|
|
1627
|
|
1628
|
|
1629 /**
|
|
1630 * Interface for 0.5.0 version
|
|
1631 *
|
|
1632 * do not even think about it's usage for this moment
|
|
1633 */
|
|
1634
|
|
1635 typedef struct {
|
|
1636 /// compressed size used from given memory buffer
|
|
1637 int size;
|
|
1638 /// I/P/B frame type
|
|
1639 int frame_type;
|
|
1640 } avc_enc_result_t;
|
|
1641
|
|
1642 /**
|
|
1643 * Commands
|
|
1644 * order can't be changed - once it was defined
|
|
1645 */
|
|
1646 typedef enum {
|
|
1647 // general commands
|
|
1648 AVC_OPEN_BY_NAME = 0xACA000,
|
|
1649 AVC_OPEN_BY_CODEC_ID,
|
|
1650 AVC_OPEN_BY_FOURCC,
|
|
1651 AVC_CLOSE,
|
|
1652
|
|
1653 AVC_FLUSH,
|
|
1654 // pin - struct { uint8_t* src, uint_t src_size }
|
|
1655 // pout - struct { AVPicture* img, consumed_bytes,
|
|
1656 AVC_DECODE,
|
|
1657 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
|
|
1658 // pout - uint_t used_from_dest_size
|
|
1659 AVC_ENCODE,
|
|
1660
|
|
1661 // query/get video commands
|
|
1662 AVC_GET_VERSION = 0xACB000,
|
|
1663 AVC_GET_WIDTH,
|
|
1664 AVC_GET_HEIGHT,
|
|
1665 AVC_GET_DELAY,
|
|
1666 AVC_GET_QUANT_TABLE,
|
|
1667 // ...
|
|
1668
|
|
1669 // query/get audio commands
|
|
1670 AVC_GET_FRAME_SIZE = 0xABC000,
|
|
1671
|
|
1672 // maybe define some simple structure which
|
|
1673 // might be passed to the user - but they can't
|
|
1674 // contain any codec specific parts and these
|
|
1675 // calls are usualy necessary only few times
|
|
1676
|
|
1677 // set video commands
|
|
1678 AVC_SET_WIDTH = 0xACD000,
|
|
1679 AVC_SET_HEIGHT,
|
|
1680
|
|
1681 // set video encoding commands
|
|
1682 AVC_SET_FRAME_RATE = 0xACD800,
|
|
1683 AVC_SET_QUALITY,
|
|
1684 AVC_SET_HURRY_UP,
|
|
1685
|
|
1686 // set audio commands
|
|
1687 AVC_SET_SAMPLE_RATE = 0xACE000,
|
|
1688 AVC_SET_CHANNELS,
|
|
1689
|
|
1690 } avc_cmd_t;
|
|
1691
|
|
1692 /**
|
|
1693 * \param handle allocated private structure by libavcodec
|
|
1694 * for initialization pass NULL - will be returned pout
|
|
1695 * user is supposed to know nothing about its structure
|
|
1696 * \param cmd type of operation to be performed
|
|
1697 * \param pint input parameter
|
|
1698 * \param pout output parameter
|
|
1699 *
|
|
1700 * \returns command status - eventually for query command it might return
|
|
1701 * integer resulting value
|
|
1702 */
|
|
1703 int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
|
|
1704
|
|
1705 /* frame parsing */
|
|
1706 typedef struct AVCodecParserContext {
|
|
1707 void *priv_data;
|
|
1708 struct AVCodecParser *parser;
|
|
1709 int64_t frame_offset; /* offset of the current frame */
|
|
1710 int64_t cur_offset; /* current offset
|
|
1711 (incremented by each av_parser_parse()) */
|
|
1712 int64_t last_frame_offset; /* offset of the last frame */
|
|
1713 /* video info */
|
|
1714 int pict_type; /* XXX: put it back in AVCodecContext */
|
|
1715 int repeat_pict; /* XXX: put it back in AVCodecContext */
|
|
1716 int64_t pts; /* pts of the current frame */
|
|
1717 int64_t dts; /* dts of the current frame */
|
|
1718
|
|
1719 /* private data */
|
|
1720 int64_t last_pts;
|
|
1721 int64_t last_dts;
|
|
1722
|
|
1723 #define AV_PARSER_PTS_NB 4
|
|
1724 int cur_frame_start_index;
|
|
1725 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
|
|
1726 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
|
|
1727 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
|
|
1728 } AVCodecParserContext;
|
|
1729
|
|
1730 typedef struct AVCodecParser {
|
|
1731 int codec_ids[3]; /* several codec IDs are permitted */
|
|
1732 int priv_data_size;
|
|
1733 int (*parser_init)(AVCodecParserContext *s);
|
|
1734 int (*parser_parse)(AVCodecParserContext *s,
|
|
1735 AVCodecContext *avctx,
|
|
1736 uint8_t **poutbuf, int *poutbuf_size,
|
|
1737 const uint8_t *buf, int buf_size);
|
|
1738 void (*parser_close)(AVCodecParserContext *s);
|
|
1739 struct AVCodecParser *next;
|
|
1740 } AVCodecParser;
|
|
1741
|
|
1742 extern AVCodecParser *av_first_parser;
|
|
1743
|
|
1744 void av_register_codec_parser(AVCodecParser *parser);
|
|
1745 AVCodecParserContext *av_parser_init(int codec_id);
|
|
1746 int av_parser_parse(AVCodecParserContext *s,
|
|
1747 AVCodecContext *avctx,
|
|
1748 uint8_t **poutbuf, int *poutbuf_size,
|
|
1749 const uint8_t *buf, int buf_size,
|
|
1750 int64_t pts, int64_t dts);
|
|
1751 void av_parser_close(AVCodecParserContext *s);
|
|
1752
|
|
1753 extern AVCodecParser mpegvideo_parser;
|
|
1754 extern AVCodecParser mpeg4video_parser;
|
|
1755 extern AVCodecParser h263_parser;
|
|
1756 extern AVCodecParser h264_parser;
|
|
1757 extern AVCodecParser mpegaudio_parser;
|
|
1758 extern AVCodecParser ac3_parser;
|
|
1759
|
|
1760 /*char *av_strdup(const char *s);*/
|
|
1761 void __av_freep(void **ptr);
|
|
1762 #define av_freep(p) __av_freep((void **)(p))
|
|
1763 void *av_fast_realloc(void *ptr, int *size, unsigned int min_size);
|
|
1764 void *av_malloc(unsigned int size);
|
|
1765 void *av_mallocz(unsigned int size);
|
|
1766 void *av_realloc(void *ptr, unsigned int size);
|
|
1767 void av_free(void *ptr);
|
|
1768 /* for static data only */
|
|
1769 /* call av_free_static to release all staticaly allocated tables */
|
|
1770 void av_free_static(void);
|
|
1771 void *__av_mallocz_static(void** location, unsigned int size);
|
|
1772 #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
|
|
1773
|
|
1774 /* add by bero : in adx.c */
|
|
1775 int is_adx(const unsigned char *buf,size_t bufsize);
|
|
1776
|
|
1777 void img_copy(AVPicture *dst, const AVPicture *src,
|
|
1778 int pix_fmt, int width, int height);
|
|
1779
|
|
1780 /* av_log API */
|
|
1781
|
|
1782 #include <stdarg.h>
|
|
1783
|
|
1784 #define AV_LOG_ERROR 0
|
|
1785 #define AV_LOG_INFO 1
|
|
1786 #define AV_LOG_DEBUG 2
|
|
1787
|
|
1788 extern void av_log(AVCodecContext*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
|
1789 extern void av_vlog(AVCodecContext*, int level, const char *fmt, va_list);
|
|
1790 extern int av_log_get_level(void);
|
|
1791 extern void av_log_set_level(int);
|
|
1792 extern void av_log_set_callback(void (*)(AVCodecContext*, int, const char*, va_list));
|
|
1793
|
|
1794 #undef AV_LOG_TRAP_PRINTF
|
|
1795 #ifdef AV_LOG_TRAP_PRINTF
|
|
1796 #define printf DO NOT USE
|
|
1797 #define fprintf DO NOT USE
|
|
1798 #undef stderr
|
|
1799 #define stderr DO NOT USE
|
|
1800 #endif
|
|
1801
|
|
1802 #ifdef __cplusplus
|
|
1803 }
|
|
1804 #endif
|
|
1805
|
|
1806 #endif /* AVCODEC_H */
|