From patchwork Fri Apr 5 16:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47832 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1069172pzd; Fri, 5 Apr 2024 09:13:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt5AvCDXJcup0Owgz/ZWOVOWglAGQtRHH9JFPvPbz7OjGVVTAUR/gulMMLMku5INam5CLwO9tfu3xLlKejJSf48wGuFbtniYhdHA== X-Google-Smtp-Source: AGHT+IHe6Un1yUjQggVu75P6BBfymuJlIE6tlk5k58ID19p+0f46Y1FJw2lCt2LpSg2Uw4M+HE+5 X-Received: by 2002:a05:6402:4313:b0:56e:3535:9617 with SMTP id m19-20020a056402431300b0056e35359617mr1301226edc.1.1712333630133; Fri, 05 Apr 2024 09:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333630; cv=none; d=google.com; s=arc-20160816; b=TTtvtyu9qhiLX/bMtwPGzlDY/D6AyDW4gYEBNYqSMoP5pT2zkdBjEdvNELeb34GOvT ZjByipIWJGvYKWCL74nn7jkr6LqoFzmDuIarke7sT0eMDa1G0ty44o16eRNVIzJAeOT+ cTIxVAwShPeZ+PTBi6k05MjZDoTDm7MTX+FwqPtnmklVGQu1QkalnWkvTyccJT8NDW8L 23loa5tNXqG7dpzXX8k/HlyOL94B2dpuHhG9rGE0OsbtDiIPmgdGCbLVhMWe3YrpyXmK /ZGfgcyrvVzXTcJcrXWZet+dW4BeuPwQIZysWCm0dA/Z1Mta13XgktPEGAUkzTNXnuk6 Jcfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:dkim-signature:delivered-to; bh=VWCl2Qfrd9wVRvEXUNgIKFmOt/C9n4ELsTto7mGbqZQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=FUMJh3mtVwyYOeKsrgrZDP/wV6H8HEbEtGeuVIDtIDZldJJ3xoHQZXpEQyyFmviPoT hykJ7TcxkvGnLfLrVWsLXO1ZZziRxFnI4iDCHj7qMwBO+pVRljQ3YleH1rLdDMq7rXEk Z4T0gmlFqzx1B9X0Vr+HYOtOwyY6CKDKw1hvp5jQFNF09YO3xb6SwaFOJ5xH7BGd/pIT B6vehlvwsnxsqD47UsDfhzGvZsfmc6gsIC3CwN7svrfw9rhxYK4knjBOP6FNtM6PWkAL latXbpRewOg3ltY04sugK5XbhzrFV1w7CVbZfj5wyncmZ4F7qmE74dRUuMbUO6WGl1ar WqoQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=hWkqHJtr; 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 c22-20020a50f616000000b0056e2acef875si878944edn.669.2024.04.05.09.13.49; Fri, 05 Apr 2024 09:13:50 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=hWkqHJtr; 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 C5BF768D13B; Fri, 5 Apr 2024 19:13:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D159768D10C for ; Fri, 5 Apr 2024 19:13:04 +0300 (EEST) Authentication-Results: mail1.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=hWkqHJtr; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 200C14D84 for ; Fri, 5 Apr 2024 18:13:04 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ncUp68X5ZAHE for ; Fri, 5 Apr 2024 18:13:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333582; bh=xqWxSQyQ/nzidDuU4sRuLBofwJZsF/RKf0LbszjNWBY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hWkqHJtrwE5ZDRitLLeDWFH23o3kV9muXlA2ZcnzgPKLW9t3hc6N0cHT6LhUi3SQp 7BCGyLZmFH2mieF2Mq5PTUVfMaoyG4RnYiOgbUagJyk98aOPSxK4WMiw+dLBaLP5IY FEOACwdbkfcGxfela4I80UGi5jd6Uso3ZS8Qz4GA619/VoRMeGPwSacp5QNmjIKMtx XwIB+wcQmES0HCxE3TzvFClAN2sGbP1uVHhmRVFCaTk7O2oq70Sj5LtbeRvHnYYGRE T2AiEHJn0QWp2okcrWuRE/Zo9VL4+taWz1ut7pqs//KyAS4P06gShFCoGIQIyPIOKt B5FzDBNLPQ8/Q== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id E92B94D58 for ; Fri, 5 Apr 2024 18:13:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8B1633A07B9 for ; Fri, 5 Apr 2024 18:12:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:11:44 +0200 Message-ID: <20240405161212.26167-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405161212.26167-1-anton@khirnov.net> References: <20240405161212.26167-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/31] fftools/ffmpeg_filter: do not pass OutputStream to set_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 89r9vAF1ee3X It only needs a list of allowed layouts and the requested layout. --- fftools/ffmpeg_filter.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 2308abf82a..ba6c6c7673 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -722,42 +722,42 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec) return 0; } -static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) +static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layouts_allowed, + const AVChannelLayout *layout_requested) { - const AVCodec *c = ost->enc_ctx->codec; int i, err; - if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { + if (layout_requested->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); + err = av_channel_layout_copy(&f->ch_layout, layout_requested); if (err < 0) return err; return 0; } /* Requested layout is of order UNSPEC */ - if (!c->ch_layouts) { + if (!layouts_allowed) { /* 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); + av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); return 0; } /* 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; c->ch_layouts[i].nb_channels; i++) { - if (c->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) + for (i = 0; layouts_allowed[i].nb_channels; i++) { + if (layouts_allowed[i].nb_channels == layout_requested->nb_channels) break; } - if (c->ch_layouts[i].nb_channels) { + if (layouts_allowed[i].nb_channels) { /* Use it if one is found */ - err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]); + err = av_channel_layout_copy(&f->ch_layout, &layouts_allowed[i]); if (err < 0) return err; return 0; } /* 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); + av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); return 0; } @@ -844,7 +844,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->sample_rates = c->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { - int ret = set_channel_layout(ofp, ost); + int ret = set_channel_layout(ofp, c->ch_layouts, &ost->enc_ctx->ch_layout); if (ret < 0) return ret; } else if (c->ch_layouts) {