[x265] [PATCH] api: change meaning of pic.stride to be in bytes rather than pixels (fixes #35)
Steve Borho
steve at borho.org
Wed Mar 5 20:33:41 CET 2014
On Wed, Mar 5, 2014 at 12:47 PM, Steve Borho <steve at borho.org> wrote:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1394045238 21600
> # Wed Mar 05 12:47:18 2014 -0600
> # Node ID 59f0664b3d9060a56cd64187cb5e9d1d6b173f09
> # Parent 6d55869ed5e29c97977b89aa0218a5c8510c671a
> api: change meaning of pic.stride to be in bytes rather than pixels (fixes #35)
>
> x264's pic.plane pointer is a uint8_t* so their input strides are byte based,
> ffmpeg is currently assuming our input strides are byte based. This commit
> will make that assumption correct.
If no one objects, I'll push this with a bump to X265_BUILD
>
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/Lib/TLibCommon/TComPicYuv.cpp
> --- a/source/Lib/TLibCommon/TComPicYuv.cpp Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/Lib/TLibCommon/TComPicYuv.cpp Wed Mar 05 12:47:18 2014 -0600
> @@ -205,7 +205,7 @@
> }
>
> Y += getStride();
> - y += pic.stride[0];
> + y += pic.stride[0] / sizeof(pixel);
> }
>
> for (int r = 0; r < height >> m_vChromaShift; r++)
> @@ -218,8 +218,8 @@
>
> U += getCStride();
> V += getCStride();
> - u += pic.stride[1];
> - v += pic.stride[2];
> + u += pic.stride[1] / sizeof(*u);
> + v += pic.stride[2] / sizeof(*v);
> }
> }
> else if (pic.bitDepth == 8)
> @@ -240,7 +240,7 @@
> }
>
> Y += getStride();
> - y += pic.stride[0];
> + y += pic.stride[0] / sizeof(*y);
> }
>
> for (int r = 0; r < height >> m_vChromaShift; r++)
> @@ -253,8 +253,8 @@
>
> U += getCStride();
> V += getCStride();
> - u += pic.stride[1];
> - v += pic.stride[2];
> + u += pic.stride[1] / sizeof(*u);
> + v += pic.stride[2] / sizeof(*v);
> }
> }
> else /* pic.bitDepth > 8 */
> @@ -280,7 +280,7 @@
> }
>
> Y += getStride();
> - y += pic.stride[0];
> + y += pic.stride[0] / sizeof(*y);
> }
>
> for (int r = 0; r < height >> m_vChromaShift; r++)
> @@ -293,8 +293,8 @@
>
> U += getCStride();
> V += getCStride();
> - u += pic.stride[1];
> - v += pic.stride[2];
> + u += pic.stride[1] / sizeof(*u);
> + v += pic.stride[2] / sizeof(*v);
> }
> }
>
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/encoder/encoder.cpp Wed Mar 05 12:47:18 2014 -0600
> @@ -390,11 +390,11 @@
> }
>
> pic_out->planes[0] = recpic->getLumaAddr();
> - pic_out->stride[0] = recpic->getStride();
> + pic_out->stride[0] = recpic->getStride() * sizeof(pixel);
> pic_out->planes[1] = recpic->getCbAddr();
> - pic_out->stride[1] = recpic->getCStride();
> + pic_out->stride[1] = recpic->getCStride() * sizeof(pixel);
> pic_out->planes[2] = recpic->getCrAddr();
> - pic_out->stride[2] = recpic->getCStride();
> + pic_out->stride[2] = recpic->getCStride() * sizeof(pixel);
> }
>
> if (out->getSlice()->m_numWPRefs > 0)
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/input/yuv.cpp
> --- a/source/input/yuv.cpp Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/input/yuv.cpp Wed Mar 05 12:47:18 2014 -0600
> @@ -219,11 +219,11 @@
>
> pic.colorSpace = colorSpace;
> pic.bitDepth = depth;
> + pic.stride[0] = width * pixelbytes;
> + pic.stride[1] = pic.stride[2] = pic.stride[0] >> 1;
> pic.planes[0] = buf[head];
> - pic.planes[1] = (char*)(pic.planes[0]) + width * height * pixelbytes;
> - pic.planes[2] = (char*)(pic.planes[1]) + ((width * height * pixelbytes) >> 2);
> - pic.stride[0] = width;
> - pic.stride[1] = pic.stride[2] = pic.stride[0] >> 1;
> + pic.planes[1] = (char*)(pic.planes[0]) + height * pic.stride[0];
> + pic.planes[2] = (char*)(pic.planes[1]) + ((height * pic.stride[1]) >> 2);
>
> head = (head + 1) % QUEUE_SIZE;
> notFull.trigger();
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/output/y4m.cpp
> --- a/source/output/y4m.cpp Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/output/y4m.cpp Wed Mar 05 12:47:18 2014 -0600
> @@ -93,18 +93,19 @@
> }
>
> ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]);
> - src += pic.stride[i];
> + src += pic.stride[i] / sizeof(*src);
> }
> }
>
> #else // if HIGH_BIT_DEPTH
> +
> for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
> {
> char *src = (char*)pic.planes[i];
> for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
> {
> ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]);
> - src += pic.stride[i];
> + src += pic.stride[i] / sizeof(*src);
> }
> }
>
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/output/yuv.cpp
> --- a/source/output/yuv.cpp Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/output/yuv.cpp Wed Mar 05 12:47:18 2014 -0600
> @@ -73,7 +73,7 @@
> }
>
> ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]);
> - src += pic.stride[i];
> + src += pic.stride[i] / sizeof(*src);
> }
> }
> }
> @@ -86,7 +86,7 @@
> for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
> {
> ofs.write((const char*)src, (width * 2) >> x265_cli_csps[colorSpace].width[i]);
> - src += pic.stride[i];
> + src += pic.stride[i] / sizeof(*src);
> }
> }
> }
> @@ -98,7 +98,7 @@
> for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
> {
> ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]);
> - src += pic.stride[i];
> + src += pic.stride[i] / sizeof(*src);
> }
> }
>
> diff -r 6d55869ed5e2 -r 59f0664b3d90 source/x265.h
> --- a/source/x265.h Wed Mar 05 11:48:14 2014 -0600
> +++ b/source/x265.h Wed Mar 05 12:47:18 2014 -0600
> @@ -95,6 +95,8 @@
> /* Must be specified on input pictures, the number of planes is determined
> * by the colorSpace value */
> void* planes[3];
> +
> + /* Stride is the number of bytes between row starts */
> int stride[3];
>
> /* Must be specified on input pictures. x265_picture_init() will set it to
--
Steve Borho
More information about the x265-devel
mailing list