From patchwork Sat May 18 16:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 48984 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3522754pzb; Sat, 18 May 2024 09:11:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnfgDf6WbO8G1NHcP29ZcbC/Y7/8RHQ/t/eVIHYILgPSSWhOa+LAQE0pDqlnige7Zwk+LgrLVyqbKMxF5+TIXUCBEs0p9IB7lTgw== X-Google-Smtp-Source: AGHT+IGx9kjYnx7a8YjLeIwBtMrKUxhrJgzmp1V+Z+T3xAZzC77RY6iF7rrNvw/O+oTuCiTlwqhk X-Received: by 2002:a50:9b0d:0:b0:572:a4eb:6678 with SMTP id 4fb4d7f45d1cf-5752b4e2b0fmr2001861a12.19.1716048696417; Sat, 18 May 2024 09:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716048696; cv=none; d=google.com; s=arc-20160816; b=IGJzdoMjyXnmkAeVMp81ukppyYo0VrpVjC3NNkVDGmasmpcOdWI3xeJ9toXPKZEPLw KMf+nw2I+miJZYjgtmIOkx18tVhUbtBKAD1hO2KMkpWO2UdFz+CW7pZQY9RtUCb374wI gxB5Xmko7dB8xWSw3InbDcQ+7GqQ7iYjvyA/LC1FwUKXNVyj1G+5YTj+qs0Y+8rOF2m5 z8UW3+qW1iLKU7JmBEIIH+TeOT6dSL7PBeH6bAhJewBwc01Ae8KJhUhi9L+ZsgDvXngQ CLLT9ChVaBUKrImSn4D8Nx0tbCeTt6KV3zzFUzz/HT9dlIRcMf+bSW6CNT6mttwoeNnU H/JQ== 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:message-id:date:to:from :delivered-to; bh=dFe91ATeLJVB47EMEiEUV8tIDtfuB69kldz5p0Hr+tc=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=aN8sdjE2TIowhG7qJmCD2msw7LDnOzZFo/WwoQsKWyzLuMzm5YmgR7VS0drsFguAdQ 83s09PW/rjOOX6bsAboIqGofUNfuNo4OA4/w7go+iL8A986oXyoHLBPTp+Ud7NCYuXC+ aiDY7j298aWbMSF1NxNtKeYLgX43HGVx26kz9mS7vyEtbA6/F9PwMzSm9EiuItUecii3 8vQ53vGfx2BfSU43fffCrHTPA3U7hohjARozvnDHq2zeMoyFdqlk5B6+pBZOiSaLchJX aCZUAVb1quIe33TJRnUV9JOHw25SfSg9PccPMFexVFbHRFQ9baLowMxgu9qdpsaw4w3J 2EIQ==; 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-5743067d141si8931621a12.208.2024.05.18.09.11.35; Sat, 18 May 2024 09:11:36 -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 BE34D68CE05; Sat, 18 May 2024 19:11:31 +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 7D1AB68C094 for ; Sat, 18 May 2024 19:11:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EC0D3EA67C; Sat, 18 May 2024 18:11:24 +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 X3CuIIXAoBOb; Sat, 18 May 2024 18:11:22 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BE59DEA671; Sat, 18 May 2024 18:11:22 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 18:11:12 +0200 Message-Id: <20240518161116.8661-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] fftools/ffmpeg_demux: also set -ch_layout avcodec option for -ch_layout CLI param 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: PwLqzLhwZIsU The code only set the channel layout of the AVFormatContext, so the user could not override the channel layout if the demuxer did not have such parameter. Let's set the specified channel layouts as codec options as well. Fixes ticket #11016. A regression since 639c2f00497257cb60ecaeeac1aacfa80df3be06. Signed-off-by: Marton Balint --- doc/ffmpeg.texi | 7 ++++--- fftools/ffmpeg_demux.c | 46 +++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index da37e3ad37..83db6584fd 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1689,9 +1689,10 @@ demuxers and is mapped to the corresponding demuxer options. @item -aq @var{q} (@emph{output}) Set the audio quality (codec-specific, VBR). This is an alias for -q:a. @item -ac[:@var{stream_specifier}] @var{channels} (@emph{input/output,per-stream}) -Set the number of audio channels. For output streams it is set by -default to the number of input audio channels. For input streams -this option only makes sense for audio grabbing devices and raw demuxers +Set the number of audio channels. For output streams it is set by default to +the number of input audio channels. For input streams it overrides the number +of channels if the decoder allows it. When used without a stream specifier it +also sets the input channel count for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. @item -an (@emph{input/output}) As an input option, blocks all audio streams of a file from being filtered or diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index cba63dab5f..6e23079ceb 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1524,6 +1524,33 @@ static Demuxer *demux_alloc(void) return d; } +static int set_input_ch_layout_opts(const OptionsContext *o) +{ + /* "ch_layout" is only a valid format option for some formats, but we set + * it anyway, because it is also a codec option and we don't report + * unconsumed format options if they are codec options as well. */ + for (int i = 0; i < o->audio_channels.nb_opt; i++) { + char val[32]; + char *spec = o->audio_channels.opt[i].specifier; + char *key = av_asprintf("ch_layout%s%s", spec[0] ? ":" : "", spec); + if (!key) + return AVERROR(ENOMEM); + snprintf(val, sizeof(val), "%dC", o->audio_channels.opt[i].u.i); + av_dict_set(&o->g->format_opts, key, val, 0); + av_dict_set(&o->g->codec_opts, key, val, AV_DICT_DONT_STRDUP_KEY); + } + for (int i = 0; i < o->audio_ch_layouts.nb_opt; i++) { + char *val = o->audio_ch_layouts.opt[i].u.str; + char *spec = o->audio_ch_layouts.opt[i].specifier; + char *key = av_asprintf("ch_layout%s%s", spec[0] ? ":" : "", spec); + if (!key) + return AVERROR(ENOMEM); + av_dict_set(&o->g->format_opts, key, val, 0); + av_dict_set(&o->g->codec_opts, key, val, AV_DICT_DONT_STRDUP_KEY); + } + return 0; +} + int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) { Demuxer *d; @@ -1592,24 +1619,6 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) if (o->audio_sample_rate.nb_opt) { av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0); } - if (o->audio_channels.nb_opt) { - const AVClass *priv_class; - if (file_iformat && (priv_class = file_iformat->priv_class) && - av_opt_find(&priv_class, "ch_layout", NULL, 0, - AV_OPT_SEARCH_FAKE_OBJ)) { - char buf[32]; - snprintf(buf, sizeof(buf), "%dC", o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i); - av_dict_set(&o->g->format_opts, "ch_layout", buf, 0); - } - } - if (o->audio_ch_layouts.nb_opt) { - const AVClass *priv_class; - if (file_iformat && (priv_class = file_iformat->priv_class) && - av_opt_find(&priv_class, "ch_layout", NULL, 0, - AV_OPT_SEARCH_FAKE_OBJ)) { - av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts.opt[o->audio_ch_layouts.nb_opt - 1].u.str, 0); - } - } if (o->frame_rates.nb_opt) { const AVClass *priv_class; /* set the format-level framerate option; @@ -1626,6 +1635,7 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) } if (o->frame_pix_fmts.nb_opt) av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0); + ret = set_input_ch_layout_opts(o); video_codec_name = opt_match_per_type_str(&o->codec_names, 'v'); audio_codec_name = opt_match_per_type_str(&o->codec_names, 'a'); From patchwork Sat May 18 16:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 48985 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3522827pzb; Sat, 18 May 2024 09:11:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtir98tgsmItvrKb6YpaHsss/vtk3eAtQFcq9kJwb0qTkLC5zoeznBzepJBWB012ZTW2SCdMA4Kr0C9GaokZoj7bHZK8xeVIfxIg== X-Google-Smtp-Source: AGHT+IHrnle6KHmAw8x2n/SFdJFf9y+uTqP45c+XfR3wXBCWxUlWXO+9FuSsdLscg67Dn22pZRDW X-Received: by 2002:aa7:dd12:0:b0:572:d841:1189 with SMTP id 4fb4d7f45d1cf-5734d6f576fmr16620337a12.3.1716048707109; Sat, 18 May 2024 09:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716048707; cv=none; d=google.com; s=arc-20160816; b=Sr7wY+rhpBPRgUM02ZwrgXvW93s9DAEQ9E28rh9Lr/+Ro0FOteV9AUxycG9/7ecSIL PFxBmPEAonKyJiMqOUX1yx4riNZw/4FVlWA9OSZp/F82hKTgsaNrqNmx7oYe+Wm9o1fb qT6XGMCbU+85oF2f7V+GFOx9+BDLVAhFR0H2G1CDxpsb6AJPS2dsBjSjKgjsACQizxvf 2fcGo+8zz0Sw7K9GHHlgaDDZ4QceJ6AN36RDkOudLl1Yeg7tKwu4EoYoPnhIxcsM7u9k e3BL8OIKaqj56AYJeInYQm6WWd1FGilXCRgGwQ+ghWON5JbxdqQEgsMOLUxzwOztzSTr Spnw== 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=FthaX8gL4ZDFWsp2kR7PEnOx63YFyVwnbmgwKW8UPjE=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=w8NT4VfTi9vRNcgz0ZClgkmsDqOe81Esn5WXxlnGLRhplBFYMFKRuVqI6UNuRebag4 Kj6EF0cEf9jmO/4xCq8P1SWsYgk2mTjamRQz5apbhDjo20wOx31Tf0+FLDL8zigaK71M p1nFb6EmQKoiPidgOrPiJYCXIS1PuclTFpFWqG/QyMqiyM3x71TTcPry6tbPje2YOFP/ UBsazJPL8dX8Z3PdlijxcFeqh0QvhSY/Wf4/Xr/F8qCKrUW7W0A8C/1k3HiwmgosnRZF 4SwboO6B4NcHMoy2MlsMiyLW3wbwRR+Kx2I0tSZqUtwntxO9pXefsul1JJxaA0tbwTum 1EMg==; 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-5733c378546si12001313a12.643.2024.05.18.09.11.46; Sat, 18 May 2024 09:11:47 -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 5F1AA68CF0E; Sat, 18 May 2024 19:11:34 +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 A5AF868CEC8 for ; Sat, 18 May 2024 19:11:27 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7F4EAEA689; Sat, 18 May 2024 18:11:27 +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 YICBmhoSZrNn; Sat, 18 May 2024 18:11:25 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 185D3EA681; Sat, 18 May 2024 18:11:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 18:11:13 +0200 Message-Id: <20240518161116.8661-2-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 2/5] doc/ffmpeg: document -channel_layout/ch_layout options 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: 3sg+uh5kuJH1 Signed-off-by: Marton Balint --- doc/ffmpeg.texi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 83db6584fd..9b490f523f 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1720,6 +1720,16 @@ This is an alias for @code{-filter:a}, see the @ref{filter_option,,-filter optio @table @option @item -atag @var{fourcc/tag} (@emph{output}) Force audio tag/fourcc. This is an alias for @code{-tag:a}. +@item -ch_layout[:@var{stream_specifier}] @var{layout} (@emph{input/output,per-stream}) +@item -channel_layout[:@var{stream_specifier}] @var{layout} (@emph{input/output,per-stream}) +Set the audio channel layout. For output streams it is set by default to the +input channel layout. For input streams it overrides the channel layout if the +decoder allows it. When used without a stream specifier it also sets the input +channel layout for audio grabbing devices and raw demuxers and is mapped to the +corresponding demuxer options. + +Note that specifying a channel layout also sets the channel count and this +option has precedence over the @code{-ac} option. @item -guess_layout_max @var{channels} (@emph{input,per-stream}) If some input channel layout is not known, try to guess only if it corresponds to at most the specified number of channels. For example, 2 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, From patchwork Sat May 18 16:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 48987 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3522968pzb; Sat, 18 May 2024 09:12:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbDawpc7BDe2pPDMbQy8tkGxoO9L+v3eTmra3eUStfunB8H8Vq4QVtEz+m5iuMc/zOI2KddwiWiqb3r/6/WRBF3a58tGThHJz5fQ== X-Google-Smtp-Source: AGHT+IH4kABcFYxF7bloMw75U3qUp+icZlY3LcKkkRlUSxFbdpa15aD85vfeuz0sRNGWRcrWNts2 X-Received: by 2002:a50:9b06:0:b0:572:727f:d0db with SMTP id 4fb4d7f45d1cf-5734d5c13dfmr16595735a12.15.1716048726208; Sat, 18 May 2024 09:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716048726; cv=none; d=google.com; s=arc-20160816; b=wRnM9smchEzlyCmNDWag21lM4mGNgTGHpflxbR3VociV1kTjeXY6oifMF/jYIcIOm+ N0Hv/7tLL6wqpH1Ug2gam+poFdRHwzkHiQjssd/InkOn7+WZNvAwvohkCzrlADtSDGgL fWYL/tiZR83XE3x0Vyp0eflntnQ2ODOhkrUBL6PpWS5Xh7zlZVBIQniInW5O4k5Srftj maO+Qh+Q3G5t+vBySzELa8po00KcFWXMVltTWpscaZuyQ2eRBHaz5kJu5Est3G8DRqY1 8Fdl+Ma4bvPeNeVYoFoXu106uVceoSDw46kgbRdbN0eszXdTX5HdwsU2NteHm6MDFJD2 eOww== 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=U5Qht0mxwIgLTdhjgfUn76oFlQfGAjPFmiNcBtDfidc=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=qqwjt/LSDzNsUOpVUleZTkelDGIN5QVqOfHA/IatTLVI8rwcqKjzrALyhUPNsapaxB bsPxZ29PXf9pTxrdxUFtgpt66Q2qvZ4BuIhhJ2KHi5bcRdre/3KJ9Q4aScwMvsgXqnJQ tbCQu636J1vWTaC9kDu0viDpzQW/XU+ezD8oZ7HDcL9ABGVItSKpAmJk7gXE4B0/goGs iBo2gFSBEXzy8iRoBocVonMblAbiNmkSeZNSHjX0jr77KRfHPqAr4K2WbH6/1MvGDhg2 ULbb56wLC9ZZkthihCkExyUG5vNRE1vrL5rNY/TyAbMkvH6HMiYxwtlcEOY+bBOt3HB6 38Zg==; 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-574e13c0966si5866724a12.338.2024.05.18.09.12.05; Sat, 18 May 2024 09:12:06 -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 ADDC268CFCE; Sat, 18 May 2024 19:11:39 +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 A86F168CED8 for ; Sat, 18 May 2024 19:11:31 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6E0C0EA681; Sat, 18 May 2024 18:11:31 +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 G1Kc2DycIqxZ; Sat, 18 May 2024 18:11:29 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 61BD3EA67D; Sat, 18 May 2024 18:11:28 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 18:11:15 +0200 Message-Id: <20240518161116.8661-4-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 4/5] fftools/ffplay: use cmdutils code for checking remaining avoptions 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: Apl3zLVeVmiM Signed-off-by: Marton Balint --- fftools/ffplay.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index b9d11eecee..ff48fa5f8c 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2626,7 +2626,6 @@ static int stream_component_open(VideoState *is, int stream_index) const AVCodec *codec; const char *forced_codec_name = NULL; AVDictionary *opts = NULL; - const AVDictionaryEntry *t = NULL; int sample_rate; AVChannelLayout ch_layout = { 0 }; int ret = 0; @@ -2694,11 +2693,9 @@ static int stream_component_open(VideoState *is, int stream_index) if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) { goto fail; } - if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { - av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); - ret = AVERROR_OPTION_NOT_FOUND; + ret = check_avoptions(opts); + if (ret < 0) goto fail; - } is->eof = 0; ic->streams[stream_index]->discard = AVDISCARD_DEFAULT; @@ -2862,11 +2859,9 @@ static int read_thread(void *arg) if (scan_all_pmts_set) av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); - if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { - av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); - ret = AVERROR_OPTION_NOT_FOUND; + ret = check_avoptions(format_opts); + if (ret < 0) goto fail; - } is->ic = ic; if (genpts) From patchwork Sat May 18 16:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 48988 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3523045pzb; Sat, 18 May 2024 09:12:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWgKjUnKfuCb2SaCbMci60DNNNUCBakptMr13K9Uol+SQlbQEYd3CZ53bMJNIEQ8U74hPX8ZoSO8rZ1LXNaPmHoAGdD24QTCf9c5A== X-Google-Smtp-Source: AGHT+IGm+dCmvii9y6eANIQMJHeCr+hDROsTP9vczdavEMTSwdb0uuVQ4M1YjhhVy8+l0Hvgum1D X-Received: by 2002:a17:906:f898:b0:a5a:8ca4:6781 with SMTP id a640c23a62f3a-a5a8ca468bbmr909220066b.51.1716048735264; Sat, 18 May 2024 09:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716048735; cv=none; d=google.com; s=arc-20160816; b=tyqga5fdUB0fweeoSWG57dZAu8Y8h3WEqfzjIgCWcj1eZUW0dutbkWpezwRLK5heGB s+oV73CczcZVHQ9y9K1gxEyZJZFJ3gzhWC7mjjOj6E1GyJyPmjkHLfMIwJyMcA/jyP5R k1MA0HuBrc8TzkhECaYZDdqizA3diC9QWliYldEULv4YPCTRZVwyCVrs3bPPTySoK2ih O2p3jj3INt97QSCVz6zDoeOQ+upCdt7E/L68qRt2HyVol+7DO59rB+8xRhHUK+2K1Z2x pzg9kciVdlV1cIcYC8CvEIIbLnzzQZpowyUdFGDgjK3FO06kwGh8CqlwlO1zWBkFUhhZ biFw== 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=lqGxrmfNqRka6tdcrkCx+wpurF3LmvLoaK0ARFsBX10=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=pxg3KbgkAevCzzJFt/tNPGJuXu8HXXO84vbb0kqaWoyT43TOQlktQNlhYM39IDf3JM ZUnuNHpOHSLi2bb28UcQQcjx7ZuY5ePKcvGKMrPl+HkfrscysjaQDLayyjAHFqN2e/6p WI3WkIg421WsQt8cBHfvEAklvrymsnsOCh4vRKQGuODssAhdUp8Q1bBme8W3Erge5Bwi d5CsRCywugJqlqL5UuORlSk2IxhpmvuFLiM5QYOCKfoCShlUM6swGCIFs4EBMaMvn3LB dVEEDdz/PyIpD2LJQp1IVMann19SvI5SN1g2EA7WmJbM6Oz9L5pSPM1z8DnlxyIa22gN 35fg==; 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 a640c23a62f3a-a5a17945d18si1064178366b.186.2024.05.18.09.12.14; Sat, 18 May 2024 09:12:15 -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 94F7768D01E; Sat, 18 May 2024 19:11:40 +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 2D11068CF50 for ; Sat, 18 May 2024 19:11:33 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 04416EA67C; Sat, 18 May 2024 18:11:33 +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 e2DJ5ft0sjLJ; Sat, 18 May 2024 18:11:31 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2012FEA69C; Sat, 18 May 2024 18:11:30 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 18:11:16 +0200 Message-Id: <20240518161116.8661-5-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 5/5] fftools/ffplay: allow unused format options which are also codec options 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: DuE7pL5rmWYV Same as it is handled in ffmpeg, allows using -ch_layout codec option. Signed-off-by: Marton Balint --- fftools/ffplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index ff48fa5f8c..1d0511b254 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2858,6 +2858,7 @@ static int read_thread(void *arg) } if (scan_all_pmts_set) av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); + remove_avoptions(&format_opts, codec_opts); ret = check_avoptions(format_opts); if (ret < 0)