[FFmpeg-devel] [PATCH] avutil/eval: add function to track variable use

Nicolas George george at nsup.org
Tue Nov 5 16:10:13 EET 2019


Gyan (12019-11-05):
> An example of a cross-referenced expression would be 'y=x+rand(10)'. 
> Normally in filters, X would be evaluated first, then Y, then X again. The
> 2nd eval of X will overwrite the first and can generate a different value.
> With this func, we can avoid the 2nd eval.
> 
> I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
> variables in frame eval mode (it already supports dynamic output based on
> incoming frame changes) and I would like to catch their presence in init
> mode, since av_expr_eval will fail. Now, it can also fail due to circularly
> referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
> detect whether it's this case or if inapplicable variables have been used.

Then I would prefer that we wait for that to be done and working to
commit this patch. After all, it is entirely possible that you realize
this is not exactly what you need to achieve your goal.

Also, you may consider if it would be worthwhile to globally improve the
expression system: maybe have a context with dedicated structure to
define the variables and custom functions instead of just arrays that
needs to have the same size.

The scale filter is not the only one with multiple expression
evaluation, it would be a waste if the simplification was not applicable
to all cases easily.

(Also, the possibility to define user variables would be nice. But that
would require re-writing most of the parser. It needs doing anyway, but
it is a huge work.)

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191105/0460a0ca/attachment.sig>


More information about the ffmpeg-devel mailing list