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 B97FF42FAE for ; Thu, 13 Jan 2022 02:50:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2ABE068BA3E; Thu, 13 Jan 2022 04:08:03 +0200 (EET) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51EA668BA1F for ; Thu, 13 Jan 2022 04:08:01 +0200 (EET) Received: by mail-qt1-f170.google.com with SMTP id c10so5402555qte.2 for ; Wed, 12 Jan 2022 18:08:01 -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=OJmA+6YThMJkSIemQvoFcLMmR6PIM76TxXhAzmNX5uw=; b=dQEmPJ39SkXybZrmAcIpybzKjm+hvVVOHY2MK+a0KW4btzilNweb8AG4iw+SL8jl/b Qq7BKSB2hLloH85E7m9wmP36mKMNRC68YPJN7tANTJyu2PyOCsUmKfFgUNH71OSui59c seyEt7zbvQou1dnxqCyt35zR6TQbfysxocE8CPuDmkPzbRydWQiR1foxtqBTEHli5pos 9SgIfCdTUjA189HNeGPZdkEMBxbpck2UK0zPxAeKVN7LtlYAV7wovV9EcfH3oVIRy2yo bSep7g4OvaQTtk8l+whImWfd9FL1Evti6uS8ROC5rRT2rgcz2jMppCpnneeIL1gKFpNL NR6A== 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=OJmA+6YThMJkSIemQvoFcLMmR6PIM76TxXhAzmNX5uw=; b=jh1T35R0lhGZsbqipwvTWWELKZcON36NhzU5iSr8Wbx01e5lZm9/0pNXBoolrvpgtY kPtmIMwPJH4t2Yvag3GBsR1WOzhZOu2+bC2PpqR45oIKp0jDsRitV3dzlriLQr2XNd2U ucssdpVq3NTgn847c7sTIZ3nWTfXhm7S7SPiaM6O+DhXQLP0V7BUapG2B5yk26ACCBz6 psfYdt5IPiQiIX9gOtl4OptdvsKcSeZ6OS+V3N9cgEQAx5LItb+QmbGlt8m892X9UTYT +VsYj39KAnBMhvCKC07y5/fg89Te4gQUXky9Ulx8wDWydWxabJCzXkH39acxQzRGE8A1 3AjA== X-Gm-Message-State: AOAM531qVfdm491HLdgEy4RTlZymQkO28XbXa5CcprWQ74aUdTSU7D1+ 2TGI4jdQEkOwHHGUIcfOtv+LqH/Ln+w= X-Google-Smtp-Source: ABdhPJzCK0oIrvSY9TkvjXOqbpfy40s3IQhroAf9uVA69jQnKLzL4Wu0YSVPxNHWe47i48+Muns2sw== X-Received: by 2002:a05:622a:649:: with SMTP id a9mr2002307qtb.604.1642039679796; Wed, 12 Jan 2022 18:07:59 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id a16sm1085946qta.13.2022.01.12.18.07.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:07:59 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:07:09 -0300 Message-Id: <20220113020713.801-26-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 265/281] twinvq: 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: Vittorio Giovara Signed-off-by: James Almer --- libavcodec/twinvq.c | 20 +++++++++++--------- libavcodec/twinvqdec.c | 18 +++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 6dfaf06b14..ba9672a41f 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -217,17 +217,18 @@ static void dec_gain(TwinVQContext *tctx, const TwinVQModeTab *mtab = tctx->mtab; const TwinVQFrameData *bits = &tctx->bits[tctx->cur_frame]; int i, j; + int channels = tctx->avctx->ch_layout.nb_channels; int sub = mtab->fmode[ftype].sub; float step = TWINVQ_AMP_MAX / ((1 << TWINVQ_GAIN_BITS) - 1); float sub_step = TWINVQ_SUB_AMP_MAX / ((1 << TWINVQ_SUB_GAIN_BITS) - 1); if (ftype == TWINVQ_FT_LONG) { - for (i = 0; i < tctx->avctx->channels; i++) + for (i = 0; i < channels; i++) out[i] = (1.0 / (1 << 13)) * twinvq_mulawinv(step * 0.5 + step * bits->gain_bits[i], TWINVQ_AMP_MAX, TWINVQ_MULAW_MU); } else { - for (i = 0; i < tctx->avctx->channels; i++) { + for (i = 0; i < channels; i++) { float val = (1.0 / (1 << 23)) * twinvq_mulawinv(step * 0.5 + step * bits->gain_bits[i], TWINVQ_AMP_MAX, TWINVQ_MULAW_MU); @@ -380,10 +381,11 @@ static void imdct_output(TwinVQContext *tctx, enum TwinVQFrameType ftype, { const TwinVQModeTab *mtab = tctx->mtab; float *prev_buf = tctx->prev_frame + tctx->last_block_pos[0]; + int channels = tctx->avctx->ch_layout.nb_channels; int size1, size2, i; float *out1, *out2; - for (i = 0; i < tctx->avctx->channels; i++) + for (i = 0; i < channels; i++) imdct_and_window(tctx, ftype, wtype, tctx->spectrum + i * mtab->size, prev_buf + 2 * i * mtab->size, @@ -399,7 +401,7 @@ static void imdct_output(TwinVQContext *tctx, enum TwinVQFrameType ftype, memcpy(out1, prev_buf, size1 * sizeof(*out1)); memcpy(out1 + size1, tctx->curr_frame, size2 * sizeof(*out1)); - if (tctx->avctx->channels == 2) { + if (channels == 2) { out2 = &out[1][0] + offset; memcpy(out2, &prev_buf[2 * mtab->size], size1 * sizeof(*out2)); @@ -414,7 +416,7 @@ static void read_and_decode_spectrum(TwinVQContext *tctx, float *out, { const TwinVQModeTab *mtab = tctx->mtab; TwinVQFrameData *bits = &tctx->bits[tctx->cur_frame]; - int channels = tctx->avctx->channels; + int channels = tctx->avctx->ch_layout.nb_channels; int sub = mtab->fmode[ftype].sub; int block_size = mtab->size / sub; float gain[TWINVQ_CHANNELS_MAX * TWINVQ_SUBBLOCKS_MAX]; @@ -536,7 +538,7 @@ static av_cold int init_mdct_win(TwinVQContext *tctx) const TwinVQModeTab *mtab = tctx->mtab; int size_s = mtab->size / mtab->fmode[TWINVQ_FT_SHORT].sub; int size_m = mtab->size / mtab->fmode[TWINVQ_FT_MEDIUM].sub; - int channels = tctx->avctx->channels; + int channels = tctx->avctx->ch_layout.nb_channels; float norm = channels == 1 ? 2.0 : 1.0; int table_size = 2 * mtab->size * channels; @@ -645,10 +647,10 @@ static av_cold void construct_perm_table(TwinVQContext *tctx, int16_t *tmp_perm = (int16_t *)tctx->tmp_buf; if (ftype == TWINVQ_FT_PPC) { - size = tctx->avctx->channels; + size = tctx->avctx->ch_layout.nb_channels; block_size = mtab->ppc_shape_len; } else { - size = tctx->avctx->channels * mtab->fmode[ftype].sub; + size = tctx->avctx->ch_layout.nb_channels * mtab->fmode[ftype].sub; block_size = mtab->size / mtab->fmode[ftype].sub; } @@ -666,7 +668,7 @@ static av_cold void construct_perm_table(TwinVQContext *tctx, static av_cold void init_bitstream_params(TwinVQContext *tctx) { const TwinVQModeTab *mtab = tctx->mtab; - int n_ch = tctx->avctx->channels; + int n_ch = tctx->avctx->ch_layout.nb_channels; int total_fr_bits = tctx->avctx->bit_rate * mtab->size / tctx->avctx->sample_rate; diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c index 1fbe0bc32e..98702c7ef2 100644 --- a/libavcodec/twinvqdec.c +++ b/libavcodec/twinvqdec.c @@ -181,7 +181,7 @@ static void decode_ppc(TwinVQContext *tctx, int period_coef, int g_coef, { const TwinVQModeTab *mtab = tctx->mtab; int isampf = tctx->avctx->sample_rate / 1000; - int ibps = tctx->avctx->bit_rate / (1000 * tctx->avctx->channels); + int ibps = tctx->avctx->bit_rate / (1000 * tctx->avctx->ch_layout.nb_channels); int min_period = ROUNDED_DIV(40 * 2 * mtab->size, isampf); int max_period = ROUNDED_DIV(40 * 2 * mtab->size * 6, isampf); int period_range = max_period - min_period; @@ -254,7 +254,7 @@ static int twinvq_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, { TwinVQFrameData *bits = &tctx->bits[0]; 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; @@ -319,14 +319,14 @@ static int twinvq_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, static av_cold int twinvq_decode_init(AVCodecContext *avctx) { - int isampf, ibps; + int isampf, ibps, channels; TwinVQContext *tctx = avctx->priv_data; if (!avctx->extradata || avctx->extradata_size < 12) { av_log(avctx, AV_LOG_ERROR, "Missing or incomplete extradata\n"); return AVERROR_INVALIDDATA; } - avctx->channels = AV_RB32(avctx->extradata) + 1; + channels = AV_RB32(avctx->extradata) + 1; avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000; isampf = AV_RB32(avctx->extradata + 8); @@ -349,15 +349,15 @@ static av_cold int twinvq_decode_init(AVCodecContext *avctx) break; } - 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 -1; } - 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); if (ibps < 8 || ibps > 48) { av_log(avctx, AV_LOG_ERROR, "Bad bitrate per channel value %d\n", ibps); return AVERROR_INVALIDDATA; -- 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".