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 2111542139 for ; Wed, 23 Feb 2022 10:25:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC50F68B2A1; Wed, 23 Feb 2022 12:24:59 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4A0C68B226 for ; Wed, 23 Feb 2022 12:24:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 21166240179 for ; Wed, 23 Feb 2022 11:24:53 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Is4jZi0FAhZp for ; Wed, 23 Feb 2022 11:24:52 +0100 (CET) Received: from lain.red.khirnov.net (lain.red.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.red.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 55007240175 for ; Wed, 23 Feb 2022 11:24:52 +0100 (CET) Received: by lain.red.khirnov.net (Postfix, from userid 1000) id 7DAA61601AD; Wed, 23 Feb 2022 11:24:52 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220113020518.730-2-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> <20220113020518.730-2-jamrial@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Wed, 23 Feb 2022 11:24:52 +0100 Message-ID: <164561189248.19727.3918458142864400379@lain.red.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 211/281] flac: convert to new channel layout API 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-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 James Almer (2022-01-13 03:04:50) > From: Anton Khirnov > > Signed-off-by: Vittorio Giovara > Signed-off-by: Anton Khirnov > Signed-off-by: James Almer > --- > libavcodec/flac.c | 39 +++++++++++++++++++++------------------ > libavcodec/flac.h | 2 +- > libavcodec/flac_parser.c | 7 ++----- > libavcodec/flacdec.c | 9 ++++----- > libavcodec/flacenc.c | 26 +++++++++++++------------- > 5 files changed, 41 insertions(+), 42 deletions(-) > > diff --git a/libavcodec/flac.c b/libavcodec/flac.c > index 7b075d4bd3..51014faea1 100644 > --- a/libavcodec/flac.c > +++ b/libavcodec/flac.c > @@ -29,15 +29,15 @@ > > static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; > > -static const uint64_t flac_channel_layouts[8] = { > - AV_CH_LAYOUT_MONO, > - AV_CH_LAYOUT_STEREO, > - AV_CH_LAYOUT_SURROUND, > - AV_CH_LAYOUT_QUAD, > - AV_CH_LAYOUT_5POINT0, > - AV_CH_LAYOUT_5POINT1, > - AV_CH_LAYOUT_6POINT1, > - AV_CH_LAYOUT_7POINT1 > +static const AVChannelLayout flac_channel_layouts[8] = { > + AV_CHANNEL_LAYOUT_MONO, > + AV_CHANNEL_LAYOUT_STEREO, > + AV_CHANNEL_LAYOUT_SURROUND, > + AV_CHANNEL_LAYOUT_QUAD, > + AV_CHANNEL_LAYOUT_5POINT0, > + AV_CHANNEL_LAYOUT_5POINT1, > + AV_CHANNEL_LAYOUT_6POINT1, > + AV_CHANNEL_LAYOUT_7POINT1 > }; > > static int64_t get_utf8(GetBitContext *gb) > @@ -193,12 +193,19 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, > return 1; > } > > -void ff_flac_set_channel_layout(AVCodecContext *avctx) > +void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels) > { > - if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts)) > - avctx->channel_layout = flac_channel_layouts[avctx->channels - 1]; > + if (channels == avctx->ch_layout.nb_channels && > + avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && > + avctx->ch_layout.u.mask) Not sure why I wrote this check like this originally, now it seems better to check for order != UNSPEC, so that a user-supplied custom layout is preserved. -- 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".