This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit e598463b3d3b7703f7578a74e9ee695c3e2e6b00
Author:     Jun Zhao <[email protected]>
AuthorDate: Sun Jun 7 21:17:30 2026 +0800
Commit:     James Almer <[email protected]>
CommitDate: Sun Jun 7 18:55:16 2026 +0000

    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 <[email protected]>.
    Fixes: ticket #23321
    
    Signed-off-by: Jun Zhao <[email protected]>
---
 libavcodec/h2645_vui.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/h2645_vui.c b/libavcodec/h2645_vui.c
index 0e576c1563..fb16ec99e6 100644
--- a/libavcodec/h2645_vui.c
+++ b/libavcodec/h2645_vui.c
@@ -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);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to