--- colorspace.c 2004/03/22 22:36:23 1.9 +++ colorspace.c 2006/10/29 08:04:02 1.12 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: colorspace.c,v 1.9 2004/03/22 22:36:23 edgomez Exp $ + * $Id: colorspace.c,v 1.12 2006/10/29 08:04:02 chl Exp $ * ****************************************************************************/ @@ -38,7 +38,6 @@ packedFuncPtr abgr_to_yv12; packedFuncPtr rgba_to_yv12; packedFuncPtr argb_to_yv12; -packedFuncPtr yuv_to_yv12; packedFuncPtr yuyv_to_yv12; packedFuncPtr uyvy_to_yv12; @@ -60,7 +59,6 @@ packedFuncPtr yv12_to_abgr; packedFuncPtr yv12_to_rgba; packedFuncPtr yv12_to_argb; -packedFuncPtr yv12_to_yuv; packedFuncPtr yv12_to_yuyv; packedFuncPtr yv12_to_uyvy; @@ -77,11 +75,11 @@ planarFuncPtr yv12_to_yv12; -int32_t RGB_Y_tab[256]; -int32_t B_U_tab[256]; -int32_t G_U_tab[256]; -int32_t G_V_tab[256]; -int32_t R_V_tab[256]; +static int32_t RGB_Y_tab[256]; +static int32_t B_U_tab[256]; +static int32_t G_U_tab[256]; +static int32_t G_V_tab[256]; +static int32_t R_V_tab[256]; @@ -339,12 +337,12 @@ ((MAX(0,MIN(255, B)) >> 3) & 0x001f) #define WRITE_RGB16(ROW,UV_ROW,C1) \ - rgb_y = RGB_Y_tab[ y_ptr[y_stride + 0] ]; \ + rgb_y = RGB_Y_tab[ y_ptr[y_stride*(ROW) + 0] ]; \ b[ROW] = (b[ROW] & 0x7) + ((rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT); \ g[ROW] = (g[ROW] & 0x7) + ((rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT); \ r[ROW] = (r[ROW] & 0x7) + ((rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT); \ *(uint16_t *) (x_ptr+((ROW)*x_stride)+0) = C1(r[ROW], g[ROW], b[ROW]); \ - rgb_y = RGB_Y_tab[ y_ptr[y_stride + 1] ]; \ + rgb_y = RGB_Y_tab[ y_ptr[y_stride*(ROW) + 1] ]; \ b[ROW] = (b[ROW] & 0x7) + ((rgb_y + b_u##UV_ROW) >> SCALEBITS_OUT); \ g[ROW] = (g[ROW] & 0x7) + ((rgb_y - g_uv##UV_ROW) >> SCALEBITS_OUT); \ r[ROW] = (r[ROW] & 0x7) + ((rgb_y + r_v##UV_ROW) >> SCALEBITS_OUT); \ @@ -489,17 +487,29 @@ y_dst += y_dst_stride; } - for (y = height2; y; y--) { - memcpy(u_dst, u_src, width2); - u_src += uv_src_stride; - u_dst += uv_dst_stride; - } - - for (y = height2; y; y--) { - memcpy(v_dst, v_src, width2); - v_src += uv_src_stride; - v_dst += uv_dst_stride; - } + if (u_src) + for (y = height2; y; y--) { + memcpy(u_dst, u_src, width2); + u_src += uv_src_stride; + u_dst += uv_dst_stride; + } + else + for (y = height2; y; y--) { + memset(u_dst, 0x80, width2); + u_dst += uv_dst_stride; + } + + if (v_src) + for (y = height2; y; y--) { + memcpy(v_dst, v_src, width2); + v_src += uv_src_stride; + v_dst += uv_dst_stride; + } + else + for (y = height2; y; y--) { + memset(v_dst, 0x80, width2); + v_dst += uv_dst_stride; + } }