diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2012-07-29 03:53:35 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2012-07-29 03:53:35 +0200 |
commit | e49a3521c025a535a26e2c3134b0031ef1af167f (patch) | |
tree | 2a9876d14b049748bfea43a6e004bd2740583c12 /plugins | |
parent | cc573f249314771eb5e6615ff85a23629ad25838 (diff) | |
download | k3b-e49a3521c025a535a26e2c3134b0031ef1af167f.tar.gz k3b-e49a3521c025a535a26e2c3134b0031ef1af167f.zip |
Enhance ffmpeg compatibility with older versions
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
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, |