]> git.sesse.net Git - vlc/blobdiff - plugins/chroma/yv12_rgb16.c
* ./ChangeLog: imported the 0.2.92 changes, unrolled current CVS changes.
[vlc] / plugins / chroma / yv12_rgb16.c
index e6a06e09e0d6ad43c188f6555890be2288ae4d9b..81dbf56df020cfe79fd1a44ce2191a23f8e46bd8 100644 (file)
@@ -2,7 +2,7 @@
  * yv12_rgb16.c : YUV to paletted RGB16 conversion module for vlc
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: yv12_rgb16.c,v 1.1 2001/12/30 07:09:54 sam Exp $
+ * $Id: yv12_rgb16.c,v 1.3 2002/01/02 14:37:42 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -100,13 +100,26 @@ void _M( chroma_getfunctions )( function_list_t * p_function_list )
  *****************************************************************************/
 static int chroma_Probe( probedata_t *p_data )
 {
-    if( p_data->chroma.p_render->i_chroma != YUV_420_PICTURE
-         || p_data->chroma.p_output->i_chroma != RGB_16BPP_PICTURE )
+    switch( p_data->chroma.p_render->i_chroma )
     {
-        return 0;
+        case FOURCC_YV12:
+        case FOURCC_I420:
+        case FOURCC_IYUV:
+            switch( ONLY_FOURCC( p_data->chroma.p_output->i_chroma ) )
+            {
+                case FOURCC_BI_BITFIELDS:
+                    break;
+
+                default:
+                    return 0;
+            }
+            break;
+
+        default:
+            return 0;
     }
 
-    return( 100 );
+    return 100;
 }
 
 /*****************************************************************************
@@ -116,12 +129,34 @@ static int chroma_Probe( probedata_t *p_data )
  *****************************************************************************/
 static int chroma_Init( vout_thread_t *p_vout )
 {
-    if( p_vout->render.i_chroma != YUV_420_PICTURE
-         || p_vout->output.i_chroma != RGB_16BPP_PICTURE )
+    switch( p_vout->render.i_chroma )
     {
-        return -1;
+        case FOURCC_YV12:
+        case FOURCC_I420:
+        case FOURCC_IYUV:
+            switch( ONLY_FOURCC( p_vout->output.i_chroma ) )
+            {
+                case FOURCC_BI_BITFIELDS:
+                    switch( ONLY_EXTRA( p_vout->output.i_chroma ) )
+                    {
+                        case DEPTH_16BPP:
+                            p_vout->chroma.pf_convert = ConvertYUV420RGB16;
+                            break;
+
+                        default:
+                            return -1;
+                    }
+                    break;
+
+                default:
+                    return -1;
+            }
+            break;
+
+        default:
+            return -1;
     }
-
+    
 #if 0
     p_vout->chroma.p_sys = malloc( sizeof( chroma_sys_t ) );
     if( p_vout->chroma.p_sys == NULL )
@@ -131,7 +166,6 @@ static int chroma_Init( vout_thread_t *p_vout )
 #endif
 
     /* FIXME: this is really suboptimal ! */
-    p_vout->chroma.pf_convert = ConvertYUV420RGB16;
 
     return 0; 
 }
@@ -170,44 +204,49 @@ static void ConvertYUV420RGB16( vout_thread_t *p_vout, picture_t *p_source,
 
     pixel_data_t *p_in, *p_in_end, *p_out, *p_out_end;
 
-    p_in = p_source->planes[ Y_PLANE ].p_data;
+    p_in = p_source->P_Y;
     p_in_end = p_in + p_source->planes[ Y_PLANE ].i_bytes;
 
-    p_out = p_dest->planes[ RGB_PLANE ].p_data;
-    p_out_end = p_out + p_dest->planes[ RGB_PLANE ].i_bytes;
+    p_out = p_dest->P_MAIN;
+    p_out_end = p_out + p_dest->planes[ MAIN_PLANE ].i_bytes;
 
     while( p_in < p_in_end && p_out < p_out_end )
     {
         int i_src = p_source->planes[ Y_PLANE ].i_line_bytes;
-        int i_dst = p_dest->planes[ RGB_PLANE ].i_line_bytes / 2;
+        int i_dst = p_dest->planes[ MAIN_PLANE ].i_line_bytes / 2;
 
         /* Masks: 0xf800 0x07e0 0x001f */
-#define RED ((u16*)p_out)[i_dst--] = (u16)(p_in[i_src--]>>3) << 11;
-#define GREEN ((u16*)p_out)[i_dst--] = (u16)(p_in[i_src--]>>2) << 5;
-#define BLUE ((u16*)p_out)[i_dst--] = (u16)(p_in[i_src--]>>3) << 0;
-#define WHITE ((u16*)p_out)[i_dst--] = ((u16)(p_in[i_src]>>3) << 11) | ((u16)(p_in[i_src]>>2) << 5) | ((u16)(p_in[i_src]>>3) << 0); i_src--;
-#define BLACK ((u16*)p_out)[i_dst--] = 0; i_src--;
+#define RED ((u16*)p_out)[--i_dst] = (u16)(p_in[--i_src]>>3) << 11;
+#define GREEN ((u16*)p_out)[--i_dst] = (u16)(p_in[--i_src]>>2) << 5;
+#define BLUE ((u16*)p_out)[--i_dst] = (u16)(p_in[--i_src]>>3) << 0;
+#define WHITE ((u16*)p_out)[--i_dst] = ((u16)(p_in[i_src]>>3) << 11) | ((u16)(p_in[i_src]>>2) << 5) | ((u16)(p_in[i_src]>>3) << 0); --i_src;
+#define BLACK ((u16*)p_out)[--i_dst] = 0; --i_src;
         
         while( i_src && i_dst )
         {
-            BLACK; BLUE; GREEN; RED; GREEN; BLUE; WHITE; RED;
-            GREEN; BLUE; WHITE; RED; BLACK; BLUE; GREEN; RED;
+            WHITE; WHITE; WHITE; WHITE; WHITE; WHITE; WHITE; WHITE;
+            //BLACK; BLUE; GREEN; RED; GREEN; BLUE; WHITE; RED;
         }
 
         p_in += p_source->planes[ Y_PLANE ].i_line_bytes;
-        p_out += p_dest->planes[ RGB_PLANE ].i_line_bytes;
+        p_out += p_dest->planes[ MAIN_PLANE ].i_line_bytes;
+
+        if( p_in >= p_in_end || p_out >= p_out_end )
+        {
+            break;
+        }
 
         i_src = p_source->planes[ Y_PLANE ].i_line_bytes;
-        i_dst = p_dest->planes[ RGB_PLANE ].i_line_bytes / 2;
+        i_dst = p_dest->planes[ MAIN_PLANE ].i_line_bytes / 2;
 
         while( i_src && i_dst )
         {
-            GREEN; RED; WHITE; BLUE; BLACK; RED; GREEN; BLUE;
-            BLACK; RED; GREEN; BLUE; GREEN; RED; WHITE; BLUE;
+            WHITE; WHITE; WHITE; WHITE; WHITE; WHITE; WHITE; WHITE;
+            //GREEN; RED; WHITE; BLUE; BLACK; RED; GREEN; BLUE;
         }
 
         p_in += p_source->planes[ Y_PLANE ].i_line_bytes;
-        p_out += p_dest->planes[ RGB_PLANE ].i_line_bytes;
+        p_out += p_dest->planes[ MAIN_PLANE ].i_line_bytes;
     }
 
     /**********************************************************************