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 EC39643F89 for ; Tue, 23 Aug 2022 12:26:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D3F568B924; Tue, 23 Aug 2022 15:26:15 +0300 (EEST) Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E965568B00F for ; Tue, 23 Aug 2022 15:26:08 +0300 (EEST) Received: by mail-oo1-f53.google.com with SMTP id u3-20020a4ab5c3000000b0044b125e5d9eso1598618ooo.12 for ; Tue, 23 Aug 2022 05:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=vZosCvJQGSVwsGGMy+aW5Byv2MOe/2UvK0D0n/UOYao=; b=ASbZg5VVFlHiJ4w4EoBFL+bCCYYb73NwCEjH4M+ZSvndTkaVZpa17EBscFVIxiMvso FKuYe6/zJruQgUsqYXM6BNvw0/hb+LWIOAoM8SUMsER16iCtDO0t5CCqrlMBh2WmwjVi 2DfmEZxCpmJLa4wdl6WVeaR4xtB7c7eEeoX5VLou42my1x2JYBw+xUv/vMakQuD4r+Gs sf/DfWg+yzlQbFCSIi0c7dHxQJsBQaUENHSk1SHlVk6n0xi8zmmOie8VAFjiyddb6C3M GkCSiVKV4Fw/QhEQ3kaD+5Mw8xjTJKGoP9U/BbT7rGs/VXdLXJg3UhIH5eEsSJyrvfJn tfuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=vZosCvJQGSVwsGGMy+aW5Byv2MOe/2UvK0D0n/UOYao=; b=Fi64mS+u2LMdoAjCXUUadDgnujxSlx9FxXyJxRb7g5XHeQk9cg9fxK6HWm03DydxSr SQJ7/eljiZHBDhIpqZXSAagb85FFuX4WoOtgnt2rILkf9RNrQBP30KqeoO052D8jrnLF 6bqoQVJmkAz0yd80P1mrD0oyAOTNl3rBeTTt56dd1CeM6n+Sj8OkRcHerFL7e4BR6RxG dGGf0YX8t/kX6kAiyuLrNsFeJ2AFC4mihBBx6Y9PzXoUvgo015qE6dhysgEljHLLIj9+ jybYAlHsdvnOSJzsnwfU/+d+f5MUMB84JZkPlwzhp/rG78CEn6FhkySsuNgnWpRMn/Me JFrA== X-Gm-Message-State: ACgBeo0vnpyEbgodyjMdJXFm814vGKwl/dnYoBeUpr1jIgBEfjtvrgD3 Wuw81npTZJBFHeMG6Iz1HSkzzhZETHk= X-Google-Smtp-Source: AA6agR43WEaFHPCDCoDbN6JoG+T15LxVDRoroi8qY/Pplrl8lu4x2CJoOwjEU0yON88z3laQjTnkBQ== X-Received: by 2002:a4a:b048:0:b0:435:b7b4:7505 with SMTP id g8-20020a4ab048000000b00435b7b47505mr7869114oon.57.1661257566084; Tue, 23 Aug 2022 05:26:06 -0700 (PDT) Received: from [192.168.0.13] ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id l13-20020a056870204d00b000f342d078fasm3599612oad.52.2022.08.23.05.26.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Aug 2022 05:26:05 -0700 (PDT) Message-ID: <91f5e4a7-c0d6-87b4-ca60-492791522fd5@gmail.com> Date: Tue, 23 Aug 2022 09:26:04 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US From: James Almer To: ffmpeg-devel@ffmpeg.org References: <20220821204228.2287-1-jamrial@gmail.com> In-Reply-To: <20220821204228.2287-1-jamrial@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_opt: try to propagate the requested output channel layout 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 8/21/2022 5:42 PM, James Almer wrote: > Don't silently replace it with the default layout for the amount of channels > from the requested layout. > > Should fix ticket #9869 > > Signed-off-by: James Almer > --- > fftools/ffmpeg_opt.c | 38 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 37 insertions(+), 1 deletion(-) > > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index 30ca5cd609..3a555c4c16 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -2865,6 +2865,42 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o) > } > } > } > +static void set_channel_layout(OutputFilter *f, OutputStream *ost) > +{ > + int i, err; > + > + if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { > + /* Pass the layout through for all orders but UNSPEC */ > + err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout); > + if (err < 0) > + exit_program(1); > + return; > + } > + > + /* Requested layout is of order UNSPEC */ > + if (!ost->enc->ch_layouts) { > + /* Use the default native layout for the requested amount of channels when the > + encoder doesn't have a list of supported layouts */ > + av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); > + return; > + } > + /* Encoder has a list of supported layouts. Pick the first layout in it with the > + same amount of channels as the requested layout */ > + for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) { > + if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) > + break; > + } > + if (ost->enc->ch_layouts[i].nb_channels) { > + /* Use it if one is found */ > + err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]); > + if (err < 0) > + exit_program(1); > + return; > + } > + /* If no layout for the amount of channels requested was found, use the default > + native layout for it. */ > + av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); > +} > > static int open_output_file(OptionsContext *o, const char *filename) > { > @@ -3055,7 +3091,7 @@ static int open_output_file(OptionsContext *o, const char *filename) > f->sample_rates = ost->enc->supported_samplerates; > } > if (ost->enc_ctx->ch_layout.nb_channels) { > - av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); > + set_channel_layout(f, ost); > } else if (ost->enc->ch_layouts) { > f->ch_layouts = ost->enc->ch_layouts; > } Will apply soon. _______________________________________________ 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".