From 47d1d00b2cdcc4523581044f369283ac5f5b26a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 29 Jul 2012 03:53:35 +0200 Subject: Enhance ffmpeg compatibility with older versions (cherry picked from commit e49a3521c025a535a26e2c3134b0031ef1af167f) --- plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp index 3f8daf1..d4b7778 100644 --- a/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp +++ b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp @@ -79,14 +79,22 @@ bool K3bFFMpegFile::open() close(); // open the file +# if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 2, 0) int err = avformat_open_input( &d->formatContext, m_filename.local8Bit(), 0, 0); +# else + int err = av_open_input_file( &d->formatContext, m_filename.local8Bit(), 0, 0, 0); +# endif if( err < 0 ) { kdDebug() << "(K3bFFMpegFile) unable to open " << m_filename << " with error " << err << endl; return false; } // analyze the streams +# if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 6, 0) avformat_find_stream_info( d->formatContext, NULL ); +# else + av_find_stream_info( d->formatContext ); +# endif // we only handle files containing one audio stream if( d->formatContext->nb_streams != 1 ) { @@ -114,7 +122,13 @@ bool K3bFFMpegFile::open() // open the codec on our context kdDebug() << "(K3bFFMpegFile) found codec for " << m_filename << endl; - if( avcodec_open2( codecContext, d->codec, NULL ) < 0 ) { + if( +# if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0) + avcodec_open2( codecContext, d->codec, NULL ) < 0 +# else + avcodec_open( codecContext, d->codec ) < 0 +# endif + ) { kdDebug() << "(K3bFFMpegDecoderFactory) could not open codec." << endl; return false; } @@ -128,7 +142,11 @@ bool K3bFFMpegFile::open() } // dump some debugging info +# if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 101, 0) av_dump_format( d->formatContext, 0, m_filename.local8Bit(), 0 ); +# else + dump_format( d->formatContext, 0, m_filename.local8Bit(), 0 ); +# endif return true; } @@ -150,7 +168,11 @@ void K3bFFMpegFile::close() } if( d->formatContext ) { +# if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0) avformat_close_input( &d->formatContext ); +# else + av_close_input_file( d->formatContext ); +# endif d->formatContext = 0; } } @@ -315,9 +337,15 @@ int K3bFFMpegFile::fillOutputBuffer() av_init_packet( &avp ); avp.data = d->packetData; avp.size = d->packetSize; +# if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 25, 0) int len = avcodec_decode_audio4( d->formatContext->streams[0]->codec, (AVFrame*)d->outputBuffer, &d->outputBufferSize, &avp ); +# else +int len = avcodec_decode_audio3( d->formatContext->streams[0]->codec, + (short*)d->outputBuffer, &d->outputBufferSize, + &avp ); +# endif #else #ifdef FFMPEG_BUILD_PRE_4629 int len = avcodec_decode_audio2( &d->formatContext->streams[0]->codec, -- cgit v1.2.3