summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-11-29 21:31:53 +0000
committerMark Thompson <sw@jkqxz.net>2017-12-06 22:33:53 +0000
commit3ff8fbbf5a7bc40c09db74d4952364997fd3c611 (patch)
tree375423db4c9b7dd41db3504cb397075fade2da73 /libavcodec
parent6679654efe15af7156a94e9abc754098dfccd10e (diff)
vaapi_h265: Add named options for setting profile and level
Also fixes the default, which previously contained a nonsense value.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vaapi_encode_h265.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 0e5958d531..8fa277bf94 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -63,6 +63,8 @@ typedef struct VAAPIEncodeH265Context {
typedef struct VAAPIEncodeH265Options {
int qp;
int aud;
+ int profile;
+ int level;
} VAAPIEncodeH265Options;
@@ -880,10 +882,17 @@ static const VAAPIEncodeType vaapi_encode_type_h265 = {
static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
{
- VAAPIEncodeContext *ctx = avctx->priv_data;
+ VAAPIEncodeContext *ctx = avctx->priv_data;
+ VAAPIEncodeH265Options *opt =
+ (VAAPIEncodeH265Options*)ctx->codec_options_data;
ctx->codec = &vaapi_encode_type_h265;
+ if (avctx->profile == FF_PROFILE_UNKNOWN)
+ avctx->profile = opt->profile;
+ if (avctx->level == FF_LEVEL_UNKNOWN)
+ avctx->level = opt->level;
+
switch (avctx->profile) {
case FF_PROFILE_HEVC_MAIN:
case FF_PROFILE_UNKNOWN:
@@ -946,12 +955,41 @@ static const AVOption vaapi_encode_h265_options[] = {
{ "aud", "Include AUD",
OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+ { "profile", "Set profile (general_profile_idc)",
+ OFFSET(profile), AV_OPT_TYPE_INT,
+ { .i64 = FF_PROFILE_HEVC_MAIN }, 0x00, 0xff, FLAGS, "profile" },
+
+#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
+ { .i64 = value }, 0, 0, FLAGS, "profile"
+ { PROFILE("main", FF_PROFILE_HEVC_MAIN) },
+ { PROFILE("main10", FF_PROFILE_HEVC_MAIN_10) },
+#undef PROFILE
+
+ { "level", "Set level (general_level_idc)",
+ OFFSET(level), AV_OPT_TYPE_INT,
+ { .i64 = 153 }, 0x00, 0xff, FLAGS, "level" },
+
+#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
+ { .i64 = value }, 0, 0, FLAGS, "level"
+ { LEVEL("1", 30) },
+ { LEVEL("2", 60) },
+ { LEVEL("2.1", 63) },
+ { LEVEL("3", 90) },
+ { LEVEL("3.1", 93) },
+ { LEVEL("4", 120) },
+ { LEVEL("4.1", 123) },
+ { LEVEL("5", 150) },
+ { LEVEL("5.1", 153) },
+ { LEVEL("5.2", 156) },
+ { LEVEL("6", 180) },
+ { LEVEL("6.1", 183) },
+ { LEVEL("6.2", 186) },
+#undef LEVEL
+
{ NULL },
};
static const AVCodecDefault vaapi_encode_h265_defaults[] = {
- { "profile", "1" },
- { "level", "51" },
{ "b", "0" },
{ "bf", "2" },
{ "g", "120" },