summaryrefslogtreecommitdiff
path: root/libavcodec/vaapi_decode.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-11-09 01:04:44 +0000
committerMark Thompson <sw@jkqxz.net>2017-11-26 21:41:19 +0000
commitefd0612fdcb7490ed371899f532d73ef8bb7cba0 (patch)
treee55927d6712fa8ddf819c94f150e7196e7683e80 /libavcodec/vaapi_decode.c
parentb0cd14fb1dab4b044f7fe6b53ac635409849de77 (diff)
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.
Diffstat (limited to 'libavcodec/vaapi_decode.c')
-rw-r--r--libavcodec/vaapi_decode.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d467bed874..d36ef906a2 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -287,8 +287,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
VAStatus vas;
int err, i, j;
const AVCodecDescriptor *codec_desc;
- VAProfile profile, va_profile, *profile_list = NULL;
- int profile_count, exact_match, alt_profile;
+ VAProfile *profile_list = NULL, matched_va_profile;
+ int profile_count, exact_match, matched_ff_profile;
const AVPixFmtDescriptor *sw_desc, *desc;
AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data;
@@ -317,7 +317,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
goto fail;
}
- profile = VAProfileNone;
+ matched_va_profile = VAProfileNone;
exact_match = 0;
for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
@@ -326,23 +326,22 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
continue;
if (avctx->profile == vaapi_profile_map[i].codec_profile)
profile_match = 1;
- profile = vaapi_profile_map[i].va_profile;
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;
break;
}
}
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)
break;
- alt_profile = vaapi_profile_map[i].codec_profile;
- va_profile = vaapi_profile_map[i].va_profile;
}
}
av_freep(&profile_list);
- if (profile == VAProfileNone) {
+ if (matched_va_profile == VAProfileNone) {
av_log(avctx, AV_LOG_ERROR, "No support for codec %s "
"profile %d.\n", codec_desc->name, avctx->profile);
err = AVERROR(ENOSYS);
@@ -356,8 +355,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
codec_desc->name, avctx->profile);
av_log(avctx, AV_LOG_WARNING, "Using possibly-"
"incompatible profile %d instead.\n",
- alt_profile);
- profile = va_profile;
+ matched_ff_profile);
} else {
av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not "
"supported for hardware decode.\n",
@@ -367,7 +365,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
}
}
- vas = vaCreateConfig(hwctx->display, profile,
+ vas = vaCreateConfig(hwctx->display, matched_va_profile,
VAEntrypointVLD, NULL, 0,
va_config);
if (vas != VA_STATUS_SUCCESS) {