mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-11 08:13:06 +00:00
avcodec/h2645_vui: interpret a degenerate SAR as unspecified
Per ITU-T H.264 (ISO/IEC 14496-10) Annex E.2.1 and ITU-T H.265 (ISO/IEC 23008-2) Annex E.3.1, when sar_width or sar_height is zero the sample aspect ratio shall be considered unspecified. Internally ffmpeg represents an unspecified SAR as 0/1, while fractions with a zero denominator are not handled properly (den=0 is silently changed to den=1 in h264_ps.c, turning an invalid 20480/0 into a "valid" but impossibly extreme 20480/1); so we bridge the gap by replacing x/0 with 0/1 at the VUI parsing layer. An av_log warning is added so an invalid SAR in the bitstream is diagnosed rather than silently overwritten. This fixes a problem with some video files provided by game OddBallers when executed with Wine/Proton, which report SAR 20480/0. Based on patch by Giovanni Mascellani <gmascellani@codeweavers.com>. Fixes: ticket #23321 Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
committed by
James Almer
co-authored by
James Almer
parent
bb49197ede
commit
e598463b3d
@@ -46,6 +46,12 @@ void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *l
|
||||
else if (vui->aspect_ratio_idc == EXTENDED_SAR) {
|
||||
vui->sar.num = get_bits(gb, 16);
|
||||
vui->sar.den = get_bits(gb, 16);
|
||||
if (!vui->sar.num || !vui->sar.den) {
|
||||
av_log(logctx, AV_LOG_WARNING,
|
||||
"Invalid SAR %d/%d in bitstream, treating as unspecified.\n",
|
||||
vui->sar.num, vui->sar.den);
|
||||
vui->sar = (AVRational){ 0, 1 };
|
||||
}
|
||||
} else
|
||||
av_log(logctx, AV_LOG_WARNING,
|
||||
"Unknown SAR index: %u.\n", vui->aspect_ratio_idc);
|
||||
|
||||
Reference in New Issue
Block a user