summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPengfei Qu <Pengfei.Qu@intel.com>2018-01-18 17:39:36 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2018-01-23 16:28:03 +0800
commit354185247db89a564bc7bbfd7648367572776fd9 (patch)
tree20eb68f1d83f80cdefafaa113b155b26da7e54c0
parent570dfe1e51b657211a8c38b98c862d78ac44f302 (diff)
downloadlibva-intel-driver-354185247db89a564bc7bbfd7648367572776fd9.tar.gz
ENC:fix min resolution check for encoder
JPEG encoder allow min resolution 1x1 add min resolution check in vaCreateContext to avoid gtest failture add fix for gtest case fix the regression in 88249259d4abb2fd701ed3db229941738da2497e Fixes #330 #333 Signed-off-by: Pengfei Qu <Pengfei.Qu@intel.com>
-rw-r--r--src/i965_drv_video.c28
-rw-r--r--src/i965_drv_video.h1
-rw-r--r--src/i965_encoder.c4
-rw-r--r--test/i965_avce_context_test.cpp32
4 files changed, 52 insertions, 13 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 9b54597c..0582741e 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2508,12 +2508,16 @@ i965_CreateContext(VADriverContextP ctx,
int i;
int max_width;
int max_height;
+ int min_width_height = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
if (NULL == obj_config) {
vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
return vaStatus;
}
+ if (obj_config->profile == VAProfileJPEGBaseline)
+ min_width_height = 1;
+
max_resolution(i965, obj_config, &max_width, &max_height);
if (picture_width > max_width ||
@@ -2522,6 +2526,17 @@ i965_CreateContext(VADriverContextP ctx,
return vaStatus;
}
+ if ((VAEntrypointEncSlice == obj_config->entrypoint) ||
+ (VAEntrypointEncPicture == obj_config->entrypoint) ||
+ (VAEntrypointEncSliceLP == obj_config->entrypoint) ||
+ (VAEntrypointFEI == obj_config->entrypoint)) {
+ if (picture_width < min_width_height ||
+ picture_height < min_width_height) {
+ vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
+ return vaStatus;
+ }
+ }
+
/* Validate flag */
/* Validate picture dimensions */
contextID = NEW_CONTEXT_ID();
@@ -2666,6 +2681,7 @@ i965_CreateContext(VADriverContextP ctx,
if (vaStatus == VA_STATUS_SUCCESS)
obj_context->wrapper_context = wrapper_context;
}
+
/* Error recovery */
if (VA_STATUS_SUCCESS != vaStatus) {
i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context);
@@ -6438,21 +6454,23 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx,
i++;
if (obj_config->entrypoint == VAEntrypointEncSlice ||
- obj_config->entrypoint == VAEntrypointEncSliceLP) {
+ obj_config->entrypoint == VAEntrypointEncSliceLP ||
+ obj_config->entrypoint == VAEntrypointEncPicture ||
+ obj_config->entrypoint == VAEntrypointFEI) {
attribs[i].type = VASurfaceAttribMinWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
- attribs[i].value.value.i = 32;
+ attribs[i].value.value.i = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
if (obj_config->profile == VAProfileJPEGBaseline)
- attribs[i].value.value.i = 16;
+ attribs[i].value.value.i = 1;
i++;
attribs[i].type = VASurfaceAttribMinHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
- attribs[i].value.value.i = 32;
+ attribs[i].value.value.i = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
if (obj_config->profile == VAProfileJPEGBaseline)
- attribs[i].value.value.i = 16;
+ attribs[i].value.value.i = 1;
i++;
}
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 239aa03a..6e7139f4 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -81,6 +81,7 @@
#define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY
#define ENCODER_LOW_QUALITY 2
+#define I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT 32
#define I965_MAX_NUM_ROI_REGIONS 8
#define I965_MAX_NUM_SLICE 32
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index daa18b17..04f108eb 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -824,12 +824,12 @@ intel_encoder_check_misc_parameter(VADriverContextP ctx,
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
VAStatus ret = VA_STATUS_SUCCESS;
- int min_width_height = 32;
+ int min_width_height = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
if (encoder_context->frame_width_in_pixel > 0 &&
encoder_context->frame_height_in_pixel > 0) {
if (profile == VAProfileJPEGBaseline)
- min_width_height = 16;
+ min_width_height = 1;
if (encoder_context->frame_width_in_pixel < min_width_height ||
encoder_context->frame_height_in_pixel < min_width_height)
return VA_STATUS_ERROR_INVALID_PARAMETER;
diff --git a/test/i965_avce_context_test.cpp b/test/i965_avce_context_test.cpp
index db854b5b..fa31385c 100644
--- a/test/i965_avce_context_test.cpp
+++ b/test/i965_avce_context_test.cpp
@@ -77,6 +77,7 @@ protected:
VAConfigID config = VA_INVALID_ID;
VAContextID context = VA_INVALID_ID;
bool is_gen9 = false;
+ int min_resolution_width_height = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
};
TEST_P(AVCEContextTest, RateControl)
@@ -113,7 +114,11 @@ TEST_P(AVCEContextTest, RateControl)
config = createConfig(profile, entrypoint, attribs, expect);
if (expect != VA_STATUS_SUCCESS) continue;
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
+
if (HasFailure()) continue;
struct intel_encoder_context const *hw_context(*this);
@@ -148,7 +153,10 @@ TEST_P(AVCEContextTest, Codec)
ASSERT_NO_FAILURE(
config = createConfig(profile, entrypoint);
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
);
struct intel_encoder_context const *hw_context(*this);
@@ -168,7 +176,10 @@ TEST_P(AVCEContextTest, LowPowerMode)
ASSERT_NO_FAILURE(
config = createConfig(profile, entrypoint);
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
);
struct intel_encoder_context const *hw_context(*this);
@@ -193,7 +204,10 @@ TEST_P(AVCEContextTest, ROINotSpecified)
// will disable it.
ASSERT_NO_FAILURE(
config = createConfig(profile, entrypoint);
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
);
struct intel_encoder_context const *hw_context(*this);
@@ -222,7 +236,10 @@ TEST_P(AVCEContextTest, ROISpecified)
ConfigAttribs attribs(1, {type:VAConfigAttribEncROI});
ASSERT_NO_FAILURE(
config = createConfig(profile, entrypoint, attribs);
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
);
struct intel_encoder_context const *hw_context(*this);
@@ -242,7 +259,10 @@ TEST_P(AVCEContextTest, QualityRange)
ASSERT_NO_FAILURE(
config = createConfig(profile, entrypoint);
- context = createContext(config, 1, 1);
+ context = createContext(
+ config,
+ min_resolution_width_height,
+ min_resolution_width_height);
);
struct intel_encoder_context const *hw_context(*this);