diff mbox

[FFmpeg-devel,2/2] lavfi/metadata: allow deleting all metadata

Message ID 1475326436-17647-2-git-send-email-cus@passwd.hu
State Accepted
Commit 7ef3e5b593fb984b318d971421a7e687ca69d536
Headers show

Commit Message

Marton Balint Oct. 1, 2016, 12:53 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 doc/filters.texi         | 5 +++--
 libavfilter/f_metadata.c | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Paul B Mahol Oct. 1, 2016, 1:46 p.m. UTC | #1
On 10/1/16, Marton Balint <cus@passwd.hu> wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  doc/filters.texi         | 5 +++--
>  libavfilter/f_metadata.c | 6 ++++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
>

lgtm
Marton Balint Oct. 1, 2016, 3:39 p.m. UTC | #2
On Sat, 1 Oct 2016, Paul B Mahol wrote:
> On 10/1/16, Marton Balint <cus@passwd.hu> wrote:
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  doc/filters.texi         | 5 +++--
>>  libavfilter/f_metadata.c | 6 ++++--
>>  2 files changed, 7 insertions(+), 4 deletions(-)
>>
>
> lgtm

Pushed, thanks.

Marton
diff mbox

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 9d51757..4b2f7bf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16059,7 +16059,8 @@  Modify value of already present key.
 
 @item delete
 If @code{value} is set, delete only keys that have such value.
-Otherwise, delete key.
+Otherwise, delete key. If @code{key} is not set, delete all metadata values in
+the frame.
 
 @item print
 Print key and its value if metadata was found. If @code{key} is not set print all
@@ -16067,7 +16068,7 @@  metadata values available in frame.
 @end table
 
 @item key
-Set key used with all modes. Must be set for all modes except @code{print}.
+Set key used with all modes. Must be set for all modes except @code{print} and @code{delete}.
 
 @item value
 Set metadata value which will be used. This option is mandatory for
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index 1fe713c..f4a929c 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -194,7 +194,7 @@  static av_cold int init(AVFilterContext *ctx)
     MetadataContext *s = ctx->priv;
     int ret;
 
-    if (!s->key && s->mode != METADATA_PRINT) {
+    if (!s->key && s->mode != METADATA_PRINT && s->mode != METADATA_DELETE) {
         av_log(ctx, AV_LOG_WARNING, "Metadata key must be set\n");
         return AVERROR(EINVAL);
     }
@@ -328,7 +328,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         return ff_filter_frame(outlink, frame);
         break;
     case METADATA_DELETE:
-        if (e && e->value && s->value && s->compare(s, e->value, s->value)) {
+        if (!s->key) {
+            av_dict_free(metadata);
+        } else if (e && e->value && s->value && s->compare(s, e->value, s->value)) {
             av_dict_set(metadata, s->key, NULL, 0);
         } else if (e && e->value) {
             av_dict_set(metadata, s->key, NULL, 0);