[FFmpeg-devel] [PATCH] ffprobe: print non-time values like integer if they have no decimal part
stefasab at gmail.com
Sun Nov 6 14:07:10 CET 2011
On date Monday 2011-10-24 04:10:31 +0200, Michael Niedermayer encoded:
> On Mon, Oct 24, 2011 at 02:40:02AM +0200, Stefano Sabatini wrote:
> > Prettify, simplify parsing for integer values.
> > ---
> > ffprobe.c | 16 ++++++++++++----
> > 1 files changed, 12 insertions(+), 4 deletions(-)
> > diff --git a/ffprobe.c b/ffprobe.c
> > index 5913d60..c21c57c 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -90,11 +90,19 @@ static char *value_string(char *buf, int buf_size, double val, const char *unit)
> > prefix_string = decimal_unit_prefixes[index];
> > }
> > - snprintf(buf, buf_size, "%.3f%s%s%s", val, prefix_string || show_value_unit ? " " : "",
> > - prefix_string, show_value_unit ? unit : "");
> > + if (val != (int)val)
> i think this can crash with nan/inf
According to C spec:
220.127.116.11 Real floating and integer
1 When a finite value of real floating type is converted to an integer type other than _Bool,
the fractional part is discarded (i.e., the value is truncated toward zero). If the value of
the integral part cannot be represented by the integer type, the behavior is undefined.
so in case of NAN/Inf/out-of-range value the behavior is undefined,
but I assume that the (int)val will be different from val in any case.
I can still add checks for that if you don't consider my assumption
Patch updated with some factorization.
FFmpeg = Free and Fundamentalist MultiPurpose ExchanGer
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1848 bytes
Desc: not available
More information about the ffmpeg-devel