Magellan Linux

Annotation of /trunk/xine-lib/patches/xine-lib-1.1.19-ffmpeg.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1559 - (hide annotations) (download)
Tue Nov 8 23:13:38 2011 UTC (12 years, 7 months ago) by niro
File size: 12075 byte(s)
added patch to fix build against newer ffmpeg
1 niro 1559 diff -r 717450d734f7 src/combined/ffmpeg/ff_audio_decoder.c
2     --- a/src/combined/ffmpeg/ff_audio_decoder.c Mon May 16 15:49:02 2011 +0100
3     +++ b/src/combined/ffmpeg/ff_audio_decoder.c Mon May 16 19:46:49 2011 -0400
4     @@ -46,6 +46,12 @@
5    
6     #define AUDIOBUFSIZE (64 * 1024)
7    
8     +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
9     +# define AVAUDIO 3
10     +#else
11     +# define AVAUDIO 2
12     +#endif
13     +
14     typedef struct {
15     audio_decoder_class_t decoder_class;
16     } ff_audio_class_t;
17     @@ -255,6 +261,9 @@
18     buf->decoder_info[2]);
19    
20     } else if (!(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
21     +#if AVAUDIO > 2
22     + AVPacket avpkt;
23     +#endif
24    
25     if( !this->decoder_ok ) {
26     if ( ! this->context || ! this->codec ) {
27     @@ -286,11 +295,21 @@
28     if (!this->output_open) {
29     if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
30     decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
31     +#if AVAUDIO > 2
32     + av_init_packet (&avpkt);
33     + avpkt.data = (uint8_t *)&this->buf[0];
34     + avpkt.size = this->size;
35     + avpkt.flags = AV_PKT_FLAG_KEY;
36     + avcodec_decode_audio3 (this->context,
37     + (int16_t *)this->decode_buffer,
38     + &decode_buffer_size, &avpkt);
39     +#else
40     avcodec_decode_audio2 (this->context,
41     (int16_t *)this->decode_buffer,
42     &decode_buffer_size,
43     &this->buf[0],
44     this->size);
45     +#endif
46     this->audio_bits = this->context->bits_per_sample;
47     this->audio_sample_rate = this->context->sample_rate;
48     this->audio_channels = this->context->channels;
49     @@ -311,12 +330,21 @@
50     offset = 0;
51     while (this->size>0) {
52     decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
53     +#if AVAUDIO > 2
54     + av_init_packet (&avpkt);
55     + avpkt.data = (uint8_t *)&this->buf[offset];
56     + avpkt.size = this->size;
57     + avpkt.flags = AV_PKT_FLAG_KEY;
58     + bytes_consumed = avcodec_decode_audio3 (this->context,
59     + (int16_t *)this->decode_buffer,
60     + &decode_buffer_size, &avpkt);
61     +#else
62     bytes_consumed = avcodec_decode_audio2 (this->context,
63     (int16_t *)this->decode_buffer,
64     &decode_buffer_size,
65     &this->buf[offset],
66     this->size);
67     -
68     +#endif
69     if (bytes_consumed<0) {
70     xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
71     "ffmpeg_audio_dec: error decompressing audio frame\n");
72     diff -r 717450d734f7 src/combined/ffmpeg/ff_video_decoder.c
73     --- a/src/combined/ffmpeg/ff_video_decoder.c Mon May 16 15:49:02 2011 +0100
74     +++ b/src/combined/ffmpeg/ff_video_decoder.c Mon May 16 19:46:49 2011 -0400
75     @@ -58,6 +58,14 @@
76    
77     #define ENABLE_DIRECT_RENDERING
78    
79     +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
80     +# define AVVIDEO 2
81     +#else
82     +# define AVVIDEO 1
83     +# define pp_context pp_context_t
84     +# define pp_mode pp_mode_t
85     +#endif
86     +
87     /* reordered_opaque appeared in libavcodec 51.68.0 */
88     #define AVCODEC_HAS_REORDERED_OPAQUE
89     #if LIBAVCODEC_VERSION_INT < 0x334400
90     @@ -116,8 +124,8 @@
91    
92     int pp_quality;
93     int pp_flags;
94     - pp_context_t *pp_context;
95     - pp_mode_t *pp_mode;
96     + pp_context *our_context;
97     + pp_mode *our_mode;
98    
99     /* mpeg-es parsing */
100     mpeg_parser_t *mpeg_parser;
101     @@ -444,23 +452,23 @@
102     this->pp_quality = this->class->pp_quality;
103    
104     if(this->pp_available && this->pp_quality) {
105     - if(!this->pp_context && this->context)
106     - this->pp_context = pp_get_context(this->context->width, this->context->height,
107     + if(!this->our_context && this->context)
108     + this->our_context = pp_get_context(this->context->width, this->context->height,
109     this->pp_flags);
110     - if(this->pp_mode)
111     - pp_free_mode(this->pp_mode);
112     + if(this->our_mode)
113     + pp_free_mode(this->our_mode);
114    
115     - this->pp_mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a",
116     + this->our_mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a",
117     this->pp_quality);
118     } else {
119     - if(this->pp_mode) {
120     - pp_free_mode(this->pp_mode);
121     - this->pp_mode = NULL;
122     + if(this->our_mode) {
123     + pp_free_mode(this->our_mode);
124     + this->our_mode = NULL;
125     }
126    
127     - if(this->pp_context) {
128     - pp_free_context(this->pp_context);
129     - this->pp_context = NULL;
130     + if(this->our_context) {
131     + pp_free_context(this->our_context);
132     + this->our_context = NULL;
133     }
134     }
135     }
136     @@ -1055,12 +1063,26 @@
137     }
138    
139     /* skip decoding b frames if too late */
140     +#if AVVIDEO > 1
141     + this->context->skip_frame = (this->skipframes > 0) ? AVDISCARD_NONREF : AVDISCARD_DEFAULT;
142     +#else
143     this->context->hurry_up = (this->skipframes > 0);
144     +#endif
145    
146     lprintf("avcodec_decode_video: size=%d\n", this->mpeg_parser->buffer_size);
147     +#if AVVIDEO > 1
148     + AVPacket avpkt;
149     + av_init_packet(&avpkt);
150     + avpkt.data = (uint8_t *)this->mpeg_parser->chunk_buffer;
151     + avpkt.size = this->mpeg_parser->buffer_size;
152     + avpkt.flags = AV_PKT_FLAG_KEY;
153     + len = avcodec_decode_video2 (this->context, this->av_frame,
154     + &got_picture, &avpkt);
155     +#else
156     len = avcodec_decode_video (this->context, this->av_frame,
157     &got_picture, this->mpeg_parser->chunk_buffer,
158     this->mpeg_parser->buffer_size);
159     +#endif
160     lprintf("avcodec_decode_video: decoded_size=%d, got_picture=%d\n",
161     len, got_picture);
162     len = current - buf->content - offset;
163     @@ -1112,7 +1134,13 @@
164    
165     } else {
166    
167     - if (this->context->hurry_up) {
168     + if (
169     +#if AVVIDEO > 1
170     + this->context->skip_frame != AVDISCARD_DEFAULT
171     +#else
172     + this->context->hurry_up
173     +#endif
174     + ) {
175     /* skipped frame, output a bad frame */
176     img = this->stream->video_out->get_frame (this->stream->video_out,
177     this->bih.biWidth,
178     @@ -1304,13 +1332,25 @@
179     got_picture = 0;
180     } else {
181     /* skip decoding b frames if too late */
182     +#if AVVIDEO > 1
183     + this->context->skip_frame = (this->skipframes > 0) ? AVDISCARD_NONREF : AVDISCARD_DEFAULT;
184     +#else
185     this->context->hurry_up = (this->skipframes > 0);
186     -
187     +#endif
188     lprintf("buffer size: %d\n", this->size);
189     +#if AVVIDEO > 1
190     + AVPacket avpkt;
191     + av_init_packet(&avpkt);
192     + avpkt.data = (uint8_t *)&chunk_buf[offset];
193     + avpkt.size = this->size;
194     + avpkt.flags = AV_PKT_FLAG_KEY;
195     + len = avcodec_decode_video2 (this->context, this->av_frame,
196     + &got_picture, &avpkt);
197     +#else
198     len = avcodec_decode_video (this->context, this->av_frame,
199     &got_picture, &chunk_buf[offset],
200     this->size);
201     -
202     +#endif
203     #ifdef AVCODEC_HAS_REORDERED_OPAQUE
204     /* reset consumed pts value */
205     this->context->reordered_opaque = ff_tag_pts(this, 0);
206     @@ -1432,7 +1472,7 @@
207     img->base, img->pitches,
208     img->width, img->height,
209     this->av_frame->qscale_table, this->av_frame->qstride,
210     - this->pp_mode, this->pp_context,
211     + this->our_mode, this->our_context,
212     this->av_frame->pict_type);
213    
214     } else if (!this->av_frame->opaque) {
215     @@ -1676,11 +1716,11 @@
216     free(this->buf);
217     this->buf = NULL;
218    
219     - if(this->pp_context)
220     - pp_free_context(this->pp_context);
221     + if(this->our_context)
222     + pp_free_context(this->our_context);
223    
224     - if(this->pp_mode)
225     - pp_free_mode(this->pp_mode);
226     + if(this->our_mode)
227     + pp_free_mode(this->our_mode);
228    
229     mpeg_parser_dispose(this->mpeg_parser);
230    
231     @@ -1721,8 +1761,8 @@
232     this->aspect_ratio = 0;
233    
234     this->pp_quality = 0;
235     - this->pp_context = NULL;
236     - this->pp_mode = NULL;
237     + this->our_context = NULL;
238     + this->our_mode = NULL;
239    
240     this->mpeg_parser = NULL;
241    
242     diff -r 717450d734f7 src/post/planar/pp.c
243     --- a/src/post/planar/pp.c Mon May 16 15:49:02 2011 +0100
244     +++ b/src/post/planar/pp.c Mon May 16 19:46:49 2011 -0400
245     @@ -35,6 +35,12 @@
246     # include <libpostproc/postprocess.h>
247     #endif
248    
249     +#if LIBPOSTPROC_VERSION_MAJOR < 52
250     +# define pp_context pp_context_t
251     +# define pp_mode pp_mode_t
252     +# define PP_PARAMETERS_T
253     +#endif
254     +
255     #define PP_STRING_SIZE 256 /* size of pp mode string (including all options) */
256    
257     /* plugin class initialization function */
258     @@ -76,14 +82,15 @@
259    
260     /* libpostproc specific stuff */
261     int pp_flags;
262     - pp_context_t *pp_context;
263     - pp_mode_t *pp_mode;
264     + pp_context *our_context;
265     + pp_mode *our_mode;
266    
267     pthread_mutex_t lock;
268     };
269    
270    
271     static int set_parameters (xine_post_t *this_gen, void *param_gen) {
272     +#ifdef PP_PARAMETERS_T
273     post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
274     pp_parameters_t *param = (pp_parameters_t *)param_gen;
275    
276     @@ -92,17 +99,18 @@
277     memcpy( &this->params, param, sizeof(pp_parameters_t) );
278    
279     pthread_mutex_unlock (&this->lock);
280     -
281     +#endif
282     return 1;
283     }
284    
285     static int get_parameters (xine_post_t *this_gen, void *param_gen) {
286     +#ifdef PP_PARAMETERS_T
287     post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
288     pp_parameters_t *param = (pp_parameters_t *)param_gen;
289    
290    
291     memcpy( param, &this->params, sizeof(pp_parameters_t) );
292     -
293     +#endif
294     return 1;
295     }
296    
297     @@ -202,8 +210,8 @@
298     if(cpu_caps & MM_ACCEL_X86_3DNOW)
299     this->pp_flags |= PP_CPU_CAPS_3DNOW;
300    
301     - this->pp_mode = NULL;
302     - this->pp_context = NULL;
303     + this->our_mode = NULL;
304     + this->our_context = NULL;
305    
306     pthread_mutex_init (&this->lock, NULL);
307    
308     @@ -248,13 +256,13 @@
309     post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
310    
311     if (_x_post_dispose(this_gen)) {
312     - if(this->pp_mode) {
313     - pp_free_mode(this->pp_mode);
314     - this->pp_mode = NULL;
315     + if(this->our_mode) {
316     + pp_free_mode(this->our_mode);
317     + this->our_mode = NULL;
318     }
319     - if(this->pp_context) {
320     - pp_free_context(this->pp_context);
321     - this->pp_context = NULL;
322     + if(this->our_context) {
323     + pp_free_context(this->our_context);
324     + this->our_context = NULL;
325     }
326     free(this);
327     }
328     @@ -304,7 +312,7 @@
329    
330     pthread_mutex_lock (&this->lock);
331    
332     - if( !this->pp_context ||
333     + if( !this->our_context ||
334     this->frame_width != yv12_frame->width ||
335     this->frame_height != yv12_frame->height ) {
336    
337     @@ -312,32 +320,32 @@
338     this->frame_height = yv12_frame->height;
339     pp_flags = this->pp_flags;
340    
341     - if(this->pp_context)
342     - pp_free_context(this->pp_context);
343     + if(this->our_context)
344     + pp_free_context(this->our_context);
345    
346     - this->pp_context = pp_get_context(frame->width, frame->height, pp_flags);
347     + this->our_context = pp_get_context(frame->width, frame->height, pp_flags);
348    
349     - if(this->pp_mode) {
350     - pp_free_mode(this->pp_mode);
351     - this->pp_mode = NULL;
352     + if(this->our_mode) {
353     + pp_free_mode(this->our_mode);
354     + this->our_mode = NULL;
355     }
356     }
357    
358     - if(!this->pp_mode)
359     - this->pp_mode = pp_get_mode_by_name_and_quality(this->params.mode,
360     + if(!this->our_mode)
361     + this->our_mode = pp_get_mode_by_name_and_quality(this->params.mode,
362     this->params.quality);
363    
364     - if(this->pp_mode)
365     + if(this->our_mode)
366     pp_postprocess(yv12_frame->base, yv12_frame->pitches,
367     out_frame->base, out_frame->pitches,
368     (frame->width+7)&(~7), frame->height,
369     NULL, 0,
370     - this->pp_mode, this->pp_context,
371     + this->our_mode, this->our_context,
372     0 /*this->av_frame->pict_type*/);
373    
374     pthread_mutex_unlock (&this->lock);
375    
376     - if(this->pp_mode) {
377     + if(this->our_mode) {
378     skip = out_frame->draw(out_frame, stream);
379     _x_post_frame_copy_up(frame, out_frame);
380     } else {