Drop compatibility for FFmpeg < 1.2 and libav < 0.8.
Dropping support for unsupported upstream FFmpeg/libav versions makes our code simpler by removing preprocessor conditionals.
This commit is contained in:
parent
e77ad86b8d
commit
3416b2a8c1
|
@ -883,25 +883,14 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr))
|
|||
FFMPEG_INITALT(avformat, av_guess_format, guess_format);
|
||||
FFMPEG_INITALT(avformat, av_match_ext, match_ext);
|
||||
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 58, 0)
|
||||
FFMPEG_INITDYN(avcodec, av_init_packet);
|
||||
#else
|
||||
FFMPEG_INITDYN(avformat, av_init_packet);
|
||||
#endif
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT > AV_VERSION_INT(52, 31, 0)
|
||||
FFMPEG_INITDYN(avcodec, av_free_packet);
|
||||
#endif
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_encoder);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_encoder_by_name);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_decoder);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_open2);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_decode_audio4);
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 25, 0)
|
||||
FFMPEG_INITDYN(avcodec, avcodec_decode_audio3);
|
||||
#else
|
||||
FFMPEG_INITDYN(avcodec, avcodec_decode_audio2);
|
||||
#endif
|
||||
FFMPEG_INITDYN(avcodec, avcodec_encode_audio);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_encode_audio2);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_close);
|
||||
|
@ -917,11 +906,7 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr))
|
|||
FFMPEG_INITDYN(avutil, av_free);
|
||||
FFMPEG_INITDYN(avutil, av_log_set_callback);
|
||||
FFMPEG_INITDYN(avutil, av_log_default_callback);
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
FFMPEG_INITDYN(avutil, av_fifo_alloc);
|
||||
#else
|
||||
FFMPEG_INITDYN(avutil, av_fifo_init);
|
||||
#endif
|
||||
FFMPEG_INITDYN(avutil, av_fifo_generic_read);
|
||||
FFMPEG_INITDYN(avutil, av_fifo_realloc2);
|
||||
FFMPEG_INITDYN(avutil, av_fifo_free);
|
||||
|
|
59
src/FFmpeg.h
59
src/FFmpeg.h
|
@ -422,18 +422,7 @@ streamContext *import_ffmpeg_read_next_frame(AVFormatContext* formatContext,
|
|||
|
||||
int import_ffmpeg_decode_frame(streamContext *sc, bool flushing);
|
||||
|
||||
#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
|
||||
// Use the preprocessor to rename old function names instead of checking the
|
||||
// function names with FFMPEG_INITALT when loading the library.
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
|
||||
#define av_match_ext match_ext
|
||||
#endif
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
|
||||
#define av_guess_format guess_format
|
||||
#endif
|
||||
#else
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
|
||||
extern "C" {
|
||||
// A little explanation of what's going on here.
|
||||
//
|
||||
|
@ -600,21 +589,12 @@ extern "C" {
|
|||
(AVCodecContext *avctx, AVFrame *frame, int *got_output, const AVPacket *avpkt),
|
||||
(avctx, frame, got_output, avpkt)
|
||||
);
|
||||
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 25, 0)
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
avcodec_decode_audio3,
|
||||
(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt),
|
||||
(avctx, samples, frame_size_ptr, avpkt)
|
||||
);
|
||||
#else
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
avcodec_decode_audio2,
|
||||
(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, const uint8_t *buf, int buf_size),
|
||||
(avctx, samples, frame_size_ptr, buf, buf_size)
|
||||
);
|
||||
#endif
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
avcodec_encode_audio,
|
||||
|
@ -666,21 +646,12 @@ extern "C" {
|
|||
(void),
|
||||
()
|
||||
);
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 0, 0)
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
void*,
|
||||
av_fast_realloc,
|
||||
(void *ptr, unsigned int *size, unsigned int min_size),
|
||||
(ptr, size, min_size)
|
||||
);
|
||||
#else
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
void*,
|
||||
av_fast_realloc,
|
||||
(void *ptr, unsigned int *size, size_t min_size),
|
||||
(ptr, size, min_size)
|
||||
);
|
||||
#endif
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
avformat_open_input,
|
||||
|
@ -803,21 +774,12 @@ extern "C" {
|
|||
(AVFifoBuffer *f),
|
||||
(f)
|
||||
);
|
||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 0, 0)
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
void*,
|
||||
av_malloc,
|
||||
(unsigned int size),
|
||||
(size)
|
||||
);
|
||||
#else
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
void*,
|
||||
av_malloc,
|
||||
(size_t size),
|
||||
(size)
|
||||
);
|
||||
#endif
|
||||
FFMPEG_FUNCTION_NO_RETURN(
|
||||
av_freep,
|
||||
(void *ptr),
|
||||
|
@ -829,16 +791,11 @@ extern "C" {
|
|||
(int64_t a, AVRational bq, AVRational cq),
|
||||
(a, bq, cq)
|
||||
);
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT > AV_VERSION_INT(52, 31, 0)
|
||||
FFMPEG_FUNCTION_NO_RETURN(
|
||||
av_free_packet,
|
||||
(AVPacket *pkt),
|
||||
(pkt)
|
||||
);
|
||||
#endif
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
AVFifoBuffer*,
|
||||
av_fifo_alloc,
|
||||
|
@ -851,20 +808,6 @@ extern "C" {
|
|||
(AVFifoBuffer *f, void *buf, int buf_size, void (*func)(void*, void*, int)),
|
||||
(f, buf, buf_size, func)
|
||||
);
|
||||
#else
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
av_fifo_init,
|
||||
(AVFifoBuffer *f, unsigned int size),
|
||||
(f, size)
|
||||
);
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
av_fifo_generic_read,
|
||||
(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest),
|
||||
(f, buf_size, func, dest)
|
||||
);
|
||||
#endif
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int,
|
||||
av_fifo_realloc2,
|
||||
|
|
|
@ -154,10 +154,6 @@ private:
|
|||
uint8_t * mEncAudioFifoOutBuf; // buffer to read _out_ of the FIFO into
|
||||
int mEncAudioFifoOutBufSiz;
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(50, 0, 0)
|
||||
AVFifoBuffer mEncAudioFifoBuffer; // FIFO to write incoming audio samples into
|
||||
#endif
|
||||
|
||||
wxString mName;
|
||||
|
||||
int mSubFormat;
|
||||
|
@ -178,10 +174,6 @@ ExportFFmpeg::ExportFFmpeg()
|
|||
mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into
|
||||
mEncAudioFifoOutBufSiz = 0;
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(50, 0, 0)
|
||||
mEncAudioFifo = &mEncAudioFifoBuffer;
|
||||
#endif
|
||||
|
||||
mSampleRate = 0;
|
||||
mSupportsUTF8 = true;
|
||||
|
||||
|
@ -406,9 +398,6 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project)
|
|||
if (gPrefs->Read(wxT("/FileFormats/FFmpegBitReservoir"),true))
|
||||
av_dict_set(&options, "reservoir", "1", 0);
|
||||
if (gPrefs->Read(wxT("/FileFormats/FFmpegVariableBlockLen"),true)) mEncAudioCodecCtx->flags2 |= 0x0004; //WMA only?
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 0, 0)
|
||||
mEncAudioCodecCtx->use_lpc = gPrefs->Read(wxT("/FileFormats/FFmpegUseLPC"),true);
|
||||
#endif
|
||||
mEncAudioCodecCtx->compression_level = gPrefs->Read(wxT("/FileFormats/FFmpegCompLevel"),-1);
|
||||
mEncAudioCodecCtx->frame_size = gPrefs->Read(wxT("/FileFormats/FFmpegFrameSize"),(long)0);
|
||||
|
||||
|
@ -508,11 +497,7 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project)
|
|||
// The encoder may require a minimum number of raw audio samples for each encoding but we can't
|
||||
// guarantee we'll get this minimum each time an audio frame is decoded from the input file so
|
||||
// we use a FIFO to store up incoming raw samples until we have enough for one call to the codec.
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
mEncAudioFifo = av_fifo_alloc(1024);
|
||||
#else
|
||||
av_fifo_init(mEncAudioFifo, 1024);
|
||||
#endif
|
||||
|
||||
mEncAudioFifoOutBufSiz = 2*MAX_AUDIO_PACKET_SIZE;
|
||||
// Allocate a buffer to read OUT of the FIFO into. The FIFO maintains its own buffer internally.
|
||||
|
@ -662,11 +647,7 @@ bool ExportFFmpeg::Finalize()
|
|||
nFifoBytes, frame_size);
|
||||
|
||||
// Pull the bytes out from the FIFO and feed them to the encoder.
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
if (av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nFifoBytes, NULL) == 0)
|
||||
#else
|
||||
if (av_fifo_generic_read(mEncAudioFifo, nFifoBytes, NULL, mEncAudioFifoOutBuf) == 0)
|
||||
#endif
|
||||
{
|
||||
nEncodedBytes = encode_audio(mEncAudioCodecCtx, &pkt, (int16_t*)mEncAudioFifoOutBuf, frame_size);
|
||||
}
|
||||
|
@ -721,9 +702,7 @@ bool ExportFFmpeg::Finalize()
|
|||
|
||||
av_fifo_free(mEncAudioFifo);
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
mEncAudioFifo = NULL;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -753,11 +732,7 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, int frameSize)
|
|||
// Read raw audio samples out of the FIFO in nAudioFrameSizeOut byte-sized groups to encode.
|
||||
while ((ret = av_fifo_size(mEncAudioFifo)) >= nAudioFrameSizeOut)
|
||||
{
|
||||
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0)
|
||||
ret = av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nAudioFrameSizeOut, NULL);
|
||||
#else
|
||||
ret = av_fifo_generic_read(mEncAudioFifo, nAudioFrameSizeOut, NULL, mEncAudioFifoOutBuf);
|
||||
#endif
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user