X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Favcodec.h;h=0cc81749b05be3a4e2534e7c52901881f541019b;hb=0026e356d044e72b6e743b234708b8b8af457ac0;hp=2a39b433c3ee4b7a5be1e76b8b80d46db28a3f6d;hpb=a0b901a348e435f0234440736670fc9e8fcca836;p=ffmpeg diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2a39b433c3e..0cc81749b05 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -41,6 +41,11 @@ #include "version.h" +#if FF_API_FAST_MALLOC +// to provide fast_*alloc +#include "libavutil/mem.h" +#endif + /** * @defgroup libavc Encoding/Decoding Library * @{ @@ -103,7 +108,9 @@ enum AVCodecID { /* video codecs */ AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding +#if FF_API_XVMC AV_CODEC_ID_MPEG2VIDEO_XVMC, +#endif /* FF_API_XVMC */ AV_CODEC_ID_H261, AV_CODEC_ID_H263, AV_CODEC_ID_RV10, @@ -273,6 +280,19 @@ enum AVCodecID { AV_CODEC_ID_AIC, AV_CODEC_ID_ESCAPE130, AV_CODEC_ID_G2M, + AV_CODEC_ID_WEBP, + AV_CODEC_ID_HNM4_VIDEO, + AV_CODEC_ID_HEVC, + AV_CODEC_ID_FIC, + AV_CODEC_ID_ALIAS_PIX, + AV_CODEC_ID_BRENDER_PIX, + AV_CODEC_ID_PAF_VIDEO, + AV_CODEC_ID_EXR, + AV_CODEC_ID_VP7, + AV_CODEC_ID_SANM, + AV_CODEC_ID_SGIRLE, + AV_CODEC_ID_MVC1, + AV_CODEC_ID_MVC2, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -304,6 +324,8 @@ enum AVCodecID { AV_CODEC_ID_PCM_LXF, AV_CODEC_ID_S302M, AV_CODEC_ID_PCM_S8_PLANAR, + AV_CODEC_ID_PCM_S24LE_PLANAR, + AV_CODEC_ID_PCM_S32LE_PLANAR, /* various ADPCM codecs */ AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, @@ -336,6 +358,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_IMA_ISS, AV_CODEC_ID_ADPCM_G722, AV_CODEC_ID_ADPCM_IMA_APC, + AV_CODEC_ID_ADPCM_VIMA, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -419,6 +442,8 @@ enum AVCodecID { AV_CODEC_ID_COMFORT_NOISE, AV_CODEC_ID_TAK, AV_CODEC_ID_METASOUND, + AV_CODEC_ID_PAF_AUDIO, + AV_CODEC_ID_ON2AVC, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -484,6 +509,16 @@ typedef struct AVCodecDescriptor { * Codec supports lossless compression. Audio and video codecs only. */ #define AV_CODEC_PROP_LOSSLESS (1 << 2) +/** + * Codec supports frame reordering. That is, the coded order (the order in which + * the encoded packets are output by the encoders / stored / input to the + * decoders) may be different from the presentation order of the corresponding + * frames. + * + * For codecs that do not have this property set, PTS and DTS should always be + * equal. + */ +#define AV_CODEC_PROP_REORDER (1 << 3) /** * @ingroup lavc_decoding @@ -533,61 +568,6 @@ enum AVDiscard{ AVDISCARD_ALL = 48, ///< discard all }; -enum AVColorPrimaries{ - AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B - AVCOL_PRI_UNSPECIFIED = 2, - AVCOL_PRI_BT470M = 4, - AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM - AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above - AVCOL_PRI_FILM = 8, - AVCOL_PRI_NB , ///< Not part of ABI -}; - -enum AVColorTransferCharacteristic{ - AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 - AVCOL_TRC_UNSPECIFIED = 2, - AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM - AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG - AVCOL_TRC_SMPTE240M = 7, - AVCOL_TRC_NB , ///< Not part of ABI -}; - -enum AVColorSpace{ - AVCOL_SPC_RGB = 0, - AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B - AVCOL_SPC_UNSPECIFIED = 2, - AVCOL_SPC_FCC = 4, - AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 - AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above - AVCOL_SPC_SMPTE240M = 7, - AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 - AVCOL_SPC_NB , ///< Not part of ABI -}; - -enum AVColorRange{ - AVCOL_RANGE_UNSPECIFIED = 0, - AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges - AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges - AVCOL_RANGE_NB , ///< Not part of ABI -}; - -/** - * X X 3 4 X X are luma samples, - * 1 2 1-6 are possible chroma positions - * X X 5 6 X 0 is undefined/unknown position - */ -enum AVChromaLocation{ - AVCHROMA_LOC_UNSPECIFIED = 0, - AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default - AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263 - AVCHROMA_LOC_TOPLEFT = 3, ///< DV - AVCHROMA_LOC_TOP = 4, - AVCHROMA_LOC_BOTTOMLEFT = 5, - AVCHROMA_LOC_BOTTOM = 6, - AVCHROMA_LOC_NB , ///< Not part of ABI -}; - enum AVAudioServiceType { AV_AUDIO_SERVICE_TYPE_MAIN = 0, AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, @@ -611,7 +591,12 @@ typedef struct RcOverride{ float quality_factor; } RcOverride; +#if FF_API_MAX_BFRAMES +/** + * @deprecated there is no libavcodec-wide limit on the number of B-frames + */ #define FF_MAX_B_FRAMES 16 +#endif /* encoding support These flags can be passed in AVCodecContext.flags before initialization. @@ -625,23 +610,48 @@ typedef struct RcOverride{ #define CODEC_FLAG_UNALIGNED 0x0001 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. +#define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#if FF_API_GMC +/** + * @deprecated use the "gmc" private option of the libxvid encoder + */ #define CODEC_FLAG_GMC 0x0020 ///< Use GMC. -#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +#endif +#if FF_API_MV0 /** - * The parent program guarantees that the input for B-frames containing - * streams is not written to for at least s->max_b_frames+1 frames, if - * this is not set the input will be copied. + * @deprecated use the flag "mv0" in the "mpv_flags" private option of the + * mpegvideo encoders + */ +#define CODEC_FLAG_MV0 0x0040 +#endif +#if FF_API_INPUT_PRESERVED +/** + * @deprecated passing reference-counted frames to the encoders replaces this + * flag */ #define CODEC_FLAG_INPUT_PRESERVED 0x0100 +#endif #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. -#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. +#if FF_API_EMU_EDGE +/** + * @deprecated edges are not used/required anymore. I.e. this flag is now always + * set. + */ +#define CODEC_FLAG_EMU_EDGE 0x4000 +#endif #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random location instead of only at frame boundaries. */ -#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. +#if FF_API_NORMALIZE_AQP +/** + * @deprecated use the flag "naq" in the "mpv_flags" private option of the + * mpegvideo encoders + */ +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 +#endif #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. @@ -673,8 +683,10 @@ typedef struct RcOverride{ */ #define CODEC_CAP_DR1 0x0002 #define CODEC_CAP_TRUNCATED 0x0008 +#if FF_API_XVMC /* Codec can export data for HW decoding (XvMC). */ #define CODEC_CAP_HWACCEL 0x0010 +#endif /* FF_API_XVMC */ /** * Encoder or decoder requires flushing with NULL input at the end in order to * give the complete and correct output. @@ -731,10 +743,12 @@ typedef struct RcOverride{ * Codec should fill in channel configuration and samplerate instead of container */ #define CODEC_CAP_CHANNEL_CONF 0x0400 +#if FF_API_NEG_LINESIZES /** - * Codec is able to deal with negative linesizes + * @deprecated no codecs use this capability */ #define CODEC_CAP_NEG_LINESIZES 0x0800 +#endif /** * Codec supports frame-level multithreading. */ @@ -756,6 +770,7 @@ typedef struct RcOverride{ */ #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000 +#if FF_API_MB_TYPE //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific @@ -779,6 +794,7 @@ typedef struct RcOverride{ #define MB_TYPE_QUANT 0x00010000 #define MB_TYPE_CBP 0x00020000 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) +#endif /** * Pan Scan area. @@ -809,10 +825,12 @@ typedef struct AVPanScan{ int16_t position[3][2]; }AVPanScan; +#if FF_API_QSCALE_TYPE #define FF_QSCALE_TYPE_MPEG1 0 #define FF_QSCALE_TYPE_MPEG2 1 #define FF_QSCALE_TYPE_H264 2 #define FF_QSCALE_TYPE_VP56 3 +#endif #if FF_API_GET_BUFFER #define FF_BUFFER_TYPE_INTERNAL 1 @@ -878,8 +896,29 @@ enum AVPacketSideDataType { * @endcode */ AV_PKT_DATA_H263_MB_INFO, + + /** + * This side data should be associated with an audio stream and contains + * ReplayGain information in form of the AVReplayGain struct. + */ + AV_PKT_DATA_REPLAYGAIN, + + /** + * This side data contains a 3x3 transformation matrix describing an affine + * transformation that needs to be applied to the decoded video frames for + * correct presentation. + * + * See libavutil/display.h for a detailed description of the data. + */ + AV_PKT_DATA_DISPLAYMATRIX, }; +typedef struct AVPacketSideData { + uint8_t *data; + int size; + enum AVPacketSideDataType type; +} AVPacketSideData; + /** * This structure stores compressed data. It is typically exported by demuxers * and then passed as input to decoders, or received as output from encoders and @@ -936,11 +975,7 @@ typedef struct AVPacket { * Additional packet data that can be provided by the container. * Packet can contain several types of side information. */ - struct { - uint8_t *data; - int size; - enum AVPacketSideDataType type; - } *side_data; + AVPacketSideData *side_data; int side_data_elems; /** @@ -1016,7 +1051,13 @@ typedef struct AVCodecContext { enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ const struct AVCodec *codec; +#if FF_API_CODEC_NAME + /** + * @deprecated this field is not used for anything in libavcodec + */ + attribute_deprecated char codec_name[32]; +#endif enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ /** @@ -1144,12 +1185,17 @@ typedef struct AVCodecContext { * encoded input. * * Audio: - * For encoding, this is the number of "priming" samples added to the - * beginning of the stream. The decoded output will be delayed by this - * many samples relative to the input to the encoder. Note that this - * field is purely informational and does not directly affect the pts - * output by the encoder, which should always be based on the actual - * presentation time, including any delay. + * For encoding, this is the number of "priming" samples added by the + * encoder to the beginning of the stream. The decoded output will be + * delayed by this many samples relative to the input to the encoder (or + * more, if the decoder adds its own padding). + * The timestamps on the output packets are adjusted by the encoder so + * that they always refer to the first sample of the data actually + * contained in the packet, including any added padding. + * E.g. if the timebase is 1/samplerate and the timestamp of the first + * input sample is 0, the timestamp of the first output packet will be + * -delay. + * * For decoding, this is the number of samples the decoder needs to * output before the decoder's output is valid. When seeking, you should * start decoding this many samples prior to your desired seek point. @@ -1181,7 +1227,9 @@ typedef struct AVCodecContext { */ int coded_width, coded_height; +#if FF_API_ASPECT_EXTENDED #define FF_ASPECT_EXTENDED 15 +#endif /** * the number of pictures in a group of pictures, or 0 for intra_only @@ -1455,6 +1503,7 @@ typedef struct AVCodecContext { */ int me_subpel_quality; +#if FF_API_AFD /** * DTG active format information (additional aspect ratio * information only used in DVB MPEG-2 transport streams) @@ -1462,8 +1511,9 @@ typedef struct AVCodecContext { * * - encoding: unused * - decoding: Set by decoder. + * @deprecated Deprecated in favor of AVSideData */ - int dtg_active_format; + attribute_deprecated int dtg_active_format; #define FF_DTG_AFD_SAME 8 #define FF_DTG_AFD_4_3 9 #define FF_DTG_AFD_16_9 10 @@ -1471,6 +1521,7 @@ typedef struct AVCodecContext { #define FF_DTG_AFD_4_3_SP_14_9 13 #define FF_DTG_AFD_16_9_SP_14_9 14 #define FF_DTG_AFD_SP_4_3 15 +#endif /* FF_API_AFD */ /** * maximum motion estimation search range in subpel units @@ -1506,12 +1557,15 @@ typedef struct AVCodecContext { #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics) #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) +#if FF_API_XVMC /** * XVideo Motion Acceleration * - encoding: forbidden * - decoding: set by decoder + * @deprecated XvMC support is slated for removal. */ - int xvmc_acceleration; + attribute_deprecated int xvmc_acceleration; +#endif /* FF_API_XVMC */ /** * macroblock decision mode @@ -1653,12 +1707,14 @@ typedef struct AVCodecContext { */ int chromaoffset; +#if FF_API_UNUSED_MEMBERS /** * Multiplied by qscale for each frame and added to scene_change_score. * - encoding: Set by user. * - decoding: unused */ - int scenechange_factor; + attribute_deprecated int scenechange_factor; +#endif /** * @@ -1957,9 +2013,6 @@ typedef struct AVCodecContext { * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused * (read and/or written to if it is writable) later by libavcodec. * - * If CODEC_FLAG_EMU_EDGE is not set in s->flags, the buffer must contain an - * edge of the size returned by avcodec_get_edge_width() on all sides. - * * avcodec_align_dimensions2() should be used to find the required width and * height, as they normally need to be rounded up to the next multiple of 16. * @@ -2108,7 +2161,9 @@ typedef struct AVCodecContext { #define FF_CODER_TYPE_AC 1 #define FF_CODER_TYPE_RAW 2 #define FF_CODER_TYPE_RLE 3 +#if FF_API_UNUSED_MEMBERS #define FF_CODER_TYPE_DEFLATE 4 +#endif /* FF_API_UNUSED_MEMBERS */ /** * coder type * - encoding: Set by user. @@ -2245,12 +2300,16 @@ typedef struct AVCodecContext { */ int workaround_bugs; #define FF_BUG_AUTODETECT 1 ///< autodetection +#if FF_API_OLD_MSMPEG4 #define FF_BUG_OLD_MSMPEG4 2 +#endif #define FF_BUG_XVID_ILACE 4 #define FF_BUG_UMP4 8 #define FF_BUG_NO_PADDING 16 #define FF_BUG_AMV 32 +#if FF_API_AC_VLC #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. +#endif #define FF_BUG_QPEL_CHROMA 64 #define FF_BUG_STD_QPEL 128 #define FF_BUG_QPEL_CHROMA2 256 @@ -2300,28 +2359,38 @@ typedef struct AVCodecContext { #define FF_DEBUG_BITSTREAM 4 #define FF_DEBUG_MB_TYPE 8 #define FF_DEBUG_QP 16 +#if FF_API_DEBUG_MV +/** + * @deprecated this option does nothing + */ #define FF_DEBUG_MV 32 +#endif #define FF_DEBUG_DCT_COEFF 0x00000040 #define FF_DEBUG_SKIP 0x00000080 #define FF_DEBUG_STARTCODE 0x00000100 +#if FF_API_UNUSED_MEMBERS #define FF_DEBUG_PTS 0x00000200 +#endif /* FF_API_UNUSED_MEMBERS */ #define FF_DEBUG_ER 0x00000400 #define FF_DEBUG_MMCO 0x00000800 #define FF_DEBUG_BUGS 0x00001000 +#if FF_API_DEBUG_MV #define FF_DEBUG_VIS_QP 0x00002000 #define FF_DEBUG_VIS_MB_TYPE 0x00004000 +#endif #define FF_DEBUG_BUFFERS 0x00008000 #define FF_DEBUG_THREADS 0x00010000 +#if FF_API_DEBUG_MV /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. + * @deprecated this option does not have any effect */ + attribute_deprecated int debug_mv; #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames +#endif /** * Error recognition; may misdetect some more or less valid parts as errors. @@ -2329,6 +2398,13 @@ typedef struct AVCodecContext { * - decoding: Set by user. */ int err_recognition; + +/** + * Verify checksums embedded in the bitstream (could be of either encoded or + * decoded data, depending on the codec) and print an error message on mismatch. + * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the + * decoder returning an error. + */ #define AV_EF_CRCCHECK (1<<0) #define AV_EF_BITSTREAM (1<<1) #define AV_EF_BUFFER (1<<2) @@ -2337,7 +2413,6 @@ typedef struct AVCodecContext { /** * opaque 64bit number (generally a PTS) that will be reordered and * output in AVFrame.reordered_opaque - * @deprecated in favor of pkt_pts * - encoding: unused * - decoding: Set by user. */ @@ -2377,7 +2452,9 @@ typedef struct AVCodecContext { int dct_algo; #define FF_DCT_AUTO 0 #define FF_DCT_FASTINT 1 +#if FF_API_UNUSED_MEMBERS #define FF_DCT_INT 2 +#endif /* FF_API_UNUSED_MEMBERS */ #define FF_DCT_MMX 3 #define FF_DCT_ALTIVEC 5 #define FF_DCT_FAAN 6 @@ -2394,16 +2471,24 @@ typedef struct AVCodecContext { #define FF_IDCT_SIMPLEMMX 3 #define FF_IDCT_ARM 7 #define FF_IDCT_ALTIVEC 8 +#if FF_API_ARCH_SH4 #define FF_IDCT_SH4 9 +#endif #define FF_IDCT_SIMPLEARM 10 +#if FF_API_UNUSED_MEMBERS #define FF_IDCT_IPP 13 +#endif /* FF_API_UNUSED_MEMBERS */ #define FF_IDCT_XVIDMMX 14 #define FF_IDCT_SIMPLEARMV5TE 16 #define FF_IDCT_SIMPLEARMV6 17 +#if FF_API_ARCH_SPARC #define FF_IDCT_SIMPLEVIS 18 +#endif #define FF_IDCT_FAAN 20 #define FF_IDCT_SIMPLENEON 22 +#if FF_API_ARCH_ALPHA #define FF_IDCT_SIMPLEALPHA 23 +#endif /** * bits per sample/pixel from the demuxer (needed for huffyuv). @@ -2433,7 +2518,7 @@ typedef struct AVCodecContext { /** * the picture in the bitstream * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. + * - decoding: unused */ AVFrame *coded_frame; @@ -2505,13 +2590,13 @@ typedef struct AVCodecContext { */ int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); +#if FF_API_THREAD_OPAQUE /** - * thread opaque - * Can be used by execute() to store some per AVCodecContext stuff. - * - encoding: set by execute() - * - decoding: set by execute() + * @deprecated this field should not be used from outside of lavc */ + attribute_deprecated void *thread_opaque; +#endif /** * noise vs. sse weight for the nsse comparsion function @@ -2598,6 +2683,11 @@ typedef struct AVCodecContext { #define FF_PROFILE_JPEG2000_DCINEMA_2K 3 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4 + +#define FF_PROFILE_HEVC_MAIN 1 +#define FF_PROFILE_HEVC_MAIN_10 2 +#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 + /** * level * - encoding: Set by user. @@ -2638,21 +2728,22 @@ typedef struct AVCodecContext { uint8_t *subtitle_header; int subtitle_header_size; +#if FF_API_ERROR_RATE /** - * Simulates errors in the bitstream to test error concealment. - * - encoding: Set by user. - * - decoding: unused + * @deprecated use the 'error_rate' private AVOption of the mpegvideo + * encoders */ + attribute_deprecated int error_rate; +#endif +#if FF_API_CODEC_PKT /** - * Current packet as passed into the decoder, to avoid having - * to pass the packet into every function. Currently only valid - * inside lavc and get/release_buffer callbacks. - * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts - * - encoding: unused + * @deprecated this field is not supposed to be accessed from outside lavc */ + attribute_deprecated AVPacket *pkt; +#endif /** * VBV delay coded in the last frame (in periods of a 27 MHz clock). @@ -2661,6 +2752,21 @@ typedef struct AVCodecContext { * - decoding: unused. */ uint64_t vbv_delay; + + /** + * Encoding only. Allow encoders to output packets that do not contain any + * encoded data, only side data. + * + * Some encoders need to output such packets, e.g. to update some stream + * parameters at the end of encoding. + * + * All callers are strongly recommended to set this option to 1 and update + * their code to deal with such packets, since this behaviour may become + * always enabled in the future (then this option will be deprecated and + * later removed). To avoid ABI issues when this happens, the callers should + * use AVOptions to set this field. + */ + int side_data_only_packets; } AVCodecContext; /** @@ -2703,7 +2809,9 @@ typedef struct AVCodec { const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 +#if FF_API_LOWRES attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder +#endif const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} @@ -2808,8 +2916,20 @@ typedef struct AVHWAccel { */ int capabilities; + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ struct AVHWAccel *next; + /** + * Allocate a custom buffer + */ + int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame); + /** * Called at the beginning of each frame or field picture. * @@ -2851,12 +2971,35 @@ typedef struct AVHWAccel { int (*end_frame)(AVCodecContext *avctx); /** - * Size of HW accelerator private data. + * Size of per-frame hardware accelerator private data. * * Private data is allocated with av_mallocz() before * AVCodecContext.get_buffer() and deallocated after * AVCodecContext.release_buffer(). */ + int frame_priv_data_size; + + /** + * Initialize the hwaccel private data. + * + * This will be called from ff_get_format(), after hwaccel and + * hwaccel_context are set and the hwaccel private data in AVCodecInternal + * is allocated. + */ + int (*init)(AVCodecContext *avctx); + + /** + * Uninitialize the hwaccel private data. + * + * This will be called from get_format() or avcodec_close(), after hwaccel + * and hwaccel_context are already uninitialized. + */ + int (*uninit)(AVCodecContext *avctx); + + /** + * Size of the private data to allocate in + * AVCodecInternal.hwaccel_priv_data. + */ int priv_data_size; } AVHWAccel; @@ -2982,9 +3125,8 @@ void avcodec_register(AVCodec *codec); void avcodec_register_all(void); /** - * Allocate an AVCodecContext and set its fields to default values. The - * resulting struct can be deallocated by calling avcodec_close() on it followed - * by av_free(). + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct should be freed with avcodec_free_context(). * * @param codec if non-NULL, allocate private data and initialize defaults * for the given codec. It is illegal to then call avcodec_open2() @@ -2998,6 +3140,12 @@ void avcodec_register_all(void); */ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); +/** + * Free the codec context and everything associated with it and write NULL to + * the provided pointer. + */ +void avcodec_free_context(AVCodecContext **avctx); + /** * Set the fields of the given AVCodecContext to default values corresponding * to the given codec (defaults may be codec-dependent). @@ -3030,20 +3178,21 @@ const AVClass *avcodec_get_class(void); */ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); +#if FF_API_AVFRAME_LAVC /** - * Allocate an AVFrame and set its fields to default values. The resulting - * struct must be freed using avcodec_free_frame(). - * - * @return An AVFrame filled with default values or NULL on failure. - * @see avcodec_get_frame_defaults + * @deprecated use av_frame_alloc() */ +attribute_deprecated AVFrame *avcodec_alloc_frame(void); /** * Set the fields of the given AVFrame to default values. * * @param frame The AVFrame of which the fields should be set to default values. + * + * @deprecated use av_frame_unref() */ +attribute_deprecated void avcodec_get_frame_defaults(AVFrame *frame); /** @@ -3055,8 +3204,12 @@ void avcodec_get_frame_defaults(AVFrame *frame); * @warning this function does NOT free the data buffers themselves * (it does not know how, since they might have been allocated with * a custom get_buffer()). + * + * @deprecated use av_frame_free() */ +attribute_deprecated void avcodec_free_frame(AVFrame **frame); +#endif /** * Initialize the AVCodecContext to use the given AVCodec. Prior to using this @@ -3289,6 +3442,19 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src); */ int av_packet_copy_props(AVPacket *dst, const AVPacket *src); +/** + * Convert valid timing fields (timestamps / durations) in a packet from one + * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be + * ignored. + * + * @param pkt packet on which the conversion will be performed + * @param tb_src source timebase, in which the timing fields in pkt are + * expressed + * @param tb_dst destination timebase, to which the timing fields will be + * converted + */ +void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); + /** * @} */ @@ -3327,14 +3493,20 @@ attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame */ int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); +#if FF_API_EMU_EDGE /** * Return the amount of padding in pixels which the get_buffer callback must * provide around the edge of the image for codecs which do not have the * CODEC_FLAG_EMU_EDGE flag. * * @return Required padding in pixels. + * + * @deprecated CODEC_FLAG_EMU_EDGE is deprecated, so this function is no longer + * needed */ +attribute_deprecated unsigned avcodec_get_edge_width(void); +#endif /** * Modify width and height values so that they will result in a memory @@ -3342,8 +3514,6 @@ unsigned avcodec_get_edge_width(void); * padding. * * May only be used if a codec with CODEC_CAP_DR1 has been opened. - * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased - * according to avcodec_get_edge_width() before. */ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); @@ -3353,8 +3523,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); * line sizes are a multiple of the respective linesize_align[i]. * * May only be used if a codec with CODEC_CAP_DR1 has been opened. - * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased - * according to avcodec_get_edge_width() before. */ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); @@ -3363,19 +3531,25 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, * Decode the audio frame of size avpkt->size from avpkt->data into frame. * * Some decoders may support multiple frames in a single AVPacket. Such - * decoders would then just decode the first frame. In this case, - * avcodec_decode_audio4 has to be called again with an AVPacket containing - * the remaining data in order to decode the second frame, etc... - * Even if no frames are returned, the packet needs to be fed to the decoder - * with remaining data until it is completely consumed or an error occurs. + * decoders would then just decode the first frame and the return value would be + * less than the packet size. In this case, avcodec_decode_audio4 has to be + * called again with an AVPacket containing the remaining data in order to + * decode the second frame, etc... Even if no frames are returned, the packet + * needs to be fed to the decoder with remaining data until it is completely + * consumed or an error occurs. + * + * Some decoders (those marked with CODEC_CAP_DELAY) have a delay between input + * and output. This means that for some packets they will not immediately + * produce decoded output and need to be flushed at the end of decoding to get + * all the decoded data. Flushing is done by calling this function with packets + * with avpkt->data set to NULL and avpkt->size set to 0 until it stops + * returning samples. It is safe to flush even those decoders that are not + * marked with CODEC_CAP_DELAY, then no samples will be returned. * * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE * larger than the actual read bytes because some optimized bitstream * readers read 32 or 64 bits at once and could read over the end. * - * @note You might have to align the input buffer. The alignment requirements - * depend on the CPU and the decoder. - * * @param avctx the codec context * @param[out] frame The AVFrame in which to store decoded audio samples. * The decoder will allocate a buffer for the decoded frame by @@ -3387,10 +3561,13 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, * to the frame if av_frame_is_writable() returns 1. * When AVCodecContext.refcounted_frames is set to 0, the returned * reference belongs to the decoder and is valid only until the - * next call to this function or until closing the decoder. - * The caller may not write to it. + * next call to this function or until closing or flushing the + * decoder. The caller may not write to it. * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is - * non-zero. + * non-zero. Note that this field being set to zero + * does not mean that an error has occurred. For + * decoders with CODEC_CAP_DELAY set, no given decode + * call is guaranteed to produce a frame. * @param[in] avpkt The input AVPacket containing the input buffer. * At least avpkt->data and avpkt->size should be set. Some * decoders might also require additional fields to be set. @@ -3413,13 +3590,6 @@ int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, * @warning The end of the input buffer buf should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note You might have to align the input buffer avpkt->data. - * The alignment requirements depend on the CPU: on some CPUs it isn't - * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. - * - * In practice, avpkt->data should have 4 byte alignment at minimum. - * * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay * between input and output, these need to be fed with avpkt->data=NULL, * avpkt->size=0 at the end to return the remaining frames. @@ -3436,8 +3606,8 @@ int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, * to the frame if av_frame_is_writable() returns 1. * When AVCodecContext.refcounted_frames is set to 0, the returned * reference belongs to the decoder and is valid only until the - * next call to this function or until closing the decoder. The - * caller may not write to it. + * next call to this function or until closing or flushing the + * decoder. The caller may not write to it. * * @param[in] avpkt The input AVpacket containing the input buffer. * You can create such packet with av_init_packet() and by then setting @@ -3652,7 +3822,7 @@ typedef struct AVCodecParser { struct AVCodecParser *next; } AVCodecParser; -AVCodecParser *av_parser_next(AVCodecParser *c); +AVCodecParser *av_parser_next(const AVCodecParser *c); void av_register_codec_parser(AVCodecParser *parser); AVCodecParserContext *av_parser_init(int codec_id); @@ -4012,12 +4182,20 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en * @} */ +#if FF_API_SET_DIMENSIONS +/** + * @deprecated this function is not supposed to be used from outside of lavc + */ +attribute_deprecated void avcodec_set_dimensions(AVCodecContext *s, int width, int height); +#endif /** * Put a string representing the codec tag codec_tag in buf. * + * @param buf buffer to place codec tag in * @param buf_size size in bytes of buf + * @param codec_tag codec tag to assign * @return the length of the string that would have been generated if * enough space had been available, excluding the trailing null */ @@ -4059,7 +4237,13 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, int buf_size, int align); /** - * Flush buffers, should be called when seeking or when switching to a different stream. + * Reset the internal decoder state / flush internal buffers. Should be called + * e.g. when seeking or when switching to a different stream. + * + * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0), + * this invalidates the frames previously returned from the decoder. When + * refcounted frames are used, the decoder just releases any references it might + * keep internally, but the caller's reference remains valid. */ void avcodec_flush_buffers(AVCodecContext *avctx); @@ -4119,31 +4303,10 @@ int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, const uint8_t *buf, int buf_size, int keyframe); void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); -AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); +AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); /* memory */ -/** - * Reallocate the given block if it is not large enough, otherwise do nothing. - * - * @see av_realloc - */ -void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); - -/** - * Allocate a buffer, reusing the given one if large enough. - * - * Contrary to av_fast_realloc the current buffer contents might not be - * preserved and on error the old buffer is freed, thus no special - * handling to avoid memleaks is necessary. - * - * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer - * @param size size of the buffer *ptr points to - * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and - * *size 0 if an error occurred. - */ -void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); - /** * Allocate a buffer with padding, reusing the given one if large enough. * @@ -4202,7 +4365,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel); * if hwaccel is non-NULL, returns the next registered hardware accelerator * after hwaccel, or NULL if hwaccel is the last one. */ -AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); +AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); /**