[FFmpeg-devel] [PATCH] ac3dec: fix non-optimal dithering of zero bit mantissas

Nicolas George nicolas.george at normalesup.org
Sat Jan 5 13:07:13 CET 2013


Le sextidi 16 nivôse, an CCXXI, Reimar Döffinger a écrit :
> See also the NOTES section of e.g. "man rand".

I do not have a NOTES sections in rand(3) from manpages-dev 3.42, but I
guess what it says.

> I think I get the idea, but I'm horrible at mathematical terms in
> English, I only ever learned that stuff with the German terms and a
> bit of French, and they translate really horribly I think...

You have the advantage on me, as I know nothing of maths in German. For
reference, let us use the universal language: C.

If a % b == 0, then for all x, (x % a) % b == x % b.

Therefore:

	static uint32_t state;
	state = state * 1664525 + 1013904223;
	return state;

has 1<<32 period, but:

	static uint32_t state;
	state = state * 1664525 + 1013904223;
	return state & 0x7F;

is equivalent to:

	static uint7_t state; /* I know it does not exist */
	state = state * 1664525 + 1013904223;
	return state;

or even:

	static uint7_t state;
	state = state * 13 + 95; /* 1664525 & 0x7F and 1013904223 & 0x7F */
	return state;

and therefore has at most 1<<7 = 128 period.

OTOH,

	static uint32_t state;
	state = state * 1664525 + 1013904223;
	return state % 11864549;

I am not sure, because av_gcd(1<<32, 11864549) = 1. (But note that you
suggested 11864550 rather than 11864549.)

Regards,

-- 
  Nicolas George
-------------- 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/20130105/a3ad1971/attachment.asc>


More information about the ffmpeg-devel mailing list