[FFmpeg-devel] [PATCH] lavfi/testsrc2: fix completely transparent alpha.

Nicolas George george at nsup.org
Mon Jul 24 14:02:15 EEST 2017


Le sextidi 6 thermidor, an CCXXV, Carl Eugen Hoyos a écrit :
> > Oh, you mean a gradient on the alpha channel. It is not really possible
> > without making the code more complex and I think significantly slower.
> 
> > A coarse gradient between the different vertical bands is easy, but the
> > alpha must be constant in each band, just like the color.
> 
> (Why?)

Because memset() is faster and simpler than anything else that could do
the work. testsrc2 is based on the drawutils functions, which provide a
few drawing primitives, especially rectangles. They are limited in
features but are fast and support many pixel formats with little code.

> Any change that provides different transparency values on one frame is
> a useful fix for a long-standing bug / missing feature imo.

Note that with the current patch, while most of the drawing has constant
alpha, the beating cross and bouncing square ball are fully opaque, so
there are already two alpha values. It is better than nothing.

I suggest we apply the patch as is, since it allows the overlay test to
move forward. And then we can consider how to add an interesting alpha
channel for better testing.

Is it ok with you?


For the alpha, I suggest the following:

Somebody should implement an animated plasma (fractal) generator. I have
been meaning to do that for some time, but I have not yet found an
elegant and efficient way to dot, and copying somebody else's algorithm
when I think I can devise my own is not my style.

If that happens, we can use a gray plasma as the alpha channel of
testsrc2 for planar modes, either with the alphamerge filter or with
easy additional code. It would be a matter of minutes to implement that
as an option.

For the plasma generator, my idea is to use a deterministic 3D pink-ish
noise generator: the screen is a slice of a x-y plane at z=PTS.

For the pink-ish noise, I consider the following algorithm: Select
random values at a certain interval/frequency, and make a linear
interpolation between, that yields a random zigzag signal. Do the same
at half interval / double frequency, quarter interval / quadruple
frequency, etc., until the sampling precision is reached, and add all
the random zigzags together. The relative amplitudes of the frequency
bands determine the color of the noise: constant amplitude over the
audible frequencies yields a rather good pink noise. Maybe, on top of
that, apply soft-clipping to be able to generate a signal with a decent
amplitude without clipping.

For multidimensional plasma, instead of zigzaging between random values
at regular interval, it must select random values on a regular grid and
interpolate with the multilinear fit. But because of that, the values
cannot be selected in order and then discarded, it requires either
caching the values or re-generating them deterministically.

If somebody has a very fast parametric PRNG to suggest, it would be
helpful. By parametric, I mean: rand(x,y,z,f) -> a number, always the
same for the same values of (x,y,z,f) but with all the properties of a
PRNG as soon as any parameter changes.

Anyway, if anybody wants to implement a plasma or any kind of
deterministic nice-looking animated gradient, it would be helpful for
the project.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170724/35694ed4/attachment.sig>


More information about the ffmpeg-devel mailing list