1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-23 22:51:23 +01:00

Bug #176 - Support newer versions of FFmpeg.

Also includes Benjamin's ffmpeg-configure-v2.patch.
This commit is contained in:
lllucius
2011-04-02 02:10:50 +00:00
parent b55fb15b89
commit f50be91900
25 changed files with 1956 additions and 860 deletions

View File

@@ -22,7 +22,7 @@
#define AVCODEC_AVCODEC_H
/**
* @file libavcodec/avcodec.h
* @file
* external API header
*/
@@ -30,8 +30,8 @@
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 32
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_MINOR 72
#define LIBAVCODEC_VERSION_MICRO 2
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@@ -125,7 +125,9 @@ enum CodecID {
CODEC_ID_QDRAW,
CODEC_ID_VIXL,
CODEC_ID_QPEG,
#if LIBAVCODEC_VERSION_MAJOR < 53
CODEC_ID_XVID,
#endif
CODEC_ID_PNG,
CODEC_ID_PPM,
CODEC_ID_PBM,
@@ -198,6 +200,17 @@ enum CodecID {
CODEC_ID_V210,
CODEC_ID_DPX,
CODEC_ID_MAD,
CODEC_ID_FRWU,
CODEC_ID_FLASHSV2,
CODEC_ID_CDGRAPHICS,
CODEC_ID_R210,
CODEC_ID_ANM,
CODEC_ID_BINKVIDEO,
CODEC_ID_IFF_ILBM,
CODEC_ID_IFF_BYTERUN1,
CODEC_ID_KGV1,
CODEC_ID_YOP,
CODEC_ID_VP8,
/* various PCM "codecs" */
CODEC_ID_PCM_S16LE= 0x10000,
@@ -224,6 +237,7 @@ enum CodecID {
CODEC_ID_PCM_F32LE,
CODEC_ID_PCM_F64BE,
CODEC_ID_PCM_F64LE,
CODEC_ID_PCM_BLURAY,
/* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT= 0x11000,
@@ -319,6 +333,9 @@ enum CodecID {
CODEC_ID_TWINVQ,
CODEC_ID_TRUEHD,
CODEC_ID_MP4ALS,
CODEC_ID_ATRAC1,
CODEC_ID_BINKAUDIO_RDFT,
CODEC_ID_BINKAUDIO_DCT,
/* subtitle codecs */
CODEC_ID_DVD_SUBTITLE= 0x17000,
@@ -327,6 +344,8 @@ enum CodecID {
CODEC_ID_XSUB,
CODEC_ID_SSA,
CODEC_ID_MOV_TEXT,
CODEC_ID_HDMV_PGS_SUBTITLE,
CODEC_ID_DVB_TELETEXT,
/* other specific kind of codecs (generally used for attachments) */
CODEC_ID_TTF= 0x18000,
@@ -337,15 +356,17 @@ enum CodecID {
* stream (only used by libavformat) */
};
enum CodecType {
CODEC_TYPE_UNKNOWN = -1,
CODEC_TYPE_VIDEO,
CODEC_TYPE_AUDIO,
CODEC_TYPE_DATA,
CODEC_TYPE_SUBTITLE,
CODEC_TYPE_ATTACHMENT,
CODEC_TYPE_NB
};
#if LIBAVCODEC_VERSION_MAJOR < 53
#define CodecType AVMediaType
#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
#define CODEC_TYPE_NB AVMEDIA_TYPE_NB
#endif
/**
* all in native-endian format
@@ -382,6 +403,11 @@ enum SampleFormat {
#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
/** 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 0x8000000000000000LL
/* Audio channel convenience macros */
#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
@@ -394,6 +420,7 @@ enum SampleFormat {
#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
@@ -568,6 +595,9 @@ typedef struct RcOverride{
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
#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.
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
@@ -578,8 +608,9 @@ typedef struct RcOverride{
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
/**
* Codec uses get_buffer() for allocating buffers.
* direct rendering method 1
* Codec uses get_buffer() for allocating buffers and supports custom allocators.
* If not set, it might not use get_buffer() at all or use operations that
* assume the buffer was allocated by avcodec_default_get_buffer.
*/
#define CODEC_CAP_DR1 0x0002
/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
@@ -601,6 +632,23 @@ typedef struct RcOverride{
* Codec can export data for HW decoding (VDPAU).
*/
#define CODEC_CAP_HWACCEL_VDPAU 0x0080
/**
* Codec can output multiple frames per AVPacket
* Normally demuxers return one frame at a time, demuxers which do not do
* are connected to a parser to split what they return into proper frames.
* This flag is reserved to the very rare category of codecs which have a
* bitstream that cannot be split into frames without timeconsuming
* operations like full decoding. Demuxers carring such bitstreams thus
* may return multiple frames in a packet. This has many disadvantages like
* prohibiting stream copy in many cases thus it should only be considered
* as a last resort.
*/
#define CODEC_CAP_SUBFRAMES 0x0100
/**
* Codec is experimental and is thus avoided in favor of non experimental
* encoders
*/
#define CODEC_CAP_EXPERIMENTAL 0x0200
//The following defines may change, don't expect compatibility if you use them.
#define MB_TYPE_INTRA4x4 0x0001
@@ -860,7 +908,8 @@ typedef struct AVPanScan{
short *dct_coeff;\
\
/**\
* motion referece frame index\
* motion reference frame index\
* the order in which these are stored can depend on the codec.\
* - encoding: Set by user.\
* - decoding: Set by libavcodec.\
*/\
@@ -885,6 +934,7 @@ typedef struct AVPanScan{
#define FF_QSCALE_TYPE_MPEG1 0
#define FF_QSCALE_TYPE_MPEG2 1
#define FF_QSCALE_TYPE_H264 2
#define FF_QSCALE_TYPE_VP56 3
#define FF_BUFFER_TYPE_INTERNAL 1
#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
@@ -1235,7 +1285,7 @@ typedef struct AVCodecContext {
void *opaque;
char codec_name[32];
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
enum CodecID codec_id; /* see CODEC_ID_xxx */
/**
@@ -1274,6 +1324,7 @@ typedef struct AVCodecContext {
#define FF_BUG_HPEL_CHROMA 2048
#define FF_BUG_DC_CLIP 4096
#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
#define FF_BUG_TRUNCATED 16384
//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
/**
@@ -1331,7 +1382,7 @@ typedef struct AVCodecContext {
/**
* Called at the beginning of each frame to get a buffer for it.
* If pic.reference is set then the frame will be read later by libavcodec.
* avcodec_align_dimensions() should be used to find the required width and
* 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.
* if CODEC_CAP_DR1 is not set then get_buffer() must call
* avcodec_default_get_buffer() instead of providing buffers allocated by
@@ -1540,6 +1591,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_EA 21
#define FF_IDCT_SIMPLENEON 22
#define FF_IDCT_SIMPLEALPHA 23
#define FF_IDCT_BINK 24
/**
* slice count
@@ -2095,11 +2147,21 @@ typedef struct AVCodecContext {
*/
int profile;
#define FF_PROFILE_UNKNOWN -99
#define FF_PROFILE_AAC_MAIN 0
#define FF_PROFILE_AAC_LOW 1
#define FF_PROFILE_AAC_SSR 2
#define FF_PROFILE_AAC_LTP 3
#define FF_PROFILE_H264_BASELINE 66
#define FF_PROFILE_H264_MAIN 77
#define FF_PROFILE_H264_EXTENDED 88
#define FF_PROFILE_H264_HIGH 100
#define FF_PROFILE_H264_HIGH_10 110
#define FF_PROFILE_H264_HIGH_422 122
#define FF_PROFILE_H264_HIGH_444 244
#define FF_PROFILE_H264_CAVLC_444 44
/**
* level
* - encoding: Set by user.
@@ -2517,7 +2579,79 @@ typedef struct AVCodecContext {
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVChromaLocation chroma_sample_location;
enum AVChromaLocation chroma_sample_location;
/**
* The codec may call this to execute several independent things.
* It will return only after finishing all tasks.
* The user may replace this with some multithreaded implementation,
* the default implementation will execute the parts serially.
* Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
* @param c context passed also to func
* @param count the number of things to execute
* @param arg2 argument passed unchanged to func
* @param ret return values of executed functions, must have space for "count" values. May be NULL.
* @param func function that will be called count times, with jobnr from 0 to count-1.
* threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
* two instances of func executing at the same time will have the same threadnr.
* @return always 0 currently, but code should handle a future improvement where when any call to func
* returns < 0 no further calls to func may be done and < 0 is returned.
* - encoding: Set by libavcodec, user can override.
* - decoding: Set by libavcodec, user can override.
*/
int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
/**
* 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
*/
int weighted_p_pred;
/**
* AQ mode
* 0: Disabled
* 1: Variance AQ (complexity mask)
* 2: Auto-variance AQ (experimental)
* - encoding: Set by user
* - decoding: unused
*/
int aq_mode;
/**
* AQ strength
* Reduces blocking and blurring in flat and textured areas.
* - encoding: Set by user
* - decoding: unused
*/
float aq_strength;
/**
* PSY RD
* Strength of psychovisual optimization
* - encoding: Set by user
* - decoding: unused
*/
float psy_rd;
/**
* PSY trellis
* Strength of psychovisual optimization
* - encoding: Set by user
* - decoding: unused
*/
float psy_trellis;
/**
* RC lookahead
* Number of frames for frametype and ratecontrol lookahead
* - encoding: Set by user
* - decoding: unused
*/
int rc_lookahead;
} AVCodecContext;
/**
@@ -2531,7 +2665,7 @@ typedef struct AVCodec {
* This is the primary way to find a codec from the user perspective.
*/
const char *name;
enum CodecType type;
enum AVMediaType type;
enum CodecID id;
int priv_data_size;
int (*init)(AVCodecContext *);
@@ -2575,9 +2709,9 @@ typedef struct AVHWAccel {
/**
* Type of codec implemented by the hardware accelerator.
*
* See CODEC_TYPE_xxx
* See AVMEDIA_TYPE_xxx
*/
enum CodecType type;
enum AVMediaType type;
/**
* Codec implemented by the hardware accelerator.
@@ -2923,6 +3057,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *
const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* Returns the pixel format corresponding to the name name.
*
@@ -2933,9 +3068,18 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
* then for "gray16le".
*
* Finally if no pixel format has been found, returns PIX_FMT_NONE.
*
* @deprecated Deprecated in favor of av_get_pix_fmt().
*/
enum PixelFormat avcodec_get_pix_fmt(const char* name);
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
#endif
/**
* Returns a value representing the fourCC code associated to the
* pixel format pix_fmt, or 0 if no associated fourCC code can be
* found.
*/
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
@@ -3031,6 +3175,16 @@ AVCodec *av_codec_next(AVCodec *c);
*/
unsigned avcodec_version(void);
/**
* Returns the libavcodec build-time configuration.
*/
const char *avcodec_configuration(void);
/**
* Returns the libavcodec license.
*/
const char *avcodec_license(void);
/**
* Initializes libavcodec.
*
@@ -3095,7 +3249,7 @@ 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! */
void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
/**
* Allocates an AVCodecContext and sets its fields to default values. The
@@ -3108,7 +3262,20 @@ 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! */
AVCodecContext *avcodec_alloc_context2(enum CodecType);
AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
/**
* Copy the settings of the source AVCodecContext into the destination
* AVCodecContext. The resulting destination codec context will be
* unopened, i.e. you are required to call avcodec_open() before you
* can use this AVCodecContext to decode/encode video/audio data.
*
* @param dest target codec context, should be initialized with
* avcodec_alloc_context(), but otherwise uninitialized
* @param src source codec context
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
*/
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
/**
* Sets the fields of the given AVFrame to default values.
@@ -3129,7 +3296,36 @@ AVFrame *avcodec_alloc_frame(void);
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
/**
* Returns 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.
*/
unsigned avcodec_get_edge_width(void);
/**
* Modifies width and height values so that they will result in a memory
* buffer that is acceptable for the codec if you do not use any horizontal
* 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);
/**
* Modifies width and height values so that they will result in a memory
* buffer that is acceptable for the codec if you also ensure that all
* 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[4]);
/**
* Checks if the given dimension of a picture is valid, meaning that all
@@ -3144,8 +3340,8 @@ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum
int avcodec_thread_init(AVCodecContext *s, int thread_count);
void avcodec_thread_free(AVCodecContext *s);
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
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
/**
@@ -3199,9 +3395,11 @@ attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *s
/**
* Decodes the audio frame of size avpkt->size from avpkt->data into samples.
* Some decoders may support multiple frames in a single AVPacket, such
* decoders would then just decode the first frame.
* decoders would then just decode the first frame. In this case,
* avcodec_decode_audio3 has to be called again with an AVPacket that contains
* the remaining data in order to decode the second frame etc.
* If no frame
* could be decompressed, frame_size_ptr is zero. Otherwise, it is the
* could be outputted, frame_size_ptr is zero. Otherwise, it is the
* decompressed frame size in bytes.
*
* @warning You must set frame_size_ptr to the allocated size of the
@@ -3231,7 +3429,7 @@ attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *s
* data and size, some decoders might in addition need other fields.
* All decoders are designed to use the least fields possible though.
* @return On error a negative value is returned, otherwise the number of bytes
* used or zero if no frame could be decompressed.
* used or zero if no frame data was decompressed (used) from the input AVPacket.
*/
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
@@ -3276,14 +3474,16 @@ attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *pi
* In practice, avpkt->data should have 4 byte alignment at minimum.
*
* @note Some codecs have a delay between input and output, these need to be
* feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
* fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
*
* @param avctx the codec context
* @param[out] picture The AVFrame in which the decoded video frame will be stored.
* Use avcodec_alloc_frame to get an AVFrame, the codec will
* allocate memory for the actual bitmap.
* @param[in] avpkt The input AVpacket containing the input buffer.
* You can create such packet with av_init_packet() and by then setting
* data and size, some decoders might in addition need other fields like
* flags&PKT_FLAG_KEY. All decoders are designed to use the least
* flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
* fields possible.
* @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
* @return On error a negative value is returned, otherwise the number of bytes
@@ -3670,6 +3870,13 @@ int av_picture_crop(AVPicture *dst, const AVPicture *src,
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
int padtop, int padbottom, int padleft, int padright, int *color);
/**
* Encodes extradata length to a buffer. Used by xiph codecs.
*
* @param s buffer to write to; must be at least (v/255+1) bytes long
* @param v size of extradata in bytes
* @return number of bytes written to the buffer.
*/
unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
/**
@@ -3696,26 +3903,6 @@ int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
*/
int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
/* error handling */
#if EINVAL > 0
#define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */
#define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */
#else
/* Some platforms have E* and errno already negated. */
#define AVERROR(e) (e)
#define AVUNERROR(e) (e)
#endif
#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
#define AVERROR_IO AVERROR(EIO) /**< I/O error */
#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< Number syntax expected in filename. */
#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< Operation not supported. */
#define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */
#define AVERROR_EOF AVERROR(EPIPE) /**< End of file. */
#define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */
/**
* Logs a generic warning message about a missing feature. This function is
* intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)