[Ffmpeg-devel] [PATCH] Use ff_eval for AVOption parsing
Panagiotis Issaris
takis.issaris
Sat Sep 23 12:33:36 CEST 2006
Hi,
The attached patch changes the AVOption parsing code to use ff_eval
instead of av_strtod. As ff_eval uses av_strtod, the postfix ('k',
'M', ...) functionality is not lost.
It does this, by moving av_strtod to eval.c as this is the only place
where it is used now. Furthermore, one parser log message has been
decreased in severness as it kept complaining about missing '(' in
"bitexact", "fastint", etc. which are all parsed by eval now, and aren't
errors. Parsing failures were/are indicated by NAN (the infrastructure
was partly there, but they returned 0 not NAN). For the moment I've
only added the QP2LAMBDA option to the eval's constants, so that
ffmpeg -i src.avi -lmax 10*QP2LAMBDA dst.avi
would work. After I sent a patch to migrate lmax from OptionDef to
AVOptions that is.
One more thing is that I had to add four "if isnan returns" in the code,
because parsing would fail (segfault in fact) if parsing continued when
using "max", "default" or "min" as options:
ffmpeg -i src.avi -b max dst.avi
To be able to add these escapes, I introduced a temporary variable in
two out of four cases.
I am not sure I fully like this patch myself:
1. because of it is quiet intrusive imho, although splitting the patch
would result in broken code for most parts of it (except for the
escapes)
2. because of the added escapes, more precisely, because I do not fully
(in detail) understand the segfaults. Initially I thought it was because
of the continued operations on a double containing NAN, but it seemed
impossible that such would result in a _segfault_. I would think it
would just always result in NAN. Then I thought it might be because the
parser increases p->s++, and in some strange way there would be a
dereference somewhere causing the segfault. Anyway, I did not find the
exact reason for the segfault, but I am sending it anyway as I'm off for
lunch and shopping and hoped for some feedback on this patch.
eval.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
opt.c | 92 ++++++++++++++---------------------------------------------------
2 files changed, 96 insertions(+), 74 deletions(-)
With friendly regards,
Takis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pi-20060923T122055-ffmpeg-avoption_using_ff_eval.diff
Type: text/x-patch
Size: 6699 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060923/05eac720/attachment.bin>
More information about the ffmpeg-devel
mailing list