[Ffmpeg-devel] [PATCH] Apple Video Encoder (rpza)

Mike Melanson mike
Mon Jun 6 19:04:27 CEST 2005

Todd Kirby wrote:
> Ok, most of this stuff is easy but, what is the alternative to random?
> Is this a new requirement? I see lots of uses of random in the
> libraries.

	I believe one of the overriding goals here is repeatability. It helps 
for testing and validation. Using random numbers makes this difficult. 
Even when using the same random seeds, I am not sure if the ANSI C spec 
requires the actual random number generator to be implemented the same 
way on different platforms.

	I looked at the way random() is used in the video encoder:

+    r = (uint32_t)rgb24[0] + (uint32_t)(random() % 8);
+    g = (uint32_t)rgb24[1] + (uint32_t)(random() % 8);
+    b = (uint32_t)rgb24[2] + (uint32_t)(random() % 8);

+            int channel_value = color[channel] + ((random() % range) / 
3.0) - (range / 6.0);

To get around using random(), maybe you could just write a program to 
generate a static table of random values from 0..7. Copy the text of 
those tables into the source and just iterate through the values, 
wrapping when you hit the end. Encoding results should be repeatable.

	-Mike Melanson

More information about the ffmpeg-devel mailing list