PR #25710 opened by Kilian (lusoris) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25710 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25710.patch
`av1_qsv` exports AV1 film grain parameters with `subsampling_x` and `subsampling_y` left at 0, so `av_film_grain_params_select()` never picks them for the NV12 and P010 frames the decoder outputs. The AV1 branch of `av_film_grain_params_select()` needs an exact match between the parameters' subsampling and the frame's chroma shift. This patch fills both fields from `avctx->sw_pix_fmt` with `av_pix_fmt_get_chroma_sub_sample()`, which gives 1/1 for 4:2:0, the same values libdav1d exports for these streams. Found during review of PR 25614, which touches the same function. Tested on an Intel Arc (xe, iHD) with `-export_side_data film_grain -vf showinfo`, 10 frames each of `av1-1-b8-23-film_grain-50.ivf` and `av1-1-b10-23-film_grain-50.ivf`: | Stream | master `av1_qsv` | this branch `av1_qsv` | `libdav1d` | | --- | --- | --- | --- | | 8-bit (nv12) | 0/0 | 1/1 | 1/1 | | 10-bit (p010le) | 0/0 | 1/1 | 1/1 | No other exported film grain field changed between master and this branch. The build shows no new warnings. >From 2e7691e86d37dfa4537fd51e4b0151d423cf5765 Mon Sep 17 00:00:00 2001 From: lusoris <[email protected]> Date: Tue, 3 Nov 2026 13:15:50 +0100 Subject: [PATCH] avcodec/qsvdec: export the film grain chroma subsampling The fields were left at 0. av_film_grain_params_select() needs an exact AV1 subsampling match, so NV12/P010 frames never get the params. Take them from sw_pix_fmt, like libdav1d. Signed-off-by: lusoris <[email protected]> --- libavcodec/qsvdec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 990e46ea1d7..652507f1954 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -37,6 +37,7 @@ #include "libavutil/mem.h" #include "libavutil/log.h" #include "libavutil/opt.h" +#include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" #include "libavutil/time.h" #include "libavutil/imgutils.h" @@ -629,6 +630,7 @@ static int qsv_export_film_grain(AVCodecContext *avctx, mfxExtAV1FilmGrainParam { AVFilmGrainParams *fgp; AVFilmGrainAOMParams *aom; + int ret; int i; if (!(ext_param->FilmGrainFlags & MFX_FILM_GRAIN_APPLY)) @@ -641,6 +643,11 @@ static int qsv_export_film_grain(AVCodecContext *avctx, mfxExtAV1FilmGrainParam fgp->type = AV_FILM_GRAIN_PARAMS_AV1; fgp->seed = ext_param->GrainSeed; + ret = av_pix_fmt_get_chroma_sub_sample(avctx->sw_pix_fmt, + &fgp->subsampling_x, + &fgp->subsampling_y); + if (ret < 0) + return ret; aom = &fgp->codec.aom; aom->chroma_scaling_from_luma = !!(ext_param->FilmGrainFlags & MFX_FILM_GRAIN_CHROMA_SCALING_FROM_LUMA); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
