vaapi: Make the decode profile matching more explicit
Also fixes a bug where it could attempt to decode with an unsupported codec if allow-profile-mismatch was set.
This commit is contained in:
parent
4b57f06447
commit
e171022c24
@ -284,8 +284,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
|
|||||||
VAStatus vas;
|
VAStatus vas;
|
||||||
int err, i, j;
|
int err, i, j;
|
||||||
const AVCodecDescriptor *codec_desc;
|
const AVCodecDescriptor *codec_desc;
|
||||||
VAProfile profile, *profile_list = NULL;
|
VAProfile *profile_list = NULL, matched_va_profile;
|
||||||
int profile_count, exact_match, alt_profile;
|
int profile_count, exact_match, matched_ff_profile;
|
||||||
const AVPixFmtDescriptor *sw_desc, *desc;
|
const AVPixFmtDescriptor *sw_desc, *desc;
|
||||||
|
|
||||||
AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data;
|
AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data;
|
||||||
@ -314,7 +314,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile = VAProfileNone;
|
matched_va_profile = VAProfileNone;
|
||||||
exact_match = 0;
|
exact_match = 0;
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
|
for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
|
||||||
@ -324,22 +324,22 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
|
|||||||
if (avctx->profile == vaapi_profile_map[i].codec_profile ||
|
if (avctx->profile == vaapi_profile_map[i].codec_profile ||
|
||||||
vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
|
vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
|
||||||
profile_match = 1;
|
profile_match = 1;
|
||||||
profile = vaapi_profile_map[i].va_profile;
|
|
||||||
for (j = 0; j < profile_count; j++) {
|
for (j = 0; j < profile_count; j++) {
|
||||||
if (profile == profile_list[j]) {
|
if (vaapi_profile_map[i].va_profile == profile_list[j]) {
|
||||||
exact_match = profile_match;
|
exact_match = profile_match;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j < profile_count) {
|
if (j < profile_count) {
|
||||||
|
matched_va_profile = vaapi_profile_map[i].va_profile;
|
||||||
|
matched_ff_profile = vaapi_profile_map[i].codec_profile;
|
||||||
if (exact_match)
|
if (exact_match)
|
||||||
break;
|
break;
|
||||||
alt_profile = vaapi_profile_map[i].codec_profile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_freep(&profile_list);
|
av_freep(&profile_list);
|
||||||
|
|
||||||
if (profile == VAProfileNone) {
|
if (matched_va_profile == VAProfileNone) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "No support for codec %s "
|
av_log(avctx, AV_LOG_ERROR, "No support for codec %s "
|
||||||
"profile %d.\n", codec_desc->name, avctx->profile);
|
"profile %d.\n", codec_desc->name, avctx->profile);
|
||||||
err = AVERROR(ENOSYS);
|
err = AVERROR(ENOSYS);
|
||||||
@ -353,7 +353,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
|
|||||||
codec_desc->name, avctx->profile);
|
codec_desc->name, avctx->profile);
|
||||||
av_log(avctx, AV_LOG_WARNING, "Using possibly-"
|
av_log(avctx, AV_LOG_WARNING, "Using possibly-"
|
||||||
"incompatible profile %d instead.\n",
|
"incompatible profile %d instead.\n",
|
||||||
alt_profile);
|
matched_ff_profile);
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not "
|
av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not "
|
||||||
"supported for hardware decode.\n",
|
"supported for hardware decode.\n",
|
||||||
@ -363,7 +363,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vas = vaCreateConfig(hwctx->display, profile,
|
vas = vaCreateConfig(hwctx->display, matched_va_profile,
|
||||||
VAEntrypointVLD, NULL, 0,
|
VAEntrypointVLD, NULL, 0,
|
||||||
va_config);
|
va_config);
|
||||||
if (vas != VA_STATUS_SUCCESS) {
|
if (vas != VA_STATUS_SUCCESS) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user