From 7fccf82df5b5f9d07b07e9946d86e60d6d83d5f5 Mon Sep 17 00:00:00 2001 From: Pu Cheng Date: Fri, 20 Nov 2026 07:52:54 +0800 Subject: [PATCH] decoder: Do not keep an output stride narrower than the picture u4_frm_buf_stride is set to the picture width after the header only when it is 0. It can still be smaller than the width there: - after a decode call returns IVD_RES_CHANGED (not a fatal error) and the application keeps feeding data without a reset, the stride of the previous, narrower sequence is kept for the new one; - a display width set with IVD_CMD_CTL_SETPARAMS before the first header is accepted without checking it against the picture width. The 420SP (UV and VU) and 422ILE format conversions advance the destination pointer at the end of each row by the unsigned difference "stride - width", so with a stride below the width they write outside the output buffer. With 420P output the rows overlap instead. Use the picture width when the stride is below it. --- decoder/impeg2d_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/impeg2d_decoder.c b/decoder/impeg2d_decoder.c index fe0b870..f1a6eec 100644 --- a/decoder/impeg2d_decoder.c +++ b/decoder/impeg2d_decoder.c @@ -156,7 +156,7 @@ void impeg2d_dec_hdr(void *pv_dec,impeg2d_video_decode_ip_t *ps_ip, ps_op->s_ivd_video_decode_op_t.u4_frame_decoded_flag = 0; /* Set the stride */ - if (0 == ps_dec->u4_frm_buf_stride) + if (ps_dec->u4_frm_buf_stride < ps_dec->u2_horizontal_size) { ps_dec->u4_frm_buf_stride = ps_dec->u2_horizontal_size; }