[FFmpeg-cvslog] avcodec: Add the extended pixel format profile for HEVC
ffmpeg | branch: master | Yogender Gupta | Sat Sep 17 15:28:27 2016 +0200| [de64dd13cbd47fd54334b6aa2a2cd3c7c36daae2] | committer: Luca Barbato avcodec: Add the extended pixel format profile for HEVC It is supported by the NVIDIA video SDK 7. Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de64dd13cbd47fd54334b6aa2a2cd3c7c36daae2 --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 1 + libavcodec/version.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index a4e418a..43e3262 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2016-xx-xx - xxx - lavc 59.27.0 - avcodec.h + Add FF_PROFILE_HEVC_REXT, the extended pixel format profile for HEVC. + 2016-08-24 - xxx - lavu 55.21.0 - imgutils.h Add av_image_copy_uc_from(), a version of av_image_copy() for copying from GPU mapped memory. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7a5f10f..607688c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2961,6 +2961,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_MAIN1 #define FF_PROFILE_HEVC_MAIN_10 2 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 +#define FF_PROFILE_HEVC_REXT4 /** * level diff --git a/libavcodec/version.h b/libavcodec/version.h index b132bf7..20edb61 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 26 +#define LIBAVCODEC_VERSION_MINOR 27 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] nvenc: Add some easier to understand presets that match x264 terminology
ffmpeg | branch: master | Yogender Gupta | Sat Sep 24 17:54:58 2016 +0200| [e02e2515b24bfc37ede6ca1744696230be55e50b] | committer: Luca Barbato nvenc: Add some easier to understand presets that match x264 terminology Signed-off-by: Luca Barbato Signed-off-by: Diego Biurrun Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e02e2515b24bfc37ede6ca1744696230be55e50b --- libavcodec/nvenc.c | 10 -- libavcodec/nvenc.h | 7 ++- libavcodec/nvenc_h264.c | 5 - libavcodec/nvenc_hevc.c | 5 - 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 6db5b0d..7f8737e 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -459,8 +459,10 @@ typedef struct GUIDTuple { int flags; } GUIDTuple; -#define PRESET(name, ...) \ -[PRESET_ ## name] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ } +#define PRESET_ALIAS(alias, name, ...) \ +[PRESET_ ## alias] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ } + +#define PRESET(name, ...) PRESET_ALIAS(name, name, __VA_ARGS__) static int nvec_map_preset(NVENCContext *ctx) { @@ -474,6 +476,9 @@ static int nvec_map_preset(NVENCContext *ctx) PRESET(LOW_LATENCY_HQ, NVENC_LOWLATENCY), PRESET(LOSSLESS_DEFAULT,NVENC_LOSSLESS), PRESET(LOSSLESS_HP, NVENC_LOSSLESS), +PRESET_ALIAS(SLOW, HQ, NVENC_TWO_PASSES), +PRESET_ALIAS(MEDIUM, HQ,NVENC_ONE_PASS), +PRESET_ALIAS(FAST, HP, NVENC_ONE_PASS), { { 0 } } }; @@ -486,6 +491,7 @@ static int nvec_map_preset(NVENCContext *ctx) } #undef PRESET +#undef PRESET_ALIAS static void set_constqp(AVCodecContext *avctx, NV_ENC_RC_PARAMS *rc) { diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index e7e6182..26c6515 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -91,6 +91,9 @@ typedef struct NVENCLibraryContext enum { PRESET_DEFAULT, +PRESET_SLOW, +PRESET_MEDIUM, +PRESET_FAST, PRESET_HP, PRESET_HQ, PRESET_BD , @@ -111,7 +114,9 @@ enum { enum { NVENC_LOWLATENCY = 1, -NVENC_LOSSLESS, +NVENC_LOSSLESS = 2, +NVENC_ONE_PASS = 4, +NVENC_TWO_PASSES = 8, }; enum { diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index ea91e07..d58ee88 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -27,8 +27,11 @@ #define OFFSET(x) offsetof(NVENCContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT,{ .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" }, +{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT,{ .i64 = PRESET_MEDIUM }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" }, { "default","", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" }, +{ "slow", "hq 2 passes",0, AV_OPT_TYPE_CONST, { .i64 = PRESET_SLOW }, 0, 0, VE, "preset" }, +{ "medium", "hq 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_MEDIUM }, 0, 0, VE, "preset" }, +{ "fast", "hp 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_FAST }, 0, 0, VE, "preset" }, { "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" }, { "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" }, { "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" }, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 6ff3506..f129826 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -27,8 +27,11 @@ #define OFFSET(x) offsetof(NVENCContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT,{ .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" }, +{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT,{ .i64 = PRESET_MEDIUM }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset"
[FFmpeg-cvslog] nvenc: Add support for high bitdepth
ffmpeg | branch: master | Yogender Gupta | Sat Sep 24 17:54:59 2016 +0200| [358c887a9fa0fb2e7ce089eaea71ab924a3e47a7] | committer: Luca Barbato nvenc: Add support for high bitdepth Signed-off-by: Luca Barbato Signed-off-by: Diego Biurrun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=358c887a9fa0fb2e7ce089eaea71ab924a3e47a7 --- libavcodec/nvenc.c | 87 +++-- libavcodec/nvenc.h | 6 libavcodec/nvenc_hevc.c | 8 +++-- 3 files changed, 96 insertions(+), 5 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 7f8737e..14651d4 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -89,12 +89,22 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, +#if NVENCAPI_MAJOR_VERSION >= 7 +AV_PIX_FMT_P010, +AV_PIX_FMT_YUV444P16, +#endif #if CONFIG_CUDA AV_PIX_FMT_CUDA, #endif AV_PIX_FMT_NONE }; +#define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010|| \ +pix_fmt == AV_PIX_FMT_YUV444P16) + +#define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \ +pix_fmt == AV_PIX_FMT_YUV444P16) + static const struct { NVENCSTATUS nverr; int averr; @@ -703,9 +713,47 @@ static int nvenc_setup_hevc_config(AVCodecContext *avctx) hevc->outputPictureTimingSEI = 1; } -/* No other profile is supported in the current SDK version 5 */ -cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; -avctx->profile = FF_PROFILE_HEVC_MAIN; +switch (ctx->profile) { +case NV_ENC_HEVC_PROFILE_MAIN: +cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; +avctx->profile = FF_PROFILE_HEVC_MAIN; +break; +#if NVENCAPI_MAJOR_VERSION >= 7 +case NV_ENC_HEVC_PROFILE_MAIN_10: +cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID; +avctx->profile = FF_PROFILE_HEVC_MAIN_10; +break; +case NV_ENC_HEVC_PROFILE_REXT: +cc->profileGUID = NV_ENC_HEVC_PROFILE_FREXT_GUID; +avctx->profile = FF_PROFILE_HEVC_REXT; +break; +#endif /* NVENCAPI_MAJOR_VERSION >= 7 */ +} + +// force setting profile for various input formats +switch (ctx->data_pix_fmt) { +case AV_PIX_FMT_YUV420P: +case AV_PIX_FMT_NV12: +cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; +avctx->profile = FF_PROFILE_HEVC_MAIN; +break; +#if NVENCAPI_MAJOR_VERSION >= 7 +case AV_PIX_FMT_P010: +cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID; +avctx->profile = FF_PROFILE_HEVC_MAIN_10; +break; +case AV_PIX_FMT_YUV444P: +case AV_PIX_FMT_YUV444P16: +cc->profileGUID = NV_ENC_HEVC_PROFILE_FREXT_GUID; +avctx->profile = FF_PROFILE_HEVC_REXT; +break; +#endif /* NVENCAPI_MAJOR_VERSION >= 7 */ +} + +#if NVENCAPI_MAJOR_VERSION >= 7 +hevc->chromaFormatIDC = IS_YUV444(ctx->data_pix_fmt) ? 3 : 1; +hevc->pixelBitDepthMinus8 = IS_10BIT(ctx->data_pix_fmt) ? 2 : 0; +#endif /* NVENCAPI_MAJOR_VERSION >= 7 */ hevc->sliceMode = 3; hevc->sliceModeData = FFMAX(avctx->slices, 1); @@ -858,6 +906,14 @@ static int nvenc_alloc_surface(AVCodecContext *avctx, int idx) case AV_PIX_FMT_YUV444P: ctx->frames[idx].format = NV_ENC_BUFFER_FORMAT_YUV444_PL; break; +#if NVENCAPI_MAJOR_VERSION >= 7 +case AV_PIX_FMT_P010: +ctx->frames[idx].format = NV_ENC_BUFFER_FORMAT_YUV420_10BIT; +break; +case AV_PIX_FMT_YUV444P16: +ctx->frames[idx].format = NV_ENC_BUFFER_FORMAT_YUV444_10BIT; +break; +#endif /* NVENCAPI_MAJOR_VERSION >= 7 */ default: return AVERROR_BUG; } @@ -1096,6 +1152,16 @@ static int nvenc_copy_frame(NV_ENC_LOCK_INPUT_BUFFER *in, const AVFrame *frame) frame->data[1], frame->linesize[1], frame->width, frame->height >> 1); break; +case AV_PIX_FMT_P010: +av_image_copy_plane(buf, in->pitch, +frame->data[0], frame->linesize[0], +frame->width << 1, frame->height); +buf += off; + +av_image_copy_plane(buf, in->pitch, +frame->data[1], frame->linesize[1], +frame->width << 1, frame->height >> 1); +break; case AV_PIX_FMT_YUV444P: av_image_copy_plane(buf, in->pitch, frame->data[0], frame->linesize[0], @@ -,6 +1177,21 @@ static int nvenc_copy_frame(NV_ENC_LOCK_INPUT_BUFFER *in, const AVFrame *frame) frame->data[2], frame->linesize[2],
[FFmpeg-cvslog] nvenc: Extended rate-control support as provided by SDK 7
ffmpeg | branch: master | Yogender Gupta | Sat Sep 24 17:55:00 2016 +0200| [70de2ea4261f860457a04e3d0c58c5543f403325] | committer: Luca Barbato nvenc: Extended rate-control support as provided by SDK 7 Signed-off-by: Luca Barbato Signed-off-by: Diego Biurrun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70de2ea4261f860457a04e3d0c58c5543f403325 --- libavcodec/nvenc.c | 47 +++ libavcodec/nvenc.h | 10 ++ libavcodec/nvenc_h264.c | 12 libavcodec/nvenc_hevc.c | 10 ++ libavcodec/version.h| 2 +- 5 files changed, 80 insertions(+), 1 deletion(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 14651d4..0b6e4ce 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -610,6 +610,53 @@ static void nvenc_setup_rate_control(AVCodecContext *avctx) if (rc->averageBitRate > 0) avctx->bit_rate = rc->averageBitRate; + +#if NVENCAPI_MAJOR_VERSION >= 7 +if (ctx->aq) { +ctx->config.rcParams.enableAQ = 1; +ctx->config.rcParams.aqStrength = ctx->aq_strength; +av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n"); +} + +if (ctx->temporal_aq) { +ctx->config.rcParams.enableTemporalAQ = 1; +av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); +} + +if (ctx->rc_lookahead) { +int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - +ctx->config.frameIntervalP - 4; + +if (lkd_bound < 0) { +av_log(avctx, AV_LOG_WARNING, + "Lookahead not enabled. Increase buffer delay (-delay).\n"); +} else { +ctx->config.rcParams.enableLookahead = 1; +ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); +ctx->config.rcParams.disableIadapt = ctx->no_scenecut; +ctx->config.rcParams.disableBadapt = !ctx->b_adapt; +av_log(avctx, AV_LOG_VERBOSE, + "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", + ctx->config.rcParams.lookaheadDepth, + ctx->config.rcParams.disableIadapt ? "disabled" : "enabled", + ctx->config.rcParams.disableBadapt ? "disabled" : "enabled"); +} +} + +if (ctx->strict_gop) { +ctx->config.rcParams.strictGOPTarget = 1; +av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); +} + +if (ctx->nonref_p) +ctx->config.rcParams.enableNonRefP = 1; + +if (ctx->zerolatency) +ctx->config.rcParams.zeroReorderDelay = 1; + +if (ctx->quality) +ctx->config.rcParams.targetQuality = ctx->quality; +#endif /* NVENCAPI_MAJOR_VERSION >= 7 */ } static int nvenc_setup_h264_config(AVCodecContext *avctx) diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index fddf433..dfd03b5 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -171,6 +171,16 @@ typedef struct NVENCContext { int device; int flags; int async_depth; +int rc_lookahead; +int aq; +int no_scenecut; +int b_adapt; +int temporal_aq; +int zerolatency; +int nonref_p; +int strict_gop; +int aq_strength; +int quality; } NVENCContext; int ff_nvenc_encode_init(AVCodecContext *avctx); diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index d58ee88..faeafe9 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -77,6 +77,18 @@ static const AVOption options[] = { { "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "device" }, { "async_depth", "Delay frame output by the given amount of frames", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE }, { "delay", "Delay frame output by the given amount of frames", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE }, +#if NVENCAPI_MAJOR_VERSION >= 7 +{ "rc-lookahead", "Number of frames to look ahead for rate-control", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE }, +{ "no-scenecut", "When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts", OFFSET(no_scenecut), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, +{ "b_adapt", "When lookahead is enabled, set this to 0 to disable adaptive B-frame decision", OFFSET(b_adapt), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, +{ "spatial-aq", "set to 1 to enable Spatial AQ", OFFSET(aq), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, +{ &qu
[FFmpeg-cvslog] nvenc: Force high_444 profile for 444 input
ffmpeg | branch: master | Yogender Gupta | Thu Oct 6 09:10:25 2016 +| [da2848375a2e2121dad9f1e8cbd0ead4e3bf77d6] | committer: Luca Barbato nvenc: Force high_444 profile for 444 input Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da2848375a2e2121dad9f1e8cbd0ead4e3bf77d6 --- libavcodec/nvenc.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0b6e4ce..9c35bd0 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -723,6 +723,11 @@ static int nvenc_setup_h264_config(AVCodecContext *avctx) break; } +if (ctx->data_pix_fmt == AV_PIX_FMT_YUV444P) { +cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID; +avctx->profile = FF_PROFILE_H264_HIGH_444_PREDICTIVE; +} + h264->level = ctx->level; return 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] nvenc: Fix error log
ffmpeg | branch: master | Yogender Gupta | Thu Oct 6 15:02:26 2016 +0530| [cbd84b8a51aa656d71b7d6ed44bd89041ff081a8] | committer: Luca Barbato nvenc: Fix error log Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbd84b8a51aa656d71b7d6ed44bd89041ff081a8 --- libavcodec/nvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 9c35bd0..d5bfd74 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -928,7 +928,7 @@ static int nvenc_setup_encoder(AVCodecContext *avctx) ret = nv->nvEncInitializeEncoder(ctx->nvenc_ctx, &ctx->params); if (ret != NV_ENC_SUCCESS) -return nvenc_print_error(avctx, ret, "Cannot initialize the decoder"); +return nvenc_print_error(avctx, ret, "InitializeEncoder failed"); cpb_props = ff_add_cpb_side_data(avctx); if (!cpb_props) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] scale_npp: fix passthrough mode
ffmpeg | branch: master | Yogender Gupta | Mon Oct 24 18:44:41 2016 +0530| [99aeae20de4d09ea313fdc619d4e2df825155e62] | committer: Anton Khirnov scale_npp: fix passthrough mode Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=99aeae20de4d09ea313fdc619d4e2df825155e62 --- libavfilter/vf_scale_npp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index 247baf1..2fb4990 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -337,7 +337,7 @@ static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig } if (last_stage < 0) -return AVERROR_BUG; +return 0; ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx); if (!ctx->outputs[0]->hw_frames_ctx) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/scale_cuda: add CUDA scale filter
ffmpeg | branch: master | Yogender Gupta | Wed May 10 23:06:16 2017 +0530| [921bd9a2be4c1f4a0524346a694e2da814488d7f] | committer: Timo Rothenpieler avfilter/scale_cuda: add CUDA scale filter Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=921bd9a2be4c1f4a0524346a694e2da814488d7f --- Changelog| 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h| 2 +- libavfilter/vf_scale_cuda.c | 556 +++ libavfilter/vf_scale_cuda.cu | 212 + 6 files changed, 772 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 1778980e7e..581aa73fc7 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ version : - config.log and other configuration files moved into ffbuild/ directory - update cuvid/nvenc headers to Video Codec SDK 8.0.14 - afir audio filter +- scale_cuda CUDA based video scale filter version 3.3: - CrystalHD decoder moved to new decode API diff --git a/libavfilter/Makefile b/libavfilter/Makefile index f7dfe8ad54..f177fdb42b 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -267,6 +267,7 @@ OBJS-$(CONFIG_REVERSE_FILTER)+= f_reverse.o OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o OBJS-$(CONFIG_SAB_FILTER)+= vf_sab.o OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o scale.o +OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o vf_scale_cuda.ptx.o OBJS-$(CONFIG_SCALE_NPP_FILTER) += vf_scale_npp.o scale.o OBJS-$(CONFIG_SCALE_QSV_FILTER) += vf_scale_qsv.o OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index cd35ae4c9c..a8939b9094 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -278,6 +278,7 @@ static void register_all(void) REGISTER_FILTER(ROTATE, rotate, vf); REGISTER_FILTER(SAB,sab,vf); REGISTER_FILTER(SCALE, scale, vf); +REGISTER_FILTER(SCALE_CUDA, scale_cuda, vf); REGISTER_FILTER(SCALE_NPP, scale_npp, vf); REGISTER_FILTER(SCALE_QSV, scale_qsv, vf); REGISTER_FILTER(SCALE_VAAPI,scale_vaapi,vf); diff --git a/libavfilter/version.h b/libavfilter/version.h index ebfa644d1c..85d8f8 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 6 #define LIBAVFILTER_VERSION_MINOR 89 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c new file mode 100644 index 00..23ac27a7dc --- /dev/null +++ b/libavfilter/vf_scale_cuda.c @@ -0,0 +1,556 @@ +/* +* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include +#include +#include + +#include "libavutil/avstring.h" +#include "libavutil/common.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/internal.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "scale.h" +#include "video.h" + +static const enum AVPixelFormat supported_formats[] = { +AV_PIX_FMT_YUV420P, +AV_PIX_FMT_NV12, +AV_PIX_FMT_YUV444P, +AV_PIX_FMT_P010, +AV_PIX_FMT_P016 +}; + +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) +#define ALIGN_UP(a, b) (((a
[FFmpeg-cvslog] hwupload_cuda : Add 10/16 bit format support
ffmpeg | branch: master | Yogender Gupta | Tue Jul 18 16:19:02 2017 +0530| [2e8679373ab628a19885645ed5e1271be7797600] | committer: Philip Langdale hwupload_cuda : Add 10/16 bit format support Signed-off-by: Philip Langdale > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e8679373ab628a19885645ed5e1271be7797600 --- libavfilter/version.h | 2 +- libavfilter/vf_hwupload_cuda.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/version.h b/libavfilter/version.h index 01dd1dbb72..04ea8b71f8 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 6 #define LIBAVFILTER_VERSION_MINOR 96 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_hwupload_cuda.c b/libavfilter/vf_hwupload_cuda.c index ef98233d12..063f0285c3 100644 --- a/libavfilter/vf_hwupload_cuda.c +++ b/libavfilter/vf_hwupload_cuda.c @@ -58,6 +58,7 @@ static int cudaupload_query_formats(AVFilterContext *ctx) static const enum AVPixelFormat input_pix_fmts[] = { AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, +AV_PIX_FMT_P010, AV_PIX_FMT_P016, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_NONE, }; static const enum AVPixelFormat output_pix_fmts[] = { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_cuda : Support YUV444P16 format
ffmpeg | branch: master | Yogender Gupta | Tue Jul 18 16:53:53 2017 +0530| [3407d8118c7236c94dc0eddabc82041e5c130201] | committer: Philip Langdale hwcontext_cuda : Support YUV444P16 format Signed-off-by: Philip Langdale > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3407d8118c7236c94dc0eddabc82041e5c130201 --- libavutil/hwcontext_cuda.c | 8 +++- libavutil/version.h| 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index ed595c3e0f..dfb67bc941 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -37,6 +37,7 @@ static const enum AVPixelFormat supported_formats[] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_P010, AV_PIX_FMT_P016, +AV_PIX_FMT_YUV444P16, }; static int cuda_frames_get_constraints(AVHWDeviceContext *ctx, @@ -142,6 +143,9 @@ static int cuda_frames_init(AVHWFramesContext *ctx) case AV_PIX_FMT_P016: size = aligned_width * ctx->height * 3; break; +case AV_PIX_FMT_YUV444P16: +size = aligned_width * ctx->height * 6; +break; default: av_log(ctx, AV_LOG_ERROR, "BUG: Pixel format missing from size calculation."); return AVERROR_BUG; @@ -161,7 +165,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) int width_in_bytes = ctx->width; if (ctx->sw_format == AV_PIX_FMT_P010 || -ctx->sw_format == AV_PIX_FMT_P016) { +ctx->sw_format == AV_PIX_FMT_P016 || +ctx->sw_format == AV_PIX_FMT_YUV444P16) { width_in_bytes *= 2; } aligned_width = FFALIGN(width_in_bytes, CUDA_FRAME_ALIGNMENT); @@ -188,6 +193,7 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) frame->linesize[2] = aligned_width / 2; break; case AV_PIX_FMT_YUV444P: +case AV_PIX_FMT_YUV444P16: frame->data[0] = frame->buf[0]->data; frame->data[1] = frame->data[0] + aligned_width * ctx->height; frame->data[2] = frame->data[1] + aligned_width * ctx->height; diff --git a/libavutil/version.h b/libavutil/version.h index 35987e7b50..3dad41f74d 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -81,7 +81,7 @@ #define LIBAVUTIL_VERSION_MAJOR 55 #define LIBAVUTIL_VERSION_MINOR 69 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/scale_npp: fix passthrough mode
ffmpeg | branch: master | Yogender Gupta | Mon Aug 14 16:29:32 2017 +0530| [77c5a54192b2bd662bdd6bfe5976707da6b68a35] | committer: Timo Rothenpieler avfilter/scale_npp: fix passthrough mode Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77c5a54192b2bd662bdd6bfe5976707da6b68a35 --- libavfilter/vf_scale_npp.c | 4 1 file changed, 4 insertions(+) diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index c36772e800..f64ab956c7 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -320,7 +320,11 @@ static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig } if (last_stage < 0) +{ +ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(ctx->inputs[0]->hw_frames_ctx); return 0; +} + ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx); if (!ctx->outputs[0]->hw_frames_ctx) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/thumbnail_cuda: add cuda thumbnail filter
ffmpeg | branch: master | Yogender Gupta | Mon Sep 4 18:36:16 2017 +0530| [21e077fcb3d968e3ed6772a0309e31f94cd7a2a5] | committer: Timo Rothenpieler avfilter/thumbnail_cuda: add cuda thumbnail filter Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21e077fcb3d968e3ed6772a0309e31f94cd7a2a5 --- Changelog| 2 + configure| 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h| 2 +- libavfilter/vf_thumbnail_cuda.c | 444 +++ libavfilter/vf_thumbnail_cuda.cu | 79 +++ 7 files changed, 529 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index ea48e81efe..38b125be39 100644 --- a/Changelog +++ b/Changelog @@ -48,6 +48,8 @@ version : - convolve video filter - VP9 tile threading support - KMS screen grabber +- CUDA thumbnail filter + version 3.3: - CrystalHD decoder moved to new decode API diff --git a/configure b/configure index 2de20a02a4..ff9a64292c 100755 --- a/configure +++ b/configure @@ -2759,6 +2759,7 @@ vaapi_encode_deps="vaapi" hwupload_cuda_filter_deps="cuda" scale_npp_filter_deps="cuda libnpp" scale_cuda_filter_deps="cuda_sdk" +thumbnail_cuda_filter_deps="cuda_sdk" nvenc_deps="cuda" nvenc_deps_any="dlopen LoadLibrary" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 8aa974e115..98acb51bcb 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -315,6 +315,7 @@ OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o OBJS-$(CONFIG_TELECINE_FILTER) += vf_telecine.o OBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o framesync.o OBJS-$(CONFIG_THUMBNAIL_FILTER) += vf_thumbnail.o +OBJS-$(CONFIG_THUMBNAIL_CUDA_FILTER) += vf_thumbnail_cuda.o vf_thumbnail_cuda.ptx.o OBJS-$(CONFIG_TILE_FILTER) += vf_tile.o OBJS-$(CONFIG_TINTERLACE_FILTER) += vf_tinterlace.o OBJS-$(CONFIG_TLUT2_FILTER) += vf_lut2.o framesync.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 63e86721cd..baa84a3e72 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -326,6 +326,7 @@ static void register_all(void) REGISTER_FILTER(TELECINE, telecine, vf); REGISTER_FILTER(THRESHOLD, threshold, vf); REGISTER_FILTER(THUMBNAIL, thumbnail, vf); +REGISTER_FILTER(THUMBNAIL_CUDA, thumbnail_cuda, vf); REGISTER_FILTER(TILE, tile, vf); REGISTER_FILTER(TINTERLACE, tinterlace, vf); REGISTER_FILTER(TLUT2, tlut2, vf); diff --git a/libavfilter/version.h b/libavfilter/version.h index 5d6aa5fc70..fb382d4e25 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 6 -#define LIBAVFILTER_VERSION_MINOR 105 +#define LIBAVFILTER_VERSION_MINOR 106 #define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_thumbnail_cuda.c b/libavfilter/vf_thumbnail_cuda.c new file mode 100644 index 00..4c08a85121 --- /dev/null +++ b/libavfilter/vf_thumbnail_cuda.c @@ -0,0 +1,444 @@ +/* +* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "internal.h" + +#define HIST_SIZE (3*256) +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) +#define BLOCKX 32 +#defin
[FFmpeg-cvslog] avcodec/cuviddec: set key frame for decoded frames
ffmpeg | branch: master | Yogender Gupta | Thu Jan 18 12:34:19 2018 +0530| [07a96b6251f0d55d370e14d661301ced0cd03c24] | committer: Timo Rothenpieler avcodec/cuviddec: set key frame for decoded frames Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=07a96b6251f0d55d370e14d661301ced0cd03c24 --- libavcodec/cuviddec.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index c23033c7e3..122c28f6e8 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -74,6 +74,8 @@ typedef struct CuvidContext int internal_error; int decoder_flushing; +int *key_frame; + cudaVideoCodec codec_type; cudaVideoChromaFormat chroma_format; @@ -340,6 +342,8 @@ static int CUDAAPI cuvid_handle_picture_decode(void *opaque, CUVIDPICPARAMS* pic av_log(avctx, AV_LOG_TRACE, "pfnDecodePicture\n"); +ctx->key_frame[picparams->CurrPicIdx] = picparams->intra_pic_flag; + ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams)); if (ctx->internal_error < 0) return 0; @@ -590,6 +594,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) goto error; } +frame->key_frame = ctx->key_frame[parsed_frame.dispinfo.picture_index]; frame->width = avctx->width; frame->height = avctx->height; if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) @@ -693,6 +698,8 @@ static av_cold int cuvid_decode_end(AVCodecContext *avctx) av_buffer_unref(&ctx->hwframe); av_buffer_unref(&ctx->hwdevice); +av_freep(&ctx->key_frame); + cuvid_free_functions(&ctx->cvdl); return 0; @@ -977,6 +984,12 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), avctx->extradata_size)); } +ctx->key_frame = av_mallocz(ctx->nb_surfaces * sizeof(int)); +if (!ctx->key_frame) { +ret = AVERROR(ENOMEM); +goto error; +} + ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces; ctx->cuparseinfo.ulMaxDisplayDelay = 4; ctx->cuparseinfo.pUserData = avctx; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/scale_npp: fix passthrough mode
ffmpeg | branch: master | Yogender Gupta | Mon Oct 24 18:20:01 2016 +0530| [f524275ef93882f27c0067e85e8fb3c0fc1a762b] | committer: Michael Niedermayer avfilter/scale_npp: fix passthrough mode Reviewed-by: Timo Rothenpieler Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f524275ef93882f27c0067e85e8fb3c0fc1a762b --- libavfilter/vf_scale_npp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index 35abe39..8eafdc8 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -349,7 +349,7 @@ static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig } if (last_stage < 0) -return AVERROR_BUG; +return 0; ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx); if (!ctx->outputs[0]->hw_frames_ctx) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/nvenc: Extended rate-control support as provided by SDK 7
ffmpeg | branch: master | Yogender Gupta | Sat Sep 24 17:55:00 2016 +0200| [facc19ef06a753515a3fa604269dd1aa412dc08f] | committer: Timo Rothenpieler avcodec/nvenc: Extended rate-control support as provided by SDK 7 Merged from libav commit by Yogender Gupta: https://git.libav.org/?p=libav.git;a=commitdiff;h=70de2ea4261f860457a04e3d0c58c5543f403325 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=facc19ef06a753515a3fa604269dd1aa412dc08f --- libavcodec/nvenc.c | 46 +++--- libavcodec/nvenc.h | 9 + libavcodec/nvenc_h264.c | 9 + libavcodec/nvenc_hevc.c | 7 +++ libavcodec/version.h| 2 +- 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 421ea79..f6f756f 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -724,10 +724,50 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx) ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate; } -if (ctx->rc_lookahead > 0) { -ctx->encode_config.rcParams.enableLookahead = 1; -ctx->encode_config.rcParams.lookaheadDepth = FFMIN(ctx->rc_lookahead, 32); +if (ctx->aq) { +ctx->encode_config.rcParams.enableAQ = 1; +ctx->encode_config.rcParams.aqStrength = ctx->aq_strength; +av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n"); } + +if (ctx->temporal_aq) { +ctx->encode_config.rcParams.enableTemporalAQ = 1; +av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); +} + +if (ctx->rc_lookahead) { +int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - +ctx->encode_config.frameIntervalP - 4; + +if (lkd_bound < 0) { +av_log(avctx, AV_LOG_WARNING, + "Lookahead not enabled. Increase buffer delay (-delay).\n"); +} else { +ctx->encode_config.rcParams.enableLookahead = 1; +ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); +ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut; +ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt; +av_log(avctx, AV_LOG_VERBOSE, + "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", + ctx->encode_config.rcParams.lookaheadDepth, + ctx->encode_config.rcParams.disableIadapt ? "disabled" : "enabled", + ctx->encode_config.rcParams.disableBadapt ? "disabled" : "enabled"); +} +} + +if (ctx->strict_gop) { +ctx->encode_config.rcParams.strictGOPTarget = 1; +av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); +} + +if (ctx->nonref_p) +ctx->encode_config.rcParams.enableNonRefP = 1; + +if (ctx->zerolatency) +ctx->encode_config.rcParams.zeroReorderDelay = 1; + +if (ctx->quality) +ctx->encode_config.rcParams.targetQuality = ctx->quality; } static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index efc2a7a..648d1dc 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -183,6 +183,15 @@ typedef struct NvencContext int flags; int async_depth; int rc_lookahead; +int aq; +int no_scenecut; +int b_adapt; +int temporal_aq; +int zerolatency; +int nonref_p; +int strict_gop; +int aq_strength; +int quality; } NvencContext; int ff_nvenc_encode_init(AVCodecContext *avctx); diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 4ef9836..788cf69 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -84,6 +84,15 @@ static const AVOption options[] = { { "any", "Pick the first device available", 0, AV_OPT_TYPE_CONST, { .i64 = ANY_DEVICE }, 0, 0, VE, "gpu" }, { "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "gpu" }, { "delay","Delay frame output by the given amount of frames", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE }, +{ "no-scenecut", "When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts", OFFSET(no_scenecut), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, +{ "b_adapt", "When lookahead is enabled, set this to 0 to disable adaptive B-frame decision", OFFSET(b_adapt), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, +{ &quo