2 * copyright (c) 2001 Fabrice Bellard
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
27 * Libavcodec external API header
31 #include "libavutil/samplefmt.h"
32 #include "libavutil/attributes.h"
33 #include "libavutil/avutil.h"
34 #include "libavutil/buffer.h"
35 #include "libavutil/cpu.h"
36 #include "libavutil/dict.h"
37 #include "libavutil/frame.h"
38 #include "libavutil/log.h"
39 #include "libavutil/pixfmt.h"
40 #include "libavutil/rational.h"
44 #if FF_API_FAST_MALLOC
45 // to provide fast_*alloc
46 #include "libavutil/mem.h"
50 * @defgroup libavc Encoding/Decoding Library
53 * @defgroup lavc_decoding Decoding
57 * @defgroup lavc_encoding Encoding
61 * @defgroup lavc_codec Codecs
63 * @defgroup lavc_codec_native Native Codecs
66 * @defgroup lavc_codec_wrappers External library wrappers
69 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
73 * @defgroup lavc_internal Internal
81 * @defgroup lavc_encdec send/receive encoding and decoding API overview
84 * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/
85 * avcodec_receive_packet() functions provide an encode/decode API, which
86 * decouples input and output.
88 * The API is very similar for encoding/decoding and audio/video, and works as
90 * - Set up and open the AVCodecContext as usual.
92 * - For decoding, call avcodec_send_packet() to give the decoder raw
93 * compressed data in an AVPacket.
94 * - For encoding, call avcodec_send_frame() to give the decoder an AVFrame
95 * containing uncompressed audio or video.
96 * In both cases, it is recommended that AVPackets and AVFrames are
97 * refcounted, or libavcodec might have to copy the input data. (libavformat
98 * always returns refcounted AVPackets, and av_frame_get_buffer() allocates
99 * refcounted AVFrames.)
100 * - Receive output in a loop. Periodically call one of the avcodec_receive_*()
101 * functions and process their output:
102 * - For decoding, call avcodec_receive_frame(). On success, it will return
103 * an AVFrame containing uncompressed audio or video data.
104 * - For encoding, call avcodec_receive_packet(). On success, it will return
105 * an AVPacket with a compressed frame.
106 * Repeat this call until it returns AVERROR(EAGAIN) or an error. The
107 * AVERROR(EAGAIN) return value means that new input data is required to
108 * return new output. In this case, continue with sending input. For each
109 * input frame/packet, the codec will typically return 1 output frame/packet,
110 * but it can also be 0 or more than 1.
112 * At the beginning of decoding or encoding, the codec might accept multiple
113 * input frames/packets without returning a frame, until its internal buffers
114 * are filled. This situation is handled transparently if you follow the steps
117 * In theory, sending input can result in EAGAIN - this should happen only if
118 * not all output was received. You can use this to structure alternative decode
119 * or encode loops other than the one suggested above. For example, you could
120 * try sending new input on each iteration, and try to receive output if that
123 * End of stream situations. These require "flushing" (aka draining) the codec,
124 * as the codec might buffer multiple frames or packets internally for
125 * performance or out of necessity (consider B-frames).
126 * This is handled as follows:
127 * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)
128 * or avcodec_send_frame() (encoding) functions. This will enter draining
130 * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()
131 * (encoding) in a loop until AVERROR_EOF is returned. The functions will
132 * not return AVERROR(EAGAIN), unless you forgot to enter draining mode.
133 * - Before decoding can be resumed again, the codec has to be reset with
134 * avcodec_flush_buffers().
136 * Using the API as outlined above is highly recommended. But it is also
137 * possible to call functions outside of this rigid schema. For example, you can
138 * call avcodec_send_packet() repeatedly without calling
139 * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed
140 * until the codec's internal buffer has been filled up (which is typically of
141 * size 1 per output frame, after initial input), and then reject input with
142 * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to
143 * read at least some output.
145 * Not all codecs will follow a rigid and predictable dataflow; the only
146 * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on
147 * one end implies that a receive/send call on the other end will succeed. In
148 * general, no codec will permit unlimited buffering of input or output.
150 * This API replaces the following legacy functions:
151 * - avcodec_decode_video2() and avcodec_decode_audio4():
152 * Use avcodec_send_packet() to feed input to the decoder, then use
153 * avcodec_receive_frame() to receive decoded frames after each packet.
154 * Unlike with the old video decoding API, multiple frames might result from
155 * a packet. For audio, splitting the input packet into frames by partially
156 * decoding packets becomes transparent to the API user. You never need to
157 * feed an AVPacket to the API twice (unless it is rejected with EAGAIN - then
158 * no data was read from the packet).
159 * Additionally, sending a flush/draining packet is required only once.
160 * - avcodec_encode_video2()/avcodec_encode_audio2():
161 * Use avcodec_send_frame() to feed input to the encoder, then use
162 * avcodec_receive_packet() to receive encoded packets.
163 * Providing user-allocated buffers for avcodec_receive_packet() is not
165 * - The new API does not handle subtitles yet.
167 * Mixing new and old function calls on the same AVCodecContext is not allowed,
168 * and will result in arbitrary behavior.
170 * Some codecs might require using the new API; using the old API will return
171 * an error when calling it. All codecs support the new API.
173 * A codec is not allowed to return EAGAIN for both sending and receiving. This
174 * would be an invalid state, which could put the codec user into an endless
175 * loop. The API has no concept of time either: it cannot happen that trying to
176 * do avcodec_send_packet() results in EAGAIN, but a repeated call 1 second
177 * later accepts the packet (with no other receive/flush API calls involved).
178 * The API is a strict state machine, and the passage of time is not supposed
179 * to influence it. Some timing-dependent behavior might still be deemed
180 * acceptable in certain cases. But it must never result in both send/receive
181 * returning EAGAIN at the same time at any point. It must also absolutely be
182 * avoided that the current state is "unstable" and can "flip-flop" between
183 * the send/receive APIs allowing progress. For example, it's not allowed that
184 * the codec randomly decides that it actually wants to consume a packet now
185 * instead of returning a frame, after it just returned EAGAIN on an
186 * avcodec_send_packet() call.
191 * @defgroup lavc_core Core functions/structures.
194 * Basic definitions, functions for querying libavcodec capabilities,
195 * allocating core structures, etc.
201 * Identify the syntax and semantics of the bitstream.
202 * The principle is roughly:
203 * Two decoders with the same ID can decode the same streams.
204 * Two encoders with the same ID can encode compatible streams.
205 * There may be slight deviations from the principle due to implementation
208 * If you add a codec ID to this list, add it so that
209 * 1. no value of a existing codec ID changes (that would break ABI),
210 * 2. it is as close as possible to similar codecs.
212 * After adding new codec IDs, do not forget to add an entry to the codec
213 * descriptor list and bump libavcodec minor version.
219 AV_CODEC_ID_MPEG1VIDEO,
220 AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
222 AV_CODEC_ID_MPEG2VIDEO_XVMC,
223 #endif /* FF_API_XVMC */
234 AV_CODEC_ID_RAWVIDEO,
235 AV_CODEC_ID_MSMPEG4V1,
236 AV_CODEC_ID_MSMPEG4V2,
237 AV_CODEC_ID_MSMPEG4V3,
260 AV_CODEC_ID_INTERPLAY_VIDEO,
267 AV_CODEC_ID_MSVIDEO1,
272 AV_CODEC_ID_TRUEMOTION1,
273 AV_CODEC_ID_VMDVIDEO,
298 AV_CODEC_ID_TRUEMOTION2,
304 AV_CODEC_ID_SMACKVIDEO,
309 AV_CODEC_ID_JPEG2000,
315 AV_CODEC_ID_DSICINVIDEO,
316 AV_CODEC_ID_TIERTEXSEQVIDEO,
324 AV_CODEC_ID_BETHSOFTVID,
336 AV_CODEC_ID_ESCAPE124,
340 AV_CODEC_ID_MOTIONPIXELS,
352 AV_CODEC_ID_FLASHSV2,
353 AV_CODEC_ID_CDGRAPHICS,
356 AV_CODEC_ID_BINKVIDEO,
357 AV_CODEC_ID_IFF_ILBM,
358 AV_CODEC_ID_IFF_BYTERUN1,
364 AV_CODEC_ID_A64_MULTI,
365 AV_CODEC_ID_A64_MULTI5,
368 AV_CODEC_ID_LAGARITH,
372 AV_CODEC_ID_WMV3IMAGE,
373 AV_CODEC_ID_VC1IMAGE,
375 AV_CODEC_ID_BMV_VIDEO,
382 AV_CODEC_ID_ZEROCODEC,
391 AV_CODEC_ID_ESCAPE130,
394 AV_CODEC_ID_HNM4_VIDEO,
397 AV_CODEC_ID_ALIAS_PIX,
398 AV_CODEC_ID_BRENDER_PIX,
399 AV_CODEC_ID_PAF_VIDEO,
412 AV_CODEC_ID_SCREENPRESSO,
414 AV_CODEC_ID_MAGICYUV,
415 AV_CODEC_ID_TRUEMOTION2RT,
420 /* various PCM "codecs" */
421 AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
422 AV_CODEC_ID_PCM_S16LE = 0x10000,
423 AV_CODEC_ID_PCM_S16BE,
424 AV_CODEC_ID_PCM_U16LE,
425 AV_CODEC_ID_PCM_U16BE,
428 AV_CODEC_ID_PCM_MULAW,
429 AV_CODEC_ID_PCM_ALAW,
430 AV_CODEC_ID_PCM_S32LE,
431 AV_CODEC_ID_PCM_S32BE,
432 AV_CODEC_ID_PCM_U32LE,
433 AV_CODEC_ID_PCM_U32BE,
434 AV_CODEC_ID_PCM_S24LE,
435 AV_CODEC_ID_PCM_S24BE,
436 AV_CODEC_ID_PCM_U24LE,
437 AV_CODEC_ID_PCM_U24BE,
438 AV_CODEC_ID_PCM_S24DAUD,
439 AV_CODEC_ID_PCM_ZORK,
440 AV_CODEC_ID_PCM_S16LE_PLANAR,
442 AV_CODEC_ID_PCM_F32BE,
443 AV_CODEC_ID_PCM_F32LE,
444 AV_CODEC_ID_PCM_F64BE,
445 AV_CODEC_ID_PCM_F64LE,
446 AV_CODEC_ID_PCM_BLURAY,
449 AV_CODEC_ID_PCM_S8_PLANAR,
450 AV_CODEC_ID_PCM_S24LE_PLANAR,
451 AV_CODEC_ID_PCM_S32LE_PLANAR,
452 AV_CODEC_ID_PCM_S16BE_PLANAR,
454 /* various ADPCM codecs */
455 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
456 AV_CODEC_ID_ADPCM_IMA_WAV,
457 AV_CODEC_ID_ADPCM_IMA_DK3,
458 AV_CODEC_ID_ADPCM_IMA_DK4,
459 AV_CODEC_ID_ADPCM_IMA_WS,
460 AV_CODEC_ID_ADPCM_IMA_SMJPEG,
461 AV_CODEC_ID_ADPCM_MS,
462 AV_CODEC_ID_ADPCM_4XM,
463 AV_CODEC_ID_ADPCM_XA,
464 AV_CODEC_ID_ADPCM_ADX,
465 AV_CODEC_ID_ADPCM_EA,
466 AV_CODEC_ID_ADPCM_G726,
467 AV_CODEC_ID_ADPCM_CT,
468 AV_CODEC_ID_ADPCM_SWF,
469 AV_CODEC_ID_ADPCM_YAMAHA,
470 AV_CODEC_ID_ADPCM_SBPRO_4,
471 AV_CODEC_ID_ADPCM_SBPRO_3,
472 AV_CODEC_ID_ADPCM_SBPRO_2,
473 AV_CODEC_ID_ADPCM_THP,
474 AV_CODEC_ID_ADPCM_IMA_AMV,
475 AV_CODEC_ID_ADPCM_EA_R1,
476 AV_CODEC_ID_ADPCM_EA_R3,
477 AV_CODEC_ID_ADPCM_EA_R2,
478 AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
479 AV_CODEC_ID_ADPCM_IMA_EA_EACS,
480 AV_CODEC_ID_ADPCM_EA_XAS,
481 AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
482 AV_CODEC_ID_ADPCM_IMA_ISS,
483 AV_CODEC_ID_ADPCM_G722,
484 AV_CODEC_ID_ADPCM_IMA_APC,
485 AV_CODEC_ID_ADPCM_VIMA,
488 AV_CODEC_ID_AMR_NB = 0x12000,
491 /* RealAudio codecs*/
492 AV_CODEC_ID_RA_144 = 0x13000,
495 /* various DPCM codecs */
496 AV_CODEC_ID_ROQ_DPCM = 0x14000,
497 AV_CODEC_ID_INTERPLAY_DPCM,
498 AV_CODEC_ID_XAN_DPCM,
499 AV_CODEC_ID_SOL_DPCM,
502 AV_CODEC_ID_MP2 = 0x15000,
503 AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
513 AV_CODEC_ID_VMDAUDIO,
519 AV_CODEC_ID_WESTWOOD_SND1,
520 AV_CODEC_ID_GSM, ///< as in Berlin toast format
523 AV_CODEC_ID_TRUESPEECH,
525 AV_CODEC_ID_SMACKAUDIO,
528 AV_CODEC_ID_DSICINAUDIO,
530 AV_CODEC_ID_MUSEPACK7,
532 AV_CODEC_ID_GSM_MS, /* as found in WAV */
538 AV_CODEC_ID_NELLYMOSER,
539 AV_CODEC_ID_MUSEPACK8,
541 AV_CODEC_ID_WMAVOICE,
543 AV_CODEC_ID_WMALOSSLESS,
552 AV_CODEC_ID_BINKAUDIO_RDFT,
553 AV_CODEC_ID_BINKAUDIO_DCT,
554 AV_CODEC_ID_AAC_LATM,
559 AV_CODEC_ID_8SVX_EXP,
560 AV_CODEC_ID_8SVX_FIB,
561 AV_CODEC_ID_BMV_AUDIO,
566 AV_CODEC_ID_COMFORT_NOISE,
568 AV_CODEC_ID_METASOUND,
569 AV_CODEC_ID_PAF_AUDIO,
573 /* subtitle codecs */
574 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
575 AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
576 AV_CODEC_ID_DVB_SUBTITLE,
577 AV_CODEC_ID_TEXT, ///< raw UTF-8 text
580 AV_CODEC_ID_MOV_TEXT,
581 AV_CODEC_ID_HDMV_PGS_SUBTITLE,
582 AV_CODEC_ID_DVB_TELETEXT,
585 /* other specific kind of codecs (generally used for attachments) */
586 AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
587 AV_CODEC_ID_TTF = 0x18000,
589 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
591 AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
592 * stream (only used by libavformat) */
593 AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
594 * stream (only used by libavformat) */
595 AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
596 AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
600 * This struct describes the properties of a single codec described by an
602 * @see avcodec_descriptor_get()
604 typedef struct AVCodecDescriptor {
606 enum AVMediaType type;
608 * Name of the codec described by this descriptor. It is non-empty and
609 * unique for each codec descriptor. It should contain alphanumeric
610 * characters and '_' only.
614 * A more descriptive name for this codec. May be NULL.
616 const char *long_name;
618 * Codec properties, a combination of AV_CODEC_PROP_* flags.
622 * If non-NULL, an array of profiles recognized for this codec.
623 * Terminated with FF_PROFILE_UNKNOWN.
625 const struct AVProfile *profiles;
629 * Codec uses only intra compression.
632 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
634 * Codec supports lossy compression. Audio and video codecs only.
635 * @note a codec may support both lossy and lossless
638 #define AV_CODEC_PROP_LOSSY (1 << 1)
640 * Codec supports lossless compression. Audio and video codecs only.
642 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
644 * Codec supports frame reordering. That is, the coded order (the order in which
645 * the encoded packets are output by the encoders / stored / input to the
646 * decoders) may be different from the presentation order of the corresponding
649 * For codecs that do not have this property set, PTS and DTS should always be
652 #define AV_CODEC_PROP_REORDER (1 << 3)
655 * @ingroup lavc_decoding
656 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
657 * This is mainly needed because some optimized bitstream readers read
658 * 32 or 64 bit at once and could read over the end.<br>
659 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
660 * MPEG bitstreams could cause overread and segfault.
662 #define AV_INPUT_BUFFER_PADDING_SIZE 8
665 * @ingroup lavc_encoding
666 * minimum encoding buffer size
667 * Used to avoid some checks during header writing.
669 #define AV_INPUT_BUFFER_MIN_SIZE 16384
671 #if FF_API_WITHOUT_PREFIX
673 * @deprecated use AV_INPUT_BUFFER_PADDING_SIZE instead
675 #define FF_INPUT_BUFFER_PADDING_SIZE 8
678 * @deprecated use AV_INPUT_BUFFER_MIN_SIZE instead
680 #define FF_MIN_BUFFER_SIZE 16384
681 #endif /* FF_API_WITHOUT_PREFIX */
684 * @ingroup lavc_encoding
685 * motion estimation type.
686 * @deprecated use codec private option instead
688 #if FF_API_MOTION_EST
690 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
694 ME_EPZS, ///< enhanced predictive zonal search
695 ME_X1, ///< reserved for experiments
696 ME_HEX, ///< hexagon based search
697 ME_UMH, ///< uneven multi-hexagon search
698 ME_TESA, ///< transformed exhaustive search algorithm
703 * @ingroup lavc_decoding
706 /* We leave some space between them for extensions (drop some
707 * keyframes for intra-only or drop just some bidir frames). */
708 AVDISCARD_NONE =-16, ///< discard nothing
709 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
710 AVDISCARD_NONREF = 8, ///< discard all non reference
711 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
712 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
713 AVDISCARD_ALL = 48, ///< discard all
716 enum AVAudioServiceType {
717 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
718 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
719 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
720 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
721 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
722 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
723 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
724 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
725 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
726 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
730 * @ingroup lavc_encoding
732 typedef struct RcOverride{
735 int qscale; // If this is 0 then quality_factor will be used instead.
736 float quality_factor;
739 #if FF_API_MAX_BFRAMES
741 * @deprecated there is no libavcodec-wide limit on the number of B-frames
743 #define FF_MAX_B_FRAMES 16
747 These flags can be passed in AVCodecContext.flags before initialization.
748 Note: Not everything is supported yet.
752 * Allow decoders to produce frames with data planes that are not aligned
753 * to CPU requirements (e.g. due to cropping).
755 #define AV_CODEC_FLAG_UNALIGNED (1 << 0)
759 #define AV_CODEC_FLAG_QSCALE (1 << 1)
761 * 4 MV per MB allowed / advanced prediction for H.263.
763 #define AV_CODEC_FLAG_4MV (1 << 2)
765 * Output even those frames that might be corrupted.
767 #define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)
771 #define AV_CODEC_FLAG_QPEL (1 << 4)
773 * Use internal 2pass ratecontrol in first pass mode.
775 #define AV_CODEC_FLAG_PASS1 (1 << 9)
777 * Use internal 2pass ratecontrol in second pass mode.
779 #define AV_CODEC_FLAG_PASS2 (1 << 10)
783 #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
785 * Only decode/encode grayscale.
787 #define AV_CODEC_FLAG_GRAY (1 << 13)
789 * error[?] variables will be set during encoding.
791 #define AV_CODEC_FLAG_PSNR (1 << 15)
793 * Input bitstream might be truncated at a random location
794 * instead of only at frame boundaries.
796 #define AV_CODEC_FLAG_TRUNCATED (1 << 16)
798 * Use interlaced DCT.
800 #define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18)
804 #define AV_CODEC_FLAG_LOW_DELAY (1 << 19)
806 * Place global headers in extradata instead of every keyframe.
808 #define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
810 * Use only bitexact stuff (except (I)DCT).
812 #define AV_CODEC_FLAG_BITEXACT (1 << 23)
813 /* Fx : Flag for H.263+ extra options */
815 * H.263 advanced intra coding / MPEG-4 AC prediction
817 #define AV_CODEC_FLAG_AC_PRED (1 << 24)
819 * interlaced motion estimation
821 #define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)
822 #define AV_CODEC_FLAG_CLOSED_GOP (1 << 31)
825 * Allow non spec compliant speedup tricks.
827 #define AV_CODEC_FLAG2_FAST (1 << 0)
829 * Skip bitstream encoding.
831 #define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)
833 * Place global headers at every keyframe instead of in extradata.
835 #define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)
837 * Input bitstream might be truncated at a packet boundaries
838 * instead of only at frame boundaries.
840 #define AV_CODEC_FLAG2_CHUNKS (1 << 15)
842 * Discard cropping information from SPS.
844 #define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)
846 /* Unsupported options :
847 * Syntax Arithmetic coding (SAC)
848 * Reference Picture Selection
849 * Independent Segment Decoding */
851 /* codec capabilities */
854 * Decoder can use draw_horiz_band callback.
856 #define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0)
858 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
859 * If not set, it might not use get_buffer() at all or use operations that
860 * assume the buffer was allocated by avcodec_default_get_buffer.
862 #define AV_CODEC_CAP_DR1 (1 << 1)
863 #define AV_CODEC_CAP_TRUNCATED (1 << 3)
865 * Encoder or decoder requires flushing with NULL input at the end in order to
866 * give the complete and correct output.
868 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
869 * with NULL data. The user can still send NULL data to the public encode
870 * or decode function, but libavcodec will not pass it along to the codec
871 * unless this flag is set.
874 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
875 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
879 * The encoder needs to be fed with NULL data at the end of encoding until the
880 * encoder no longer returns data.
882 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
883 * flag also means that the encoder must set the pts and duration for
884 * each output packet. If this flag is not set, the pts and duration will
885 * be determined by libavcodec from the input frame.
887 #define AV_CODEC_CAP_DELAY (1 << 5)
889 * Codec can be fed a final frame with a smaller size.
890 * This can be used to prevent truncation of the last audio samples.
892 #define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)
894 * Codec can output multiple frames per AVPacket
895 * Normally demuxers return one frame at a time, demuxers which do not do
896 * are connected to a parser to split what they return into proper frames.
897 * This flag is reserved to the very rare category of codecs which have a
898 * bitstream that cannot be split into frames without timeconsuming
899 * operations like full decoding. Demuxers carrying such bitstreams thus
900 * may return multiple frames in a packet. This has many disadvantages like
901 * prohibiting stream copy in many cases thus it should only be considered
904 #define AV_CODEC_CAP_SUBFRAMES (1 << 8)
906 * Codec is experimental and is thus avoided in favor of non experimental
909 #define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)
911 * Codec should fill in channel configuration and samplerate instead of container
913 #define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)
915 * Codec supports frame-level multithreading.
917 #define AV_CODEC_CAP_FRAME_THREADS (1 << 12)
919 * Codec supports slice-based (or partition-based) multithreading.
921 #define AV_CODEC_CAP_SLICE_THREADS (1 << 13)
923 * Codec supports changed parameters at any point.
925 #define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)
927 * Codec supports avctx->thread_count == 0 (auto).
929 #define AV_CODEC_CAP_AUTO_THREADS (1 << 15)
931 * Audio encoder supports receiving a different number of samples in each call.
933 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
935 #if FF_API_WITHOUT_PREFIX
937 * Allow decoders to produce frames with data planes that are not aligned
938 * to CPU requirements (e.g. due to cropping).
940 #define CODEC_FLAG_UNALIGNED 0x0001
941 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
942 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
943 #define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted
944 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
947 * @deprecated use the "gmc" private option of the libxvid encoder
949 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
953 * @deprecated use the flag "mv0" in the "mpv_flags" private option of the
956 #define CODEC_FLAG_MV0 0x0040
958 #if FF_API_INPUT_PRESERVED
960 * @deprecated passing reference-counted frames to the encoders replaces this
963 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
965 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
966 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
967 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
970 * @deprecated edges are not used/required anymore. I.e. this flag is now always
973 #define CODEC_FLAG_EMU_EDGE 0x4000
975 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
976 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
977 location instead of only at frame boundaries. */
978 #if FF_API_NORMALIZE_AQP
980 * @deprecated use the flag "naq" in the "mpv_flags" private option of the
983 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000
985 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
986 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
987 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
988 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
989 /* Fx : Flag for H.263+ extra options */
990 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
991 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
992 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
993 #define CODEC_FLAG_CLOSED_GOP 0x80000000
994 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
995 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
996 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
997 #define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS.
999 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
1001 /* Unsupported options :
1002 * Syntax Arithmetic coding (SAC)
1003 * Reference Picture Selection
1004 * Independent Segment Decoding */
1006 /* codec capabilities */
1008 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
1010 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
1011 * If not set, it might not use get_buffer() at all or use operations that
1012 * assume the buffer was allocated by avcodec_default_get_buffer.
1014 #define CODEC_CAP_DR1 0x0002
1015 #define CODEC_CAP_TRUNCATED 0x0008
1017 /* Codec can export data for HW decoding (XvMC). */
1018 #define CODEC_CAP_HWACCEL 0x0010
1019 #endif /* FF_API_XVMC */
1021 * Encoder or decoder requires flushing with NULL input at the end in order to
1022 * give the complete and correct output.
1024 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
1025 * with NULL data. The user can still send NULL data to the public encode
1026 * or decode function, but libavcodec will not pass it along to the codec
1027 * unless this flag is set.
1030 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
1031 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
1035 * The encoder needs to be fed with NULL data at the end of encoding until the
1036 * encoder no longer returns data.
1038 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
1039 * flag also means that the encoder must set the pts and duration for
1040 * each output packet. If this flag is not set, the pts and duration will
1041 * be determined by libavcodec from the input frame.
1043 #define CODEC_CAP_DELAY 0x0020
1045 * Codec can be fed a final frame with a smaller size.
1046 * This can be used to prevent truncation of the last audio samples.
1048 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
1049 #if FF_API_CAP_VDPAU
1051 * Codec can export data for HW decoding (VDPAU).
1053 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
1056 * Codec can output multiple frames per AVPacket
1057 * Normally demuxers return one frame at a time, demuxers which do not do
1058 * are connected to a parser to split what they return into proper frames.
1059 * This flag is reserved to the very rare category of codecs which have a
1060 * bitstream that cannot be split into frames without timeconsuming
1061 * operations like full decoding. Demuxers carrying such bitstreams thus
1062 * may return multiple frames in a packet. This has many disadvantages like
1063 * prohibiting stream copy in many cases thus it should only be considered
1066 #define CODEC_CAP_SUBFRAMES 0x0100
1068 * Codec is experimental and is thus avoided in favor of non experimental
1071 #define CODEC_CAP_EXPERIMENTAL 0x0200
1073 * Codec should fill in channel configuration and samplerate instead of container
1075 #define CODEC_CAP_CHANNEL_CONF 0x0400
1076 #if FF_API_NEG_LINESIZES
1078 * @deprecated no codecs use this capability
1080 #define CODEC_CAP_NEG_LINESIZES 0x0800
1083 * Codec supports frame-level multithreading.
1085 #define CODEC_CAP_FRAME_THREADS 0x1000
1087 * Codec supports slice-based (or partition-based) multithreading.
1089 #define CODEC_CAP_SLICE_THREADS 0x2000
1091 * Codec supports changed parameters at any point.
1093 #define CODEC_CAP_PARAM_CHANGE 0x4000
1095 * Codec supports avctx->thread_count == 0 (auto).
1097 #define CODEC_CAP_AUTO_THREADS 0x8000
1099 * Audio encoder supports receiving a different number of samples in each call.
1101 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
1102 #endif /* FF_API_WITHOUT_PREFIX */
1105 //The following defines may change, don't expect compatibility if you use them.
1106 #define MB_TYPE_INTRA4x4 0x0001
1107 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
1108 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
1109 #define MB_TYPE_16x16 0x0008
1110 #define MB_TYPE_16x8 0x0010
1111 #define MB_TYPE_8x16 0x0020
1112 #define MB_TYPE_8x8 0x0040
1113 #define MB_TYPE_INTERLACED 0x0080
1114 #define MB_TYPE_DIRECT2 0x0100 //FIXME
1115 #define MB_TYPE_ACPRED 0x0200
1116 #define MB_TYPE_GMC 0x0400
1117 #define MB_TYPE_SKIP 0x0800
1118 #define MB_TYPE_P0L0 0x1000
1119 #define MB_TYPE_P1L0 0x2000
1120 #define MB_TYPE_P0L1 0x4000
1121 #define MB_TYPE_P1L1 0x8000
1122 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
1123 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
1124 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
1125 #define MB_TYPE_QUANT 0x00010000
1126 #define MB_TYPE_CBP 0x00020000
1127 // Note bits 24-31 are reserved for codec specific use (H.264 ref0, MPEG-1 0mv, ...)
1132 * This specifies the area which should be displayed.
1133 * Note there may be multiple such areas for one frame.
1135 typedef struct AVPanScan{
1138 * - encoding: Set by user.
1139 * - decoding: Set by libavcodec.
1144 * width and height in 1/16 pel
1145 * - encoding: Set by user.
1146 * - decoding: Set by libavcodec.
1152 * position of the top left corner in 1/16 pel for up to 3 fields/frames
1153 * - encoding: Set by user.
1154 * - decoding: Set by libavcodec.
1156 int16_t position[3][2];
1160 * This structure describes the bitrate properties of an encoded bitstream. It
1161 * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
1162 * parameters for H.264/HEVC.
1164 typedef struct AVCPBProperties {
1166 * Maximum bitrate of the stream, in bits per second.
1167 * Zero if unknown or unspecified.
1171 * Minimum bitrate of the stream, in bits per second.
1172 * Zero if unknown or unspecified.
1176 * Average bitrate of the stream, in bits per second.
1177 * Zero if unknown or unspecified.
1182 * The size of the buffer to which the ratecontrol is applied, in bits.
1183 * Zero if unknown or unspecified.
1188 * The delay between the time the packet this structure is associated with
1189 * is received and the time when it should be decoded, in periods of a 27MHz
1192 * UINT64_MAX when unknown or unspecified.
1197 #if FF_API_QSCALE_TYPE
1198 #define FF_QSCALE_TYPE_MPEG1 0
1199 #define FF_QSCALE_TYPE_MPEG2 1
1200 #define FF_QSCALE_TYPE_H264 2
1201 #define FF_QSCALE_TYPE_VP56 3
1205 * The decoder will keep a reference to the frame and may reuse it later.
1207 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
1210 * @defgroup lavc_packet AVPacket
1212 * Types and functions for working with AVPacket.
1215 enum AVPacketSideDataType {
1217 * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE
1218 * bytes worth of palette. This side data signals that a new palette is
1221 AV_PKT_DATA_PALETTE,
1224 * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
1225 * that the extradata buffer was changed and the receiving side should
1226 * act upon it appropriately. The new extradata is embedded in the side
1227 * data buffer and should be immediately used for processing the current
1230 AV_PKT_DATA_NEW_EXTRADATA,
1233 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
1236 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
1237 * s32le channel_count
1238 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
1239 * u64le channel_layout
1240 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
1242 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
1247 AV_PKT_DATA_PARAM_CHANGE,
1250 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
1251 * structures with info about macroblocks relevant to splitting the
1252 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
1253 * That is, it does not necessarily contain info about all macroblocks,
1254 * as long as the distance between macroblocks in the info is smaller
1255 * than the target payload size.
1256 * Each MB info structure is 12 bytes, and is laid out as follows:
1258 * u32le bit offset from the start of the packet
1259 * u8 current quantizer at the start of the macroblock
1261 * u16le macroblock address within the GOB
1262 * u8 horizontal MV predictor
1263 * u8 vertical MV predictor
1264 * u8 horizontal MV predictor for block number 3
1265 * u8 vertical MV predictor for block number 3
1268 AV_PKT_DATA_H263_MB_INFO,
1271 * This side data should be associated with an audio stream and contains
1272 * ReplayGain information in form of the AVReplayGain struct.
1274 AV_PKT_DATA_REPLAYGAIN,
1277 * This side data contains a 3x3 transformation matrix describing an affine
1278 * transformation that needs to be applied to the decoded video frames for
1279 * correct presentation.
1281 * See libavutil/display.h for a detailed description of the data.
1283 AV_PKT_DATA_DISPLAYMATRIX,
1286 * This side data should be associated with a video stream and contains
1287 * Stereoscopic 3D information in form of the AVStereo3D struct.
1289 AV_PKT_DATA_STEREO3D,
1292 * This side data should be associated with an audio stream and corresponds
1293 * to enum AVAudioServiceType.
1295 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
1298 * This side data contains an integer value representing the quality
1299 * factor of the compressed frame. Allowed range is between 1 (good)
1300 * and FF_LAMBDA_MAX (bad).
1302 AV_PKT_DATA_QUALITY_FACTOR,
1305 * This side data contains an integer value representing the stream index
1306 * of a "fallback" track. A fallback track indicates an alternate
1307 * track to use when the current track can not be decoded for some reason.
1308 * e.g. no decoder available for codec.
1310 AV_PKT_DATA_FALLBACK_TRACK,
1313 * This side data corresponds to the AVCPBProperties struct.
1315 AV_PKT_DATA_CPB_PROPERTIES,
1318 * This side data should be associated with a video stream and corresponds
1319 * to the AVSphericalMapping structure.
1321 AV_PKT_DATA_SPHERICAL,
1324 typedef struct AVPacketSideData {
1327 enum AVPacketSideDataType type;
1331 * This structure stores compressed data. It is typically exported by demuxers
1332 * and then passed as input to decoders, or received as output from encoders and
1333 * then passed to muxers.
1335 * For video, it should typically contain one compressed frame. For audio it may
1336 * contain several compressed frames. Encoders are allowed to output empty
1337 * packets, with no compressed data, containing only side data
1338 * (e.g. to update some stream parameters at the end of encoding).
1340 * AVPacket is one of the few structs in Libav, whose size is a part of public
1341 * ABI. Thus it may be allocated on stack and no new fields can be added to it
1342 * without libavcodec and libavformat major bump.
1344 * The semantics of data ownership depends on the buf field.
1345 * If it is set, the packet data is dynamically allocated and is
1346 * valid indefinitely until a call to av_packet_unref() reduces the
1347 * reference count to 0.
1349 * If the buf field is not set av_packet_ref() would make a copy instead
1350 * of increasing the reference count.
1352 * The side data is always allocated with av_malloc(), copied by
1353 * av_packet_ref() and freed by av_packet_unref().
1355 * @see av_packet_ref
1356 * @see av_packet_unref
1358 typedef struct AVPacket {
1360 * A reference to the reference-counted buffer where the packet data is
1362 * May be NULL, then the packet data is not reference-counted.
1366 * Presentation timestamp in AVStream->time_base units; the time at which
1367 * the decompressed packet will be presented to the user.
1368 * Can be AV_NOPTS_VALUE if it is not stored in the file.
1369 * pts MUST be larger or equal to dts as presentation cannot happen before
1370 * decompression, unless one wants to view hex dumps. Some formats misuse
1371 * the terms dts and pts/cts to mean something different. Such timestamps
1372 * must be converted to true pts/dts before they are stored in AVPacket.
1376 * Decompression timestamp in AVStream->time_base units; the time at which
1377 * the packet is decompressed.
1378 * Can be AV_NOPTS_VALUE if it is not stored in the file.
1385 * A combination of AV_PKT_FLAG values
1389 * Additional packet data that can be provided by the container.
1390 * Packet can contain several types of side information.
1392 AVPacketSideData *side_data;
1393 int side_data_elems;
1396 * Duration of this packet in AVStream->time_base units, 0 if unknown.
1397 * Equals next_pts - this_pts in presentation order.
1401 int64_t pos; ///< byte position in stream, -1 if unknown
1403 #if FF_API_CONVERGENCE_DURATION
1405 * @deprecated Same as the duration field, but as int64_t. This was required
1406 * for Matroska subtitles, whose duration values could overflow when the
1407 * duration field was still an int.
1409 attribute_deprecated
1410 int64_t convergence_duration;
1413 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
1414 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
1416 enum AVSideDataParamChangeFlags {
1417 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
1418 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
1419 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
1420 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
1426 struct AVCodecInternal;
1430 AV_FIELD_PROGRESSIVE,
1431 AV_FIELD_TT, //< Top coded_first, top displayed first
1432 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1433 AV_FIELD_TB, //< Top coded first, bottom displayed first
1434 AV_FIELD_BT, //< Bottom coded first, top displayed first
1438 * main external API structure.
1439 * New fields can be added to the end with minor version bumps.
1440 * Removal, reordering and changes to existing fields require a major
1442 * sizeof(AVCodecContext) must not be used outside libav*.
1444 typedef struct AVCodecContext {
1446 * information on struct for av_log
1447 * - set by avcodec_alloc_context3
1449 const AVClass *av_class;
1450 int log_level_offset;
1452 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1453 const struct AVCodec *codec;
1454 #if FF_API_CODEC_NAME
1456 * @deprecated this field is not used for anything in libavcodec
1458 attribute_deprecated
1459 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;
1478 #if FF_API_STREAM_CODEC_TAG
1480 * @deprecated this field is unused
1482 attribute_deprecated
1483 unsigned int stream_codec_tag;
1489 * Private context used for internal data.
1491 * Unlike priv_data, this is not codec-specific. It is used in general
1492 * libavcodec functions.
1494 struct AVCodecInternal *internal;
1497 * Private data of the user, can be used to carry app specific stuff.
1498 * - encoding: Set by user.
1499 * - decoding: Set by user.
1504 * the average bitrate
1505 * - encoding: Set by user; unused for constant quantizer encoding.
1506 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1511 * number of bits the bitstream is allowed to diverge from the reference.
1512 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1513 * - encoding: Set by user; unused for constant quantizer encoding.
1514 * - decoding: unused
1516 int bit_rate_tolerance;
1519 * Global quality for codecs which cannot change it per frame.
1520 * This should be proportional to MPEG-1/2/4 qscale.
1521 * - encoding: Set by user.
1522 * - decoding: unused
1527 * - encoding: Set by user.
1528 * - decoding: unused
1530 int compression_level;
1531 #define FF_COMPRESSION_DEFAULT -1
1535 * - encoding: Set by user.
1536 * - decoding: Set by user.
1542 * - encoding: Set by user.
1543 * - decoding: Set by user.
1548 * some codecs need / can use extradata like Huffman tables.
1549 * MJPEG: Huffman tables
1550 * rv10: additional flags
1551 * MPEG-4: global headers (they can be in the bitstream or here)
1552 * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
1553 * than extradata_size to avoid problems if it is read with the bitstream reader.
1554 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1555 * - encoding: Set/allocated/freed by libavcodec.
1556 * - decoding: Set/allocated/freed by user.
1562 * This is the fundamental unit of time (in seconds) in terms
1563 * of which frame timestamps are represented. For fixed-fps content,
1564 * timebase should be 1/framerate and timestamp increments should be
1566 * - encoding: MUST be set by user.
1567 * - decoding: the use of this field for decoding is deprecated.
1568 * Use framerate instead.
1570 AVRational time_base;
1573 * For some codecs, the time base is closer to the field rate than the frame rate.
1574 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1575 * if no telecine is used ...
1577 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1579 int ticks_per_frame;
1585 * Number of frames the decoded output will be delayed relative to the
1589 * For encoding, this field is unused (see initial_padding).
1591 * For decoding, this is the number of samples the decoder needs to
1592 * output before the decoder's output is valid. When seeking, you should
1593 * start decoding this many samples prior to your desired seek point.
1595 * - encoding: Set by libavcodec.
1596 * - decoding: Set by libavcodec.
1603 * picture width / height.
1605 * @note Those fields may not match the values of the last
1606 * AVFrame output by avcodec_decode_video2 due frame
1609 * - encoding: MUST be set by user.
1610 * - decoding: May be set by the user before opening the decoder if known e.g.
1611 * from the container. Some decoders will require the dimensions
1612 * to be set by the caller. During decoding, the decoder may
1613 * overwrite those values as required while parsing the data.
1618 * Bitstream width / height, may be different from width/height e.g. when
1619 * the decoded frame is cropped before being output.
1621 * @note Those field may not match the value of the last
1622 * AVFrame output by avcodec_receive_frame() due frame
1625 * - encoding: unused
1626 * - decoding: May be set by the user before opening the decoder if known
1627 * e.g. from the container. During decoding, the decoder may
1628 * overwrite those values as required while parsing the data.
1630 int coded_width, coded_height;
1632 #if FF_API_ASPECT_EXTENDED
1633 #define FF_ASPECT_EXTENDED 15
1637 * the number of pictures in a group of pictures, or 0 for intra_only
1638 * - encoding: Set by user.
1639 * - decoding: unused
1644 * Pixel format, see AV_PIX_FMT_xxx.
1645 * May be set by the demuxer if known from headers.
1646 * May be overridden by the decoder if it knows better.
1648 * @note This field may not match the value of the last
1649 * AVFrame output by avcodec_receive_frame() due frame
1652 * - encoding: Set by user.
1653 * - decoding: Set by user if known, overridden by libavcodec while
1656 enum AVPixelFormat pix_fmt;
1658 #if FF_API_MOTION_EST
1660 * This option does nothing
1661 * @deprecated use codec private options instead
1663 attribute_deprecated int me_method;
1667 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1668 * decoder to draw a horizontal band. It improves cache usage. Not
1669 * all codecs can do that. You must check the codec capabilities
1671 * When multithreading is used, it may be called from multiple threads
1672 * at the same time; threads might draw different parts of the same AVFrame,
1673 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1675 * The function is also used by hardware acceleration APIs.
1676 * It is called at least once during frame decoding to pass
1677 * the data needed for hardware render.
1678 * In that mode instead of pixel data, AVFrame points to
1679 * a structure specific to the acceleration API. The application
1680 * reads the structure and can change some fields to indicate progress
1682 * - encoding: unused
1683 * - decoding: Set by user.
1684 * @param height the height of the slice
1685 * @param y the y position of the slice
1686 * @param type 1->top field, 2->bottom field, 3->frame
1687 * @param offset offset into the AVFrame.data from which the slice should be read
1689 void (*draw_horiz_band)(struct AVCodecContext *s,
1690 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1691 int y, int type, int height);
1694 * callback to negotiate the pixelFormat
1695 * @param fmt is the list of formats which are supported by the codec,
1696 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1697 * The first is always the native one.
1698 * @note The callback may be called again immediately if initialization for
1699 * the selected (hardware-accelerated) pixel format failed.
1700 * @warning Behavior is undefined if the callback returns a value not
1701 * in the fmt list of formats.
1702 * @return the chosen format
1703 * - encoding: unused
1704 * - decoding: Set by user, if not set the native format will be chosen.
1706 enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1709 * maximum number of B-frames between non-B-frames
1710 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1711 * - encoding: Set by user.
1712 * - decoding: unused
1717 * qscale factor between IP and B-frames
1718 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1719 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1720 * - encoding: Set by user.
1721 * - decoding: unused
1723 float b_quant_factor;
1725 #if FF_API_RC_STRATEGY
1726 /** @deprecated use codec private option instead */
1727 attribute_deprecated int rc_strategy;
1728 #define FF_RC_STRATEGY_XVID 1
1731 #if FF_API_PRIVATE_OPT
1732 /** @deprecated use encoder private options instead */
1733 attribute_deprecated
1734 int b_frame_strategy;
1738 * qscale offset between IP and B-frames
1739 * - encoding: Set by user.
1740 * - decoding: unused
1742 float b_quant_offset;
1745 * Size of the frame reordering buffer in the decoder.
1746 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1747 * - encoding: Set by libavcodec.
1748 * - decoding: Set by libavcodec.
1752 #if FF_API_PRIVATE_OPT
1753 /** @deprecated use encoder private options instead */
1754 attribute_deprecated
1759 * qscale factor between P- and I-frames
1760 * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
1761 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1762 * - encoding: Set by user.
1763 * - decoding: unused
1765 float i_quant_factor;
1768 * qscale offset between P and I-frames
1769 * - encoding: Set by user.
1770 * - decoding: unused
1772 float i_quant_offset;
1775 * luminance masking (0-> disabled)
1776 * - encoding: Set by user.
1777 * - decoding: unused
1782 * temporary complexity masking (0-> disabled)
1783 * - encoding: Set by user.
1784 * - decoding: unused
1786 float temporal_cplx_masking;
1789 * spatial complexity masking (0-> disabled)
1790 * - encoding: Set by user.
1791 * - decoding: unused
1793 float spatial_cplx_masking;
1796 * p block masking (0-> disabled)
1797 * - encoding: Set by user.
1798 * - decoding: unused
1803 * darkness masking (0-> disabled)
1804 * - encoding: Set by user.
1805 * - decoding: unused
1811 * - encoding: Set by libavcodec.
1812 * - decoding: Set by user (or 0).
1816 #if FF_API_PRIVATE_OPT
1817 /** @deprecated use encoder private options instead */
1818 attribute_deprecated
1819 int prediction_method;
1820 #define FF_PRED_LEFT 0
1821 #define FF_PRED_PLANE 1
1822 #define FF_PRED_MEDIAN 2
1826 * slice offsets in the frame in bytes
1827 * - encoding: Set/allocated by libavcodec.
1828 * - decoding: Set/allocated by user (or NULL).
1833 * sample aspect ratio (0 if unknown)
1834 * That is the width of a pixel divided by the height of the pixel.
1835 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1836 * - encoding: Set by user.
1837 * - decoding: Set by libavcodec.
1839 AVRational sample_aspect_ratio;
1842 * motion estimation comparison function
1843 * - encoding: Set by user.
1844 * - decoding: unused
1848 * subpixel motion estimation comparison function
1849 * - encoding: Set by user.
1850 * - decoding: unused
1854 * macroblock comparison function (not supported yet)
1855 * - encoding: Set by user.
1856 * - decoding: unused
1860 * interlaced DCT comparison function
1861 * - encoding: Set by user.
1862 * - decoding: unused
1865 #define FF_CMP_SAD 0
1866 #define FF_CMP_SSE 1
1867 #define FF_CMP_SATD 2
1868 #define FF_CMP_DCT 3
1869 #define FF_CMP_PSNR 4
1870 #define FF_CMP_BIT 5
1872 #define FF_CMP_ZERO 7
1873 #define FF_CMP_VSAD 8
1874 #define FF_CMP_VSSE 9
1875 #define FF_CMP_NSSE 10
1876 #define FF_CMP_DCTMAX 13
1877 #define FF_CMP_DCT264 14
1878 #define FF_CMP_CHROMA 256
1881 * ME diamond size & shape
1882 * - encoding: Set by user.
1883 * - decoding: unused
1888 * amount of previous MV predictors (2a+1 x 2a+1 square)
1889 * - encoding: Set by user.
1890 * - decoding: unused
1892 int last_predictor_count;
1894 #if FF_API_PRIVATE_OPT
1895 /** @deprecated use encoder private options instead */
1896 attribute_deprecated
1901 * motion estimation prepass comparison function
1902 * - encoding: Set by user.
1903 * - decoding: unused
1908 * ME prepass diamond size & shape
1909 * - encoding: Set by user.
1910 * - decoding: unused
1916 * - encoding: Set by user.
1917 * - decoding: unused
1919 int me_subpel_quality;
1923 * DTG active format information (additional aspect ratio
1924 * information only used in DVB MPEG-2 transport streams)
1927 * - encoding: unused
1928 * - decoding: Set by decoder.
1929 * @deprecated Deprecated in favor of AVSideData
1931 attribute_deprecated int dtg_active_format;
1932 #define FF_DTG_AFD_SAME 8
1933 #define FF_DTG_AFD_4_3 9
1934 #define FF_DTG_AFD_16_9 10
1935 #define FF_DTG_AFD_14_9 11
1936 #define FF_DTG_AFD_4_3_SP_14_9 13
1937 #define FF_DTG_AFD_16_9_SP_14_9 14
1938 #define FF_DTG_AFD_SP_4_3 15
1939 #endif /* FF_API_AFD */
1942 * maximum motion estimation search range in subpel units
1943 * If 0 then no limit.
1945 * - encoding: Set by user.
1946 * - decoding: unused
1950 #if FF_API_QUANT_BIAS
1952 * @deprecated use encoder private option instead
1954 attribute_deprecated int intra_quant_bias;
1955 #define FF_DEFAULT_QUANT_BIAS 999999
1958 * @deprecated use encoder private option instead
1960 attribute_deprecated int inter_quant_bias;
1965 * - encoding: unused
1966 * - decoding: Set by user.
1969 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1970 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
1971 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1975 * XVideo Motion Acceleration
1976 * - encoding: forbidden
1977 * - decoding: set by decoder
1978 * @deprecated XvMC support is slated for removal.
1980 attribute_deprecated int xvmc_acceleration;
1981 #endif /* FF_API_XVMC */
1984 * macroblock decision mode
1985 * - encoding: Set by user.
1986 * - decoding: unused
1989 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1990 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1991 #define FF_MB_DECISION_RD 2 ///< rate distortion
1994 * custom intra quantization matrix
1995 * - encoding: Set by user, can be NULL.
1996 * - decoding: Set by libavcodec.
1998 uint16_t *intra_matrix;
2001 * custom inter quantization matrix
2002 * - encoding: Set by user, can be NULL.
2003 * - decoding: Set by libavcodec.
2005 uint16_t *inter_matrix;
2007 #if FF_API_PRIVATE_OPT
2008 /** @deprecated use encoder private options instead */
2009 attribute_deprecated
2010 int scenechange_threshold;
2012 /** @deprecated use encoder private options instead */
2013 attribute_deprecated
2014 int noise_reduction;
2019 * @deprecated this field is unused
2021 attribute_deprecated
2025 * @deprecated this field is unused
2027 attribute_deprecated
2032 * precision of the intra DC coefficient - 8
2033 * - encoding: Set by user.
2034 * - decoding: unused
2036 int intra_dc_precision;
2039 * Number of macroblock rows at the top which are skipped.
2040 * - encoding: unused
2041 * - decoding: Set by user.
2046 * Number of macroblock rows at the bottom which are skipped.
2047 * - encoding: unused
2048 * - decoding: Set by user.
2054 * @deprecated use encoder private options instead
2056 attribute_deprecated
2057 float border_masking;
2061 * minimum MB Lagrange multiplier
2062 * - encoding: Set by user.
2063 * - decoding: unused
2068 * maximum MB Lagrange multiplier
2069 * - encoding: Set by user.
2070 * - decoding: unused
2074 #if FF_API_PRIVATE_OPT
2076 * @deprecated use encoder private options instead
2078 attribute_deprecated
2079 int me_penalty_compensation;
2083 * - encoding: Set by user.
2084 * - decoding: unused
2088 #if FF_API_PRIVATE_OPT
2089 /** @deprecated use encoder private options instead */
2090 attribute_deprecated
2096 * - encoding: Set by user.
2097 * - decoding: unused
2102 * number of reference frames
2103 * - encoding: Set by user.
2104 * - decoding: Set by lavc.
2108 #if FF_API_PRIVATE_OPT
2109 /** @deprecated use encoder private options instead */
2110 attribute_deprecated
2114 #if FF_API_UNUSED_MEMBERS
2116 * Multiplied by qscale for each frame and added to scene_change_score.
2117 * - encoding: Set by user.
2118 * - decoding: unused
2120 attribute_deprecated int scenechange_factor;
2124 * Note: Value depends upon the compare function used for fullpel ME.
2125 * - encoding: Set by user.
2126 * - decoding: unused
2130 #if FF_API_PRIVATE_OPT
2131 /** @deprecated use encoder private options instead */
2132 attribute_deprecated
2137 * Chromaticity coordinates of the source primaries.
2138 * - encoding: Set by user
2139 * - decoding: Set by libavcodec
2141 enum AVColorPrimaries color_primaries;
2144 * Color Transfer Characteristic.
2145 * - encoding: Set by user
2146 * - decoding: Set by libavcodec
2148 enum AVColorTransferCharacteristic color_trc;
2151 * YUV colorspace type.
2152 * - encoding: Set by user
2153 * - decoding: Set by libavcodec
2155 enum AVColorSpace colorspace;
2158 * MPEG vs JPEG YUV range.
2159 * - encoding: Set by user
2160 * - decoding: Set by libavcodec
2162 enum AVColorRange color_range;
2165 * This defines the location of chroma samples.
2166 * - encoding: Set by user
2167 * - decoding: Set by libavcodec
2169 enum AVChromaLocation chroma_sample_location;
2173 * Indicates number of picture subdivisions. Used for parallelized
2175 * - encoding: Set by user
2176 * - decoding: unused
2181 * - encoding: set by libavcodec
2182 * - decoding: Set by libavcodec
2184 enum AVFieldOrder field_order;
2187 int sample_rate; ///< samples per second
2188 int channels; ///< number of audio channels
2191 * audio sample format
2192 * - encoding: Set by user.
2193 * - decoding: Set by libavcodec.
2195 enum AVSampleFormat sample_fmt; ///< sample format
2197 /* The following data should not be initialized. */
2199 * Number of samples per channel in an audio frame.
2201 * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
2202 * except the last must contain exactly frame_size samples per channel.
2203 * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
2204 * frame size is not restricted.
2205 * - decoding: may be set by some decoders to indicate constant frame size
2210 * Frame counter, set by libavcodec.
2212 * - decoding: total number of frames returned from the decoder so far.
2213 * - encoding: total number of frames passed to the encoder so far.
2215 * @note the counter is not incremented if encoding/decoding resulted in
2221 * number of bytes per packet if constant and known or 0
2222 * Used by some WAV based audio codecs.
2227 * Audio cutoff bandwidth (0 means "automatic")
2228 * - encoding: Set by user.
2229 * - decoding: unused
2234 * Audio channel layout.
2235 * - encoding: set by user.
2236 * - decoding: set by libavcodec.
2238 uint64_t channel_layout;
2241 * Request decoder to use this channel layout if it can (0 for default)
2242 * - encoding: unused
2243 * - decoding: Set by user.
2245 uint64_t request_channel_layout;
2248 * Type of service that the audio stream conveys.
2249 * - encoding: Set by user.
2250 * - decoding: Set by libavcodec.
2252 enum AVAudioServiceType audio_service_type;
2255 * Used to request a sample format from the decoder.
2256 * - encoding: unused.
2257 * - decoding: Set by user.
2259 enum AVSampleFormat request_sample_fmt;
2262 * This callback is called at the beginning of each frame to get data
2263 * buffer(s) for it. There may be one contiguous buffer for all the data or
2264 * there may be a buffer per each data plane or anything in between. What
2265 * this means is, you may set however many entries in buf[] you feel necessary.
2266 * Each buffer must be reference-counted using the AVBuffer API (see description
2269 * The following fields will be set in the frame before this callback is
2272 * - width, height (video only)
2273 * - sample_rate, channel_layout, nb_samples (audio only)
2274 * Their values may differ from the corresponding values in
2275 * AVCodecContext. This callback must use the frame values, not the codec
2276 * context values, to calculate the required buffer size.
2278 * This callback must fill the following fields in the frame:
2282 * * if the data is planar audio with more than 8 channels, then this
2283 * callback must allocate and fill extended_data to contain all pointers
2284 * to all data planes. data[] must hold as many pointers as it can.
2285 * extended_data must be allocated with av_malloc() and will be freed in
2287 * * otherwise extended_data must point to data
2288 * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
2289 * the frame's data and extended_data pointers must be contained in these. That
2290 * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
2291 * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
2292 * and av_buffer_ref().
2293 * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
2294 * this callback and filled with the extra buffers if there are more
2295 * buffers than buf[] can hold. extended_buf will be freed in
2298 * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
2299 * avcodec_default_get_buffer2() instead of providing buffers allocated by
2302 * Each data plane must be aligned to the maximum required by the target
2305 * @see avcodec_default_get_buffer2()
2309 * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
2310 * (read and/or written to if it is writable) later by libavcodec.
2312 * avcodec_align_dimensions2() should be used to find the required width and
2313 * height, as they normally need to be rounded up to the next multiple of 16.
2315 * If frame multithreading is used and thread_safe_callbacks is set,
2316 * this callback may be called from a different thread, but not from more
2317 * than one at once. Does not need to be reentrant.
2319 * @see avcodec_align_dimensions2()
2323 * Decoders request a buffer of a particular size by setting
2324 * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
2325 * however, utilize only part of the buffer by setting AVFrame.nb_samples
2326 * to a smaller value in the output frame.
2328 * As a convenience, av_samples_get_buffer_size() and
2329 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
2330 * functions to find the required data size and to fill data pointers and
2331 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2332 * since all planes must be the same size.
2334 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2336 * - encoding: unused
2337 * - decoding: Set by libavcodec, user can override.
2339 int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
2342 * If non-zero, the decoded audio and video frames returned from
2343 * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
2344 * and are valid indefinitely. The caller must free them with
2345 * av_frame_unref() when they are not needed anymore.
2346 * Otherwise, the decoded frames must not be freed by the caller and are
2347 * only valid until the next decode call.
2349 * This is always automatically enabled if avcodec_receive_frame() is used.
2351 * - encoding: unused
2352 * - decoding: set by the caller before avcodec_open2().
2354 attribute_deprecated int refcounted_frames;
2356 /* - encoding parameters */
2357 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2358 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2362 * - encoding: Set by user.
2363 * - decoding: unused
2369 * - encoding: Set by user.
2370 * - decoding: unused
2375 * maximum quantizer difference between frames
2376 * - encoding: Set by user.
2377 * - decoding: unused
2383 * @deprecated use encoder private options instead
2385 attribute_deprecated
2388 attribute_deprecated
2390 attribute_deprecated
2395 * decoder bitstream buffer size
2396 * - encoding: Set by user.
2397 * - decoding: unused
2402 * ratecontrol override, see RcOverride
2403 * - encoding: Allocated/set/freed by user.
2404 * - decoding: unused
2406 int rc_override_count;
2407 RcOverride *rc_override;
2411 * @deprecated use encoder private options instead
2413 attribute_deprecated
2419 * - encoding: Set by user.
2420 * - decoding: unused
2426 * - encoding: Set by user.
2427 * - decoding: unused
2433 * @deprecated use encoder private options instead
2435 attribute_deprecated
2436 float rc_buffer_aggressivity;
2438 attribute_deprecated
2439 float rc_initial_cplx;
2443 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2444 * - encoding: Set by user.
2445 * - decoding: unused.
2447 float rc_max_available_vbv_use;
2450 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2451 * - encoding: Set by user.
2452 * - decoding: unused.
2454 float rc_min_vbv_overflow_use;
2457 * Number of bits which should be loaded into the rc buffer before decoding starts.
2458 * - encoding: Set by user.
2459 * - decoding: unused
2461 int rc_initial_buffer_occupancy;
2463 #if FF_API_CODER_TYPE
2464 #define FF_CODER_TYPE_VLC 0
2465 #define FF_CODER_TYPE_AC 1
2466 #define FF_CODER_TYPE_RAW 2
2467 #define FF_CODER_TYPE_RLE 3
2468 #if FF_API_UNUSED_MEMBERS
2469 #define FF_CODER_TYPE_DEFLATE 4
2470 #endif /* FF_API_UNUSED_MEMBERS */
2472 * @deprecated use encoder private options instead
2474 attribute_deprecated
2476 #endif /* FF_API_CODER_TYPE */
2478 #if FF_API_PRIVATE_OPT
2479 /** @deprecated use encoder private options instead */
2480 attribute_deprecated
2486 * @deprecated use encoder private options instead
2488 attribute_deprecated
2492 * @deprecated use encoder private options instead
2494 attribute_deprecated
2498 #if FF_API_PRIVATE_OPT
2499 /** @deprecated use encoder private options instead */
2500 attribute_deprecated
2501 int frame_skip_threshold;
2503 /** @deprecated use encoder private options instead */
2504 attribute_deprecated
2505 int frame_skip_factor;
2507 /** @deprecated use encoder private options instead */
2508 attribute_deprecated
2511 /** @deprecated use encoder private options instead */
2512 attribute_deprecated
2514 #endif /* FF_API_PRIVATE_OPT */
2517 * trellis RD quantization
2518 * - encoding: Set by user.
2519 * - decoding: unused
2523 #if FF_API_PRIVATE_OPT
2524 /** @deprecated use encoder private options instead */
2525 attribute_deprecated
2526 int min_prediction_order;
2528 /** @deprecated use encoder private options instead */
2529 attribute_deprecated
2530 int max_prediction_order;
2532 /** @deprecated use encoder private options instead */
2533 attribute_deprecated
2534 int64_t timecode_frame_start;
2537 #if FF_API_RTP_CALLBACK
2539 * @deprecated unused
2541 /* The RTP callback: This function is called */
2542 /* every time the encoder has a packet to send. */
2543 /* It depends on the encoder if the data starts */
2544 /* with a Start Code (it should). H.263 does. */
2545 /* mb_nb contains the number of macroblocks */
2546 /* encoded in the RTP payload. */
2547 attribute_deprecated
2548 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2551 #if FF_API_PRIVATE_OPT
2552 /** @deprecated use encoder private options instead */
2553 attribute_deprecated
2554 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2555 /* do its best to deliver a chunk with size */
2556 /* below rtp_payload_size, the chunk will start */
2557 /* with a start code on some codecs like H.263. */
2558 /* This doesn't take account of any particular */
2559 /* headers inside the transmitted RTP payload. */
2562 #if FF_API_STAT_BITS
2563 /* statistics, used for 2-pass encoding */
2564 attribute_deprecated
2566 attribute_deprecated
2568 attribute_deprecated
2570 attribute_deprecated
2572 attribute_deprecated
2574 attribute_deprecated
2576 attribute_deprecated
2578 attribute_deprecated
2581 /** @deprecated this field is unused */
2582 attribute_deprecated
2587 * pass1 encoding statistics output buffer
2588 * - encoding: Set by libavcodec.
2589 * - decoding: unused
2594 * pass2 encoding statistics input buffer
2595 * Concatenated stuff from stats_out of pass1 should be placed here.
2596 * - encoding: Allocated/set/freed by user.
2597 * - decoding: unused
2602 * Work around bugs in encoders which sometimes cannot be detected automatically.
2603 * - encoding: Set by user
2604 * - decoding: Set by user
2606 int workaround_bugs;
2607 #define FF_BUG_AUTODETECT 1 ///< autodetection
2608 #if FF_API_OLD_MSMPEG4
2609 #define FF_BUG_OLD_MSMPEG4 2
2611 #define FF_BUG_XVID_ILACE 4
2612 #define FF_BUG_UMP4 8
2613 #define FF_BUG_NO_PADDING 16
2614 #define FF_BUG_AMV 32
2616 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2618 #define FF_BUG_QPEL_CHROMA 64
2619 #define FF_BUG_STD_QPEL 128
2620 #define FF_BUG_QPEL_CHROMA2 256
2621 #define FF_BUG_DIRECT_BLOCKSIZE 512
2622 #define FF_BUG_EDGE 1024
2623 #define FF_BUG_HPEL_CHROMA 2048
2624 #define FF_BUG_DC_CLIP 4096
2625 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2626 #define FF_BUG_TRUNCATED 16384
2629 * strictly follow the standard (MPEG-4, ...).
2630 * - encoding: Set by user.
2631 * - decoding: Set by user.
2632 * Setting this to STRICT or higher means the encoder and decoder will
2633 * generally do stupid things, whereas setting it to unofficial or lower
2634 * will mean the encoder might produce output that is not supported by all
2635 * spec-compliant decoders. Decoders don't differentiate between normal,
2636 * unofficial and experimental (that is, they always try to decode things
2637 * when they can) unless they are explicitly asked to behave stupidly
2638 * (=strictly conform to the specs)
2640 int strict_std_compliance;
2641 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2642 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2643 #define FF_COMPLIANCE_NORMAL 0
2644 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2645 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2648 * error concealment flags
2649 * - encoding: unused
2650 * - decoding: Set by user.
2652 int error_concealment;
2653 #define FF_EC_GUESS_MVS 1
2654 #define FF_EC_DEBLOCK 2
2658 * - encoding: Set by user.
2659 * - decoding: Set by user.
2662 #define FF_DEBUG_PICT_INFO 1
2663 #define FF_DEBUG_RC 2
2664 #define FF_DEBUG_BITSTREAM 4
2665 #define FF_DEBUG_MB_TYPE 8
2666 #define FF_DEBUG_QP 16
2669 * @deprecated this option does nothing
2671 #define FF_DEBUG_MV 32
2673 #define FF_DEBUG_DCT_COEFF 0x00000040
2674 #define FF_DEBUG_SKIP 0x00000080
2675 #define FF_DEBUG_STARTCODE 0x00000100
2676 #if FF_API_UNUSED_MEMBERS
2677 #define FF_DEBUG_PTS 0x00000200
2678 #endif /* FF_API_UNUSED_MEMBERS */
2679 #define FF_DEBUG_ER 0x00000400
2680 #define FF_DEBUG_MMCO 0x00000800
2681 #define FF_DEBUG_BUGS 0x00001000
2683 #define FF_DEBUG_VIS_QP 0x00002000
2684 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2686 #define FF_DEBUG_BUFFERS 0x00008000
2687 #define FF_DEBUG_THREADS 0x00010000
2691 * @deprecated this option does not have any effect
2693 attribute_deprecated
2695 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames
2696 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames
2697 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
2701 * Error recognition; may misdetect some more or less valid parts as errors.
2702 * - encoding: unused
2703 * - decoding: Set by user.
2705 int err_recognition;
2708 * Verify checksums embedded in the bitstream (could be of either encoded or
2709 * decoded data, depending on the codec) and print an error message on mismatch.
2710 * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
2711 * decoder returning an error.
2713 #define AV_EF_CRCCHECK (1<<0)
2714 #define AV_EF_BITSTREAM (1<<1)
2715 #define AV_EF_BUFFER (1<<2)
2716 #define AV_EF_EXPLODE (1<<3)
2719 * opaque 64-bit number (generally a PTS) that will be reordered and
2720 * output in AVFrame.reordered_opaque
2721 * - encoding: unused
2722 * - decoding: Set by user.
2724 int64_t reordered_opaque;
2727 * Hardware accelerator in use
2728 * - encoding: unused.
2729 * - decoding: Set by libavcodec
2731 struct AVHWAccel *hwaccel;
2734 * Hardware accelerator context.
2735 * For some hardware accelerators, a global context needs to be
2736 * provided by the user. In that case, this holds display-dependent
2737 * data Libav cannot instantiate itself. Please refer to the
2738 * Libav HW accelerator documentation to know how to fill this
2739 * is. e.g. for VA API, this is a struct vaapi_context.
2740 * - encoding: unused
2741 * - decoding: Set by user
2743 void *hwaccel_context;
2747 * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
2748 * - decoding: unused
2750 uint64_t error[AV_NUM_DATA_POINTERS];
2753 * DCT algorithm, see FF_DCT_* below
2754 * - encoding: Set by user.
2755 * - decoding: unused
2758 #define FF_DCT_AUTO 0
2759 #define FF_DCT_FASTINT 1
2760 #define FF_DCT_INT 2
2761 #define FF_DCT_MMX 3
2762 #define FF_DCT_ALTIVEC 5
2763 #define FF_DCT_FAAN 6
2766 * IDCT algorithm, see FF_IDCT_* below.
2767 * - encoding: Set by user.
2768 * - decoding: Set by user.
2771 #define FF_IDCT_AUTO 0
2772 #define FF_IDCT_INT 1
2773 #define FF_IDCT_SIMPLE 2
2774 #define FF_IDCT_SIMPLEMMX 3
2775 #define FF_IDCT_ARM 7
2776 #define FF_IDCT_ALTIVEC 8
2778 #define FF_IDCT_SH4 9
2780 #define FF_IDCT_SIMPLEARM 10
2781 #if FF_API_UNUSED_MEMBERS
2782 #define FF_IDCT_IPP 13
2783 #endif /* FF_API_UNUSED_MEMBERS */
2784 #define FF_IDCT_XVID 14
2785 #if FF_API_IDCT_XVIDMMX
2786 #define FF_IDCT_XVIDMMX 14
2787 #endif /* FF_API_IDCT_XVIDMMX */
2788 #define FF_IDCT_SIMPLEARMV5TE 16
2789 #define FF_IDCT_SIMPLEARMV6 17
2790 #if FF_API_ARCH_SPARC
2791 #define FF_IDCT_SIMPLEVIS 18
2793 #define FF_IDCT_FAAN 20
2794 #define FF_IDCT_SIMPLENEON 22
2795 #if FF_API_ARCH_ALPHA
2796 #define FF_IDCT_SIMPLEALPHA 23
2800 * bits per sample/pixel from the demuxer (needed for huffyuv).
2801 * - encoding: Set by libavcodec.
2802 * - decoding: Set by user.
2804 int bits_per_coded_sample;
2807 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2808 * - encoding: set by user.
2809 * - decoding: set by libavcodec.
2811 int bits_per_raw_sample;
2815 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2816 * - encoding: unused
2817 * - decoding: Set by user.
2819 * @deprecated use decoder private options instead
2821 attribute_deprecated int lowres;
2824 #if FF_API_CODED_FRAME
2826 * the picture in the bitstream
2827 * - encoding: Set by libavcodec.
2828 * - decoding: unused
2830 * @deprecated use the quality factor packet side data instead
2832 attribute_deprecated AVFrame *coded_frame;
2837 * is used to decide how many independent tasks should be passed to execute()
2838 * - encoding: Set by user.
2839 * - decoding: Set by user.
2844 * Which multithreading methods to use.
2845 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2846 * so clients which cannot provide future frames should not use it.
2848 * - encoding: Set by user, otherwise the default is used.
2849 * - decoding: Set by user, otherwise the default is used.
2852 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2853 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2856 * Which multithreading methods are in use by the codec.
2857 * - encoding: Set by libavcodec.
2858 * - decoding: Set by libavcodec.
2860 int active_thread_type;
2863 * Set by the client if its custom get_buffer() callback can be called
2864 * synchronously from another thread, which allows faster multithreaded decoding.
2865 * draw_horiz_band() will be called from other threads regardless of this setting.
2866 * Ignored if the default get_buffer() is used.
2867 * - encoding: Set by user.
2868 * - decoding: Set by user.
2870 int thread_safe_callbacks;
2873 * The codec may call this to execute several independent things.
2874 * It will return only after finishing all tasks.
2875 * The user may replace this with some multithreaded implementation,
2876 * the default implementation will execute the parts serially.
2877 * @param count the number of things to execute
2878 * - encoding: Set by libavcodec, user can override.
2879 * - decoding: Set by libavcodec, user can override.
2881 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2884 * The codec may call this to execute several independent things.
2885 * It will return only after finishing all tasks.
2886 * The user may replace this with some multithreaded implementation,
2887 * the default implementation will execute the parts serially.
2888 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2889 * @param c context passed also to func
2890 * @param count the number of things to execute
2891 * @param arg2 argument passed unchanged to func
2892 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2893 * @param func function that will be called count times, with jobnr from 0 to count-1.
2894 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2895 * two instances of func executing at the same time will have the same threadnr.
2896 * @return always 0 currently, but code should handle a future improvement where when any call to func
2897 * returns < 0 no further calls to func may be done and < 0 is returned.
2898 * - encoding: Set by libavcodec, user can override.
2899 * - decoding: Set by libavcodec, user can override.
2901 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2904 * noise vs. sse weight for the nsse comparison function
2905 * - encoding: Set by user.
2906 * - decoding: unused
2912 * - encoding: Set by user.
2913 * - decoding: Set by libavcodec.
2916 #define FF_PROFILE_UNKNOWN -99
2917 #define FF_PROFILE_RESERVED -100
2919 #define FF_PROFILE_AAC_MAIN 0
2920 #define FF_PROFILE_AAC_LOW 1
2921 #define FF_PROFILE_AAC_SSR 2
2922 #define FF_PROFILE_AAC_LTP 3
2923 #define FF_PROFILE_AAC_HE 4
2924 #define FF_PROFILE_AAC_HE_V2 28
2925 #define FF_PROFILE_AAC_LD 22
2926 #define FF_PROFILE_AAC_ELD 38
2927 #define FF_PROFILE_MPEG2_AAC_LOW 128
2928 #define FF_PROFILE_MPEG2_AAC_HE 131
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
2935 #define FF_PROFILE_DTS_EXPRESS 70
2937 #define FF_PROFILE_MPEG2_422 0
2938 #define FF_PROFILE_MPEG2_HIGH 1
2939 #define FF_PROFILE_MPEG2_SS 2
2940 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2941 #define FF_PROFILE_MPEG2_MAIN 4
2942 #define FF_PROFILE_MPEG2_SIMPLE 5
2944 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2945 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2947 #define FF_PROFILE_H264_BASELINE 66
2948 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2949 #define FF_PROFILE_H264_MAIN 77
2950 #define FF_PROFILE_H264_EXTENDED 88
2951 #define FF_PROFILE_H264_HIGH 100
2952 #define FF_PROFILE_H264_HIGH_10 110
2953 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2954 #define FF_PROFILE_H264_MULTIVIEW_HIGH 118
2955 #define FF_PROFILE_H264_HIGH_422 122
2956 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2957 #define FF_PROFILE_H264_STEREO_HIGH 128
2958 #define FF_PROFILE_H264_HIGH_444 144
2959 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2960 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2961 #define FF_PROFILE_H264_CAVLC_444 44
2963 #define FF_PROFILE_VC1_SIMPLE 0
2964 #define FF_PROFILE_VC1_MAIN 1
2965 #define FF_PROFILE_VC1_COMPLEX 2
2966 #define FF_PROFILE_VC1_ADVANCED 3
2968 #define FF_PROFILE_MPEG4_SIMPLE 0
2969 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2970 #define FF_PROFILE_MPEG4_CORE 2
2971 #define FF_PROFILE_MPEG4_MAIN 3
2972 #define FF_PROFILE_MPEG4_N_BIT 4
2973 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2974 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2975 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2976 #define FF_PROFILE_MPEG4_HYBRID 8
2977 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2978 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2979 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2980 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2981 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2982 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2983 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2985 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
2986 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
2987 #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
2988 #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
2989 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
2991 #define FF_PROFILE_VP9_0 0
2992 #define FF_PROFILE_VP9_1 1
2993 #define FF_PROFILE_VP9_2 2
2994 #define FF_PROFILE_VP9_3 3
2996 #define FF_PROFILE_HEVC_MAIN 1
2997 #define FF_PROFILE_HEVC_MAIN_10 2
2998 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
2999 #define FF_PROFILE_HEVC_REXT 4
3003 * - encoding: Set by user.
3004 * - decoding: Set by libavcodec.
3007 #define FF_LEVEL_UNKNOWN -99
3010 * - encoding: unused
3011 * - decoding: Set by user.
3013 enum AVDiscard skip_loop_filter;
3016 * - encoding: unused
3017 * - decoding: Set by user.
3019 enum AVDiscard skip_idct;
3022 * - encoding: unused
3023 * - decoding: Set by user.
3025 enum AVDiscard skip_frame;
3028 * Header containing style information for text subtitles.
3029 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3030 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3031 * the Format line following. It shouldn't include any Dialogue line.
3032 * - encoding: Set/allocated/freed by user (before avcodec_open2())
3033 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3035 uint8_t *subtitle_header;
3036 int subtitle_header_size;
3038 #if FF_API_ERROR_RATE
3040 * @deprecated use the 'error_rate' private AVOption of the mpegvideo
3043 attribute_deprecated
3047 #if FF_API_VBV_DELAY
3049 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3050 * Used for compliant TS muxing.
3051 * - encoding: Set by libavcodec.
3052 * - decoding: unused.
3053 * @deprecated this value is now exported as a part of
3054 * AV_PKT_DATA_CPB_PROPERTIES packet side data
3056 attribute_deprecated
3060 #if FF_API_SIDEDATA_ONLY_PKT
3062 * Encoding only and set by default. Allow encoders to output packets
3063 * that do not contain any encoded data, only side data.
3065 * Some encoders need to output such packets, e.g. to update some stream
3066 * parameters at the end of encoding.
3068 * @deprecated this field disables the default behaviour and
3069 * it is kept only for compatibility.
3071 attribute_deprecated
3072 int side_data_only_packets;
3076 * Audio only. The number of "priming" samples (padding) inserted by the
3077 * encoder at the beginning of the audio. I.e. this number of leading
3078 * decoded samples must be discarded by the caller to get the original audio
3079 * without leading padding.
3081 * - decoding: unused
3082 * - encoding: Set by libavcodec. The timestamps on the output packets are
3083 * adjusted by the encoder so that they always refer to the
3084 * first sample of the data actually contained in the packet,
3085 * including any added padding. E.g. if the timebase is
3086 * 1/samplerate and the timestamp of the first input sample is
3087 * 0, the timestamp of the first output packet will be
3090 int initial_padding;
3093 * - decoding: For codecs that store a framerate value in the compressed
3094 * bitstream, the decoder may export it here. { 0, 1} when
3096 * - encoding: May be used to signal the framerate of CFR content to an
3099 AVRational framerate;
3102 * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
3103 * - encoding: unused.
3104 * - decoding: Set by libavcodec before calling get_format()
3106 enum AVPixelFormat sw_pix_fmt;
3109 * Additional data associated with the entire coded stream.
3111 * - decoding: unused
3112 * - encoding: may be set by libavcodec after avcodec_open2().
3114 AVPacketSideData *coded_side_data;
3115 int nb_coded_side_data;
3118 * A reference to the AVHWFramesContext describing the input (for encoding)
3119 * or output (decoding) frames. The reference is set by the caller and
3120 * afterwards owned (and freed) by libavcodec - it should never be read by
3121 * the caller after being set.
3123 * - decoding: This field should be set by the caller from the get_format()
3124 * callback. The previous reference (if any) will always be
3125 * unreffed by libavcodec before the get_format() call.
3127 * If the default get_buffer2() is used with a hwaccel pixel
3128 * format, then this AVHWFramesContext will be used for
3129 * allocating the frame buffers.
3131 * - encoding: For hardware encoders configured to use a hwaccel pixel
3132 * format, this field should be set by the caller to a reference
3133 * to the AVHWFramesContext describing input frames.
3134 * AVHWFramesContext.format must be equal to
3135 * AVCodecContext.pix_fmt.
3137 * This field should be set before avcodec_open2() is called.
3139 AVBufferRef *hw_frames_ctx;
3142 * Video decoding only. Certain video codecs support cropping, meaning that
3143 * only a sub-rectangle of the decoded frame is intended for display. This
3144 * option controls how cropping is handled by libavcodec.
3146 * When set to 1 (the default), libavcodec will apply cropping internally.
3147 * I.e. it will modify the output frame width/height fields and offset the
3148 * data pointers (only by as much as possible while preserving alignment, or
3149 * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
3150 * the frames output by the decoder refer only to the cropped area. The
3151 * crop_* fields of the output frames will be zero.
3153 * When set to 0, the width/height fields of the output frames will be set
3154 * to the coded dimensions and the crop_* fields will describe the cropping
3155 * rectangle. Applying the cropping is left to the caller.
3157 * @warning When hardware acceleration with opaque output frames is used,
3158 * libavcodec is unable to apply cropping from the top/left border.
3160 * @note when this option is set to zero, the width/height fields of the
3161 * AVCodecContext and output AVFrames have different meanings. The codec
3162 * context fields store display dimensions (with the coded dimensions in
3163 * coded_width/height), while the frame fields store the coded dimensions
3164 * (with the display dimensions being determined by the crop_* fields).
3169 * A reference to the AVHWDeviceContext describing the device which will
3170 * be used by a hardware encoder/decoder. The reference is set by the
3171 * caller and afterwards owned (and freed) by libavcodec.
3173 * This should be used if either the codec device does not require
3174 * hardware frames or any that are used are to be allocated internally by
3175 * libavcodec. If the user wishes to supply any of the frames used as
3176 * encoder input or decoder output then hw_frames_ctx should be used
3177 * instead. When hw_frames_ctx is set in get_format() for a decoder, this
3178 * field will be ignored while decoding the associated stream segment, but
3179 * may again be used on a following one after another get_format() call.
3181 * For both encoders and decoders this field should be set before
3182 * avcodec_open2() is called and must not be written to thereafter.
3184 * Note that some decoders may require this field to be set initially in
3185 * order to support hw_frames_ctx at all - in that case, all frames
3186 * contexts used must be created on the same device.
3188 AVBufferRef *hw_device_ctx;
3191 * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated
3192 * decoding (if active).
3193 * - encoding: unused
3194 * - decoding: Set by user (either before avcodec_open2(), or in the
3195 * AVCodecContext.get_format callback)
3203 typedef struct AVProfile {
3205 const char *name; ///< short name for the profile
3208 typedef struct AVCodecDefault AVCodecDefault;
3215 typedef struct AVCodec {
3217 * Name of the codec implementation.
3218 * The name is globally unique among encoders and among decoders (but an
3219 * encoder and a decoder can share the same name).
3220 * This is the primary way to find a codec from the user perspective.
3224 * Descriptive name for the codec, meant to be more human readable than name.
3225 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3227 const char *long_name;
3228 enum AVMediaType type;
3231 * Codec capabilities.
3232 * see AV_CODEC_CAP_*
3235 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3236 const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3237 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3238 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3239 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3241 attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
3243 const AVClass *priv_class; ///< AVClass for the private context
3244 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3246 /*****************************************************************
3247 * No fields below this line are part of the public API. They
3248 * may not be used outside of libavcodec and can be changed and
3250 * New public fields should be added right above.
3251 *****************************************************************
3254 struct AVCodec *next;
3256 * @name Frame-level threading support functions
3260 * If defined, called on thread contexts when they are created.
3261 * If the codec allocates writable tables in init(), re-allocate them here.
3262 * priv_data will be set to a copy of the original.
3264 int (*init_thread_copy)(AVCodecContext *);
3266 * Copy necessary context variables from a previous thread context to the current one.
3267 * If not defined, the next thread will start automatically; otherwise, the codec
3268 * must call ff_thread_finish_setup().
3270 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3272 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
3276 * Private codec-specific defaults.
3278 const AVCodecDefault *defaults;
3281 * Initialize codec static data, called from avcodec_register().
3283 void (*init_static_data)(struct AVCodec *codec);
3285 int (*init)(AVCodecContext *);
3286 int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
3287 const struct AVSubtitle *sub);
3289 * Encode data to an AVPacket.
3291 * @param avctx codec context
3292 * @param avpkt output AVPacket (may contain a user-provided buffer)
3293 * @param[in] frame AVFrame containing the raw data to be encoded
3294 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3295 * non-empty packet was returned in avpkt.
3296 * @return 0 on success, negative error code on failure
3298 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3299 int *got_packet_ptr);
3300 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3301 int (*close)(AVCodecContext *);
3303 * Encode API with decoupled packet/frame dataflow. The API is the
3304 * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except
3306 * - never called if the codec is closed or the wrong type,
3307 * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent,
3308 * - only one drain frame is ever passed down,
3310 int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame);
3311 int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt);
3314 * Decode API with decoupled packet/frame dataflow. This function is called
3315 * to get one output frame. It should call ff_decode_get_packet() to obtain
3318 int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame);
3321 * Will be called when seeking
3323 void (*flush)(AVCodecContext *);
3325 * Internal codec capabilities.
3326 * See FF_CODEC_CAP_* in internal.h
3331 * Decoding only, a comma-separated list of bitstream filters to apply to
3332 * packets before decoding.
3338 * @defgroup lavc_hwaccel AVHWAccel
3341 typedef struct AVHWAccel {
3343 * Name of the hardware accelerated codec.
3344 * The name is globally unique among encoders and among decoders (but an
3345 * encoder and a decoder can share the same name).
3350 * Type of codec implemented by the hardware accelerator.
3352 * See AVMEDIA_TYPE_xxx
3354 enum AVMediaType type;
3357 * Codec implemented by the hardware accelerator.
3359 * See AV_CODEC_ID_xxx
3364 * Supported pixel format.
3366 * Only hardware accelerated formats are supported here.
3368 enum AVPixelFormat pix_fmt;
3371 * Hardware accelerated codec capabilities.
3372 * see FF_HWACCEL_CODEC_CAP_*
3376 /*****************************************************************
3377 * No fields below this line are part of the public API. They
3378 * may not be used outside of libavcodec and can be changed and
3380 * New public fields should be added right above.
3381 *****************************************************************
3383 struct AVHWAccel *next;
3386 * Allocate a custom buffer
3388 int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
3391 * Called at the beginning of each frame or field picture.
3393 * Meaningful frame information (codec specific) is guaranteed to
3394 * be parsed at this point. This function is mandatory.
3396 * Note that buf can be NULL along with buf_size set to 0.
3397 * Otherwise, this means the whole frame is available at this point.
3399 * @param avctx the codec context
3400 * @param buf the frame data buffer base
3401 * @param buf_size the size of the frame in bytes
3402 * @return zero if successful, a negative value otherwise
3404 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3407 * Callback for each slice.
3409 * Meaningful slice information (codec specific) is guaranteed to
3410 * be parsed at this point. This function is mandatory.
3412 * @param avctx the codec context
3413 * @param buf the slice data buffer base
3414 * @param buf_size the size of the slice in bytes
3415 * @return zero if successful, a negative value otherwise
3417 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3420 * Called at the end of each frame or field picture.
3422 * The whole picture is parsed at this point and can now be sent
3423 * to the hardware accelerator. This function is mandatory.
3425 * @param avctx the codec context
3426 * @return zero if successful, a negative value otherwise
3428 int (*end_frame)(AVCodecContext *avctx);
3431 * Size of per-frame hardware accelerator private data.
3433 * Private data is allocated with av_mallocz() before
3434 * AVCodecContext.get_buffer() and deallocated after
3435 * AVCodecContext.release_buffer().
3437 int frame_priv_data_size;
3440 * Initialize the hwaccel private data.
3442 * This will be called from ff_get_format(), after hwaccel and
3443 * hwaccel_context are set and the hwaccel private data in AVCodecInternal
3446 int (*init)(AVCodecContext *avctx);
3449 * Uninitialize the hwaccel private data.
3451 * This will be called from get_format() or avcodec_close(), after hwaccel
3452 * and hwaccel_context are already uninitialized.
3454 int (*uninit)(AVCodecContext *avctx);
3457 * Size of the private data to allocate in
3458 * AVCodecInternal.hwaccel_priv_data.
3463 * Internal hwaccel capabilities.
3469 * Hardware acceleration should be used for decoding even if the codec level
3470 * used is unknown or higher than the maximum supported level reported by the
3473 #define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)
3476 * Hardware acceleration can output YUV pixel formats with a different chroma
3477 * sampling than 4:2:0 and/or other than 8 bits per component.
3479 #define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)
3485 #if FF_API_AVPICTURE
3487 * @defgroup lavc_picture AVPicture
3489 * Functions for working with AVPicture
3494 * four components are given, that's all.
3495 * the last component is alpha
3496 * @deprecated Use the imgutils functions
3498 typedef struct AVPicture {
3499 attribute_deprecated
3500 uint8_t *data[AV_NUM_DATA_POINTERS];
3501 attribute_deprecated
3502 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
3510 #define AVPALETTE_SIZE 1024
3511 #define AVPALETTE_COUNT 256
3513 enum AVSubtitleType {
3516 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
3519 * Plain text, the text field must be set by the decoder and is
3520 * authoritative. ass and pict fields may contain approximations.
3525 * Formatted text, the ass field must be set by the decoder and is
3526 * authoritative. pict and text fields may contain approximations.
3531 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
3533 typedef struct AVSubtitleRect {
3534 int x; ///< top left corner of pict, undefined when pict is not set
3535 int y; ///< top left corner of pict, undefined when pict is not set
3536 int w; ///< width of pict, undefined when pict is not set
3537 int h; ///< height of pict, undefined when pict is not set
3538 int nb_colors; ///< number of colors in pict, undefined when pict is not set
3540 #if FF_API_AVPICTURE
3542 * @deprecated unused
3544 attribute_deprecated
3548 * data+linesize for the bitmap of this subtitle.
3549 * Can be set for text/ass as well once they are rendered.
3554 enum AVSubtitleType type;
3556 char *text; ///< 0 terminated plain UTF-8 text
3559 * 0 terminated ASS/SSA compatible event line.
3560 * The presentation of this is unaffected by the other values in this
3567 typedef struct AVSubtitle {
3568 uint16_t format; /* 0 = graphics */
3569 uint32_t start_display_time; /* relative to packet pts, in ms */
3570 uint32_t end_display_time; /* relative to packet pts, in ms */
3572 AVSubtitleRect **rects;
3573 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3577 * This struct describes the properties of an encoded stream.
3579 * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
3580 * be allocated with avcodec_parameters_alloc() and freed with
3581 * avcodec_parameters_free().
3583 typedef struct AVCodecParameters {
3585 * General type of the encoded data.
3587 enum AVMediaType codec_type;
3589 * Specific type of the encoded data (the codec used).
3591 enum AVCodecID codec_id;
3593 * Additional information about the codec (corresponds to the AVI FOURCC).
3598 * Extra binary data needed for initializing the decoder, codec-dependent.
3600 * Must be allocated with av_malloc() and will be freed by
3601 * avcodec_parameters_free(). The allocated size of extradata must be at
3602 * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
3607 * Size of the extradata content in bytes.
3612 * - video: the pixel format, the value corresponds to enum AVPixelFormat.
3613 * - audio: the sample format, the value corresponds to enum AVSampleFormat.
3618 * The average bitrate of the encoded data (in bits per second).
3622 int bits_per_coded_sample;
3625 * Codec-specific bitstream restrictions that the stream conforms to.
3631 * Video only. The dimensions of the video frame in pixels.
3637 * Video only. The aspect ratio (width / height) which a single pixel
3638 * should have when displayed.
3640 * When the aspect ratio is unknown / undefined, the numerator should be
3641 * set to 0 (the denominator may have any value).
3643 AVRational sample_aspect_ratio;
3646 * Video only. The order of the fields in interlaced video.
3648 enum AVFieldOrder field_order;
3651 * Video only. Additional colorspace characteristics.
3653 enum AVColorRange color_range;
3654 enum AVColorPrimaries color_primaries;
3655 enum AVColorTransferCharacteristic color_trc;
3656 enum AVColorSpace color_space;
3657 enum AVChromaLocation chroma_location;
3660 * Audio only. The channel layout bitmask. May be 0 if the channel layout is
3661 * unknown or unspecified, otherwise the number of bits set must be equal to
3662 * the channels field.
3664 uint64_t channel_layout;
3666 * Audio only. The number of audio channels.
3670 * Audio only. The number of audio samples per second.
3674 * Audio only. The number of bytes per coded audio frame, required by some
3677 * Corresponds to nBlockAlign in WAVEFORMATEX.
3682 * Audio only. The amount of padding (in samples) inserted by the encoder at
3683 * the beginning of the audio. I.e. this number of leading decoded samples
3684 * must be discarded by the caller to get the original audio without leading
3687 int initial_padding;
3689 * Audio only. The amount of padding (in samples) appended by the encoder to
3690 * the end of the audio. I.e. this number of decoded samples must be
3691 * discarded by the caller from the end of the stream to get the original
3692 * audio without any trailing padding.
3694 int trailing_padding;
3695 } AVCodecParameters;
3698 * If c is NULL, returns the first registered codec,
3699 * if c is non-NULL, returns the next registered codec after c,
3700 * or NULL if c is the last one.
3702 AVCodec *av_codec_next(const AVCodec *c);
3705 * Return the LIBAVCODEC_VERSION_INT constant.
3707 unsigned avcodec_version(void);
3710 * Return the libavcodec build-time configuration.
3712 const char *avcodec_configuration(void);
3715 * Return the libavcodec license.
3717 const char *avcodec_license(void);
3720 * Register the codec codec and initialize libavcodec.
3722 * @warning either this function or avcodec_register_all() must be called
3723 * before any other libavcodec functions.
3725 * @see avcodec_register_all()
3727 void avcodec_register(AVCodec *codec);
3730 * Register all the codecs, parsers and bitstream filters which were enabled at
3731 * configuration time. If you do not call this function you can select exactly
3732 * which formats you want to support, by using the individual registration
3735 * @see avcodec_register
3736 * @see av_register_codec_parser
3737 * @see av_register_bitstream_filter
3739 void avcodec_register_all(void);
3742 * Allocate an AVCodecContext and set its fields to default values. The
3743 * resulting struct should be freed with avcodec_free_context().
3745 * @param codec if non-NULL, allocate private data and initialize defaults
3746 * for the given codec. It is illegal to then call avcodec_open2()
3747 * with a different codec.
3748 * If NULL, then the codec-specific defaults won't be initialized,
3749 * which may result in suboptimal default settings (this is
3750 * important mainly for encoders, e.g. libx264).
3752 * @return An AVCodecContext filled with default values or NULL on failure.
3754 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
3757 * Free the codec context and everything associated with it and write NULL to
3758 * the provided pointer.
3760 void avcodec_free_context(AVCodecContext **avctx);
3762 #if FF_API_GET_CONTEXT_DEFAULTS
3764 * @deprecated This function should not be used, as closing and opening a codec
3765 * context multiple time is not supported. A new codec context should be
3766 * allocated for each new use.
3768 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
3772 * Get the AVClass for AVCodecContext. It can be used in combination with
3773 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3775 * @see av_opt_find().
3777 const AVClass *avcodec_get_class(void);
3779 #if FF_API_COPY_CONTEXT
3781 * Copy the settings of the source AVCodecContext into the destination
3782 * AVCodecContext. The resulting destination codec context will be
3783 * unopened, i.e. you are required to call avcodec_open2() before you
3784 * can use this AVCodecContext to decode/encode video/audio data.
3786 * @param dest target codec context, should be initialized with
3787 * avcodec_alloc_context3(), but otherwise uninitialized
3788 * @param src source codec context
3789 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3791 * @deprecated The semantics of this function are ill-defined and it should not
3792 * be used. If you need to transfer the stream parameters from one codec context
3793 * to another, use an intermediate AVCodecParameters instance and the
3794 * avcodec_parameters_from_context() / avcodec_parameters_to_context()
3797 attribute_deprecated
3798 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3802 * Allocate a new AVCodecParameters and set its fields to default values
3803 * (unknown/invalid/0). The returned struct must be freed with
3804 * avcodec_parameters_free().
3806 AVCodecParameters *avcodec_parameters_alloc(void);
3809 * Free an AVCodecParameters instance and everything associated with it and
3810 * write NULL to the supplied pointer.
3812 void avcodec_parameters_free(AVCodecParameters **par);
3815 * Copy the contents of src to dst. Any allocated fields in dst are freed and
3816 * replaced with newly allocated duplicates of the corresponding fields in src.
3818 * @return >= 0 on success, a negative AVERROR code on failure.
3820 int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
3823 * Fill the parameters struct based on the values from the supplied codec
3824 * context. Any allocated fields in par are freed and replaced with duplicates
3825 * of the corresponding fields in codec