From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 085AA4C634 for ; Tue, 30 Jul 2024 21:32:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 94EFB68D7FF; Wed, 31 Jul 2024 00:32:40 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8F54368D412 for ; Wed, 31 Jul 2024 00:32:34 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id D82A71BF204 for ; Tue, 30 Jul 2024 21:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1722375154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=W/uzmezYW54BsTzHuIHRmHiTrdPR/SXLTVbPEYmfcnA=; b=T3scBWKJv7aJZah5VvNVOAerSssZiuu3e5uoleBm9/KwKSxoO7P8IVPy7Jl/mdUoXf2PiL I3t9Wr6LxLZBePOo/FIJiLYcEnsCnc6TqeccNoyvZ+gaSqw3+h1dhCMxIk65W1hT52eZF7 akKIYYCn9YjnJ4hEfJf8UHfxA46qb6sP6m8qIPdX6AVT+EnnmH+UhjVPKE5LFZNSgLjFND Ch7RHftkM6VBrNI3y/FLVT1a6mWPEFPPy560SzQW67UXzMUZFcyu4pCv+TVd5AK3uLKPfV XVil9ykZCProwSd+ijV+0NFTuZYTwagqvk2lzoNc5pRtMtabl5cqTbQZBwJXcA== Date: Tue, 30 Jul 2024 23:32:32 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240730213232.GQ4991@pb2> References: <20240730131149.210571-1-gmascellani@codeweavers.com> <20240730205452.GP4991@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 0/2] Interpret a degenerate SAR as 1/1. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============8825325276514096689==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8825325276514096689== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hDghOh9X1ppnsb4f" Content-Disposition: inline --hDghOh9X1ppnsb4f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 30, 2024 at 06:15:30PM -0300, James Almer wrote: > On 7/30/2024 5:54 PM, Michael Niedermayer wrote: > > On Tue, Jul 30, 2024 at 03:11:47PM +0200, Giovanni Mascellani wrote: > > > I came across some H.264 files in the wild whose SAR is set to > > > 20480/0. The files are provided by the Ubisoft game OddBallers, and > > > are seemingly accepted and played properly when the game is played on > > > Windows (thus using the Microsoft Media Foundations > > > implementation). > > >=20 > > > When running the game with Wine the files are ultimately decoded by > > > libavcodec (via GStreamer), and playback is broken. It seems that only > > > a frame each second or so (maybe the key frames? I didn't check) is > > > decoded and presented, the others are discarded. After dumping the > > > video, I ran it with ffplay and it has the same problem, and the > > > following message is emitted many times: > > >=20 > > > [h264 @ 0x7fd7301ef440] ignoring invalid SAR: 20480/1 > > >=20 > > > Interestingly the invalid SAR is dumped as 20480/1 (which would be > > > strange, but in princple legal), while the file has 20480/0 (which > > > doesn't make sense at all). Equally interestingly, the frames that are > > > presented are indeed presented with SAR 1/1, like they are on Windows. > > >=20 > > > The H.264 standard says that "When aspect_ratio_idc is equal to 0 or > > > sar_width is equal to 0 or sar_height is equal to 0, the sample aspect > > > ratio shall be considered unspecified by this Recommendation | > > > International Standard". Given the behavior on Windows it seems that > > > the de facto standard way to solve the missing specification is to > > > assume that SAR is 1/1, which is what my patches seek to do. > >=20 > > Why does playback fail ? > >=20 > > 1/1 and unspecified are different things, 0/0 would be unspecified >=20 > afair we use 0/1 for unspecified, since it prevents division by 0 without > having to worry about extra sanity checks. why this is a bad idea: if a rectangle W/H with unspecified AR is 0/1, now the H/W rectangle has 1/0 OTOH if you use 0/0 then both W/H and H/W are naturally 0/0 what about scaling? 0/1 scaled by a/b is 0/b, while 0/0 scaled by a/b is 0/0 what about adding ratios ? 0/1 + a/b =3D a/b (thats not unspecified anymore) OTOH 0/0 + a/b =3D 0/0 :) so people may argue about this, but 0/0 behaves much closer to unspecified = than 0/1 so fewer special cases are needed if 0/0 is used. And 0/1 really is 0 and 0 is not unspecified in a mathematical sense which is why it works so poorly = for that And in floats 0/0 is NaN which is again behaving much closer to unspecified. If you do an operation with a NaN the result is NaN, same as if you do an operation with a unspecified ratio, the result is unspecified Thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The smallest minority on earth is the individual. Those who deny=20 individual rights cannot claim to be defenders of minorities. - Ayn Rand --hDghOh9X1ppnsb4f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZqlb7QAKCRBhHseHBAsP q9eqAJ9o8A2LUM59drXCLLEWT1TOImp5TgCeP8tXgIiCcvHbusMgKXIRHcjQEFU= =CGXh -----END PGP SIGNATURE----- --hDghOh9X1ppnsb4f-- --===============8825325276514096689== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============8825325276514096689==--