From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 30E834B065 for ; Mon, 27 May 2024 07:52:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5903D68D4DB; Mon, 27 May 2024 10:51:59 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C00268D239 for ; Mon, 27 May 2024 10:51:53 +0300 (EEST) Authentication-Results: mail0.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=PdU4KgSj; dkim-atps=neutral Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 400F2240DAC; Mon, 27 May 2024 09:51:52 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id IWQyw8DtXIVF; Mon, 27 May 2024 09:51:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1716796310; bh=DtVTgIfSJ/K7w6XNWbHSSlY9NAjc4Iuk12e5ytHak/Y=; h=Subject:From:To:Cc:In-Reply-To:References:Date:From; b=PdU4KgSjBTDOb6cxhICnqa8V8F0z4Azap9WVWPgtVUjU47h6pXEmroKPVYBoja8oq qP/dr8cvCy9I2kvIFfPJ7kLyL0g9PVtedPCvhiErLfMnVq3jypJhfy/95cFT3DzB+k OQ2/+5DK4ufCzislmVmfcqAonnuzQKb4raJ5ljDvsreTM3532P6fIaDsQBUshZoB0S hrppa0GV+VO7jo8Nb7wm8RbqSDVBxL8d6dMChfu658wx/d3knCrIqZazEsYMYBLR2L HmVEShoXMVwm+O9Ve6RgM2UdiQHAwAHEbQ2dv+TsoWy87UkYRs0USywyB7zWLfIbl/ mUItRdIw5+Q2w== Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 236F62404E5; Mon, 27 May 2024 09:51:50 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id F3A0F1601B9; Mon, 27 May 2024 09:51:49 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20240518161116.8661-1-cus@passwd.hu> References: <20240518161116.8661-1-cus@passwd.hu> Mail-Followup-To: FFmpeg development discussions and patches , Marton Balint Date: Mon, 27 May 2024 09:51:49 +0200 Message-ID: <171679630996.28895.471585656981378600@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting Marton Balint (2024-05-18 18:11:12) > 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); I don't like modifying OptionsContext in its consumers (it's const for a reason), and it's probably not even necessary - if the semantics of the option is "override demuxer-reported channel layout", then you can just override the demuxer-reported channel layout (similarly to how guess_input_channel_layout() does it) and it will be communicated to the decoder automagically. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".