ffmpeg | branch: master | Tobias Rapp <t.r...@noa-archive.com> | Thu Feb 11 
13:35:20 2016 +0100| [6889deba68fcc3d9f1015f10392dea38b2fcd028] | committer: 
Paul B Mahol

avfilter/f_metadata: add starts_with string function

Signed-off-by: Tobias Rapp <t.r...@noa-archive.com>

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

 doc/filters.texi         |    4 ++++
 libavfilter/f_metadata.c |   10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8f4dcea..8264498 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8500,6 +8500,10 @@ Can be one of following:
 Values are interpreted as strings, returns true if @code{value} is same as 
metadata value up
 to N chars as set in @code{length} option.
 
+@item starts_with
+Values are interpreted as strings, returns true if metadata value starts with
+the @code{value} option string.
+
 @item less
 Values are interpreted as floats, returns true if metadata value is less than 
@code{value}.
 
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index 9246a2a..6c9317a 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -49,6 +49,7 @@ enum MetadataMode {
 
 enum MetadataFunction {
     METADATAF_STRING,
+    METADATAF_STARTS_WITH,
     METADATAF_LESS,
     METADATAF_EQUAL,
     METADATAF_GREATER,
@@ -102,6 +103,7 @@ static const AVOption filt_name##_options[] = {             
        \
     { "value", "set metadata value",     OFFSET(value),  AV_OPT_TYPE_STRING, 
{.str = NULL }, 0, 0, FLAGS }, \
     { "function", "function for comparing values", OFFSET(function), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATAF_NB-1, FLAGS, "function" }, \
     {   "string",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_STRING  }, 0, 
3, FLAGS, "function" }, \
+    {   "starts_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
METADATAF_STARTS_WITH }, 0, 0, FLAGS, "function" }, \
     {   "less",    NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_LESS    }, 0, 
3, FLAGS, "function" }, \
     {   "equal",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EQUAL   }, 0, 
3, FLAGS, "function" }, \
     {   "greater", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_GREATER }, 0, 
3, FLAGS, "function" }, \
@@ -117,6 +119,11 @@ static int string(MetadataContext *s, const char *value1, 
const char *value2, si
     return !strncmp(value1, value2, length);
 }
 
+static int starts_with(MetadataContext *s, const char *value1, const char 
*value2, size_t length)
+{
+    return !strncmp(value1, value2, strlen(value2));
+}
+
 static int equal(MetadataContext *s, const char *value1, const char *value2, 
size_t length)
 {
     float f1, f2;
@@ -201,6 +208,9 @@ static av_cold int init(AVFilterContext *ctx)
     case METADATAF_STRING:
         s->compare = string;
         break;
+    case METADATAF_STARTS_WITH:
+        s->compare = starts_with;
+        break;
     case METADATAF_LESS:
         s->compare = less;
         break;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to