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 C6AD8423DA for ; Sun, 15 May 2022 19:19:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1270F68B4D1; Sun, 15 May 2022 22:19:21 +0300 (EEST) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6B24768B294 for ; Sun, 15 May 2022 22:19:14 +0300 (EEST) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id BAF65100004 for ; Sun, 15 May 2022 19:19:13 +0000 (UTC) Date: Sun, 15 May 2022 21:19:12 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220515191912.GP396728@pb2> References: <20220513154208.17941-1-leo.izen@gmail.com> <20220513212245.GN396728@pb2> <20220515185549.GO396728@pb2> MIME-Version: 1.0 In-Reply-To: <20220515185549.GO396728@pb2> Subject: Re: [FFmpeg-devel] [PATCH] avutil/csp: create public API for colorspace structs 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="===============3939121607841458500==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3939121607841458500== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YolNsh7G+K7zsfIR" Content-Disposition: inline --YolNsh7G+K7zsfIR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 15, 2022 at 08:55:49PM +0200, Michael Niedermayer wrote: > On Sun, May 15, 2022 at 12:49:51PM -0400, Ronald S. Bultje wrote: > > Hi, > >=20 > > On Fri, May 13, 2022 at 5:22 PM Michael Niedermayer > > wrote: > >=20 > > > On Fri, May 13, 2022 at 11:42:08AM -0400, Leo Izen wrote: > > > > This commit moves some of the functionality from avfilter/colorspace > > > > into avutil/csp and exposes it as a public API so it can be used by > > > > libavcodec and/or libavformat. > > > [...] > > > > diff --git a/libavutil/csp.h b/libavutil/csp.h > > > > new file mode 100644 > > > > index 0000000000..1bcde7ddd3 > > > > --- /dev/null > > > > +++ b/libavutil/csp.h > > > > @@ -0,0 +1,49 @@ > > > > +/* > > > > + * Copyright (c) 2016 Ronald S. Bultje > > > > + * This file is part of FFmpeg. > > > > + * > > > > + * FFmpeg is free software; you can redistribute it and/or > > > > + * modify it under the terms of the GNU Lesser General Public > > > > + * License as published by the Free Software Foundation; either > > > > + * version 2.1 of the License, or (at your option) any later versi= on. > > > > + * > > > > + * FFmpeg is distributed in the hope that it will be useful, > > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the G= NU > > > > + * Lesser General Public License for more details. > > > > + * > > > > + * You should have received a copy of the GNU Lesser General Public > > > > + * License along with FFmpeg; if not, write to the Free Software > > > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > > 02110-1301 USA > > > > + */ > > > > + > > > > +#ifndef AVUTIL_CSP_H > > > > +#define AVUTIL_CSP_H > > > > + > > > > +#include "libavutil/frame.h" > > > > +#include "libavutil/pixfmt.h" > > > > + > > > > +struct LumaCoefficients { > > > > + double cr, cg, cb; > > > > +}; > > > > + > > > > +struct PrimaryCoefficients { > > > > + double xr, yr, xg, yg, xb, yb; > > > > +}; > > > > + > > > > +struct WhitepointCoefficients { > > > > + double xw, yw; > > > > +}; > > > > > > I think we should avoid floating point so as to ensure reproduceable > > > results and simplify regerssion testing > > > > >=20 > > To explain: when I designed this stuff, I chose to keep them in float so > > that we can use the literal values from the specs, which are themselves= in > > floating point. That would not be possible anymore, and would therefore > > make it slightly harder to read for a casual observer. > >=20 > > (Otherwise no opinion, I'm typically used to fixed-point rather than > > floating-point myself also.) >=20 > I looked at Rec. ITU-T H.264 (02/2016) (was the first thing laying around, > i assume but did not check that this matches the specs these numbers came= from) >=20 > (randomly picking "whitepoints") > the whitepoints for "10" contain some 1/3 values > but if i just look at "1" the values are > 0.3127, 0.3290 > i dont think these can be represented as m*2^E either > 3127/10000 =3D m*2^E > 3127 * 2^-E =3D m * 10000 > both sides would be all integers > the right side contains 5 as factor, the left doesnt >=20 > of course i may be missing something Also for extra entertainment try this: #include #include int main(int argc, char **argv) { float exact_tenth =3D 0.1; double done =3D 1.0; float fone =3D 1.0; int i; for(i=3D 0; i<100000000; i++) { done *=3D exact_tenth * 10.0; fone *=3D exact_tenth * 10.0; } printf("float one is %f double one is %f\n", fone, done); return 0; } [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. --YolNsh7G+K7zsfIR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYoFSLQAKCRBhHseHBAsP q5y6AJwNMNxO6eWHYqjKflIhpPCZklXlQgCeMOcpt52eKofqwzkea8nVpdX5JAM= =T/I5 -----END PGP SIGNATURE----- --YolNsh7G+K7zsfIR-- --===============3939121607841458500== 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". --===============3939121607841458500==--