X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Favcodec.h;h=c8fde8d0d06b3a2e764b2b06bab8feeff1f74374;hb=ec104eef51d16974f7d90dfb2ab705df3f47e6bb;hp=669afe80bae35b16097c69b995d399c9493b3658;hpb=19341c58e0f7210046286e08ae5f955a14ee3e3f;p=ffmpeg diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 669afe80bae..c8fde8d0d06 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -253,6 +253,8 @@ enum CodecID { CODEC_ID_BMV_VIDEO, CODEC_ID_VBLE, CODEC_ID_DXTORY, + CODEC_ID_V410, + CODEC_ID_XWD, /* various PCM "codecs" */ CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -315,6 +317,7 @@ enum CodecID { CODEC_ID_ADPCM_EA_MAXIS_XA, CODEC_ID_ADPCM_IMA_ISS, CODEC_ID_ADPCM_G722, + CODEC_ID_ADPCM_IMA_APC, /* AMR */ CODEC_ID_AMR_NB = 0x12000, @@ -421,66 +424,6 @@ enum CodecID { CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. }; -#if FF_API_OLD_SAMPLE_FMT -#define SampleFormat AVSampleFormat - -#define SAMPLE_FMT_NONE AV_SAMPLE_FMT_NONE -#define SAMPLE_FMT_U8 AV_SAMPLE_FMT_U8 -#define SAMPLE_FMT_S16 AV_SAMPLE_FMT_S16 -#define SAMPLE_FMT_S32 AV_SAMPLE_FMT_S32 -#define SAMPLE_FMT_FLT AV_SAMPLE_FMT_FLT -#define SAMPLE_FMT_DBL AV_SAMPLE_FMT_DBL -#define SAMPLE_FMT_NB AV_SAMPLE_FMT_NB -#endif - -#if FF_API_OLD_AUDIOCONVERT -#include "libavutil/audioconvert.h" - -/* Audio channel masks */ -#define CH_FRONT_LEFT AV_CH_FRONT_LEFT -#define CH_FRONT_RIGHT AV_CH_FRONT_RIGHT -#define CH_FRONT_CENTER AV_CH_FRONT_CENTER -#define CH_LOW_FREQUENCY AV_CH_LOW_FREQUENCY -#define CH_BACK_LEFT AV_CH_BACK_LEFT -#define CH_BACK_RIGHT AV_CH_BACK_RIGHT -#define CH_FRONT_LEFT_OF_CENTER AV_CH_FRONT_LEFT_OF_CENTER -#define CH_FRONT_RIGHT_OF_CENTER AV_CH_FRONT_RIGHT_OF_CENTER -#define CH_BACK_CENTER AV_CH_BACK_CENTER -#define CH_SIDE_LEFT AV_CH_SIDE_LEFT -#define CH_SIDE_RIGHT AV_CH_SIDE_RIGHT -#define CH_TOP_CENTER AV_CH_TOP_CENTER -#define CH_TOP_FRONT_LEFT AV_CH_TOP_FRONT_LEFT -#define CH_TOP_FRONT_CENTER AV_CH_TOP_FRONT_CENTER -#define CH_TOP_FRONT_RIGHT AV_CH_TOP_FRONT_RIGHT -#define CH_TOP_BACK_LEFT AV_CH_TOP_BACK_LEFT -#define CH_TOP_BACK_CENTER AV_CH_TOP_BACK_CENTER -#define CH_TOP_BACK_RIGHT AV_CH_TOP_BACK_RIGHT -#define CH_STEREO_LEFT AV_CH_STEREO_LEFT -#define CH_STEREO_RIGHT AV_CH_STEREO_RIGHT - -/** Channel mask value used for AVCodecContext.request_channel_layout - to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ -#define CH_LAYOUT_NATIVE AV_CH_LAYOUT_NATIVE - -/* Audio channel convenience macros */ -#define CH_LAYOUT_MONO AV_CH_LAYOUT_MONO -#define CH_LAYOUT_STEREO AV_CH_LAYOUT_STEREO -#define CH_LAYOUT_2_1 AV_CH_LAYOUT_2_1 -#define CH_LAYOUT_SURROUND AV_CH_LAYOUT_SURROUND -#define CH_LAYOUT_4POINT0 AV_CH_LAYOUT_4POINT0 -#define CH_LAYOUT_2_2 AV_CH_LAYOUT_2_2 -#define CH_LAYOUT_QUAD AV_CH_LAYOUT_QUAD -#define CH_LAYOUT_5POINT0 AV_CH_LAYOUT_5POINT0 -#define CH_LAYOUT_5POINT1 AV_CH_LAYOUT_5POINT1 -#define CH_LAYOUT_5POINT0_BACK AV_CH_LAYOUT_5POINT0_BACK -#define CH_LAYOUT_5POINT1_BACK AV_CH_LAYOUT_5POINT1_BACK -#define CH_LAYOUT_7POINT0 AV_CH_LAYOUT_7POINT0 -#define CH_LAYOUT_7POINT1 AV_CH_LAYOUT_7POINT1 -#define CH_LAYOUT_7POINT1_WIDE AV_CH_LAYOUT_7POINT1_WIDE -#define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX -#endif - #if FF_API_OLD_DECODE_AUDIO /* in bytes */ #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio @@ -582,20 +525,6 @@ enum AVChromaLocation{ AVCHROMA_LOC_NB , ///< Not part of ABI }; -#if FF_API_FLAC_GLOBAL_OPTS -/** - * LPC analysis type - */ -enum AVLPCType { - AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type - AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients - AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients - AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion - AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization - AV_LPC_TYPE_NB , ///< Not part of ABI -}; -#endif - enum AVAudioServiceType { AV_AUDIO_SERVICE_TYPE_MAIN = 0, AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, @@ -664,34 +593,9 @@ typedef struct RcOverride{ * Use corresponding private codec options instead. * @{ */ -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC -#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC -#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. -#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. -#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector -#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 -#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. -#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. -#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. -#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. -#endif #if FF_API_MJPEG_GLOBAL_OPTS #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). #endif -#if FF_API_X264_GLOBAL_OPTS -#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. -#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames -#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock -#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform -#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip -#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters -#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization -#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) -#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. -#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. -#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. -#endif #if FF_API_SNOW_GLOBAL_OPTS #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). #endif @@ -724,10 +628,27 @@ typedef struct RcOverride{ /* Codec can export data for HW decoding (XvMC). */ #define CODEC_CAP_HWACCEL 0x0010 /** - * Codec has a nonzero delay and needs to be fed with avpkt->data=NULL, + * Encoder or decoder requires flushing with NULL input at the end in order to + * give the complete and correct output. + * + * NOTE: If this flag is not set, the codec is guaranteed to never be fed with + * with NULL data. The user can still send NULL data to the public encode + * or decode function, but libavcodec will not pass it along to the codec + * unless this flag is set. + * + * Decoders: + * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, * avpkt->size=0 at the end to get the delayed data until the decoder no longer - * returns frames. If this is not set, the codec is guaranteed to never be fed - * with NULL data. + * returns frames. + * + * Encoders: + * The encoder needs to be fed with NULL data at the end of encoding until the + * encoder no longer returns data. + * + * NOTE: For encoders implementing the AVCodec.encode2() function, setting this + * flag also means that the encoder must set the pts and duration for + * each output packet. If this flag is not set, the pts and duration will + * be determined by libavcodec from the input frame. */ #define CODEC_CAP_DELAY 0x0020 /** @@ -772,6 +693,18 @@ typedef struct RcOverride{ * Codec supports slice-based (or partition-based) multithreading. */ #define CODEC_CAP_SLICE_THREADS 0x2000 +/** + * Codec supports changed parameters at any point. + */ +#define CODEC_CAP_PARAM_CHANGE 0x4000 +/** + * Codec supports avctx->thread_count == 0 (auto). + */ +#define CODEC_CAP_AUTO_THREADS 0x8000 +/** + * Audio encoder supports receiving a different number of samples in each call. + */ +#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 @@ -836,17 +769,6 @@ typedef struct AVPanScan{ #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. -#if FF_API_OLD_FF_PICT_TYPES -/* DEPRECATED, directly use the AV_PICTURE_TYPE_* enum values */ -#define FF_I_TYPE AV_PICTURE_TYPE_I ///< Intra -#define FF_P_TYPE AV_PICTURE_TYPE_P ///< Predicted -#define FF_B_TYPE AV_PICTURE_TYPE_B ///< Bi-dir predicted -#define FF_S_TYPE AV_PICTURE_TYPE_S ///< S(GMC)-VOP MPEG4 -#define FF_SI_TYPE AV_PICTURE_TYPE_SI ///< Switching Intra -#define FF_SP_TYPE AV_PICTURE_TYPE_SP ///< Switching Predicted -#define FF_BI_TYPE AV_PICTURE_TYPE_BI -#endif - #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. @@ -854,6 +776,8 @@ typedef struct AVPanScan{ enum AVPacketSideDataType { AV_PKT_DATA_PALETTE, + AV_PKT_DATA_NEW_EXTRADATA, + AV_PKT_DATA_PARAM_CHANGE, }; typedef struct AVPacket { @@ -922,6 +846,27 @@ typedef struct AVPacket { #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted +/** + * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: + * u32le param_flags + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) + * s32le channel_count + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) + * u64le channel_layout + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) + * s32le sample_rate + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) + * s32le width + * s32le height + */ + +enum AVSideDataParamChangeFlags { + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, +}; + /** * Audio Video Frame. * New fields can be added to the end of AVFRAME with minor version @@ -1003,13 +948,12 @@ typedef struct AVFrame { */ int quality; +#if FF_API_AVFRAME_AGE /** - * buffer age (1->was last buffer and dint change, 2->..., ...). - * Set to INT_MAX if the buffer has not been used yet. - * - encoding: unused - * - decoding: MUST be set by get_buffer() for video. + * @deprecated unused */ - int age; + attribute_deprecated int age; +#endif /** * is this picture used as reference @@ -1231,10 +1175,42 @@ typedef struct AVFrame { * decoding: set by AVCodecContext.get_buffer() */ uint8_t **extended_data; + + /** + * sample aspect ratio for the video frame, 0/1 if unknown\unspecified + * - encoding: unused + * - decoding: Read by user. + */ + AVRational sample_aspect_ratio; + + /** + * width and height of the video frame + * - encoding: unused + * - decoding: Read by user. + */ + int width, height; + + /** + * format of the frame, -1 if unknown or unset + * Values correspond to enum PixelFormat for video frames, + * enum AVSampleFormat for audio) + * - encoding: unused + * - decoding: Read by user. + */ + int format; } AVFrame; struct AVCodecInternal; +enum AVFieldOrder { + AV_FIELD_UNKNOWN, + AV_FIELD_PROGRESSIVE, + AV_FIELD_TT, //< Top coded_first, top displayed first + AV_FIELD_BB, //< Bottom coded first, bottom displayed first + AV_FIELD_TB, //< Top coded first, bottom displayed first + AV_FIELD_BT, //< Bottom coded first, top displayed first +}; + /** * main external API structure. * New fields can be added to the end with minor version bumps. @@ -1274,7 +1250,7 @@ typedef struct AVCodecContext { * Some codecs need additional format info. It is stored here. * If any muxer uses this then ALL demuxers/parsers AND encoders for the * specific codec MUST set it correctly otherwise stream copy breaks. - * In general use of this field by muxers is not recommanded. + * In general use of this field by muxers is not recommended. * - encoding: Set by libavcodec. * - decoding: Set by libavcodec. (FIXME: Is this OK?) */ @@ -2221,15 +2197,6 @@ typedef struct AVCodecContext { */ int lmax; -#if FF_API_PALETTE_CONTROL - /** - * palette control structure - * - encoding: ??? (no palette-enabled encoder yet) - * - decoding: Set by user. - */ - struct AVPaletteControl *palctrl; -#endif - /** * noise reduction strength * - encoding: Set by user. @@ -2279,19 +2246,6 @@ typedef struct AVCodecContext { */ int error_rate; -#if FF_API_ANTIALIAS_ALGO - /** - * MP3 antialias algorithm, see FF_AA_* below. - * - encoding: unused - * - decoding: Set by user. - */ - attribute_deprecated int antialias_algo; -#define FF_AA_AUTO 0 -#define FF_AA_FASTINT 1 //not implemented yet -#define FF_AA_INT 2 -#define FF_AA_FLOAT 3 -#endif - /** * quantizer noise shaping * - encoding: Set by user. @@ -2550,24 +2504,6 @@ typedef struct AVCodecContext { */ int brd_scale; -#if FF_API_X264_GLOBAL_OPTS - /** - * constant rate factor - quality-based VBR - values ~correspond to qps - * - encoding: Set by user. - * - decoding: unused - * @deprecated use 'crf' libx264 private option - */ - attribute_deprecated float crf; - - /** - * constant quantization parameter rate control method - * - encoding: Set by user. - * - decoding: unused - * @deprecated use 'cqp' libx264 private option - */ - attribute_deprecated int cqp; -#endif - /** * minimum GOP size * - encoding: Set by user. @@ -2589,15 +2525,6 @@ typedef struct AVCodecContext { */ int chromaoffset; -#if FF_API_X264_GLOBAL_OPTS - /** - * Influences how often B-frames are used. - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int bframebias; -#endif - /** * trellis RD quantization * - encoding: Set by user. @@ -2605,50 +2532,6 @@ typedef struct AVCodecContext { */ int trellis; -#if FF_API_X264_GLOBAL_OPTS - /** - * Reduce fluctuations in qp (before curve compression). - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated float complexityblur; - - /** - * in-loop deblocking filter alphac0 parameter - * alpha is in the range -6...6 - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int deblockalpha; - - /** - * in-loop deblocking filter beta parameter - * beta is in the range -6...6 - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int deblockbeta; - - /** - * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int partitions; -#define X264_PART_I4X4 0x001 /* Analyze i4x4 */ -#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ -#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ -#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ -#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ - - /** - * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto) - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int directpred; -#endif - /** * Audio cutoff bandwidth (0 means "automatic") * - encoding: Set by user. @@ -2672,7 +2555,7 @@ typedef struct AVCodecContext { int mv0_threshold; /** - * Adjusts sensitivity of b_frame_strategy 1. + * Adjust sensitivity of b_frame_strategy 1. * - encoding: Set by user. * - decoding: unused */ @@ -2697,43 +2580,6 @@ typedef struct AVCodecContext { */ int max_prediction_order; -#if FF_API_FLAC_GLOBAL_OPTS - /** - * @name FLAC options - * @deprecated Use FLAC encoder private options instead. - * @{ - */ - - /** - * LPC coefficient precision - used by FLAC encoder - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int lpc_coeff_precision; - - /** - * search method for selecting prediction order - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int prediction_order_method; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int min_partition_order; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int max_partition_order; - /** - * @} - */ -#endif - /** * GOP timecode frame start number, in non drop frame format * - encoding: Set by user. @@ -2889,87 +2735,8 @@ 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_X264_GLOBAL_OPTS - /** - * explicit P-frame weighted prediction analysis method - * 0: off - * 1: fast blind weighting (one reference duplicate with -1 offset) - * 2: smart weighting (full fade detection analysis) - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated int weighted_p_pred; - - /** - * AQ mode - * 0: Disabled - * 1: Variance AQ (complexity mask) - * 2: Auto-variance AQ (experimental) - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated int aq_mode; - - /** - * AQ strength - * Reduces blocking and blurring in flat and textured areas. - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated float aq_strength; - - /** - * PSY RD - * Strength of psychovisual optimization - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated float psy_rd; - - /** - * PSY trellis - * Strength of psychovisual optimization - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated float psy_trellis; - - /** - * RC lookahead - * Number of frames for frametype and ratecontrol lookahead - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated int rc_lookahead; - - /** - * Constant rate factor maximum - * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse - * than crf_max, even if doing so would violate VBV restrictions. - * - encoding: Set by user. - * - decoding: unused - */ - attribute_deprecated float crf_max; -#endif - int log_level_offset; -#if FF_API_FLAC_GLOBAL_OPTS - /** - * Determines which LPC analysis algorithm to use. - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated enum AVLPCType lpc_type; - - /** - * Number of passes to use for Cholesky factorization during LPC analysis - * - encoding: Set by user - * - decoding: unused - */ - attribute_deprecated int lpc_passes; -#endif - /** * Number of slices. * Indicates number of picture subdivisions. Used for parallelized @@ -3081,6 +2848,12 @@ typedef struct AVCodecContext { * libavcodec functions. */ struct AVCodecInternal *internal; + + /** Field order + * - encoding: set by libavcodec + * - decoding: Set by libavcodec + */ + enum AVFieldOrder field_order; } AVCodecContext; /** @@ -3165,6 +2938,19 @@ typedef struct AVCodec { * Initialize codec static data, called from avcodec_register(). */ void (*init_static_data)(struct AVCodec *codec); + + /** + * Encode data to an AVPacket. + * + * @param avctx codec context + * @param avpkt output AVPacket (may contain a user-provided buffer) + * @param[in] frame AVFrame containing the raw data to be encoded + * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in avpkt. + * @return 0 on success, negative error code on failure + */ + int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, + int *got_packet_ptr); } AVCodec; /** @@ -3268,29 +3054,6 @@ typedef struct AVPicture { #define AVPALETTE_SIZE 1024 #define AVPALETTE_COUNT 256 -#if FF_API_PALETTE_CONTROL -/** - * AVPaletteControl - * This structure defines a method for communicating palette changes - * between and demuxer and a decoder. - * - * @deprecated Use AVPacket to send palette changes instead. - * This is totally broken. - */ -typedef struct AVPaletteControl { - - /* Demuxer sets this to 1 to indicate the palette has changed; - * decoder resets to 0. */ - int palette_changed; - - /* 4-byte ARGB palette entries, stored in native byte order; note that - * the individual palette components should be on a 8-bit scale; if - * the palette data comes from an IBM VGA native format, the component - * data is probably 6 bits in size and needs to be scaled. */ - unsigned int palette[AVPALETTE_COUNT]; - -} AVPaletteControl attribute_deprecated; -#endif enum AVSubtitleType { SUBTITLE_NONE, @@ -3444,7 +3207,7 @@ typedef struct ReSampleContext ReSampleContext; * @param linear if 1 then the used FIR filter will be linearly interpolated between the 2 closest, if 0 the closest will be used * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate - * @return allocated ReSampleContext, NULL if error occured + * @return allocated ReSampleContext, NULL if error occurred */ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate, @@ -3580,14 +3343,6 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height); void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift); -#if FF_API_GET_PIX_FMT_NAME -/** - * @deprecated Deprecated in favor of av_get_pix_fmt_name(). - */ -attribute_deprecated -const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); -#endif - void avcodec_set_dimensions(AVCodecContext *s, int width, int height); /** @@ -3761,22 +3516,6 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); */ const char *av_get_profile_name(const AVCodec *codec, int profile); -#if FF_API_ALLOC_CONTEXT -/** - * Set the fields of the given AVCodecContext to default values. - * - * @param s The AVCodecContext of which the fields should be set to default values. - * @deprecated use avcodec_get_context_defaults3 - */ -attribute_deprecated -void avcodec_get_context_defaults(AVCodecContext *s); - -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ -attribute_deprecated -void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); -#endif - /** * Set the fields of the given AVCodecContext to default values corresponding * to the given codec (defaults may be codec-dependent). @@ -3788,25 +3527,6 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); */ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec); -#if FF_API_ALLOC_CONTEXT -/** - * Allocate an AVCodecContext and set its fields to default values. The - * resulting struct can be deallocated by simply calling av_free(). - * - * @return An AVCodecContext filled with default values or NULL on failure. - * @see avcodec_get_context_defaults - * - * @deprecated use avcodec_alloc_context3() - */ -attribute_deprecated -AVCodecContext *avcodec_alloc_context(void); - -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ -attribute_deprecated -AVCodecContext *avcodec_alloc_context2(enum AVMediaType); -#endif - /** * Allocate an AVCodecContext and set its fields to default values. The * resulting struct can be deallocated by simply calling av_free(). @@ -3885,14 +3605,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); -#if FF_API_THREAD_INIT -/** - * @deprecated Set s->thread_count before calling avcodec_open2() instead of calling this. - */ -attribute_deprecated -int avcodec_thread_init(AVCodecContext *s, int thread_count); -#endif - int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef @@ -3989,6 +3701,11 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * + * @warning You must not provide a custom get_buffer() when using + * avcodec_decode_audio3(). Doing so will override it with + * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead, + * which does allow the application to provide a custom get_buffer(). + * * @note You might have to align the input buffer avpkt->data and output buffer * samples. 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 @@ -4121,19 +3838,22 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, AVPacket *avpkt); /** - * Frees all allocated data in the given subtitle struct. + * Free all allocated data in the given subtitle struct. * * @param sub AVSubtitle to free. */ void avsubtitle_free(AVSubtitle *sub); +#if FF_API_OLD_ENCODE_AUDIO /** * Encode an audio frame from samples into buf. * + * @deprecated Use avcodec_encode_audio2 instead. + * * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. - * However, for PCM audio the user will know how much space is needed - * because it depends on the value passed in buf_size as described - * below. In that case a lower value can be used. + * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user + * will know how much space is needed because it depends on the value passed + * in buf_size as described below. In that case a lower value can be used. * * @param avctx the codec context * @param[out] buf the output buffer @@ -4141,13 +3861,79 @@ void avsubtitle_free(AVSubtitle *sub); * @param[in] samples the input buffer containing the samples * The number of samples read from this buffer is frame_size*channels, * both of which are defined in avctx. - * For PCM audio the number of samples read from samples is equal to - * buf_size * input_sample_size / output_sample_size. + * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of + * samples read from samples is equal to: + * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id)) + * This also implies that av_get_bits_per_sample() must not return 0 for these + * codecs. * @return On error a negative value is returned, on success zero or the number * of bytes used to encode the data read from the input buffer. */ -int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const short *samples); +int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx, + uint8_t *buf, int buf_size, + const short *samples); +#endif + +/** + * Encode a frame of audio. + * + * Takes input samples from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay, split, and combine input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. + * @param[in] frame AVFrame containing the raw audio data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * There are 2 codec capabilities that affect the allowed + * values of frame->nb_samples. + * If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final + * frame may be smaller than avctx->frame_size, and all other + * frames must be equal to avctx->frame_size. + * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame + * can have any number of samples. + * If neither is set, frame->nb_samples must be equal to + * avctx->frame_size for all frames. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + +/** + * Fill audio frame data and linesize. + * AVFrame extended_data channel pointers are allocated if necessary for + * planar audio. + * + * @param frame the AVFrame + * frame->nb_samples must be set prior to calling the + * function. This function fills in frame->data, + * frame->extended_data, frame->linesize[0]. + * @param nb_channels channel count + * @param sample_fmt sample format + * @param buf buffer to use for frame data + * @param buf_size size of buffer + * @param align plane size sample alignment + * @return 0 on success, negative error code on failure + */ +int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, + enum AVSampleFormat sample_fmt, const uint8_t *buf, + int buf_size, int align); /** * Encode a video frame from pict into buf. @@ -4189,18 +3975,6 @@ void avcodec_default_free_buffers(AVCodecContext *s); /* misc useful functions */ -#if FF_API_OLD_FF_PICT_TYPES -/** - * Return a single letter to describe the given picture type pict_type. - * - * @param[in] pict_type the picture type - * @return A single character representing the picture type. - * @deprecated Use av_get_picture_type_char() instead. - */ -attribute_deprecated -char av_get_pict_type_char(int pict_type); -#endif - /** * Return codec bits per sample. * @@ -4209,14 +3983,6 @@ char av_get_pict_type_char(int pict_type); */ int av_get_bits_per_sample(enum CodecID codec_id); -#if FF_API_OLD_SAMPLE_FMT -/** - * @deprecated Use av_get_bytes_per_sample() instead. - */ -attribute_deprecated -int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt); -#endif - /* frame parsing */ typedef struct AVCodecParserContext { void *priv_data; @@ -4486,7 +4252,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, unsigned int av_xiphlacing(unsigned char *s, unsigned int v); /** - * Logs a generic warning message about a missing feature. This function is + * Log a generic warning message about a missing feature. This function is * intended to be used internally by Libav (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is