ffmpeg | branch: master | Timo Rothenpieler <t...@rothenpieler.org> | Wed Aug 
30 21:06:25 2017 +0200| [a0b69e2b0a7ba994b722393a0273bb3464fd5efe] | committer: 
Timo Rothenpieler

avcodec/nvenc: add support for specifying entropy coding mode

Signed-off-by: Timo Rothenpieler <t...@rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0b69e2b0a7ba994b722393a0273bb3464fd5efe
---

 libavcodec/nvenc.c      | 9 +++++++++
 libavcodec/nvenc.h      | 1 +
 libavcodec/nvenc_h264.c | 7 +++++++
 libavcodec/version.h    | 2 +-
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index f79b9a502e..422ac6c73e 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -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;
 }
 
@@ -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;
 }
 
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 2e24604cea..2c682275da 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -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);
diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
index 5fcbcb9f4f..9adbe9f909 100644
--- a/libavcodec/nvenc_h264.c
+++ b/libavcodec/nvenc_h264.c
@@ -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 }
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 22cab7b0dd..29cdb85589 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -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, \

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to