[FFmpeg-devel] [PATCH] avutil/eval: Use even better PRNG
Michael Niedermayer
michael at niedermayer.cc
Sat Jan 20 02:33:41 EET 2024
On Fri, Jan 19, 2024 at 09:53:46AM +0100, Michael Koch wrote:
> There is still a small problem with the random generator, but this has
> nothing to do with the recent changes.
> If the random() expression is used in the geq filter, then multiple pixels
> get the same sequence of random numbers.
> As can be shown with this command, where the frame has only two pixels:
>
> ffmpeg -loglevel repeat -f lavfi -i nullsrc=size=1x2,format=gray -vf
> "geq=lum='print(random(0));print(random(0));print(random(0))'" -frames 1 -y
> out.png
>
> I think it's because the filter is executed in multiple threads.
> -filter_threads 1 fixes the problem, but it slows down the whole filter
> thread.
You can avoid this by using
ifnot(X,st(0,Y))
which would reseed the random number generator differently on the first pixel of
each line
Not sure this is the best solution, better ideas are welcome
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Some people wanted to paint the bikeshed green, some blue and some pink.
People argued and fought, when they finally agreed, only rust was left.
-------------- 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/20240120/6a0040f0/attachment.sig>
More information about the ffmpeg-devel
mailing list