]>
Commit | Line | Data |
---|---|---|
7c5d0ad2 JR |
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. | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | Signed-off-by: Oldřich Jedlička <oldium.pro@seznam.cz> | |
10 | --- | |
11 | plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp | 60 ++++++++++++++++++++++++----- | |
12 | 1 file changed, 50 insertions(+), 10 deletions(-) | |
13 | ||
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: | |
19 | K3b::Msf length; | |
20 | ||
21 | // for decoding. ffmpeg requires 16-byte alignment. | |
22 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
23 | + ::AVFrame* frame; | |
24 | +#else | |
25 | char outputBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE + 15]; | |
26 | char* alignedOutputBuffer; | |
27 | +#endif | |
28 | char* outputBufferPos; | |
29 | int outputBufferSize; | |
30 | ::AVPacket packet; | |
31 | @@ -102,14 +106,29 @@ K3bFFMpegFile::K3bFFMpegFile( const QString& filename ) | |
32 | d = new Private; | |
33 | d->formatContext = 0; | |
34 | d->codec = 0; | |
35 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
36 | +# if LIBAVCODEC_BUILD < AV_VERSION_INT(55,28,1) | |
37 | + d->frame = avcodec_alloc_frame(); | |
38 | +# else | |
39 | + d->frame = av_frame_alloc(); | |
40 | +# endif | |
41 | +#else | |
42 | int offset = 0x10 - (reinterpret_cast<intptr_t>(&d->outputBuffer) & 0xf); | |
43 | d->alignedOutputBuffer = &d->outputBuffer[offset]; | |
44 | +#endif | |
45 | } | |
46 | ||
47 | ||
48 | K3bFFMpegFile::~K3bFFMpegFile() | |
49 | { | |
50 | close(); | |
51 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
52 | +# if LIBAVCODEC_BUILD < AV_VERSION_INT(55,28,1) | |
53 | + av_free(d->frame); | |
54 | +# else | |
55 | + av_frame_free(&d->frame); | |
56 | +# endif | |
57 | +#endif | |
58 | delete d; | |
59 | } | |
60 | ||
61 | @@ -326,26 +345,36 @@ int K3bFFMpegFile::fillOutputBuffer() | |
62 | return 0; | |
63 | } | |
64 | ||
65 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
66 | + int gotFrame = 0; | |
67 | + int len = ::avcodec_decode_audio4( | |
68 | +#else | |
69 | d->outputBufferPos = d->alignedOutputBuffer; | |
70 | d->outputBufferSize = AVCODEC_MAX_AUDIO_FRAME_SIZE; | |
71 | - | |
72 | -#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3 | |
73 | +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3 | |
74 | int len = ::avcodec_decode_audio3( | |
75 | -#else | |
76 | -# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO2 | |
77 | - int len = ::avcodec_decode_audio2( | |
78 | # else | |
79 | +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO2 | |
80 | + int len = ::avcodec_decode_audio2( | |
81 | +# else | |
82 | int len = ::avcodec_decode_audio( | |
83 | +# endif | |
84 | # endif | |
85 | #endif | |
86 | ||
87 | FFMPEG_CODEC(d->formatContext->streams[0]), | |
88 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
89 | + d->frame, | |
90 | + &gotFrame, | |
91 | + &d->packet ); | |
92 | +#else | |
93 | (short*)d->alignedOutputBuffer, | |
94 | &d->outputBufferSize, | |
95 | -#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3 | |
96 | +# ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3 | |
97 | &d->packet ); | |
98 | -#else | |
99 | +# else | |
100 | d->packetData, d->packetSize ); | |
101 | +# endif | |
102 | #endif | |
103 | ||
104 | if( d->packetSize <= 0 || len < 0 ) | |
105 | @@ -355,6 +384,17 @@ int K3bFFMpegFile::fillOutputBuffer() | |
106 | return -1; | |
107 | } | |
108 | ||
109 | +#ifdef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4 | |
110 | + if ( gotFrame ) { | |
111 | + d->outputBufferSize = ::av_samples_get_buffer_size( | |
112 | + NULL, | |
113 | + FFMPEG_CODEC(d->formatContext->streams[0])->channels, | |
114 | + d->frame->nb_samples, | |
115 | + FFMPEG_CODEC(d->formatContext->streams[0])->sample_fmt, | |
116 | + 1 ); | |
117 | + d->outputBufferPos = reinterpret_cast<char*>( d->frame->data[0] ); | |
118 | + } | |
119 | +#endif | |
120 | d->packetSize -= len; | |
121 | d->packetData += len; | |
122 | } | |
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 | |
125 | // its thing. | |
126 | // | |
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 ) | |
133 | #endif | |
134 | return file; | |
135 | } | |
136 | -- | |
137 | 2.0.5 | |
138 |