[Mesa-dev] [PATCH v2 6/7] egl/android: Add support for YV12 pixel format (v2)
Chad Versace
chad at kiwitree.net
Mon Aug 8 18:39:03 UTC 2016
On 08/02/2016 04:07 AM, Tomasz Figa wrote:
> This patch adds support for YV12 pixel format to the Android platform
> backend. Only creating EGL images is supported, it is not added to the
> list of available visuals.
>
> v2: Use const array defined just for YV12 instead of trying to be overly
> generic.
>
> Signed-off-by: Tomasz Figa <tfiga at chromium.org>
> Signed-off-by: Kalyan Kondapally <kalyan.kondapally at intel.com>
> ---
> src/egl/drivers/dri2/platform_android.c | 56 +++++++++++++++++++++++++++++----
> 1 file changed, 50 insertions(+), 6 deletions(-)
> @@ -512,22 +518,60 @@ static _EGLImage *
> droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx,
> struct ANativeWindowBuffer *buf, int fd)
> {
> + unsigned int offsets[3] = { 0, 0, 0 };
> + unsigned int pitches[3] = { 0, 0, 0 };
> +
> const int fourcc = get_fourcc(buf->format);
> - const int pitch = buf->stride * get_format_bpp(buf->format);
> + if (fourcc == -1) {
> + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> + return NULL;
> + }
>
> - const EGLint attr_list[14] = {
> + pitches[0] = buf->stride * get_format_bpp(buf->format);
> + if (pitches[0] == 0) {
> + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
> + return NULL;
> + }
> +
> + switch (buf->format) {
> + case HAL_PIXEL_FORMAT_YV12:
> + /* Y plane is assumed to be at offset 0. */
> + /* Cr plane is located after Y plane */
> + offsets[1] = offsets[0] + pitches[0] * buf->height;
> + pitches[1] = ALIGN(pitches[0] / 2, 16);
> + /* Cb plane is located after Cr plane */
> + offsets[2] = offsets[1] + pitches[1] * buf->height / 2;
I believe the above should be
offsets[2] = offsets[1] + pitches[1] * ALIGN(buf->height, 2) / 2;
to accommodate buffers with odd height.
That's the only issue I found in this patch.
More information about the mesa-dev
mailing list