[FFmpeg-cvslog] avcodec/h264_mb: Fix tmp_cr for arm
Michael Niedermayer
git at videolan.org
Tue May 13 02:51:20 EEST 2025
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Apr 16 02:25:00 2025 +0200| [74fd2c3ddbaf1fef5c4777784aa72b5747ad389c] | committer: Michael Niedermayer
avcodec/h264_mb: Fix tmp_cr for arm
When decoding a bitstream with weighted-bipred enabled,
the results on ARM and x86 platforms may differ.
The reason for the inconsistency is that the value of
STRIDE_ALIGN differs between platforms. And STRIDE_ALIGN
is set to the buffer stride of temporary buffers for U
and V components in mc_part_weighted.
If the buffer stride is 32 or 64 (as on x86 platforms),
the U and V pixels can be interleaved row by row without
overlapping, resulting in correct output.
However, on ARM platforms where the stride is 16,
the V component did overwrite part of the U component's pixels,
leading to incorrect predicted pixels.
The bug can be reproduced by the following bitstream.
https://trac.ffmpeg.org/attachment/ticket/11357/inter_weighted_bipred2.264
Fixes: ticket 11357
Commit-msg-mostly-by: Bin Peng <pengbin at visionular.com>
Reviewed-by: Bin Peng <pengbin at visionular.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=74fd2c3ddbaf1fef5c4777784aa72b5747ad389c
---
libavcodec/h264_mb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index 6083f7ad84..0d6562b583 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -407,7 +407,7 @@ static av_always_inline void mc_part_weighted(const H264Context *h, H264SliceCon
/* don't optimize for luma-only case, since B-frames usually
* use implicit weights => chroma too. */
uint8_t *tmp_cb = sl->bipred_scratchpad;
- uint8_t *tmp_cr = sl->bipred_scratchpad + (16 << pixel_shift);
+ uint8_t *tmp_cr = sl->bipred_scratchpad + (8 << pixel_shift + (chroma_idc == 3));
uint8_t *tmp_y = sl->bipred_scratchpad + 16 * sl->mb_uvlinesize;
int refn0 = sl->ref_cache[0][scan8[n]];
int refn1 = sl->ref_cache[1][scan8[n]];
More information about the ffmpeg-cvslog
mailing list