blob: a8ca66650fca049a92c90b0416084d9b26f72f22 [file] [log] [blame]
From b106ce175b0667a020a49aa6350b733714404285 Mon Sep 17 00:00:00 2001
From: Haihao Xiang <haihao.xiang@intel.com>
Date: Wed, 12 Aug 2020 14:24:55 +0800
Subject: [PATCH] Handle the odd resolution
Alignment calculation was missing in some places which caused
greenline appearance while processing the odd dimension videos.
https://github.com/intel/intel-vaapi-driver/issues/516
---
src/gen8_post_processing.c | 24 +++++++++----------
src/gen9_post_processing.c | 24 +++++++++----------
src/i965_drv_video.c | 48 +++++++++++++++++++-------------------
3 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/src/gen8_post_processing.c b/src/gen8_post_processing.c
index abddcd0..2163300 100644
--- a/src/gen8_post_processing.c
+++ b/src/gen8_post_processing.c
@@ -1909,17 +1909,17 @@ gen8_pp_context_get_surface_conf(VADriverContextP ctx,
fourcc == VA_FOURCC_BGRA) {
/* nothing to do here */
} else if (fourcc == VA_FOURCC_P010 || fourcc == VA_FOURCC_NV12) {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_surface->cb_cr_pitch;
bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
} else {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_surface->cb_cr_pitch;
bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
- width[2] = width[0] / 2;
- height[2] = height[0] / 2;
+ width[2] = ALIGN(width[0], 2) / 2;
+ height[2] = ALIGN(height[0], 2) / 2;
pitch[2] = obj_surface->cb_cr_pitch;
bo_offset[2] = obj_surface->width * obj_surface->y_cr_offset;
}
@@ -1940,8 +1940,8 @@ gen8_pp_context_get_surface_conf(VADriverContextP ctx,
fourcc == VA_FOURCC_BGRA) {
/* nothing to do here */
} else if (fourcc == VA_FOURCC_P010 || fourcc == VA_FOURCC_NV12) {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_image->image.pitches[1];
bo_offset[1] = obj_image->image.offsets[1];
} else {
@@ -1950,12 +1950,12 @@ gen8_pp_context_get_surface_conf(VADriverContextP ctx,
if (fourcc == VA_FOURCC_YV12 || fourcc == VA_FOURCC_IMC1)
u = 2, v = 1;
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_image->image.pitches[u];
bo_offset[1] = obj_image->image.offsets[u];
- width[2] = width[0] / 2;
- height[2] = height[0] / 2;
+ width[2] = ALIGN(width[0], 2) / 2;
+ height[2] = ALIGN(height[0], 2) / 2;
pitch[2] = obj_image->image.pitches[v];
bo_offset[2] = obj_image->image.offsets[v];
}
diff --git a/src/gen9_post_processing.c b/src/gen9_post_processing.c
index eede36f..da36f2a 100644
--- a/src/gen9_post_processing.c
+++ b/src/gen9_post_processing.c
@@ -731,19 +731,19 @@ gen9_pp_context_get_surface_conf(VADriverContextP ctx,
fourcc == VA_FOURCC_BGRA) {
/* nothing to do here */
} else if (fourcc == VA_FOURCC_P010 || fourcc == VA_FOURCC_NV12) {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_surface->cb_cr_pitch;
bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
} else if (fourcc == VA_FOURCC_YUY2 || fourcc == VA_FOURCC_UYVY) {
/* nothing to do here */
} else {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_surface->cb_cr_pitch;
bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
- width[2] = width[0] / 2;
- height[2] = height[0] / 2;
+ width[2] = ALIGN(width[0], 2) / 2;
+ height[2] = ALIGN(height[0], 2) / 2;
pitch[2] = obj_surface->cb_cr_pitch;
bo_offset[2] = obj_surface->width * obj_surface->y_cr_offset;
}
@@ -764,8 +764,8 @@ gen9_pp_context_get_surface_conf(VADriverContextP ctx,
fourcc == VA_FOURCC_BGRA) {
/* nothing to do here */
} else if (fourcc == VA_FOURCC_P010 || fourcc == VA_FOURCC_NV12) {
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_image->image.pitches[1];
bo_offset[1] = obj_image->image.offsets[1];
} else if (fourcc == VA_FOURCC_YUY2 || fourcc == VA_FOURCC_UYVY) {
@@ -776,12 +776,12 @@ gen9_pp_context_get_surface_conf(VADriverContextP ctx,
if (fourcc == VA_FOURCC_YV12 || fourcc == VA_FOURCC_IMC1)
u = 2, v = 1;
- width[1] = width[0] / 2;
- height[1] = height[0] / 2;
+ width[1] = ALIGN(width[0], 2) / 2;
+ height[1] = ALIGN(height[0], 2) / 2;
pitch[1] = obj_image->image.pitches[u];
bo_offset[1] = obj_image->image.offsets[u];
- width[2] = width[0] / 2;
- height[2] = height[0] / 2;
+ width[2] = ALIGN(width[0], 2) / 2;
+ height[2] = ALIGN(height[0], 2) / 2;
pitch[2] = obj_image->image.pitches[v];
bo_offset[2] = obj_image->image.offsets[v];
}
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 7df3621..2c4752e 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1725,8 +1725,8 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->subsampling = SUBSAMPLE_YUV420;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->height;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
if (tiling)
ASSERT_RET(IS_ALIGNED(obj_surface->cb_cr_pitch, 128), VA_STATUS_ERROR_INVALID_PARAMETER);
@@ -1743,8 +1743,8 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->subsampling = SUBSAMPLE_YUV420;
obj_surface->y_cr_offset = obj_surface->height;
obj_surface->y_cb_offset = memory_attibute->offsets[2] / obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
if (tiling)
@@ -1764,8 +1764,8 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->subsampling = SUBSAMPLE_YUV420;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = memory_attibute->offsets[2] / obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
if (tiling)
ASSERT_RET(IS_ALIGNED(obj_surface->cb_cr_pitch, 128), VA_STATUS_ERROR_INVALID_PARAMETER);
@@ -1837,7 +1837,7 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->subsampling = SUBSAMPLE_YUV422H;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = memory_attibute->offsets[2] / obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->cb_cr_height = obj_surface->orig_height;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
if (tiling)
@@ -1854,7 +1854,7 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->subsampling = SUBSAMPLE_YUV422H;
obj_surface->y_cr_offset = memory_attibute->offsets[1] / obj_surface->width;
obj_surface->y_cb_offset = memory_attibute->offsets[2] / obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->cb_cr_height = obj_surface->orig_height;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
ASSERT_RET(IS_ALIGNED(obj_surface->cb_cr_pitch, i965->codec_info->min_linear_wpitch), VA_STATUS_ERROR_INVALID_PARAMETER);
@@ -1869,7 +1869,7 @@ i965_suface_external_memory(VADriverContextP ctx,
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = memory_attibute->offsets[2] / obj_surface->width;
obj_surface->cb_cr_width = obj_surface->orig_width;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
if (tiling)
ASSERT_RET(IS_ALIGNED(obj_surface->cb_cr_pitch, 128), VA_STATUS_ERROR_INVALID_PARAMETER);
@@ -4522,8 +4522,8 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_P010:
assert(subsampling == SUBSAMPLE_YUV420);
obj_surface->cb_cr_pitch = obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->height;
region_width = obj_surface->width;
@@ -4534,8 +4534,8 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_IMC1:
assert(subsampling == SUBSAMPLE_YUV420);
obj_surface->cb_cr_pitch = obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->y_cr_offset = obj_surface->height;
obj_surface->y_cb_offset = obj_surface->y_cr_offset + ALIGN(obj_surface->cb_cr_height, 32);
region_width = obj_surface->width;
@@ -4546,8 +4546,8 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_IMC3:
assert(subsampling == SUBSAMPLE_YUV420);
obj_surface->cb_cr_pitch = obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->y_cb_offset + ALIGN(obj_surface->cb_cr_height, 32);
region_width = obj_surface->width;
@@ -4558,7 +4558,7 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_422H:
assert(subsampling == SUBSAMPLE_YUV422H);
obj_surface->cb_cr_pitch = obj_surface->width;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->cb_cr_height = obj_surface->orig_height;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->y_cb_offset + ALIGN(obj_surface->cb_cr_height, 32);
@@ -4571,7 +4571,7 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
assert(subsampling == SUBSAMPLE_YUV422V);
obj_surface->cb_cr_pitch = obj_surface->width;
obj_surface->cb_cr_width = obj_surface->orig_width;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->y_cb_offset + ALIGN(obj_surface->cb_cr_height, 32);
region_width = obj_surface->width;
@@ -4659,17 +4659,17 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_P010:
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->height;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->width = ALIGN(obj_surface->cb_cr_width * 2, i965->codec_info->min_linear_wpitch) *
bpp_1stplane;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = obj_surface->width;
region_width = obj_surface->width;
region_height = obj_surface->height + obj_surface->height / 2;
break;
case VA_FOURCC_YV16:
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->width = ALIGN(obj_surface->cb_cr_width, i965->codec_info->min_linear_wpitch) * 2;
obj_surface->cb_cr_height = obj_surface->orig_height;
obj_surface->y_cr_offset = obj_surface->height;
@@ -4690,9 +4690,9 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
obj_surface->y_cr_offset = obj_surface->height + obj_surface->height / 4;
}
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->width = ALIGN(obj_surface->cb_cr_width, i965->codec_info->min_linear_wpitch) * 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_height = ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = obj_surface->width / 2;
region_width = obj_surface->width;
region_height = obj_surface->height + obj_surface->height / 2;
@@ -4701,9 +4701,9 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
case VA_FOURCC_I010:
obj_surface->y_cb_offset = obj_surface->height;
obj_surface->y_cr_offset = obj_surface->height + obj_surface->height / 4;
- obj_surface->cb_cr_width = obj_surface->orig_width / 2;
+ obj_surface->cb_cr_width = ALIGN(obj_surface->orig_width, 2) / 2;
obj_surface->width = ALIGN(obj_surface->cb_cr_width * 2, i965->codec_info->min_linear_wpitch) * 2;
- obj_surface->cb_cr_height = obj_surface->orig_height / 2;
+ obj_surface->cb_cr_height =ALIGN(obj_surface->orig_height, 2) / 2;
obj_surface->cb_cr_pitch = obj_surface->width / 2;
region_width = obj_surface->width;
region_height = obj_surface->height + obj_surface->height / 2;
--
2.29.2.729.g45daf8777d-goog