/*****************************************************************************
* 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
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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" );
}
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
/*****************************************************************************
* 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 */
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 );
/*
}
}
+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" );
+
+}
+