~ubuntu-branches/ubuntu/trusty/k3b/trusty

« back to all changes in this revision

Viewing changes to debian/patches/kubuntu_06_libav_0.7.diff

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-11-12 10:36:01 UTC
  • mfrom: (2.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20131112103601-q6vvln9lv3mg7qxh
Tags: 2.0.2-7ubuntu1
* Merge with Debian, remaining changes:
  - Suggest, not recommend libk3b6-extracodecs (Cannot be on the CD)
  - Do not ship k3b documentation, it's for the KDE3 version.
  - Do not install unused scalable icons to save space
  - Keep kubuntu_02_kubuntu_restricted.diff
  - Keep kubuntu_03_no_missing_mp3_warn.diff
  - Keep kubuntu_05_no_system_settings.diff
  - Keep kubuntu_07_quicklists.diff
  - Disable 111_advice_debian_libk3b3-extracodes.diff and
    112_dont_require_mp3.diff which aren't required due to our mp3 patches.
  - swap kubuntu_06_libav_0.7.diff for Debian's
    Fixed_compilation_with_new_FFMPEG.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Port to libav 0.7 API
2
 
Author: Colin Watson <cjwatson@ubuntu.com>
3
 
Forwarded: no
4
 
Last-Update: 2011-08-21
5
 
 
6
 
Index: b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
7
 
===================================================================
8
 
--- a/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
9
 
+++ b/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
10
 
@@ -60,8 +60,10 @@
11
 
     char* outputBufferPos;
12
 
     int outputBufferSize;
13
 
     ::AVPacket packet;
14
 
-    quint8* packetData;
15
 
-    int packetSize;
16
 
+
17
 
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( 52, 31, 0 )
18
 
+    QString getMetadataEntry( const char* ) const;
19
 
+#endif
20
 
 };
21
 
 
22
 
 
23
 
@@ -73,6 +75,8 @@
24
 
     d->codec = 0;
25
 
     int offset = 0x10 - (reinterpret_cast<intptr_t>(&d->outputBuffer) & 0xf);
26
 
     d->alignedOutputBuffer = &d->outputBuffer[offset];
27
 
+    d->packet.data = 0;
28
 
+    d->packet.size = 0;
29
 
 }
30
 
 
31
 
 
32
 
@@ -88,7 +92,11 @@
33
 
     close();
34
 
 
35
 
     // open the file
36
 
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 53, 2, 0 )
37
 
     int err = ::av_open_input_file( &d->formatContext, m_filename.toLocal8Bit(), 0, 0, 0 );
38
 
+#else
39
 
+    int err = ::avformat_open_input( &d->formatContext, m_filename.toLocal8Bit(), 0, 0 );
40
 
+#endif
41
 
     if( err < 0 ) {
42
 
         kDebug() << "(K3bFFMpegFile) unable to open " << m_filename << " with error " << err;
43
 
         return false;
44
 
@@ -109,7 +117,12 @@
45
 
 #else
46
 
     ::AVCodecContext* codecContext =  d->formatContext->streams[0]->codec;
47
 
 #endif
48
 
-    if( codecContext->codec_type != CODEC_TYPE_AUDIO ) {
49
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
50
 
+    if( codecContext->codec_type != CODEC_TYPE_AUDIO )
51
 
+#else
52
 
+    if( codecContext->codec_type != AVMEDIA_TYPE_AUDIO )
53
 
+#endif
54
 
+    {
55
 
         kDebug() << "(K3bFFMpegFile) not a simple audio stream: " << m_filename;
56
 
         return false;
57
 
     }
58
 
@@ -137,7 +150,11 @@
59
 
     }
60
 
 
61
 
     // dump some debugging info
62
 
+#if LIBAVFORMAT_VERSION_MAJOR < 53
63
 
     ::dump_format( d->formatContext, 0, m_filename.toLocal8Bit(), 0 );
64
 
+#else
65
 
+    ::av_dump_format( d->formatContext, 0, m_filename.toLocal8Bit(), 0 );
66
 
+#endif
67
 
 
68
 
     return true;
69
 
 }
70
 
@@ -146,8 +163,7 @@
71
 
 void K3bFFMpegFile::close()
72
 
 {
73
 
     d->outputBufferSize = 0;
74
 
-    d->packetSize = 0;
75
 
-    d->packetData = 0;
76
 
+    ::av_free_packet( &d->packet );
77
 
 
78
 
     if( d->codec ) {
79
 
 #ifdef FFMPEG_BUILD_PRE_4629
80
 
@@ -222,33 +238,64 @@
81
 
 }
82
 
 
83
 
 
84
 
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( 52, 31, 0 )
85
 
+QString K3bFFMpegFile::Private::getMetadataEntry( const char* key ) const
86
 
+{
87
 
+#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT( 51, 5, 0 )
88
 
+    const ::AVMetadataTag* entry =
89
 
+        ::av_metadata_get( formatContext->metadata, key, 0, 0 );
90
 
+#else
91
 
+    const ::AVDictionaryEntry* entry =
92
 
+        ::av_dict_get( formatContext->metadata, key, 0, 0 );
93
 
+#endif
94
 
+    if( entry->value[0] != '\0' )
95
 
+        return QString::fromLocal8Bit( entry->value );
96
 
+    else
97
 
+        return QString();
98
 
+}
99
 
+#endif
100
 
+
101
 
 QString K3bFFMpegFile::title() const
102
 
 {
103
 
     // FIXME: is this UTF8 or something??
104
 
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 52, 31, 0 )
105
 
     if( d->formatContext->title[0] != '\0' )
106
 
         return QString::fromLocal8Bit( d->formatContext->title );
107
 
     else
108
 
         return QString();
109
 
+#else
110
 
+    return d->getMetadataEntry( "title" );
111
 
+#endif
112
 
 }
113
 
 
114
 
 
115
 
 QString K3bFFMpegFile::author() const
116
 
 {
117
 
     // FIXME: is this UTF8 or something??
118
 
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 52, 31, 0 )
119
 
     if( d->formatContext->author[0] != '\0' )
120
 
         return QString::fromLocal8Bit( d->formatContext->author );
121
 
     else
122
 
         return QString();
123
 
+#elif LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 52, 50, 0 )
124
 
+    return d->getMetadataEntry( "author" );
125
 
+#else
126
 
+    return d->getMetadataEntry( "artist" );
127
 
+#endif
128
 
 }
129
 
 
130
 
 
131
 
 QString K3bFFMpegFile::comment() const
132
 
 {
133
 
     // FIXME: is this UTF8 or something??
134
 
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 52, 31, 0 )
135
 
     if( d->formatContext->comment[0] != '\0' )
136
 
         return QString::fromLocal8Bit( d->formatContext->comment );
137
 
     else
138
 
         return QString();
139
 
+#else
140
 
+    return d->getMetadataEntry( "comment" );
141
 
+#endif
142
 
 }
143
 
 
144
 
 
145
 
@@ -275,24 +322,22 @@
146
 
 }
147
 
 
148
 
 
149
 
-// fill d->packetData with data to decode
150
 
+// fill d->packet.data with data to decode
151
 
 int K3bFFMpegFile::readPacket()
152
 
 {
153
 
-    if( d->packetSize <= 0 ) {
154
 
+    if( d->packet.size <= 0 ) {
155
 
         ::av_init_packet( &d->packet );
156
 
 
157
 
         if( ::av_read_frame( d->formatContext, &d->packet ) < 0 ) {
158
 
             return 0;
159
 
         }
160
 
-        d->packetSize = d->packet.size;
161
 
-        d->packetData = d->packet.data;
162
 
     }
163
 
 
164
 
-    return d->packetSize;
165
 
+    return d->packet.size;
166
 
 }
167
 
 
168
 
 
169
 
-// decode data in d->packetData and fill d->outputBuffer
170
 
+// decode data in d->packet.data and fill d->outputBuffer
171
 
 int K3bFFMpegFile::fillOutputBuffer()
172
 
 {
173
 
     // decode if the output buffer is empty
174
 
@@ -308,8 +353,10 @@
175
 
 
176
 
 #if LIBAVCODEC_VERSION_MAJOR < 52
177
 
         int len = ::avcodec_decode_audio(
178
 
-#else
179
 
+#elif LIBAVCODEC_VERSION_MAJOR < 53
180
 
         int len = ::avcodec_decode_audio2(
181
 
+#else
182
 
+        int len = ::avcodec_decode_audio3(
183
 
 #endif
184
 
 #ifdef FFMPEG_BUILD_PRE_4629
185
 
             &d->formatContext->streams[0]->codec,
186
 
@@ -318,17 +365,22 @@
187
 
 #endif
188
 
             (short*)d->alignedOutputBuffer,
189
 
             &d->outputBufferSize,
190
 
-            d->packetData, d->packetSize );
191
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
192
 
+            d->packet.data, d->packet.size
193
 
+#else
194
 
+            &d->packet
195
 
+#endif
196
 
+        );
197
 
 
198
 
-        if( d->packetSize <= 0 || len < 0 )
199
 
+        if( d->packet.size <= 0 || len < 0 )
200
 
             ::av_free_packet( &d->packet );
201
 
         if( len < 0 ) {
202
 
             kDebug() << "(K3bFFMpegFile) decoding failed for " << m_filename;
203
 
             return -1;
204
 
         }
205
 
 
206
 
-        d->packetSize -= len;
207
 
-        d->packetData += len;
208
 
+        d->packet.size -= len;
209
 
+        d->packet.data += len;
210
 
     }
211
 
 
212
 
     // if it is still empty try again
213
 
@@ -342,7 +394,7 @@
214
 
 bool K3bFFMpegFile::seek( const K3b::Msf& msf )
215
 
 {
216
 
     d->outputBufferSize = 0;
217
 
-    d->packetSize = 0;
218
 
+    d->packet.size = 0;
219
 
 
220
 
     double seconds = (double)msf.totalFrames()/75.0;
221
 
     quint64 timestamp = (quint64)(seconds * (double)AV_TIME_BASE);