From patchwork Sat May 18 16:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 48986 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3522898pzb; Sat, 18 May 2024 09:11:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUI1QpcGbFkXc/OaYgI7JF3s+kBKDD2+HihyVnjz2iFi9MlmUzx51+JTUFRCYWzpCspYncHru50qbcvS61JlnBVrJ6p+lAxQbc7w== X-Google-Smtp-Source: AGHT+IEwe0/rGqLfbu2347x8r2xwzfsGXIXlSTq5u2rvxk68C5E0Mf9FtoBl+xpvcS9Saoa+2fVY X-Received: by 2002:a50:9f8f:0:b0:572:a23d:7912 with SMTP id 4fb4d7f45d1cf-5734d5c2584mr16302433a12.13.1716048716702; Sat, 18 May 2024 09:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716048716; cv=none; d=google.com; s=arc-20160816; b=XmxaS3TRcMAihGlTCDa8dwAY5Ccu8Up7Y6KY0Bc9BGBvM+v6qRQWIU4dPnuL7oDYtB XRa9ObcKHGK6y10k17O6i3RN7t9BFDq3i4XbbCQDTBIWBfClwgH3GktKpHy1R3r9V424 34PhHIPxRFPMH5txA5Tyq9/xwGQaZkeNFbhV9mDzoOsnPSgvdyNc67Sr/9z0jXwVh2ye I0SDybpwnqBr0ypAjapzGkRjI603tYsYbk7QpNXy9EnYzPWqSJ5eRl4LCMtDch6pAd4i xoUQUJA3qmO7sBVYcWUM2/pnPue/8Dkf80L3bmF/c7AP5KOpSJS+gJShn4tiGajU+4AL Neaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=CTkyGL1yRe2WUa0lwNyB3Fy6t/j3HVWrHMJcothGRfI=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=L007/uOhEagLBRbOJhxOJzyoG+lNqXo1N2D3QnK2ZvpYs+SUj3kbmXC/iR8yQvH3+u Y6MMd7n8YB37xTcbzctvY42IgC3owT2mYiMitGGeBpWiemoc/wQSssZXW7p9YuxB9TIm jvl86J6t5nAHbjO37lXs7EpYWBfGa7HnHIABLw8ruzBQ8FyzEJI+bbbQzJYRRXNMcARN KSHp3GxKreqZ7jUyH9oPIslUMxzWmPrZFOKDaCI5fJ8Bj3qxKC4SKZivTRn5QXU+/SvR H+f1yXTPcB4U1KMdPPIAX0MeLds70P9SPJq6npecK/lvST2FhCzFhbRDAk2xvNZshG8d YuuQ==; dara=google.com ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5733c2d5363si11241605a12.320.2024.05.18.09.11.56; Sat, 18 May 2024 09:11:56 -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 3CF4568CF47; Sat, 18 May 2024 19:11:37 +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 C8DAA68C094 for ; Sat, 18 May 2024 19:11:29 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A47A7EA694; Sat, 18 May 2024 18:11:29 +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 rPcPq-k7Y-y2; Sat, 18 May 2024 18:11:27 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9BDE5EA69C; Sat, 18 May 2024 18:11:26 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 18:11:14 +0200 Message-Id: <20240518161116.8661-3-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240518161116.8661-1-cus@passwd.hu> References: <20240518161116.8661-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] fftools: move check_avoptions and remove_avoptions to cmdutils X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2wNodknGWfDd Signed-off-by: Marton Balint --- fftools/cmdutils.c | 20 ++++++++++++++++++++ fftools/cmdutils.h | 6 ++++++ fftools/ffmpeg.c | 20 -------------------- fftools/ffmpeg.h | 3 --- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index a8f5c6d89b..8953b21e23 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1146,3 +1146,23 @@ char *file_read(const char *filename) return NULL; return str; } + +void remove_avoptions(AVDictionary **a, AVDictionary *b) +{ + const AVDictionaryEntry *t = NULL; + + while ((t = av_dict_iterate(b, t))) { + av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE); + } +} + +int check_avoptions(AVDictionary *m) +{ + const AVDictionaryEntry *t; + if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); + return AVERROR_OPTION_NOT_FOUND; + } + + return 0; +} diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d0c773663b..2125f791d0 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -483,4 +483,10 @@ double get_rotation(const int32_t *displaymatrix); /* read file contents into a string */ char *file_read(const char *filename); +/* Remove keys in dictionary b from dictionary a */ +void remove_avoptions(AVDictionary **a, AVDictionary *b); + +/* Check if any keys exist in dictionary m */ +int check_avoptions(AVDictionary *m); + #endif /* FFTOOLS_CMDUTILS_H */ diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1f50ed6805..88ce3007e8 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -473,26 +473,6 @@ const FrameData *packet_data_c(AVPacket *pkt) return ret < 0 ? NULL : (const FrameData*)pkt->opaque_ref->data; } -void remove_avoptions(AVDictionary **a, AVDictionary *b) -{ - const AVDictionaryEntry *t = NULL; - - while ((t = av_dict_iterate(b, t))) { - av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE); - } -} - -int check_avoptions(AVDictionary *m) -{ - const AVDictionaryEntry *t; - if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { - av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); - return AVERROR_OPTION_NOT_FOUND; - } - - return 0; -} - void update_benchmark(const char *fmt, ...) { if (do_benchmark_all) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 885a7c0c10..fe75706afd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -710,9 +710,6 @@ void term_exit(void); void show_usage(void); -void remove_avoptions(AVDictionary **a, AVDictionary *b); -int check_avoptions(AVDictionary *m); - int assert_file_overwrite(const char *filename); AVDictionary *strip_specifiers(const AVDictionary *dict); int find_codec(void *logctx, const char *name,