# HG changeset patch # User reimar # Date 1331662776 0 # Node ID b9a160ba58179a018e54a0a8d415b674f0fb4fb9 # Parent 2d928e78d2489026ba099b13d60d367d86e2ccd0 Fix PBO handling with > 8 bit YUV formats. Thanks to Ivan for debugging it. diff -r 2d928e78d248 -r b9a160ba5817 libvo/vo_gl.c --- a/libvo/vo_gl.c Tue Mar 13 11:44:05 2012 +0000 +++ b/libvo/vo_gl.c Tue Mar 13 18:19:36 2012 +0000 @@ -965,13 +965,15 @@ if (is_yuv) { // planar YUV int xs, ys; - mp_get_chroma_shift(image_format, &xs, &ys, NULL); + int bpp; + mp_get_chroma_shift(image_format, &xs, &ys, &bpp); + bpp = (bpp + 7) / 8; mpi->flags |= MP_IMGFLAG_COMMON_STRIDE | MP_IMGFLAG_COMMON_PLANE; - mpi->stride[0] = mpi->width; + mpi->stride[0] = mpi->width * bpp; mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * mpi->height; - mpi->stride[1] = mpi->width >> xs; + mpi->stride[1] = (mpi->width >> xs) * bpp; mpi->planes[2] = mpi->planes[1] + mpi->stride[1] * (mpi->height >> ys); - mpi->stride[2] = mpi->width >> xs; + mpi->stride[2] = mpi->stride[1]; if (ati_hack && !mesa_buffer) { mpi->flags &= ~MP_IMGFLAG_COMMON_PLANE; if (!gl_buffer_uv[0]) mpglGenBuffers(2, gl_buffer_uv); @@ -1021,19 +1023,23 @@ mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP; mpi2.width = mpi2.w; mpi2.height = mpi2.h; if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) { - int bpp = is_yuv ? 8 : mpi->bpp; + int bpp; + int line_bytes, line_bytes_c; int xs, ys; - mp_get_chroma_shift(image_format, &xs, &ys, NULL); - memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bpp / 8, mpi->h, mpi2.stride[0], mpi->stride[0]); + mp_get_chroma_shift(image_format, &xs, &ys, &bpp); + bpp = is_yuv ? (bpp + 7) & ~7 : mpi->bpp; + line_bytes = mpi->w * bpp / 8; + line_bytes_c = (mpi->w >> xs) * bpp / 8; + memcpy_pic(mpi2.planes[0], mpi->planes[0], line_bytes, mpi->h, mpi2.stride[0], mpi->stride[0]); if (is_yuv) { - memcpy_pic(mpi2.planes[1], mpi->planes[1], mpi->w >> xs, mpi->h >> ys, mpi2.stride[1], mpi->stride[1]); - memcpy_pic(mpi2.planes[2], mpi->planes[2], mpi->w >> xs, mpi->h >> ys, mpi2.stride[2], mpi->stride[2]); + memcpy_pic(mpi2.planes[1], mpi->planes[1], line_bytes_c, mpi->h >> ys, mpi2.stride[1], mpi->stride[1]); + memcpy_pic(mpi2.planes[2], mpi->planes[2], line_bytes_c, mpi->h >> ys, mpi2.stride[2], mpi->stride[2]); } if (ati_hack) { // since we have to do a full upload we need to clear the borders - clear_border(mpi2.planes[0], mpi->w * bpp / 8, mpi2.stride[0], mpi->h, mpi2.height, 0); + clear_border(mpi2.planes[0], line_bytes, mpi2.stride[0], mpi->h, mpi2.height, 0); if (is_yuv) { - clear_border(mpi2.planes[1], mpi->w >> xs, mpi2.stride[1], mpi->h >> ys, mpi2.height >> ys, 128); - clear_border(mpi2.planes[2], mpi->w >> xs, mpi2.stride[2], mpi->h >> ys, mpi2.height >> ys, 128); + clear_border(mpi2.planes[1], line_bytes_c, mpi2.stride[1], mpi->h >> ys, mpi2.height >> ys, 128); + clear_border(mpi2.planes[2], line_bytes_c, mpi2.stride[2], mpi->h >> ys, mpi2.height >> ys, 128); } } mpi = &mpi2;