2 * copyright (c) 2001 Fabrice Bellard
4 * This file is part of FFmpeg.
6 * FFmpeg 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.
11 * FFmpeg 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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_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 #include "libavutil/audioconvert.h"
39 #include "libavcodec/version.h"
41 * @defgroup libavc Encoding/Decoding Library
44 * @defgroup lavc_decoding Decoding
48 * @defgroup lavc_encoding Encoding
52 * @defgroup lavc_codec Codecs
54 * @defgroup lavc_codec_native Native Codecs
57 * @defgroup lavc_codec_wrappers External library wrappers
60 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
64 * @defgroup lavc_internal Internal
72 * @defgroup lavc_core Core functions/structures.
75 * Basic definitions, functions for querying libavcodec capabilities,
76 * allocating core structures, etc.
82 * Identify the syntax and semantics of the bitstream.
83 * The principle is roughly:
84 * Two decoders with the same ID can decode the same streams.
85 * Two encoders with the same ID can encode compatible streams.
86 * There may be slight deviations from the principle due to implementation
89 * If you add a codec ID to this list, add it so that
90 * 1. no value of a existing codec ID changes (that would break ABI),
91 * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
92 * This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
94 * After adding new codec IDs, do not forget to add an entry to the codec
95 * descriptor list and bump libavcodec minor version.
101 AV_CODEC_ID_MPEG1VIDEO,
102 AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
103 AV_CODEC_ID_MPEG2VIDEO_XVMC,
114 AV_CODEC_ID_RAWVIDEO,
115 AV_CODEC_ID_MSMPEG4V1,
116 AV_CODEC_ID_MSMPEG4V2,
117 AV_CODEC_ID_MSMPEG4V3,
140 AV_CODEC_ID_INTERPLAY_VIDEO,
147 AV_CODEC_ID_MSVIDEO1,
152 AV_CODEC_ID_TRUEMOTION1,
153 AV_CODEC_ID_VMDVIDEO,
179 AV_CODEC_ID_TRUEMOTION2,
185 AV_CODEC_ID_SMACKVIDEO,
190 AV_CODEC_ID_JPEG2000,
196 AV_CODEC_ID_DSICINVIDEO,
197 AV_CODEC_ID_TIERTEXSEQVIDEO,
205 AV_CODEC_ID_BETHSOFTVID,
217 AV_CODEC_ID_ESCAPE124,
221 AV_CODEC_ID_MOTIONPIXELS,
233 AV_CODEC_ID_FLASHSV2,
234 AV_CODEC_ID_CDGRAPHICS,
237 AV_CODEC_ID_BINKVIDEO,
238 AV_CODEC_ID_IFF_ILBM,
239 AV_CODEC_ID_IFF_BYTERUN1,
245 AV_CODEC_ID_A64_MULTI,
246 AV_CODEC_ID_A64_MULTI5,
249 AV_CODEC_ID_LAGARITH,
253 AV_CODEC_ID_WMV3IMAGE,
254 AV_CODEC_ID_VC1IMAGE,
256 AV_CODEC_ID_BMV_VIDEO,
263 AV_CODEC_ID_ZEROCODEC,
270 AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
271 AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
272 AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'),
273 AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
275 AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
276 AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
277 AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
278 AV_CODEC_ID_V308 = MKBETAG('V','3','0','8'),
279 AV_CODEC_ID_V408 = MKBETAG('V','4','0','8'),
280 AV_CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
281 AV_CODEC_ID_SANM = MKBETAG('S','A','N','M'),
282 AV_CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
283 AV_CODEC_ID_AVRN = MKBETAG('A','V','R','n'),
284 AV_CODEC_ID_CPIA = MKBETAG('C','P','I','A'),
286 /* various PCM "codecs" */
287 AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
288 AV_CODEC_ID_PCM_S16LE = 0x10000,
289 AV_CODEC_ID_PCM_S16BE,
290 AV_CODEC_ID_PCM_U16LE,
291 AV_CODEC_ID_PCM_U16BE,
294 AV_CODEC_ID_PCM_MULAW,
295 AV_CODEC_ID_PCM_ALAW,
296 AV_CODEC_ID_PCM_S32LE,
297 AV_CODEC_ID_PCM_S32BE,
298 AV_CODEC_ID_PCM_U32LE,
299 AV_CODEC_ID_PCM_U32BE,
300 AV_CODEC_ID_PCM_S24LE,
301 AV_CODEC_ID_PCM_S24BE,
302 AV_CODEC_ID_PCM_U24LE,
303 AV_CODEC_ID_PCM_U24BE,
304 AV_CODEC_ID_PCM_S24DAUD,
305 AV_CODEC_ID_PCM_ZORK,
306 AV_CODEC_ID_PCM_S16LE_PLANAR,
308 AV_CODEC_ID_PCM_F32BE,
309 AV_CODEC_ID_PCM_F32LE,
310 AV_CODEC_ID_PCM_F64BE,
311 AV_CODEC_ID_PCM_F64LE,
312 AV_CODEC_ID_PCM_BLURAY,
315 AV_CODEC_ID_PCM_S8_PLANAR,
317 /* various ADPCM codecs */
318 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
319 AV_CODEC_ID_ADPCM_IMA_WAV,
320 AV_CODEC_ID_ADPCM_IMA_DK3,
321 AV_CODEC_ID_ADPCM_IMA_DK4,
322 AV_CODEC_ID_ADPCM_IMA_WS,
323 AV_CODEC_ID_ADPCM_IMA_SMJPEG,
324 AV_CODEC_ID_ADPCM_MS,
325 AV_CODEC_ID_ADPCM_4XM,
326 AV_CODEC_ID_ADPCM_XA,
327 AV_CODEC_ID_ADPCM_ADX,
328 AV_CODEC_ID_ADPCM_EA,
329 AV_CODEC_ID_ADPCM_G726,
330 AV_CODEC_ID_ADPCM_CT,
331 AV_CODEC_ID_ADPCM_SWF,
332 AV_CODEC_ID_ADPCM_YAMAHA,
333 AV_CODEC_ID_ADPCM_SBPRO_4,
334 AV_CODEC_ID_ADPCM_SBPRO_3,
335 AV_CODEC_ID_ADPCM_SBPRO_2,
336 AV_CODEC_ID_ADPCM_THP,
337 AV_CODEC_ID_ADPCM_IMA_AMV,
338 AV_CODEC_ID_ADPCM_EA_R1,
339 AV_CODEC_ID_ADPCM_EA_R3,
340 AV_CODEC_ID_ADPCM_EA_R2,
341 AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
342 AV_CODEC_ID_ADPCM_IMA_EA_EACS,
343 AV_CODEC_ID_ADPCM_EA_XAS,
344 AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
345 AV_CODEC_ID_ADPCM_IMA_ISS,
346 AV_CODEC_ID_ADPCM_G722,
347 AV_CODEC_ID_ADPCM_IMA_APC,
348 AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
351 AV_CODEC_ID_AMR_NB = 0x12000,
354 /* RealAudio codecs*/
355 AV_CODEC_ID_RA_144 = 0x13000,
358 /* various DPCM codecs */
359 AV_CODEC_ID_ROQ_DPCM = 0x14000,
360 AV_CODEC_ID_INTERPLAY_DPCM,
361 AV_CODEC_ID_XAN_DPCM,
362 AV_CODEC_ID_SOL_DPCM,
365 AV_CODEC_ID_MP2 = 0x15000,
366 AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
376 AV_CODEC_ID_VMDAUDIO,
382 AV_CODEC_ID_WESTWOOD_SND1,
383 AV_CODEC_ID_GSM, ///< as in Berlin toast format
386 AV_CODEC_ID_TRUESPEECH,
388 AV_CODEC_ID_SMACKAUDIO,
391 AV_CODEC_ID_DSICINAUDIO,
393 AV_CODEC_ID_MUSEPACK7,
395 AV_CODEC_ID_GSM_MS, /* as found in WAV */
399 AV_CODEC_ID_NELLYMOSER,
400 AV_CODEC_ID_MUSEPACK8,
402 AV_CODEC_ID_WMAVOICE,
404 AV_CODEC_ID_WMALOSSLESS,
413 AV_CODEC_ID_BINKAUDIO_RDFT,
414 AV_CODEC_ID_BINKAUDIO_DCT,
415 AV_CODEC_ID_AAC_LATM,
420 AV_CODEC_ID_8SVX_EXP,
421 AV_CODEC_ID_8SVX_FIB,
422 AV_CODEC_ID_BMV_AUDIO,
426 AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
427 AV_CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
428 AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
429 AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
430 AV_CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
431 AV_CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
433 /* subtitle codecs */
434 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
435 AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
436 AV_CODEC_ID_DVB_SUBTITLE,
437 AV_CODEC_ID_TEXT, ///< raw UTF-8 text
440 AV_CODEC_ID_MOV_TEXT,
441 AV_CODEC_ID_HDMV_PGS_SUBTITLE,
442 AV_CODEC_ID_DVB_TELETEXT,
444 AV_CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
445 AV_CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
446 AV_CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
447 AV_CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
448 AV_CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
449 AV_CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
450 AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'),
452 /* other specific kind of codecs (generally used for attachments) */
453 AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
454 AV_CODEC_ID_TTF = 0x18000,
455 AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
456 AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
457 AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
459 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
461 AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
462 * stream (only used by libavformat) */
463 AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
464 * stream (only used by libavformat) */
465 AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
468 #include "old_codec_ids.h"
473 #define CodecID AVCodecID
477 * This struct describes the properties of a single codec described by an
479 * @see avcodec_get_descriptor()
481 typedef struct AVCodecDescriptor {
483 enum AVMediaType type;
485 * Name of the codec described by this descriptor. It is non-empty and
486 * unique for each codec descriptor. It should contain alphanumeric
487 * characters and '_' only.
491 * A more descriptive name for this codec. May be NULL.
493 const char *long_name;
495 * Codec properties, a combination of AV_CODEC_PROP_* flags.
501 * Codec uses only intra compression.
504 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
506 * Codec supports lossy compression. Audio and video codecs only.
507 * @note a codec may support both lossy and lossless
510 #define AV_CODEC_PROP_LOSSY (1 << 1)
512 * Codec supports lossless compression. Audio and video codecs only.
514 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
516 #if FF_API_OLD_DECODE_AUDIO
518 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
522 * @ingroup lavc_decoding
523 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
524 * This is mainly needed because some optimized bitstream readers read
525 * 32 or 64 bit at once and could read over the end.<br>
526 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
527 * MPEG bitstreams could cause overread and segfault.
529 #define FF_INPUT_BUFFER_PADDING_SIZE 16
532 * @ingroup lavc_encoding
533 * minimum encoding buffer size
534 * Used to avoid some checks during header writing.
536 #define FF_MIN_BUFFER_SIZE 16384
540 * @ingroup lavc_encoding
541 * motion estimation type.
544 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
548 ME_EPZS, ///< enhanced predictive zonal search
549 ME_X1, ///< reserved for experiments
550 ME_HEX, ///< hexagon based search
551 ME_UMH, ///< uneven multi-hexagon search
552 ME_ITER, ///< iterative search
553 ME_TESA, ///< transformed exhaustive search algorithm
557 * @ingroup lavc_decoding
560 /* We leave some space between them for extensions (drop some
561 * keyframes for intra-only or drop just some bidir frames). */
562 AVDISCARD_NONE =-16, ///< discard nothing
563 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
564 AVDISCARD_NONREF = 8, ///< discard all non reference
565 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
566 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
567 AVDISCARD_ALL = 48, ///< discard all
570 enum AVColorPrimaries{
571 AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
572 AVCOL_PRI_UNSPECIFIED = 2,
573 AVCOL_PRI_BT470M = 4,
574 AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
575 AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
576 AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
578 AVCOL_PRI_NB , ///< Not part of ABI
581 enum AVColorTransferCharacteristic{
582 AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
583 AVCOL_TRC_UNSPECIFIED = 2,
584 AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
585 AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
586 AVCOL_TRC_SMPTE240M = 7,
587 AVCOL_TRC_NB , ///< Not part of ABI
592 AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
593 AVCOL_SPC_UNSPECIFIED = 2,
595 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
596 AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
597 AVCOL_SPC_SMPTE240M = 7,
598 AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
599 AVCOL_SPC_NB , ///< Not part of ABI
601 #define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
604 AVCOL_RANGE_UNSPECIFIED = 0,
605 AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
606 AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
607 AVCOL_RANGE_NB , ///< Not part of ABI
611 * X X 3 4 X X are luma samples,
612 * 1 2 1-6 are possible chroma positions
613 * X X 5 6 X 0 is undefined/unknown position
615 enum AVChromaLocation{
616 AVCHROMA_LOC_UNSPECIFIED = 0,
617 AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
618 AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
619 AVCHROMA_LOC_TOPLEFT = 3, ///< DV
620 AVCHROMA_LOC_TOP = 4,
621 AVCHROMA_LOC_BOTTOMLEFT = 5,
622 AVCHROMA_LOC_BOTTOM = 6,
623 AVCHROMA_LOC_NB , ///< Not part of ABI
626 enum AVAudioServiceType {
627 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
628 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
629 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
630 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
631 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
632 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
633 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
634 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
635 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
636 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
640 * @ingroup lavc_encoding
642 typedef struct RcOverride{
645 int qscale; // If this is 0 then quality_factor will be used instead.
646 float quality_factor;
649 #define FF_MAX_B_FRAMES 16
652 These flags can be passed in AVCodecContext.flags before initialization.
653 Note: Not everything is supported yet.
656 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
657 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
658 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
659 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
660 #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
662 * The parent program guarantees that the input for B-frames containing
663 * streams is not written to for at least s->max_b_frames+1 frames, if
664 * this is not set the input will be copied.
666 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
667 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
668 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
669 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
670 #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
671 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
672 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
673 location instead of only at frame boundaries. */
674 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
675 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
676 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
677 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
678 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
679 /* Fx : Flag for h263+ extra options */
680 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
681 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
682 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
683 #define CODEC_FLAG_CLOSED_GOP 0x80000000
684 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
685 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
686 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
687 #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
688 #if FF_API_MPV_GLOBAL_OPTS
689 #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
690 #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
691 #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
692 #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
694 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
695 #define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
697 /* Unsupported options :
698 * Syntax Arithmetic coding (SAC)
699 * Reference Picture Selection
700 * Independent Segment Decoding */
702 /* codec capabilities */
704 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
706 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
707 * If not set, it might not use get_buffer() at all or use operations that
708 * assume the buffer was allocated by avcodec_default_get_buffer.
710 #define CODEC_CAP_DR1 0x0002
711 #define CODEC_CAP_TRUNCATED 0x0008
712 /* Codec can export data for HW decoding (XvMC). */
713 #define CODEC_CAP_HWACCEL 0x0010
715 * Encoder or decoder requires flushing with NULL input at the end in order to
716 * give the complete and correct output.
718 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
719 * with NULL data. The user can still send NULL data to the public encode
720 * or decode function, but libavcodec will not pass it along to the codec
721 * unless this flag is set.
724 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
725 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
729 * The encoder needs to be fed with NULL data at the end of encoding until the
730 * encoder no longer returns data.
732 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
733 * flag also means that the encoder must set the pts and duration for
734 * each output packet. If this flag is not set, the pts and duration will
735 * be determined by libavcodec from the input frame.
737 #define CODEC_CAP_DELAY 0x0020
739 * Codec can be fed a final frame with a smaller size.
740 * This can be used to prevent truncation of the last audio samples.
742 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
744 * Codec can export data for HW decoding (VDPAU).
746 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
748 * Codec can output multiple frames per AVPacket
749 * Normally demuxers return one frame at a time, demuxers which do not do
750 * are connected to a parser to split what they return into proper frames.
751 * This flag is reserved to the very rare category of codecs which have a
752 * bitstream that cannot be split into frames without timeconsuming
753 * operations like full decoding. Demuxers carring such bitstreams thus
754 * may return multiple frames in a packet. This has many disadvantages like
755 * prohibiting stream copy in many cases thus it should only be considered
758 #define CODEC_CAP_SUBFRAMES 0x0100
760 * Codec is experimental and is thus avoided in favor of non experimental
763 #define CODEC_CAP_EXPERIMENTAL 0x0200
765 * Codec should fill in channel configuration and samplerate instead of container
767 #define CODEC_CAP_CHANNEL_CONF 0x0400
770 * Codec is able to deal with negative linesizes
772 #define CODEC_CAP_NEG_LINESIZES 0x0800
775 * Codec supports frame-level multithreading.
777 #define CODEC_CAP_FRAME_THREADS 0x1000
779 * Codec supports slice-based (or partition-based) multithreading.
781 #define CODEC_CAP_SLICE_THREADS 0x2000
783 * Codec supports changed parameters at any point.
785 #define CODEC_CAP_PARAM_CHANGE 0x4000
787 * Codec supports avctx->thread_count == 0 (auto).
789 #define CODEC_CAP_AUTO_THREADS 0x8000
791 * Audio encoder supports receiving a different number of samples in each call.
793 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
795 * Codec is intra only.
797 #define CODEC_CAP_INTRA_ONLY 0x40000000
801 #define CODEC_CAP_LOSSLESS 0x80000000
803 //The following defines may change, don't expect compatibility if you use them.
804 #define MB_TYPE_INTRA4x4 0x0001
805 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
806 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
807 #define MB_TYPE_16x16 0x0008
808 #define MB_TYPE_16x8 0x0010
809 #define MB_TYPE_8x16 0x0020
810 #define MB_TYPE_8x8 0x0040
811 #define MB_TYPE_INTERLACED 0x0080
812 #define MB_TYPE_DIRECT2 0x0100 //FIXME
813 #define MB_TYPE_ACPRED 0x0200
814 #define MB_TYPE_GMC 0x0400
815 #define MB_TYPE_SKIP 0x0800
816 #define MB_TYPE_P0L0 0x1000
817 #define MB_TYPE_P1L0 0x2000
818 #define MB_TYPE_P0L1 0x4000
819 #define MB_TYPE_P1L1 0x8000
820 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
821 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
822 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
823 #define MB_TYPE_QUANT 0x00010000
824 #define MB_TYPE_CBP 0x00020000
825 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
829 * This specifies the area which should be displayed.
830 * Note there may be multiple such areas for one frame.
832 typedef struct AVPanScan{
835 * - encoding: Set by user.
836 * - decoding: Set by libavcodec.
841 * width and height in 1/16 pel
842 * - encoding: Set by user.
843 * - decoding: Set by libavcodec.
849 * position of the top left corner in 1/16 pel for up to 3 fields/frames
850 * - encoding: Set by user.
851 * - decoding: Set by libavcodec.
853 int16_t position[3][2];
856 #define FF_QSCALE_TYPE_MPEG1 0
857 #define FF_QSCALE_TYPE_MPEG2 1
858 #define FF_QSCALE_TYPE_H264 2
859 #define FF_QSCALE_TYPE_VP56 3
861 #define FF_BUFFER_TYPE_INTERNAL 1
862 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
863 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
864 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
866 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
867 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
868 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
869 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
872 * @defgroup lavc_packet AVPacket
874 * Types and functions for working with AVPacket.
877 enum AVPacketSideDataType {
879 AV_PKT_DATA_NEW_EXTRADATA,
882 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
885 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
886 * s32le channel_count
887 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
888 * u64le channel_layout
889 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
891 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
896 AV_PKT_DATA_PARAM_CHANGE,
899 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
900 * structures with info about macroblocks relevant to splitting the
901 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
902 * That is, it does not necessarily contain info about all macroblocks,
903 * as long as the distance between macroblocks in the info is smaller
904 * than the target payload size.
905 * Each MB info structure is 12 bytes, and is laid out as follows:
907 * u32le bit offset from the start of the packet
908 * u8 current quantizer at the start of the macroblock
910 * u16le macroblock address within the GOB
911 * u8 horizontal MV predictor
912 * u8 vertical MV predictor
913 * u8 horizontal MV predictor for block number 3
914 * u8 vertical MV predictor for block number 3
917 AV_PKT_DATA_H263_MB_INFO,
920 * Recommmends skipping the specified number of samples
922 * u32le number of samples to skip from start of this packet
923 * u32le number of samples to skip from end of this packet
924 * u8 reason for start skip
925 * u8 reason for end skip (0=padding silence, 1=convergence)
928 AV_PKT_DATA_SKIP_SAMPLES=70,
931 typedef struct AVPacket {
933 * Presentation timestamp in AVStream->time_base units; the time at which
934 * the decompressed packet will be presented to the user.
935 * Can be AV_NOPTS_VALUE if it is not stored in the file.
936 * pts MUST be larger or equal to dts as presentation cannot happen before
937 * decompression, unless one wants to view hex dumps. Some formats misuse
938 * the terms dts and pts/cts to mean something different. Such timestamps
939 * must be converted to true pts/dts before they are stored in AVPacket.
943 * Decompression timestamp in AVStream->time_base units; the time at which
944 * the packet is decompressed.
945 * Can be AV_NOPTS_VALUE if it is not stored in the file.
952 * A combination of AV_PKT_FLAG values
956 * Additional packet data that can be provided by the container.
957 * Packet can contain several types of side information.
962 enum AVPacketSideDataType type;
967 * Duration of this packet in AVStream->time_base units, 0 if unknown.
968 * Equals next_pts - this_pts in presentation order.
971 void (*destruct)(struct AVPacket *);
973 int64_t pos; ///< byte position in stream, -1 if unknown
976 * Time difference in AVStream->time_base units from the pts of this
977 * packet to the point at which the output from the decoder has converged
978 * independent from the availability of previous frames. That is, the
979 * frames are virtually identical no matter if decoding started from
980 * the very first frame or from this keyframe.
981 * Is AV_NOPTS_VALUE if unknown.
982 * This field is not the display duration of the current packet.
983 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
986 * The purpose of this field is to allow seeking in streams that have no
987 * keyframes in the conventional sense. It corresponds to the
988 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
989 * essential for some types of subtitle streams to ensure that all
990 * subtitles are correctly displayed after seeking.
992 int64_t convergence_duration;
994 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
995 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
997 enum AVSideDataParamChangeFlags {
998 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
999 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
1000 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
1001 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
1008 * Audio Video Frame.
1009 * New fields can be added to the end of AVFRAME with minor version
1010 * bumps. Similarly fields that are marked as to be only accessed by
1011 * av_opt_ptr() can be reordered. This allows 2 forks to add fields
1012 * without breaking compatibility with each other.
1013 * Removal, reordering and changes in the remaining cases require
1014 * a major version bump.
1015 * sizeof(AVFrame) must not be used outside libavcodec.
1017 typedef struct AVFrame {
1018 #define AV_NUM_DATA_POINTERS 8
1020 * pointer to the picture/channel planes.
1021 * This might be different from the first allocated byte
1022 * - encoding: Set by user
1023 * - decoding: set by AVCodecContext.get_buffer()
1025 uint8_t *data[AV_NUM_DATA_POINTERS];
1028 * Size, in bytes, of the data for each picture/channel plane.
1030 * For audio, only linesize[0] may be set. For planar audio, each channel
1031 * plane must be the same size.
1033 * - encoding: Set by user
1034 * - decoding: set by AVCodecContext.get_buffer()
1036 int linesize[AV_NUM_DATA_POINTERS];
1039 * pointers to the data planes/channels.
1041 * For video, this should simply point to data[].
1043 * For planar audio, each channel has a separate data pointer, and
1044 * linesize[0] contains the size of each channel buffer.
1045 * For packed audio, there is just one data pointer, and linesize[0]
1046 * contains the total size of the buffer for all channels.
1048 * Note: Both data and extended_data will always be set by get_buffer(),
1049 * but for planar audio with more channels that can fit in data,
1050 * extended_data must be used by the decoder in order to access all
1054 * decoding: set by AVCodecContext.get_buffer()
1056 uint8_t **extended_data;
1059 * width and height of the video frame
1060 * - encoding: unused
1061 * - decoding: Read by user.
1066 * number of audio samples (per channel) described by this frame
1067 * - encoding: Set by user
1068 * - decoding: Set by libavcodec
1073 * format of the frame, -1 if unknown or unset
1074 * Values correspond to enum PixelFormat for video frames,
1075 * enum AVSampleFormat for audio)
1076 * - encoding: unused
1077 * - decoding: Read by user.
1082 * 1 -> keyframe, 0-> not
1083 * - encoding: Set by libavcodec.
1084 * - decoding: Set by libavcodec.
1089 * Picture type of the frame, see ?_TYPE below.
1090 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1091 * - decoding: Set by libavcodec.
1093 enum AVPictureType pict_type;
1096 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
1097 * This isn't used by libavcodec unless the default get/release_buffer() is used.
1101 uint8_t *base[AV_NUM_DATA_POINTERS];
1104 * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
1105 * - encoding: unused
1106 * - decoding: Read by user.
1108 AVRational sample_aspect_ratio;
1111 * presentation timestamp in time_base units (time when frame should be shown to user)
1112 * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
1113 * - encoding: MUST be set by user.
1114 * - decoding: Set by libavcodec.
1119 * reordered pts from the last AVPacket that has been input into the decoder
1120 * - encoding: unused
1121 * - decoding: Read by user.
1126 * dts from the last AVPacket that has been input into the decoder
1127 * - encoding: unused
1128 * - decoding: Read by user.
1133 * picture number in bitstream order
1134 * - encoding: set by
1135 * - decoding: Set by libavcodec.
1137 int coded_picture_number;
1139 * picture number in display order
1140 * - encoding: set by
1141 * - decoding: Set by libavcodec.
1143 int display_picture_number;
1146 * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
1147 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1148 * - decoding: Set by libavcodec.
1153 * is this picture used as reference
1154 * The values for this are the same as the MpegEncContext.picture_structure
1155 * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1156 * Set to 4 for delayed, non-reference frames.
1157 * - encoding: unused
1158 * - decoding: Set by libavcodec. (before get_buffer() call)).
1164 * - encoding: unused
1165 * - decoding: Set by libavcodec.
1167 int8_t *qscale_table;
1170 * - encoding: unused
1171 * - decoding: Set by libavcodec.
1181 * mbskip_table[mb]>=1 if MB didn't change
1182 * stride= mb_width = (width+15)>>4
1183 * - encoding: unused
1184 * - decoding: Set by libavcodec.
1186 uint8_t *mbskip_table;
1189 * motion vector table
1192 * int mv_sample_log2= 4 - motion_subsample_log2;
1193 * int mb_width= (width+15)>>4;
1194 * int mv_stride= (mb_width << mv_sample_log2) + 1;
1195 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1197 * - encoding: Set by user.
1198 * - decoding: Set by libavcodec.
1200 int16_t (*motion_val[2])[2];
1203 * macroblock type table
1204 * mb_type_base + mb_width + 2
1205 * - encoding: Set by user.
1206 * - decoding: Set by libavcodec.
1212 * - encoding: unused
1213 * - decoding: Set by libavcodec.
1218 * motion reference frame index
1219 * the order in which these are stored can depend on the codec.
1220 * - encoding: Set by user.
1221 * - decoding: Set by libavcodec.
1223 int8_t *ref_index[2];
1226 * for some private data of the user
1227 * - encoding: unused
1228 * - decoding: Set by user.
1234 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1235 * - decoding: unused
1237 uint64_t error[AV_NUM_DATA_POINTERS];
1240 * type of the buffer (to keep track of who has to deallocate data[*])
1241 * - encoding: Set by the one who allocates it.
1242 * - decoding: Set by the one who allocates it.
1243 * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1248 * When decoding, this signals how much the picture must be delayed.
1249 * extra_delay = repeat_pict / (2*fps)
1250 * - encoding: unused
1251 * - decoding: Set by libavcodec.
1256 * The content of the picture is interlaced.
1257 * - encoding: Set by user.
1258 * - decoding: Set by libavcodec. (default 0)
1260 int interlaced_frame;
1263 * If the content is interlaced, is top field displayed first.
1264 * - encoding: Set by user.
1265 * - decoding: Set by libavcodec.
1267 int top_field_first;
1270 * Tell user application that palette has changed from previous frame.
1271 * - encoding: ??? (no palette-enabled encoder yet)
1272 * - decoding: Set by libavcodec. (default 0).
1274 int palette_has_changed;
1277 * codec suggestion on buffer type if != 0
1278 * - encoding: unused
1279 * - decoding: Set by libavcodec. (before get_buffer() call)).
1285 * - encoding: Set by user.
1286 * - decoding: Set by libavcodec.
1288 AVPanScan *pan_scan;
1291 * reordered opaque 64bit (generally an integer or a double precision float
1292 * PTS but can be anything).
1293 * The user sets AVCodecContext.reordered_opaque to represent the input at
1295 * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1296 * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1297 * @deprecated in favor of pkt_pts
1298 * - encoding: unused
1299 * - decoding: Read by user.
1301 int64_t reordered_opaque;
1304 * hardware accelerator private data (FFmpeg-allocated)
1305 * - encoding: unused
1306 * - decoding: Set by libavcodec
1308 void *hwaccel_picture_private;
1311 * the AVCodecContext which ff_thread_get_buffer() was last called on
1312 * - encoding: Set by libavcodec.
1313 * - decoding: Set by libavcodec.
1315 struct AVCodecContext *owner;
1318 * used by multithreading to store frame-specific info
1319 * - encoding: Set by libavcodec.
1320 * - decoding: Set by libavcodec.
1322 void *thread_opaque;
1325 * log2 of the size of the block which a single vector in motion_val represents:
1326 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1327 * - encoding: unused
1328 * - decoding: Set by libavcodec.
1330 uint8_t motion_subsample_log2;
1333 * Sample rate of the audio data.
1335 * - encoding: unused
1336 * - decoding: read by user
1341 * Channel layout of the audio data.
1343 * - encoding: unused
1344 * - decoding: read by user.
1346 uint64_t channel_layout;
1349 * frame timestamp estimated using various heuristics, in stream time base
1350 * Code outside libavcodec should access this field using:
1351 * av_frame_get_best_effort_timestamp(frame)
1352 * - encoding: unused
1353 * - decoding: set by libavcodec, read by user.
1355 int64_t best_effort_timestamp;
1358 * reordered pos from the last AVPacket that has been input into the decoder
1359 * Code outside libavcodec should access this field using:
1360 * av_frame_get_pkt_pos(frame)
1361 * - encoding: unused
1362 * - decoding: Read by user.
1367 * duration of the corresponding packet, expressed in
1368 * AVStream->time_base units, 0 if unknown.
1369 * Code outside libavcodec should access this field using:
1370 * av_frame_get_pkt_duration(frame)
1371 * - encoding: unused
1372 * - decoding: Read by user.
1374 int64_t pkt_duration;
1378 * Code outside libavcodec should access this field using:
1379 * av_frame_get_metadata(frame)
1380 * - encoding: Set by user.
1381 * - decoding: Set by libavcodec.
1383 AVDictionary *metadata;
1386 * decode error flags of the frame, set to a combination of
1387 * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
1388 * were errors during the decoding.
1389 * Code outside libavcodec should access this field using:
1390 * av_frame_get_decode_error_flags(frame)
1391 * - encoding: unused
1392 * - decoding: set by libavcodec, read by user.
1394 int decode_error_flags;
1395 #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
1396 #define FF_DECODE_ERROR_MISSING_REFERENCE 2
1399 * number of audio channels, only used for audio.
1400 * Code outside libavcodec should access this field using:
1401 * av_frame_get_channels(frame)
1402 * - encoding: unused
1403 * - decoding: Read by user.
1409 * Accessors for some AVFrame fields.
1410 * The position of these field in the structure is not part of the ABI,
1411 * they should not be accessed directly outside libavcodec.
1413 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
1414 void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
1415 int64_t av_frame_get_pkt_duration (const AVFrame *frame);
1416 void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
1417 int64_t av_frame_get_pkt_pos (const AVFrame *frame);
1418 void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
1419 int64_t av_frame_get_channel_layout (const AVFrame *frame);
1420 void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
1421 int av_frame_get_channels (const AVFrame *frame);
1422 void av_frame_set_channels (AVFrame *frame, int val);
1423 int av_frame_get_sample_rate (const AVFrame *frame);
1424 void av_frame_set_sample_rate (AVFrame *frame, int val);
1425 AVDictionary *av_frame_get_metadata (const AVFrame *frame);
1426 void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
1427 int av_frame_get_decode_error_flags (const AVFrame *frame);
1428 void av_frame_set_decode_error_flags (AVFrame *frame, int val);
1430 struct AVCodecInternal;
1434 AV_FIELD_PROGRESSIVE,
1435 AV_FIELD_TT, //< Top coded_first, top displayed first
1436 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1437 AV_FIELD_TB, //< Top coded first, bottom displayed first
1438 AV_FIELD_BT, //< Bottom coded first, top displayed first
1442 * main external API structure.
1443 * New fields can be added to the end with minor version bumps.
1444 * Removal, reordering and changes to existing fields require a major
1446 * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1448 * sizeof(AVCodecContext) must not be used outside libav*.
1450 typedef struct AVCodecContext {
1452 * information on struct for av_log
1453 * - set by avcodec_alloc_context3
1455 const AVClass *av_class;
1456 int log_level_offset;
1458 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1459 const struct AVCodec *codec;
1460 char codec_name[32];
1461 enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
1464 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1465 * This is used to work around some encoder bugs.
1466 * A demuxer should set this to what is stored in the field used to identify the codec.
1467 * If there are multiple such fields in a container then the demuxer should choose the one
1468 * which maximizes the information about the used codec.
1469 * If the codec tag field in a container is larger than 32 bits then the demuxer should
1470 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1471 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1473 * - encoding: Set by user, if not then the default based on codec_id will be used.
1474 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1476 unsigned int codec_tag;
1479 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1480 * This is used to work around some encoder bugs.
1481 * - encoding: unused
1482 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1484 unsigned int stream_codec_tag;
1488 * @deprecated this field is unused
1490 attribute_deprecated int sub_id;
1496 * Private context used for internal data.
1498 * Unlike priv_data, this is not codec-specific. It is used in general
1499 * libavcodec functions.
1501 struct AVCodecInternal *internal;
1504 * Private data of the user, can be used to carry app specific stuff.
1505 * - encoding: Set by user.
1506 * - decoding: Set by user.
1511 * the average bitrate
1512 * - encoding: Set by user; unused for constant quantizer encoding.
1513 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1518 * number of bits the bitstream is allowed to diverge from the reference.
1519 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1520 * - encoding: Set by user; unused for constant quantizer encoding.
1521 * - decoding: unused
1523 int bit_rate_tolerance;
1526 * Global quality for codecs which cannot change it per frame.
1527 * This should be proportional to MPEG-1/2/4 qscale.
1528 * - encoding: Set by user.
1529 * - decoding: unused
1534 * - encoding: Set by user.
1535 * - decoding: unused
1537 int compression_level;
1538 #define FF_COMPRESSION_DEFAULT -1
1542 * - encoding: Set by user.
1543 * - decoding: Set by user.
1549 * - encoding: Set by user.
1550 * - decoding: Set by user.
1555 * some codecs need / can use extradata like Huffman tables.
1556 * mjpeg: Huffman tables
1557 * rv10: additional flags
1558 * mpeg4: global headers (they can be in the bitstream or here)
1559 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1560 * than extradata_size to avoid prolems if it is read with the bitstream reader.
1561 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1562 * - encoding: Set/allocated/freed by libavcodec.
1563 * - decoding: Set/allocated/freed by user.
1569 * This is the fundamental unit of time (in seconds) in terms
1570 * of which frame timestamps are represented. For fixed-fps content,
1571 * timebase should be 1/framerate and timestamp increments should be
1573 * - encoding: MUST be set by user.
1574 * - decoding: Set by libavcodec.
1576 AVRational time_base;
1579 * For some codecs, the time base is closer to the field rate than the frame rate.
1580 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1581 * if no telecine is used ...
1583 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1585 int ticks_per_frame;
1588 * Encoding: Number of frames delay there will be from the encoder input to
1589 * the decoder output. (we assume the decoder matches the spec)
1590 * Decoding: Number of frames delay in addition to what a standard decoder
1591 * as specified in the spec would produce.
1594 * Number of frames the decoded output will be delayed relative to the
1598 * Number of "priming" samples added to the beginning of the stream
1599 * during encoding. The decoded output will be delayed by this many
1600 * samples relative to the input to the encoder. Note that this field is
1601 * purely informational and does not directly affect the pts output by
1602 * the encoder, which should always be based on the actual presentation
1603 * time, including any delay.
1605 * - encoding: Set by libavcodec.
1606 * - decoding: Set by libavcodec.
1613 * picture width / height.
1614 * - encoding: MUST be set by user.
1615 * - decoding: Set by libavcodec.
1616 * Note: For compatibility it is possible to set this instead of
1617 * coded_width/height before decoding.
1622 * Bitstream width / height, may be different from width/height if lowres enabled.
1623 * - encoding: unused
1624 * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
1626 int coded_width, coded_height;
1628 #define FF_ASPECT_EXTENDED 15
1631 * the number of pictures in a group of pictures, or 0 for intra_only
1632 * - encoding: Set by user.
1633 * - decoding: unused
1638 * Pixel format, see PIX_FMT_xxx.
1639 * May be set by the demuxer if known from headers.
1640 * May be overridden by the decoder if it knows better.
1641 * - encoding: Set by user.
1642 * - decoding: Set by user if known, overridden by libavcodec if known
1644 enum PixelFormat pix_fmt;
1647 * Motion estimation algorithm used for video coding.
1648 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1649 * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1650 * - encoding: MUST be set by user.
1651 * - decoding: unused
1656 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1657 * decoder to draw a horizontal band. It improves cache usage. Not
1658 * all codecs can do that. You must check the codec capabilities
1660 * When multithreading is used, it may be called from multiple threads
1661 * at the same time; threads might draw different parts of the same AVFrame,
1662 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1664 * The function is also used by hardware acceleration APIs.
1665 * It is called at least once during frame decoding to pass
1666 * the data needed for hardware render.
1667 * In that mode instead of pixel data, AVFrame points to
1668 * a structure specific to the acceleration API. The application
1669 * reads the structure and can change some fields to indicate progress
1671 * - encoding: unused
1672 * - decoding: Set by user.
1673 * @param height the height of the slice
1674 * @param y the y position of the slice
1675 * @param type 1->top field, 2->bottom field, 3->frame
1676 * @param offset offset into the AVFrame.data from which the slice should be read
1678 void (*draw_horiz_band)(struct AVCodecContext *s,
1679 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1680 int y, int type, int height);
1683 * callback to negotiate the pixelFormat
1684 * @param fmt is the list of formats which are supported by the codec,
1685 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1686 * The first is always the native one.
1687 * @return the chosen format
1688 * - encoding: unused
1689 * - decoding: Set by user, if not set the native format will be chosen.
1691 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
1694 * maximum number of B-frames between non-B-frames
1695 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1696 * - encoding: Set by user.
1697 * - decoding: unused
1702 * qscale factor between IP and B-frames
1703 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1704 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1705 * - encoding: Set by user.
1706 * - decoding: unused
1708 float b_quant_factor;
1710 /** obsolete FIXME remove */
1712 #define FF_RC_STRATEGY_XVID 1
1714 int b_frame_strategy;
1716 #if FF_API_MPV_GLOBAL_OPTS
1718 * luma single coefficient elimination threshold
1719 * - encoding: Set by user.
1720 * - decoding: unused
1722 attribute_deprecated int luma_elim_threshold;
1725 * chroma single coeff elimination threshold
1726 * - encoding: Set by user.
1727 * - decoding: unused
1729 attribute_deprecated int chroma_elim_threshold;
1733 * qscale offset between IP and B-frames
1734 * - encoding: Set by user.
1735 * - decoding: unused
1737 float b_quant_offset;
1740 * Size of the frame reordering buffer in the decoder.
1741 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1742 * - encoding: Set by libavcodec.
1743 * - decoding: Set by libavcodec.
1748 * 0-> h263 quant 1-> mpeg quant
1749 * - encoding: Set by user.
1750 * - decoding: unused
1755 * qscale factor between P and I-frames
1756 * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1757 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1758 * - encoding: Set by user.
1759 * - decoding: unused
1761 float i_quant_factor;
1764 * qscale offset between P and I-frames
1765 * - encoding: Set by user.
1766 * - decoding: unused
1768 float i_quant_offset;
1771 * luminance masking (0-> disabled)
1772 * - encoding: Set by user.
1773 * - decoding: unused
1778 * temporary complexity masking (0-> disabled)
1779 * - encoding: Set by user.
1780 * - decoding: unused
1782 float temporal_cplx_masking;
1785 * spatial complexity masking (0-> disabled)
1786 * - encoding: Set by user.
1787 * - decoding: unused
1789 float spatial_cplx_masking;
1792 * p block masking (0-> disabled)
1793 * - encoding: Set by user.
1794 * - decoding: unused
1799 * darkness masking (0-> disabled)
1800 * - encoding: Set by user.
1801 * - decoding: unused
1807 * - encoding: Set by libavcodec.
1808 * - decoding: Set by user (or 0).
1812 * prediction method (needed for huffyuv)
1813 * - encoding: Set by user.
1814 * - decoding: unused
1816 int prediction_method;
1817 #define FF_PRED_LEFT 0
1818 #define FF_PRED_PLANE 1
1819 #define FF_PRED_MEDIAN 2
1822 * slice offsets in the frame in bytes
1823 * - encoding: Set/allocated by libavcodec.
1824 * - decoding: Set/allocated by user (or NULL).
1829 * sample aspect ratio (0 if unknown)
1830 * That is the width of a pixel divided by the height of the pixel.
1831 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1832 * - encoding: Set by user.
1833 * - decoding: Set by libavcodec.
1835 AVRational sample_aspect_ratio;
1838 * motion estimation comparison function
1839 * - encoding: Set by user.
1840 * - decoding: unused
1844 * subpixel motion estimation comparison function
1845 * - encoding: Set by user.
1846 * - decoding: unused
1850 * macroblock comparison function (not supported yet)
1851 * - encoding: Set by user.
1852 * - decoding: unused
1856 * interlaced DCT comparison function
1857 * - encoding: Set by user.
1858 * - decoding: unused
1861 #define FF_CMP_SAD 0
1862 #define FF_CMP_SSE 1
1863 #define FF_CMP_SATD 2
1864 #define FF_CMP_DCT 3
1865 #define FF_CMP_PSNR 4
1866 #define FF_CMP_BIT 5
1868 #define FF_CMP_ZERO 7
1869 #define FF_CMP_VSAD 8
1870 #define FF_CMP_VSSE 9
1871 #define FF_CMP_NSSE 10
1872 #define FF_CMP_W53 11
1873 #define FF_CMP_W97 12
1874 #define FF_CMP_DCTMAX 13
1875 #define FF_CMP_DCT264 14
1876 #define FF_CMP_CHROMA 256
1879 * ME diamond size & shape
1880 * - encoding: Set by user.
1881 * - decoding: unused
1886 * amount of previous MV predictors (2a+1 x 2a+1 square)
1887 * - encoding: Set by user.
1888 * - decoding: unused
1890 int last_predictor_count;
1893 * prepass for motion estimation
1894 * - encoding: Set by user.
1895 * - decoding: unused
1900 * motion estimation prepass comparison function
1901 * - encoding: Set by user.
1902 * - decoding: unused
1907 * ME prepass diamond size & shape
1908 * - encoding: Set by user.
1909 * - decoding: unused
1915 * - encoding: Set by user.
1916 * - decoding: unused
1918 int me_subpel_quality;
1921 * DTG active format information (additional aspect ratio
1922 * information only used in DVB MPEG-2 transport streams)
1925 * - encoding: unused
1926 * - decoding: Set by decoder.
1928 int dtg_active_format;
1929 #define FF_DTG_AFD_SAME 8
1930 #define FF_DTG_AFD_4_3 9
1931 #define FF_DTG_AFD_16_9 10
1932 #define FF_DTG_AFD_14_9 11
1933 #define FF_DTG_AFD_4_3_SP_14_9 13
1934 #define FF_DTG_AFD_16_9_SP_14_9 14
1935 #define FF_DTG_AFD_SP_4_3 15
1938 * maximum motion estimation search range in subpel units
1939 * If 0 then no limit.
1941 * - encoding: Set by user.
1942 * - decoding: unused
1947 * intra quantizer bias
1948 * - encoding: Set by user.
1949 * - decoding: unused
1951 int intra_quant_bias;
1952 #define FF_DEFAULT_QUANT_BIAS 999999
1955 * inter quantizer bias
1956 * - encoding: Set by user.
1957 * - decoding: unused
1959 int inter_quant_bias;
1961 #if FF_API_COLOR_TABLE_ID
1964 * - encoding: unused
1965 * - decoding: Which clrtable should be used for 8bit RGB images.
1966 * Tables have to be stored somewhere. FIXME
1968 attribute_deprecated int color_table_id;
1973 * - encoding: unused
1974 * - decoding: Set by user.
1977 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1978 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1979 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1982 * XVideo Motion Acceleration
1983 * - encoding: forbidden
1984 * - decoding: set by decoder
1986 int xvmc_acceleration;
1989 * macroblock decision mode
1990 * - encoding: Set by user.
1991 * - decoding: unused
1994 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1995 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1996 #define FF_MB_DECISION_RD 2 ///< rate distortion
1999 * custom intra quantization matrix
2000 * - encoding: Set by user, can be NULL.
2001 * - decoding: Set by libavcodec.
2003 uint16_t *intra_matrix;
2006 * custom inter quantization matrix
2007 * - encoding: Set by user, can be NULL.
2008 * - decoding: Set by libavcodec.
2010 uint16_t *inter_matrix;
2013 * scene change detection threshold
2014 * 0 is default, larger means fewer detected scene changes.
2015 * - encoding: Set by user.
2016 * - decoding: unused
2018 int scenechange_threshold;
2021 * noise reduction strength
2022 * - encoding: Set by user.
2023 * - decoding: unused
2025 int noise_reduction;
2027 #if FF_API_INTER_THRESHOLD
2029 * @deprecated this field is unused
2031 attribute_deprecated int inter_threshold;
2034 #if FF_API_MPV_GLOBAL_OPTS
2036 * @deprecated use mpegvideo private options instead
2038 attribute_deprecated int quantizer_noise_shaping;
2042 * Motion estimation threshold below which no motion estimation is
2043 * performed, but instead the user specified motion vectors are used.
2045 * - encoding: Set by user.
2046 * - decoding: unused
2051 * Macroblock threshold below which the user specified macroblock types will be used.
2052 * - encoding: Set by user.
2053 * - decoding: unused
2058 * precision of the intra DC coefficient - 8
2059 * - encoding: Set by user.
2060 * - decoding: unused
2062 int intra_dc_precision;
2065 * Number of macroblock rows at the top which are skipped.
2066 * - encoding: unused
2067 * - decoding: Set by user.
2072 * Number of macroblock rows at the bottom which are skipped.
2073 * - encoding: unused
2074 * - decoding: Set by user.
2079 * Border processing masking, raises the quantizer for mbs on the borders
2081 * - encoding: Set by user.
2082 * - decoding: unused
2084 float border_masking;
2087 * minimum MB lagrange multipler
2088 * - encoding: Set by user.
2089 * - decoding: unused
2094 * maximum MB lagrange multipler
2095 * - encoding: Set by user.
2096 * - decoding: unused
2102 * - encoding: Set by user.
2103 * - decoding: unused
2105 int me_penalty_compensation;
2109 * - encoding: Set by user.
2110 * - decoding: unused
2116 * - encoding: Set by user.
2117 * - decoding: unused
2123 * - encoding: Set by user.
2124 * - decoding: unused
2129 * number of reference frames
2130 * - encoding: Set by user.
2131 * - decoding: Set by lavc.
2136 * chroma qp offset from luma
2137 * - encoding: Set by user.
2138 * - decoding: unused
2143 * Multiplied by qscale for each frame and added to scene_change_score.
2144 * - encoding: Set by user.
2145 * - decoding: unused
2147 int scenechange_factor;
2151 * Note: Value depends upon the compare function used for fullpel ME.
2152 * - encoding: Set by user.
2153 * - decoding: unused
2158 * Adjust sensitivity of b_frame_strategy 1.
2159 * - encoding: Set by user.
2160 * - decoding: unused
2165 * Chromaticity coordinates of the source primaries.
2166 * - encoding: Set by user
2167 * - decoding: Set by libavcodec
2169 enum AVColorPrimaries color_primaries;
2172 * Color Transfer Characteristic.
2173 * - encoding: Set by user
2174 * - decoding: Set by libavcodec
2176 enum AVColorTransferCharacteristic color_trc;
2179 * YUV colorspace type.
2180 * - encoding: Set by user
2181 * - decoding: Set by libavcodec
2183 enum AVColorSpace colorspace;
2186 * MPEG vs JPEG YUV range.
2187 * - encoding: Set by user
2188 * - decoding: Set by libavcodec
2190 enum AVColorRange color_range;
2193 * This defines the location of chroma samples.
2194 * - encoding: Set by user
2195 * - decoding: Set by libavcodec
2197 enum AVChromaLocation chroma_sample_location;
2201 * Indicates number of picture subdivisions. Used for parallelized
2203 * - encoding: Set by user
2204 * - decoding: unused
2209 * - encoding: set by libavcodec
2210 * - decoding: Set by libavcodec
2212 enum AVFieldOrder field_order;
2215 int sample_rate; ///< samples per second
2216 int channels; ///< number of audio channels
2219 * audio sample format
2220 * - encoding: Set by user.
2221 * - decoding: Set by libavcodec.
2223 enum AVSampleFormat sample_fmt; ///< sample format
2225 /* The following data should not be initialized. */
2227 * Samples per packet, initialized when calling 'init'.
2232 * Frame counter, set by libavcodec.
2234 * - decoding: total number of frames returned from the decoder so far.
2235 * - encoding: total number of frames passed to the encoder so far.
2237 * @note the counter is not incremented if encoding/decoding resulted in
2243 * number of bytes per packet if constant and known or 0
2244 * Used by some WAV based audio codecs.
2249 * Audio cutoff bandwidth (0 means "automatic")
2250 * - encoding: Set by user.
2251 * - decoding: unused
2255 #if FF_API_REQUEST_CHANNELS
2257 * Decoder should decode to this many channels if it can (0 for default)
2258 * - encoding: unused
2259 * - decoding: Set by user.
2260 * @deprecated Deprecated in favor of request_channel_layout.
2262 int request_channels;
2266 * Audio channel layout.
2267 * - encoding: set by user.
2268 * - decoding: set by user, may be overwritten by libavcodec.
2270 uint64_t channel_layout;
2273 * Request decoder to use this channel layout if it can (0 for default)
2274 * - encoding: unused
2275 * - decoding: Set by user.
2277 uint64_t request_channel_layout;
2280 * Type of service that the audio stream conveys.
2281 * - encoding: Set by user.
2282 * - decoding: Set by libavcodec.
2284 enum AVAudioServiceType audio_service_type;
2287 * desired sample format
2288 * - encoding: Not used.
2289 * - decoding: Set by user.
2290 * Decoder will decode to this format if it can.
2292 enum AVSampleFormat request_sample_fmt;
2295 * Called at the beginning of each frame to get a buffer for it.
2297 * The function will set AVFrame.data[], AVFrame.linesize[].
2298 * AVFrame.extended_data[] must also be set, but it should be the same as
2299 * AVFrame.data[] except for planar audio with more channels than can fit
2300 * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
2301 * many data pointers as it can hold.
2303 * if CODEC_CAP_DR1 is not set then get_buffer() must call
2304 * avcodec_default_get_buffer() instead of providing buffers allocated by
2307 * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
2308 * need it. avcodec_default_get_buffer() aligns the output buffer properly,
2309 * but if get_buffer() is overridden then alignment considerations should
2310 * be taken into account.
2312 * @see avcodec_default_get_buffer()
2316 * If pic.reference is set then the frame will be read later by libavcodec.
2317 * avcodec_align_dimensions2() should be used to find the required width and
2318 * height, as they normally need to be rounded up to the next multiple of 16.
2320 * If frame multithreading is used and thread_safe_callbacks is set,
2321 * it may be called from a different thread, but not from more than one at
2322 * once. Does not need to be reentrant.
2324 * @see release_buffer(), reget_buffer()
2325 * @see avcodec_align_dimensions2()
2329 * Decoders request a buffer of a particular size by setting
2330 * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
2331 * however, utilize only part of the buffer by setting AVFrame.nb_samples
2332 * to a smaller value in the output frame.
2334 * Decoders cannot use the buffer after returning from
2335 * avcodec_decode_audio4(), so they will not call release_buffer(), as it
2336 * is assumed to be released immediately upon return.
2338 * As a convenience, av_samples_get_buffer_size() and
2339 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
2340 * functions to find the required data size and to fill data pointers and
2341 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2342 * since all planes must be the same size.
2344 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2346 * - encoding: unused
2347 * - decoding: Set by libavcodec, user can override.
2349 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
2352 * Called to release buffers which were allocated with get_buffer.
2353 * A released buffer can be reused in get_buffer().
2354 * pic.data[*] must be set to NULL.
2355 * May be called from a different thread if frame multithreading is used,
2356 * but not by more than one thread at once, so does not need to be reentrant.
2357 * - encoding: unused
2358 * - decoding: Set by libavcodec, user can override.
2360 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
2363 * Called at the beginning of a frame to get cr buffer for it.
2364 * Buffer type (size, hints) must be the same. libavcodec won't check it.
2365 * libavcodec will pass previous buffer in pic, function should return
2366 * same buffer or new buffer with old frame "painted" into it.
2367 * If pic.data[0] == NULL must behave like get_buffer().
2368 * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2369 * avcodec_default_reget_buffer() instead of providing buffers allocated by
2371 * - encoding: unused
2372 * - decoding: Set by libavcodec, user can override.
2374 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2377 /* - encoding parameters */
2378 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2379 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2383 * - encoding: Set by user.
2384 * - decoding: unused
2390 * - encoding: Set by user.
2391 * - decoding: unused
2396 * maximum quantizer difference between frames
2397 * - encoding: Set by user.
2398 * - decoding: unused
2403 * ratecontrol qmin qmax limiting method
2404 * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
2405 * - encoding: Set by user.
2406 * - decoding: unused
2414 * decoder bitstream buffer size
2415 * - encoding: Set by user.
2416 * - decoding: unused
2421 * ratecontrol override, see RcOverride
2422 * - encoding: Allocated/set/freed by user.
2423 * - decoding: unused
2425 int rc_override_count;
2426 RcOverride *rc_override;
2429 * rate control equation
2430 * - encoding: Set by user
2431 * - decoding: unused
2437 * - encoding: Set by user.
2438 * - decoding: unused
2444 * - encoding: Set by user.
2445 * - decoding: unused
2449 float rc_buffer_aggressivity;
2452 * initial complexity for pass1 ratecontrol
2453 * - encoding: Set by user.
2454 * - decoding: unused
2456 float rc_initial_cplx;
2459 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2460 * - encoding: Set by user.
2461 * - decoding: unused.
2463 float rc_max_available_vbv_use;
2466 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2467 * - encoding: Set by user.
2468 * - decoding: unused.
2470 float rc_min_vbv_overflow_use;
2473 * Number of bits which should be loaded into the rc buffer before decoding starts.
2474 * - encoding: Set by user.
2475 * - decoding: unused
2477 int rc_initial_buffer_occupancy;
2479 #define FF_CODER_TYPE_VLC 0
2480 #define FF_CODER_TYPE_AC 1
2481 #define FF_CODER_TYPE_RAW 2
2482 #define FF_CODER_TYPE_RLE 3
2483 #define FF_CODER_TYPE_DEFLATE 4
2486 * - encoding: Set by user.
2487 * - decoding: unused
2493 * - encoding: Set by user.
2494 * - decoding: unused
2499 * minimum Lagrange multipler
2500 * - encoding: Set by user.
2501 * - decoding: unused
2506 * maximum Lagrange multipler
2507 * - encoding: Set by user.
2508 * - decoding: unused
2513 * frame skip threshold
2514 * - encoding: Set by user.
2515 * - decoding: unused
2517 int frame_skip_threshold;
2521 * - encoding: Set by user.
2522 * - decoding: unused
2524 int frame_skip_factor;
2527 * frame skip exponent
2528 * - encoding: Set by user.
2529 * - decoding: unused
2534 * frame skip comparison function
2535 * - encoding: Set by user.
2536 * - decoding: unused
2541 * trellis RD quantization
2542 * - encoding: Set by user.
2543 * - decoding: unused
2548 * - encoding: Set by user.
2549 * - decoding: unused
2551 int min_prediction_order;
2554 * - encoding: Set by user.
2555 * - decoding: unused
2557 int max_prediction_order;
2560 * GOP timecode frame start number
2561 * - encoding: Set by user, in non drop frame format
2562 * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
2564 int64_t timecode_frame_start;
2566 /* The RTP callback: This function is called */
2567 /* every time the encoder has a packet to send. */
2568 /* It depends on the encoder if the data starts */
2569 /* with a Start Code (it should). H.263 does. */
2570 /* mb_nb contains the number of macroblocks */
2571 /* encoded in the RTP payload. */
2572 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2574 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2575 /* do its best to deliver a chunk with size */
2576 /* below rtp_payload_size, the chunk will start */
2577 /* with a start code on some codecs like H.263. */
2578 /* This doesn't take account of any particular */
2579 /* headers inside the transmitted RTP payload. */
2581 /* statistics, used for 2-pass encoding */
2592 * number of bits used for the previously encoded frame
2593 * - encoding: Set by libavcodec.
2594 * - decoding: unused
2599 * pass1 encoding statistics output buffer
2600 * - encoding: Set by libavcodec.
2601 * - decoding: unused
2606 * pass2 encoding statistics input buffer
2607 * Concatenated stuff from stats_out of pass1 should be placed here.
2608 * - encoding: Allocated/set/freed by user.
2609 * - decoding: unused
2614 * Work around bugs in encoders which sometimes cannot be detected automatically.
2615 * - encoding: Set by user
2616 * - decoding: Set by user
2618 int workaround_bugs;
2619 #define FF_BUG_AUTODETECT 1 ///< autodetection
2620 #define FF_BUG_OLD_MSMPEG4 2
2621 #define FF_BUG_XVID_ILACE 4
2622 #define FF_BUG_UMP4 8
2623 #define FF_BUG_NO_PADDING 16
2624 #define FF_BUG_AMV 32
2625 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2626 #define FF_BUG_QPEL_CHROMA 64
2627 #define FF_BUG_STD_QPEL 128
2628 #define FF_BUG_QPEL_CHROMA2 256
2629 #define FF_BUG_DIRECT_BLOCKSIZE 512
2630 #define FF_BUG_EDGE 1024
2631 #define FF_BUG_HPEL_CHROMA 2048
2632 #define FF_BUG_DC_CLIP 4096
2633 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2634 #define FF_BUG_TRUNCATED 16384
2637 * strictly follow the standard (MPEG4, ...).
2638 * - encoding: Set by user.
2639 * - decoding: Set by user.
2640 * Setting this to STRICT or higher means the encoder and decoder will
2641 * generally do stupid things, whereas setting it to unofficial or lower
2642 * will mean the encoder might produce output that is not supported by all
2643 * spec-compliant decoders. Decoders don't differentiate between normal,
2644 * unofficial and experimental (that is, they always try to decode things
2645 * when they can) unless they are explicitly asked to behave stupidly
2646 * (=strictly conform to the specs)
2648 int strict_std_compliance;
2649 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2650 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2651 #define FF_COMPLIANCE_NORMAL 0
2652 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2653 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2656 * error concealment flags
2657 * - encoding: unused
2658 * - decoding: Set by user.
2660 int error_concealment;
2661 #define FF_EC_GUESS_MVS 1
2662 #define FF_EC_DEBLOCK 2
2666 * - encoding: Set by user.
2667 * - decoding: Set by user.
2670 #define FF_DEBUG_PICT_INFO 1
2671 #define FF_DEBUG_RC 2
2672 #define FF_DEBUG_BITSTREAM 4
2673 #define FF_DEBUG_MB_TYPE 8
2674 #define FF_DEBUG_QP 16
2675 #define FF_DEBUG_MV 32
2676 #define FF_DEBUG_DCT_COEFF 0x00000040
2677 #define FF_DEBUG_SKIP 0x00000080
2678 #define FF_DEBUG_STARTCODE 0x00000100
2679 #define FF_DEBUG_PTS 0x00000200
2680 #define FF_DEBUG_ER 0x00000400
2681 #define FF_DEBUG_MMCO 0x00000800
2682 #define FF_DEBUG_BUGS 0x00001000
2683 #define FF_DEBUG_VIS_QP 0x00002000
2684 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2685 #define FF_DEBUG_BUFFERS 0x00008000
2686 #define FF_DEBUG_THREADS 0x00010000
2690 * - encoding: Set by user.
2691 * - decoding: Set by user.
2694 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2695 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2696 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2699 * Error recognition; may misdetect some more or less valid parts as errors.
2700 * - encoding: unused
2701 * - decoding: Set by user.
2703 int err_recognition;
2704 #define AV_EF_CRCCHECK (1<<0)
2705 #define AV_EF_BITSTREAM (1<<1)
2706 #define AV_EF_BUFFER (1<<2)
2707 #define AV_EF_EXPLODE (1<<3)
2709 #define AV_EF_CAREFUL (1<<16)
2710 #define AV_EF_COMPLIANT (1<<17)
2711 #define AV_EF_AGGRESSIVE (1<<18)
2715 * opaque 64bit number (generally a PTS) that will be reordered and
2716 * output in AVFrame.reordered_opaque
2717 * @deprecated in favor of pkt_pts
2718 * - encoding: unused
2719 * - decoding: Set by user.
2721 int64_t reordered_opaque;
2724 * Hardware accelerator in use
2725 * - encoding: unused.
2726 * - decoding: Set by libavcodec
2728 struct AVHWAccel *hwaccel;
2731 * Hardware accelerator context.
2732 * For some hardware accelerators, a global context needs to be
2733 * provided by the user. In that case, this holds display-dependent
2734 * data FFmpeg cannot instantiate itself. Please refer to the
2735 * FFmpeg HW accelerator documentation to know how to fill this
2736 * is. e.g. for VA API, this is a struct vaapi_context.
2737 * - encoding: unused
2738 * - decoding: Set by user
2740 void *hwaccel_context;
2744 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2745 * - decoding: unused
2747 uint64_t error[AV_NUM_DATA_POINTERS];
2750 * DCT algorithm, see FF_DCT_* below
2751 * - encoding: Set by user.
2752 * - decoding: unused
2755 #define FF_DCT_AUTO 0
2756 #define FF_DCT_FASTINT 1
2757 #define FF_DCT_INT 2
2758 #define FF_DCT_MMX 3
2759 #define FF_DCT_ALTIVEC 5
2760 #define FF_DCT_FAAN 6
2763 * IDCT algorithm, see FF_IDCT_* below.
2764 * - encoding: Set by user.
2765 * - decoding: Set by user.
2768 #define FF_IDCT_AUTO 0
2769 #define FF_IDCT_INT 1
2770 #define FF_IDCT_SIMPLE 2
2771 #define FF_IDCT_SIMPLEMMX 3
2772 #define FF_IDCT_LIBMPEG2MMX 4
2773 #define FF_IDCT_MMI 5
2774 #define FF_IDCT_ARM 7
2775 #define FF_IDCT_ALTIVEC 8
2776 #define FF_IDCT_SH4 9
2777 #define FF_IDCT_SIMPLEARM 10
2778 #define FF_IDCT_H264 11
2779 #define FF_IDCT_VP3 12
2780 #define FF_IDCT_IPP 13
2781 #define FF_IDCT_XVIDMMX 14
2782 #define FF_IDCT_CAVS 15
2783 #define FF_IDCT_SIMPLEARMV5TE 16
2784 #define FF_IDCT_SIMPLEARMV6 17
2785 #define FF_IDCT_SIMPLEVIS 18
2786 #define FF_IDCT_WMV2 19
2787 #define FF_IDCT_FAAN 20
2788 #define FF_IDCT_EA 21
2789 #define FF_IDCT_SIMPLENEON 22
2790 #define FF_IDCT_SIMPLEALPHA 23
2791 #define FF_IDCT_BINK 24
2796 * @deprecated use av_set_cpu_flags_mask() instead.
2798 attribute_deprecated unsigned dsp_mask;
2802 * bits per sample/pixel from the demuxer (needed for huffyuv).
2803 * - encoding: Set by libavcodec.
2804 * - decoding: Set by user.
2806 int bits_per_coded_sample;
2809 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2810 * - encoding: set by user.
2811 * - decoding: set by libavcodec.
2813 int bits_per_raw_sample;
2816 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2817 * - encoding: unused
2818 * - decoding: Set by user.
2823 * the picture in the bitstream
2824 * - encoding: Set by libavcodec.
2825 * - decoding: Set by libavcodec.
2827 AVFrame *coded_frame;
2831 * is used to decide how many independent tasks should be passed to execute()
2832 * - encoding: Set by user.
2833 * - decoding: Set by user.
2838 * Which multithreading methods to use.
2839 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2840 * so clients which cannot provide future frames should not use it.
2842 * - encoding: Set by user, otherwise the default is used.
2843 * - decoding: Set by user, otherwise the default is used.
2846 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2847 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2850 * Which multithreading methods are in use by the codec.
2851 * - encoding: Set by libavcodec.
2852 * - decoding: Set by libavcodec.
2854 int active_thread_type;
2857 * Set by the client if its custom get_buffer() callback can be called
2858 * synchronously from another thread, which allows faster multithreaded decoding.
2859 * draw_horiz_band() will be called from other threads regardless of this setting.
2860 * Ignored if the default get_buffer() is used.
2861 * - encoding: Set by user.
2862 * - decoding: Set by user.
2864 int thread_safe_callbacks;
2867 * The codec may call this to execute several independent things.
2868 * It will return only after finishing all tasks.
2869 * The user may replace this with some multithreaded implementation,
2870 * the default implementation will execute the parts serially.
2871 * @param count the number of things to execute
2872 * - encoding: Set by libavcodec, user can override.
2873 * - decoding: Set by libavcodec, user can override.
2875 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2878 * The codec may call this to execute several independent things.
2879 * It will return only after finishing all tasks.
2880 * The user may replace this with some multithreaded implementation,
2881 * the default implementation will execute the parts serially.
2882 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2883 * @param c context passed also to func
2884 * @param count the number of things to execute
2885 * @param arg2 argument passed unchanged to func
2886 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2887 * @param func function that will be called count times, with jobnr from 0 to count-1.
2888 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2889 * two instances of func executing at the same time will have the same threadnr.
2890 * @return always 0 currently, but code should handle a future improvement where when any call to func
2891 * returns < 0 no further calls to func may be done and < 0 is returned.
2892 * - encoding: Set by libavcodec, user can override.
2893 * - decoding: Set by libavcodec, user can override.
2895 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2899 * Can be used by execute() to store some per AVCodecContext stuff.
2900 * - encoding: set by execute()
2901 * - decoding: set by execute()
2903 void *thread_opaque;
2906 * noise vs. sse weight for the nsse comparsion function
2907 * - encoding: Set by user.
2908 * - decoding: unused
2914 * - encoding: Set by user.
2915 * - decoding: Set by libavcodec.
2918 #define FF_PROFILE_UNKNOWN -99
2919 #define FF_PROFILE_RESERVED -100
2921 #define FF_PROFILE_AAC_MAIN 0
2922 #define FF_PROFILE_AAC_LOW 1
2923 #define FF_PROFILE_AAC_SSR 2
2924 #define FF_PROFILE_AAC_LTP 3
2925 #define FF_PROFILE_AAC_HE 4
2926 #define FF_PROFILE_AAC_HE_V2 28
2927 #define FF_PROFILE_AAC_LD 22
2928 #define FF_PROFILE_AAC_ELD 38
2930 #define FF_PROFILE_DTS 20
2931 #define FF_PROFILE_DTS_ES 30
2932 #define FF_PROFILE_DTS_96_24 40
2933 #define FF_PROFILE_DTS_HD_HRA 50
2934 #define FF_PROFILE_DTS_HD_MA 60
2936 #define FF_PROFILE_MPEG2_422 0
2937 #define FF_PROFILE_MPEG2_HIGH 1
2938 #define FF_PROFILE_MPEG2_SS 2
2939 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2940 #define FF_PROFILE_MPEG2_MAIN 4
2941 #define FF_PROFILE_MPEG2_SIMPLE 5
2943 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2944 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2946 #define FF_PROFILE_H264_BASELINE 66
2947 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2948 #define FF_PROFILE_H264_MAIN 77
2949 #define FF_PROFILE_H264_EXTENDED 88
2950 #define FF_PROFILE_H264_HIGH 100
2951 #define FF_PROFILE_H264_HIGH_10 110
2952 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2953 #define FF_PROFILE_H264_HIGH_422 122
2954 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2955 #define FF_PROFILE_H264_HIGH_444 144
2956 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2957 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2958 #define FF_PROFILE_H264_CAVLC_444 44
2960 #define FF_PROFILE_VC1_SIMPLE 0
2961 #define FF_PROFILE_VC1_MAIN 1
2962 #define FF_PROFILE_VC1_COMPLEX 2
2963 #define FF_PROFILE_VC1_ADVANCED 3
2965 #define FF_PROFILE_MPEG4_SIMPLE 0
2966 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2967 #define FF_PROFILE_MPEG4_CORE 2
2968 #define FF_PROFILE_MPEG4_MAIN 3
2969 #define FF_PROFILE_MPEG4_N_BIT 4
2970 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2971 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2972 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2973 #define FF_PROFILE_MPEG4_HYBRID 8
2974 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2975 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2976 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2977 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2978 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2979 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2980 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2984 * - encoding: Set by user.
2985 * - decoding: Set by libavcodec.
2988 #define FF_LEVEL_UNKNOWN -99
2992 * - encoding: unused
2993 * - decoding: Set by user.
2995 enum AVDiscard skip_loop_filter;
2999 * - encoding: unused
3000 * - decoding: Set by user.
3002 enum AVDiscard skip_idct;
3006 * - encoding: unused
3007 * - decoding: Set by user.
3009 enum AVDiscard skip_frame;
3012 * Header containing style information for text subtitles.
3013 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3014 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3015 * the Format line following. It shouldn't include any Dialogue line.
3016 * - encoding: Set/allocated/freed by user (before avcodec_open2())
3017 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3019 uint8_t *subtitle_header;
3020 int subtitle_header_size;
3023 * Simulates errors in the bitstream to test error concealment.
3024 * - encoding: Set by user.
3025 * - decoding: unused
3030 * Current packet as passed into the decoder, to avoid having
3031 * to pass the packet into every function. Currently only valid
3032 * inside lavc and get/release_buffer callbacks.
3033 * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
3034 * - encoding: unused
3039 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3040 * Used for compliant TS muxing.
3041 * - encoding: Set by libavcodec.
3042 * - decoding: unused.
3047 * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
3048 * Code outside libavcodec should access this field using:
3049 * avcodec_set_pkt_timebase(avctx)
3050 * - encoding unused.
3051 * - decodimg set by user
3053 AVRational pkt_timebase;
3057 * Code outside libavcodec should access this field using:
3058 * avcodec_get_codec_descriptior(avctx)
3059 * - encoding: unused.
3060 * - decoding: set by libavcodec.
3062 const AVCodecDescriptor *codec_descriptor;
3065 * Current statistics for PTS correction.
3066 * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3067 * - encoding: unused
3069 int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
3070 int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
3071 int64_t pts_correction_last_pts; /// PTS of the last frame
3072 int64_t pts_correction_last_dts; /// DTS of the last frame
3075 AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
3076 void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val);
3078 const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
3079 void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
3084 typedef struct AVProfile {
3086 const char *name; ///< short name for the profile
3089 typedef struct AVCodecDefault AVCodecDefault;
3094 typedef struct AVCodec {
3096 * Name of the codec implementation.
3097 * The name is globally unique among encoders and among decoders (but an
3098 * encoder and a decoder can share the same name).
3099 * This is the primary way to find a codec from the user perspective.
3103 * Descriptive name for the codec, meant to be more human readable than name.
3104 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3106 const char *long_name;
3107 enum AVMediaType type;
3110 * Codec capabilities.
3114 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3115 const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3116 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3117 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3118 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3119 uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
3120 const AVClass *priv_class; ///< AVClass for the private context
3121 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3123 /*****************************************************************
3124 * No fields below this line are part of the public API. They
3125 * may not be used outside of libavcodec and can be changed and
3127 * New public fields should be added right above.
3128 *****************************************************************
3131 struct AVCodec *next;
3133 * @name Frame-level threading support functions
3137 * If defined, called on thread contexts when they are created.
3138 * If the codec allocates writable tables in init(), re-allocate them here.
3139 * priv_data will be set to a copy of the original.
3141 int (*init_thread_copy)(AVCodecContext *);
3143 * Copy necessary context variables from a previous thread context to the current one.
3144 * If not defined, the next thread will start automatically; otherwise, the codec
3145 * must call ff_thread_finish_setup().
3147 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3149 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
3153 * Private codec-specific defaults.
3155 const AVCodecDefault *defaults;
3158 * Initialize codec static data, called from avcodec_register().
3160 void (*init_static_data)(struct AVCodec *codec);
3162 int (*init)(AVCodecContext *);
3163 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
3165 * Encode data to an AVPacket.
3167 * @param avctx codec context
3168 * @param avpkt output AVPacket (may contain a user-provided buffer)
3169 * @param[in] frame AVFrame containing the raw data to be encoded
3170 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3171 * non-empty packet was returned in avpkt.
3172 * @return 0 on success, negative error code on failure
3174 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3175 int *got_packet_ptr);
3176 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3177 int (*close)(AVCodecContext *);
3180 * Will be called when seeking
3182 void (*flush)(AVCodecContext *);
3188 typedef struct AVHWAccel {
3190 * Name of the hardware accelerated codec.
3191 * The name is globally unique among encoders and among decoders (but an
3192 * encoder and a decoder can share the same name).
3197 * Type of codec implemented by the hardware accelerator.
3199 * See AVMEDIA_TYPE_xxx
3201 enum AVMediaType type;
3204 * Codec implemented by the hardware accelerator.
3206 * See AV_CODEC_ID_xxx
3211 * Supported pixel format.
3213 * Only hardware accelerated formats are supported here.
3215 enum PixelFormat pix_fmt;
3218 * Hardware accelerated codec capabilities.
3219 * see FF_HWACCEL_CODEC_CAP_*
3223 struct AVHWAccel *next;
3226 * Called at the beginning of each frame or field picture.
3228 * Meaningful frame information (codec specific) is guaranteed to
3229 * be parsed at this point. This function is mandatory.
3231 * Note that buf can be NULL along with buf_size set to 0.
3232 * Otherwise, this means the whole frame is available at this point.
3234 * @param avctx the codec context
3235 * @param buf the frame data buffer base
3236 * @param buf_size the size of the frame in bytes
3237 * @return zero if successful, a negative value otherwise
3239 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3242 * Callback for each slice.
3244 * Meaningful slice information (codec specific) is guaranteed to
3245 * be parsed at this point. This function is mandatory.
3247 * @param avctx the codec context
3248 * @param buf the slice data buffer base
3249 * @param buf_size the size of the slice in bytes
3250 * @return zero if successful, a negative value otherwise
3252 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3255 * Called at the end of each frame or field picture.
3257 * The whole picture is parsed at this point and can now be sent
3258 * to the hardware accelerator. This function is mandatory.
3260 * @param avctx the codec context
3261 * @return zero if successful, a negative value otherwise
3263 int (*end_frame)(AVCodecContext *avctx);
3266 * Size of HW accelerator private data.
3268 * Private data is allocated with av_mallocz() before
3269 * AVCodecContext.get_buffer() and deallocated after
3270 * AVCodecContext.release_buffer().
3276 * @defgroup lavc_picture AVPicture
3278 * Functions for working with AVPicture
3283 * four components are given, that's all.
3284 * the last component is alpha
3286 typedef struct AVPicture {
3287 uint8_t *data[AV_NUM_DATA_POINTERS];
3288 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
3295 enum AVSubtitleType {
3298 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
3301 * Plain text, the text field must be set by the decoder and is
3302 * authoritative. ass and pict fields may contain approximations.
3307 * Formatted text, the ass field must be set by the decoder and is
3308 * authoritative. pict and text fields may contain approximations.
3313 typedef struct AVSubtitleRect {
3314 int x; ///< top left corner of pict, undefined when pict is not set
3315 int y; ///< top left corner of pict, undefined when pict is not set
3316 int w; ///< width of pict, undefined when pict is not set
3317 int h; ///< height of pict, undefined when pict is not set
3318 int nb_colors; ///< number of colors in pict, undefined when pict is not set
3321 * data+linesize for the bitmap of this subtitle.
3322 * can be set for text/ass as well once they where rendered
3325 enum AVSubtitleType type;
3327 char *text; ///< 0 terminated plain UTF-8 text
3330 * 0 terminated ASS/SSA compatible event line.
3331 * The presentation of this is unaffected by the other values in this
3337 * 1 indicates this subtitle is a forced subtitle.
3338 * A forced subtitle should be displayed even when subtitles are hidden.
3343 typedef struct AVSubtitle {
3344 uint16_t format; /* 0 = graphics */
3345 uint32_t start_display_time; /* relative to packet pts, in ms */
3346 uint32_t end_display_time; /* relative to packet pts, in ms */
3348 AVSubtitleRect **rects;
3349 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3353 * If c is NULL, returns the first registered codec,
3354 * if c is non-NULL, returns the next registered codec after c,
3355 * or NULL if c is the last one.
3357 AVCodec *av_codec_next(const AVCodec *c);
3360 * Return the LIBAVCODEC_VERSION_INT constant.
3362 unsigned avcodec_version(void);
3365 * Return the libavcodec build-time configuration.
3367 const char *avcodec_configuration(void);
3370 * Return the libavcodec license.
3372 const char *avcodec_license(void);
3375 * Register the codec codec and initialize libavcodec.
3377 * @warning either this function or avcodec_register_all() must be called
3378 * before any other libavcodec functions.
3380 * @see avcodec_register_all()
3382 void avcodec_register(AVCodec *codec);
3385 * Register all the codecs, parsers and bitstream filters which were enabled at
3386 * configuration time. If you do not call this function you can select exactly
3387 * which formats you want to support, by using the individual registration
3390 * @see avcodec_register
3391 * @see av_register_codec_parser
3392 * @see av_register_bitstream_filter
3394 void avcodec_register_all(void);
3397 #if FF_API_ALLOC_CONTEXT
3399 * Allocate an AVCodecContext and set its fields to default values. The
3400 * resulting struct can be deallocated by simply calling av_free().
3402 * @return An AVCodecContext filled with default values or NULL on failure.
3403 * @see avcodec_get_context_defaults
3405 * @deprecated use avcodec_alloc_context3()
3407 attribute_deprecated
3408 AVCodecContext *avcodec_alloc_context(void);
3410 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3411 * we WILL change its arguments and name a few times! */
3412 attribute_deprecated
3413 AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
3416 * Set the fields of the given AVCodecContext to default values.
3418 * @param s The AVCodecContext of which the fields should be set to default values.
3419 * @deprecated use avcodec_get_context_defaults3
3421 attribute_deprecated
3422 void avcodec_get_context_defaults(AVCodecContext *s);
3424 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3425 * we WILL change its arguments and name a few times! */
3426 attribute_deprecated
3427 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
3431 * Allocate an AVCodecContext and set its fields to default values. The
3432 * resulting struct can be deallocated by calling avcodec_close() on it followed
3435 * @param codec if non-NULL, allocate private data and initialize defaults
3436 * for the given codec. It is illegal to then call avcodec_open2()
3437 * with a different codec.
3438 * If NULL, then the codec-specific defaults won't be initialized,
3439 * which may result in suboptimal default settings (this is
3440 * important mainly for encoders, e.g. libx264).
3442 * @return An AVCodecContext filled with default values or NULL on failure.
3443 * @see avcodec_get_context_defaults
3445 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
3448 * Set the fields of the given AVCodecContext to default values corresponding
3449 * to the given codec (defaults may be codec-dependent).
3451 * Do not call this function if a non-NULL codec has been passed
3452 * to avcodec_alloc_context3() that allocated this AVCodecContext.
3453 * If codec is non-NULL, it is illegal to call avcodec_open2() with a
3454 * different codec on this AVCodecContext.
3456 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
3459 * Get the AVClass for AVCodecContext. It can be used in combination with
3460 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3462 * @see av_opt_find().
3464 const AVClass *avcodec_get_class(void);
3467 * Get the AVClass for AVFrame. It can be used in combination with
3468 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3470 * @see av_opt_find().
3472 const AVClass *avcodec_get_frame_class(void);
3475 * Get the AVClass for AVSubtitleRect. It can be used in combination with
3476 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3478 * @see av_opt_find().
3480 const AVClass *avcodec_get_subtitle_rect_class(void);
3483 * Copy the settings of the source AVCodecContext into the destination
3484 * AVCodecContext. The resulting destination codec context will be
3485 * unopened, i.e. you are required to call avcodec_open2() before you
3486 * can use this AVCodecContext to decode/encode video/audio data.
3488 * @param dest target codec context, should be initialized with
3489 * avcodec_alloc_context3(), but otherwise uninitialized
3490 * @param src source codec context
3491 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3493 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3496 * Allocate an AVFrame and set its fields to default values. The resulting
3497 * struct can be deallocated by simply calling av_free().
3499 * @return An AVFrame filled with default values or NULL on failure.
3500 * @see avcodec_get_frame_defaults
3502 AVFrame *avcodec_alloc_frame(void);
3505 * Set the fields of the given AVFrame to default values.
3507 * @param pic The AVFrame of which the fields should be set to default values.
3509 void avcodec_get_frame_defaults(AVFrame *pic);
3511 #if FF_API_AVCODEC_OPEN
3513 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3514 * function the context has to be allocated.
3516 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3517 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3518 * retrieving a codec.
3520 * @warning This function is not thread safe!
3523 * avcodec_register_all();
3524 * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3528 * context = avcodec_alloc_context3(codec);
3530 * if (avcodec_open(context, codec) < 0)
3534 * @param avctx The context which will be set up to use the given codec.
3535 * @param codec The codec to use within the context.
3536 * @return zero on success, a negative value on error
3537 * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
3539 * @deprecated use avcodec_open2
3541 attribute_deprecated
3542 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
3546 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3547 * function the context has to be allocated with avcodec_alloc_context3().
3549 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3550 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3551 * retrieving a codec.
3553 * @warning This function is not thread safe!
3556 * avcodec_register_all();
3557 * av_dict_set(&opts, "b", "2.5M", 0);
3558 * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3562 * context = avcodec_alloc_context3(codec);
3564 * if (avcodec_open2(context, codec, opts) < 0)
3568 * @param avctx The context to initialize.
3569 * @param codec The codec to open this context for. If a non-NULL codec has been
3570 * previously passed to avcodec_alloc_context3() or
3571 * avcodec_get_context_defaults3() for this context, then this
3572 * parameter MUST be either NULL or equal to the previously passed
3574 * @param options A dictionary filled with AVCodecContext and codec-private options.
3575 * On return this object will be filled with options that were not found.
3577 * @return zero on success, a negative value on error
3578 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3579 * av_dict_set(), av_opt_find().
3581 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3584 * Close a given AVCodecContext and free all the data associated with it
3585 * (but not the AVCodecContext itself).
3587 * Calling this function on an AVCodecContext that hasn't been opened will free
3588 * the codec-specific data allocated in avcodec_alloc_context3() /
3589 * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
3592 int avcodec_close(AVCodecContext *avctx);
3595 * Free all allocated data in the given subtitle struct.
3597 * @param sub AVSubtitle to free.
3599 void avsubtitle_free(AVSubtitle *sub);
3606 * @addtogroup lavc_packet
3611 * @deprecated use NULL instead
3613 attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
3616 * Default packet destructor.
3618 void av_destruct_packet(AVPacket *pkt);
3621 * Initialize optional fields of a packet with default values.
3623 * Note, this does not touch the data and size members, which have to be
3624 * initialized separately.
3628 void av_init_packet(AVPacket *pkt);
3631 * Allocate the payload of a packet and initialize its fields with
3635 * @param size wanted payload size
3636 * @return 0 if OK, AVERROR_xxx otherwise
3638 int av_new_packet(AVPacket *pkt, int size);
3641 * Reduce packet size, correctly zeroing padding
3644 * @param size new size
3646 void av_shrink_packet(AVPacket *pkt, int size);
3649 * Increase packet size, correctly zeroing padding
3652 * @param grow_by number of bytes by which to increase the size of the packet
3654 int av_grow_packet(AVPacket *pkt, int grow_by);
3657 * @warning This is a hack - the packet memory allocation stuff is broken. The
3658 * packet is allocated if it was not really allocated.
3660 int av_dup_packet(AVPacket *pkt);
3665 * @param pkt packet to free
3667 void av_free_packet(AVPacket *pkt);
3670 * Allocate new information of a packet.
3673 * @param type side information type
3674 * @param size side information size
3675 * @return pointer to fresh allocated data or NULL otherwise
3677 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3681 * Shrink the already allocated side data buffer
3684 * @param type side information type
3685 * @param size new side information size
3686 * @return 0 on success, < 0 on failure
3688 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3692 * Get side information from packet.
3695 * @param type desired side information type
3696 * @param size pointer for side information size to store (optional)
3697 * @return pointer to data if present or NULL otherwise
3699 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3702 int av_packet_merge_side_data(AVPacket *pkt);
3704 int av_packet_split_side_data(AVPacket *pkt);
3712 * @addtogroup lavc_decoding
3717 * Find a registered decoder with a matching codec ID.
3719 * @param id AVCodecID of the requested decoder
3720 * @return A decoder if one was found, NULL otherwise.
3722 AVCodec *avcodec_find_decoder(enum AVCodecID id);
3725 * Find a registered decoder with the specified name.
3727 * @param name name of the requested decoder
3728 * @return A decoder if one was found, NULL otherwise.
3730 AVCodec *avcodec_find_decoder_by_name(const char *name);
3732 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3733 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3734 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3737 * Return the amount of padding in pixels which the get_buffer callback must
3738 * provide around the edge of the image for codecs which do not have the
3739 * CODEC_FLAG_EMU_EDGE flag.
3741 * @return Required padding in pixels.
3743 unsigned avcodec_get_edge_width(void);
3746 * Modify width and height values so that they will result in a memory
3747 * buffer that is acceptable for the codec if you do not use any horizontal
3750 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3751 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3752 * according to avcodec_get_edge_width() before.
3754 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3757 * Modify width and height values so that they will result in a memory
3758 * buffer that is acceptable for the codec if you also ensure that all
3759 * line sizes are a multiple of the respective linesize_align[i].
3761 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3762 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3763 * according to avcodec_get_edge_width() before.
3765 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3766 int linesize_align[AV_NUM_DATA_POINTERS]);
3768 #if FF_API_OLD_DECODE_AUDIO
3770 * Wrapper function which calls avcodec_decode_audio4.
3772 * @deprecated Use avcodec_decode_audio4 instead.
3774 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3775 * Some decoders may support multiple frames in a single AVPacket, such
3776 * decoders would then just decode the first frame. In this case,
3777 * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3778 * the remaining data in order to decode the second frame etc.
3780 * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3781 * decompressed frame size in bytes.
3783 * @warning You must set frame_size_ptr to the allocated size of the
3784 * output buffer before calling avcodec_decode_audio3().
3786 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3787 * the actual read bytes because some optimized bitstream readers read 32 or 64
3788 * bits at once and could read over the end.
3790 * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3791 * no overreading happens for damaged MPEG streams.
3793 * @warning You must not provide a custom get_buffer() when using
3794 * avcodec_decode_audio3(). Doing so will override it with
3795 * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
3796 * which does allow the application to provide a custom get_buffer().
3798 * @note You might have to align the input buffer avpkt->data and output buffer
3799 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3800 * necessary at all, on others it won't work at all if not aligned and on others
3801 * it will work but it will have an impact on performance.
3803 * In practice, avpkt->data should have 4 byte alignment at minimum and
3804 * samples should be 16 byte aligned unless the CPU doesn't need it
3805 * (AltiVec and SSE do).
3807 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3808 * between input and output, these need to be fed with avpkt->data=NULL,
3809 * avpkt->size=0 at the end to return the remaining frames.
3811 * @param avctx the codec context
3812 * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3813 * If the sample format is planar, each channel plane will
3814 * be the same size, with no padding between channels.
3815 * @param[in,out] frame_size_ptr the output buffer size in bytes
3816 * @param[in] avpkt The input AVPacket containing the input buffer.
3817 * You can create such packet with av_init_packet() and by then setting
3818 * data and size, some decoders might in addition need other fields.
3819 * All decoders are designed to use the least fields possible though.
3820 * @return On error a negative value is returned, otherwise the number of bytes
3821 * used or zero if no frame data was decompressed (used) from the input AVPacket.
3823 attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3824 int *frame_size_ptr,
3829 * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3831 * Some decoders may support multiple frames in a single AVPacket. Such
3832 * decoders would then just decode the first frame. In this case,
3833 * avcodec_decode_audio4 has to be called again with an AVPacket containing
3834 * the remaining data in order to decode the second frame, etc...
3835 * Even if no frames are returned, the packet needs to be fed to the decoder
3836 * with remaining data until it is completely consumed or an error occurs.
3838 * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3839 * larger than the actual read bytes because some optimized bitstream
3840 * readers read 32 or 64 bits at once and could read over the end.
3842 * @note You might have to align the input buffer. The alignment requirements
3843 * depend on the CPU and the decoder.
3845 * @param avctx the codec context
3846 * @param[out] frame The AVFrame in which to store decoded audio samples.
3847 * Decoders request a buffer of a particular size by setting
3848 * AVFrame.nb_samples prior to calling get_buffer(). The
3849 * decoder may, however, only utilize part of the buffer by
3850 * setting AVFrame.nb_samples to a smaller value in the
3852 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3854 * @param[in] avpkt The input AVPacket containing the input buffer.
3855 * At least avpkt->data and avpkt->size should be set. Some
3856 * decoders might also require additional fields to be set.
3857 * @return A negative error code is returned if an error occurred during
3858 * decoding, otherwise the number of bytes consumed from the input
3859 * AVPacket is returned.
3861 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3862 int *got_frame_ptr, const AVPacket *avpkt);
3865 * Decode the video frame of size avpkt->size from avpkt->data into picture.
3866 * Some decoders may support multiple frames in a single AVPacket, such
3867 * decoders would then just decode the first frame.
3869 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3870 * the actual read bytes because some optimized bitstream readers read 32 or 64
3871 * bits at once and could read over the end.
3873 * @warning The end of the input buffer buf should be set to 0 to ensure that
3874 * no overreading happens for damaged MPEG streams.
3876 * @note You might have to align the input buffer avpkt->data.
3877 * The alignment requirements depend on the CPU: on some CPUs it isn't
3878 * necessary at all, on others it won't work at all if not aligned and on others
3879 * it will work but it will have an impact on performance.
3881 * In practice, avpkt->data should have 4 byte alignment at minimum.
3883 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3884 * between input and output, these need to be fed with avpkt->data=NULL,
3885 * avpkt->size=0 at the end to return the remaining frames.
3887 * @param avctx the codec context
3888 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3889 * Use avcodec_alloc_frame to get an AVFrame, the codec will
3890 * allocate memory for the actual bitmap.
3891 * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
3892 * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
3893 * decodes and the decoder tells the user once it does not need the data anymore,
3894 * the user app can at this point free/reuse/keep the memory as it sees fit.
3896 * @param[in] avpkt The input AVpacket containing the input buffer.
3897 * You can create such packet with av_init_packet() and by then setting
3898 * data and size, some decoders might in addition need other fields like
3899 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
3901 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3902 * @return On error a negative value is returned, otherwise the number of bytes
3903 * used or zero if no frame could be decompressed.
3905 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
3906 int *got_picture_ptr,
3907 const AVPacket *avpkt);
3910 * Decode a subtitle message.
3911 * Return a negative value on error, otherwise return the number of bytes used.
3912 * If no subtitle could be decompressed, got_sub_ptr is zero.
3913 * Otherwise, the subtitle is stored in *sub.
3914 * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
3915 * simplicity, because the performance difference is expect to be negligible
3916 * and reusing a get_buffer written for video codecs would probably perform badly
3917 * due to a potentially very different allocation pattern.
3919 * @param avctx the codec context
3920 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3921 freed with avsubtitle_free if *got_sub_ptr is set.
3922 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
3923 * @param[in] avpkt The input AVPacket containing the input buffer.
3925 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
3930 * @defgroup lavc_parsing Frame parsing
3934 typedef struct AVCodecParserContext {
3936 struct AVCodecParser *parser;
3937 int64_t frame_offset; /* offset of the current frame */
3938 int64_t cur_offset; /* current offset
3939 (incremented by each av_parser_parse()) */
3940 int64_t next_frame_offset; /* offset of the next frame */
3942 int pict_type; /* XXX: Put it back in AVCodecContext. */
3944 * This field is used for proper frame duration computation in lavf.
3945 * It signals, how much longer the frame duration of the current frame
3946 * is compared to normal frame duration.
3948 * frame_duration = (1 + repeat_pict) * time_base
3950 * It is used by codecs like H.264 to display telecined material.
3952 int repeat_pict; /* XXX: Put it back in AVCodecContext. */
3953 int64_t pts; /* pts of the current frame */
3954 int64_t dts; /* dts of the current frame */
3959 int fetch_timestamp;
3961 #define AV_PARSER_PTS_NB 4
3962 int cur_frame_start_index;
3963 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
3964 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
3965 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
3968 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
3969 #define PARSER_FLAG_ONCE 0x0002
3970 /// Set if the parser has a valid file offset
3971 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
3972 #define PARSER_FLAG_USE_CODEC_TS 0x1000
3974 int64_t offset; ///< byte offset from starting packet start
3975 int64_t cur_frame_end[AV_PARSER_PTS_NB];
3978 * Set by parser to 1 for key frames and 0 for non-key frames.
3979 * It is initialized to -1, so if the parser doesn't set this flag,
3980 * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
3986 * Time difference in stream time base units from the pts of this
3987 * packet to the point at which the output from the decoder has converged
3988 * independent from the availability of previous frames. That is, the
3989 * frames are virtually identical no matter if decoding started from
3990 * the very first frame or from this keyframe.
3991 * Is AV_NOPTS_VALUE if unknown.
3992 * This field is not the display duration of the current frame.
3993 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
3996 * The purpose of this field is to allow seeking in streams that have no
3997 * keyframes in the conventional sense. It corresponds to the
3998 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
3999 * essential for some types of subtitle streams to ensure that all
4000 * subtitles are correctly displayed after seeking.
4002 int64_t convergence_duration;
4004 // Timestamp generation support:
4006 * Synchronization point for start of timestamp generation.
4008 * Set to >0 for sync point, 0 for no sync point and <0 for undefined
4011 * For example, this corresponds to presence of H.264 buffering period
4017 * Offset of the current timestamp against last timestamp sync point in
4018 * units of AVCodecContext.time_base.
4020 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4021 * contain a valid timestamp offset.
4023 * Note that the timestamp of sync point has usually a nonzero
4024 * dts_ref_dts_delta, which refers to the previous sync point. Offset of
4025 * the next frame after timestamp sync point will be usually 1.
4027 * For example, this corresponds to H.264 cpb_removal_delay.
4029 int dts_ref_dts_delta;
4032 * Presentation delay of current frame in units of AVCodecContext.time_base.
4034 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4035 * contain valid non-negative timestamp delta (presentation time of a frame
4036 * must not lie in the past).
4038 * This delay represents the difference between decoding and presentation
4039 * time of the frame.
4041 * For example, this corresponds to H.264 dpb_output_delay.
4046 * Position of the packet in file.
4048 * Analogous to cur_frame_pts/dts
4050 int64_t cur_frame_pos[AV_PARSER_PTS_NB];
4053 * Byte position of currently parsed frame in stream.
4058 * Previous frame byte position.
4063 * Duration of the current frame.
4064 * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4065 * For all other types, this is in units of AVCodecContext.time_base.
4068 } AVCodecParserContext;
4070 typedef struct AVCodecParser {
4071 int codec_ids[5]; /* several codec IDs are permitted */
4073 int (*parser_init)(AVCodecParserContext *s);
4074 int (*parser_parse)(AVCodecParserContext *s,
4075 AVCodecContext *avctx,
4076 const uint8_t **poutbuf, int *poutbuf_size,
4077 const uint8_t *buf, int buf_size);
4078 void (*parser_close)(AVCodecParserContext *s);
4079 int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
4080 struct AVCodecParser *next;
4083 AVCodecParser *av_parser_next(AVCodecParser *c);
4085 void av_register_codec_parser(AVCodecParser *parser);
4086 AVCodecParserContext *av_parser_init(int codec_id);
4091 * @param s parser context.
4092 * @param avctx codec context.
4093 * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
4094 * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
4095 * @param buf input buffer.
4096 * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
4097 * @param pts input presentation timestamp.
4098 * @param dts input decoding timestamp.
4099 * @param pos input byte position in stream.
4100 * @return the number of bytes of the input bitstream used.
4105 * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
4112 * decode_frame(data, size);
4116 int av_parser_parse2(AVCodecParserContext *s,
4117 AVCodecContext *avctx,
4118 uint8_t **poutbuf, int *poutbuf_size,
4119 const uint8_t *buf, int buf_size,
4120 int64_t pts, int64_t dts,
4123 int av_parser_change(AVCodecParserContext *s,
4124 AVCodecContext *avctx,
4125 uint8_t **poutbuf, int *poutbuf_size,
4126 const uint8_t *buf, int buf_size, int keyframe);
4127 void av_parser_close(AVCodecParserContext *s);
4135 * @addtogroup lavc_encoding
4140 * Find a registered encoder with a matching codec ID.
4142 * @param id AVCodecID of the requested encoder
4143 * @return An encoder if one was found, NULL otherwise.
4145 AVCodec *avcodec_find_encoder(enum AVCodecID id);
4148 * Find a registered encoder with the specified name.
4150 * @param name name of the requested encoder
4151 * @return An encoder if one was found, NULL otherwise.
4153 AVCodec *avcodec_find_encoder_by_name(const char *name);
4155 #if FF_API_OLD_ENCODE_AUDIO
4157 * Encode an audio frame from samples into buf.
4159 * @deprecated Use avcodec_encode_audio2 instead.
4161 * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
4162 * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
4163 * will know how much space is needed because it depends on the value passed
4164 * in buf_size as described below. In that case a lower value can be used.
4166 * @param avctx the codec context
4167 * @param[out] buf the output buffer
4168 * @param[in] buf_size the output buffer size
4169 * @param[in] samples the input buffer containing the samples
4170 * The number of samples read from this buffer is frame_size*channels,
4171 * both of which are defined in avctx.
4172 * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
4173 * samples read from samples is equal to:
4174 * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
4175 * This also implies that av_get_bits_per_sample() must not return 0 for these
4177 * @return On error a negative value is returned, on success zero or the number
4178 * of bytes used to encode the data read from the input buffer.
4180 int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
4181 uint8_t *buf, int buf_size,
4182 const short *samples);
4186 * Encode a frame of audio.
4188 * Takes input samples from frame and writes the next output packet, if
4189 * available, to avpkt. The output packet does not necessarily contain data for
4190 * the most recent frame, as encoders can delay, split, and combine input frames
4191 * internally as needed.
4193 * @param avctx codec context
4194 * @param avpkt output AVPacket.
4195 * The user can supply an output buffer by setting
4196 * avpkt->data and avpkt->size prior to calling the
4197 * function, but if the size of the user-provided data is not
4198 * large enough, encoding will fail. If avpkt->data and
4199 * avpkt->size are set, avpkt->destruct must also be set. All
4200 * other AVPacket fields will be reset by the encoder using
4201 * av_init_packet(). If avpkt->data is NULL, the encoder will
4202 * allocate it. The encoder will set avpkt->size to the size
4203 * of the output packet.
4205 * If this function fails or produces no output, avpkt will be
4206 * freed using av_free_packet() (i.e. avpkt->destruct will be
4207 * called to free the user supplied buffer).
4208 * @param[in] frame AVFrame containing the raw audio data to be encoded.
4209 * May be NULL when flushing an encoder that has the
4210 * CODEC_CAP_DELAY capability set.
4211 * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
4212 * can have any number of samples.
4213 * If it is not set, frame->nb_samples must be equal to
4214 * avctx->frame_size for all frames except the last.
4215 * The final frame may be smaller than avctx->frame_size.
4216 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4217 * output packet is non-empty, and to 0 if it is
4218 * empty. If the function returns an error, the
4219 * packet can be assumed to be invalid, and the
4220 * value of got_packet_ptr is undefined and should
4222 * @return 0 on success, negative error code on failure
4224 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
4225 const AVFrame *frame, int *got_packet_ptr);
4227 #if FF_API_OLD_ENCODE_VIDEO
4229 * @deprecated use avcodec_encode_video2() instead.
4231 * Encode a video frame from pict into buf.
4232 * The input picture should be
4233 * stored using a specific format, namely avctx.pix_fmt.
4235 * @param avctx the codec context
4236 * @param[out] buf the output buffer for the bitstream of encoded frame
4237 * @param[in] buf_size the size of the output buffer in bytes
4238 * @param[in] pict the input picture to encode
4239 * @return On error a negative value is returned, on success zero or the number
4240 * of bytes used from the output buffer.
4242 attribute_deprecated
4243 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4244 const AVFrame *pict);
4248 * Encode a frame of video.
4250 * Takes input raw video data from frame and writes the next output packet, if
4251 * available, to avpkt. The output packet does not necessarily contain data for
4252 * the most recent frame, as encoders can delay and reorder input frames
4253 * internally as needed.
4255 * @param avctx codec context
4256 * @param avpkt output AVPacket.
4257 * The user can supply an output buffer by setting
4258 * avpkt->data and avpkt->size prior to calling the
4259 * function, but if the size of the user-provided data is not
4260 * large enough, encoding will fail. All other AVPacket fields
4261 * will be reset by the encoder using av_init_packet(). If
4262 * avpkt->data is NULL, the encoder will allocate it.
4263 * The encoder will set avpkt->size to the size of the
4264 * output packet. The returned data (if any) belongs to the
4265 * caller, he is responsible for freeing it.
4267 * If this function fails or produces no output, avpkt will be
4268 * freed using av_free_packet() (i.e. avpkt->destruct will be
4269 * called to free the user supplied buffer).
4270 * @param[in] frame AVFrame containing the raw video data to be encoded.
4271 * May be NULL when flushing an encoder that has the
4272 * CODEC_CAP_DELAY capability set.
4273 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4274 * output packet is non-empty, and to 0 if it is
4275 * empty. If the function returns an error, the
4276 * packet can be assumed to be invalid, and the
4277 * value of got_packet_ptr is undefined and should
4279 * @return 0 on success, negative error code on failure
4281 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
4282 const AVFrame *frame, int *got_packet_ptr);
4284 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4285 const AVSubtitle *sub);
4293 * @defgroup lavc_resample Audio resampling
4298 struct ReSampleContext;
4299 struct AVResampleContext;
4301 typedef struct ReSampleContext ReSampleContext;
4304 * Initialize audio resampling context.
4306 * @param output_channels number of output channels
4307 * @param input_channels number of input channels
4308 * @param output_rate output sample rate
4309 * @param input_rate input sample rate
4310 * @param sample_fmt_out requested output sample format
4311 * @param sample_fmt_in input sample format
4312 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
4313 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4314 * @param linear if 1 then the used FIR filter will be linearly interpolated
4315 between the 2 closest, if 0 the closest will be used
4316 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
4317 * @return allocated ReSampleContext, NULL if error occurred
4319 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
4320 int output_rate, int input_rate,
4321 enum AVSampleFormat sample_fmt_out,
4322 enum AVSampleFormat sample_fmt_in,
4323 int filter_length, int log2_phase_count,
4324 int linear, double cutoff);
4326 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
4329 * Free resample context.
4331 * @param s a non-NULL pointer to a resample context previously
4332 * created with av_audio_resample_init()
4334 void audio_resample_close(ReSampleContext *s);
4338 * Initialize an audio resampler.
4339 * Note, if either rate is not an integer then simply scale both rates up so they are.
4340 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
4341 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4342 * @param linear If 1 then the used FIR filter will be linearly interpolated
4343 between the 2 closest, if 0 the closest will be used
4344 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
4346 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
4349 * Resample an array of samples using a previously configured context.
4350 * @param src an array of unconsumed samples
4351 * @param consumed the number of samples of src which have been consumed are returned here
4352 * @param src_size the number of unconsumed samples available
4353 * @param dst_size the amount of space in samples available in dst
4354 * @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.
4355 * @return the number of samples written in dst or -1 if an error occurred
4357 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
4361 * Compensate samplerate/timestamp drift. The compensation is done by changing
4362 * the resampler parameters, so no audible clicks or similar distortions occur
4363 * @param compensation_distance distance in output samples over which the compensation should be performed
4364 * @param sample_delta number of output samples which should be output less
4366 * example: av_resample_compensate(c, 10, 500)
4367 * here instead of 510 samples only 500 samples would be output
4369 * note, due to rounding the actual compensation might be slightly different,
4370 * especially if the compensation_distance is large and the in_rate used during init is small
4372 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
4373 void av_resample_close(struct AVResampleContext *c);
4380 * @addtogroup lavc_picture
4385 * Allocate memory for a picture. Call avpicture_free() to free it.
4387 * @see avpicture_fill()
4389 * @param picture the picture to be filled in
4390 * @param pix_fmt the format of the picture
4391 * @param width the width of the picture
4392 * @param height the height of the picture
4393 * @return zero if successful, a negative value if not
4395 int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
4398 * Free a picture previously allocated by avpicture_alloc().
4399 * The data buffer used by the AVPicture is freed, but the AVPicture structure
4402 * @param picture the AVPicture to be freed
4404 void avpicture_free(AVPicture *picture);
4407 * Fill in the AVPicture fields, always assume a linesize alignment of
4410 * @see av_image_fill_arrays()
4412 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
4413 enum PixelFormat pix_fmt, int width, int height);
4416 * Copy pixel data from an AVPicture into a buffer, always assume a
4417 * linesize alignment of 1.
4419 * @see av_image_copy_to_buffer()
4421 int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
4422 unsigned char *dest, int dest_size);
4425 * Calculate the size in bytes that a picture of the given width and height
4426 * would occupy if stored in the given picture format.
4427 * Always assume a linesize alignment of 1.
4429 * @see av_image_get_buffer_size().
4431 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
4434 * deinterlace - if not supported return -1
4436 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
4437 enum PixelFormat pix_fmt, int width, int height);
4439 * Copy image src to dst. Wraps av_image_copy().
4441 void av_picture_copy(AVPicture *dst, const AVPicture *src,
4442 enum PixelFormat pix_fmt, int width, int height);
4445 * Crop image top and left side.
4447 int av_picture_crop(AVPicture *dst, const AVPicture *src,
4448 enum PixelFormat pix_fmt, int top_band, int left_band);
4453 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
4454 int padtop, int padbottom, int padleft, int padright, int *color);
4461 * @defgroup lavc_misc Utility functions
4464 * Miscellaneous utility functions related to both encoding and decoding
4470 * @defgroup lavc_misc_pixfmt Pixel formats
4472 * Functions for working with pixel formats.
4476 void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
4479 * Return a value representing the fourCC code associated to the
4480 * pixel format pix_fmt, or 0 if no associated fourCC code can be
4483 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
4485 #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
4486 #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
4487 #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
4488 #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
4489 #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
4490 #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
4493 * Compute what kind of losses will occur when converting from one specific
4494 * pixel format to another.
4495 * When converting from one pixel format to another, information loss may occur.
4496 * For example, when converting from RGB24 to GRAY, the color information will
4497 * be lost. Similarly, other losses occur when converting from some formats to
4498 * other formats. These losses can involve loss of chroma, but also loss of
4499 * resolution, loss of color depth, loss due to the color space conversion, loss
4500 * of the alpha bits or loss due to color quantization.
4501 * avcodec_get_fix_fmt_loss() informs you about the various types of losses
4502 * which will occur when converting from one pixel format to another.
4504 * @param[in] dst_pix_fmt destination pixel format
4505 * @param[in] src_pix_fmt source pixel format
4506 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4507 * @return Combination of flags informing you what kind of losses will occur
4508 * (maximum loss for an invalid dst_pix_fmt).
4510 int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
4513 #if FF_API_FIND_BEST_PIX_FMT
4515 * @deprecated use avcodec_find_best_pix_fmt_of_2() instead.
4517 * Find the best pixel format to convert to given a certain source pixel
4518 * format. When converting from one pixel format to another, information loss
4519 * may occur. For example, when converting from RGB24 to GRAY, the color
4520 * information will be lost. Similarly, other losses occur when converting from
4521 * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
4522 * the given pixel formats should be used to suffer the least amount of loss.
4523 * The pixel formats from which it chooses one, are determined by the
4524 * pix_fmt_mask parameter.
4526 * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
4529 * src_pix_fmt = PIX_FMT_YUV420P;
4530 * pix_fmt_mask = (1 << PIX_FMT_YUV422P) | (1 << PIX_FMT_RGB24);
4531 * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
4534 * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
4535 * @param[in] src_pix_fmt source pixel format
4536 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4537 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4538 * @return The best pixel format to convert to or -1 if none was found.
4540 attribute_deprecated
4541 enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
4542 int has_alpha, int *loss_ptr);
4543 #endif /* FF_API_FIND_BEST_PIX_FMT */
4546 * Find the best pixel format to convert to given a certain source pixel
4547 * format. When converting from one pixel format to another, information loss
4548 * may occur. For example, when converting from RGB24 to GRAY, the color
4549 * information will be lost. Similarly, other losses occur when converting from
4550 * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
4551 * the given pixel formats should be used to suffer the least amount of loss.
4552 * The pixel formats from which it chooses one, are determined by the
4553 * pix_fmt_list parameter.
4556 * @param[in] pix_fmt_list PIX_FMT_NONE terminated array of pixel formats to choose from
4557 * @param[in] src_pix_fmt source pixel format
4558 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4559 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4560 * @return The best pixel format to convert to or -1 if none was found.
4562 enum PixelFormat avcodec_find_best_pix_fmt_of_list(enum PixelFormat *pix_fmt_list,
4563 enum PixelFormat src_pix_fmt,
4564 int has_alpha, int *loss_ptr);
4567 * Find the best pixel format to convert to given a certain source pixel
4568 * format and a selection of two destination pixel formats. When converting from
4569 * one pixel format to another, information loss may occur. For example, when converting
4570 * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
4571 * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
4572 * the given pixel formats should be used to suffer the least amount of loss.
4574 * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be
4578 * src_pix_fmt = PIX_FMT_YUV420P;
4579 * dst_pix_fmt1= PIX_FMT_RGB24;
4580 * dst_pix_fmt2= PIX_FMT_GRAY8;
4581 * dst_pix_fmt3= PIX_FMT_RGB8;
4582 * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
4583 * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
4584 * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
4587 * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
4588 * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
4589 * @param[in] src_pix_fmt Source pixel format
4590 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4591 * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
4592 * NULL or value of zero means we care about all losses. Out: the loss
4593 * that occurs when converting from src to selected dst pixel format.
4594 * @return The best pixel format to convert to or -1 if none was found.
4596 enum PixelFormat avcodec_find_best_pix_fmt_of_2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
4597 enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4599 attribute_deprecated
4600 #if AV_HAVE_INCOMPATIBLE_FORK_ABI
4601 enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat *pix_fmt_list,
4602 enum PixelFormat src_pix_fmt,
4603 int has_alpha, int *loss_ptr);
4605 enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
4606 enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4610 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
4616 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
4619 * Put a string representing the codec tag codec_tag in buf.
4621 * @param buf_size size in bytes of buf
4622 * @return the length of the string that would have been generated if
4623 * enough space had been available, excluding the trailing null
4625 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
4627 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
4630 * Return a name for the specified profile, if available.
4632 * @param codec the codec that is searched for the given profile
4633 * @param profile the profile value for which a name is requested
4634 * @return A name for the profile if found, NULL otherwise.
4636 const char *av_get_profile_name(const AVCodec *codec, int profile);
4638 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
4639 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
4640 //FIXME func typedef
4643 * Fill audio frame data and linesize.
4644 * AVFrame extended_data channel pointers are allocated if necessary for
4647 * @param frame the AVFrame
4648 * frame->nb_samples must be set prior to calling the
4649 * function. This function fills in frame->data,
4650 * frame->extended_data, frame->linesize[0].
4651 * @param nb_channels channel count
4652 * @param sample_fmt sample format
4653 * @param buf buffer to use for frame data
4654 * @param buf_size size of buffer
4655 * @param align plane size sample alignment (0 = default)
4656 * @return 0 on success, negative error code on failure
4658 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
4659 enum AVSampleFormat sample_fmt, const uint8_t *buf,
4660 int buf_size, int align);
4663 * Flush buffers, should be called when seeking or when switching to a different stream.
4665 void avcodec_flush_buffers(AVCodecContext *avctx);
4667 void avcodec_default_free_buffers(AVCodecContext *s);
4670 * Return codec bits per sample.
4672 * @param[in] codec_id the codec
4673 * @return Number of bits per sample or zero if unknown for the given codec.
4675 int av_get_bits_per_sample(enum AVCodecID codec_id);
4678 * Return the PCM codec associated with a sample format.
4679 * @param be endianness, 0 for little, 1 for big,
4680 * -1 (or anything else) for native
4681 * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
4683 enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
4686 * Return codec bits per sample.
4687 * Only return non-zero if the bits per sample is exactly correct, not an
4690 * @param[in] codec_id the codec
4691 * @return Number of bits per sample or zero if unknown for the given codec.
4693 int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
4696 * Return audio frame duration.
4698 * @param avctx codec context
4699 * @param frame_bytes size of the frame, or 0 if unknown
4700 * @return frame duration, in samples, if known. 0 if not able to
4703 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
4706 typedef struct AVBitStreamFilterContext {
4708 struct AVBitStreamFilter *filter;
4709 AVCodecParserContext *parser;
4710 struct AVBitStreamFilterContext *next;
4711 } AVBitStreamFilterContext;
4714 typedef struct AVBitStreamFilter {
4717 int (*filter)(AVBitStreamFilterContext *bsfc,
4718 AVCodecContext *avctx, const char *args,
4719 uint8_t **poutbuf, int *poutbuf_size,
4720 const uint8_t *buf, int buf_size, int keyframe);
4721 void (*close)(AVBitStreamFilterContext *bsfc);
4722 struct AVBitStreamFilter *next;
4723 } AVBitStreamFilter;
4725 void av_register_bitstream_filter(AVBitStreamFilter *bsf);
4726 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
4727 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
4728 AVCodecContext *avctx, const char *args,
4729 uint8_t **poutbuf, int *poutbuf_size,
4730 const uint8_t *buf, int buf_size, int keyframe);
4731 void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
4733 AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
4738 * Reallocate the given block if it is not large enough, otherwise do nothing.
4742 void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
4745 * Allocate a buffer, reusing the given one if large enough.
4747 * Contrary to av_fast_realloc the current buffer contents might not be
4748 * preserved and on error the old buffer is freed, thus no special
4749 * handling to avoid memleaks is necessary.
4751 * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
4752 * @param size size of the buffer *ptr points to
4753 * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
4754 * *size 0 if an error occurred.
4756 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
4759 * Same behaviour av_fast_malloc but the buffer has additional
4760 * FF_INPUT_PADDING_SIZE at the end which will will always be 0.
4762 * In addition the whole buffer will initially and after resizes
4763 * be 0-initialized so that no uninitialized data will ever appear.
4765 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
4768 * Same behaviour av_fast_padded_malloc except that buffer will always
4769 * be 0-initialized after call.
4771 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
4774 * Encode extradata length to a buffer. Used by xiph codecs.
4776 * @param s buffer to write to; must be at least (v/255+1) bytes long
4777 * @param v size of extradata in bytes
4778 * @return number of bytes written to the buffer.
4780 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
4783 * Log a generic warning message about a missing feature. This function is
4784 * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4785 * only, and would normally not be used by applications.
4786 * @param[in] avc a pointer to an arbitrary struct of which the first field is
4787 * a pointer to an AVClass struct
4788 * @param[in] feature string containing the name of the missing feature
4789 * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
4790 * If want_sample is non-zero, additional verbage will be added to the log
4791 * message which tells the user how to report samples to the development
4794 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
4797 * Log a generic warning message asking for a sample. This function is
4798 * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4799 * only, and would normally not be used by applications.
4800 * @param[in] avc a pointer to an arbitrary struct of which the first field is
4801 * a pointer to an AVClass struct
4802 * @param[in] msg string containing an optional message, or NULL if no message
4804 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
4807 * Register the hardware accelerator hwaccel.
4809 void av_register_hwaccel(AVHWAccel *hwaccel);
4812 * If hwaccel is NULL, returns the first registered hardware accelerator,
4813 * if hwaccel is non-NULL, returns the next registered hardware accelerator
4814 * after hwaccel, or NULL if hwaccel is the last one.
4816 AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
4820 * Lock operation used by lockmgr
4823 AV_LOCK_CREATE, ///< Create a mutex
4824 AV_LOCK_OBTAIN, ///< Lock the mutex
4825 AV_LOCK_RELEASE, ///< Unlock the mutex
4826 AV_LOCK_DESTROY, ///< Free mutex resources
4830 * Register a user provided lock manager supporting the operations
4831 * specified by AVLockOp. mutex points to a (void *) where the
4832 * lockmgr should store/get a pointer to a user allocated mutex. It's
4833 * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
4835 * @param cb User defined callback. Note: FFmpeg may invoke calls to this
4836 * callback during the call to av_lockmgr_register().
4837 * Thus, the application must be prepared to handle that.
4838 * If cb is set to NULL the lockmgr will be unregistered.
4839 * Also note that during unregistration the previously registered
4840 * lockmgr callback may also be invoked.
4842 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
4845 * Get the type of the given codec.
4847 enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
4850 * Get the name of a codec.
4851 * @return a static string identifying the codec; never NULL
4853 const char *avcodec_get_name(enum AVCodecID id);
4856 * @return a positive value if s is open (i.e. avcodec_open2() was called on it
4857 * with no corresponding avcodec_close()), 0 otherwise.
4859 int avcodec_is_open(AVCodecContext *s);
4862 * @return a non-zero number if codec is an encoder, zero otherwise
4864 int av_codec_is_encoder(const AVCodec *codec);
4867 * @return a non-zero number if codec is a decoder, zero otherwise
4869 int av_codec_is_decoder(const AVCodec *codec);
4872 * @return descriptor for given codec ID or NULL if no descriptor exists.
4874 const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
4877 * Iterate over all codec descriptors known to libavcodec.
4879 * @param prev previous descriptor. NULL to get the first descriptor.
4881 * @return next descriptor or NULL after the last descriptor
4883 const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
4886 * @return codec descriptor with the given name or NULL if no such descriptor
4889 const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
4895 #endif /* AVCODEC_AVCODEC_H */