Opened 2 hours ago

Last modified 106 minutes ago

#11357 new defect

Results may be inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices

Reported by: Bin Peng Owned by:
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 Bin Peng)

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)

inter_weighted_bipred2.264 (5.1 KB ) - added by Bin Peng 2 hours ago.
h264 bitstream with weighted-bipred enabled

Download all attachments as: .zip

Change History (7)

by Bin Peng, 2 hours ago

Attachment: inter_weighted_bipred2.264 added

h264 bitstream with weighted-bipred enabled

comment:1 by Bin Peng, 2 hours ago

Description: modified (diff)

comment:2 by Bin Peng, 2 hours 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 Bin Peng, 2 hours ago

Summary: H.264 decoder bug on ArmInconsistency on ARM when decoding weighted-bipred enabled H.264 bitstream

comment:4 by Bin Peng, 2 hours ago

Keywords: arm added

comment:5 by Bin Peng, 2 hours ago

Summary: Inconsistency on ARM when decoding weighted-bipred enabled H.264 bitstreamInconsistency on ARM and X86 when decoding H.264 bitstream with weighted-bipred enabled

comment:6 by Bin Peng, 106 minutes ago

Summary: Inconsistency on ARM and X86 when decoding H.264 bitstream with weighted-bipred enabledResults may be inconsistent when decoding an H.264 bitstream with bi-prediction weighted prediction enabled on ARM and x86 devices
Note: See TracTickets for help on using tickets.