From: Limin Wang <lance.lmw...@gmail.com> Signed-off-by: Limin Wang <lance.lmw...@gmail.com> --- libavcodec/nvenc.c | 12 ++++++++++++ libavcodec/nvenc.h | 1 + libavcodec/nvenc_h264.c | 2 ++ libavcodec/nvenc_hevc.c | 2 ++ libavcodec/version.h | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 79f3253..5eeb4fe 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -552,6 +552,12 @@ static int nvenc_check_capabilities(AVCodecContext *avctx) return AVERROR(ENOSYS); } + ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING); + if(ctx->constrained_encoding && ret <= 0) { + av_log(avctx, AV_LOG_WARNING, "constrained encoding not supported by the device\n"); + return AVERROR(ENOSYS); + } + ctx->support_dyn_bitrate = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE); return 0; @@ -1108,6 +1114,9 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) #endif } + if (ctx->constrained_encoding) + h264->enableConstrainedEncoding = 1; + h264->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; h264->repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; h264->outputAUD = ctx->aud; @@ -1214,6 +1223,9 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) #endif } + if (ctx->constrained_encoding) + hevc->enableConstrainedEncoding = 1; + hevc->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; hevc->repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; hevc->outputAUD = ctx->aud; diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 1e756a6..950c2ab 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -233,6 +233,7 @@ typedef struct NvencContext int extra_sei; int intra_refresh; int single_slice_intra_refresh; + int constrained_encoding; } NvencContext; int ff_nvenc_encode_init(AVCodecContext *avctx); diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 1a46e70..ab7c67f 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -192,6 +192,8 @@ static const AVOption options[] = { OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "single_slice_intra_refresh", "Use single slice intra refresh.", OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "constrained_encoding", "enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.", + OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } }; diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 8c89d6e..180e7a3 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -173,6 +173,8 @@ static const AVOption options[] = { OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "single_slice_intra_refresh", "Use single slice intra refresh.", OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "constrained_encoding", "enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.", + OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } }; diff --git a/libavcodec/version.h b/libavcodec/version.h index d39329b..10f998e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 59 #define LIBAVCODEC_VERSION_MINOR 6 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 1.8.3.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".