This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 042ff8056281df0b374c2b22faff393ec9ea68db Author: Jun Zhao <[email protected]> AuthorDate: Sun Mar 8 22:55:37 2026 +0800 Commit: toots <[email protected]> CommitDate: Wed Mar 18 02:08:09 2026 +0000 doc/examples/qsv_decode: fix raw frame dump for chroma planes The output loop used sw_frame->width as the write size for all planes. This is only correct for NV12 where the interleaved UV plane happens to have the same byte width as the Y plane. For other pixel formats (e.g. YUV420P where U/V planes are half width, or P010 where samples are 2 bytes), the output would be corrupted. Use av_image_get_linesize() to compute the correct byte width for each plane based on the actual pixel format. Signed-off-by: Jun Zhao <[email protected]> --- doc/examples/qsv_decode.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/examples/qsv_decode.c b/doc/examples/qsv_decode.c index ec91109480..cdfde89652 100644 --- a/doc/examples/qsv_decode.c +++ b/doc/examples/qsv_decode.c @@ -39,6 +39,7 @@ #include <libavutil/error.h> #include <libavutil/hwcontext.h> #include <libavutil/hwcontext_qsv.h> +#include <libavutil/imgutils.h> #include <libavutil/mem.h> static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) @@ -88,9 +89,16 @@ static int decode_packet(AVCodecContext *decoder_ctx, goto fail; } - for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++) - for (j = 0; j < (sw_frame->height >> (i > 0)); j++) - avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width); + for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++) { + int h = sw_frame->height >> (i > 0); + int linesize = av_image_get_linesize(sw_frame->format, sw_frame->width, i); + if (linesize < 0) { + ret = linesize; + goto fail; + } + for (j = 0; j < h; j++) + avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], linesize); + } fail: av_frame_unref(sw_frame); _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
