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 A756440B13 for ; Mon, 7 Mar 2022 10:26:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 94D3568B0D3; Mon, 7 Mar 2022 12:26:27 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E192A689A2B for ; Mon, 7 Mar 2022 12:26:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 111EB240179 for ; Mon, 7 Mar 2022 11:26:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id KgHepU5tJ0_K for ; Mon, 7 Mar 2022 11:26:19 +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 5F2032400F5 for ; Mon, 7 Mar 2022 11:26:19 +0100 (CET) Received: by lain.red.khirnov.net (Postfix, from userid 1000) id 483FF1601AD; Mon, 7 Mar 2022 11:26:14 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220113020913.870-1-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> <20220113020913.870-1-jamrial@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Mon, 07 Mar 2022 11:26:14 +0100 Message-ID: <164664877425.19727.1849995045662076930@lain.red.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 270/281] wma: 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:09:02) > From: Anton Khirnov > > Signed-off-by: James Almer > --- > libavcodec/wma.c | 11 ++++++----- > libavcodec/wmadec.c | 29 +++++++++++++++-------------- > libavcodec/wmaenc.c | 27 ++++++++++++++------------- > libavcodec/wmalosslessdec.c | 13 +++++++------ > libavcodec/wmaprodec.c | 30 ++++++++++++++++++++---------- > libavcodec/wmavoice.c | 4 ++-- > 6 files changed, 64 insertions(+), 50 deletions(-) > > diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c > index ba7bddc51c..5c1d38eca5 100644 > --- a/libavcodec/wmaprodec.c > +++ b/libavcodec/wmaprodec.c > @@ -384,7 +384,7 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu > s->decode_flags = 0x10d6; > s->bits_per_sample = 16; > channel_mask = 0; //AV_RL32(edata_ptr+2); /* not always in expected order */ > - if ((num_stream+1) * XMA_MAX_CHANNELS_STREAM > avctx->channels) /* stream config is 2ch + 2ch + ... + 1/2ch */ > + if ((num_stream+1) * XMA_MAX_CHANNELS_STREAM > avctx->ch_layout.nb_channels) /* stream config is 2ch + 2ch + ... + 1/2ch */ > s->nb_channels = 1; > else > s->nb_channels = 2; > @@ -402,7 +402,7 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu > s->decode_flags = AV_RL16(edata_ptr+14); > channel_mask = AV_RL32(edata_ptr+2); > s->bits_per_sample = AV_RL16(edata_ptr); > - s->nb_channels = avctx->channels; > + s->nb_channels = avctx->ch_layout.nb_channels; > > if (s->bits_per_sample > 32 || s->bits_per_sample < 1) { > avpriv_request_sample(avctx, "bits per sample is %d", s->bits_per_sample); > @@ -474,7 +474,7 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu > av_log(avctx, AV_LOG_ERROR, "invalid number of channels per XMA stream %d\n", > s->nb_channels); > return AVERROR_INVALIDDATA; > - } else if (s->nb_channels > WMAPRO_MAX_CHANNELS || s->nb_channels > avctx->channels) { > + } else if (s->nb_channels > WMAPRO_MAX_CHANNELS || s->nb_channels > avctx->ch_layout.nb_channels) { > avpriv_request_sample(avctx, > "More than %d channels", WMAPRO_MAX_CHANNELS); > return AVERROR_PATCHWELCOME; > @@ -575,8 +575,13 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu > if (avctx->debug & FF_DEBUG_BITSTREAM) > dump_context(s); > > - if (avctx->codec_id == AV_CODEC_ID_WMAPRO) > - avctx->channel_layout = channel_mask; > + if (avctx->codec_id == AV_CODEC_ID_WMAPRO) { > + if (channel_mask) { > + av_channel_layout_uninit(&avctx->ch_layout); > + av_channel_layout_from_mask(&avctx->ch_layout, channel_mask); > + } else > + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; > + } > > ff_thread_once(&init_static_once, decode_init_static); > > @@ -1775,7 +1780,7 @@ static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s, > AVFrame *frame = data; > > if (s->trim_start < frame->nb_samples) { > - for (int ch = 0; ch < frame->channels; ch++) > + for (int ch = 0; ch < frame->ch_layout.nb_channels; ch++) > frame->extended_data[ch] += s->trim_start * 4; > > frame->nb_samples -= s->trim_start; > @@ -1952,13 +1957,18 @@ static av_cold int xma_decode_init(AVCodecContext *avctx) > XMADecodeCtx *s = avctx->priv_data; > int i, ret, start_channels = 0; > > - if (avctx->channels <= 0 || avctx->extradata_size == 0) > + if (avctx->ch_layout.nb_channels <= 0 || avctx->extradata_size == 0) > return AVERROR_INVALIDDATA; > > /* get stream config */ > if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size == 34) { /* XMA2WAVEFORMATEX */ > + unsigned int channel_mask = AV_RL32(avctx->extradata + 2); > + if (channel_mask) { > + av_channel_layout_uninit(&avctx->ch_layout); > + av_channel_layout_from_mask(&avctx->ch_layout, channel_mask); > + } else > + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; This function doesn't seem to validate that the channel_mask is consistent with s->nb_channels - should probably be done -- 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".