[FFmpeg-devel] [PATCH] nvenc set slice number to 1 to improve encoding quality

Agatha Hu ahu at nvidia.com
Mon Dec 7 07:42:03 CET 2015


---
 libavcodec/nvenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 43b8e78..f0e5a19 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -762,6 +762,17 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
         }
     }
 
+    switch (avctx->codec->id) {
+    case AV_CODEC_ID_H264:
+        ctx->encode_config.encodeCodecConfig.h264Config.sliceMode = 3;
+        ctx->encode_config.encodeCodecConfig.h264Config.sliceModeData = 1;
+        break;
+    case AV_CODEC_ID_H265:
+        ctx->encode_config.encodeCodecConfig.hevcConfig.sliceMode = 3;
+        ctx->encode_config.encodeCodecConfig.hevcConfig.sliceModeData = 1;
+        break;
+    }
+
     /* when there're b frames, set dts offset */
     if (ctx->encode_config.frameIntervalP >= 2)
         ctx->last_dts = -2;
-- 
1.9.5.github.0



More information about the ffmpeg-devel mailing list