mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 09:10:11 +01:00
frontends/va: Update conditional checks for code stability.
Added parameter checks and updated returns based on that. https://github.com/intel/libva-utils/tree/master/test run test_va_api Signed-off-by: SureshGuttula <sguttula@amd.com> Reviewed-by: Thong Thai <thong.thai@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8374>
This commit is contained in:
parent
083843de1e
commit
b4651890be
2 changed files with 49 additions and 7 deletions
|
|
@ -87,7 +87,9 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ProfileToPipe(profile);
|
p = ProfileToPipe(profile);
|
||||||
if (p == PIPE_VIDEO_PROFILE_UNKNOWN)
|
if (p == PIPE_VIDEO_PROFILE_UNKNOWN ||
|
||||||
|
(u_reduce_video_profile(p) == PIPE_VIDEO_FORMAT_MPEG4 &&
|
||||||
|
!debug_get_option_mpeg4()))
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||||
|
|
||||||
pscreen = VL_VA_PSCREEN(ctx);
|
pscreen = VL_VA_PSCREEN(ctx);
|
||||||
|
|
@ -211,7 +213,10 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
if (!config)
|
if (!config)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
|
if (profile == VAProfileNone) {
|
||||||
|
if (entrypoint != VAEntrypointVideoProc)
|
||||||
|
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
|
||||||
|
|
||||||
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_UNKNOWN;
|
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_UNKNOWN;
|
||||||
config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
|
config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
|
||||||
supported_rt_formats = VA_RT_FORMAT_YUV420 |
|
supported_rt_formats = VA_RT_FORMAT_YUV420 |
|
||||||
|
|
@ -225,6 +230,10 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
FREE(config);
|
FREE(config);
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/*other attrib_types are not supported.*/
|
||||||
|
FREE(config);
|
||||||
|
return VA_STATUS_ERROR_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +248,9 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ProfileToPipe(profile);
|
p = ProfileToPipe(profile);
|
||||||
if (p == PIPE_VIDEO_PROFILE_UNKNOWN) {
|
if (p == PIPE_VIDEO_PROFILE_UNKNOWN ||
|
||||||
|
(u_reduce_video_profile(p) == PIPE_VIDEO_FORMAT_MPEG4 &&
|
||||||
|
!debug_get_option_mpeg4())) {
|
||||||
FREE(config);
|
FREE(config);
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||||
}
|
}
|
||||||
|
|
@ -248,20 +259,22 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
|
|
||||||
switch (entrypoint) {
|
switch (entrypoint) {
|
||||||
case VAEntrypointVLD:
|
case VAEntrypointVLD:
|
||||||
|
supported_rt_formats = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422;
|
||||||
if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
|
||||||
PIPE_VIDEO_CAP_SUPPORTED)) {
|
PIPE_VIDEO_CAP_SUPPORTED)) {
|
||||||
FREE(config);
|
FREE(config);
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
|
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VAEntrypointEncSlice:
|
case VAEntrypointEncSlice:
|
||||||
|
supported_rt_formats = VA_RT_FORMAT_YUV420;
|
||||||
if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
|
if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
|
||||||
PIPE_VIDEO_CAP_SUPPORTED)) {
|
PIPE_VIDEO_CAP_SUPPORTED)) {
|
||||||
FREE(config);
|
FREE(config);
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
|
config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
|
||||||
|
|
@ -273,7 +286,6 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
}
|
}
|
||||||
|
|
||||||
config->profile = p;
|
config->profile = p;
|
||||||
supported_rt_formats = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422;
|
|
||||||
if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P010, p,
|
if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P010, p,
|
||||||
config->entrypoint) ||
|
config->entrypoint) ||
|
||||||
pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016, p,
|
pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016, p,
|
||||||
|
|
@ -281,13 +293,22 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
supported_rt_formats |= VA_RT_FORMAT_YUV420_10BPP;
|
supported_rt_formats |= VA_RT_FORMAT_YUV420_10BPP;
|
||||||
|
|
||||||
for (int i = 0; i <num_attribs ; i++) {
|
for (int i = 0; i <num_attribs ; i++) {
|
||||||
|
if (attrib_list[i].type != VAConfigAttribRTFormat &&
|
||||||
|
entrypoint == VAEntrypointVLD ) {
|
||||||
|
FREE(config);
|
||||||
|
return VA_STATUS_ERROR_INVALID_VALUE;
|
||||||
|
}
|
||||||
if (attrib_list[i].type == VAConfigAttribRateControl) {
|
if (attrib_list[i].type == VAConfigAttribRateControl) {
|
||||||
if (attrib_list[i].value == VA_RC_CBR)
|
if (attrib_list[i].value == VA_RC_CBR)
|
||||||
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT;
|
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT;
|
||||||
else if (attrib_list[i].value == VA_RC_VBR)
|
else if (attrib_list[i].value == VA_RC_VBR)
|
||||||
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE;
|
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE;
|
||||||
else
|
else if (attrib_list[i].value == VA_RC_CQP)
|
||||||
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE;
|
config->rc = PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE;
|
||||||
|
else {
|
||||||
|
FREE(config);
|
||||||
|
return VA_STATUS_ERROR_INVALID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (attrib_list[i].type == VAConfigAttribRTFormat) {
|
if (attrib_list[i].type == VAConfigAttribRTFormat) {
|
||||||
if (attrib_list[i].value & supported_rt_formats) {
|
if (attrib_list[i].value & supported_rt_formats) {
|
||||||
|
|
@ -297,6 +318,12 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (attrib_list[i].type == VAConfigAttribEncPackedHeaders) {
|
||||||
|
if (attrib_list[i].value != 0) {
|
||||||
|
FREE(config);
|
||||||
|
return VA_STATUS_ERROR_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default value if not specified in the input attributes. */
|
/* Default value if not specified in the input attributes. */
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
|
||||||
vlVaContext *context;
|
vlVaContext *context;
|
||||||
vlVaConfig *config;
|
vlVaConfig *config;
|
||||||
int is_vpp;
|
int is_vpp;
|
||||||
|
int max_supported_width,max_supported_height;
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
|
|
@ -226,6 +227,9 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
|
||||||
config = handle_table_get(drv->htab, config_id);
|
config = handle_table_get(drv->htab, config_id);
|
||||||
mtx_unlock(&drv->mutex);
|
mtx_unlock(&drv->mutex);
|
||||||
|
|
||||||
|
if (!config)
|
||||||
|
return VA_STATUS_ERROR_INVALID_CONFIG;
|
||||||
|
|
||||||
is_vpp = config->profile == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width &&
|
is_vpp = config->profile == PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width &&
|
||||||
!picture_height && !flag && !render_targets && !num_render_targets;
|
!picture_height && !flag && !render_targets && !num_render_targets;
|
||||||
|
|
||||||
|
|
@ -239,6 +243,17 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
|
||||||
if (is_vpp) {
|
if (is_vpp) {
|
||||||
context->decoder = NULL;
|
context->decoder = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
if (config->entrypoint != PIPE_VIDEO_ENTRYPOINT_UNKNOWN) {
|
||||||
|
max_supported_width = drv->vscreen->pscreen->get_video_param(drv->vscreen->pscreen,
|
||||||
|
config->profile, config->entrypoint,
|
||||||
|
PIPE_VIDEO_CAP_MAX_WIDTH);
|
||||||
|
max_supported_height = drv->vscreen->pscreen->get_video_param(drv->vscreen->pscreen,
|
||||||
|
config->profile, config->entrypoint,
|
||||||
|
PIPE_VIDEO_CAP_MAX_HEIGHT);
|
||||||
|
|
||||||
|
if (picture_width > max_supported_width || picture_height > max_supported_height)
|
||||||
|
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
context->templat.profile = config->profile;
|
context->templat.profile = config->profile;
|
||||||
context->templat.entrypoint = config->entrypoint;
|
context->templat.entrypoint = config->entrypoint;
|
||||||
context->templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
|
context->templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue