From patchwork Sat Oct 1 12:53:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 801 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp722546vsd; Sat, 1 Oct 2016 05:54:30 -0700 (PDT) X-Received: by 10.28.129.145 with SMTP id c139mr2354666wmd.102.1475326470487; Sat, 01 Oct 2016 05:54:30 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 14si10078470wmn.119.2016.10.01.05.54.29; Sat, 01 Oct 2016 05:54:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F15E768A065; Sat, 1 Oct 2016 15:54:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F042A68A03E for ; Sat, 1 Oct 2016 15:54:03 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5A9231017B9; Sat, 1 Oct 2016 14:54:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7t3qijkVDYhe; Sat, 1 Oct 2016 14:54:16 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0D16E1017A4; Sat, 1 Oct 2016 14:54:16 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Oct 2016 14:53:56 +0200 Message-Id: <1475326436-17647-2-git-send-email-cus@passwd.hu> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1475326436-17647-1-git-send-email-cus@passwd.hu> References: <1475326436-17647-1-git-send-email-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/metadata: allow deleting all metadata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/filters.texi | 5 +++-- libavfilter/f_metadata.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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);