--- colorspace.c 2005/11/22 10:23:01 1.11 +++ 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.11 2005/11/22 10:23:01 suxen_drol Exp $ + * $Id: colorspace.c,v 1.13 2006/10/30 10:52:00 Skal Exp $ * ****************************************************************************/ @@ -472,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; } @@ -487,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; + } } }