diff options
author | Tobias Rapp <t.rapp@noa-archive.com> | 2016-02-11 13:35:19 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-02-11 13:47:25 +0100 |
commit | 8b99c5e8daf27c8198df4061eef0ac8b193e1b73 (patch) | |
tree | a82878b039f3eae8ec982374f2cba8316370ea94 /libavfilter | |
parent | ac3a275d1e0da79b1dd8c5d2bb98e4b9456615e0 (diff) | |
download | ffmpeg-8b99c5e8daf27c8198df4061eef0ac8b193e1b73.tar.gz |
avfilter/f_metadata: avoid float rounding problems
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/f_metadata.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c index 40ab6bb174..e0ea30b951 100644 --- a/libavfilter/f_metadata.c +++ b/libavfilter/f_metadata.c @@ -23,6 +23,8 @@ * filter for manipulating frame metadata */ +#include <float.h> + #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" @@ -117,7 +119,7 @@ static int equal(MetadataContext *s, const char *value1, const char *value2, siz if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2) return 0; - return f1 == f2; + return fabsf(f1 - f2) < FLT_EPSILON; } static int less(MetadataContext *s, const char *value1, const char *value2, size_t length) @@ -127,7 +129,7 @@ static int less(MetadataContext *s, const char *value1, const char *value2, size if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2) return 0; - return f1 < f2; + return (f1 - f2) < FLT_EPSILON; } static int greater(MetadataContext *s, const char *value1, const char *value2, size_t length) @@ -137,7 +139,7 @@ static int greater(MetadataContext *s, const char *value1, const char *value2, s if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2) return 0; - return f1 > f2; + return (f2 - f1) < FLT_EPSILON; } static int parse_expr(MetadataContext *s, const char *value1, const char *value2, size_t length) |