From 3aa8fbe690e33e2026002f7af713d52faf1bd617 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Sun, 5 Jul 2020 19:27:11 +0200 Subject: [PATCH] fix exporting buffers with 3 planes and VA_EXPORT_SURFACE_SEPARATE_LAYERS To get the plane offset, y_cb_offset or y_cr_offset must be multiplied with the pitch for the 'Y' plane. See for example i965_DeriveImage(). Without this, exporting formats with 3 planes where cb_cr_pitch == width/2 is broken, because the offset of the third plane is calculated incorrectly. --- src/i965_drv_video.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index ff163887e..2202b8494 100644 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -6904,16 +6904,17 @@ i965_ExportSurfaceHandle(VADriverContextP ctx, VASurfaceID surface_id, else y_offset = obj_surface->y_cr_offset; } else { - y_offset = obj_surface->y_cr_offset - obj_surface->y_cb_offset; - if (y_offset < 0) - y_offset = -y_offset; + if (obj_surface->y_cb_offset < obj_surface->y_cr_offset) + y_offset = obj_surface->y_cr_offset; + else + y_offset = obj_surface->y_cb_offset; pitch = obj_surface->cb_cr_pitch; height = obj_surface->cb_cr_height; } desc->layers[p].offset[0] = offset; desc->layers[p].pitch[0] = pitch; - offset += pitch * y_offset; + offset = obj_surface->width * y_offset; } }