summaryrefslogtreecommitdiff
path: root/libavcodec/vaapi_encode_vp9.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2018-09-18 23:30:40 +0100
committerMark Thompson <sw@jkqxz.net>2018-09-23 14:42:33 +0100
commit3b188666f19a17d15efb7eae590e988832972666 (patch)
tree9442d49ab736e26b84bf4983cf3e781cdc076a32 /libavcodec/vaapi_encode_vp9.c
parenta00763be8861bcf499675b2af89d29e4e113cdc9 (diff)
vaapi_encode: Choose profiles dynamically
Previously there was one fixed choice for each codec (e.g. H.265 -> Main profile), and using anything else then required an explicit option from the user. This changes to selecting the profile based on the input format and the set of profiles actually supported by the driver (e.g. P010 input will choose Main 10 profile for H.265 if the driver supports it). The entrypoint and render target format are also chosen dynamically in the same way, removing those explicit selections from the per-codec code.
Diffstat (limited to 'libavcodec/vaapi_encode_vp9.c')
-rw-r--r--libavcodec/vaapi_encode_vp9.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c
index bf99597e4c..88c0ce3b0a 100644
--- a/libavcodec/vaapi_encode_vp9.c
+++ b/libavcodec/vaapi_encode_vp9.c
@@ -203,7 +203,15 @@ static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx)
return 0;
}
+static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = {
+ { FF_PROFILE_VP9_0, 8, 3, 1, 1, VAProfileVP9Profile0 },
+ { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 },
+ { FF_PROFILE_UNKNOWN }
+};
+
static const VAAPIEncodeType vaapi_encode_type_vp9 = {
+ .profiles = vaapi_encode_vp9_profiles,
+
.configure = &vaapi_encode_vp9_configure,
.sequence_params_size = sizeof(VAEncSequenceParameterBufferVP9),
@@ -219,31 +227,6 @@ static av_cold int vaapi_encode_vp9_init(AVCodecContext *avctx)
ctx->codec = &vaapi_encode_type_vp9;
- switch (avctx->profile) {
- case FF_PROFILE_VP9_0:
- case FF_PROFILE_UNKNOWN:
- ctx->va_profile = VAProfileVP9Profile0;
- ctx->va_rt_format = VA_RT_FORMAT_YUV420;
- break;
- case FF_PROFILE_VP9_1:
- av_log(avctx, AV_LOG_ERROR, "VP9 profile 1 is not "
- "supported.\n");
- return AVERROR_PATCHWELCOME;
- case FF_PROFILE_VP9_2:
- ctx->va_profile = VAProfileVP9Profile2;
- ctx->va_rt_format = VA_RT_FORMAT_YUV420_10BPP;
- break;
- case FF_PROFILE_VP9_3:
- av_log(avctx, AV_LOG_ERROR, "VP9 profile 3 is not "
- "supported.\n");
- return AVERROR_PATCHWELCOME;
- default:
- av_log(avctx, AV_LOG_ERROR, "Unknown VP9 profile %d.\n",
- avctx->profile);
- return AVERROR(EINVAL);
- }
- ctx->va_entrypoint = VAEntrypointEncSlice;
-
if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
ctx->va_rc_mode = VA_RC_CQP;
} else if (avctx->bit_rate > 0) {
@@ -276,7 +259,6 @@ static const AVOption vaapi_encode_vp9_options[] = {
};
static const AVCodecDefault vaapi_encode_vp9_defaults[] = {
- { "profile", "0" },
{ "b", "0" },
{ "bf", "0" },
{ "g", "250" },