[FFmpeg-cvslog] avfilter/f_metadata: fix few logic errors

Paul B Mahol git at videolan.org
Wed Feb 10 11:50:18 CET 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Feb 10 11:47:52 2016 +0100| [408ea50ca6bcc666babc8b8e654eb135164480af] | committer: Paul B Mahol

avfilter/f_metadata: fix few logic errors

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=408ea50ca6bcc666babc8b8e654eb135164480af
---

 doc/filters.texi         |    4 ++--
 libavfilter/f_metadata.c |   12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 56de876..6c5003f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8501,13 +8501,13 @@ Values are interpreted as strings, returns true if @code{value} is same as metad
 to N chars as set in @code{length} option.
 
 @item less
-Values are interpreted as floats, returns true if @code{value} is less than metadata value.
+Values are interpreted as floats, returns true if metadata value is less than @code{value}.
 
 @item equal
 Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
 
 @item greater
-Values are interpreted as floats, returns true if @code{value} is greater than metadata value.
+Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
 
 @item expr
 Values are interpreted as floats, returns true if expression from option @code{expr}
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index 1969cb5..40ab6bb 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -127,7 +127,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;
 }
 
 static int greater(MetadataContext *s, const char *value1, const char *value2, size_t length)
@@ -137,7 +137,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 f1 > f2;
 }
 
 static int parse_expr(MetadataContext *s, const char *value1, const char *value2, size_t length)
@@ -148,7 +148,7 @@ static int parse_expr(MetadataContext *s, const char *value1, const char *value2
         return 0;
 
     s->var_values[VAR_VALUE1] = f1;
-    s->var_values[VAR_VALUE1] = f2;
+    s->var_values[VAR_VALUE2] = f2;
 
     return av_expr_eval(s->expr, s->var_values, NULL);
 }
@@ -223,7 +223,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         if (!s->value && e && e->value) {
             return ff_filter_frame(outlink, frame);
         } else if (s->value && e && e->value &&
-                   s->compare(s, s->value, e->value, s->length)) {
+                   s->compare(s, e->value, s->value, s->length)) {
             return ff_filter_frame(outlink, frame);
         }
         break;
@@ -248,14 +248,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
             while ((e = av_dict_get(metadata, "", e, AV_DICT_IGNORE_SUFFIX)) != NULL) {
                 av_log(ctx, AV_LOG_INFO, "%s=%s\n", e->key, e->value);
             }
-        } else if (e && e->value && (!s->value || (e->value && s->compare(s, s->value, e->value, s->length)))) {
+        } else if (e && e->value && (!s->value || (e->value && s->compare(s, e->value, s->value, s->length)))) {
             av_log(ctx, AV_LOG_INFO, "frame %"PRId64" pts %"PRId64"\n", inlink->frame_count, frame->pts);
             av_log(ctx, AV_LOG_INFO, "%s=%s\n", s->key, e->value);
         }
         return ff_filter_frame(outlink, frame);
         break;
     case METADATA_DELETE:
-        if (e && e->value && s->value && s->compare(s, s->value, e->value, s->length)) {
+        if (e && e->value && s->value && s->compare(s, e->value, s->value, s->length)) {
             av_dict_set(&metadata, s->key, NULL, 0);
         } else if (e && e->value) {
             av_dict_set(&metadata, s->key, NULL, 0);



More information about the ffmpeg-cvslog mailing list