From patchwork Wed Nov 22 13:32:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "pkv.stream" X-Patchwork-Id: 6268 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp172675jah; Wed, 22 Nov 2017 05:32:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMZGcp7L2deeRRb++6zO6sHvUIXxMBmBvKKqJN6QKqOmBUxrF7QjH81/fY1QYK8Z9/WK55GE X-Received: by 10.223.157.41 with SMTP id k41mr16754633wre.281.1511357538102; Wed, 22 Nov 2017 05:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511357537; cv=none; d=google.com; s=arc-20160816; b=PnKDLymo8uZD98n2zei3B8bUJjGpbDkUVnVwe4NTDxjvt7/tfC9HsgGVFbafbvb9ou R4f4h+owx7m7q/PZl8zw+YcnH6J3rnKS+yLNhJG815NDBwH75asOsDvCLje5bnCr/WM0 4ya3a9WSf8q6wbxOT/zYcOHAgAXkggyc7W0HY7lVoBIdAJrz1rGorlyWtBO50uHGFUZk +DhcqqXJFhAzt9+UMmkNNIKjQAwl5t41MdeozWGi0JhGaNmZgwW2VIqPuHtJV0nFeVat hGnuGYUFYCybHA2UZiirer9+fJ6MdZj2Buh6IXDVO6hoQFRlV6XweygrbZESxRhxgSot 31yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:dkim-signature:delivered-to :arc-authentication-results; bh=fod8/eHFyurqAe64ctVAamYnDZP3jJm6tE4K6rPgL3w=; b=i26D6eELsFzR5SQht4RY5zqHi8FKZef/nrk1zcB5ugph+kn8Ltzhmx2GT7N7HNbMSX 0c3lYmY6rW/W/S2mi2ePEJEBudr1HzV3kHznfwcrM0FRx39jV6b+il8rzuQC8J8rvFJg gXp2LYC8P0jBCjQaQPWhpOmHtZG2XkMKlDwzQOtpC8jxUR5+QMthX6Y35Bb9CwIepKm7 mznaUDZMyL/24tKla50B4Vf29RrZPRl4vkjz4JHLOuA4MmCKNibTUlHnYHpqN93dMNwE CwSHYL55wpYxfC5Pmmz64AAlmecIyCzGCT7KTFju6YcOQD0tqfBScRkcn62Ci6riO4g/ RVCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=aTcwbQCi; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o67si3081203wme.106.2017.11.22.05.32.17; Wed, 22 Nov 2017 05:32:17 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=aTcwbQCi; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6E3568A14C; Wed, 22 Nov 2017 15:32:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 88BB368A0B2 for ; Wed, 22 Nov 2017 15:32:09 +0200 (EET) Received: by mail-lf0-f44.google.com with SMTP id d10so7200903lfj.7 for ; Wed, 22 Nov 2017 05:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=A/6lbMNJMqkiwjSF7GE/cYdye0GIVZZ0hmSLCSnPZbw=; b=aTcwbQCixkr7gilGU28nJN3x5RJOMG3NVKhFSn5LxCoM/w6wDzgJTn6OhCqnzXpgYF Bvtw7kl2dc19bBaG9p2s7Ov256wbzFl7uaITJfITUQ5bQgYyrk3op57fEZTj0TENX0EG UuDTvmZCx6quuytZ6BQLZ+NwaaQqnizBP8YiBC3OacLKC6L4D+AazjRCAAUXygkGcUwj px2t4xSUXqEL9QTsa0RngcWfPJxH0a4xCwuNLIjlorIl2GE/nkH2flleFJoj6gT8wC9K LWFft5fRjiV9KY9vsPCPXOmTgsoUP2JYA/7xXtPbIOb6+TFmJxMKeyISVT9i+SEt/vT8 2upw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=A/6lbMNJMqkiwjSF7GE/cYdye0GIVZZ0hmSLCSnPZbw=; b=AtpHZ5e9Ee7yQCSbjCcVoJkVy4R2ir7mol+tofBXKeu5SnImhbjARCnXyStBr3ZrYX nwVuK/jiEZzloXJ5wrl0FC71TzQ1mezgENVNJqKMq7HPs+kr1UvmHV1WpwQPMz/aqsHO jTCmcGFV5NsDbDnKUnsMCzXnClBFC4UMVtmeh3P3/qZj/Z28QD3TTqMWtBG2dM0XK0yr obHZndz7qEOJRMBOKt35/KcpHm4X6+Gx8kp9f6HCLUVE54T/aO5U6oFwII4rxaYfuLGS 32xI6Bpt3djuslo64QEqX885q04YS1BaIPM6662eNwNzWjhETbHcXLu569BVZSS17s0b K22g== X-Gm-Message-State: AJaThX4rlSOB4sfjHEKqZne6ahYVsOHY0zrFiED4tmdzg38959gcwL1D 0AW00bgLjMnvRs06KdMDaovRsg== X-Received: by 10.25.161.201 with SMTP id k192mr6105546lfe.45.1511357528710; Wed, 22 Nov 2017 05:32:08 -0800 (PST) Received: from [192.168.0.100] ([176.159.7.188]) by smtp.googlemail.com with ESMTPSA id x21sm2761515lfi.36.2017.11.22.05.32.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 05:32:08 -0800 (PST) To: ffmpeg-devel@ffmpeg.org References: <20171112160048.GQ6009@nb4> <20171112163827.GT6009@nb4> <19c44254-1279-b685-3f46-0f03b2fa7a07@gmail.com> <20171114121355.GB6009@nb4> <16cfbba9-053d-0958-0042-6487d93301e9@gmail.com> <20171116014847.GT6009@nb4> <148ce8f6-476b-a8b1-a7ae-d44cd2e44316@gmail.com> <20171118202649.GC4903@nb4> <425f2195-fc3d-9325-df02-796dae5289e3@gmail.com> <20171119192842.GB4645@nb4> From: "pkv.stream" Message-ID: Date: Wed, 22 Nov 2017 14:32:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171119192842.GB4645@nb4> Content-Language: fr Subject: [FFmpeg-devel] [DEVEL][PATCH 1/2] ffmpeg: parse duplicate option 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Le 19/11/2017 à 8:28 PM, Michael Niedermayer a écrit : > On Sun, Nov 19, 2017 at 11:01:37AM +0100, pkv.stream wrote: > [...] > >> @@ -3674,6 +3697,10 @@ const OptionDef options[] = { >> { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | >> OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_channel_layout }, >> "set channel layout", "layout" }, >> + { "channel_layout_uint64", OPT_AUDIO | HAS_ARG | OPT_INT64 | OPT_SPEC | > i mean as "channel_layout" > does it work with both using the same name so the option is routed > to both the field and callback or am i missing something why this is > not intended? Hi Michael, I've modified previous patch per your remark, so that channel_layout option is now routed both as func_arg and OPT_SPEC with same option name. patch 1/2:  parse duplicate option. Allows two entries carrying same name in OptionDef table, the main one (the first) calls a func_arg while the second writes an offset in a SpecifierOpt. The duplicate option can never be set directly and should be set when the main option is parsed (in func_arg). patch 2/2: fix channel_layout bug (ticket 6706) by retrieving channel_layout from stream output options and passing to filters. Hope it will be OK. Thanks. From 7b53b8a6487173c62fcab2761289340b35bd171a Mon Sep 17 00:00:00 2001 From: pkviet Date: Wed, 22 Nov 2017 13:44:37 +0100 Subject: [PATCH 1/2] ffmpeg: parse duplicate option Allows parsing of a duplicate option in an OptionDef table, with same name as main option. This is useful for example for channel_layout which can be parsed with func_arg (opt_channel_layout) and also stored as an offset in a SpecifierOpt. Signed-off-by: pkviet --- fftools/cmdutils.c | 18 ++++++++++++++++++ fftools/cmdutils.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 6920ca0..00802cf 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -380,6 +380,24 @@ int parse_option(void *optctx, const char *opt, const char *arg, return !!(po->flags & HAS_ARG); } +int parse_duplicate_option(void *optctx, const char *opt, const char *arg, + const OptionDef *options) +{ + const OptionDef *po; + int ret; + + po = find_option(options, opt) + 1; + if (po->name != (po - 1)->name) { + av_log(NULL, AV_LOG_ERROR, "Option '%s' has no duplicate.\n", opt); + return AVERROR(EINVAL); + } + ret = write_option(optctx, po, opt, arg); + if (ret < 0) + return ret; + + return !!(po->flags & HAS_ARG); +} + void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void (*parse_arg_function)(void *, const char*)) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index fa2b255..a2f74b5 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -301,6 +301,19 @@ int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options); /** +* Parse the duplicate of one given option (carrying same name). Some options may +* need to be dealt with func_arg as well as OPT_SPEC. +* Ex: channel_layout is parsed with func_arg (allowing strings as well as numerals +* as arguments); but it can be needed also as an OPT_SPEC. +* The duplicate option should be defined in an OptionDef table right after the main +* option and carries the same name. +* +* @return on success 1 if arg was consumed, 0 otherwise; negative number on error +*/ +int parse_duplicate_option(void *optctx, const char *opt, const char *arg, + const OptionDef *options); + +/** * An option extracted from the commandline. * Cannot use AVDictionary because of options like -map which can be * used multiple times.