summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2021-09-02 18:38:58 +0800
committerTimo Rothenpieler <timo@rothenpieler.org>2021-09-06 14:25:26 +0200
commit75001ae8440d819d23443709091fca4c39e395a1 (patch)
tree4c21f37c98190d5c31e25a5f0b4a7d6717f6101f /libavcodec/nvenc.c
parent3756525a59cc63db431fc301ea3748958964af16 (diff)
downloadffmpeg-75001ae8440d819d23443709091fca4c39e395a1.tar.gz
avcodec/nvenc: add constrainedFrame encoding support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ff7c9d6542..ae25afd7f8 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -548,6 +548,19 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
+#ifndef NVENC_HAVE_HEVC_CONSTRAINED_ENCODING
+ if (ctx->constrained_encoding && avctx->codec->id == AV_CODEC_ID_HEVC) {
+ av_log(avctx, AV_LOG_WARNING, "HEVC constrained encoding needs SDK 10.0 at build time\n");
+ return AVERROR(ENOSYS);
+ }
+#endif
+
+ 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;
@@ -1104,6 +1117,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;
@@ -1213,6 +1229,11 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
#endif
}
+#ifdef NVENC_HAVE_HEVC_CONSTRAINED_ENCODING
+ if (ctx->constrained_encoding)
+ hevc->enableConstrainedEncoding = 1;
+#endif
+
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;