Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avcodec/nvenc: add support for specifying entropy coding mode
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
  • Loading branch information
BtbN committed Sep 1, 2017
1 parent 78a7af8 commit a0b69e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libavcodec/nvenc.c
Expand Up @@ -317,6 +317,12 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}

ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_CABAC);
if (ctx->coder == NV_ENC_H264_ENTROPY_CODING_MODE_CABAC && ret <= 0) {
av_log(avctx, AV_LOG_VERBOSE, "CABAC entropy coding not supported\n");
return AVERROR(ENOSYS);
}

return 0;
}

Expand Down Expand Up @@ -916,6 +922,9 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)

h264->level = ctx->level;

if (ctx->coder >= 0)
h264->entropyCodingMode = ctx->coder;

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions libavcodec/nvenc.h
Expand Up @@ -162,6 +162,7 @@ typedef struct NvencContext
int init_qp_i;
int cqp;
int weighted_pred;
int coder;
} NvencContext;

int ff_nvenc_encode_init(AVCodecContext *avctx);
Expand Down
7 changes: 7 additions & 0 deletions libavcodec/nvenc_h264.c
Expand Up @@ -119,6 +119,13 @@ static const AVOption options[] = {
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "weighted_pred","Set 1 to enable weighted prediction",
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 },-1, 2, VE, "coder" },
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "coder" },
{ "auto", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT }, 0, 0, VE, "coder" },
{ "cabac", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CABAC }, 0, 0, VE, "coder" },
{ "cavlc", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC }, 0, 0, VE, "coder" },
{ "ac", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CABAC }, 0, 0, VE, "coder" },
{ "vlc", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC }, 0, 0, VE, "coder" },
{ NULL }
};

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/version.h
Expand Up @@ -29,7 +29,7 @@

#define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 104
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101

#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
Expand Down

1 comment on commit a0b69e2

@TimothyGu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an update to the docs, right?

Please sign in to comment.