Opened 19 months ago
Closed 14 months ago
#11357 closed defect (fixed)
Inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices
| Reported by: | Bin Peng | Owned by: | Michael Niedermayer <michael@niedermayer.cc> |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | H264 decoder arm |
| Cc: | Bin Peng | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
When decoding a bitstream with weighted-bipred enabled, the output of FFmpeg on ARM and x86 platforms may differ.
How to reproduce:
using ffmpeg git-master built on aarch64 and test on aarch64 devices % ffmpeg -i inter_weighted_bipred2.264 -f framemd5 -y md5_arm using ffmpeg git-master built on x86 and test on x86 devices % ffmpeg -i inter_weighted_bipred2.264 -f framemd5 -y md5_x86 md5_arm and md5_x86 would be different, but we expect the same decode result on different CPUs with the same input bit-stream.
Attachments (1)
Change History (9)
by , 19 months ago
| Attachment: | inter_weighted_bipred2.264 added |
|---|
comment:1 by , 19 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 19 months ago
The reason for the inconsistency is that the value of STRIDE_ALIGN differs between platforms. On x86 platforms, it is greater than 16 (typically 32 or 64), while on ARM platforms, it is 16.
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/internal.h#L39
The STRIDE_ALIGN is set to the buffer stride of temporary buffers for U and V components in mc_part_weighted.
uint8_t *tmp_cb = sl->bipred_scratchpad; uint8_t *tmp_cr = sl->bipred_scratchpad + (16 << pixel_shift);
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/h264_mb.c#L410
But the offset of temporary buffers for U and V components is hardcoded to 16.
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 will overwrite part of the U component's pixels, leading to incorrect predicted pixels.
comment:3 by , 19 months ago
| Summary: | H.264 decoder bug on Arm → Inconsistency on ARM when decoding weighted-bipred enabled H.264 bitstream |
|---|
comment:4 by , 19 months ago
| Keywords: | arm added |
|---|
comment:5 by , 19 months ago
| Summary: | Inconsistency on ARM when decoding weighted-bipred enabled H.264 bitstream → Inconsistency on ARM and X86 when decoding H.264 bitstream with weighted-bipred enabled |
|---|
comment:6 by , 19 months ago
| Summary: | Inconsistency on ARM and X86 when decoding H.264 bitstream with weighted-bipred enabled → Results may be inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices |
|---|
comment:7 by , 18 months ago
| Summary: | Results may be inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices → Inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices |
|---|
comment:8 by , 14 months ago
| Owner: | set to |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
In 74fd2c3d/ffmpeg:



h264 bitstream with weighted-bipred enabled