[FFmpeg-devel] [PATCH] ffprobe: print non-time values like integer if they have no decimal part
Stefano Sabatini
stefasab at gmail.com
Mon Oct 24 02:40:02 CEST 2011
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)
+ snprintf(buf, buf_size, "%.3f%s%s%s", val, prefix_string || show_value_unit ? " " : "",
+ prefix_string, show_value_unit ? unit : "");
+ else
+ snprintf(buf, buf_size, "%d%s%s%s", (int)val, prefix_string || show_value_unit ? " " : "",
+ prefix_string, show_value_unit ? unit : "");
} else {
- snprintf(buf, buf_size, "%f%s%s", val, show_value_unit ? " " : "",
- show_value_unit ? unit : "");
+ if (val != (int)val)
+ snprintf(buf, buf_size, "%f%s%s", val, show_value_unit ? " " : "",
+ show_value_unit ? unit : "");
+ else
+ snprintf(buf, buf_size, "%d%s%s", (int)val, show_value_unit ? " " : "",
+ show_value_unit ? unit : "");
}
return buf;
--
1.7.4.1
More information about the ffmpeg-devel
mailing list