summaryrefslogtreecommitdiff
path: root/libavcodec/vaapi_encode_h265.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_h265.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_h265.c')
-rw-r--r--libavcodec/vaapi_encode_h265.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 8f191efc4b..9fa16593d0 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -1025,7 +1025,17 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
return 0;
}
+static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
+ { FF_PROFILE_HEVC_MAIN, 8, 3, 1, 1, VAProfileHEVCMain },
+#if VA_CHECK_VERSION(0, 37, 0)
+ { FF_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10 },
+#endif
+ { FF_PROFILE_UNKNOWN }
+};
+
static const VAAPIEncodeType vaapi_encode_type_h265 = {
+ .profiles = vaapi_encode_h265_profiles,
+
.configure = &vaapi_encode_h265_configure,
.sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),
@@ -1058,29 +1068,6 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
if (avctx->level == FF_LEVEL_UNKNOWN)
avctx->level = priv->level;
- switch (avctx->profile) {
- case FF_PROFILE_HEVC_MAIN:
- case FF_PROFILE_UNKNOWN:
- ctx->va_profile = VAProfileHEVCMain;
- ctx->va_rt_format = VA_RT_FORMAT_YUV420;
- break;
- case FF_PROFILE_HEVC_MAIN_10:
-#ifdef VA_RT_FORMAT_YUV420_10BPP
- ctx->va_profile = VAProfileHEVCMain10;
- ctx->va_rt_format = VA_RT_FORMAT_YUV420_10BPP;
- break;
-#else
- av_log(avctx, AV_LOG_ERROR, "10-bit encoding is not "
- "supported with this VAAPI version.\n");
- return AVERROR(ENOSYS);
-#endif
- default:
- av_log(avctx, AV_LOG_ERROR, "Unknown H.265 profile %d.\n",
- avctx->profile);
- return AVERROR(EINVAL);
- }
- ctx->va_entrypoint = VAEntrypointEncSlice;
-
if (avctx->bit_rate > 0) {
if (avctx->rc_max_rate == avctx->bit_rate)
ctx->va_rc_mode = VA_RC_CBR;
@@ -1120,7 +1107,7 @@ static const AVOption vaapi_encode_h265_options[] = {
{ "profile", "Set profile (general_profile_idc)",
OFFSET(profile), AV_OPT_TYPE_INT,
- { .i64 = FF_PROFILE_HEVC_MAIN }, 0x00, 0xff, FLAGS, "profile" },
+ { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
{ .i64 = value }, 0, 0, FLAGS, "profile"