]> git.sesse.net Git - vlc/blobdiff - plugins/yuv/transforms_yuv.c
Rewritten vout for BeOS. Now does not support overlay however code is simpler
[vlc] / plugins / yuv / transforms_yuv.c
index 34524c8e7d039417ee181fc975b7186822d6c5eb..d8a2b148adeae5f2f9101115f0a6e963a6a4f318 100644 (file)
@@ -1,12 +1,15 @@
 /*****************************************************************************
  * transforms_yuv.c: C YUV transformation functions
- * Provides functions to perform the YUV conversion. The functions provided here
- * are a complete and portable C implementation, and may be replaced in certain
- * case by optimized functions.
+ * Provides functions to perform the YUV conversion. The functions provided
+ * here are a complete and portable C implementation, and may be replaced in
+ * certain cases by optimized functions.
  *****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
+ * Copyright (C) 1999, 2000, 2001 VideoLAN
+ * $Id: transforms_yuv.c,v 1.6 2001/06/03 12:47:21 sam Exp $
  *
- * Authors:
+ * Authors: Vincent Seguin <ptyx@via.ecp.fr>
+ *          Samuel Hocevar <sam@zoy.org>
+ *          Richard Shepherd <richard@rshepherd.demon.co.uk>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +27,9 @@
  * Boston, MA 02111-1307, USA.
  *****************************************************************************/
 
+#define MODULE_NAME yuv
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 
 #include "intf_msg.h"
 
+#include "modules.h"
+#include "modules_export.h"
+
 /*****************************************************************************
  * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
  *****************************************************************************/
-void ConvertY4Gray8( YUV_ARGS_8BPP )
+void _M( ConvertY4Gray8 )( YUV_ARGS_8BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -72,7 +81,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP )
     p_gray =            p_vout->yuv.yuv.p_gray8;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -109,7 +118,7 @@ void ConvertY4Gray8( YUV_ARGS_8BPP )
 /*****************************************************************************
  * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
  *****************************************************************************/
-void ConvertYUV420RGB8( YUV_ARGS_8BPP )
+void _M( ConvertYUV420RGB8 )( YUV_ARGS_8BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -134,14 +143,14 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
     static int dither22[4] = {  0x6, 0x16,  0x2, 0x12 };
     static int dither23[4] = { 0x1e,  0xe, 0x1a,  0xa };
 
-    /*
+   /*
      * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_offset_start =    p_vout->yuv.p_offset;
     p_lookup =          p_vout->yuv.p_base;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 1 );
 
     /*
@@ -160,7 +169,7 @@ void ConvertYUV420RGB8( YUV_ARGS_8BPP )
 /*****************************************************************************
  * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
  *****************************************************************************/
-void ConvertYUV422RGB8( YUV_ARGS_8BPP )
+void _M( ConvertYUV422RGB8 )( YUV_ARGS_8BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 8" );
 }
@@ -168,7 +177,7 @@ void ConvertYUV422RGB8( YUV_ARGS_8BPP )
 /*****************************************************************************
  * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
  *****************************************************************************/
-void ConvertYUV444RGB8( YUV_ARGS_8BPP )
+void _M( ConvertYUV444RGB8 )( YUV_ARGS_8BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 8" );
 }
@@ -176,7 +185,7 @@ void ConvertYUV444RGB8( YUV_ARGS_8BPP )
 /*****************************************************************************
  * ConvertY4Gray16: grayscale YUV 4:x:x to RGB 2 Bpp
  *****************************************************************************/
-void ConvertY4Gray16( YUV_ARGS_16BPP )
+void _M( ConvertY4Gray16 )( YUV_ARGS_16BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -197,7 +206,7 @@ void ConvertY4Gray16( YUV_ARGS_16BPP )
     p_gray =            p_vout->yuv.yuv.p_gray16;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -234,7 +243,7 @@ void ConvertY4Gray16( YUV_ARGS_16BPP )
 /*****************************************************************************
  * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV420RGB16( YUV_ARGS_16BPP )
+void _M( ConvertYUV420RGB16 )( YUV_ARGS_16BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -259,7 +268,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -296,7 +305,7 @@ void ConvertYUV420RGB16( YUV_ARGS_16BPP )
 /*****************************************************************************
  * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV422RGB16( YUV_ARGS_16BPP )
+void _M( ConvertYUV422RGB16 )( YUV_ARGS_16BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -321,7 +330,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -358,7 +367,7 @@ void ConvertYUV422RGB16( YUV_ARGS_16BPP )
 /*****************************************************************************
  * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV444RGB16( YUV_ARGS_16BPP )
+void _M( ConvertYUV444RGB16 )( YUV_ARGS_16BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -382,7 +391,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -419,7 +428,7 @@ void ConvertYUV444RGB16( YUV_ARGS_16BPP )
 /*****************************************************************************
  * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 2 Bpp
  *****************************************************************************/
-void ConvertY4Gray24( YUV_ARGS_24BPP )
+void _M( ConvertY4Gray24 )( YUV_ARGS_24BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, grayscale, bpp = 24" );
 }
@@ -427,7 +436,7 @@ void ConvertY4Gray24( YUV_ARGS_24BPP )
 /*****************************************************************************
  * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV420RGB24( YUV_ARGS_24BPP )
+void _M( ConvertYUV420RGB24 )( YUV_ARGS_24BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, chroma = 420, bpp = 24" );
 }
@@ -435,7 +444,7 @@ void ConvertYUV420RGB24( YUV_ARGS_24BPP )
 /*****************************************************************************
  * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV422RGB24( YUV_ARGS_24BPP )
+void _M( ConvertYUV422RGB24 )( YUV_ARGS_24BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 24" );
 }
@@ -443,7 +452,7 @@ void ConvertYUV422RGB24( YUV_ARGS_24BPP )
 /*****************************************************************************
  * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 2 Bpp
  *****************************************************************************/
-void ConvertYUV444RGB24( YUV_ARGS_24BPP )
+void _M( ConvertYUV444RGB24 )( YUV_ARGS_24BPP )
 {
     intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 24" );
 }
@@ -451,7 +460,7 @@ void ConvertYUV444RGB24( YUV_ARGS_24BPP )
 /*****************************************************************************
  * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
  *****************************************************************************/
-void ConvertY4Gray32( YUV_ARGS_32BPP )
+void _M( ConvertY4Gray32 )( YUV_ARGS_32BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -472,7 +481,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP )
     p_gray =            p_vout->yuv.yuv.p_gray32;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -509,7 +518,7 @@ void ConvertY4Gray32( YUV_ARGS_32BPP )
 /*****************************************************************************
  * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
  *****************************************************************************/
-void ConvertYUV420RGB32( YUV_ARGS_32BPP )
+void _M( ConvertYUV420RGB32 )( YUV_ARGS_32BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -534,7 +543,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -571,7 +580,7 @@ void ConvertYUV420RGB32( YUV_ARGS_32BPP )
 /*****************************************************************************
  * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
  *****************************************************************************/
-void ConvertYUV422RGB32( YUV_ARGS_32BPP )
+void _M( ConvertYUV422RGB32 )( YUV_ARGS_32BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -596,7 +605,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -633,7 +642,7 @@ void ConvertYUV422RGB32( YUV_ARGS_32BPP )
 /*****************************************************************************
  * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
  *****************************************************************************/
-void ConvertYUV444RGB32( YUV_ARGS_32BPP )
+void _M( ConvertYUV444RGB32 )( YUV_ARGS_32BPP )
 {
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
@@ -657,7 +666,7 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP )
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
     p_buffer_start =    p_vout->yuv.p_buffer;
     p_offset_start =    p_vout->yuv.p_offset;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
+    _M( SetOffset )( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
 
     /*
@@ -691,3 +700,103 @@ void ConvertYUV444RGB32( YUV_ARGS_32BPP )
     }
 }
 
+static __inline__ void yuv2YCbCr422_inner( u8 *p_y, u8 *p_u, u8 *p_v,
+                                           u8 *p_out, int i_width_by_4 )
+{
+    int i_x;
+
+    for( i_x = 0 ; i_x < 4 * i_width_by_4 ; ++i_x )
+    {
+        *p_out++ = p_y[ 2 * i_x ];
+        *p_out++ = p_u[ i_x ];
+        *p_out++ = p_y[ 2 * i_x + 1 ];
+        *p_out++ = p_v[ i_x ];
+    }
+}
+
+void _M( ConvertYUV420YCbr8 )( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 420, YCbr = 8" );
+}
+
+void _M( ConvertYUV422YCbr8 )( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, YCbr = 8" );
+
+}
+
+void _M( ConvertYUV444YCbr8 )( YUV_ARGS_8BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, YCbr = 8" );
+
+}
+
+/*****************************************************************************
+ * yuv2YCbCr422: color YUV 4:2:0 to color YCbCr 16bpp
+ *****************************************************************************/
+void _M( ConvertYUV420YCbr16 )( YUV_ARGS_16BPP )
+{
+    int i_y;
+
+    for( i_y = 0 ; i_y < i_height ; ++i_y )
+    {
+        yuv2YCbCr422_inner( p_y, p_u, p_v, (u8 *)p_pic, i_width / 8 );
+
+        p_pic += i_width * 2;
+        
+        p_y += i_width;
+
+        if( i_y & 0x1 )
+        {
+            p_u += i_width / 2;
+            p_v += i_width / 2;
+        }
+    }
+}
+
+void _M( ConvertYUV422YCbr16 )( YUV_ARGS_16BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, YCbr = 16" );
+
+}
+void _M( ConvertYUV444YCbr16 )( YUV_ARGS_16BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, YCbr = 16" );
+
+}
+
+void _M( ConvertYUV420YCbr24 )( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 420, YCbr = 24" );
+
+}
+
+void _M( ConvertYUV422YCbr24 )( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, YCbr = 24" );
+
+}
+
+void _M( ConvertYUV444YCbr24 )( YUV_ARGS_24BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, YCbr = 24" );
+
+}
+
+void _M( ConvertYUV420YCbr32 )( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 420, YCbr = 32" );
+
+}
+
+void _M( ConvertYUV422YCbr32 )( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 422, YCbr = 32" );
+
+}
+void _M( ConvertYUV444YCbr32 )( YUV_ARGS_32BPP )
+{
+    intf_ErrMsg( "yuv error: unhandled function, chroma = 444, YCbr = 32" );
+
+}
+