[FFmpeg-devel] [RFC] av_set_string() semantics

Stefano Sabatini stefano.sabatini-lala
Sat May 24 12:00:27 CEST 2008


Hi all,

Setting a value for an option with av_set_string() for a number or a
flag option currently works like this:

* A '+' or '-' at the beginning of the value string cause the
  following value to be added to the *default* value for the option,
  that is for example:
  ffmpeg -foo +1

  sets the foo value to default+1

  while

  ffmpeg -foo -1
  sets the foo value to default-1.

  If you want to set the foo value to -1 you have to perform:
  ffmpeg -foo 0-1

  (BTW this behaviour was always true for flags options, and has been
  introduced for number values too by a recent commit by Michael, so I
  don't know if this is to be considered a bug or a feature...).
  
  Furthermore the evaluation of the value constraints for a number
  value is performed after the reading of each addend, so for example:
  ffmpeg -foo 0-n_1+n_2+n_3+...+n_N

  will fail if any of the partial sum S_i = Sum_j=1..n n_j doesn't
  respect the constraints for that value.

This behaviour looks to me very confusing, so my proposal is to change
the behaviour to this:

* A '-' or a '+' at the beginning of a string value doesn't have any
  special meaning, so for example:

  ffmpeg -foo -1
  sets foo to -1

  and
  ffmpeg -foo +1
  sets foo to +1.

  If you want to set foo to its default value +/- a certain value X you
  have to explicitly set it with:
  ffmpeg -foo default+X
  or 
  ffmpeg -foo default-X.

  The evaluation of the value constraints is performed after the
  reading of all the addends, so for example: 

  ffmpeg -foo 0-n_1+n_2+n_3+...+n_N

  will fail only if the total Sum_i=1..N n_i doesn't
  respect the constraints for that value.
  
If you agree with this change I'll provide a patch to implement such
behaviour, if we don't want to change the semantic of av_set_string()
we should at least document the current beahviour.

Best regards.
-- 
FFmpeg = Freak Fast MultiPurpose EnGine




More information about the ffmpeg-devel mailing list