[FFmpeg-devel] [PATCH v4] avutil/csp: create avpriv API for colorspace structs
Michael Niedermayer
michael at niedermayer.cc
Fri May 20 16:11:43 EEST 2022
Hi Ronald
On Fri, May 20, 2022 at 07:26:56AM -0400, Ronald S. Bultje wrote:
> Hi Michael,
>
> On Fri, May 20, 2022 at 6:28 AM Michael Niedermayer <michael at niedermayer.cc>
> wrote:
>
> > 1. exactly representing values
> >
>
> This isn't actually what I meant when I made the argument. If the spec says
> "0.137", I'd expect to be able to git grep the source code for "0.137" and
> find where it's defined. This is lost with AVRational, where it becomes {
> 137, 1000 }. This may sound silly, but I find this helpful.
>
> One way to address this is to add the exact value in a comment, like
> "(AVRational) { 137, 1000 }, // 0.137". This isn't pretty but retains
> grep-discoverability.
We use fixed point numbers in multiple places without
loosing grep-discoverability
for example
libavcodec/mpegaudiotab.h: FIX(0.54119610014619701222),
libavcodec/mpegaudiotab.h: FIX(1.3065629648763763537),
libavcodec/mpegaudiotab.h: FIX(0.50979557910415917998),
libavcodec/mpegaudiotab.h: FIX(2.5629154477415054814),
libavcodec/mpegaudiotab.h: FIX(0.89997622313641556513),
libavcodec/mpegaudiotab.h: FIX(0.60134488693504528634),
libavcodec/mpegaudiotab.h: FIX(0.5024192861881556782),
libavcodec/jfdctint_template.c:#define FIX_0_765366865 FIX(0.765366865)
libavcodec/jfdctint_template.c:#define FIX_0_899976223 FIX(0.899976223)
libavcodec/jfdctint_template.c:#define FIX_1_175875602 FIX(1.175875602)
libavcodec/jfdctint_template.c:#define FIX_1_501321110 FIX(1.501321110)
libavcodec/jfdctint_template.c:#define FIX_1_847759065 FIX(1.847759065)
libavcodec/jfdctint_template.c:#define FIX_1_961570560 FIX(1.961570560)
libavcodec/dcadata.c: SCALE(0.01112466771), SCALE(0.43016362190), SCALE(0.53190881014), SCALE(0.02678431384),
libavcodec/dcadata.c: SCALE(0.01170534454), SCALE(0.43572667241), SCALE(0.52686679363), SCALE(0.02568206564),
libavcodec/dcadata.c: SCALE(0.01230939943), SCALE(0.44127810001), SCALE(0.52177828550), SCALE(0.02461459488),
libavcodec/dcadata.c: SCALE(0.01293735672), SCALE(0.44681602716), SCALE(0.51664537191), SCALE(0.02358125709),
libavcodec/dcadata.c: SCALE(0.01358995494), SCALE(0.45233830810), SCALE(0.51147013903), SCALE(0.02258131653),
libavcodec/dcadata.c: SCALE(0.01426773332), SCALE(0.45784294605), SCALE(0.50625455379), SCALE(0.02161412500),
tests/utils.c: lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
tests/utils.c: FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
tests/utils.c: lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
tests/utils.c: FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
tests/utils.c: lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
tests/utils.c: FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
tests/utils.c: lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
tests/utils.c: FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
such a macro could produce a AVRational too easily (if wanted)
the advantage over a comment is that a comment can be forgotten
the argument for a macro cannot be forgotten and still succeed build
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220520/4caedde5/attachment.sig>
More information about the ffmpeg-devel
mailing list