]> git.sesse.net Git - vlc/blob - plugins/sdl/vout_sdl.c
* Mouse wheel seek patch for XVideo courtesy of Peter Surda.
[vlc] / plugins / sdl / vout_sdl.c
1 /*****************************************************************************
2  * vout_sdl.c: SDL video output display method
3  *****************************************************************************
4  * Copyright (C) 1998-2001 VideoLAN
5  * $Id: vout_sdl.c,v 1.73 2001/12/20 15:43:15 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Pierre Baillet <oct@zoy.org>
9  *          Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 #define MODULE_NAME sdl
27 #include "modules_inner.h"
28
29 /*****************************************************************************
30  * Preamble
31  *****************************************************************************/
32 #include "defs.h"
33
34 #include <errno.h>                                                 /* ENOMEM */
35 #include <stdlib.h>                                                /* free() */
36 #include <string.h>                                            /* strerror() */
37
38 #include <sys/types.h>
39 #ifndef WIN32
40 #   include <netinet/in.h>                            /* BSD: struct in_addr */
41 #endif
42
43 #include SDL_INCLUDE_FILE
44
45 #include "common.h"
46 #include "intf_msg.h"
47 #include "threads.h"
48 #include "mtime.h"
49 #include "netutils.h"
50 #include "tests.h"
51
52 #include "video.h"
53 #include "video_output.h"
54
55 #include "interface.h"
56
57 #include "stream_control.h"                 /* needed by input_ext-intf.h... */
58 #include "input_ext-intf.h"
59
60 #include "modules.h"
61 #include "modules_export.h"
62
63 #define SDL_MAX_DIRECTBUFFERS 5
64 #define SDL_DEFAULT_BPP 16
65
66 /*****************************************************************************
67  * vout_sys_t: video output SDL method descriptor
68  *****************************************************************************
69  * This structure is part of the video output thread descriptor.
70  * It describes the SDL specific properties of an output thread.
71  *****************************************************************************/
72 typedef struct vout_sys_s
73 {
74     SDL_Surface *   p_display;                             /* display device */
75     SDL_Overlay *   p_overlay; /* An overlay we keep to grab the XVideo port */
76
77     int i_width;
78     int i_height;
79
80     boolean_t   b_cursor;
81     boolean_t   b_cursor_autohidden;
82     mtime_t     i_lastmoved;
83
84 } vout_sys_t;
85
86 /*****************************************************************************
87  * picture_sys_t: direct buffer method descriptor
88  *****************************************************************************
89  * This structure is part of the picture descriptor, it describes the
90  * SDL specific properties of a direct buffer.
91  *****************************************************************************/
92 typedef struct picture_sys_s
93 {
94     SDL_Overlay *p_overlay;
95
96 } picture_sys_t;
97
98 /*****************************************************************************
99  * Local prototypes.
100  *****************************************************************************/
101 static int  vout_Probe      ( probedata_t *p_data );
102 static int  vout_Create     ( struct vout_thread_s * );
103 static int  vout_Init       ( struct vout_thread_s * );
104 static void vout_End        ( struct vout_thread_s * );
105 static void vout_Destroy    ( struct vout_thread_s * );
106 static int  vout_Manage     ( struct vout_thread_s * );
107 static void vout_Display    ( struct vout_thread_s *, struct picture_s * );
108
109 static int  SDLOpenDisplay      ( vout_thread_t *p_vout );
110 static void SDLCloseDisplay     ( vout_thread_t *p_vout );
111 static int  SDLNewPicture       ( vout_thread_t *p_vout, picture_t *p_pic );
112
113 /*****************************************************************************
114  * Functions exported as capabilities. They are declared as static so that
115  * we don't pollute the namespace too much.
116  *****************************************************************************/
117 void _M( vout_getfunctions )( function_list_t * p_function_list )
118 {
119     p_function_list->pf_probe = vout_Probe;
120     p_function_list->functions.vout.pf_create     = vout_Create;
121     p_function_list->functions.vout.pf_init       = vout_Init;
122     p_function_list->functions.vout.pf_end        = vout_End;
123     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
124     p_function_list->functions.vout.pf_manage     = vout_Manage;
125     p_function_list->functions.vout.pf_display    = vout_Display;
126     p_function_list->functions.vout.pf_setpalette = NULL;
127 }
128
129 /*****************************************************************************
130  * vout_Probe: probe the video driver and return a score
131  *****************************************************************************
132  * This function tries to initialize SDL and returns a score to the
133  * plugin manager so that it can select the best plugin.
134  *****************************************************************************/
135 static int vout_Probe( probedata_t *p_data )
136 {
137     if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
138     {
139         return( 0 );
140     }
141
142     if( TestMethod( VOUT_METHOD_VAR, "sdl" ) )
143     {
144         return( 999 );
145     }
146
147     return( 100 );
148 }
149
150 /*****************************************************************************
151  * vout_Create: allocate SDL video thread output method
152  *****************************************************************************
153  * This function allocate and initialize a SDL vout method. It uses some of the
154  * vout properties to choose the correct mode, and change them according to the
155  * mode actually used.
156  *****************************************************************************/
157 static int vout_Create( vout_thread_t *p_vout )
158 {
159     /* Allocate structure */
160     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
161     if( p_vout->p_sys == NULL )
162     {
163         intf_ErrMsg( "vout error: can't create p_sys (%s)", strerror(ENOMEM) );
164         return( 1 );
165     }
166
167     /* Initialize library */
168     if( SDL_Init( SDL_INIT_VIDEO
169 #ifndef WIN32
170     /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/
171                 | SDL_INIT_EVENTTHREAD
172 #endif
173 #ifdef DEBUG
174     /* In debug mode you may want vlc to dump a core instead of staying
175      * stuck */
176                 | SDL_INIT_NOPARACHUTE
177 #endif
178                 ) < 0 )
179     {
180         intf_ErrMsg( "vout error: can't initialize SDL (%s)", SDL_GetError() );
181         free( p_vout->p_sys );
182         return( 1 );
183     }
184
185     p_vout->p_sys->b_cursor = 1; /* TODO should be done with a main_GetInt.. */
186     p_vout->p_sys->b_cursor_autohidden = 0;
187     p_vout->p_sys->i_lastmoved = mdate();
188
189     if( p_vout->render.i_height * p_vout->render.i_aspect
190          >= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
191     {
192         p_vout->p_sys->i_width = p_vout->render.i_height
193             * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
194         p_vout->p_sys->i_height = p_vout->render.i_height;
195     }
196     else
197     {
198         p_vout->p_sys->i_width = p_vout->render.i_width;
199         p_vout->p_sys->i_height = p_vout->render.i_width
200             * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
201     }
202
203     if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
204     {
205         p_vout->p_sys->i_width <<= 1;
206         p_vout->p_sys->i_height <<= 1;
207     }
208     else if( p_vout->p_sys->i_width <= 400 && p_vout->p_sys->i_height <= 400 )
209     {
210         p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
211         p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
212     }
213
214     if( SDLOpenDisplay( p_vout ) )
215     {
216         intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() );
217         SDL_QuitSubSystem( SDL_INIT_VIDEO );
218         free( p_vout->p_sys );
219         return( 1 );
220     }
221
222     return( 0 );
223 }
224
225 /*****************************************************************************
226  * vout_Init: initialize SDL video thread output method
227  *****************************************************************************
228  * This function initialize the SDL display device.
229  *****************************************************************************/
230 static int vout_Init( vout_thread_t *p_vout )
231 {
232     int i_index;
233     picture_t *p_pic;
234
235     I_OUTPUTPICTURES = 0;
236
237     /* Initialize the output structure */
238     switch( p_vout->render.i_chroma )
239     {
240         case YUV_420_PICTURE:
241             p_vout->output.i_chroma = p_vout->render.i_chroma;
242             p_vout->output.i_width  = p_vout->render.i_width;
243             p_vout->output.i_height = p_vout->render.i_height;
244             p_vout->output.i_aspect = p_vout->render.i_aspect;
245             break;
246
247         default:
248             return( 0 );
249     }
250
251     /* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
252     while( I_OUTPUTPICTURES < SDL_MAX_DIRECTBUFFERS )
253     {
254         p_pic = NULL;
255
256         /* Find an empty picture slot */
257         for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
258         {
259             if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
260             {
261                 p_pic = p_vout->p_picture + i_index;
262                 break;
263             }
264         }
265
266         /* Allocate the picture if we found one */
267         if( p_pic == NULL || SDLNewPicture( p_vout, p_pic ) )
268         {
269             break;
270         }
271
272         p_pic->i_status        = DESTROYED_PICTURE;
273         p_pic->i_type          = DIRECT_PICTURE;
274
275         p_pic->i_left_margin   =
276         p_pic->i_right_margin  =
277         p_pic->i_top_margin    =
278         p_pic->i_bottom_margin = 0;
279
280         PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
281
282         I_OUTPUTPICTURES++;
283     }
284
285     return( 0 );
286 }
287
288 /*****************************************************************************
289  * vout_End: terminate Sys video thread output method
290  *****************************************************************************
291  * Terminate an output method created by vout_SDLCreate
292  *****************************************************************************/
293 static void vout_End( vout_thread_t *p_vout )
294 {
295     int i_index;
296
297     /* Free the output buffers we allocated */
298     for( i_index = I_OUTPUTPICTURES ; i_index ; )
299     {
300         i_index--;
301         SDL_UnlockYUVOverlay( PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
302         SDL_FreeYUVOverlay( PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
303         free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
304     }
305 }
306
307 /*****************************************************************************
308  * vout_Destroy: destroy Sys video thread output method
309  *****************************************************************************
310  * Terminate an output method created by vout_SDLCreate
311  *****************************************************************************/
312 static void vout_Destroy( vout_thread_t *p_vout )
313 {
314     SDLCloseDisplay( p_vout );
315
316     SDL_QuitSubSystem( SDL_INIT_VIDEO );
317
318     free( p_vout->p_sys );
319 }
320
321 static __inline__ void vout_Seek( off_t i_seek )
322 {
323 #define area p_main->p_intf->p_input->stream.p_selected_area
324     off_t i_tell = area->i_tell;
325
326     i_tell += i_seek * (off_t)50 * p_main->p_intf->p_input->stream.i_mux_rate;
327
328     i_tell = ( i_tell <= area->i_start ) ? area->i_start
329            : ( i_tell >= area->i_size ) ? area->i_size
330            : i_tell;
331
332     input_Seek( p_main->p_intf->p_input, i_tell );
333 #undef area
334 }
335
336 /*****************************************************************************
337  * vout_Manage: handle Sys events
338  *****************************************************************************
339  * This function should be called regularly by video output thread. It returns
340  * a non null value if an error occured.
341  *****************************************************************************/
342 static int vout_Manage( vout_thread_t *p_vout )
343 {
344     SDL_Event event;                                            /* SDL event */
345
346     /* Process events */
347     while( SDL_PollEvent(&event) )
348     {
349         switch( event.type )
350         {
351         case SDL_VIDEORESIZE:                          /* Resizing of window */
352             p_vout->p_sys->i_width = event.resize.w;
353             p_vout->p_sys->i_height = event.resize.h;
354             SDLCloseDisplay( p_vout );
355             SDLOpenDisplay( p_vout );
356             break;
357
358         case SDL_MOUSEMOTION:
359             if( p_vout->p_sys->b_cursor &&
360                 (abs(event.motion.xrel) > 2 || abs(event.motion.yrel) > 2) )
361             {
362                 if( p_vout->p_sys->b_cursor_autohidden )
363                 {
364                     p_vout->p_sys->b_cursor_autohidden = 0;
365                     SDL_ShowCursor( 1 );
366                 }
367                 else
368                 {
369                     p_vout->p_sys->i_lastmoved = mdate();
370                 }
371             }
372             break;
373
374         case SDL_MOUSEBUTTONUP:
375             switch( event.button.button )
376             {
377             case SDL_BUTTON_RIGHT:
378                 p_main->p_intf->b_menu_change = 1;
379                 break;
380             }
381             break;
382
383         case SDL_MOUSEBUTTONDOWN:
384             switch( event.button.button )
385             {
386             case SDL_BUTTON_LEFT:
387                 /* In this part we will eventually manage
388                  * clicks for DVD navigation for instance. For the
389                  * moment just pause the stream. */
390                 input_SetStatus( p_main->p_intf->p_input, INPUT_STATUS_PAUSE );
391                 break;
392
393             case 4:
394                 vout_Seek( 15 );
395                 break;
396
397             case 5:
398                 vout_Seek( -15 );
399                 break;
400             }
401             break;
402
403         case SDL_QUIT:
404             p_main->p_intf->b_die = 1;
405             break;
406
407         case SDL_KEYDOWN:                             /* if a key is pressed */
408
409             switch( event.key.keysym.sym )
410             {
411             case SDLK_q:                                             /* quit */
412             case SDLK_ESCAPE:
413                 p_main->p_intf->b_die = 1;
414                 break;
415
416             case SDLK_f:                             /* switch to fullscreen */
417                 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
418                 break;
419
420             case SDLK_c:                                 /* toggle grayscale */
421                 p_vout->b_grayscale = ! p_vout->b_grayscale;
422                 p_vout->i_changes |= VOUT_GRAYSCALE_CHANGE;
423                 break;
424
425             case SDLK_i:                                      /* toggle info */
426                 p_vout->b_info = ! p_vout->b_info;
427                 p_vout->i_changes |= VOUT_INFO_CHANGE;
428                 break;
429
430             case SDLK_s:                                   /* toggle scaling */
431                 p_vout->b_scale = ! p_vout->b_scale;
432                 p_vout->i_changes |= VOUT_SCALE_CHANGE;
433                 break;
434
435             case SDLK_SPACE:                             /* toggle interface */
436                 p_vout->b_interface = ! p_vout->b_interface;
437                 p_vout->i_changes |= VOUT_INTF_CHANGE;
438                 break;
439             
440             case SDLK_MENU:
441                 p_main->p_intf->b_menu_change = 1;
442                 break;
443
444             case SDLK_LEFT:
445                 vout_Seek( -5 );
446                 break;
447
448             case SDLK_RIGHT:
449                 vout_Seek( 5 );
450                 break;
451
452             case SDLK_UP:
453                 vout_Seek( 60 );
454                 break;
455
456             case SDLK_DOWN:
457                 vout_Seek( -60 );
458                 break;
459
460             case SDLK_F10: network_ChannelJoin( 0 ); break;
461             case SDLK_F1:  network_ChannelJoin( 1 ); break;
462             case SDLK_F2:  network_ChannelJoin( 2 ); break;
463             case SDLK_F3:  network_ChannelJoin( 3 ); break;
464             case SDLK_F4:  network_ChannelJoin( 4 ); break;
465             case SDLK_F5:  network_ChannelJoin( 5 ); break;
466             case SDLK_F6:  network_ChannelJoin( 6 ); break;
467             case SDLK_F7:  network_ChannelJoin( 7 ); break;
468             case SDLK_F8:  network_ChannelJoin( 8 ); break;
469             case SDLK_F9:  network_ChannelJoin( 9 ); break;
470
471             default:
472                 intf_DbgMsg( "unhandled key %i", event.key.keysym.sym );
473                 break;
474             }
475             break;
476
477         default:
478             break;
479         }
480     }
481
482     /* Fullscreen change */
483     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
484     {
485         p_vout->b_fullscreen = ! p_vout->b_fullscreen;
486
487         SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
488
489         p_vout->p_sys->b_cursor_autohidden = 0;
490         SDL_ShowCursor( p_vout->p_sys->b_cursor &&
491                         ! p_vout->p_sys->b_cursor_autohidden );
492
493         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
494     }
495
496     /* Pointer change */
497     if( ! p_vout->p_sys->b_cursor_autohidden &&
498         ( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) )
499     {
500         /* Hide the mouse automatically */
501         p_vout->p_sys->b_cursor_autohidden = 1;
502         SDL_ShowCursor( 0 );
503     }
504
505     return( 0 );
506 }
507
508 /*****************************************************************************
509  * vout_Display: displays previously rendered output
510  *****************************************************************************
511  * This function sends the currently rendered image to the display.
512  *****************************************************************************/
513 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
514 {
515     int x, y, w, h;
516     SDL_Rect disp;
517
518     vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
519                        &x, &y, &w, &h );
520     disp.x = x;
521     disp.y = y;
522     disp.w = w;
523     disp.h = h;
524
525     SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
526     SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
527     SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
528 }
529
530 /* following functions are local */
531
532 /*****************************************************************************
533  * SDLOpenDisplay: open and initialize SDL device
534  *****************************************************************************
535  * Open and initialize display according to preferences specified in the vout
536  * thread fields.
537  *****************************************************************************/
538 static int SDLOpenDisplay( vout_thread_t *p_vout )
539 {
540     Uint32 i_flags;
541     int    i_bpp;
542
543     /* Initialize flags and cursor */
544     i_flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE;
545     i_flags |= p_vout->b_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE;
546
547     i_bpp = SDL_VideoModeOK( p_vout->p_sys->i_width, p_vout->p_sys->i_height,
548                              SDL_DEFAULT_BPP, i_flags );
549     if( i_bpp == 0 )
550     {
551         intf_ErrMsg( "vout error: no video mode available" );
552         return( 1 );
553     }
554
555     p_vout->p_sys->p_display = SDL_SetVideoMode( p_vout->p_sys->i_width,
556                                                  p_vout->p_sys->i_height,
557                                                  i_bpp, i_flags );
558
559     if( p_vout->p_sys->p_display == NULL )
560     {
561         intf_ErrMsg( "vout error: cannot set video mode" );
562         return( 1 );
563     }
564
565     SDL_LockSurface( p_vout->p_sys->p_display );
566
567     p_vout->p_sys->p_overlay =
568         SDL_CreateYUVOverlay( 32, 32, SDL_YV12_OVERLAY,
569                               p_vout->p_sys->p_display );
570
571     if( p_vout->p_sys->p_overlay == NULL )
572     {
573         intf_ErrMsg( "vout error: cannot set overlay" );
574         SDL_UnlockSurface( p_vout->p_sys->p_display );
575         SDL_FreeSurface( p_vout->p_sys->p_display );
576         return( 1 );
577     }
578
579     if( p_vout->p_sys->p_overlay->hw_overlay )
580     {
581         SDL_WM_SetCaption( VOUT_TITLE " (hardware SDL output)",
582                            VOUT_TITLE " (hardware SDL output)" );
583     }
584     else
585     {
586         SDL_WM_SetCaption( VOUT_TITLE " (software SDL output)",
587                            VOUT_TITLE " (software SDL output)" );
588     }
589
590     SDL_EventState( SDL_KEYUP, SDL_IGNORE );               /* ignore keys up */
591
592     return( 0 );
593 }
594
595 /*****************************************************************************
596  * SDLCloseDisplay: close and reset SDL device
597  *****************************************************************************
598  * This function returns all resources allocated by SDLOpenDisplay and restore
599  * the original state of the device.
600  *****************************************************************************/
601 static void SDLCloseDisplay( vout_thread_t *p_vout )
602 {
603     SDL_FreeYUVOverlay( p_vout->p_sys->p_overlay );
604     SDL_UnlockSurface ( p_vout->p_sys->p_display );
605     SDL_FreeSurface( p_vout->p_sys->p_display );
606 }
607
608 /*****************************************************************************
609  * SDLNewPicture: allocate a picture
610  *****************************************************************************
611  * Returns 0 on success, -1 otherwise
612  *****************************************************************************/
613 static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
614 {
615     int i_width  = p_vout->output.i_width;
616     int i_height = p_vout->output.i_height;
617
618     switch( p_vout->output.i_chroma )
619     {
620         case YUV_420_PICTURE:
621             /* We know this chroma, allocate a buffer which will be used
622              * directly by the decoder */
623             p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
624
625             if( p_pic->p_sys == NULL )
626             {
627                 return -1;
628             }
629
630             p_pic->p_sys->p_overlay =
631                 SDL_CreateYUVOverlay( i_width, i_height,
632                                       SDL_YV12_OVERLAY,
633                                       p_vout->p_sys->p_display );
634
635             if( p_pic->p_sys->p_overlay == NULL )
636             {
637                 free( p_pic->p_sys );
638                 return -1;
639             }
640
641             SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
642
643             /* Precalculate some values */
644             p_pic->i_size         = i_width * i_height;
645             p_pic->i_chroma_width = i_width / 2;
646             p_pic->i_chroma_size  = i_height * ( i_width / 2 );
647
648             /* FIXME: try to get the right i_bytes value from p_overlay */
649             p_pic->planes[ Y_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 0 ];
650             p_pic->planes[ Y_PLANE ].i_bytes = p_pic->i_size * sizeof( u8 );
651             p_pic->planes[ Y_PLANE ].i_line_bytes = i_width * sizeof( u8 );
652
653             p_pic->planes[ U_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 2 ];
654             p_pic->planes[ U_PLANE ].i_bytes = p_pic->i_size * sizeof( u8 ) / 4;
655             p_pic->planes[ U_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof( u8 );
656
657             p_pic->planes[ V_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 1 ];
658             p_pic->planes[ V_PLANE ].i_bytes = p_pic->i_size * sizeof( u8 ) / 4;
659             p_pic->planes[ V_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof( u8 );
660
661             p_pic->i_planes = 3;
662
663             return 0;
664
665         default:
666             /* Unknown chroma, tell the guy to get lost */
667             p_pic->i_planes = 0;
668
669             return 0;
670     }
671 }
672