Submitted By: Igor Živković Date: 2013-10-08 Initial Package Version: 2.0.2 Upstream Status: Unknown Origin: Gentoo Description: Fixes building against FFmpeg version >= 2.0.0 diff -Naur k3b-2.0.2.orig/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp k3b-2.0.2/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp --- k3b-2.0.2.orig/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp 2011-01-15 21:47:29.000000000 +0100 +++ k3b-2.0.2/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp 2013-10-08 12:35:48.478083003 +0200 @@ -37,6 +37,9 @@ #include +#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE +#define AVCODEC_MAX_AUDIO_FRAME_SIZE (192000 * 4) +#endif #if LIBAVFORMAT_BUILD < 4629 #define FFMPEG_BUILD_PRE_4629 @@ -88,14 +91,14 @@ close(); // open the file - int err = ::av_open_input_file( &d->formatContext, m_filename.toLocal8Bit(), 0, 0, 0 ); + int err = ::avformat_open_input( &d->formatContext, m_filename.toLocal8Bit(), 0, NULL); if( err < 0 ) { kDebug() << "(K3bFFMpegFile) unable to open " << m_filename << " with error " << err; return false; } // analyze the streams - ::av_find_stream_info( d->formatContext ); + ::avformat_find_stream_info( d->formatContext, 0 ); // we only handle files containing one audio stream if( d->formatContext->nb_streams != 1 ) { @@ -109,7 +112,13 @@ #else ::AVCodecContext* codecContext = d->formatContext->streams[0]->codec; #endif - if( codecContext->codec_type != CODEC_TYPE_AUDIO ) { + if( codecContext->codec_type != +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0) + AVMEDIA_TYPE_AUDIO) +#else + CODEC_TYPE_AUDIO) +#endif + { kDebug() << "(K3bFFMpegFile) not a simple audio stream: " << m_filename; return false; } @@ -123,7 +132,7 @@ // open the codec on our context kDebug() << "(K3bFFMpegFile) found codec for " << m_filename; - if( ::avcodec_open( codecContext, d->codec ) < 0 ) { + if( ::avcodec_open2( codecContext, d->codec, 0 ) < 0 ) { kDebug() << "(K3bFFMpegDecoderFactory) could not open codec."; return false; } @@ -137,7 +146,7 @@ } // dump some debugging info - ::dump_format( d->formatContext, 0, m_filename.toLocal8Bit(), 0 ); + ::av_dump_format( d->formatContext, 0, m_filename.toLocal8Bit(), 0 ); return true; } @@ -225,8 +234,11 @@ QString K3bFFMpegFile::title() const { // FIXME: is this UTF8 or something?? - if( d->formatContext->title[0] != '\0' ) - return QString::fromLocal8Bit( d->formatContext->title ); + AVDictionaryEntry *ade = av_dict_get( d->formatContext->metadata, "TITLE", NULL, 0 ); + if( ade == NULL ) + return QString(); + if( ade->value != '\0' ) + return QString::fromLocal8Bit( ade->value ); else return QString(); } @@ -235,8 +247,11 @@ QString K3bFFMpegFile::author() const { // FIXME: is this UTF8 or something?? - if( d->formatContext->author[0] != '\0' ) - return QString::fromLocal8Bit( d->formatContext->author ); + AVDictionaryEntry *ade = av_dict_get( d->formatContext->metadata, "ARTIST", NULL, 0 ); + if( ade == NULL ) + return QString(); + if( ade->value != '\0' ) + return QString::fromLocal8Bit( ade->value ); else return QString(); } @@ -245,8 +260,11 @@ QString K3bFFMpegFile::comment() const { // FIXME: is this UTF8 or something?? - if( d->formatContext->comment[0] != '\0' ) - return QString::fromLocal8Bit( d->formatContext->comment ); + AVDictionaryEntry *ade = av_dict_get( d->formatContext->metadata, "COMMENT", NULL, 0 ); + if( ade == NULL ) + return QString(); + if( ade->value != '\0' ) + return QString::fromLocal8Bit( ade->value ); else return QString(); } @@ -309,8 +327,13 @@ #if LIBAVCODEC_VERSION_MAJOR < 52 int len = ::avcodec_decode_audio( #else + #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0) + int len = ::avcodec_decode_audio3( + #else int len = ::avcodec_decode_audio2( + #endif #endif + #ifdef FFMPEG_BUILD_PRE_4629 &d->formatContext->streams[0]->codec, #else @@ -318,7 +341,11 @@ #endif (short*)d->alignedOutputBuffer, &d->outputBufferSize, +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0) + &d->packet ); +#else d->packetData, d->packetSize ); +#endif if( d->packetSize <= 0 || len < 0 ) ::av_free_packet( &d->packet );