aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-11-29 21:31:53 +0000
committerMark Thompson <sw@jkqxz.net>2017-12-04 23:25:37 +0000
commit71421f382f5c53b1a109489a906a80c1b7e3eed7 (patch)
tree2e24176a1f06ac73d541494d8996f400f4affc0b
parentc490fc9536dcea7fdf1245a340bf075533610bc2 (diff)
downloadffmpeg-71421f382f5c53b1a109489a906a80c1b7e3eed7.tar.gz
vaapi_h265: Add named options for setting profile and level
Also fixes the default, which previously contained a nonsense value.
-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 3ae92a7a09..8e98b0230d 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" },