aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorAndrey Turkin <andrey.turkin@gmail.com>2016-05-25 18:00:52 +0300
committerTimo Rothenpieler <timo@rothenpieler.org>2016-05-31 15:48:43 +0200
commitb0172873a89d66976e7ca12e2cd8842afd9a27f5 (patch)
tree0c617f448104448783942a058fb828dc8b4204d5 /libavcodec/nvenc.c
parent9824321b321448854102070383aa99fa8e56f491 (diff)
downloadffmpeg-b0172873a89d66976e7ca12e2cd8842afd9a27f5.tar.gz
avcodec/nvenc: convert levels to AVOptions
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c93
1 files changed, 2 insertions, 91 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index d984b58354..a078043110 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -66,63 +66,6 @@ typedef struct NvencData
} u;
} NvencData;
-typedef struct NvencValuePair
-{
- const char *str;
- uint32_t num;
-} NvencValuePair;
-
-static const NvencValuePair nvenc_h264_level_pairs[] = {
- { "auto", NV_ENC_LEVEL_AUTOSELECT },
- { "1" , NV_ENC_LEVEL_H264_1 },
- { "1.0" , NV_ENC_LEVEL_H264_1 },
- { "1b" , NV_ENC_LEVEL_H264_1b },
- { "1.0b", NV_ENC_LEVEL_H264_1b },
- { "1.1" , NV_ENC_LEVEL_H264_11 },
- { "1.2" , NV_ENC_LEVEL_H264_12 },
- { "1.3" , NV_ENC_LEVEL_H264_13 },
- { "2" , NV_ENC_LEVEL_H264_2 },
- { "2.0" , NV_ENC_LEVEL_H264_2 },
- { "2.1" , NV_ENC_LEVEL_H264_21 },
- { "2.2" , NV_ENC_LEVEL_H264_22 },
- { "3" , NV_ENC_LEVEL_H264_3 },
- { "3.0" , NV_ENC_LEVEL_H264_3 },
- { "3.1" , NV_ENC_LEVEL_H264_31 },
- { "3.2" , NV_ENC_LEVEL_H264_32 },
- { "4" , NV_ENC_LEVEL_H264_4 },
- { "4.0" , NV_ENC_LEVEL_H264_4 },
- { "4.1" , NV_ENC_LEVEL_H264_41 },
- { "4.2" , NV_ENC_LEVEL_H264_42 },
- { "5" , NV_ENC_LEVEL_H264_5 },
- { "5.0" , NV_ENC_LEVEL_H264_5 },
- { "5.1" , NV_ENC_LEVEL_H264_51 },
- { NULL }
-};
-
-static const NvencValuePair nvenc_hevc_level_pairs[] = {
- { "auto", NV_ENC_LEVEL_AUTOSELECT },
- { "1" , NV_ENC_LEVEL_HEVC_1 },
- { "1.0" , NV_ENC_LEVEL_HEVC_1 },
- { "2" , NV_ENC_LEVEL_HEVC_2 },
- { "2.0" , NV_ENC_LEVEL_HEVC_2 },
- { "2.1" , NV_ENC_LEVEL_HEVC_21 },
- { "3" , NV_ENC_LEVEL_HEVC_3 },
- { "3.0" , NV_ENC_LEVEL_HEVC_3 },
- { "3.1" , NV_ENC_LEVEL_HEVC_31 },
- { "4" , NV_ENC_LEVEL_HEVC_4 },
- { "4.0" , NV_ENC_LEVEL_HEVC_4 },
- { "4.1" , NV_ENC_LEVEL_HEVC_41 },
- { "5" , NV_ENC_LEVEL_HEVC_5 },
- { "5.0" , NV_ENC_LEVEL_HEVC_5 },
- { "5.1" , NV_ENC_LEVEL_HEVC_51 },
- { "5.2" , NV_ENC_LEVEL_HEVC_52 },
- { "6" , NV_ENC_LEVEL_HEVC_6 },
- { "6.0" , NV_ENC_LEVEL_HEVC_6 },
- { "6.1" , NV_ENC_LEVEL_HEVC_61 },
- { "6.2" , NV_ENC_LEVEL_HEVC_62 },
- { NULL }
-};
-
static const struct {
NVENCSTATUS nverr;
int averr;
@@ -181,18 +124,6 @@ static int nvenc_print_error(void *log_ctx, NVENCSTATUS err,
return ret;
}
-static int input_string_to_uint32(AVCodecContext *avctx, const NvencValuePair *pair, const char *input, uint32_t *output)
-{
- for (; pair->str; ++pair) {
- if (!strcmp(input, pair->str)) {
- *output = pair->num;
- return 0;
- }
- }
-
- return AVERROR(EINVAL);
-}
-
static void timestamp_queue_enqueue(AVFifoBuffer* queue, int64_t timestamp)
{
av_fifo_generic_write(queue, &timestamp, sizeof(timestamp), NULL);
@@ -683,7 +614,6 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
NV_ENC_CONFIG *cc = &ctx->encode_config;
NV_ENC_CONFIG_H264 *h264 = &cc->encodeCodecConfig.h264Config;
NV_ENC_CONFIG_H264_VUI_PARAMETERS *vui = &h264->h264VUIParameters;
- int res;
vui->colourMatrix = avctx->colorspace;
vui->colourPrimaries = avctx->color_primaries;
@@ -738,16 +668,7 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
h264->chromaFormatIDC = avctx->profile == FF_PROFILE_H264_HIGH_444_PREDICTIVE ? 3 : 1;
- if (ctx->level) {
- res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &h264->level);
-
- if (res) {
- av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level);
- return res;
- }
- } else {
- h264->level = NV_ENC_LEVEL_AUTOSELECT;
- }
+ h264->level = ctx->level;
return 0;
}
@@ -758,7 +679,6 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
NV_ENC_CONFIG *cc = &ctx->encode_config;
NV_ENC_CONFIG_HEVC *hevc = &cc->encodeCodecConfig.hevcConfig;
NV_ENC_CONFIG_HEVC_VUI_PARAMETERS *vui = &hevc->hevcVUIParameters;
- int res;
vui->colourMatrix = avctx->colorspace;
vui->colourPrimaries = avctx->color_primaries;
@@ -786,16 +706,7 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
avctx->profile = FF_PROFILE_HEVC_MAIN;
- if (ctx->level) {
- res = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &hevc->level);
-
- if (res) {
- av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level);
- return res;
- }
- } else {
- hevc->level = NV_ENC_LEVEL_AUTOSELECT;
- }
+ hevc->level = ctx->level;
if (ctx->tier) {
if (!strcmp(ctx->tier, "main")) {