]> git.sesse.net Git - vlc/blob - modules/codec/libmpeg2.c
* src/video_output/vout_synchro.c, include/vout_synchro.h: got rid of the dependency...
[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: libmpeg2.c,v 1.32 2003/11/04 17:46:17 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
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/input.h>
31 #include <vlc/decoder.h>
32
33 #include <stdlib.h>                                      /* malloc(), free() */
34 #include <string.h>                                    /* memcpy(), memset() */
35
36 #include <mpeg2dec/mpeg2.h>
37
38 #include "vout_synchro.h"
39
40 /* Aspect ratio (ISO/IEC 13818-2 section 6.3.3, table 6-3) */
41 #define AR_SQUARE_PICTURE       1                           /* square pixels */
42 #define AR_3_4_PICTURE          2                        /* 3:4 picture (TV) */
43 #define AR_16_9_PICTURE         3              /* 16:9 picture (wide screen) */
44 #define AR_221_1_PICTURE        4                  /* 2.21:1 picture (movie) */
45
46 /*****************************************************************************
47  * decoder_sys_t : libmpeg2 decoder descriptor
48  *****************************************************************************/
49 struct decoder_sys_t
50 {
51     /*
52      * libmpeg2 properties
53      */
54     mpeg2dec_t          *p_mpeg2dec;
55     const mpeg2_info_t  *p_info;
56     vlc_bool_t          b_skip;
57
58     /*
59      * Input properties
60      */
61     pes_packet_t     *p_pes;                  /* current PES we are decoding */
62     mtime_t          i_pts;
63     mtime_t          i_previous_pts;
64     mtime_t          i_current_pts;
65     int              i_current_rate;
66     picture_t *      p_picture_to_destroy;
67     vlc_bool_t       b_garbage_pic;
68     vlc_bool_t       b_after_sequence_header; /* is it the next frame after
69                                                * the sequence header ?    */
70     vlc_bool_t       b_slice_i;             /* intra-slice refresh stream */
71
72     /*
73      * Output properties
74      */
75     vout_thread_t *p_vout;
76     vout_synchro_t *p_synchro;
77
78 };
79
80 /*****************************************************************************
81  * Local prototypes
82  *****************************************************************************/
83 static int OpenDecoder( vlc_object_t * );
84 static int InitDecoder( decoder_t * );
85 static int RunDecoder ( decoder_t *, block_t * );
86 static int EndDecoder ( decoder_t * );
87
88 static picture_t *GetNewPicture( decoder_t *, uint8_t ** );
89
90 /*****************************************************************************
91  * Module descriptor
92  *****************************************************************************/
93 vlc_module_begin();
94     set_description( _("MPEG I/II video decoder (using libmpeg2)") );
95     set_capability( "decoder", 150 );
96     set_callbacks( OpenDecoder, NULL );
97     add_shortcut( "libmpeg2" );
98 vlc_module_end();
99
100 /*****************************************************************************
101  * OpenDecoder: probe the decoder and return score
102  *****************************************************************************/
103 static int OpenDecoder( vlc_object_t *p_this )
104 {
105     decoder_t *p_dec = (decoder_t*)p_this;
106
107     if( p_dec->p_fifo->i_fourcc != VLC_FOURCC('m','p','g','v') &&
108         p_dec->p_fifo->i_fourcc != VLC_FOURCC('m','p','g','1') &&
109         /* Pinnacle hardware-mpeg1 */
110         p_dec->p_fifo->i_fourcc != VLC_FOURCC('P','I','M','1') &&
111         /* ATI Video */
112         p_dec->p_fifo->i_fourcc != VLC_FOURCC('V','C','R','2') &&
113         p_dec->p_fifo->i_fourcc != VLC_FOURCC('m','p','g','2') )
114     {
115         return VLC_EGENERIC;
116     }
117
118     p_dec->pf_init = InitDecoder;
119     p_dec->pf_decode = RunDecoder;
120     p_dec->pf_end = EndDecoder;
121
122     return VLC_SUCCESS;
123 }
124
125 /*****************************************************************************
126  * InitDecoder: Initalize the decoder
127  *****************************************************************************/
128 static int InitDecoder( decoder_t *p_dec )
129 {
130     /* Allocate the memory needed to store the decoder's structure */
131     if( ( p_dec->p_sys =
132           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
133     {
134         msg_Err( p_dec, "out of memory" );
135         return VLC_EGENERIC;
136     }
137
138     /* Initialize the thread properties */
139     memset( p_dec->p_sys, 0, sizeof(decoder_sys_t) );
140     p_dec->p_sys->p_pes      = NULL;
141     p_dec->p_sys->p_vout     = NULL;
142     p_dec->p_sys->p_mpeg2dec = NULL;
143     p_dec->p_sys->p_synchro  = NULL;
144     p_dec->p_sys->p_info     = NULL;
145     p_dec->p_sys->i_pts      = mdate() + DEFAULT_PTS_DELAY;
146     p_dec->p_sys->i_current_pts  = 0;
147     p_dec->p_sys->i_previous_pts = 0;
148     p_dec->p_sys->p_picture_to_destroy = NULL;
149     p_dec->p_sys->b_garbage_pic = 0;
150     p_dec->p_sys->b_slice_i  = 0;
151     p_dec->p_sys->b_skip     = 0;
152
153     /* Initialize decoder */
154     p_dec->p_sys->p_mpeg2dec = mpeg2_init();
155     if( p_dec->p_sys->p_mpeg2dec == NULL)
156     {
157         msg_Err( p_dec, "mpeg2_init() failed" );
158         free( p_dec->p_sys );
159         return VLC_EGENERIC;
160     }
161
162     p_dec->p_sys->p_info = mpeg2_info( p_dec->p_sys->p_mpeg2dec );
163
164     return VLC_SUCCESS;
165 }
166
167 /*****************************************************************************
168  * RunDecoder: the libmpeg2 decoder
169  *****************************************************************************/
170 static int RunDecoder( decoder_t *p_dec, block_t *p_block )
171 {
172     decoder_sys_t   *p_sys = p_dec->p_sys;
173     mpeg2_state_t   state;
174     picture_t       *p_pic;
175     int             i_aspect;
176
177     vlc_bool_t      b_need_more_data = VLC_FALSE;
178
179     while( 1 )
180     {
181         if( p_dec->p_fifo->b_die || p_dec->p_fifo->b_error )
182         {
183             block_Release( p_block );
184             return VLC_EGENERIC;
185         }
186
187         state = mpeg2_parse( p_sys->p_mpeg2dec );
188
189         switch( state )
190         {
191         case STATE_BUFFER:
192             if( !p_block->i_buffer || b_need_more_data )
193             {
194                 block_Release( p_block );
195                 return VLC_SUCCESS;
196             }
197
198             if( p_block->b_discontinuity && p_sys->p_synchro
199                 && p_sys->p_info->sequence->width != (unsigned)-1 )
200             {
201                 vout_SynchroReset( p_sys->p_synchro );
202                 if( p_sys->p_info->current_fbuf != NULL
203                     && p_sys->p_info->current_fbuf->id != NULL )
204                 {
205                     p_sys->b_garbage_pic = 1;
206                     p_pic = p_sys->p_info->current_fbuf->id;
207                 }
208                 else
209                 {
210                     uint8_t *buf[3];
211                     buf[0] = buf[1] = buf[2] = NULL;
212                     if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
213                         break;
214                     mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
215                 }
216                 p_sys->p_picture_to_destroy = p_pic;
217
218                 memset( p_pic->p[0].p_pixels, 0,
219                         p_sys->p_info->sequence->width
220                          * p_sys->p_info->sequence->height );
221                 memset( p_pic->p[1].p_pixels, 0x80,
222                         p_sys->p_info->sequence->width
223                          * p_sys->p_info->sequence->height / 4 );
224                 memset( p_pic->p[2].p_pixels, 0x80,
225                         p_sys->p_info->sequence->width
226                          * p_sys->p_info->sequence->height / 4 );
227
228                 if ( p_sys->b_slice_i )
229                 {
230                     vout_SynchroNewPicture( p_sys->p_synchro,
231                         I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
232                     vout_SynchroDecode( p_sys->p_synchro );
233                     vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
234                 }
235             }
236
237             if( p_block->i_pts )
238             {
239                 mpeg2_pts( p_sys->p_mpeg2dec, (uint32_t)p_block->i_pts );
240                 p_sys->i_previous_pts = p_sys->i_current_pts;
241                 p_sys->i_current_pts = p_block->i_pts;
242             }
243
244             p_sys->i_current_rate = DEFAULT_RATE;//p_pes->i_rate;
245
246             mpeg2_buffer( p_sys->p_mpeg2dec, p_block->p_buffer,
247                           p_block->p_buffer + p_block->i_buffer );
248
249             b_need_more_data = VLC_TRUE;
250             break;
251
252         case STATE_SEQUENCE:
253         {
254             /* Initialize video output */
255             uint8_t *buf[3];
256             buf[0] = buf[1] = buf[2] = NULL;
257
258             /* Check whether the input gives a particular aspect ratio */
259             if( p_dec->p_fifo->p_demux_data
260                 && ( *(int*)(p_dec->p_fifo->p_demux_data) & 0x7 ) )
261             {
262                 i_aspect = *(int*)(p_dec->p_fifo->p_demux_data);
263                 switch( i_aspect )
264                 {
265                 case AR_3_4_PICTURE:
266                     i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
267                     break;
268                 case AR_16_9_PICTURE:
269                     i_aspect = VOUT_ASPECT_FACTOR * 16 / 9;
270                     break;
271                 case AR_221_1_PICTURE:
272                     i_aspect = VOUT_ASPECT_FACTOR * 221 / 100;
273                     break;
274                 case AR_SQUARE_PICTURE:
275                 default:
276                     i_aspect = VOUT_ASPECT_FACTOR *
277                                    p_sys->p_info->sequence->width /
278                                    p_sys->p_info->sequence->height;
279                     break;
280                 }
281             }
282             else
283             {
284                 /* Use the value provided in the MPEG sequence header */
285                 i_aspect = ((uint64_t)p_sys->p_info->sequence->display_width) *
286                     p_sys->p_info->sequence->pixel_width * VOUT_ASPECT_FACTOR /
287                     p_sys->p_info->sequence->display_height /
288                     p_sys->p_info->sequence->pixel_height;
289             }
290
291             if ( p_dec->p_sys->p_vout != NULL )
292             {
293               int i_pic;
294                 /* Temporary hack to free the pictures in use by libmpeg2 */
295                 for ( i_pic = 0; i_pic < p_dec->p_sys->p_vout->render.i_pictures; i_pic++ )
296                 {
297                     if( p_dec->p_sys->p_vout->render.pp_picture[i_pic]->i_status ==
298                           RESERVED_PICTURE )
299                         vout_DestroyPicture( p_dec->p_sys->p_vout,
300                                          p_dec->p_sys->p_vout->render.pp_picture[i_pic] );
301                     if( p_dec->p_sys->p_vout->render.pp_picture[i_pic]->i_refcount > 0 )
302                         vout_UnlinkPicture( p_dec->p_sys->p_vout,
303                                          p_dec->p_sys->p_vout->render.pp_picture[i_pic] );
304                 }
305             }
306
307             p_sys->p_vout = vout_Request( p_dec, p_sys->p_vout,
308                                           p_sys->p_info->sequence->width,
309                                           p_sys->p_info->sequence->height,
310                                           VLC_FOURCC('Y','V','1','2'),
311                                           i_aspect );
312
313             if(p_sys->p_vout == NULL )
314             {
315                 msg_Err( p_dec, "cannot create vout" );
316                 block_Release( p_block );
317                 return -1;
318             }
319
320             msg_Dbg( p_dec, "%dx%d, aspect %d, %u.%03u fps",
321                      p_sys->p_info->sequence->width,
322                      p_sys->p_info->sequence->height, i_aspect,
323                      (uint32_t)((uint64_t)1001000000 * 27 /
324                                  p_sys->p_info->sequence->frame_period / 1001),
325                      (uint32_t)((uint64_t)1001000000 * 27 /
326                                  p_sys->p_info->sequence->frame_period % 1001) );
327
328             mpeg2_custom_fbuf( p_sys->p_mpeg2dec, 1 );
329
330             /* Set the first 2 reference frames */
331             mpeg2_set_buf( p_sys->p_mpeg2dec, buf, NULL );
332
333             if( (p_pic = GetNewPicture( p_dec, buf )) == NULL ) break;
334             memset( p_pic->p[0].p_pixels, 0,
335                     p_sys->p_info->sequence->width
336                      * p_sys->p_info->sequence->height );
337             memset( p_pic->p[1].p_pixels, 0x80,
338                     p_sys->p_info->sequence->width
339                      * p_sys->p_info->sequence->height / 4 );
340             memset( p_pic->p[2].p_pixels, 0x80,
341                     p_sys->p_info->sequence->width
342                      * p_sys->p_info->sequence->height / 4 );
343             mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
344             /* This picture will never go through display_picture. */
345             vout_DatePicture( p_sys->p_vout, p_pic, 0 );
346             vout_DisplayPicture( p_sys->p_vout, p_pic );
347             /* For some reason, libmpeg2 will put this pic twice in
348              * discard_picture. This can be considered a bug in libmpeg2. */
349             vout_LinkPicture( p_sys->p_vout, p_pic );
350
351             if ( p_sys->p_synchro )
352             {
353                 vout_SynchroRelease( p_sys->p_synchro );
354             }
355             p_sys->p_synchro = vout_SynchroInit( p_dec,
356                 (uint32_t)((uint64_t)1001000000 * 27 /
357                 p_sys->p_info->sequence->frame_period) );
358             p_sys->b_after_sequence_header = 1;
359         }
360         break;
361
362         case STATE_PICTURE_2ND:
363             vout_SynchroNewPicture( p_sys->p_synchro,
364                 p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
365                 p_sys->p_info->current_picture->nb_fields,
366                 0, 0,
367                 p_sys->i_current_rate );
368
369             if ( p_sys->b_skip )
370             {
371                 vout_SynchroTrash( p_sys->p_synchro );
372             }
373             else
374             {
375                 vout_SynchroDecode( p_sys->p_synchro );
376             }
377             break;
378
379         case STATE_PICTURE:
380         {
381             uint8_t *buf[3];
382             buf[0] = buf[1] = buf[2] = NULL;
383
384             if ( p_sys->b_after_sequence_header
385                   && ((p_sys->p_info->current_picture->flags
386                         & PIC_MASK_CODING_TYPE)
387                        == PIC_FLAG_CODING_TYPE_P) )
388             {
389                 /* Intra-slice refresh. Simulate a blank I picture. */
390                 msg_Dbg( p_dec, "intra-slice refresh stream" );
391                 vout_SynchroNewPicture( p_sys->p_synchro,
392                     I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
393                 vout_SynchroDecode( p_sys->p_synchro );
394                 vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
395                 p_sys->b_slice_i = 1;
396             }
397             p_sys->b_after_sequence_header = 0;
398
399             vout_SynchroNewPicture( p_sys->p_synchro,
400                 p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE,
401                 p_sys->p_info->current_picture->nb_fields,
402                 (p_sys->p_info->current_picture->flags & PIC_FLAG_PTS) ?
403                     ( ( p_sys->p_info->current_picture->pts ==
404                         (uint32_t)p_sys->i_current_pts ) ?
405                       p_sys->i_current_pts : p_sys->i_previous_pts ) : 0,
406                 0, p_sys->i_current_rate );
407
408             if ( !(p_sys->b_slice_i
409                    && ((p_sys->p_info->current_picture->flags
410                          & PIC_MASK_CODING_TYPE) == P_CODING_TYPE))
411                    && !vout_SynchroChoose( p_sys->p_synchro,
412                               p_sys->p_info->current_picture->flags
413                                 & PIC_MASK_CODING_TYPE,
414                               p_sys->p_vout->render_time ) )
415             {
416                 mpeg2_skip( p_sys->p_mpeg2dec, 1 );
417                 p_sys->b_skip = 1;
418                 vout_SynchroTrash( p_sys->p_synchro );
419                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, NULL );
420             }
421             else
422             {
423                 mpeg2_skip( p_sys->p_mpeg2dec, 0 );
424                 p_sys->b_skip = 0;
425                 vout_SynchroDecode( p_sys->p_synchro );
426                 if( (p_pic = GetNewPicture( p_dec, buf )) == NULL ) break;
427                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
428             }
429         }
430         break;
431
432         case STATE_END:
433         case STATE_SLICE:
434             if( p_sys->p_info->display_fbuf
435                 && p_sys->p_info->display_fbuf->id )
436             {
437                 p_pic = (picture_t *)p_sys->p_info->display_fbuf->id;
438
439                 vout_SynchroEnd( p_sys->p_synchro,
440                             p_sys->p_info->display_picture->flags
441                              & PIC_MASK_CODING_TYPE,
442                             p_sys->b_garbage_pic );
443                 p_sys->b_garbage_pic = 0;
444                 vout_DisplayPicture( p_sys->p_vout, p_pic );
445
446                 if ( p_sys->p_picture_to_destroy != p_pic )
447                 {
448                     vout_DatePicture( p_sys->p_vout, p_pic,
449                         vout_SynchroDate( p_sys->p_synchro ) );
450                 }
451                 else
452                 {
453                     p_sys->p_picture_to_destroy = NULL;
454                     vout_DatePicture( p_sys->p_vout, p_pic, 0 );
455                 }
456             }
457
458             if( p_sys->p_info->discard_fbuf &&
459                 p_sys->p_info->discard_fbuf->id )
460             {
461                 p_pic = (picture_t *)p_sys->p_info->discard_fbuf->id;
462                 vout_UnlinkPicture( p_sys->p_vout, p_pic );
463             }
464             break;
465
466         case STATE_INVALID:
467         {
468             uint8_t *buf[3];
469             buf[0] = buf[1] = buf[2] = NULL;
470
471             msg_Warn( p_dec, "invalid picture encountered" );
472             if ( ( p_sys->p_info->current_picture == NULL ) ||
473                ( ( p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE)
474                   != B_CODING_TYPE ) )
475             {
476                 vout_SynchroReset( p_sys->p_synchro );
477             }
478             mpeg2_skip( p_sys->p_mpeg2dec, 1 );
479             p_sys->b_skip = 1;
480
481             if( p_sys->p_info->current_fbuf &&
482                 p_sys->p_info->current_fbuf->id )
483             {
484                 p_sys->b_garbage_pic = 1;
485                 p_pic = p_sys->p_info->current_fbuf->id;
486             }
487             else
488             {
489                 if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
490                     break;
491                 mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic );
492             }
493             p_sys->p_picture_to_destroy = p_pic;
494
495             memset( p_pic->p[0].p_pixels, 0,
496                     p_sys->p_info->sequence->width
497                      * p_sys->p_info->sequence->height );
498             memset( p_pic->p[1].p_pixels, 0x80,
499                     p_sys->p_info->sequence->width
500                      * p_sys->p_info->sequence->height / 4 );
501             memset( p_pic->p[2].p_pixels, 0x80,
502                     p_sys->p_info->sequence->width
503                      * p_sys->p_info->sequence->height / 4 );
504
505             if ( p_sys->b_slice_i )
506             {
507                 vout_SynchroNewPicture( p_sys->p_synchro,
508                             I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate );
509                 vout_SynchroDecode( p_sys->p_synchro );
510                 vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 );
511             }
512             break;
513         }
514
515         default:
516             break;
517         }
518     }
519
520     block_Release( p_block );
521     return VLC_EGENERIC;
522 }
523
524 /*****************************************************************************
525  * EndDecoder: libmpeg2 decoder destruction
526  *****************************************************************************/
527 static int EndDecoder( decoder_t * p_dec )
528 {
529     decoder_sys_t *p_sys = p_dec->p_sys;
530
531     if( p_sys )
532     {
533         int i_pic;
534
535         if( p_sys->p_synchro )
536             vout_SynchroRelease( p_sys->p_synchro );
537
538         if( p_sys->p_vout )
539         {
540             /* Temporary hack to free the pictures in use by libmpeg2 */
541             for( i_pic = 0; i_pic < p_sys->p_vout->render.i_pictures; i_pic++ )
542             {
543                 if( p_sys->p_vout->render.pp_picture[i_pic]->i_status ==
544                       RESERVED_PICTURE )
545                     vout_DestroyPicture( p_sys->p_vout,
546                                      p_sys->p_vout->render.pp_picture[i_pic] );
547                 if( p_sys->p_vout->render.pp_picture[i_pic]->i_refcount > 0 )
548                     vout_UnlinkPicture( p_sys->p_vout,
549                                      p_sys->p_vout->render.pp_picture[i_pic] );
550             }
551
552             vout_Request( p_dec, p_sys->p_vout, 0, 0, 0, 0 );
553         }
554
555         if( p_sys->p_mpeg2dec ) mpeg2_close( p_sys->p_mpeg2dec );
556
557         free( p_sys );
558     }
559
560     return VLC_SUCCESS;
561 }
562
563 /*****************************************************************************
564  * GetNewPicture: Get a new picture from the vout and set the buf struct
565  *****************************************************************************/
566 static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf )
567 {
568     decoder_sys_t *p_sys = p_dec->p_sys;
569     picture_t *p_pic;
570
571     vlc_bool_t b_progressive = p_sys->p_info->current_picture != NULL ?
572         p_sys->p_info->current_picture->flags & PIC_FLAG_PROGRESSIVE_FRAME : 1;
573     vlc_bool_t b_top_field_first = p_sys->p_info->current_picture != NULL ?
574         p_sys->p_info->current_picture->flags & PIC_FLAG_TOP_FIELD_FIRST : 1;
575     unsigned int i_nb_fields = p_sys->p_info->current_picture != NULL ?
576         p_sys->p_info->current_picture->nb_fields : 2;
577
578     /* Get a new picture */
579     while( !( p_pic = vout_CreatePicture( p_sys->p_vout,
580               b_progressive, b_top_field_first, i_nb_fields ) ) )
581     {
582         if( p_dec->p_fifo->b_die || p_dec->p_fifo->b_error )
583             break;
584
585         msleep( VOUT_OUTMEM_SLEEP );
586     }
587
588     if( p_pic == NULL ) return NULL;
589
590     vout_LinkPicture( p_sys->p_vout, p_pic );
591
592     pp_buf[0] = p_pic->p[0].p_pixels;
593     pp_buf[1] = p_pic->p[1].p_pixels;
594     pp_buf[2] = p_pic->p[2].p_pixels;
595
596     return p_pic;
597 }