@@ -48,7 +48,7 @@ enum MetadataMode {
48
48
};
49
49
50
50
enum MetadataFunction {
51
- METADATAF_STRING ,
51
+ METADATAF_SAME_STR ,
52
52
METADATAF_STARTS_WITH ,
53
53
METADATAF_LESS ,
54
54
METADATAF_EQUAL ,
@@ -75,7 +75,6 @@ typedef struct MetadataContext {
75
75
int mode ;
76
76
char * key ;
77
77
char * value ;
78
- int length ;
79
78
int function ;
80
79
81
80
char * expr_str ;
@@ -86,7 +85,7 @@ typedef struct MetadataContext {
86
85
char * file_str ;
87
86
88
87
int (* compare )(struct MetadataContext * s ,
89
- const char * value1 , const char * value2 , size_t length );
88
+ const char * value1 , const char * value2 );
90
89
void (* print )(AVFilterContext * ctx , const char * msg , ...) av_printf_format (2 , 3 );
91
90
} MetadataContext ;
92
91
@@ -102,29 +101,28 @@ static const AVOption filt_name##_options[] = { \
102
101
{ "key", "set metadata key", OFFSET(key), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
103
102
{ "value", "set metadata value", OFFSET(value), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
104
103
{ "function", "function for comparing values", OFFSET(function), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATAF_NB-1, FLAGS, "function" }, \
105
- { "string ", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_STRING }, 0, 3, FLAGS, "function" }, \
104
+ { "same_str ", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_SAME_STR }, 0, 3, FLAGS, "function" }, \
106
105
{ "starts_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_STARTS_WITH }, 0, 0, FLAGS, "function" }, \
107
106
{ "less", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_LESS }, 0, 3, FLAGS, "function" }, \
108
107
{ "equal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EQUAL }, 0, 3, FLAGS, "function" }, \
109
108
{ "greater", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_GREATER }, 0, 3, FLAGS, "function" }, \
110
109
{ "expr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EXPR }, 0, 3, FLAGS, "function" }, \
111
110
{ "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
112
- { "length", "compare up to N chars for string function", OFFSET(length), AV_OPT_TYPE_INT, {.i64 = INT_MAX }, 1, INT_MAX, FLAGS }, \
113
111
{ "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
114
112
{ NULL } \
115
113
}
116
114
117
- static int string (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
115
+ static int same_str (MetadataContext * s , const char * value1 , const char * value2 )
118
116
{
119
- return !strncmp (value1 , value2 , length );
117
+ return !strcmp (value1 , value2 );
120
118
}
121
119
122
- static int starts_with (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
120
+ static int starts_with (MetadataContext * s , const char * value1 , const char * value2 )
123
121
{
124
122
return !strncmp (value1 , value2 , strlen (value2 ));
125
123
}
126
124
127
- static int equal (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
125
+ static int equal (MetadataContext * s , const char * value1 , const char * value2 )
128
126
{
129
127
float f1 , f2 ;
130
128
@@ -134,7 +132,7 @@ static int equal(MetadataContext *s, const char *value1, const char *value2, siz
134
132
return fabsf (f1 - f2 ) < FLT_EPSILON ;
135
133
}
136
134
137
- static int less (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
135
+ static int less (MetadataContext * s , const char * value1 , const char * value2 )
138
136
{
139
137
float f1 , f2 ;
140
138
@@ -144,7 +142,7 @@ static int less(MetadataContext *s, const char *value1, const char *value2, size
144
142
return (f1 - f2 ) < FLT_EPSILON ;
145
143
}
146
144
147
- static int greater (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
145
+ static int greater (MetadataContext * s , const char * value1 , const char * value2 )
148
146
{
149
147
float f1 , f2 ;
150
148
@@ -154,7 +152,7 @@ static int greater(MetadataContext *s, const char *value1, const char *value2, s
154
152
return (f2 - f1 ) < FLT_EPSILON ;
155
153
}
156
154
157
- static int parse_expr (MetadataContext * s , const char * value1 , const char * value2 , size_t length )
155
+ static int parse_expr (MetadataContext * s , const char * value1 , const char * value2 )
158
156
{
159
157
double f1 , f2 ;
160
158
@@ -205,8 +203,8 @@ static av_cold int init(AVFilterContext *ctx)
205
203
}
206
204
207
205
switch (s -> function ) {
208
- case METADATAF_STRING :
209
- s -> compare = string ;
206
+ case METADATAF_SAME_STR :
207
+ s -> compare = same_str ;
210
208
break ;
211
209
case METADATAF_STARTS_WITH :
212
210
s -> compare = starts_with ;
@@ -289,7 +287,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
289
287
if (!s -> value && e && e -> value ) {
290
288
return ff_filter_frame (outlink , frame );
291
289
} else if (s -> value && e && e -> value &&
292
- s -> compare (s , e -> value , s -> value , s -> length )) {
290
+ s -> compare (s , e -> value , s -> value )) {
293
291
return ff_filter_frame (outlink , frame );
294
292
}
295
293
break ;
@@ -314,14 +312,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
314
312
while ((e = av_dict_get (metadata , "" , e , AV_DICT_IGNORE_SUFFIX )) != NULL ) {
315
313
s -> print (ctx , "%s=%s\n" , e -> key , e -> value );
316
314
}
317
- } else if (e && e -> value && (!s -> value || (e -> value && s -> compare (s , e -> value , s -> value , s -> length )))) {
315
+ } else if (e && e -> value && (!s -> value || (e -> value && s -> compare (s , e -> value , s -> value )))) {
318
316
s -> print (ctx , "frame %" PRId64 " pts %" PRId64 "\n" , inlink -> frame_count , frame -> pts );
319
317
s -> print (ctx , "%s=%s\n" , s -> key , e -> value );
320
318
}
321
319
return ff_filter_frame (outlink , frame );
322
320
break ;
323
321
case METADATA_DELETE :
324
- if (e && e -> value && s -> value && s -> compare (s , e -> value , s -> value , s -> length )) {
322
+ if (e && e -> value && s -> value && s -> compare (s , e -> value , s -> value )) {
325
323
av_dict_set (& metadata , s -> key , NULL , 0 );
326
324
} else if (e && e -> value ) {
327
325
av_dict_set (& metadata , s -> key , NULL , 0 );
0 commit comments