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 58F5142F3F for ; Thu, 13 Jan 2022 02:43:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C909968B929; Thu, 13 Jan 2022 04:06:06 +0200 (EET) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2B6B68B8F7 for ; Thu, 13 Jan 2022 04:06:04 +0200 (EET) Received: by mail-qk1-f181.google.com with SMTP id b127so5657709qkd.0 for ; Wed, 12 Jan 2022 18:06:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JdabDAtCUkW4BCil5CEYd7Jejxyo066RSonFZMwuX2A=; b=PrG+1tYgisV7w9AlXz1/ZGayYbFovj+rp42y5S2uIGXW31kLnq8OiAwizbu/+tKh0C anucdENXyM1MYm1sQsfdg4AVfRG2GY0oQuAb6DZ/Qb98dghhdSQMrJeyk3MQaKlk0qXL hxyNPRrTESuqYN67PiQdEk7n2Pt0tGBCqJGWrvEQDAbPhjakqj1+F01LuAvXCcYTG/ob U7ZwGWFGO5rTAQRm6hRC9E6rxHum0ayeuV/Hfn7ItWtpz+dV/IzAfrTeMexercYANh7G CF/iOveyVfc0kMtHJU6H+JF9KnxgNvNl0t81YyQ7gJOK289xDRFe1RI7S682s2u6+QOa 4Nhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JdabDAtCUkW4BCil5CEYd7Jejxyo066RSonFZMwuX2A=; b=quPCwddSNe2NvC1HsC0IKaLVKGhDqdjtqwiUiWDXHeCViQ2oVctOFBhYyLFDG3C7ZO vq7tgDdj31SqjmK9j6h2tJPzM1o5DJwSvlb5KvvE0pjBBRJoDxLXnTy503CaaWdTmKo9 AvmqiOPokbkrcwML3RDQS+fRzs/moahfToZ6HgC/vwtPekJgBl+eAAXourlTYm5ALIp0 jX/QHSyeBwwHFyXp/RWCx40+5QrdeoXfXMiL11PCfZ5QlTbeQZfefeNYHyduIIPgmFPF ExbdAlmyp2paSMlB9vSVXppqi21CNpLRXAekBqv0XEI/SYv6iBbZAsfnALhgsr41rRAA tsYg== X-Gm-Message-State: AOAM533x7GdT1AQyL8Gt8EKqiA1ho7hPqlOIRW2/8JQaivjSY0jsXUmS ykZ22eclFG1uGycfd1o2y9+yjWJYJxM= X-Google-Smtp-Source: ABdhPJwPPplBlDXMs3dQ3wIwNWJVAnzSZUYLxcXv7KP3L88/I+Zw/ZQveGMYw6L8Ak0M7nLakxDp/Q== X-Received: by 2002:a05:620a:1a9d:: with SMTP id bl29mr1888581qkb.55.1642039563197; Wed, 12 Jan 2022 18:06:03 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id k9sm1264556qko.29.2022.01.12.18.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:06:02 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:05:15 -0300 Message-Id: <20220113020518.730-27-jamrial@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220113015101.4-1-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 236/281] metasound: 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: From: Anton Khirnov Signed-off-by: Vittorio Giovara Signed-off-by: James Almer --- libavcodec/metasound.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c index 57851a43c5..32d5e153be 100644 --- a/libavcodec/metasound.c +++ b/libavcodec/metasound.c @@ -65,8 +65,9 @@ static void decode_ppc(TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech) { const TwinVQModeTab *mtab = tctx->mtab; + int channels = tctx->avctx->ch_layout.nb_channels; int isampf = tctx->avctx->sample_rate / 1000; - int ibps = tctx->avctx->bit_rate / (1000 * tctx->avctx->channels); + int ibps = tctx->avctx->bit_rate / (1000 * channels); int width; float ratio = (float)mtab->size / isampf; @@ -75,7 +76,7 @@ static void decode_ppc(TwinVQContext *tctx, int period_coef, int g_coef, float pgain_base, pgain_step, ppc_gain; - if (tctx->avctx->channels == 1) { + if (channels == 1) { min_period = log2(ratio * 0.2); max_period = min_period + log2(6); } else { @@ -85,7 +86,7 @@ static void decode_ppc(TwinVQContext *tctx, int period_coef, int g_coef, period_range = max_period - min_period; period = min_period + period_coef * period_range / ((1 << mtab->ppc_period_bit) - 1); - if (tctx->avctx->channels == 1) + if (channels == 1) period = powf(2.0, period); else period = (int)(period * 400 + 0.5) / 400.0; @@ -103,7 +104,7 @@ static void decode_ppc(TwinVQContext *tctx, int period_coef, int g_coef, if (isampf == 22 && ibps == 32) width = (int)((2.0 / period + 1) * width + 0.5); - pgain_base = tctx->avctx->channels == 2 ? 25000.0 : 20000.0; + pgain_base = channels == 2 ? 25000.0 : 20000.0; pgain_step = pgain_base / ((1 << mtab->pgain_bit) - 1); ppc_gain = 1.0 / 8192 * twinvq_mulawinv(pgain_step * g_coef + pgain_step / 2, @@ -123,8 +124,9 @@ static void dec_bark_env(TwinVQContext *tctx, const uint8_t *in, int use_hist, int bark_n_coef = mtab->fmode[ftype].bark_n_coef; int fw_cb_len = mtab->fmode[ftype].bark_env_size / bark_n_coef; int idx = 0; + int channels = tctx->avctx->ch_layout.nb_channels; - if (tctx->avctx->channels == 1) + if (channels == 1) val = 0.5; for (i = 0; i < fw_cb_len; i++) for (j = 0; j < bark_n_coef; j++, idx++) { @@ -132,7 +134,7 @@ static void dec_bark_env(TwinVQContext *tctx, const uint8_t *in, int use_hist, (1.0 / 2048); float st; - if (tctx->avctx->channels == 1) + if (channels == 1) st = use_hist ? tmp2 + val * hist[idx] + 1.0 : tmp2 + 1.0; else @@ -167,7 +169,7 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, { TwinVQFrameData *bits; const TwinVQModeTab *mtab = tctx->mtab; - int channels = tctx->avctx->channels; + int channels = tctx->avctx->ch_layout.nb_channels; int sub; GetBitContext gb; int i, j, k, ret; @@ -276,6 +278,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) TwinVQContext *tctx = avctx->priv_data; uint32_t tag; const MetasoundProps *props = codec_props; + int channels; if (!avctx->extradata || avctx->extradata_size < 16) { av_log(avctx, AV_LOG_ERROR, "Missing or incomplete extradata\n"); @@ -291,7 +294,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) } if (props->tag == tag) { avctx->sample_rate = props->sample_rate; - avctx->channels = props->channels; + channels = props->channels; avctx->bit_rate = props->bit_rate * 1000; isampf = avctx->sample_rate / 1000; break; @@ -299,17 +302,17 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) props++; } - if (avctx->channels <= 0 || avctx->channels > TWINVQ_CHANNELS_MAX) { + if (channels <= 0 || channels > TWINVQ_CHANNELS_MAX) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", - avctx->channels); + channels); return AVERROR_INVALIDDATA; } - avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO - : AV_CH_LAYOUT_STEREO; + av_channel_layout_uninit(&avctx->ch_layout); + av_channel_layout_default(&avctx->ch_layout, channels); - ibps = avctx->bit_rate / (1000 * avctx->channels); + ibps = avctx->bit_rate / (1000 * channels); - switch ((avctx->channels << 16) + (isampf << 8) + ibps) { + switch ((channels << 16) + (isampf << 8) + ibps) { case (1 << 16) + ( 8 << 8) + 6: tctx->mtab = &ff_metasound_mode0806; break; -- 2.34.1 _______________________________________________ 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".