1 From 52d3d64863d2fab4128f524870851f18f5cae1fc Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= <oldium.pro@seznam.cz>
3 Date: Sat, 14 Feb 2015 15:31:07 +0100
4 Subject: [PATCH] Fixed compilation with newer ffmpeg/libav.
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Signed-off-by: Oldřich Jedlička <oldium.pro@seznam.cz>
11 plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp | 60 ++++++++++++++++++++++++-----
12 1 file changed, 50 insertions(+), 10 deletions(-)
14 diff --git a/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
15 index 5451fd3..2f80fd6 100644
16 --- a/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
17 +++ b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
18 @@ -86,8 +86,12 @@ public:
21 // for decoding. ffmpeg requires 16-byte alignment.
22 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
25 char outputBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE + 15];
26 char* alignedOutputBuffer;
28 char* outputBufferPos;
31 @@ -102,14 +106,29 @@ K3bFFMpegFile::K3bFFMpegFile( const QString& filename )
35 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
36 +# if LIBAVCODEC_BUILD < AV_VERSION_INT(55,28,1)
37 + d->frame = avcodec_alloc_frame();
39 + d->frame = av_frame_alloc();
42 int offset = 0x10 - (reinterpret_cast<intptr_t>(&d->outputBuffer) & 0xf);
43 d->alignedOutputBuffer = &d->outputBuffer[offset];
48 K3bFFMpegFile::~K3bFFMpegFile()
51 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
52 +# if LIBAVCODEC_BUILD < AV_VERSION_INT(55,28,1)
55 + av_frame_free(&d->frame);
61 @@ -326,26 +345,36 @@ int K3bFFMpegFile::fillOutputBuffer()
65 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
67 + int len = ::avcodec_decode_audio4(
69 d->outputBufferPos = d->alignedOutputBuffer;
70 d->outputBufferSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
72 -#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3
73 +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3
74 int len = ::avcodec_decode_audio3(
76 -# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO2
77 - int len = ::avcodec_decode_audio2(
79 +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO2
80 + int len = ::avcodec_decode_audio2(
82 int len = ::avcodec_decode_audio(
87 FFMPEG_CODEC(d->formatContext->streams[0]),
88 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
93 (short*)d->alignedOutputBuffer,
95 -#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3
96 +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3
100 d->packetData, d->packetSize );
104 if( d->packetSize <= 0 || len < 0 )
105 @@ -355,6 +384,17 @@ int K3bFFMpegFile::fillOutputBuffer()
109 +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
111 + d->outputBufferSize = ::av_samples_get_buffer_size(
113 + FFMPEG_CODEC(d->formatContext->streams[0])->channels,
114 + d->frame->nb_samples,
115 + FFMPEG_CODEC(d->formatContext->streams[0])->sample_fmt,
117 + d->outputBufferPos = reinterpret_cast<char*>( d->frame->data[0] );
120 d->packetSize -= len;
121 d->packetData += len;
123 @@ -420,9 +460,9 @@ K3bFFMpegFile* K3bFFMpegWrapper::open( const QString& filename ) const
124 // mp3 being one of them sadly. Most importantly: allow the libsndfile decoder to do
127 - if( file->type() == CODEC_ID_WMAV1 ||
128 - file->type() == CODEC_ID_WMAV2 ||
129 - file->type() == CODEC_ID_AAC )
130 + if( file->type() == AV_CODEC_ID_WMAV1 ||
131 + file->type() == AV_CODEC_ID_WMAV2 ||
132 + file->type() == AV_CODEC_ID_AAC )