[FFmpeg-devel] [PATCH] Add a gamma flag to exr loader to avoid banding

Michael Niedermayer michaelni at gmx.at
Sun May 4 04:45:44 CEST 2014

On Sat, May 03, 2014 at 05:22:15PM -0300, Gonzalo Garramuno wrote:
> On 02/05/14 19:54, Michael Niedermayer wrote:
> >still fails
> >both on x86_64 as well as arm32, it also fails differently on both
> >gamma_table differs between the 2
> >first difference is at index 256, where one is 0 and the other 1
> >last difference is at index 1023
> I reverted to the previous patch that kept the negative values and I
> am attaching it again without any changes.
> However, I am puzzled it fails on x86_64 as that's exactly the
> architecture I am developing on.  Are you trying it on Windows or
> FreeBSD?  I am running it on Ubuntu without problems on gcc4.7.

ubuntu gcc 4.6.3

> Find also attached an utility that creates the gamma table in
> /usr/tmp.  Place it in the main ffmpeg tree and compile with gcc
> gamma.c -o gamma -lm.  That should help us isolate the problem areas
> in the table.

> /*
> Place me at the root of ffmpeg as gamma.c and try compiling me with:
> gcc gamma.c -o gamma -lm

gcc gamma.c  -o gamma -lm
Segmentation fault (core dumped)
(user apps have no buisness writing to usr, in fact /usr could be
 physically read only)

also to debug the float issue, id suggest that you check that your
implementation is stable

one way to do that is
by adding a random small value to every non interger
that is
for example replace
o.f *= magic.f; /* exponent adjust */
if (o.f >= was_infnan.f) /* make sure Inf/NaN survive */

magic.f += random_small()
o.f += random_small()
o.f *= magic.f; /* exponent adjust */
o.f += random_small()
if (o.f + random_small() >= was_infnan.f + random_small()) /* make sure Inf/NaN survive */

with random_small() returning a random value so that it would change
the lowest 2-3 bits of the float which are still stored

do this for every use of floats or doubles
also dont assume that using the same expression twice
must evaluate to the same value, theres no such gurantee in C with

and then make sure the code gives binary identical output still
which may be tricky

alternatively you could use integers instead of floats, to generate
the table
see tests/tiny_psnr.c for fixed point log and exp for example


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140504/5653dbf1/attachment.asc>

More information about the ffmpeg-devel mailing list