summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2020-08-12 14:24:55 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2020-08-19 08:14:36 +0800
commitd87db2111a33b157d1913415f15d201cc5182850 (patch)
treea916b1bfdb3ef00bb22849a482945a6b4bfde5b7
parent567a22c8d1e495807d3ece471fe417c3fe0428f5 (diff)
downloadlibva-intel-driver-d87db2111a33b157d1913415f15d201cc5182850.tar.gz
Handle odd resolution
This fixes https://github.com/intel/intel-vaapi-driver/issues/516 Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
-rw-r--r--src/gen8_post_processing.c24
-rw-r--r--src/gen9_post_processing.c24
-rw-r--r--src/i965_drv_video.c48
3 files changed, 48 insertions, 48 deletions
diff --git a/src/gen8_post_processing.c b/src/gen8_post_processing.c
index abddcd07..2163300a 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 eede36f7..da36f2ab 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 ff163887..80278bb7 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);
@@ -4526,8 +4526,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;
@@ -4538,8 +4538,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;
@@ -4550,8 +4550,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;
@@ -4562,7 +4562,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);
@@ -4575,7 +4575,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;
@@ -4663,17 +4663,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;
@@ -4694,9 +4694,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;
@@ -4705,9 +4705,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;