]> git.sesse.net Git - vlc/blob - modules/codec/libmpeg2.c
* modules/codec/libmpeg2.c: use the DTS in the synchro algorithm.
[vlc] / modules / codec / libmpeg2.c
1 /*****************************************************************************
2  * libmpeg2.c: mpeg2 video decoder module making use of libmpeg2.
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <vlc/vlc.h>
29 #include <vlc/vout.h>
30 #include <vlc/decoder.h>
31
32 #include <mpeg2dec/mpeg2.h>
33
34 #include "vout_synchro.h"
35
36 /* Aspect ratio (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
37 #define AR_SQUARE_PICTURE       1                           /* square pixels */
38 #define AR_3_4_PICTURE          2                        /* 3:4 picture (TV) */
39 #define AR_16_9_PICTURE         3              /* 16:9 picture (wide screen) */
40 #define AR_221_1_PICTURE        4                  /* 2.21:1 picture (movie) */
41
42 /*****************************************************************************
43  * decoder_sys_t : libmpeg2 decoder descriptor
44  *****************************************************************************/
45 struct decoder_sys_t
46 {
47     /*
48      * libmpeg2 properties
49      */
50     mpeg2dec_t          *p_mpeg2dec;
51     const mpeg2_info_t  *p_info;
52     vlc_bool_t          b_skip;
53
54     /*
55      * Input properties
56      */
57     mtime_t          i_previous_pts;
58     mtime_t          i_current_pts;
59     mtime_t          i_previous_dts;
60     mtime_t          i_current_dts;
61     int              i_current_rate;
62     picture_t *      p_picture_to_destroy;
63     vlc_bool_t       b_garbage_pic;
64     vlc_bool_t       b_after_sequence_header; /* is it the next frame after
65                                                * the sequence header ?    */
66     vlc_bool_t       b_slice_i;             /* intra-slice refresh stream */
67
68     /*
69      * Output properties
70      */
71     vout_synchro_t *p_synchro;
72     int            i_aspect;
73     mtime_t        i_last_frame_pts;
74
75 };
76
77 /*****************************************************************************
78  * Local prototypes
79  *****************************************************************************/
80 static int  OpenDecoder( vlc_object_t * );
81 static void CloseDecoder( vlc_object_t * );
82
83 static picture_t *DecodeBlock( decoder_t *, block_t ** );
84
85 static picture_t *GetNewPicture( decoder_t *, uint8_t ** );
86
87 /*****************************************************************************
88  * Module descriptor
89  *****************************************************************************/
90 vlc_module_begin();
91     set_description( _("MPEG I/II video decoder (using libmpeg2)") );
92     set_capability( "decoder", 150 );
93     set_callbacks( OpenDecoder, CloseDecoder );
94     add_shortcut( "libmpeg2" );
95 vlc_module_end();
96
97 /*****************************************************************************
98  * OpenDecoder: probe the decoder and return score
99  *****************************************************************************/
100 static int OpenDecoder( vlc_object_t *p_this )
101 {
102     decoder_t *p_dec = (decoder_t*)p_this;
103     decoder_sys_t *p_sys;
104     uint32_t i_accel = 0;
105
106     if( p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','v') &&
107         p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','1') &&
108         /* Pinnacle hardware-mpeg1 */
109         p_dec->fmt_in.i_codec != VLC_FOURCC('P','I','M','1') &&
110         /* ATI Video */
111         p_dec->fmt_in.i_codec != VLC_FOURCC('V','C','R','2') &&
112         p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','2') )
113     {
114         return VLC_EGENERIC;
115     }
116
117     /* Allocate the memory needed to store the decoder's structure */
118     if( ( p_dec->p_sys = p_sys =
119           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
120     {
121         msg_Err( p_dec, "out of memory" );
122         return VLC_EGENERIC;
123     }
124
125     /* Initialize the thread properties */
126     memset( p_sys, 0, sizeof(decoder_sys_t) );
127     p_sys->p_mpeg2dec = NULL;
128     p_sys->p_synchro  = NULL;
129     p_sys->p_info     = NULL;
130     p_sys->i_current_pts  = 0;
131     p_sys->i_previous_pts = 0;
132     p_sys->i_current_dts  = 0;
133     p_sys->i_previous_dts = 0;
134     p_sys->p_picture_to_destroy = NULL;
135     p_sys->b_garbage_pic = 0;
136     p_sys->b_slice_i  = 0;
137     p_sys->b_skip     = 0;
138
139 #if defined( __i386__ )
140     if( p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_MMX )
141     {
142         i_accel |= MPEG2_ACCEL_X86_MMX;
143     }
144
145     if( p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_3DNOW )
146     {
147         i_accel |= MPEG2_ACCEL_X86_3DNOW;
148     }
149
150     if( p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT )
151     {
152         i_accel |= MPEG2_ACCEL_X86_MMXEXT;
153     }
154
155 #elif defined( __powerpc__ ) || defined( SYS_DARWIN )
156     if( p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_ALTIVEC )
157     {
158         i_accel |= MPEG2_ACCEL_PPC_ALTIVEC;
159     }
160
161 #else
162     /* If we do not know this CPU, trust libmpeg2's feature detection */
163     i_accel = MPEG2_ACCEL_DETECT;
164
165 #endif
166
167     /* Set CPU acceleration features */
168     mpeg2_accel( i_accel );
169
170     /* Initialize decoder */
171     p_sys->p_mpeg2dec = mpeg2_init();
172     if( p_sys->p_mpeg2dec == NULL)
173     {
174         msg_Err( p_dec, "mpeg2_init() failed" );
175         free( p_sys );
176         return VLC_EGENERIC;
177     }
178
179     p_sys->p_info = mpeg2_info( p_sys->p_mpeg2dec );
180
181     p_dec->pf_decode_video = DecodeBlock;
182
183     return VLC_SUCCESS;
184 }
185
186 /*****************************************************************************
187  * RunDecoder: the libmpeg2 decoder
188  *****************************************************************************/
189 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
190 {
191     decoder_sys_t   *p_sys = p_dec->p_sys;
192     mpeg2_state_t   state;
193     picture_t       *p_pic;
194
195     block_t *p_block;
196
197     if( !pp_block || !*pp_block ) return NULL;
198
199     p_block = *pp_block;
200
201     while( 1 )
202     {
203         state = mpeg2_parse( p_sys->p_mpeg2dec );
204
205         switch( state )
206         {
207         case STATE_BUFFER:
208             if( !p_block->i_buffer )
209             {
210                 block_Release( p_block );
211                 return NULL;
212             }
213
214             if( (p_block->i_flags&BLOCK_FLAG_DISCONTINUITY) &&
215                 p_sys->p_synchro &&
216                 p_sys->p_info->sequence &&
217                 p_sys->p_info->sequence->width != (unsigned)-1 )
218             {
219                 vout_SynchroReset( p_sys->p_synchro );
220                 if( p_sys->p_info->current_fbuf != NULL
221                     && p_sys->p_info->current_fbuf->id != NULL )
222                 {
223                     p_sys->b_garbage_pic = 1;
224                     p_pic = p_sys->p_info->current_fbuf->id;
225                 }
226                 else
227                 {
228                     uint8_t *buf[3];
229                     buf[0] = buf[1] = buf[2] = NULL;
230                     if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
231                         break;
232                     mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
233                 }
234                 p_sys->p_picture_to_destroy = p_pic;
235
236                 if ( p_sys->b_slice_i )
237                 {
238                     vout_SynchroNewPicture( p_sys->p_synchro,
239                         I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
240                     vout_SynchroDecode( p_sys->p_synchro );
241                     vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
242                 }
243             }
244
245 #ifdef PIC_FLAG_PTS
246             if( p_block->i_pts )
247             {
248                 mpeg2_pts( p_sys->p_mpeg2dec, (uint32_t)p_block->i_pts );
249
250 #else /* New interface */
251             if( p_block->i_pts || p_block->i_dts )
252             {
253                 mpeg2_tag_picture( p_sys->p_mpeg2dec,
254                                    (uint32_t)p_block->i_pts,
255                                    (uint32_t)p_block->i_dts );
256 #endif
257                 p_sys->i_previous_pts = p_sys->i_current_pts;
258                 p_sys->i_current_pts = p_block->i_pts;
259                 p_sys->i_previous_dts = p_sys->i_current_dts;
260                 p_sys->i_current_dts = p_block->i_dts;
261             }
262
263             p_sys->i_current_rate = p_block->i_rate;
264
265             mpeg2_buffer( p_sys->p_mpeg2dec, p_block->p_buffer,
266                           p_block->p_buffer + p_block->i_buffer );
267
268             p_block->i_buffer = 0;
269             break;
270
271         case STATE_SEQUENCE:
272         {
273             /* Initialize video output */
274             uint8_t *buf[3];
275             buf[0] = buf[1] = buf[2] = NULL;
276
277             /* Check whether the input gave a particular aspect ratio */
278             if( p_dec->fmt_in.video.i_aspect )
279             {
280                 p_sys->i_aspect = p_dec->fmt_in.video.i_aspect;
281                 if( p_sys->i_aspect <= AR_221_1_PICTURE )
282                 switch( p_sys->i_aspect )
283                 {
284                 case AR_3_4_PICTURE:
285                     p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
286                     break;
287                 case AR_16_9_PICTURE:
288                     p_sys->i_aspect = VOUT_ASPECT_FACTOR * 16 / 9;
289                     break;
290                 case AR_221_1_PICTURE:
291                     p_sys->i_aspect = VOUT_ASPECT_FACTOR * 221 / 100;
292                     break;
293                 case AR_SQUARE_PICTURE:
294                     p_sys->i_aspect = VOUT_ASPECT_FACTOR *
295                                    p_sys->p_info->sequence->width /
296                                    p_sys->p_info->sequence->height;
297                     break;
298                 }
299             }
300             else
301             {
302                 /* Use the value provided in the MPEG sequence header */
303                 if( p_sys->p_info->sequence->pixel_height > 0 )
304                 {
305                     p_sys->i_aspect =
306                         ((uint64_t)p_sys->p_info->sequence->display_width) *
307                         p_sys->p_info->sequence->pixel_width *
308                         VOUT_ASPECT_FACTOR /
309                         p_sys->p_info->sequence->display_height /
310                         p_sys->p_info->sequence->pixel_height;
311                 }
312                 else
313                 {
314                     /* Invalid aspect, assume 4:3.
315                      * This shouldn't happen and if it does it is a bug
316                      * in libmpeg2 (likely triggered by an invalid stream) */
317                     p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
318                 }
319             }
320
321             msg_Dbg( p_dec, "%dx%d, aspect %d, %u.%03u fps",
322                      p_sys->p_info->sequence->width,
323                      p_sys->p_info->sequence->height, p_sys->i_aspect,
324                      (uint32_t)((uint64_t)1001000000 * 27 /
325                          p_sys->p_info->sequence->frame_period / 1001),
326                      (uint32_t)((uint64_t)1001000000 * 27 /
327                          p_sys->p_info->sequence->frame_period % 1001) );
328
329             mpeg2_custom_fbuf( p_sys->p_mpeg2dec, 1 );
330
331             /* Set the first 2 reference frames */
332             mpeg2_set_buf( p_sys->p_mpeg2dec, buf, NULL );
333
334             if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
335             {
336                 block_Release( p_block );
337                 return NULL;
338             }
339
340             mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
341
342             /* This picture will never go through display_picture. */
343             p_pic->date = 0;
344
345             /* For some reason, libmpeg2 will put this pic twice in
346              * discard_picture. This can be considered a bug in libmpeg2. */
347             p_dec->pf_picture_link( p_dec, p_pic );
348
349             if( p_sys->p_synchro )
350             {
351                 vout_SynchroRelease( p_sys->p_synchro );
352             }
353             p_sys->p_synchro = vout_SynchroInit( p_dec,
354                 (uint32_t)((uint64_t)1001000000 * 27 /
355                 p_sys->p_info->sequence->frame_period) );
356             p_sys->b_after_sequence_header = 1;
357         }
358         break;
359
360         case STATE_PICTURE_2ND:
361             vout_SynchroNewPicture( p_sys->p_synchro,
362                 p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
363                 p_sys->p_info->current_picture->nb_fields,
364                 0, 0, p_sys->i_current_rate );
365
366             if( p_sys->b_skip )
367             {
368                 vout_SynchroTrash( p_sys->p_synchro );
369             }
370             else
371             {
372                 vout_SynchroDecode( p_sys->p_synchro );
373             }
374             break;
375
376         case STATE_PICTURE:
377         {
378             uint8_t *buf[3];
379             mtime_t i_pts, i_dts;
380             buf[0] = buf[1] = buf[2] = NULL;
381
382             if ( p_sys->b_after_sequence_header &&
383                  ((p_sys->p_info->current_picture->flags &
384                        PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) )
385             {
386                 /* Intra-slice refresh. Simulate a blank I picture. */
387                 msg_Dbg( p_dec, "intra-slice refresh stream" );
388                 vout_SynchroNewPicture( p_sys->p_synchro,
389                     I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
390                 vout_SynchroDecode( p_sys->p_synchro );
391                 vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
392                 p_sys->b_slice_i = 1;
393             }
394             p_sys->b_after_sequence_header = 0;
395
396 #ifdef PIC_FLAG_PTS
397             i_pts = p_sys->p_info->current_picture->flags & PIC_FLAG_PTS ?
398                 ( ( p_sys->p_info->current_picture->pts ==
399                     (uint32_t)p_sys->i_current_pts ) ?
400                   p_sys->i_current_pts : p_sys->i_previous_pts ) : 0;
401             i_dts = 0;
402
403             /* Hack to handle demuxers which only have DTS timestamps */
404             if( !i_pts && !p_block->i_pts && p_block->i_dts > 0 )
405             {
406                 if( p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ||
407                     (p_sys->p_info->current_picture->flags &
408                       PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B )
409                 {
410                     i_pts = p_block->i_dts;
411                 }
412             }
413             p_block->i_pts = p_block->i_dts = 0;
414             /* End hack */
415
416 #else /* New interface */
417
418             i_pts = p_sys->p_info->current_picture->flags & PIC_FLAG_TAGS ?
419                 ( ( p_sys->p_info->current_picture->tag ==
420                     (uint32_t)p_sys->i_current_pts ) ?
421                   p_sys->i_current_pts : p_sys->i_previous_pts ) : 0;
422             i_dts = p_sys->p_info->current_picture->flags & PIC_FLAG_TAGS ?
423                 ( ( p_sys->p_info->current_picture->tag2 ==
424                     (uint32_t)p_sys->i_current_dts ) ?
425                   p_sys->i_current_dts : p_sys->i_previous_dts ) : 0;
426 #endif
427
428             vout_SynchroNewPicture( p_sys->p_synchro,
429                 p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
430                 p_sys->p_info->current_picture->nb_fields, i_pts, i_dts,
431                 p_sys->i_current_rate );
432
433             if ( !(p_sys->b_slice_i
434                    && ((p_sys->p_info->current_picture->flags
435                          & PIC_MASK_CODING_TYPE) == P_CODING_TYPE))
436                    && !vout_SynchroChoose( p_sys->p_synchro,
437                               p_sys->p_info->current_picture->flags
438                                 & PIC_MASK_CODING_TYPE,
439                               /*p_sys->p_vout->render_time*/ 0 /*FIXME*/ ) )
440             {
441                 mpeg2_skip( p_sys->p_mpeg2dec, 1 );
442                 p_sys->b_skip = 1;
443                 vout_SynchroTrash( p_sys->p_synchro );
444                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, NULL );
445             }
446             else
447             {
448                 mpeg2_skip( p_sys->p_mpeg2dec, 0 );
449                 p_sys->b_skip = 0;
450                 vout_SynchroDecode( p_sys->p_synchro );
451
452                 if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
453                 {
454                     block_Release( p_block );
455                     return NULL;
456                 }
457
458                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
459             }
460         }
461         break;
462
463         case STATE_END:
464         case STATE_SLICE:
465             p_pic = NULL;
466             if( p_sys->p_info->display_fbuf
467                 && p_sys->p_info->display_fbuf->id )
468             {
469                 p_pic = (picture_t *)p_sys->p_info->display_fbuf->id;
470
471                 vout_SynchroEnd( p_sys->p_synchro,
472                             p_sys->p_info->display_picture->flags
473                              & PIC_MASK_CODING_TYPE,
474                             p_sys->b_garbage_pic );
475                 p_sys->b_garbage_pic = 0;
476
477                 if ( p_sys->p_picture_to_destroy != p_pic )
478                 {
479                     p_pic->date = vout_SynchroDate( p_sys->p_synchro );
480                 }
481                 else
482                 {
483                     p_sys->p_picture_to_destroy = NULL;
484                     p_pic->date = 0;
485                 }
486             }
487
488             if( p_sys->p_info->discard_fbuf &&
489                 p_sys->p_info->discard_fbuf->id )
490             {
491                 p_dec->pf_picture_unlink( p_dec,
492                                           p_sys->p_info->discard_fbuf->id );
493             }
494
495             /* For still frames */
496             if( state == STATE_END && p_pic ) p_pic->b_force = VLC_TRUE;
497
498             if( p_pic )
499             {
500                 /* Avoid frames with identical timestamps.
501                  * Especially needed for still frames in DVD menus. */
502                 if( p_sys->i_last_frame_pts == p_pic->date ) p_pic->date++;
503                 p_sys->i_last_frame_pts = p_pic->date;
504
505                 return p_pic;
506             }
507
508             break;
509
510         case STATE_INVALID:
511         {
512             uint8_t *buf[3];
513             buf[0] = buf[1] = buf[2] = NULL;
514
515             msg_Warn( p_dec, "invalid picture encountered" );
516             if ( ( p_sys->p_info->current_picture == NULL ) ||
517                ( ( p_sys->p_info->current_picture->flags &
518                    PIC_MASK_CODING_TYPE) != B_CODING_TYPE ) )
519             {
520                 if( p_sys->p_synchro ) vout_SynchroReset( p_sys->p_synchro );
521             }
522             mpeg2_skip( p_sys->p_mpeg2dec, 1 );
523             p_sys->b_skip = 1;
524
525             if( p_sys->p_info->current_fbuf &&
526                 p_sys->p_info->current_fbuf->id )
527             {
528                 p_sys->b_garbage_pic = 1;
529                 p_pic = p_sys->p_info->current_fbuf->id;
530             }
531             else if( !p_sys->p_info->sequence )
532             {
533                 break;
534             }
535             else
536             {
537                 if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
538                     break;
539                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
540             }
541             p_sys->p_picture_to_destroy = p_pic;
542
543             memset( p_pic->p[0].p_pixels, 0,
544                     p_sys->p_info->sequence->width
545                      * p_sys->p_info->sequence->height );
546             memset( p_pic->p[1].p_pixels, 0x80,
547                     p_sys->p_info->sequence->width
548                      * p_sys->p_info->sequence->height / 4 );
549             memset( p_pic->p[2].p_pixels, 0x80,
550                     p_sys->p_info->sequence->width
551                      * p_sys->p_info->sequence->height / 4 );
552
553             if( p_sys->b_slice_i )
554             {
555                 vout_SynchroNewPicture( p_sys->p_synchro,
556                             I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
557                 vout_SynchroDecode( p_sys->p_synchro );
558                 vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
559             }
560             break;
561         }
562
563         default:
564             break;
565         }
566     }
567
568     /* Never reached */
569     return NULL;
570 }
571
572 /*****************************************************************************
573  * CloseDecoder: libmpeg2 decoder destruction
574  *****************************************************************************/
575 static void CloseDecoder( vlc_object_t *p_this )
576 {
577     decoder_t *p_dec = (decoder_t *)p_this;
578     decoder_sys_t *p_sys = p_dec->p_sys;
579
580     if( p_sys->p_synchro ) vout_SynchroRelease( p_sys->p_synchro );
581
582     if( p_sys->p_mpeg2dec ) mpeg2_close( p_sys->p_mpeg2dec );
583
584     free( p_sys );
585 }
586
587 /*****************************************************************************
588  * GetNewPicture: Get a new picture from the vout and set the buf struct
589  *****************************************************************************/
590 static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf )
591 {
592     decoder_sys_t *p_sys = p_dec->p_sys;
593     picture_t *p_pic;
594
595     p_dec->fmt_out.video.i_width = p_sys->p_info->sequence->width;
596     p_dec->fmt_out.video.i_height = p_sys->p_info->sequence->height;
597     p_dec->fmt_out.video.i_aspect = p_sys->i_aspect;
598
599     p_dec->fmt_out.i_codec =
600         ( p_sys->p_info->sequence->chroma_height <
601           p_sys->p_info->sequence->height ) ?
602         VLC_FOURCC('I','4','2','0') : VLC_FOURCC('I','4','2','2');
603
604     /* Get a new picture */
605     p_pic = p_dec->pf_vout_buffer_new( p_dec );
606
607     if( p_pic == NULL ) return NULL;
608
609     p_pic->b_progressive = p_sys->p_info->current_picture != NULL ?
610         p_sys->p_info->current_picture->flags & PIC_FLAG_PROGRESSIVE_FRAME : 1;
611     p_pic->b_top_field_first = p_sys->p_info->current_picture != NULL ?
612         p_sys->p_info->current_picture->flags & PIC_FLAG_TOP_FIELD_FIRST : 1;
613     p_pic->i_nb_fields = p_sys->p_info->current_picture != NULL ?
614         p_sys->p_info->current_picture->nb_fields : 2;
615
616     p_dec->pf_picture_link( p_dec, p_pic );
617
618     pp_buf[0] = p_pic->p[0].p_pixels;
619     pp_buf[1] = p_pic->p[1].p_pixels;
620     pp_buf[2] = p_pic->p[2].p_pixels;
621
622     return p_pic;
623 }