diff options
author | Andrey Turkin <andrey.turkin@gmail.com> | 2016-05-25 17:26:25 +0300 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2016-05-31 15:48:43 +0200 |
commit | 9824321b321448854102070383aa99fa8e56f491 (patch) | |
tree | d14651e51146a1b878bfeb49cbf01c71e39e2594 /libavcodec | |
parent | faffff88c21c24765e5a3c87ffc657b191c4efc0 (diff) | |
download | ffmpeg-9824321b321448854102070383aa99fa8e56f491.tar.gz |
avcodec/nvenc: convert profile parsing to AVOptions
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/nvenc.c | 43 | ||||
-rw-r--r-- | libavcodec/nvenc.h | 9 | ||||
-rw-r--r-- | libavcodec/nvenc_h264.c | 6 | ||||
-rw-r--r-- | libavcodec/nvenc_hevc.c | 3 |
4 files changed, 27 insertions, 34 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 7166b9dfc2..d984b58354 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -603,9 +603,6 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; if (ctx->flags & NVENC_LOSSLESS) { - if (avctx->codec->id == AV_CODEC_ID_H264) - ctx->encode_config.encodeCodecConfig.h264Config.qpPrimeYZeroTransformBypassFlag = 1; - set_lossless(avctx); avctx->qmin = -1; @@ -710,42 +707,26 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) h264->outputAUD = 1; - if (!ctx->profile && !(ctx->flags & NVENC_LOSSLESS)) { - switch (avctx->profile) { - case FF_PROFILE_H264_HIGH_444_PREDICTIVE: - cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID; - break; - case FF_PROFILE_H264_BASELINE: + if (ctx->flags & NVENC_LOSSLESS) { + h264->qpPrimeYZeroTransformBypassFlag = 1; + } else { + switch(ctx->profile) { + case NV_ENC_H264_PROFILE_BASELINE: cc->profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; + avctx->profile = FF_PROFILE_H264_BASELINE; break; - case FF_PROFILE_H264_MAIN: + case NV_ENC_H264_PROFILE_MAIN: cc->profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; + avctx->profile = FF_PROFILE_H264_MAIN; break; - case FF_PROFILE_H264_HIGH: - case FF_PROFILE_UNKNOWN: - cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; - break; - default: - av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n"); - cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; - break; - } - } else if (!(ctx->flags & NVENC_LOSSLESS)) { - if (!strcmp(ctx->profile, "high")) { + case NV_ENC_H264_PROFILE_HIGH: cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; avctx->profile = FF_PROFILE_H264_HIGH; - } else if (!strcmp(ctx->profile, "main")) { - cc->profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; - avctx->profile = FF_PROFILE_H264_MAIN; - } else if (!strcmp(ctx->profile, "baseline")) { - cc->profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; - avctx->profile = FF_PROFILE_H264_BASELINE; - } else if (!strcmp(ctx->profile, "high444p")) { + break; + case NV_ENC_H264_PROFILE_HIGH_444P: cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID; avctx->profile = FF_PROFILE_H264_HIGH_444_PREDICTIVE; - } else { - av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); - return AVERROR(EINVAL); + break; } } diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 5b81fc8667..b5a0a2abf0 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -120,6 +120,13 @@ enum { }; enum { + NV_ENC_H264_PROFILE_BASELINE, + NV_ENC_H264_PROFILE_MAIN, + NV_ENC_H264_PROFILE_HIGH, + NV_ENC_H264_PROFILE_HIGH_444P, +}; + +enum { NVENC_LOWLATENCY = 1, NVENC_LOSSLESS = 2, NVENC_ONE_PASS = 4, @@ -160,7 +167,7 @@ typedef struct NvencContext void *nvencoder; int preset; - char *profile; + int profile; char *level; char *tier; int cbr; diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 0ed3f7cced..4e294781b8 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -39,7 +39,11 @@ static const AVOption options[] = { { "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" }, { "lossless", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_DEFAULT }, 0, 0, VE, "preset" }, { "losslesshp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_HP }, 0, 0, VE, "preset" }, - { "profile", "Set the encoding profile (high, main, baseline or high444p)", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = "main" }, 0, 0, VE }, + { "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = NV_ENC_H264_PROFILE_MAIN }, NV_ENC_H264_PROFILE_BASELINE, NV_ENC_H264_PROFILE_HIGH_444P, VE, "profile" }, + { "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_BASELINE }, 0, 0, VE, "profile" }, + { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_MAIN }, 0, 0, VE, "profile" }, + { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH }, 0, 0, VE, "profile" }, + { "high444p", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH_444P }, 0, 0, VE, "profile" }, { "level", "Set the encoding level restriction (auto, 1.0, 1.0b, 1.1, 1.2, ..., 4.2, 5.0, 5.1)", OFFSET(level), AV_OPT_TYPE_STRING, { .str = "auto" }, 0, 0, VE }, { "cbr", "Use cbr encoding mode", OFFSET(cbr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "2pass", "Use 2pass encoding mode", OFFSET(twopass), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE }, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 28e28b38e2..990d730932 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -39,7 +39,8 @@ static const AVOption options[] = { { "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" }, { "lossless", "lossless", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_DEFAULT }, 0, 0, VE, "preset" }, { "losslesshp", "lossless hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_HP }, 0, 0, VE, "preset" }, - { "profile", "Set the encoding profile (high, main, baseline or high444p)", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = "main" }, 0, 0, VE }, + { "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_HEVC_MAIN }, FF_PROFILE_HEVC_MAIN, FF_PROFILE_HEVC_MAIN, VE, "profile" }, + { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_HEVC_MAIN }, 0, 0, VE, "profile" }, { "level", "Set the encoding level restriction (auto, 1.0, 1.0b, 1.1, 1.2, ..., 4.2, 5.0, 5.1)", OFFSET(level), AV_OPT_TYPE_STRING, { .str = "auto" }, 0, 0, VE }, { "tier", "Set the encoding tier (main or high)", OFFSET(tier), AV_OPT_TYPE_STRING, { .str = "main" }, 0, 0, VE }, { "cbr", "Use cbr encoding mode", OFFSET(cbr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, |