[FFmpeg-devel] [PATCH] libavcodec/amfenc_hevc.c: Fix video fast forward hanging issue on HEVC AMF.
Change wrong gops_per_idr default value from 60 to 1 as per AMD AMF documents. https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_Encode_API.pdf Fixed: http://trac.ffmpeg.org/ticket/7272 --- libavcodec/amfenc_hevc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 77e57d2461..b0cb57cb96 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -69,7 +69,7 @@ static const AVOption options[] = { { "gop","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_GOP_ALIGNED }, 0, 0, VE, "hdrmode" }, { "idr","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED }, 0, 0, VE, "hdrmode" }, -{ "gops_per_idr","GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT, { .i64 = 60 }, 0, INT_MAX, VE }, +{ "gops_per_idr","GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, VE }, { "preanalysis","Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, { "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, { "enforce_hrd","Enforce HRD", OFFSET(enforce_hrd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, -- 2.17.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".
[FFmpeg-devel] [PATCH 1/2] libavcodec/qsvenc_hevc: add tier option
Without this change, MSDK/VPL always defaults the HEVC tier to MAIN if the -level is specified. Also, according to the HEVC specs, only level >= 4 can support High Tier. Signed-off-by: nyanmisaka --- libavcodec/qsvenc.c | 5 - libavcodec/qsvenc.h | 1 + libavcodec/qsvenc_hevc.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 15e6936a65..5250717f0b 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -614,8 +614,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) return AVERROR_BUG; q->param.mfx.CodecId = ret; -if (avctx->level > 0) +if (avctx->level > 0) { q->param.mfx.CodecLevel = avctx->level; +if (avctx->codec_id == AV_CODEC_ID_HEVC && avctx->level >= MFX_LEVEL_HEVC_4) +q->param.mfx.CodecLevel |= q->tier; +} if (avctx->compression_level == FF_COMPRESSION_DEFAULT) { avctx->compression_level = q->preset; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index d77bc0aee1..d64af90235 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -180,6 +180,7 @@ typedef struct QSVEncContext { int async_depth; int idr_interval; int profile; +int tier; int preset; int avbr_accuracy; int avbr_convergence; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 2a3f34b915..845fb93e9d 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -258,6 +258,9 @@ static const AVOption options[] = { #if QSV_VERSION_ATLEAST(1, 32) { "scc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_SCC }, INT_MIN, INT_MAX, VE, "profile" }, #endif +{ "tier","Set the encoding tier (only level >= 4 can support high tier)", OFFSET(qsv.tier), AV_OPT_TYPE_INT, { .i64 = MFX_TIER_HEVC_HIGH }, MFX_TIER_HEVC_MAIN, MFX_TIER_HEVC_HIGH, VE, "tier" }, +{ "main",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TIER_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "tier" }, +{ "high",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TIER_HEVC_HIGH }, INT_MIN, INT_MAX, VE, "tier" }, { "gpb", "1: GPB (generalized P/B frame); 0: regular P frame", OFFSET(qsv.gpb), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE}, -- 2.25.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".
[FFmpeg-devel] [PATCH 1/2] libavcodec/qsvenc_hevc: add tier option
Without this change, MSDK/VPL always defaults the HEVC tier to MAIN if the -level is specified. Also, according to the HEVC specs, only level >= 4 can support High Tier. Signed-off-by: nyanmisaka --- libavcodec/qsvenc.c | 5 - libavcodec/qsvenc.h | 1 + libavcodec/qsvenc_hevc.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 15e6936a65..5250717f0b 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -614,8 +614,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) return AVERROR_BUG; q->param.mfx.CodecId = ret; -if (avctx->level > 0) +if (avctx->level > 0) { q->param.mfx.CodecLevel = avctx->level; +if (avctx->codec_id == AV_CODEC_ID_HEVC && avctx->level >= MFX_LEVEL_HEVC_4) +q->param.mfx.CodecLevel |= q->tier; +} if (avctx->compression_level == FF_COMPRESSION_DEFAULT) { avctx->compression_level = q->preset; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index d77bc0aee1..d64af90235 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -180,6 +180,7 @@ typedef struct QSVEncContext { int async_depth; int idr_interval; int profile; +int tier; int preset; int avbr_accuracy; int avbr_convergence; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 2a3f34b915..845fb93e9d 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -258,6 +258,9 @@ static const AVOption options[] = { #if QSV_VERSION_ATLEAST(1, 32) { "scc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_SCC }, INT_MIN, INT_MAX, VE, "profile" }, #endif +{ "tier","Set the encoding tier (only level >= 4 can support high tier)", OFFSET(qsv.tier), AV_OPT_TYPE_INT, { .i64 = MFX_TIER_HEVC_HIGH }, MFX_TIER_HEVC_MAIN, MFX_TIER_HEVC_HIGH, VE, "tier" }, +{ "main",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TIER_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "tier" }, +{ "high",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TIER_HEVC_HIGH }, INT_MIN, INT_MAX, VE, "tier" }, { "gpb", "1: GPB (generalized P/B frame); 0: regular P frame", OFFSET(qsv.gpb), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE}, -- 2.25.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".
[FFmpeg-devel] [PATCH 2/2] doc/encoders: add doc of the tier option for hevc_qsv
Signed-off-by: nyanmisaka --- doc/encoders.texi | 9 + 1 file changed, 9 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 1a5216f8eb..e823d20657 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3654,6 +3654,15 @@ Set the encoding profile (scc requires libmfx >= 1.32). @item scc @end table +@item @var{tier} +Set the encoding tier (only level >= 4 can support high tier). +This option only takes effect when the level option is specified. + +@table @samp +@item main +@item high +@end table + @item @var{gpb} 1: GPB (generalized P/B frame) -- 2.25.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".
[FFmpeg-devel] [PATCH 2/2] avfilter/hwupload_cuda: add YUVA420P format support
Signed-off-by: nyanmisaka --- libavfilter/vf_hwupload_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_hwupload_cuda.c b/libavfilter/vf_hwupload_cuda.c index 8ee0825859..f01f202832 100644 --- a/libavfilter/vf_hwupload_cuda.c +++ b/libavfilter/vf_hwupload_cuda.c @@ -57,7 +57,7 @@ static int cudaupload_query_formats(AVFilterContext *ctx) int ret; static const enum AVPixelFormat input_pix_fmts[] = { -AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, +AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_P010, AV_PIX_FMT_P016, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_0RGB32, AV_PIX_FMT_0BGR32, #if CONFIG_VULKAN -- 2.30.0 ___ 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".
[FFmpeg-devel] [PATCH] avfilter/overlay_cuda: fix framesync with embedded PGS subtitle
Signed-off-by: nyanmisaka --- libavfilter/vf_overlay_cuda.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index 2f0f860e50..f6ee43e929 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -157,9 +157,12 @@ static int overlay_cuda_blend(FFFrameSync *fs) if (ret < 0) return ret; -if (!input_main || !input_overlay) +if (!input_main) return AVERROR_BUG; +if (!input_overlay) +return ff_filter_frame(outlink, input_main); + ret = av_frame_make_writable(input_main); if (ret < 0) { av_frame_free(&input_main); -- 2.30.0 ___ 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".
[FFmpeg-devel] [PATCH] avfilter/hwupload_cuda: add YUVA420P format support
Signed-off-by: nyanmisaka --- libavfilter/vf_hwupload_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_hwupload_cuda.c b/libavfilter/vf_hwupload_cuda.c index 8ee0825859..f01f202832 100644 --- a/libavfilter/vf_hwupload_cuda.c +++ b/libavfilter/vf_hwupload_cuda.c @@ -57,7 +57,7 @@ static int cudaupload_query_formats(AVFilterContext *ctx) int ret; static const enum AVPixelFormat input_pix_fmts[] = { -AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, +AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_P010, AV_PIX_FMT_P016, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_0RGB32, AV_PIX_FMT_0BGR32, #if CONFIG_VULKAN -- 2.30.0 ___ 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".
[FFmpeg-devel] [PATCH 1/2] avfilter/overlay_cuda: fix framesync with embedded PGS subtitle
Signed-off-by: nyanmisaka --- libavfilter/vf_overlay_cuda.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index 2f0f860e50..f6ee43e929 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -157,9 +157,12 @@ static int overlay_cuda_blend(FFFrameSync *fs) if (ret < 0) return ret; -if (!input_main || !input_overlay) +if (!input_main) return AVERROR_BUG; +if (!input_overlay) +return ff_filter_frame(outlink, input_main); + ret = av_frame_make_writable(input_main); if (ret < 0) { av_frame_free(&input_main); -- 2.30.0 ___ 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".
[FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: fix a race mapping to allow CSC to YUV420P (PR #20158)
PR #20158 opened by nyanmisaka URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20158 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20158.patch lavu/hwcontext_vaapi: fix a race mapping to allow CSC to YUV420P There's a race condition for YUV420P when mapping from pix_fmt to VA fourcc, both I420 and YV12 could be found by pix_fmt. Currently, vaapi_get_image_format() iterates over the query results of pix_fmt and returns the first matching result in the order declared in the driver. This may result in an incorrect image_format. Now use fourcc to find the image_format. Fixes: ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i INPUT \ -vf scale_vaapi=format=yuv420p,hwmap,format=yuv420p \ -vframes 1 -f rawvideo -y yuv420p.yuv Signed-off-by: nyanmisaka This was discovered because some NVR software's object recognition requires fully-planar YUV420P instead of NV12. >From 4b69c844b03da78cd12205e7f8865cc8f16c1a67 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 7 Aug 2025 22:32:20 +0800 Subject: [PATCH 1/2] lavu/hwcontext_vaapi: fix a race mapping to allow CSC to YUV420P There's a race condition for YUV420P when mapping from pix_fmt to VA fourcc, both I420 and YV12 could be found by pix_fmt. Currently, vaapi_get_image_format() iterates over the query results of pix_fmt and returns the first matching result in the order declared in the driver. This may result in an incorrect image_format. Now use fourcc to find the image_format. Fixes: ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i INPUT \ -vf scale_vaapi=format=yuv420p,hwmap,format=yuv420p \ -vframes 1 -f rawvideo -y yuv420p.yuv Signed-off-by: nyanmisaka --- libavutil/hwcontext_vaapi.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 95aa38d9d2..7c243ec1ef 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -72,6 +72,7 @@ typedef struct VAAPIDevicePriv { typedef struct VAAPISurfaceFormat { enum AVPixelFormat pix_fmt; VAImageFormat image_format; +unsigned int fourcc; } VAAPISurfaceFormat; typedef struct VAAPIDeviceContext { @@ -218,15 +219,21 @@ static int vaapi_get_image_format(AVHWDeviceContext *hwdev, VAImageFormat **image_format) { VAAPIDeviceContext *ctx = hwdev->hwctx; +const VAAPIFormatDescriptor *desc; int i; +desc = vaapi_format_from_pix_fmt(pix_fmt); +if (!desc || !image_format) +goto fail; + for (i = 0; i < ctx->nb_formats; i++) { -if (ctx->formats[i].pix_fmt == pix_fmt) { -if (image_format) -*image_format = &ctx->formats[i].image_format; +if (ctx->formats[i].fourcc == desc->fourcc) { +*image_format = &ctx->formats[i].image_format; return 0; } } + +fail: return AVERROR(ENOSYS); } @@ -435,6 +442,7 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n", fourcc, av_get_pix_fmt_name(pix_fmt)); ctx->formats[ctx->nb_formats].pix_fmt = pix_fmt; +ctx->formats[ctx->nb_formats].fourcc = fourcc; ctx->formats[ctx->nb_formats].image_format = image_list[i]; ++ctx->nb_formats; } -- 2.49.1 >From fcceafc72c1c6116011a1a34911a5b9cb1026de5 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 7 Aug 2025 22:48:04 +0800 Subject: [PATCH 2/2] lavu/hwcontext_vaapi: drop a redundant check vaapi_get_image_format() will be called in vaapi_map_frame(). So it's a double check, drop it to avoid redundancy. Signed-off-by: nyanmisaka --- libavutil/hwcontext_vaapi.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 7c243ec1ef..51af22a607 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1019,12 +1019,6 @@ static int vaapi_map_to_memory(AVHWFramesContext *hwfc, AVFrame *dst, { int err; -if (dst->format != AV_PIX_FMT_NONE) { -err = vaapi_get_image_format(hwfc->device_ctx, dst->format, NULL); -if (err < 0) -return err; -} - err = vaapi_map_frame(hwfc, dst, src, flags); if (err) return err; -- 2.49.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".
[FFmpeg-devel] [PATCH] lavu/log: fix color for AV_CLASS_CATEGORY_HWDEVICE on non-Win32 (PR #20196)
PR #20196 opened by nyanmisaka URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20196 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20196.patch AV_CLASS_CATEGORY_HWDEVICE was introduced in the past but no corresponding colors were added for non-Win32 platforms. Fixes bf1579c ("avutil/log,hwcontext: Add AV_CLASS_CATEGORY_HWDEVICE") Signed-off-by: nyanmisaka Use orange/yellow here to match the colors used on Win32: >From c7649b13107ca10c033d84b79b051a349bce8393 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Sat, 9 Aug 2025 20:39:15 +0800 Subject: [PATCH] lavu/log: fix color for AV_CLASS_CATEGORY_HWDEVICE on non-Win32 AV_CLASS_CATEGORY_HWDEVICE was introduced in the past but no corresponding colors were added for non-Win32 platforms. Fixes bf1579c ("avutil/log,hwcontext: Add AV_CLASS_CATEGORY_HWDEVICE") Signed-off-by: nyanmisaka --- libavutil/log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/log.c b/libavutil/log.c index 2b721aea5a..af893dde17 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -114,6 +114,7 @@ static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = { [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14, [16+AV_CLASS_CATEGORY_SWSCALER] = 153 << 8 | 0x14, [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14, +[16+AV_CLASS_CATEGORY_HWDEVICE] = 214 << 8 | 0x13, [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15, [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05, [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15, -- 2.49.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".