avcodec: add XBM encoder
[libav.git] / libavcodec / avcodec.h
1 /*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of Libav.
5 *
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
23
24 /**
25 * @file
26 * external API header
27 */
28
29 #include <errno.h>
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/cpu.h"
33 #include "libavutil/dict.h"
34 #include "libavutil/log.h"
35 #include "libavutil/pixfmt.h"
36 #include "libavutil/rational.h"
37
38 #include "libavcodec/version.h"
39 /**
40 * @defgroup libavc Encoding/Decoding Library
41 * @{
42 *
43 * @defgroup lavc_decoding Decoding
44 * @{
45 * @}
46 *
47 * @defgroup lavc_encoding Encoding
48 * @{
49 * @}
50 *
51 * @defgroup lavc_codec Codecs
52 * @{
53 * @defgroup lavc_codec_native Native Codecs
54 * @{
55 * @}
56 * @defgroup lavc_codec_wrappers External library wrappers
57 * @{
58 * @}
59 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
60 * @{
61 * @}
62 * @}
63 * @defgroup lavc_internal Internal
64 * @{
65 * @}
66 * @}
67 *
68 */
69
70
71 /**
72 * Identify the syntax and semantics of the bitstream.
73 * The principle is roughly:
74 * Two decoders with the same ID can decode the same streams.
75 * Two encoders with the same ID can encode compatible streams.
76 * There may be slight deviations from the principle due to implementation
77 * details.
78 *
79 * If you add a codec ID to this list, add it so that
80 * 1. no value of a existing codec ID changes (that would break ABI),
81 * 2. it is as close as possible to similar codecs.
82 */
83 enum CodecID {
84 CODEC_ID_NONE,
85
86 /* video codecs */
87 CODEC_ID_MPEG1VIDEO,
88 CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
89 CODEC_ID_MPEG2VIDEO_XVMC,
90 CODEC_ID_H261,
91 CODEC_ID_H263,
92 CODEC_ID_RV10,
93 CODEC_ID_RV20,
94 CODEC_ID_MJPEG,
95 CODEC_ID_MJPEGB,
96 CODEC_ID_LJPEG,
97 CODEC_ID_SP5X,
98 CODEC_ID_JPEGLS,
99 CODEC_ID_MPEG4,
100 CODEC_ID_RAWVIDEO,
101 CODEC_ID_MSMPEG4V1,
102 CODEC_ID_MSMPEG4V2,
103 CODEC_ID_MSMPEG4V3,
104 CODEC_ID_WMV1,
105 CODEC_ID_WMV2,
106 CODEC_ID_H263P,
107 CODEC_ID_H263I,
108 CODEC_ID_FLV1,
109 CODEC_ID_SVQ1,
110 CODEC_ID_SVQ3,
111 CODEC_ID_DVVIDEO,
112 CODEC_ID_HUFFYUV,
113 CODEC_ID_CYUV,
114 CODEC_ID_H264,
115 CODEC_ID_INDEO3,
116 CODEC_ID_VP3,
117 CODEC_ID_THEORA,
118 CODEC_ID_ASV1,
119 CODEC_ID_ASV2,
120 CODEC_ID_FFV1,
121 CODEC_ID_4XM,
122 CODEC_ID_VCR1,
123 CODEC_ID_CLJR,
124 CODEC_ID_MDEC,
125 CODEC_ID_ROQ,
126 CODEC_ID_INTERPLAY_VIDEO,
127 CODEC_ID_XAN_WC3,
128 CODEC_ID_XAN_WC4,
129 CODEC_ID_RPZA,
130 CODEC_ID_CINEPAK,
131 CODEC_ID_WS_VQA,
132 CODEC_ID_MSRLE,
133 CODEC_ID_MSVIDEO1,
134 CODEC_ID_IDCIN,
135 CODEC_ID_8BPS,
136 CODEC_ID_SMC,
137 CODEC_ID_FLIC,
138 CODEC_ID_TRUEMOTION1,
139 CODEC_ID_VMDVIDEO,
140 CODEC_ID_MSZH,
141 CODEC_ID_ZLIB,
142 CODEC_ID_QTRLE,
143 CODEC_ID_SNOW,
144 CODEC_ID_TSCC,
145 CODEC_ID_ULTI,
146 CODEC_ID_QDRAW,
147 CODEC_ID_VIXL,
148 CODEC_ID_QPEG,
149 CODEC_ID_PNG,
150 CODEC_ID_PPM,
151 CODEC_ID_PBM,
152 CODEC_ID_PGM,
153 CODEC_ID_PGMYUV,
154 CODEC_ID_PAM,
155 CODEC_ID_FFVHUFF,
156 CODEC_ID_RV30,
157 CODEC_ID_RV40,
158 CODEC_ID_VC1,
159 CODEC_ID_WMV3,
160 CODEC_ID_LOCO,
161 CODEC_ID_WNV1,
162 CODEC_ID_AASC,
163 CODEC_ID_INDEO2,
164 CODEC_ID_FRAPS,
165 CODEC_ID_TRUEMOTION2,
166 CODEC_ID_BMP,
167 CODEC_ID_CSCD,
168 CODEC_ID_MMVIDEO,
169 CODEC_ID_ZMBV,
170 CODEC_ID_AVS,
171 CODEC_ID_SMACKVIDEO,
172 CODEC_ID_NUV,
173 CODEC_ID_KMVC,
174 CODEC_ID_FLASHSV,
175 CODEC_ID_CAVS,
176 CODEC_ID_JPEG2000,
177 CODEC_ID_VMNC,
178 CODEC_ID_VP5,
179 CODEC_ID_VP6,
180 CODEC_ID_VP6F,
181 CODEC_ID_TARGA,
182 CODEC_ID_DSICINVIDEO,
183 CODEC_ID_TIERTEXSEQVIDEO,
184 CODEC_ID_TIFF,
185 CODEC_ID_GIF,
186 CODEC_ID_DXA,
187 CODEC_ID_DNXHD,
188 CODEC_ID_THP,
189 CODEC_ID_SGI,
190 CODEC_ID_C93,
191 CODEC_ID_BETHSOFTVID,
192 CODEC_ID_PTX,
193 CODEC_ID_TXD,
194 CODEC_ID_VP6A,
195 CODEC_ID_AMV,
196 CODEC_ID_VB,
197 CODEC_ID_PCX,
198 CODEC_ID_SUNRAST,
199 CODEC_ID_INDEO4,
200 CODEC_ID_INDEO5,
201 CODEC_ID_MIMIC,
202 CODEC_ID_RL2,
203 CODEC_ID_ESCAPE124,
204 CODEC_ID_DIRAC,
205 CODEC_ID_BFI,
206 CODEC_ID_CMV,
207 CODEC_ID_MOTIONPIXELS,
208 CODEC_ID_TGV,
209 CODEC_ID_TGQ,
210 CODEC_ID_TQI,
211 CODEC_ID_AURA,
212 CODEC_ID_AURA2,
213 CODEC_ID_V210X,
214 CODEC_ID_TMV,
215 CODEC_ID_V210,
216 CODEC_ID_DPX,
217 CODEC_ID_MAD,
218 CODEC_ID_FRWU,
219 CODEC_ID_FLASHSV2,
220 CODEC_ID_CDGRAPHICS,
221 CODEC_ID_R210,
222 CODEC_ID_ANM,
223 CODEC_ID_BINKVIDEO,
224 CODEC_ID_IFF_ILBM,
225 CODEC_ID_IFF_BYTERUN1,
226 CODEC_ID_KGV1,
227 CODEC_ID_YOP,
228 CODEC_ID_VP8,
229 CODEC_ID_PICTOR,
230 CODEC_ID_ANSI,
231 CODEC_ID_A64_MULTI,
232 CODEC_ID_A64_MULTI5,
233 CODEC_ID_R10K,
234 CODEC_ID_MXPEG,
235 CODEC_ID_LAGARITH,
236 CODEC_ID_PRORES,
237 CODEC_ID_JV,
238 CODEC_ID_DFA,
239 CODEC_ID_WMV3IMAGE,
240 CODEC_ID_VC1IMAGE,
241 CODEC_ID_UTVIDEO,
242 CODEC_ID_BMV_VIDEO,
243 CODEC_ID_VBLE,
244 CODEC_ID_DXTORY,
245 CODEC_ID_V410,
246 CODEC_ID_XWD,
247 CODEC_ID_CDXL,
248 CODEC_ID_XBM,
249
250 /* various PCM "codecs" */
251 CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
252 CODEC_ID_PCM_S16LE = 0x10000,
253 CODEC_ID_PCM_S16BE,
254 CODEC_ID_PCM_U16LE,
255 CODEC_ID_PCM_U16BE,
256 CODEC_ID_PCM_S8,
257 CODEC_ID_PCM_U8,
258 CODEC_ID_PCM_MULAW,
259 CODEC_ID_PCM_ALAW,
260 CODEC_ID_PCM_S32LE,
261 CODEC_ID_PCM_S32BE,
262 CODEC_ID_PCM_U32LE,
263 CODEC_ID_PCM_U32BE,
264 CODEC_ID_PCM_S24LE,
265 CODEC_ID_PCM_S24BE,
266 CODEC_ID_PCM_U24LE,
267 CODEC_ID_PCM_U24BE,
268 CODEC_ID_PCM_S24DAUD,
269 CODEC_ID_PCM_ZORK,
270 CODEC_ID_PCM_S16LE_PLANAR,
271 CODEC_ID_PCM_DVD,
272 CODEC_ID_PCM_F32BE,
273 CODEC_ID_PCM_F32LE,
274 CODEC_ID_PCM_F64BE,
275 CODEC_ID_PCM_F64LE,
276 CODEC_ID_PCM_BLURAY,
277 CODEC_ID_PCM_LXF,
278 CODEC_ID_S302M,
279 CODEC_ID_PCM_S8_PLANAR,
280
281 /* various ADPCM codecs */
282 CODEC_ID_ADPCM_IMA_QT = 0x11000,
283 CODEC_ID_ADPCM_IMA_WAV,
284 CODEC_ID_ADPCM_IMA_DK3,
285 CODEC_ID_ADPCM_IMA_DK4,
286 CODEC_ID_ADPCM_IMA_WS,
287 CODEC_ID_ADPCM_IMA_SMJPEG,
288 CODEC_ID_ADPCM_MS,
289 CODEC_ID_ADPCM_4XM,
290 CODEC_ID_ADPCM_XA,
291 CODEC_ID_ADPCM_ADX,
292 CODEC_ID_ADPCM_EA,
293 CODEC_ID_ADPCM_G726,
294 CODEC_ID_ADPCM_CT,
295 CODEC_ID_ADPCM_SWF,
296 CODEC_ID_ADPCM_YAMAHA,
297 CODEC_ID_ADPCM_SBPRO_4,
298 CODEC_ID_ADPCM_SBPRO_3,
299 CODEC_ID_ADPCM_SBPRO_2,
300 CODEC_ID_ADPCM_THP,
301 CODEC_ID_ADPCM_IMA_AMV,
302 CODEC_ID_ADPCM_EA_R1,
303 CODEC_ID_ADPCM_EA_R3,
304 CODEC_ID_ADPCM_EA_R2,
305 CODEC_ID_ADPCM_IMA_EA_SEAD,
306 CODEC_ID_ADPCM_IMA_EA_EACS,
307 CODEC_ID_ADPCM_EA_XAS,
308 CODEC_ID_ADPCM_EA_MAXIS_XA,
309 CODEC_ID_ADPCM_IMA_ISS,
310 CODEC_ID_ADPCM_G722,
311 CODEC_ID_ADPCM_IMA_APC,
312
313 /* AMR */
314 CODEC_ID_AMR_NB = 0x12000,
315 CODEC_ID_AMR_WB,
316
317 /* RealAudio codecs*/
318 CODEC_ID_RA_144 = 0x13000,
319 CODEC_ID_RA_288,
320
321 /* various DPCM codecs */
322 CODEC_ID_ROQ_DPCM = 0x14000,
323 CODEC_ID_INTERPLAY_DPCM,
324 CODEC_ID_XAN_DPCM,
325 CODEC_ID_SOL_DPCM,
326
327 /* audio codecs */
328 CODEC_ID_MP2 = 0x15000,
329 CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
330 CODEC_ID_AAC,
331 CODEC_ID_AC3,
332 CODEC_ID_DTS,
333 CODEC_ID_VORBIS,
334 CODEC_ID_DVAUDIO,
335 CODEC_ID_WMAV1,
336 CODEC_ID_WMAV2,
337 CODEC_ID_MACE3,
338 CODEC_ID_MACE6,
339 CODEC_ID_VMDAUDIO,
340 CODEC_ID_FLAC,
341 CODEC_ID_MP3ADU,
342 CODEC_ID_MP3ON4,
343 CODEC_ID_SHORTEN,
344 CODEC_ID_ALAC,
345 CODEC_ID_WESTWOOD_SND1,
346 CODEC_ID_GSM, ///< as in Berlin toast format
347 CODEC_ID_QDM2,
348 CODEC_ID_COOK,
349 CODEC_ID_TRUESPEECH,
350 CODEC_ID_TTA,
351 CODEC_ID_SMACKAUDIO,
352 CODEC_ID_QCELP,
353 CODEC_ID_WAVPACK,
354 CODEC_ID_DSICINAUDIO,
355 CODEC_ID_IMC,
356 CODEC_ID_MUSEPACK7,
357 CODEC_ID_MLP,
358 CODEC_ID_GSM_MS, /* as found in WAV */
359 CODEC_ID_ATRAC3,
360 CODEC_ID_VOXWARE,
361 CODEC_ID_APE,
362 CODEC_ID_NELLYMOSER,
363 CODEC_ID_MUSEPACK8,
364 CODEC_ID_SPEEX,
365 CODEC_ID_WMAVOICE,
366 CODEC_ID_WMAPRO,
367 CODEC_ID_WMALOSSLESS,
368 CODEC_ID_ATRAC3P,
369 CODEC_ID_EAC3,
370 CODEC_ID_SIPR,
371 CODEC_ID_MP1,
372 CODEC_ID_TWINVQ,
373 CODEC_ID_TRUEHD,
374 CODEC_ID_MP4ALS,
375 CODEC_ID_ATRAC1,
376 CODEC_ID_BINKAUDIO_RDFT,
377 CODEC_ID_BINKAUDIO_DCT,
378 CODEC_ID_AAC_LATM,
379 CODEC_ID_QDMC,
380 CODEC_ID_CELT,
381 CODEC_ID_G723_1,
382 CODEC_ID_G729,
383 CODEC_ID_8SVX_EXP,
384 CODEC_ID_8SVX_FIB,
385 CODEC_ID_BMV_AUDIO,
386
387 /* subtitle codecs */
388 CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
389 CODEC_ID_DVD_SUBTITLE = 0x17000,
390 CODEC_ID_DVB_SUBTITLE,
391 CODEC_ID_TEXT, ///< raw UTF-8 text
392 CODEC_ID_XSUB,
393 CODEC_ID_SSA,
394 CODEC_ID_MOV_TEXT,
395 CODEC_ID_HDMV_PGS_SUBTITLE,
396 CODEC_ID_DVB_TELETEXT,
397 CODEC_ID_SRT,
398
399 /* other specific kind of codecs (generally used for attachments) */
400 CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
401 CODEC_ID_TTF = 0x18000,
402
403 CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
404
405 CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
406 * stream (only used by libavformat) */
407 CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
408 * stream (only used by libavformat) */
409 CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
410 };
411
412 #if FF_API_OLD_DECODE_AUDIO
413 /* in bytes */
414 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
415 #endif
416
417 /**
418 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
419 * This is mainly needed because some optimized bitstream readers read
420 * 32 or 64 bit at once and could read over the end.<br>
421 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
422 * MPEG bitstreams could cause overread and segfault.
423 */
424 #define FF_INPUT_BUFFER_PADDING_SIZE 8
425
426 /**
427 * minimum encoding buffer size
428 * Used to avoid some checks during header writing.
429 */
430 #define FF_MIN_BUFFER_SIZE 16384
431
432
433 /**
434 * motion estimation type.
435 */
436 enum Motion_Est_ID {
437 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
438 ME_FULL,
439 ME_LOG,
440 ME_PHODS,
441 ME_EPZS, ///< enhanced predictive zonal search
442 ME_X1, ///< reserved for experiments
443 ME_HEX, ///< hexagon based search
444 ME_UMH, ///< uneven multi-hexagon search
445 ME_ITER, ///< iterative search
446 ME_TESA, ///< transformed exhaustive search algorithm
447 };
448
449 enum AVDiscard{
450 /* We leave some space between them for extensions (drop some
451 * keyframes for intra-only or drop just some bidir frames). */
452 AVDISCARD_NONE =-16, ///< discard nothing
453 AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
454 AVDISCARD_NONREF = 8, ///< discard all non reference
455 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
456 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
457 AVDISCARD_ALL = 48, ///< discard all
458 };
459
460 enum AVColorPrimaries{
461 AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
462 AVCOL_PRI_UNSPECIFIED=2,
463 AVCOL_PRI_BT470M =4,
464 AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
465 AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
466 AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above
467 AVCOL_PRI_FILM =8,
468 AVCOL_PRI_NB , ///< Not part of ABI
469 };
470
471 enum AVColorTransferCharacteristic{
472 AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361
473 AVCOL_TRC_UNSPECIFIED=2,
474 AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
475 AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG
476 AVCOL_TRC_NB , ///< Not part of ABI
477 };
478
479 enum AVColorSpace{
480 AVCOL_SPC_RGB =0,
481 AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
482 AVCOL_SPC_UNSPECIFIED=2,
483 AVCOL_SPC_FCC =4,
484 AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
485 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
486 AVCOL_SPC_SMPTE240M =7,
487 AVCOL_SPC_NB , ///< Not part of ABI
488 };
489
490 enum AVColorRange{
491 AVCOL_RANGE_UNSPECIFIED=0,
492 AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
493 AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges
494 AVCOL_RANGE_NB , ///< Not part of ABI
495 };
496
497 /**
498 * X X 3 4 X X are luma samples,
499 * 1 2 1-6 are possible chroma positions
500 * X X 5 6 X 0 is undefined/unknown position
501 */
502 enum AVChromaLocation{
503 AVCHROMA_LOC_UNSPECIFIED=0,
504 AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default
505 AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263
506 AVCHROMA_LOC_TOPLEFT =3, ///< DV
507 AVCHROMA_LOC_TOP =4,
508 AVCHROMA_LOC_BOTTOMLEFT =5,
509 AVCHROMA_LOC_BOTTOM =6,
510 AVCHROMA_LOC_NB , ///< Not part of ABI
511 };
512
513 enum AVAudioServiceType {
514 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
515 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
516 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
517 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
518 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
519 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
520 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
521 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
522 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
523 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
524 };
525
526 typedef struct RcOverride{
527 int start_frame;
528 int end_frame;
529 int qscale; // If this is 0 then quality_factor will be used instead.
530 float quality_factor;
531 } RcOverride;
532
533 #define FF_MAX_B_FRAMES 16
534
535 /* encoding support
536 These flags can be passed in AVCodecContext.flags before initialization.
537 Note: Not everything is supported yet.
538 */
539
540 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
541 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
542 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
543 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
544 #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
545 /**
546 * The parent program guarantees that the input for B-frames containing
547 * streams is not written to for at least s->max_b_frames+1 frames, if
548 * this is not set the input will be copied.
549 */
550 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
551 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
552 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
553 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
554 #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
555 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
556 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
557 location instead of only at frame boundaries. */
558 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
559 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
560 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
561 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
562 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
563 /* Fx : Flag for h263+ extra options */
564 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
565 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
566 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
567 #define CODEC_FLAG_CLOSED_GOP 0x80000000
568 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
569 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
570 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
571 #if FF_API_MPV_GLOBAL_OPTS
572 #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
573 #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
574 #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
575 #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
576 #endif
577 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
578
579 /* Unsupported options :
580 * Syntax Arithmetic coding (SAC)
581 * Reference Picture Selection
582 * Independent Segment Decoding */
583 /* /Fx */
584 /* codec capabilities */
585
586 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
587 /**
588 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
589 * If not set, it might not use get_buffer() at all or use operations that
590 * assume the buffer was allocated by avcodec_default_get_buffer.
591 */
592 #define CODEC_CAP_DR1 0x0002
593 #define CODEC_CAP_TRUNCATED 0x0008
594 /* Codec can export data for HW decoding (XvMC). */
595 #define CODEC_CAP_HWACCEL 0x0010
596 /**
597 * Encoder or decoder requires flushing with NULL input at the end in order to
598 * give the complete and correct output.
599 *
600 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
601 * with NULL data. The user can still send NULL data to the public encode
602 * or decode function, but libavcodec will not pass it along to the codec
603 * unless this flag is set.
604 *
605 * Decoders:
606 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
607 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
608 * returns frames.
609 *
610 * Encoders:
611 * The encoder needs to be fed with NULL data at the end of encoding until the
612 * encoder no longer returns data.
613 *
614 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
615 * flag also means that the encoder must set the pts and duration for
616 * each output packet. If this flag is not set, the pts and duration will
617 * be determined by libavcodec from the input frame.
618 */
619 #define CODEC_CAP_DELAY 0x0020
620 /**
621 * Codec can be fed a final frame with a smaller size.
622 * This can be used to prevent truncation of the last audio samples.
623 */
624 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
625 /**
626 * Codec can export data for HW decoding (VDPAU).
627 */
628 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
629 /**
630 * Codec can output multiple frames per AVPacket
631 * Normally demuxers return one frame at a time, demuxers which do not do
632 * are connected to a parser to split what they return into proper frames.
633 * This flag is reserved to the very rare category of codecs which have a
634 * bitstream that cannot be split into frames without timeconsuming
635 * operations like full decoding. Demuxers carring such bitstreams thus
636 * may return multiple frames in a packet. This has many disadvantages like
637 * prohibiting stream copy in many cases thus it should only be considered
638 * as a last resort.
639 */
640 #define CODEC_CAP_SUBFRAMES 0x0100
641 /**
642 * Codec is experimental and is thus avoided in favor of non experimental
643 * encoders
644 */
645 #define CODEC_CAP_EXPERIMENTAL 0x0200
646 /**
647 * Codec should fill in channel configuration and samplerate instead of container
648 */
649 #define CODEC_CAP_CHANNEL_CONF 0x0400
650 /**
651 * Codec is able to deal with negative linesizes
652 */
653 #define CODEC_CAP_NEG_LINESIZES 0x0800
654 /**
655 * Codec supports frame-level multithreading.
656 */
657 #define CODEC_CAP_FRAME_THREADS 0x1000
658 /**
659 * Codec supports slice-based (or partition-based) multithreading.
660 */
661 #define CODEC_CAP_SLICE_THREADS 0x2000
662 /**
663 * Codec supports changed parameters at any point.
664 */
665 #define CODEC_CAP_PARAM_CHANGE 0x4000
666 /**
667 * Codec supports avctx->thread_count == 0 (auto).
668 */
669 #define CODEC_CAP_AUTO_THREADS 0x8000
670 /**
671 * Audio encoder supports receiving a different number of samples in each call.
672 */
673 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
674
675 //The following defines may change, don't expect compatibility if you use them.
676 #define MB_TYPE_INTRA4x4 0x0001
677 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
678 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
679 #define MB_TYPE_16x16 0x0008
680 #define MB_TYPE_16x8 0x0010
681 #define MB_TYPE_8x16 0x0020
682 #define MB_TYPE_8x8 0x0040
683 #define MB_TYPE_INTERLACED 0x0080
684 #define MB_TYPE_DIRECT2 0x0100 //FIXME
685 #define MB_TYPE_ACPRED 0x0200
686 #define MB_TYPE_GMC 0x0400
687 #define MB_TYPE_SKIP 0x0800
688 #define MB_TYPE_P0L0 0x1000
689 #define MB_TYPE_P1L0 0x2000
690 #define MB_TYPE_P0L1 0x4000
691 #define MB_TYPE_P1L1 0x8000
692 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
693 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
694 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
695 #define MB_TYPE_QUANT 0x00010000
696 #define MB_TYPE_CBP 0x00020000
697 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
698
699 /**
700 * Pan Scan area.
701 * This specifies the area which should be displayed.
702 * Note there may be multiple such areas for one frame.
703 */
704 typedef struct AVPanScan{
705 /**
706 * id
707 * - encoding: Set by user.
708 * - decoding: Set by libavcodec.
709 */
710 int id;
711
712 /**
713 * width and height in 1/16 pel
714 * - encoding: Set by user.
715 * - decoding: Set by libavcodec.
716 */
717 int width;
718 int height;
719
720 /**
721 * position of the top left corner in 1/16 pel for up to 3 fields/frames
722 * - encoding: Set by user.
723 * - decoding: Set by libavcodec.
724 */
725 int16_t position[3][2];
726 }AVPanScan;
727
728 #define FF_QSCALE_TYPE_MPEG1 0
729 #define FF_QSCALE_TYPE_MPEG2 1
730 #define FF_QSCALE_TYPE_H264 2
731 #define FF_QSCALE_TYPE_VP56 3
732
733 #define FF_BUFFER_TYPE_INTERNAL 1
734 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
735 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
736 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
737
738 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
739 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
740 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
741 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
742
743 enum AVPacketSideDataType {
744 AV_PKT_DATA_PALETTE,
745 AV_PKT_DATA_NEW_EXTRADATA,
746 AV_PKT_DATA_PARAM_CHANGE,
747 AV_PKT_DATA_H263_MB_INFO,
748 };
749
750 typedef struct AVPacket {
751 /**
752 * Presentation timestamp in AVStream->time_base units; the time at which
753 * the decompressed packet will be presented to the user.
754 * Can be AV_NOPTS_VALUE if it is not stored in the file.
755 * pts MUST be larger or equal to dts as presentation cannot happen before
756 * decompression, unless one wants to view hex dumps. Some formats misuse
757 * the terms dts and pts/cts to mean something different. Such timestamps
758 * must be converted to true pts/dts before they are stored in AVPacket.
759 */
760 int64_t pts;
761 /**
762 * Decompression timestamp in AVStream->time_base units; the time at which
763 * the packet is decompressed.
764 * Can be AV_NOPTS_VALUE if it is not stored in the file.
765 */
766 int64_t dts;
767 uint8_t *data;
768 int size;
769 int stream_index;
770 /**
771 * A combination of AV_PKT_FLAG values
772 */
773 int flags;
774 /**
775 * Additional packet data that can be provided by the container.
776 * Packet can contain several types of side information.
777 */
778 struct {
779 uint8_t *data;
780 int size;
781 enum AVPacketSideDataType type;
782 } *side_data;
783 int side_data_elems;
784
785 /**
786 * Duration of this packet in AVStream->time_base units, 0 if unknown.
787 * Equals next_pts - this_pts in presentation order.
788 */
789 int duration;
790 void (*destruct)(struct AVPacket *);
791 void *priv;
792 int64_t pos; ///< byte position in stream, -1 if unknown
793
794 /**
795 * Time difference in AVStream->time_base units from the pts of this
796 * packet to the point at which the output from the decoder has converged
797 * independent from the availability of previous frames. That is, the
798 * frames are virtually identical no matter if decoding started from
799 * the very first frame or from this keyframe.
800 * Is AV_NOPTS_VALUE if unknown.
801 * This field is not the display duration of the current packet.
802 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
803 * set.
804 *
805 * The purpose of this field is to allow seeking in streams that have no
806 * keyframes in the conventional sense. It corresponds to the
807 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
808 * essential for some types of subtitle streams to ensure that all
809 * subtitles are correctly displayed after seeking.
810 */
811 int64_t convergence_duration;
812 } AVPacket;
813 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
814 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
815
816 /**
817 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
818 * u32le param_flags
819 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
820 * s32le channel_count
821 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
822 * u64le channel_layout
823 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
824 * s32le sample_rate
825 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
826 * s32le width
827 * s32le height
828 */
829
830 /**
831 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
832 * structures with info about macroblocks relevant to splitting the
833 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
834 * That is, it does not necessarily contain info about all macroblocks,
835 * as long as the distance between macroblocks in the info is smaller
836 * than the target payload size.
837 * Each MB info structure is 12 bytes, and is laid out as follows:
838 * u32le bit offset from the start of the packet
839 * u8 current quantizer at the start of the macroblock
840 * u8 GOB number
841 * u16le macroblock address within the GOB
842 * u8 horizontal MV predictor
843 * u8 vertical MV predictor
844 * u8 horizontal MV predictor for block number 3
845 * u8 vertical MV predictor for block number 3
846 */
847
848 enum AVSideDataParamChangeFlags {
849 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
850 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
851 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
852 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
853 };
854
855 /**
856 * Audio Video Frame.
857 * New fields can be added to the end of AVFRAME with minor version
858 * bumps. Removal, reordering and changes to existing fields require
859 * a major version bump.
860 * sizeof(AVFrame) must not be used outside libav*.
861 */
862 typedef struct AVFrame {
863 #define AV_NUM_DATA_POINTERS 8
864 /**
865 * pointer to the picture/channel planes.
866 * This might be different from the first allocated byte
867 * - encoding: Set by user
868 * - decoding: set by AVCodecContext.get_buffer()
869 */
870 uint8_t *data[AV_NUM_DATA_POINTERS];
871
872 /**
873 * Size, in bytes, of the data for each picture/channel plane.
874 *
875 * For audio, only linesize[0] may be set. For planar audio, each channel
876 * plane must be the same size.
877 *
878 * - encoding: Set by user
879 * - decoding: set by AVCodecContext.get_buffer()
880 */
881 int linesize[AV_NUM_DATA_POINTERS];
882
883 /**
884 * pointers to the data planes/channels.
885 *
886 * For video, this should simply point to data[].
887 *
888 * For planar audio, each channel has a separate data pointer, and
889 * linesize[0] contains the size of each channel buffer.
890 * For packed audio, there is just one data pointer, and linesize[0]
891 * contains the total size of the buffer for all channels.
892 *
893 * Note: Both data and extended_data will always be set by get_buffer(),
894 * but for planar audio with more channels that can fit in data,
895 * extended_data must be used by the decoder in order to access all
896 * channels.
897 *
898 * encoding: unused
899 * decoding: set by AVCodecContext.get_buffer()
900 */
901 uint8_t **extended_data;
902
903 /**
904 * width and height of the video frame
905 * - encoding: unused
906 * - decoding: Read by user.
907 */
908 int width, height;
909
910 /**
911 * number of audio samples (per channel) described by this frame
912 * - encoding: Set by user
913 * - decoding: Set by libavcodec
914 */
915 int nb_samples;
916
917 /**
918 * format of the frame, -1 if unknown or unset
919 * Values correspond to enum PixelFormat for video frames,
920 * enum AVSampleFormat for audio)
921 * - encoding: unused
922 * - decoding: Read by user.
923 */
924 int format;
925
926 /**
927 * 1 -> keyframe, 0-> not
928 * - encoding: Set by libavcodec.
929 * - decoding: Set by libavcodec.
930 */
931 int key_frame;
932
933 /**
934 * Picture type of the frame, see ?_TYPE below.
935 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
936 * - decoding: Set by libavcodec.
937 */
938 enum AVPictureType pict_type;
939
940 /**
941 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
942 * This isn't used by libavcodec unless the default get/release_buffer() is used.
943 * - encoding:
944 * - decoding:
945 */
946 uint8_t *base[AV_NUM_DATA_POINTERS];
947
948 /**
949 * sample aspect ratio for the video frame, 0/1 if unknown\unspecified
950 * - encoding: unused
951 * - decoding: Read by user.
952 */
953 AVRational sample_aspect_ratio;
954
955 /**
956 * presentation timestamp in time_base units (time when frame should be shown to user)
957 * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
958 * - encoding: MUST be set by user.
959 * - decoding: Set by libavcodec.
960 */
961 int64_t pts;
962
963 /**
964 * reordered pts from the last AVPacket that has been input into the decoder
965 * - encoding: unused
966 * - decoding: Read by user.
967 */
968 int64_t pkt_pts;
969
970 /**
971 * dts from the last AVPacket that has been input into the decoder
972 * - encoding: unused
973 * - decoding: Read by user.
974 */
975 int64_t pkt_dts;
976
977 /**
978 * picture number in bitstream order
979 * - encoding: set by
980 * - decoding: Set by libavcodec.
981 */
982 int coded_picture_number;
983 /**
984 * picture number in display order
985 * - encoding: set by
986 * - decoding: Set by libavcodec.
987 */
988 int display_picture_number;
989
990 /**
991 * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
992 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
993 * - decoding: Set by libavcodec.
994 */
995 int quality;
996
997 /**
998 * is this picture used as reference
999 * The values for this are the same as the MpegEncContext.picture_structure
1000 * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1001 * Set to 4 for delayed, non-reference frames.
1002 * - encoding: unused
1003 * - decoding: Set by libavcodec. (before get_buffer() call)).
1004 */
1005 int reference;
1006
1007 /**
1008 * QP table
1009 * - encoding: unused
1010 * - decoding: Set by libavcodec.
1011 */
1012 int8_t *qscale_table;
1013 /**
1014 * QP store stride
1015 * - encoding: unused
1016 * - decoding: Set by libavcodec.
1017 */
1018 int qstride;
1019
1020 /**
1021 *
1022 */
1023 int qscale_type;
1024
1025 /**
1026 * mbskip_table[mb]>=1 if MB didn't change
1027 * stride= mb_width = (width+15)>>4
1028 * - encoding: unused
1029 * - decoding: Set by libavcodec.
1030 */
1031 uint8_t *mbskip_table;
1032
1033 /**
1034 * motion vector table
1035 * @code
1036 * example:
1037 * int mv_sample_log2= 4 - motion_subsample_log2;
1038 * int mb_width= (width+15)>>4;
1039 * int mv_stride= (mb_width << mv_sample_log2) + 1;
1040 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1041 * @endcode
1042 * - encoding: Set by user.
1043 * - decoding: Set by libavcodec.
1044 */
1045 int16_t (*motion_val[2])[2];
1046
1047 /**
1048 * macroblock type table
1049 * mb_type_base + mb_width + 2
1050 * - encoding: Set by user.
1051 * - decoding: Set by libavcodec.
1052 */
1053 uint32_t *mb_type;
1054
1055 /**
1056 * DCT coefficients
1057 * - encoding: unused
1058 * - decoding: Set by libavcodec.
1059 */
1060 short *dct_coeff;
1061
1062 /**
1063 * motion reference frame index
1064 * the order in which these are stored can depend on the codec.
1065 * - encoding: Set by user.
1066 * - decoding: Set by libavcodec.
1067 */
1068 int8_t *ref_index[2];
1069
1070 /**
1071 * for some private data of the user
1072 * - encoding: unused
1073 * - decoding: Set by user.
1074 */
1075 void *opaque;
1076
1077 /**
1078 * error
1079 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1080 * - decoding: unused
1081 */
1082 uint64_t error[AV_NUM_DATA_POINTERS];
1083
1084 /**
1085 * type of the buffer (to keep track of who has to deallocate data[*])
1086 * - encoding: Set by the one who allocates it.
1087 * - decoding: Set by the one who allocates it.
1088 * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1089 */
1090 int type;
1091
1092 /**
1093 * When decoding, this signals how much the picture must be delayed.
1094 * extra_delay = repeat_pict / (2*fps)
1095 * - encoding: unused
1096 * - decoding: Set by libavcodec.
1097 */
1098 int repeat_pict;
1099
1100 /**
1101 * The content of the picture is interlaced.
1102 * - encoding: Set by user.
1103 * - decoding: Set by libavcodec. (default 0)
1104 */
1105 int interlaced_frame;
1106
1107 /**
1108 * If the content is interlaced, is top field displayed first.
1109 * - encoding: Set by user.
1110 * - decoding: Set by libavcodec.
1111 */
1112 int top_field_first;
1113
1114 /**
1115 * Tell user application that palette has changed from previous frame.
1116 * - encoding: ??? (no palette-enabled encoder yet)
1117 * - decoding: Set by libavcodec. (default 0).
1118 */
1119 int palette_has_changed;
1120
1121 /**
1122 * codec suggestion on buffer type if != 0
1123 * - encoding: unused
1124 * - decoding: Set by libavcodec. (before get_buffer() call)).
1125 */
1126 int buffer_hints;
1127
1128 /**
1129 * Pan scan.
1130 * - encoding: Set by user.
1131 * - decoding: Set by libavcodec.
1132 */
1133 AVPanScan *pan_scan;
1134
1135 /**
1136 * reordered opaque 64bit (generally an integer or a double precision float
1137 * PTS but can be anything).
1138 * The user sets AVCodecContext.reordered_opaque to represent the input at
1139 * that time,
1140 * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1141 * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1142 * @deprecated in favor of pkt_pts
1143 * - encoding: unused
1144 * - decoding: Read by user.
1145 */
1146 int64_t reordered_opaque;
1147
1148 /**
1149 * hardware accelerator private data (Libav-allocated)
1150 * - encoding: unused
1151 * - decoding: Set by libavcodec
1152 */
1153 void *hwaccel_picture_private;
1154
1155 /**
1156 * the AVCodecContext which ff_thread_get_buffer() was last called on
1157 * - encoding: Set by libavcodec.
1158 * - decoding: Set by libavcodec.
1159 */
1160 struct AVCodecContext *owner;
1161
1162 /**
1163 * used by multithreading to store frame-specific info
1164 * - encoding: Set by libavcodec.
1165 * - decoding: Set by libavcodec.
1166 */
1167 void *thread_opaque;
1168
1169 /**
1170 * log2 of the size of the block which a single vector in motion_val represents:
1171 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1172 * - encoding: unused
1173 * - decoding: Set by libavcodec.
1174 */
1175 uint8_t motion_subsample_log2;
1176 } AVFrame;
1177
1178 struct AVCodecInternal;
1179
1180 enum AVFieldOrder {
1181 AV_FIELD_UNKNOWN,
1182 AV_FIELD_PROGRESSIVE,
1183 AV_FIELD_TT, //< Top coded_first, top displayed first
1184 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1185 AV_FIELD_TB, //< Top coded first, bottom displayed first
1186 AV_FIELD_BT, //< Bottom coded first, top displayed first
1187 };
1188
1189 /**
1190 * main external API structure.
1191 * New fields can be added to the end with minor version bumps.
1192 * Removal, reordering and changes to existing fields require a major
1193 * version bump.
1194 * sizeof(AVCodecContext) must not be used outside libav*.
1195 */
1196 typedef struct AVCodecContext {
1197 /**
1198 * information on struct for av_log
1199 * - set by avcodec_alloc_context3
1200 */
1201 const AVClass *av_class;
1202 int log_level_offset;
1203
1204 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1205 struct AVCodec *codec;
1206 char codec_name[32];
1207 enum CodecID codec_id; /* see CODEC_ID_xxx */
1208
1209 /**
1210 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1211 * This is used to work around some encoder bugs.
1212 * A demuxer should set this to what is stored in the field used to identify the codec.
1213 * If there are multiple such fields in a container then the demuxer should choose the one
1214 * which maximizes the information about the used codec.
1215 * If the codec tag field in a container is larger than 32 bits then the demuxer should
1216 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1217 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1218 * first.
1219 * - encoding: Set by user, if not then the default based on codec_id will be used.
1220 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1221 */
1222 unsigned int codec_tag;
1223
1224 /**
1225 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1226 * This is used to work around some encoder bugs.
1227 * - encoding: unused
1228 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1229 */
1230 unsigned int stream_codec_tag;
1231
1232 #if FF_API_SUB_ID
1233 /**
1234 * @deprecated this field is unused
1235 */
1236 attribute_deprecated int sub_id;
1237 #endif
1238
1239 void *priv_data;
1240
1241 /**
1242 * Private context used for internal data.
1243 *
1244 * Unlike priv_data, this is not codec-specific. It is used in general
1245 * libavcodec functions.
1246 */
1247 struct AVCodecInternal *internal;
1248
1249 /**
1250 * Private data of the user, can be used to carry app specific stuff.
1251 * - encoding: Set by user.
1252 * - decoding: Set by user.
1253 */
1254 void *opaque;
1255
1256 /**
1257 * the average bitrate
1258 * - encoding: Set by user; unused for constant quantizer encoding.
1259 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1260 */
1261 int bit_rate;
1262
1263 /**
1264 * number of bits the bitstream is allowed to diverge from the reference.
1265 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1266 * - encoding: Set by user; unused for constant quantizer encoding.
1267 * - decoding: unused
1268 */
1269 int bit_rate_tolerance;
1270
1271 /**
1272 * Global quality for codecs which cannot change it per frame.
1273 * This should be proportional to MPEG-1/2/4 qscale.
1274 * - encoding: Set by user.
1275 * - decoding: unused
1276 */
1277 int global_quality;
1278
1279 /**
1280 * - encoding: Set by user.
1281 * - decoding: unused
1282 */
1283 int compression_level;
1284 #define FF_COMPRESSION_DEFAULT -1
1285
1286 /**
1287 * CODEC_FLAG_*.
1288 * - encoding: Set by user.
1289 * - decoding: Set by user.
1290 */
1291 int flags;
1292
1293 /**
1294 * CODEC_FLAG2_*
1295 * - encoding: Set by user.
1296 * - decoding: Set by user.
1297 */
1298 int flags2;
1299
1300 /**
1301 * some codecs need / can use extradata like Huffman tables.
1302 * mjpeg: Huffman tables
1303 * rv10: additional flags
1304 * mpeg4: global headers (they can be in the bitstream or here)
1305 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1306 * than extradata_size to avoid prolems if it is read with the bitstream reader.
1307 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1308 * - encoding: Set/allocated/freed by libavcodec.
1309 * - decoding: Set/allocated/freed by user.
1310 */
1311 uint8_t *extradata;
1312 int extradata_size;
1313
1314 /**
1315 * This is the fundamental unit of time (in seconds) in terms
1316 * of which frame timestamps are represented. For fixed-fps content,
1317 * timebase should be 1/framerate and timestamp increments should be
1318 * identically 1.
1319 * - encoding: MUST be set by user.
1320 * - decoding: Set by libavcodec.
1321 */
1322 AVRational time_base;
1323
1324 /**
1325 * For some codecs, the time base is closer to the field rate than the frame rate.
1326 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1327 * if no telecine is used ...
1328 *
1329 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1330 */
1331 int ticks_per_frame;
1332
1333 /**
1334 * Encoder delay.
1335 *
1336 * Video:
1337 * Number of frames the decoded output will be delayed relative to the
1338 * encoded input.
1339 *
1340 * Audio:
1341 * Number of "priming" samples added to the beginning of the stream
1342 * during encoding. The decoded output will be delayed by this many
1343 * samples relative to the input to the encoder. Note that this field is
1344 * purely informational and does not directly affect the pts output by
1345 * the encoder, which should always be based on the actual presentation
1346 * time, including any delay.
1347 *
1348 * - encoding: Set by libavcodec.
1349 * - decoding: unused
1350 */
1351 int delay;
1352
1353
1354 /* video only */
1355 /**
1356 * picture width / height.
1357 * - encoding: MUST be set by user.
1358 * - decoding: Set by libavcodec.
1359 * Note: For compatibility it is possible to set this instead of
1360 * coded_width/height before decoding.
1361 */
1362 int width, height;
1363
1364 /**
1365 * Bitstream width / height, may be different from width/height if lowres enabled.
1366 * - encoding: unused
1367 * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
1368 */
1369 int coded_width, coded_height;
1370
1371 #define FF_ASPECT_EXTENDED 15
1372
1373 /**
1374 * the number of pictures in a group of pictures, or 0 for intra_only
1375 * - encoding: Set by user.
1376 * - decoding: unused
1377 */
1378 int gop_size;
1379
1380 /**
1381 * Pixel format, see PIX_FMT_xxx.
1382 * May be set by the demuxer if known from headers.
1383 * May be overriden by the decoder if it knows better.
1384 * - encoding: Set by user.
1385 * - decoding: Set by user if known, overridden by libavcodec if known
1386 */
1387 enum PixelFormat pix_fmt;
1388
1389 /**
1390 * Motion estimation algorithm used for video coding.
1391 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1392 * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1393 * - encoding: MUST be set by user.
1394 * - decoding: unused
1395 */
1396 int me_method;
1397
1398 /**
1399 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1400 * decoder to draw a horizontal band. It improves cache usage. Not
1401 * all codecs can do that. You must check the codec capabilities
1402 * beforehand.
1403 * When multithreading is used, it may be called from multiple threads
1404 * at the same time; threads might draw different parts of the same AVFrame,
1405 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1406 * in order.
1407 * The function is also used by hardware acceleration APIs.
1408 * It is called at least once during frame decoding to pass
1409 * the data needed for hardware render.
1410 * In that mode instead of pixel data, AVFrame points to
1411 * a structure specific to the acceleration API. The application
1412 * reads the structure and can change some fields to indicate progress
1413 * or mark state.
1414 * - encoding: unused
1415 * - decoding: Set by user.
1416 * @param height the height of the slice
1417 * @param y the y position of the slice
1418 * @param type 1->top field, 2->bottom field, 3->frame
1419 * @param offset offset into the AVFrame.data from which the slice should be read
1420 */
1421 void (*draw_horiz_band)(struct AVCodecContext *s,
1422 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1423 int y, int type, int height);
1424
1425 /**
1426 * callback to negotiate the pixelFormat
1427 * @param fmt is the list of formats which are supported by the codec,
1428 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1429 * The first is always the native one.
1430 * @return the chosen format
1431 * - encoding: unused
1432 * - decoding: Set by user, if not set the native format will be chosen.
1433 */
1434 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
1435
1436 /**
1437 * maximum number of B-frames between non-B-frames
1438 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1439 * - encoding: Set by user.
1440 * - decoding: unused
1441 */
1442 int max_b_frames;
1443
1444 /**
1445 * qscale factor between IP and B-frames
1446 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1447 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1448 * - encoding: Set by user.
1449 * - decoding: unused
1450 */
1451 float b_quant_factor;
1452
1453 /** obsolete FIXME remove */
1454 int rc_strategy;
1455 #define FF_RC_STRATEGY_XVID 1
1456
1457 int b_frame_strategy;
1458
1459 #if FF_API_MPV_GLOBAL_OPTS
1460 /**
1461 * luma single coefficient elimination threshold
1462 * - encoding: Set by user.
1463 * - decoding: unused
1464 */
1465 attribute_deprecated int luma_elim_threshold;
1466
1467 /**
1468 * chroma single coeff elimination threshold
1469 * - encoding: Set by user.
1470 * - decoding: unused
1471 */
1472 attribute_deprecated int chroma_elim_threshold;
1473 #endif
1474
1475 /**
1476 * qscale offset between IP and B-frames
1477 * - encoding: Set by user.
1478 * - decoding: unused
1479 */
1480 float b_quant_offset;
1481
1482 /**
1483 * Size of the frame reordering buffer in the decoder.
1484 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1485 * - encoding: Set by libavcodec.
1486 * - decoding: Set by libavcodec.
1487 */
1488 int has_b_frames;
1489
1490 /**
1491 * 0-> h263 quant 1-> mpeg quant
1492 * - encoding: Set by user.
1493 * - decoding: unused
1494 */
1495 int mpeg_quant;
1496
1497 /**
1498 * qscale factor between P and I-frames
1499 * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1500 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1501 * - encoding: Set by user.
1502 * - decoding: unused
1503 */
1504 float i_quant_factor;
1505
1506 /**
1507 * qscale offset between P and I-frames
1508 * - encoding: Set by user.
1509 * - decoding: unused
1510 */
1511 float i_quant_offset;
1512
1513 /**
1514 * luminance masking (0-> disabled)
1515 * - encoding: Set by user.
1516 * - decoding: unused
1517 */
1518 float lumi_masking;
1519
1520 /**
1521 * temporary complexity masking (0-> disabled)
1522 * - encoding: Set by user.
1523 * - decoding: unused
1524 */
1525 float temporal_cplx_masking;
1526
1527 /**
1528 * spatial complexity masking (0-> disabled)
1529 * - encoding: Set by user.
1530 * - decoding: unused
1531 */
1532 float spatial_cplx_masking;
1533
1534 /**
1535 * p block masking (0-> disabled)
1536 * - encoding: Set by user.
1537 * - decoding: unused
1538 */
1539 float p_masking;
1540
1541 /**
1542 * darkness masking (0-> disabled)
1543 * - encoding: Set by user.
1544 * - decoding: unused
1545 */
1546 float dark_masking;
1547
1548 /**
1549 * slice count
1550 * - encoding: Set by libavcodec.
1551 * - decoding: Set by user (or 0).
1552 */
1553 int slice_count;
1554 /**
1555 * prediction method (needed for huffyuv)
1556 * - encoding: Set by user.
1557 * - decoding: unused
1558 */
1559 int prediction_method;
1560 #define FF_PRED_LEFT 0
1561 #define FF_PRED_PLANE 1
1562 #define FF_PRED_MEDIAN 2
1563
1564 /**
1565 * slice offsets in the frame in bytes
1566 * - encoding: Set/allocated by libavcodec.
1567 * - decoding: Set/allocated by user (or NULL).
1568 */
1569 int *slice_offset;
1570
1571 /**
1572 * sample aspect ratio (0 if unknown)
1573 * That is the width of a pixel divided by the height of the pixel.
1574 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1575 * - encoding: Set by user.
1576 * - decoding: Set by libavcodec.
1577 */
1578 AVRational sample_aspect_ratio;
1579
1580 /**
1581 * motion estimation comparison function
1582 * - encoding: Set by user.
1583 * - decoding: unused
1584 */
1585 int me_cmp;
1586 /**
1587 * subpixel motion estimation comparison function
1588 * - encoding: Set by user.
1589 * - decoding: unused
1590 */
1591 int me_sub_cmp;
1592 /**
1593 * macroblock comparison function (not supported yet)
1594 * - encoding: Set by user.
1595 * - decoding: unused
1596 */
1597 int mb_cmp;
1598 /**
1599 * interlaced DCT comparison function
1600 * - encoding: Set by user.
1601 * - decoding: unused
1602 */
1603 int ildct_cmp;
1604 #define FF_CMP_SAD 0
1605 #define FF_CMP_SSE 1
1606 #define FF_CMP_SATD 2
1607 #define FF_CMP_DCT 3
1608 #define FF_CMP_PSNR 4
1609 #define FF_CMP_BIT 5
1610 #define FF_CMP_RD 6
1611 #define FF_CMP_ZERO 7
1612 #define FF_CMP_VSAD 8
1613 #define FF_CMP_VSSE 9
1614 #define FF_CMP_NSSE 10
1615 #define FF_CMP_W53 11
1616 #define FF_CMP_W97 12
1617 #define FF_CMP_DCTMAX 13
1618 #define FF_CMP_DCT264 14
1619 #define FF_CMP_CHROMA 256
1620
1621 /**
1622 * ME diamond size & shape
1623 * - encoding: Set by user.
1624 * - decoding: unused
1625 */
1626 int dia_size;
1627
1628 /**
1629 * amount of previous MV predictors (2a+1 x 2a+1 square)
1630 * - encoding: Set by user.
1631 * - decoding: unused
1632 */
1633 int last_predictor_count;
1634
1635 /**
1636 * prepass for motion estimation
1637 * - encoding: Set by user.
1638 * - decoding: unused
1639 */
1640 int pre_me;
1641
1642 /**
1643 * motion estimation prepass comparison function
1644 * - encoding: Set by user.
1645 * - decoding: unused
1646 */
1647 int me_pre_cmp;
1648
1649 /**
1650 * ME prepass diamond size & shape
1651 * - encoding: Set by user.
1652 * - decoding: unused
1653 */
1654 int pre_dia_size;
1655
1656 /**
1657 * subpel ME quality
1658 * - encoding: Set by user.
1659 * - decoding: unused
1660 */
1661 int me_subpel_quality;
1662
1663 /**
1664 * DTG active format information (additional aspect ratio
1665 * information only used in DVB MPEG-2 transport streams)
1666 * 0 if not set.
1667 *
1668 * - encoding: unused
1669 * - decoding: Set by decoder.
1670 */
1671 int dtg_active_format;
1672 #define FF_DTG_AFD_SAME 8
1673 #define FF_DTG_AFD_4_3 9
1674 #define FF_DTG_AFD_16_9 10
1675 #define FF_DTG_AFD_14_9 11
1676 #define FF_DTG_AFD_4_3_SP_14_9 13
1677 #define FF_DTG_AFD_16_9_SP_14_9 14
1678 #define FF_DTG_AFD_SP_4_3 15
1679
1680 /**
1681 * maximum motion estimation search range in subpel units
1682 * If 0 then no limit.
1683 *
1684 * - encoding: Set by user.
1685 * - decoding: unused
1686 */
1687 int me_range;
1688
1689 /**
1690 * intra quantizer bias
1691 * - encoding: Set by user.
1692 * - decoding: unused
1693 */
1694 int intra_quant_bias;
1695 #define FF_DEFAULT_QUANT_BIAS 999999
1696
1697 /**
1698 * inter quantizer bias
1699 * - encoding: Set by user.
1700 * - decoding: unused
1701 */
1702 int inter_quant_bias;
1703
1704 #if FF_API_COLOR_TABLE_ID
1705 /**
1706 * color table ID
1707 * - encoding: unused
1708 * - decoding: Which clrtable should be used for 8bit RGB images.
1709 * Tables have to be stored somewhere. FIXME
1710 */
1711 attribute_deprecated int color_table_id;
1712 #endif
1713
1714 /**
1715 * slice flags
1716 * - encoding: unused
1717 * - decoding: Set by user.
1718 */
1719 int slice_flags;
1720 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1721 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1722 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1723
1724 /**
1725 * XVideo Motion Acceleration
1726 * - encoding: forbidden
1727 * - decoding: set by decoder
1728 */
1729 int xvmc_acceleration;
1730
1731 /**
1732 * macroblock decision mode
1733 * - encoding: Set by user.
1734 * - decoding: unused
1735 */
1736 int mb_decision;
1737 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1738 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1739 #define FF_MB_DECISION_RD 2 ///< rate distortion
1740
1741 /**
1742 * custom intra quantization matrix
1743 * - encoding: Set by user, can be NULL.
1744 * - decoding: Set by libavcodec.
1745 */
1746 uint16_t *intra_matrix;
1747
1748 /**
1749 * custom inter quantization matrix
1750 * - encoding: Set by user, can be NULL.
1751 * - decoding: Set by libavcodec.
1752 */
1753 uint16_t *inter_matrix;
1754
1755 /**
1756 * scene change detection threshold
1757 * 0 is default, larger means fewer detected scene changes.
1758 * - encoding: Set by user.
1759 * - decoding: unused
1760 */
1761 int scenechange_threshold;
1762
1763 /**
1764 * noise reduction strength
1765 * - encoding: Set by user.
1766 * - decoding: unused
1767 */
1768 int noise_reduction;
1769
1770 #if FF_API_INTER_THRESHOLD
1771 /**
1772 * @deprecated this field is unused
1773 */
1774 attribute_deprecated int inter_threshold;
1775 #endif
1776
1777 #if FF_API_MPV_GLOBAL_OPTS
1778 /**
1779 * @deprecated use mpegvideo private options instead
1780 */
1781 attribute_deprecated int quantizer_noise_shaping;
1782 #endif
1783
1784 /**
1785 * Motion estimation threshold below which no motion estimation is
1786 * performed, but instead the user specified motion vectors are used.
1787 *
1788 * - encoding: Set by user.
1789 * - decoding: unused
1790 */
1791 int me_threshold;
1792
1793 /**
1794 * Macroblock threshold below which the user specified macroblock types will be used.
1795 * - encoding: Set by user.
1796 * - decoding: unused
1797 */
1798 int mb_threshold;
1799
1800 /**
1801 * precision of the intra DC coefficient - 8
1802 * - encoding: Set by user.
1803 * - decoding: unused
1804 */
1805 int intra_dc_precision;
1806
1807 /**
1808 * Number of macroblock rows at the top which are skipped.
1809 * - encoding: unused
1810 * - decoding: Set by user.
1811 */
1812 int skip_top;
1813
1814 /**
1815 * Number of macroblock rows at the bottom which are skipped.
1816 * - encoding: unused
1817 * - decoding: Set by user.
1818 */
1819 int skip_bottom;
1820
1821 /**
1822 * Border processing masking, raises the quantizer for mbs on the borders
1823 * of the picture.
1824 * - encoding: Set by user.
1825 * - decoding: unused
1826 */
1827 float border_masking;
1828
1829 /**
1830 * minimum MB lagrange multipler
1831 * - encoding: Set by user.
1832 * - decoding: unused
1833 */
1834 int mb_lmin;
1835
1836 /**
1837 * maximum MB lagrange multipler
1838 * - encoding: Set by user.
1839 * - decoding: unused
1840 */
1841 int mb_lmax;
1842
1843 /**
1844 *
1845 * - encoding: Set by user.
1846 * - decoding: unused
1847 */
1848 int me_penalty_compensation;
1849
1850 /**
1851 *
1852 * - encoding: Set by user.
1853 * - decoding: unused
1854 */
1855 int bidir_refine;
1856
1857 /**
1858 *
1859 * - encoding: Set by user.
1860 * - decoding: unused
1861 */
1862 int brd_scale;
1863
1864 /**
1865 * minimum GOP size
1866 * - encoding: Set by user.
1867 * - decoding: unused
1868 */
1869 int keyint_min;
1870
1871 /**
1872 * number of reference frames
1873 * - encoding: Set by user.
1874 * - decoding: Set by lavc.
1875 */
1876 int refs;
1877
1878 /**
1879 * chroma qp offset from luma
1880 * - encoding: Set by user.
1881 * - decoding: unused
1882 */
1883 int chromaoffset;
1884
1885 /**
1886 * Multiplied by qscale for each frame and added to scene_change_score.
1887 * - encoding: Set by user.
1888 * - decoding: unused
1889 */
1890 int scenechange_factor;
1891
1892 /**
1893 *
1894 * Note: Value depends upon the compare function used for fullpel ME.
1895 * - encoding: Set by user.
1896 * - decoding: unused
1897 */
1898 int mv0_threshold;
1899
1900 /**
1901 * Adjust sensitivity of b_frame_strategy 1.
1902 * - encoding: Set by user.
1903 * - decoding: unused
1904 */
1905 int b_sensitivity;
1906
1907 /**
1908 * Chromaticity coordinates of the source primaries.
1909 * - encoding: Set by user
1910 * - decoding: Set by libavcodec
1911 */
1912 enum AVColorPrimaries color_primaries;
1913
1914 /**
1915 * Color Transfer Characteristic.
1916 * - encoding: Set by user
1917 * - decoding: Set by libavcodec
1918 */
1919 enum AVColorTransferCharacteristic color_trc;
1920
1921 /**
1922 * YUV colorspace type.
1923 * - encoding: Set by user
1924 * - decoding: Set by libavcodec
1925 */
1926 enum AVColorSpace colorspace;
1927
1928 /**
1929 * MPEG vs JPEG YUV range.
1930 * - encoding: Set by user
1931 * - decoding: Set by libavcodec
1932 */
1933 enum AVColorRange color_range;
1934
1935 /**
1936 * This defines the location of chroma samples.
1937 * - encoding: Set by user
1938 * - decoding: Set by libavcodec
1939 */
1940 enum AVChromaLocation chroma_sample_location;
1941
1942 /**
1943 * Number of slices.
1944 * Indicates number of picture subdivisions. Used for parallelized
1945 * decoding.
1946 * - encoding: Set by user
1947 * - decoding: unused
1948 */
1949 int slices;
1950
1951 /** Field order
1952 * - encoding: set by libavcodec
1953 * - decoding: Set by libavcodec
1954 */
1955 enum AVFieldOrder field_order;
1956
1957 /* audio only */
1958 int sample_rate; ///< samples per second
1959 int channels; ///< number of audio channels
1960
1961 /**
1962 * audio sample format
1963 * - encoding: Set by user.
1964 * - decoding: Set by libavcodec.
1965 */
1966 enum AVSampleFormat sample_fmt; ///< sample format
1967
1968 /* The following data should not be initialized. */
1969 /**
1970 * Samples per packet, initialized when calling 'init'.
1971 */
1972 int frame_size;
1973
1974 /**
1975 * Frame counter, set by libavcodec.
1976 *
1977 * - decoding: total number of frames returned from the decoder so far.
1978 * - encoding: total number of frames passed to the encoder so far.
1979 *
1980 * @note the counter is not incremented if encoding/decoding resulted in
1981 * an error.
1982 */
1983 int frame_number;
1984
1985 /**
1986 * number of bytes per packet if constant and known or 0
1987 * Used by some WAV based audio codecs.
1988 */
1989 int block_align;
1990
1991 /**
1992 * Audio cutoff bandwidth (0 means "automatic")
1993 * - encoding: Set by user.
1994 * - decoding: unused
1995 */
1996 int cutoff;
1997
1998 #if FF_API_REQUEST_CHANNELS
1999 /**
2000 * Decoder should decode to this many channels if it can (0 for default)
2001 * - encoding: unused
2002 * - decoding: Set by user.
2003 * @deprecated Deprecated in favor of request_channel_layout.
2004 */
2005 int request_channels;
2006 #endif
2007
2008 /**
2009 * Audio channel layout.
2010 * - encoding: set by user.
2011 * - decoding: set by libavcodec.
2012 */
2013 uint64_t channel_layout;
2014
2015 /**
2016 * Request decoder to use this channel layout if it can (0 for default)
2017 * - encoding: unused
2018 * - decoding: Set by user.
2019 */
2020 uint64_t request_channel_layout;
2021
2022 /**
2023 * Type of service that the audio stream conveys.
2024 * - encoding: Set by user.
2025 * - decoding: Set by libavcodec.
2026 */
2027 enum AVAudioServiceType audio_service_type;
2028
2029 /**
2030 * Used to request a sample format from the decoder.
2031 * - encoding: unused.
2032 * - decoding: Set by user.
2033 */
2034 enum AVSampleFormat request_sample_fmt;
2035
2036 /**
2037 * Called at the beginning of each frame to get a buffer for it.
2038 *
2039 * The function will set AVFrame.data[], AVFrame.linesize[].
2040 * AVFrame.extended_data[] must also be set, but it should be the same as
2041 * AVFrame.data[] except for planar audio with more channels than can fit
2042 * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
2043 * many data pointers as it can hold.
2044 *
2045 * if CODEC_CAP_DR1 is not set then get_buffer() must call
2046 * avcodec_default_get_buffer() instead of providing buffers allocated by
2047 * some other means.
2048 *
2049 * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
2050 * need it. avcodec_default_get_buffer() aligns the output buffer properly,
2051 * but if get_buffer() is overridden then alignment considerations should
2052 * be taken into account.
2053 *
2054 * @see avcodec_default_get_buffer()
2055 *
2056 * Video:
2057 *
2058 * If pic.reference is set then the frame will be read later by libavcodec.
2059 * avcodec_align_dimensions2() should be used to find the required width and
2060 * height, as they normally need to be rounded up to the next multiple of 16.
2061 *
2062 * If frame multithreading is used and thread_safe_callbacks is set,
2063 * it may be called from a different thread, but not from more than one at
2064 * once. Does not need to be reentrant.
2065 *
2066 * @see release_buffer(), reget_buffer()
2067 * @see avcodec_align_dimensions2()
2068 *
2069 * Audio:
2070 *
2071 * Decoders request a buffer of a particular size by setting
2072 * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
2073 * however, utilize only part of the buffer by setting AVFrame.nb_samples
2074 * to a smaller value in the output frame.
2075 *
2076 * Decoders cannot use the buffer after returning from
2077 * avcodec_decode_audio4(), so they will not call release_buffer(), as it
2078 * is assumed to be released immediately upon return.
2079 *
2080 * As a convenience, av_samples_get_buffer_size() and
2081 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
2082 * functions to find the required data size and to fill data pointers and
2083 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2084 * since all planes must be the same size.
2085 *
2086 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2087 *
2088 * - encoding: unused
2089 * - decoding: Set by libavcodec, user can override.
2090 */
2091 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
2092
2093 /**
2094 * Called to release buffers which were allocated with get_buffer.
2095 * A released buffer can be reused in get_buffer().
2096 * pic.data[*] must be set to NULL.
2097 * May be called from a different thread if frame multithreading is used,
2098 * but not by more than one thread at once, so does not need to be reentrant.
2099 * - encoding: unused
2100 * - decoding: Set by libavcodec, user can override.
2101 */
2102 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
2103
2104 /**
2105 * Called at the beginning of a frame to get cr buffer for it.
2106 * Buffer type (size, hints) must be the same. libavcodec won't check it.
2107 * libavcodec will pass previous buffer in pic, function should return
2108 * same buffer or new buffer with old frame "painted" into it.
2109 * If pic.data[0] == NULL must behave like get_buffer().
2110 * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2111 * avcodec_default_reget_buffer() instead of providing buffers allocated by
2112 * some other means.
2113 * - encoding: unused
2114 * - decoding: Set by libavcodec, user can override.
2115 */
2116 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2117
2118
2119 /* - encoding parameters */
2120 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2121 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2122
2123 /**
2124 * minimum quantizer
2125 * - encoding: Set by user.
2126 * - decoding: unused
2127 */
2128 int qmin;
2129
2130 /**
2131 * maximum quantizer
2132 * - encoding: Set by user.
2133 * - decoding: unused
2134 */
2135 int qmax;
2136
2137 /**
2138 * maximum quantizer difference between frames
2139 * - encoding: Set by user.
2140 * - decoding: unused
2141 */
2142 int max_qdiff;
2143
2144 /**
2145 * ratecontrol qmin qmax limiting method
2146 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
2147 * - encoding: Set by user.
2148 * - decoding: unused
2149 */
2150 float rc_qsquish;
2151
2152 float rc_qmod_amp;
2153 int rc_qmod_freq;
2154
2155 /**
2156 * decoder bitstream buffer size
2157 * - encoding: Set by user.
2158 * - decoding: unused
2159 */
2160 int rc_buffer_size;
2161
2162 /**
2163 * ratecontrol override, see RcOverride
2164 * - encoding: Allocated/set/freed by user.
2165 * - decoding: unused
2166 */
2167 int rc_override_count;
2168 RcOverride *rc_override;
2169
2170 /**
2171 * rate control equation
2172 * - encoding: Set by user
2173 * - decoding: unused
2174 */
2175 const char *rc_eq;
2176
2177 /**
2178 * maximum bitrate
2179 * - encoding: Set by user.
2180 * - decoding: unused
2181 */
2182 int rc_max_rate;
2183
2184 /**
2185 * minimum bitrate
2186 * - encoding: Set by user.
2187 * - decoding: unused
2188 */
2189 int rc_min_rate;
2190
2191 float rc_buffer_aggressivity;
2192
2193 /**
2194 * initial complexity for pass1 ratecontrol
2195 * - encoding: Set by user.
2196 * - decoding: unused
2197 */
2198 float rc_initial_cplx;
2199
2200 /**
2201 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2202 * - encoding: Set by user.
2203 * - decoding: unused.
2204 */
2205 float rc_max_available_vbv_use;
2206
2207 /**
2208 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2209 * - encoding: Set by user.
2210 * - decoding: unused.
2211 */
2212 float rc_min_vbv_overflow_use;
2213
2214 /**
2215 * Number of bits which should be loaded into the rc buffer before decoding starts.
2216 * - encoding: Set by user.
2217 * - decoding: unused
2218 */
2219 int rc_initial_buffer_occupancy;
2220
2221 #define FF_CODER_TYPE_VLC 0
2222 #define FF_CODER_TYPE_AC 1
2223 #define FF_CODER_TYPE_RAW 2
2224 #define FF_CODER_TYPE_RLE 3
2225 #define FF_CODER_TYPE_DEFLATE 4
2226 /**
2227 * coder type
2228 * - encoding: Set by user.
2229 * - decoding: unused
2230 */
2231 int coder_type;
2232
2233 /**
2234 * context model
2235 * - encoding: Set by user.
2236 * - decoding: unused
2237 */
2238 int context_model;
2239
2240 /**
2241 * minimum Lagrange multipler
2242 * - encoding: Set by user.
2243 * - decoding: unused
2244 */
2245 int lmin;
2246
2247 /**
2248 * maximum Lagrange multipler
2249 * - encoding: Set by user.
2250 * - decoding: unused
2251 */
2252 int lmax;
2253
2254 /**
2255 * frame skip threshold
2256 * - encoding: Set by user.
2257 * - decoding: unused
2258 */
2259 int frame_skip_threshold;
2260
2261 /**
2262 * frame skip factor
2263 * - encoding: Set by user.
2264 * - decoding: unused
2265 */
2266 int frame_skip_factor;
2267
2268 /**
2269 * frame skip exponent
2270 * - encoding: Set by user.
2271 * - decoding: unused
2272 */
2273 int frame_skip_exp;
2274
2275 /**
2276 * frame skip comparison function
2277 * - encoding: Set by user.
2278 * - decoding: unused
2279 */
2280 int frame_skip_cmp;
2281
2282 /**
2283 * trellis RD quantization
2284 * - encoding: Set by user.
2285 * - decoding: unused
2286 */
2287 int trellis;
2288
2289 /**
2290 * - encoding: Set by user.
2291 * - decoding: unused
2292 */
2293 int min_prediction_order;
2294
2295 /**
2296 * - encoding: Set by user.
2297 * - decoding: unused
2298 */
2299 int max_prediction_order;
2300
2301 /**
2302 * GOP timecode frame start number, in non drop frame format
2303 * - encoding: Set by user.
2304 * - decoding: unused
2305 */
2306 int64_t timecode_frame_start;
2307
2308 /* The RTP callback: This function is called */
2309 /* every time the encoder has a packet to send. */
2310 /* It depends on the encoder if the data starts */
2311 /* with a Start Code (it should). H.263 does. */
2312 /* mb_nb contains the number of macroblocks */
2313 /* encoded in the RTP payload. */
2314 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2315
2316 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2317 /* do its best to deliver a chunk with size */
2318 /* below rtp_payload_size, the chunk will start */
2319 /* with a start code on some codecs like H.263. */
2320 /* This doesn't take account of any particular */
2321 /* headers inside the transmitted RTP payload. */
2322
2323 /* statistics, used for 2-pass encoding */
2324 int mv_bits;
2325 int header_bits;
2326 int i_tex_bits;
2327 int p_tex_bits;
2328 int i_count;
2329 int p_count;
2330 int skip_count;
2331 int misc_bits;
2332
2333 /**
2334 * number of bits used for the previously encoded frame
2335 * - encoding: Set by libavcodec.
2336 * - decoding: unused
2337 */
2338 int frame_bits;
2339
2340 /**
2341 * pass1 encoding statistics output buffer
2342 * - encoding: Set by libavcodec.
2343 * - decoding: unused
2344 */
2345 char *stats_out;
2346
2347 /**
2348 * pass2 encoding statistics input buffer
2349 * Concatenated stuff from stats_out of pass1 should be placed here.
2350 * - encoding: Allocated/set/freed by user.
2351 * - decoding: unused
2352 */
2353 char *stats_in;
2354
2355 /**
2356 * Work around bugs in encoders which sometimes cannot be detected automatically.
2357 * - encoding: Set by user
2358 * - decoding: Set by user
2359 */
2360 int workaround_bugs;
2361 #define FF_BUG_AUTODETECT 1 ///< autodetection
2362 #define FF_BUG_OLD_MSMPEG4 2
2363 #define FF_BUG_XVID_ILACE 4
2364 #define FF_BUG_UMP4 8
2365 #define FF_BUG_NO_PADDING 16
2366 #define FF_BUG_AMV 32
2367 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2368 #define FF_BUG_QPEL_CHROMA 64
2369 #define FF_BUG_STD_QPEL 128
2370 #define FF_BUG_QPEL_CHROMA2 256
2371 #define FF_BUG_DIRECT_BLOCKSIZE 512
2372 #define FF_BUG_EDGE 1024
2373 #define FF_BUG_HPEL_CHROMA 2048
2374 #define FF_BUG_DC_CLIP 4096
2375 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2376 #define FF_BUG_TRUNCATED 16384
2377
2378 /**
2379 * strictly follow the standard (MPEG4, ...).
2380 * - encoding: Set by user.
2381 * - decoding: Set by user.
2382 * Setting this to STRICT or higher means the encoder and decoder will
2383 * generally do stupid things, whereas setting it to unofficial or lower
2384 * will mean the encoder might produce output that is not supported by all
2385 * spec-compliant decoders. Decoders don't differentiate between normal,
2386 * unofficial and experimental (that is, they always try to decode things
2387 * when they can) unless they are explicitly asked to behave stupidly
2388 * (=strictly conform to the specs)
2389 */
2390 int strict_std_compliance;
2391 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2392 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2393 #define FF_COMPLIANCE_NORMAL 0
2394 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2395 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2396
2397 /**
2398 * error concealment flags
2399 * - encoding: unused
2400 * - decoding: Set by user.
2401 */
2402 int error_concealment;
2403 #define FF_EC_GUESS_MVS 1
2404 #define FF_EC_DEBLOCK 2
2405
2406 /**
2407 * debug
2408 * - encoding: Set by user.
2409 * - decoding: Set by user.
2410 */
2411 int debug;
2412 #define FF_DEBUG_PICT_INFO 1
2413 #define FF_DEBUG_RC 2
2414 #define FF_DEBUG_BITSTREAM 4
2415 #define FF_DEBUG_MB_TYPE 8
2416 #define FF_DEBUG_QP 16
2417 #define FF_DEBUG_MV 32
2418 #define FF_DEBUG_DCT_COEFF 0x00000040
2419 #define FF_DEBUG_SKIP 0x00000080
2420 #define FF_DEBUG_STARTCODE 0x00000100
2421 #define FF_DEBUG_PTS 0x00000200
2422 #define FF_DEBUG_ER 0x00000400
2423 #define FF_DEBUG_MMCO 0x00000800
2424 #define FF_DEBUG_BUGS 0x00001000
2425 #define FF_DEBUG_VIS_QP 0x00002000
2426 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2427 #define FF_DEBUG_BUFFERS 0x00008000
2428 #define FF_DEBUG_THREADS 0x00010000
2429
2430 /**
2431 * debug
2432 * - encoding: Set by user.
2433 * - decoding: Set by user.
2434 */
2435 int debug_mv;
2436 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2437 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2438 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2439
2440 /**
2441 * Error recognition; may misdetect some more or less valid parts as errors.
2442 * - encoding: unused
2443 * - decoding: Set by user.
2444 */
2445 int err_recognition;
2446 #define AV_EF_CRCCHECK (1<<0)
2447 #define AV_EF_BITSTREAM (1<<1)
2448 #define AV_EF_BUFFER (1<<2)
2449 #define AV_EF_EXPLODE (1<<3)
2450
2451 /**
2452 * opaque 64bit number (generally a PTS) that will be reordered and
2453 * output in AVFrame.reordered_opaque
2454 * @deprecated in favor of pkt_pts
2455 * - encoding: unused
2456 * - decoding: Set by user.
2457 */
2458 int64_t reordered_opaque;
2459
2460 /**
2461 * Hardware accelerator in use
2462 * - encoding: unused.
2463 * - decoding: Set by libavcodec
2464 */
2465 struct AVHWAccel *hwaccel;
2466
2467 /**
2468 * Hardware accelerator context.
2469 * For some hardware accelerators, a global context needs to be
2470 * provided by the user. In that case, this holds display-dependent
2471 * data Libav cannot instantiate itself. Please refer to the
2472 * Libav HW accelerator documentation to know how to fill this
2473 * is. e.g. for VA API, this is a struct vaapi_context.
2474 * - encoding: unused
2475 * - decoding: Set by user
2476 */
2477 void *hwaccel_context;
2478
2479 /**
2480 * error
2481 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2482 * - decoding: unused
2483 */
2484 uint64_t error[AV_NUM_DATA_POINTERS];
2485
2486 /**
2487 * DCT algorithm, see FF_DCT_* below
2488 * - encoding: Set by user.
2489 * - decoding: unused
2490 */
2491 int dct_algo;
2492 #define FF_DCT_AUTO 0
2493 #define FF_DCT_FASTINT 1
2494 #define FF_DCT_INT 2
2495 #define FF_DCT_MMX 3
2496 #define FF_DCT_ALTIVEC 5
2497 #define FF_DCT_FAAN 6
2498
2499 /**
2500 * IDCT algorithm, see FF_IDCT_* below.
2501 * - encoding: Set by user.
2502 * - decoding: Set by user.
2503 */
2504 int idct_algo;
2505 #define FF_IDCT_AUTO 0
2506 #define FF_IDCT_INT 1
2507 #define FF_IDCT_SIMPLE 2
2508 #define FF_IDCT_SIMPLEMMX 3
2509 #define FF_IDCT_LIBMPEG2MMX 4
2510 #define FF_IDCT_MMI 5
2511 #define FF_IDCT_ARM 7
2512 #define FF_IDCT_ALTIVEC 8
2513 #define FF_IDCT_SH4 9
2514 #define FF_IDCT_SIMPLEARM 10
2515 #define FF_IDCT_H264 11
2516 #define FF_IDCT_VP3 12
2517 #define FF_IDCT_IPP 13
2518 #define FF_IDCT_XVIDMMX 14
2519 #define FF_IDCT_CAVS 15
2520 #define FF_IDCT_SIMPLEARMV5TE 16
2521 #define FF_IDCT_SIMPLEARMV6 17
2522 #define FF_IDCT_SIMPLEVIS 18
2523 #define FF_IDCT_WMV2 19
2524 #define FF_IDCT_FAAN 20
2525 #define FF_IDCT_EA 21
2526 #define FF_IDCT_SIMPLENEON 22
2527 #define FF_IDCT_SIMPLEALPHA 23
2528 #define FF_IDCT_BINK 24
2529
2530 /**
2531 * dsp_mask could be add used to disable unwanted CPU features
2532 * CPU features (i.e. MMX, SSE. ...)
2533 *
2534 * With the FORCE flag you may instead enable given CPU features.
2535 * (Dangerous: Usable in case of misdetection, improper usage however will
2536 * result into program crash.)
2537 */
2538 unsigned dsp_mask;
2539
2540 /**
2541 * bits per sample/pixel from the demuxer (needed for huffyuv).
2542 * - encoding: Set by libavcodec.
2543 * - decoding: Set by user.
2544 */
2545 int bits_per_coded_sample;
2546
2547 /**
2548 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2549 * - encoding: set by user.
2550 * - decoding: set by libavcodec.
2551 */
2552 int bits_per_raw_sample;
2553
2554 /**
2555 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2556 * - encoding: unused
2557 * - decoding: Set by user.
2558 */
2559 int lowres;
2560
2561 /**
2562 * the picture in the bitstream
2563 * - encoding: Set by libavcodec.
2564 * - decoding: Set by libavcodec.
2565 */
2566 AVFrame *coded_frame;
2567
2568 /**
2569 * thread count
2570 * is used to decide how many independent tasks should be passed to execute()
2571 * - encoding: Set by user.
2572 * - decoding: Set by user.
2573 */
2574 int thread_count;
2575
2576 /**
2577 * Which multithreading methods to use.
2578 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2579 * so clients which cannot provide future frames should not use it.
2580 *
2581 * - encoding: Set by user, otherwise the default is used.
2582 * - decoding: Set by user, otherwise the default is used.
2583 */
2584 int thread_type;
2585 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2586 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2587
2588 /**
2589 * Which multithreading methods are in use by the codec.
2590 * - encoding: Set by libavcodec.
2591 * - decoding: Set by libavcodec.
2592 */
2593 int active_thread_type;
2594
2595 /**
2596 * Set by the client if its custom get_buffer() callback can be called
2597 * from another thread, which allows faster multithreaded decoding.
2598 * draw_horiz_band() will be called from other threads regardless of this setting.
2599 * Ignored if the default get_buffer() is used.
2600 * - encoding: Set by user.
2601 * - decoding: Set by user.
2602 */
2603 int thread_safe_callbacks;
2604
2605 /**
2606 * The codec may call this to execute several independent things.
2607 * It will return only after finishing all tasks.
2608 * The user may replace this with some multithreaded implementation,
2609 * the default implementation will execute the parts serially.
2610 * @param count the number of things to execute
2611 * - encoding: Set by libavcodec, user can override.
2612 * - decoding: Set by libavcodec, user can override.
2613 */
2614 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2615
2616 /**
2617 * The codec may call this to execute several independent things.
2618 * It will return only after finishing all tasks.
2619 * The user may replace this with some multithreaded implementation,
2620 * the default implementation will execute the parts serially.
2621 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2622 * @param c context passed also to func
2623 * @param count the number of things to execute
2624 * @param arg2 argument passed unchanged to func
2625 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2626 * @param func function that will be called count times, with jobnr from 0 to count-1.
2627 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2628 * two instances of func executing at the same time will have the same threadnr.
2629 * @return always 0 currently, but code should handle a future improvement where when any call to func
2630 * returns < 0 no further calls to func may be done and < 0 is returned.
2631 * - encoding: Set by libavcodec, user can override.
2632 * - decoding: Set by libavcodec, user can override.
2633 */
2634 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2635
2636 /**
2637 * thread opaque
2638 * Can be used by execute() to store some per AVCodecContext stuff.
2639 * - encoding: set by execute()
2640 * - decoding: set by execute()
2641 */
2642 void *thread_opaque;
2643
2644 /**
2645 * noise vs. sse weight for the nsse comparsion function
2646 * - encoding: Set by user.
2647 * - decoding: unused
2648 */
2649 int nsse_weight;
2650
2651 /**
2652 * profile
2653 * - encoding: Set by user.
2654 * - decoding: Set by libavcodec.
2655 */
2656 int profile;
2657 #define FF_PROFILE_UNKNOWN -99
2658 #define FF_PROFILE_RESERVED -100
2659
2660 #define FF_PROFILE_AAC_MAIN 0
2661 #define FF_PROFILE_AAC_LOW 1
2662 #define FF_PROFILE_AAC_SSR 2
2663 #define FF_PROFILE_AAC_LTP 3
2664
2665 #define FF_PROFILE_DTS 20
2666 #define FF_PROFILE_DTS_ES 30
2667 #define FF_PROFILE_DTS_96_24 40
2668 #define FF_PROFILE_DTS_HD_HRA 50
2669 #define FF_PROFILE_DTS_HD_MA 60
2670
2671 #define FF_PROFILE_MPEG2_422 0
2672 #define FF_PROFILE_MPEG2_HIGH 1
2673 #define FF_PROFILE_MPEG2_SS 2
2674 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2675 #define FF_PROFILE_MPEG2_MAIN 4
2676 #define FF_PROFILE_MPEG2_SIMPLE 5
2677
2678 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2679 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2680
2681 #define FF_PROFILE_H264_BASELINE 66
2682 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2683 #define FF_PROFILE_H264_MAIN 77
2684 #define FF_PROFILE_H264_EXTENDED 88
2685 #define FF_PROFILE_H264_HIGH 100
2686 #define FF_PROFILE_H264_HIGH_10 110
2687 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2688 #define FF_PROFILE_H264_HIGH_422 122
2689 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2690 #define FF_PROFILE_H264_HIGH_444 144
2691 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2692 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2693 #define FF_PROFILE_H264_CAVLC_444 44
2694
2695 #define FF_PROFILE_VC1_SIMPLE 0
2696 #define FF_PROFILE_VC1_MAIN 1
2697 #define FF_PROFILE_VC1_COMPLEX 2
2698 #define FF_PROFILE_VC1_ADVANCED 3
2699
2700 #define FF_PROFILE_MPEG4_SIMPLE 0
2701 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2702 #define FF_PROFILE_MPEG4_CORE 2
2703 #define FF_PROFILE_MPEG4_MAIN 3
2704 #define FF_PROFILE_MPEG4_N_BIT 4
2705 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2706 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2707 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2708 #define FF_PROFILE_MPEG4_HYBRID 8
2709 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2710 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2711 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2712 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2713 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2714 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2715 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2716
2717 /**
2718 * level
2719 * - encoding: Set by user.
2720 * - decoding: Set by libavcodec.
2721 */
2722 int level;
2723 #define FF_LEVEL_UNKNOWN -99
2724
2725 /**
2726 *
2727 * - encoding: unused
2728 * - decoding: Set by user.
2729 */
2730 enum AVDiscard skip_loop_filter;
2731
2732 /**
2733 *
2734 * - encoding: unused
2735 * - decoding: Set by user.
2736 */
2737 enum AVDiscard skip_idct;
2738
2739 /**
2740 *
2741 * - encoding: unused
2742 * - decoding: Set by user.
2743 */
2744 enum AVDiscard skip_frame;
2745
2746 /**
2747 * Header containing style information for text subtitles.
2748 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
2749 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
2750 * the Format line following. It shouldn't include any Dialogue line.
2751 * - encoding: Set/allocated/freed by user (before avcodec_open2())
2752 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
2753 */
2754 uint8_t *subtitle_header;
2755 int subtitle_header_size;
2756
2757 /**
2758 * Simulates errors in the bitstream to test error concealment.
2759 * - encoding: Set by user.
2760 * - decoding: unused
2761 */
2762 int error_rate;
2763
2764 /**
2765 * Current packet as passed into the decoder, to avoid having
2766 * to pass the packet into every function. Currently only valid
2767 * inside lavc and get/release_buffer callbacks.
2768 * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
2769 * - encoding: unused
2770 */
2771 AVPacket *pkt;
2772
2773 /**
2774 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
2775 * Used for compliant TS muxing.
2776 * - encoding: Set by libavcodec.
2777 * - decoding: unused.
2778 */
2779 uint64_t vbv_delay;
2780 } AVCodecContext;
2781
2782 /**
2783 * AVProfile.
2784 */
2785 typedef struct AVProfile {
2786 int profile;
2787 const char *name; ///< short name for the profile
2788 } AVProfile;
2789
2790 typedef struct AVCodecDefault AVCodecDefault;
2791
2792 /**
2793 * AVCodec.
2794 */
2795 typedef struct AVCodec {
2796 /**
2797 * Name of the codec implementation.
2798 * The name is globally unique among encoders and among decoders (but an
2799 * encoder and a decoder can share the same name).
2800 * This is the primary way to find a codec from the user perspective.
2801 */
2802 const char *name;
2803 /**
2804 * Descriptive name for the codec, meant to be more human readable than name.
2805 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
2806 */
2807 const char *long_name;
2808 enum AVMediaType type;
2809 enum CodecID id;
2810 /**
2811 * Codec capabilities.
2812 * see CODEC_CAP_*
2813 */
2814 int capabilities;
2815 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
2816 const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
2817 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
2818 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
2819 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
2820 uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
2821 const AVClass *priv_class; ///< AVClass for the private context
2822 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
2823
2824 /*****************************************************************
2825 * No fields below this line are part of the public API. They
2826 * may not be used outside of libavcodec and can be changed and
2827 * removed at will.
2828 * New public fields should be added right above.
2829 *****************************************************************
2830 */
2831 int priv_data_size;
2832 struct AVCodec *next;
2833 /**
2834 * @name Frame-level threading support functions
2835 * @{
2836 */
2837 /**
2838 * If defined, called on thread contexts when they are created.
2839 * If the codec allocates writable tables in init(), re-allocate them here.
2840 * priv_data will be set to a copy of the original.
2841 */
2842 int (*init_thread_copy)(AVCodecContext *);
2843 /**
2844 * Copy necessary context variables from a previous thread context to the current one.
2845 * If not defined, the next thread will start automatically; otherwise, the codec
2846 * must call ff_thread_finish_setup().
2847 *
2848 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
2849 */
2850 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
2851 /** @} */
2852
2853 /**
2854 * Private codec-specific defaults.
2855 */
2856 const AVCodecDefault *defaults;
2857
2858 /**
2859 * Initialize codec static data, called from avcodec_register().
2860 */
2861 void (*init_static_data)(struct AVCodec *codec);
2862
2863 int (*init)(AVCodecContext *);
2864 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
2865 /**
2866 * Encode data to an AVPacket.
2867 *
2868 * @param avctx codec context
2869 * @param avpkt output AVPacket (may contain a user-provided buffer)
2870 * @param[in] frame AVFrame containing the raw data to be encoded
2871 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
2872 * non-empty packet was returned in avpkt.
2873 * @return 0 on success, negative error code on failure
2874 */
2875 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
2876 int *got_packet_ptr);
2877 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
2878 int (*close)(AVCodecContext *);
2879 /**
2880 * Flush buffers.
2881 * Will be called when seeking
2882 */
2883 void (*flush)(AVCodecContext *);
2884 } AVCodec;
2885
2886 /**
2887 * AVHWAccel.
2888 */
2889 typedef struct AVHWAccel {
2890 /**
2891 * Name of the hardware accelerated codec.
2892 * The name is globally unique among encoders and among decoders (but an
2893 * encoder and a decoder can share the same name).
2894 */
2895 const char *name;
2896
2897 /**
2898 * Type of codec implemented by the hardware accelerator.
2899 *
2900 * See AVMEDIA_TYPE_xxx
2901 */
2902 enum AVMediaType type;
2903
2904 /**
2905 * Codec implemented by the hardware accelerator.
2906 *
2907 * See CODEC_ID_xxx
2908 */
2909 enum CodecID id;
2910
2911 /**
2912 * Supported pixel format.
2913 *
2914 * Only hardware accelerated formats are supported here.
2915 */
2916 enum PixelFormat pix_fmt;
2917
2918 /**
2919 * Hardware accelerated codec capabilities.
2920 * see FF_HWACCEL_CODEC_CAP_*
2921 */
2922 int capabilities;
2923
2924 struct AVHWAccel *next;
2925
2926 /**
2927 * Called at the beginning of each frame or field picture.
2928 *
2929 * Meaningful frame information (codec specific) is guaranteed to
2930 * be parsed at this point. This function is mandatory.
2931 *
2932 * Note that buf can be NULL along with buf_size set to 0.
2933 * Otherwise, this means the whole frame is available at this point.
2934 *
2935 * @param avctx the codec context
2936 * @param buf the frame data buffer base
2937 * @param buf_size the size of the frame in bytes
2938 * @return zero if successful, a negative value otherwise
2939 */
2940 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2941
2942 /**
2943 * Callback for each slice.
2944 *
2945 * Meaningful slice information (codec specific) is guaranteed to
2946 * be parsed at this point. This function is mandatory.
2947 *
2948 * @param avctx the codec context
2949 * @param buf the slice data buffer base
2950 * @param buf_size the size of the slice in bytes
2951 * @return zero if successful, a negative value otherwise
2952 */
2953 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2954
2955 /**
2956 * Called at the end of each frame or field picture.
2957 *
2958 * The whole picture is parsed at this point and can now be sent
2959 * to the hardware accelerator. This function is mandatory.
2960 *
2961 * @param avctx the codec context
2962 * @return zero if successful, a negative value otherwise
2963 */
2964 int (*end_frame)(AVCodecContext *avctx);
2965
2966 /**
2967 * Size of HW accelerator private data.
2968 *
2969 * Private data is allocated with av_mallocz() before
2970 * AVCodecContext.get_buffer() and deallocated after
2971 * AVCodecContext.release_buffer().
2972 */
2973 int priv_data_size;
2974 } AVHWAccel;
2975
2976 /**
2977 * four components are given, that's all.
2978 * the last component is alpha
2979 */
2980 typedef struct AVPicture {
2981 uint8_t *data[AV_NUM_DATA_POINTERS];
2982 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
2983 } AVPicture;
2984
2985 #define AVPALETTE_SIZE 1024
2986 #define AVPALETTE_COUNT 256
2987
2988 enum AVSubtitleType {
2989 SUBTITLE_NONE,
2990
2991 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
2992
2993 /**
2994 * Plain text, the text field must be set by the decoder and is
2995 * authoritative. ass and pict fields may contain approximations.
2996 */
2997 SUBTITLE_TEXT,
2998
2999 /**
3000 * Formatted text, the ass field must be set by the decoder and is
3001 * authoritative. pict and text fields may contain approximations.
3002 */
3003 SUBTITLE_ASS,
3004 };
3005
3006 typedef struct AVSubtitleRect {
3007 int x; ///< top left corner of pict, undefined when pict is not set
3008 int y; ///< top left corner of pict, undefined when pict is not set
3009 int w; ///< width of pict, undefined when pict is not set
3010 int h; ///< height of pict, undefined when pict is not set
3011 int nb_colors; ///< number of colors in pict, undefined when pict is not set
3012
3013 /**
3014 * data+linesize for the bitmap of this subtitle.
3015 * can be set for text/ass as well once they where rendered
3016 */
3017 AVPicture pict;
3018 enum AVSubtitleType type;
3019
3020 char *text; ///< 0 terminated plain UTF-8 text
3021
3022 /**
3023 * 0 terminated ASS/SSA compatible event line.
3024 * The pressentation of this is unaffected by the other values in this
3025 * struct.
3026 */
3027 char *ass;
3028 } AVSubtitleRect;
3029
3030 typedef struct AVSubtitle {
3031 uint16_t format; /* 0 = graphics */
3032 uint32_t start_display_time; /* relative to packet pts, in ms */
3033 uint32_t end_display_time; /* relative to packet pts, in ms */
3034 unsigned num_rects;
3035 AVSubtitleRect **rects;
3036 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3037 } AVSubtitle;
3038
3039 /* packet functions */
3040
3041 /**
3042 * @deprecated use NULL instead
3043 */
3044 attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
3045
3046 /**
3047 * Default packet destructor.
3048 */
3049 void av_destruct_packet(AVPacket *pkt);
3050
3051 /**
3052 * Initialize optional fields of a packet with default values.
3053 *
3054 * @param pkt packet
3055 */
3056 void av_init_packet(AVPacket *pkt);
3057
3058 /**
3059 * Allocate the payload of a packet and initialize its fields with
3060 * default values.
3061 *
3062 * @param pkt packet
3063 * @param size wanted payload size
3064 * @return 0 if OK, AVERROR_xxx otherwise
3065 */
3066 int av_new_packet(AVPacket *pkt, int size);
3067
3068 /**
3069 * Reduce packet size, correctly zeroing padding
3070 *
3071 * @param pkt packet
3072 * @param size new size
3073 */
3074 void av_shrink_packet(AVPacket *pkt, int size);
3075
3076 /**
3077 * Increase packet size, correctly zeroing padding
3078 *
3079 * @param pkt packet
3080 * @param grow_by number of bytes by which to increase the size of the packet
3081 */
3082 int av_grow_packet(AVPacket *pkt, int grow_by);
3083
3084 /**
3085 * @warning This is a hack - the packet memory allocation stuff is broken. The
3086 * packet is allocated if it was not really allocated.
3087 */
3088 int av_dup_packet(AVPacket *pkt);
3089
3090 /**
3091 * Free a packet.
3092 *
3093 * @param pkt packet to free
3094 */
3095 void av_free_packet(AVPacket *pkt);
3096
3097 /**
3098 * Allocate new information of a packet.
3099 *
3100 * @param pkt packet
3101 * @param type side information type
3102 * @param size side information size
3103 * @return pointer to fresh allocated data or NULL otherwise
3104 */
3105 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3106 int size);
3107
3108 /**
3109 * Shrink the already allocated side data buffer
3110 *
3111 * @param pkt packet
3112 * @param type side information type
3113 * @param size new side information size
3114 * @return 0 on success, < 0 on failure
3115 */
3116 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3117 int size);
3118
3119 /**
3120 * Get side information from packet.
3121 *
3122 * @param pkt packet
3123 * @param type desired side information type
3124 * @param size pointer for side information size to store (optional)
3125 * @return pointer to data if present or NULL otherwise
3126 */
3127 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3128 int *size);
3129
3130 /* resample.c */
3131
3132 struct ReSampleContext;
3133 struct AVResampleContext;
3134
3135 typedef struct ReSampleContext ReSampleContext;
3136
3137 /**
3138 * Initialize audio resampling context.
3139 *
3140 * @param output_channels number of output channels
3141 * @param input_channels number of input channels
3142 * @param output_rate output sample rate
3143 * @param input_rate input sample rate
3144 * @param sample_fmt_out requested output sample format
3145 * @param sample_fmt_in input sample format
3146 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
3147 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3148 * @param linear if 1 then the used FIR filter will be linearly interpolated
3149 between the 2 closest, if 0 the closest will be used
3150 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3151 * @return allocated ReSampleContext, NULL if error occurred
3152 */
3153 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
3154 int output_rate, int input_rate,
3155 enum AVSampleFormat sample_fmt_out,
3156 enum AVSampleFormat sample_fmt_in,
3157 int filter_length, int log2_phase_count,
3158 int linear, double cutoff);
3159
3160 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
3161
3162 /**
3163 * Free resample context.
3164 *
3165 * @param s a non-NULL pointer to a resample context previously
3166 * created with av_audio_resample_init()
3167 */
3168 void audio_resample_close(ReSampleContext *s);
3169
3170
3171 /**
3172 * Initialize an audio resampler.
3173 * Note, if either rate is not an integer then simply scale both rates up so they are.
3174 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
3175 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3176 * @param linear If 1 then the used FIR filter will be linearly interpolated
3177 between the 2 closest, if 0 the closest will be used
3178 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3179 */
3180 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
3181
3182 /**
3183 * Resample an array of samples using a previously configured context.
3184 * @param src an array of unconsumed samples
3185 * @param consumed the number of samples of src which have been consumed are returned here
3186 * @param src_size the number of unconsumed samples available
3187 * @param dst_size the amount of space in samples available in dst
3188 * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
3189 * @return the number of samples written in dst or -1 if an error occurred
3190 */
3191 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
3192
3193
3194 /**
3195 * Compensate samplerate/timestamp drift. The compensation is done by changing
3196 * the resampler parameters, so no audible clicks or similar distortions occur
3197 * @param compensation_distance distance in output samples over which the compensation should be performed
3198 * @param sample_delta number of output samples which should be output less
3199 *
3200 * example: av_resample_compensate(c, 10, 500)
3201 * here instead of 510 samples only 500 samples would be output
3202 *
3203 * note, due to rounding the actual compensation might be slightly different,
3204 * especially if the compensation_distance is large and the in_rate used during init is small
3205 */
3206 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
3207 void av_resample_close(struct AVResampleContext *c);
3208
3209 /**
3210 * Allocate memory for a picture. Call avpicture_free() to free it.
3211 *
3212 * @see avpicture_fill()
3213 *
3214 * @param picture the picture to be filled in
3215 * @param pix_fmt the format of the picture
3216 * @param width the width of the picture
3217 * @param height the height of the picture
3218 * @return zero if successful, a negative value if not
3219 */
3220 int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
3221
3222 /**
3223 * Free a picture previously allocated by avpicture_alloc().
3224 * The data buffer used by the AVPicture is freed, but the AVPicture structure
3225 * itself is not.
3226 *
3227 * @param picture the AVPicture to be freed
3228 */
3229 void avpicture_free(AVPicture *picture);
3230
3231 /**
3232 * Fill in the AVPicture fields.
3233 * The fields of the given AVPicture are filled in by using the 'ptr' address
3234 * which points to the image data buffer. Depending on the specified picture
3235 * format, one or multiple image data pointers and line sizes will be set.
3236 * If a planar format is specified, several pointers will be set pointing to
3237 * the different picture planes and the line sizes of the different planes
3238 * will be stored in the lines_sizes array.
3239 * Call with ptr == NULL to get the required size for the ptr buffer.
3240 *
3241 * To allocate the buffer and fill in the AVPicture fields in one call,
3242 * use avpicture_alloc().
3243 *
3244 * @param picture AVPicture whose fields are to be filled in
3245 * @param ptr Buffer which will contain or contains the actual image data
3246 * @param pix_fmt The format in which the picture data is stored.
3247 * @param width the width of the image in pixels
3248 * @param height the height of the image in pixels
3249 * @return size of the image data in bytes
3250 */
3251 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
3252 enum PixelFormat pix_fmt, int width, int height);
3253
3254 /**
3255 * Copy pixel data from an AVPicture into a buffer.
3256 * The data is stored compactly, without any gaps for alignment or padding
3257 * which may be applied by avpicture_fill().
3258 *
3259 * @see avpicture_get_size()
3260 *
3261 * @param[in] src AVPicture containing image data
3262 * @param[in] pix_fmt The format in which the picture data is stored.
3263 * @param[in] width the width of the image in pixels.
3264 * @param[in] height the height of the image in pixels.
3265 * @param[out] dest A buffer into which picture data will be copied.
3266 * @param[in] dest_size The size of 'dest'.
3267 * @return The number of bytes written to dest, or a negative value (error code) on error.
3268 */
3269 int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
3270 unsigned char *dest, int dest_size);
3271
3272 /**
3273 * Calculate the size in bytes that a picture of the given width and height
3274 * would occupy if stored in the given picture format.
3275 * Note that this returns the size of a compact representation as generated
3276 * by avpicture_layout(), which can be smaller than the size required for e.g.
3277 * avpicture_fill().
3278 *
3279 * @param pix_fmt the given picture format
3280 * @param width the width of the image
3281 * @param height the height of the image
3282 * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
3283 */
3284 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
3285 void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
3286
3287 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
3288
3289 /**
3290 * Return a value representing the fourCC code associated to the
3291 * pixel format pix_fmt, or 0 if no associated fourCC code can be
3292 * found.
3293 */
3294 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
3295
3296 /**
3297 * Put a string representing the codec tag codec_tag in buf.
3298 *
3299 * @param buf_size size in bytes of buf
3300 * @return the length of the string that would have been generated if
3301 * enough space had been available, excluding the trailing null
3302 */
3303 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
3304
3305 #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
3306 #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
3307 #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
3308 #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
3309 #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
3310 #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
3311
3312 /**
3313 * Compute what kind of losses will occur when converting from one specific
3314 * pixel format to another.
3315 * When converting from one pixel format to another, information loss may occur.
3316 * For example, when converting from RGB24 to GRAY, the color information will
3317 * be lost. Similarly, other losses occur when converting from some formats to
3318 * other formats. These losses can involve loss of chroma, but also loss of
3319 * resolution, loss of color depth, loss due to the color space conversion, loss
3320 * of the alpha bits or loss due to color quantization.
3321 * avcodec_get_fix_fmt_loss() informs you about the various types of losses
3322 * which will occur when converting from one pixel format to another.
3323 *
3324 * @param[in] dst_pix_fmt destination pixel format
3325 * @param[in] src_pix_fmt source pixel format
3326 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3327 * @return Combination of flags informing you what kind of losses will occur.
3328 */
3329 int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
3330 int has_alpha);
3331
3332 /**
3333 * Find the best pixel format to convert to given a certain source pixel
3334 * format. When converting from one pixel format to another, information loss
3335 * may occur. For example, when converting from RGB24 to GRAY, the color
3336 * information will be lost. Similarly, other losses occur when converting from
3337 * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
3338 * the given pixel formats should be used to suffer the least amount of loss.
3339 * The pixel formats from which it chooses one, are determined by the
3340 * pix_fmt_mask parameter.
3341 *
3342 * @code
3343 * src_pix_fmt = PIX_FMT_YUV420P;
3344 * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
3345 * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
3346 * @endcode
3347 *
3348 * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
3349 * @param[in] src_pix_fmt source pixel format
3350 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3351 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
3352 * @return The best pixel format to convert to or -1 if none was found.
3353 */
3354 enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
3355 int has_alpha, int *loss_ptr);
3356
3357 /* deinterlace a picture */
3358 /* deinterlace - if not supported return -1 */
3359 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
3360 enum PixelFormat pix_fmt, int width, int height);
3361
3362 /* external high level API */
3363
3364 /**
3365 * If c is NULL, returns the first registered codec,
3366 * if c is non-NULL, returns the next registered codec after c,
3367 * or NULL if c is the last one.
3368 */
3369 AVCodec *av_codec_next(AVCodec *c);
3370
3371 /**
3372 * Return the LIBAVCODEC_VERSION_INT constant.
3373 */
3374 unsigned avcodec_version(void);
3375
3376 /**
3377 * Return the libavcodec build-time configuration.
3378 */
3379 const char *avcodec_configuration(void);
3380
3381 /**
3382 * Return the libavcodec license.
3383 */
3384 const char *avcodec_license(void);
3385
3386 /**
3387 * Register the codec codec and initialize libavcodec.
3388 *
3389 * @warning either this function or avcodec_register_all() must be called
3390 * before any other libavcodec functions.
3391 *
3392 * @see avcodec_register_all()
3393 */
3394 void avcodec_register(AVCodec *codec);
3395
3396 /**
3397 * Find a registered encoder with a matching codec ID.
3398 *
3399 * @param id CodecID of the requested encoder
3400 * @return An encoder if one was found, NULL otherwise.
3401 */
3402 AVCodec *avcodec_find_encoder(enum CodecID id);
3403
3404 /**
3405 * Find a registered encoder with the specified name.
3406 *
3407 * @param name name of the requested encoder
3408 * @return An encoder if one was found, NULL otherwise.
3409 */
3410 AVCodec *avcodec_find_encoder_by_name(const char *name);
3411
3412 /**
3413 * Find a registered decoder with a matching codec ID.
3414 *
3415 * @param id CodecID of the requested decoder
3416 * @return A decoder if one was found, NULL otherwise.
3417 */
3418 AVCodec *avcodec_find_decoder(enum CodecID id);
3419
3420 /**
3421 * Find a registered decoder with the specified name.
3422 *
3423 * @param name name of the requested decoder
3424 * @return A decoder if one was found, NULL otherwise.
3425 */
3426 AVCodec *avcodec_find_decoder_by_name(const char *name);
3427 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
3428
3429 /**
3430 * Return a name for the specified profile, if available.
3431 *
3432 * @param codec the codec that is searched for the given profile
3433 * @param profile the profile value for which a name is requested
3434 * @return A name for the profile if found, NULL otherwise.
3435 */
3436 const char *av_get_profile_name(const AVCodec *codec, int profile);
3437
3438 /**
3439 * Set the fields of the given AVCodecContext to default values corresponding
3440 * to the given codec (defaults may be codec-dependent).
3441 *
3442 * Do not call this function if a non-NULL codec has been passed
3443 * to avcodec_alloc_context3() that allocated this AVCodecContext.
3444 * If codec is non-NULL, it is illegal to call avcodec_open2() with a
3445 * different codec on this AVCodecContext.
3446 */
3447 int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
3448
3449 /**
3450 * Allocate an AVCodecContext and set its fields to default values. The
3451 * resulting struct can be deallocated by calling avcodec_close() on it followed
3452 * by av_free().
3453 *
3454 * @param codec if non-NULL, allocate private data and initialize defaults
3455 * for the given codec. It is illegal to then call avcodec_open2()
3456 * with a different codec.
3457 * If NULL, then the codec-specific defaults won't be initialized,
3458 * which may result in suboptimal default settings (this is
3459 * important mainly for encoders, e.g. libx264).
3460 *
3461 * @return An AVCodecContext filled with default values or NULL on failure.
3462 * @see avcodec_get_context_defaults
3463 */
3464 AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
3465
3466 /**
3467 * Copy the settings of the source AVCodecContext into the destination
3468 * AVCodecContext. The resulting destination codec context will be
3469 * unopened, i.e. you are required to call avcodec_open2() before you
3470 * can use this AVCodecContext to decode/encode video/audio data.
3471 *
3472 * @param dest target codec context, should be initialized with
3473 * avcodec_alloc_context3(), but otherwise uninitialized
3474 * @param src source codec context
3475 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3476 */
3477 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3478
3479 /**
3480 * Set the fields of the given AVFrame to default values.
3481 *
3482 * @param pic The AVFrame of which the fields should be set to default values.
3483 */
3484 void avcodec_get_frame_defaults(AVFrame *pic);
3485
3486 /**
3487 * Allocate an AVFrame and set its fields to default values. The resulting
3488 * struct can be deallocated by simply calling av_free().
3489 *
3490 * @return An AVFrame filled with default values or NULL on failure.
3491 * @see avcodec_get_frame_defaults
3492 */
3493 AVFrame *avcodec_alloc_frame(void);
3494
3495 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3496 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3497 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3498
3499 /**
3500 * Return the amount of padding in pixels which the get_buffer callback must
3501 * provide around the edge of the image for codecs which do not have the
3502 * CODEC_FLAG_EMU_EDGE flag.
3503 *
3504 * @return Required padding in pixels.
3505 */
3506 unsigned avcodec_get_edge_width(void);
3507 /**
3508 * Modify width and height values so that they will result in a memory
3509 * buffer that is acceptable for the codec if you do not use any horizontal
3510 * padding.
3511 *
3512 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3513 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3514 * according to avcodec_get_edge_width() before.
3515 */
3516 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3517 /**
3518 * Modify width and height values so that they will result in a memory
3519 * buffer that is acceptable for the codec if you also ensure that all
3520 * line sizes are a multiple of the respective linesize_align[i].
3521 *
3522 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3523 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3524 * according to avcodec_get_edge_width() before.
3525 */
3526 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3527 int linesize_align[AV_NUM_DATA_POINTERS]);
3528
3529 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
3530
3531 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
3532 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
3533 //FIXME func typedef
3534
3535 /**
3536 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3537 * function the context has to be allocated with avcodec_alloc_context3().
3538 *
3539 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3540 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3541 * retrieving a codec.
3542 *
3543 * @warning This function is not thread safe!
3544 *
3545 * @code
3546 * avcodec_register_all();
3547 * av_dict_set(&opts, "b", "2.5M", 0);
3548 * codec = avcodec_find_decoder(CODEC_ID_H264);
3549 * if (!codec)
3550 * exit(1);
3551 *
3552 * context = avcodec_alloc_context3(codec);
3553 *
3554 * if (avcodec_open2(context, codec, opts) < 0)
3555 * exit(1);
3556 * @endcode
3557 *
3558 * @param avctx The context to initialize.
3559 * @param codec The codec to open this context for. If a non-NULL codec has been
3560 * previously passed to avcodec_alloc_context3() or
3561 * avcodec_get_context_defaults3() for this context, then this
3562 * parameter MUST be either NULL or equal to the previously passed
3563 * codec.
3564 * @param options A dictionary filled with AVCodecContext and codec-private options.
3565 * On return this object will be filled with options that were not found.
3566 *
3567 * @return zero on success, a negative value on error
3568 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3569 * av_dict_set(), av_opt_find().
3570 */
3571 int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
3572
3573 #if FF_API_OLD_DECODE_AUDIO
3574 /**
3575 * Wrapper function which calls avcodec_decode_audio4.
3576 *
3577 * @deprecated Use avcodec_decode_audio4 instead.
3578 *
3579 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3580 * Some decoders may support multiple frames in a single AVPacket, such
3581 * decoders would then just decode the first frame. In this case,
3582 * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3583 * the remaining data in order to decode the second frame etc.
3584 * If no frame
3585 * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3586 * decompressed frame size in bytes.
3587 *
3588 * @warning You must set frame_size_ptr to the allocated size of the
3589 * output buffer before calling avcodec_decode_audio3().
3590 *
3591 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3592 * the actual read bytes because some optimized bitstream readers read 32 or 64
3593 * bits at once and could read over the end.
3594 *
3595 * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3596 * no overreading happens for damaged MPEG streams.
3597 *
3598 * @warning You must not provide a custom get_buffer() when using
3599 * avcodec_decode_audio3(). Doing so will override it with
3600 * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
3601 * which does allow the application to provide a custom get_buffer().
3602 *
3603 * @note You might have to align the input buffer avpkt->data and output buffer
3604 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3605 * necessary at all, on others it won't work at all if not aligned and on others
3606 * it will work but it will have an impact on performance.
3607 *
3608 * In practice, avpkt->data should have 4 byte alignment at minimum and
3609 * samples should be 16 byte aligned unless the CPU doesn't need it
3610 * (AltiVec and SSE do).
3611 *
3612 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3613 * between input and output, these need to be fed with avpkt->data=NULL,
3614 * avpkt->size=0 at the end to return the remaining frames.
3615 *
3616 * @param avctx the codec context
3617 * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3618 * If the sample format is planar, each channel plane will
3619 * be the same size, with no padding between channels.
3620 * @param[in,out] frame_size_ptr the output buffer size in bytes
3621 * @param[in] avpkt The input AVPacket containing the input buffer.
3622 * You can create such packet with av_init_packet() and by then setting
3623 * data and size, some decoders might in addition need other fields.
3624 * All decoders are designed to use the least fields possible though.
3625 * @return On error a negative value is returned, otherwise the number of bytes
3626 * used or zero if no frame data was decompressed (used) from the input AVPacket.
3627 */
3628 attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3629 int *frame_size_ptr,
3630 AVPacket *avpkt);
3631 #endif
3632
3633 /**
3634 * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3635 *
3636 * Some decoders may support multiple frames in a single AVPacket. Such
3637 * decoders would then just decode the first frame. In this case,
3638 * avcodec_decode_audio4 has to be called again with an AVPacket containing
3639 * the remaining data in order to decode the second frame, etc...
3640 * Even if no frames are returned, the packet needs to be fed to the decoder
3641 * with remaining data until it is completely consumed or an error occurs.
3642 *
3643 * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3644 * larger than the actual read bytes because some optimized bitstream
3645 * readers read 32 or 64 bits at once and could read over the end.
3646 *
3647 * @note You might have to align the input buffer. The alignment requirements
3648 * depend on the CPU and the decoder.
3649 *
3650 * @param avctx the codec context
3651 * @param[out] frame The AVFrame in which to store decoded audio samples.
3652 * Decoders request a buffer of a particular size by setting
3653 * AVFrame.nb_samples prior to calling get_buffer(). The
3654 * decoder may, however, only utilize part of the buffer by
3655 * setting AVFrame.nb_samples to a smaller value in the
3656 * output frame.
3657 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3658 * non-zero.
3659 * @param[in] avpkt The input AVPacket containing the input buffer.
3660 * At least avpkt->data and avpkt->size should be set. Some
3661 * decoders might also require additional fields to be set.
3662 * @return A negative error code is returned if an error occurred during
3663 * decoding, otherwise the number of bytes consumed from the input
3664 * AVPacket is returned.
3665 */
3666 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3667 int *got_frame_ptr, AVPacket *avpkt);
3668
3669 /**
3670 * Decode the video frame of size avpkt->size from avpkt->data into picture.
3671 * Some decoders may support multiple frames in a single AVPacket, such
3672 * decoders would then just decode the first frame.
3673 *
3674 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3675 * the actual read bytes because some optimized bitstream readers read 32 or 64
3676 * bits at once and could read over the end.
3677 *
3678 * @warning The end of the input buffer buf should be set to 0 to ensure that
3679 * no overreading happens for damaged MPEG streams.
3680 *
3681 * @note You might have to align the input buffer avpkt->data.
3682 * The alignment requirements depend on the CPU: on some CPUs it isn't
3683 * necessary at all, on others it won't work at all if not aligned and on others
3684 * it will work but it will have an impact on performance.
3685 *
3686 * In practice, avpkt->data should have 4 byte alignment at minimum.
3687 *
3688 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3689 * between input and output, these need to be fed with avpkt->data=NULL,
3690 * avpkt->size=0 at the end to return the remaining frames.
3691 *
3692 * @param avctx the codec context
3693 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3694 * Use avcodec_alloc_frame to get an AVFrame, the codec will
3695 * allocate memory for the actual bitmap.
3696 * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
3697 * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
3698 * decodes and the decoder tells the user once it does not need the data anymore,
3699 * the user app can at this point free/reuse/keep the memory as it sees fit.
3700 *
3701 * @param[in] avpkt The input AVpacket containing the input buffer.
3702 * You can create such packet with av_init_packet() and by then setting
3703 * data and size, some decoders might in addition need other fields like
3704 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
3705 * fields possible.
3706 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3707 * @return On error a negative value is returned, otherwise the number of bytes
3708 * used or zero if no frame could be decompressed.
3709 */
3710 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
3711 int *got_picture_ptr,
3712 AVPacket *avpkt);
3713
3714 /**
3715 * Decode a subtitle message.
3716 * Return a negative value on error, otherwise return the number of bytes used.
3717 * If no subtitle could be decompressed, got_sub_ptr is zero.
3718 * Otherwise, the subtitle is stored in *sub.
3719 * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
3720 * simplicity, because the performance difference is expect to be negligible
3721 * and reusing a get_buffer written for video codecs would probably perform badly
3722 * due to a potentially very different allocation pattern.
3723 *
3724 * @param avctx the codec context
3725 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3726 freed with avsubtitle_free if *got_sub_ptr is set.
3727 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
3728 * @param[in] avpkt The input AVPacket containing the input buffer.
3729 */
3730 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
3731 int *got_sub_ptr,
3732 AVPacket *avpkt);
3733
3734 /**
3735 * Free all allocated data in the given subtitle struct.
3736 *
3737 * @param sub AVSubtitle to free.
3738 */
3739 void avsubtitle_free(AVSubtitle *sub);
3740
3741 #if FF_API_OLD_ENCODE_AUDIO
3742 /**
3743 * Encode an audio frame from samples into buf.
3744 *
3745 * @deprecated Use avcodec_encode_audio2 instead.
3746 *
3747 * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
3748 * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
3749 * will know how much space is needed because it depends on the value passed
3750 * in buf_size as described below. In that case a lower value can be used.
3751 *
3752 * @param avctx the codec context
3753 * @param[out] buf the output buffer
3754 * @param[in] buf_size the output buffer size
3755 * @param[in] samples the input buffer containing the samples
3756 * The number of samples read from this buffer is frame_size*channels,
3757 * both of which are defined in avctx.
3758 * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
3759 * samples read from samples is equal to:
3760 * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
3761 * This also implies that av_get_bits_per_sample() must not return 0 for these
3762 * codecs.
3763 * @return On error a negative value is returned, on success zero or the number
3764 * of bytes used to encode the data read from the input buffer.
3765 */
3766 int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
3767 uint8_t *buf, int buf_size,
3768 const short *samples);
3769 #endif
3770
3771 /**
3772 * Encode a frame of audio.
3773 *
3774 * Takes input samples from frame and writes the next output packet, if
3775 * available, to avpkt. The output packet does not necessarily contain data for
3776 * the most recent frame, as encoders can delay, split, and combine input frames
3777 * internally as needed.
3778 *
3779 * @param avctx codec context
3780 * @param avpkt output AVPacket.
3781 * The user can supply an output buffer by setting
3782 * avpkt->data and avpkt->size prior to calling the
3783 * function, but if the size of the user-provided data is not
3784 * large enough, encoding will fail. All other AVPacket fields
3785 * will be reset by the encoder using av_init_packet(). If
3786 * avpkt->data is NULL, the encoder will allocate it.
3787 * The encoder will set avpkt->size to the size of the
3788 * output packet.
3789 *
3790 * If this function fails or produces no output, avpkt will be
3791 * freed using av_free_packet() (i.e. avpkt->destruct will be
3792 * called to free the user supplied buffer).
3793 * @param[in] frame AVFrame containing the raw audio data to be encoded.
3794 * May be NULL when flushing an encoder that has the
3795 * CODEC_CAP_DELAY capability set.
3796 * There are 2 codec capabilities that affect the allowed
3797 * values of frame->nb_samples.
3798 * If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final
3799 * frame may be smaller than avctx->frame_size, and all other
3800 * frames must be equal to avctx->frame_size.
3801 * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
3802 * can have any number of samples.
3803 * If neither is set, frame->nb_samples must be equal to
3804 * avctx->frame_size for all frames.
3805 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
3806 * output packet is non-empty, and to 0 if it is
3807 * empty. If the function returns an error, the
3808 * packet can be assumed to be invalid, and the
3809 * value of got_packet_ptr is undefined and should
3810 *