--- colorspace.c 2004/03/22 22:36:23 1.9 +++ colorspace.c 2006/10/30 10:52:00 1.13 @@ -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.13 2006/10/30 10:52:00 Skal 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); \ @@ -474,11 +472,14 @@ int width2 = width / 2; int height2 = height / 2; int y; + const int with_uv = (u_src!=0 && v_src!=0); if (vflip) { y_src += (height - 1) * y_src_stride; - u_src += (height2 - 1) * uv_src_stride; - v_src += (height2 - 1) * uv_src_stride; + if (with_uv) { + u_src += (height2 - 1) * uv_src_stride; + v_src += (height2 - 1) * uv_src_stride; + } y_src_stride = -y_src_stride; uv_src_stride = -uv_src_stride; } @@ -489,16 +490,23 @@ 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; + if (with_uv) { + for (y = height2; y; y--) { + memcpy(u_dst, u_src, width2); + memcpy(v_dst, v_src, width2); + u_src += uv_src_stride; + u_dst += uv_dst_stride; + v_src += uv_src_stride; + v_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; + else { + for (y = height2; y; y--) { + memset(u_dst, 0x80, width2); + memset(v_dst, 0x80, width2); + u_dst += uv_dst_stride; + v_dst += uv_dst_stride; + } } }