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 759C042EBB for ; Thu, 13 Jan 2022 02:34:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A9C668B609; Thu, 13 Jan 2022 04:03:17 +0200 (EET) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0ED6C68B5F4 for ; Thu, 13 Jan 2022 04:03:11 +0200 (EET) Received: by mail-qk1-f177.google.com with SMTP id j85so5613111qke.2 for ; Wed, 12 Jan 2022 18:03:11 -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=eAIyxwTElAOy4VD4nIxGNR9lb7H4i78+4F0rhyod/3E=; b=Wd/beCnLdWBf6lCHOJ5tLyHveb2r2YICzZc760VJna5x7EWlZ+ZZL7y6SCA1vY8D+Q 5K3e3BYJ0GAxrbtVGFOUVBVSA9RQOrMVkk9g49Qib0NbpQalco/xLSLLGDSaa5F8kxBc hWbC1AGUVDMh4q1qok2HtpazOQOF5XDTUF91kq9c9qyXj77Xn2M/JXxLNMSZwrNDgF2T C1F072aIGTt8Eixd59LjkhPXFut0VZqrtt8sP1RpYlsEULxtS9BcaOrTDJ5DK9iDQBSZ uZfH8RI8JTI5eW27AEJ7oIM1zujI4H7vbKuAZbszJRONkzAdmqsWchC1NnlGO6mAbdSi 9R+g== 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=eAIyxwTElAOy4VD4nIxGNR9lb7H4i78+4F0rhyod/3E=; b=luA5vCUkwddnc/YjkUZs+qh7Vk7pyyi1KN916q8d2vH+MbjblnW7KJULug6ALkiyGb GrRhN/RofMCMS+FaL6KWjgIfqJ996pYqNNjZyzvLZsOzQAO+zUMMAKzYO5gxME1SoA/V QtTfhWk2LfgXPbPHSSNG+n7mnvy21DxFr4DWS9Rzei/Ok7q2Uf20RvYyU7tAZ78eg8zQ T+pvhv79QowwyM7H0vmoQZxqxHANDu5MSQ1Ef3gLmQygMVkjUeu5HCpyVmuaFPPkb4Y0 5G3XFAvb1X3c0p0x6dcG3q8KM2mbu1xnF7Wl8Er64VK7hCBYz0QzNC3zj05Syu/Owvh/ yXAg== X-Gm-Message-State: AOAM530JXeOrVfy8zOwVckLZhzOYWtrXqp7p9Og4rAQGHAZn/0Aol/qz 3rmKtJZtY2YxbMLpkeKKtnP5/Rg0uS8= X-Google-Smtp-Source: ABdhPJwAekYRUcn3dVjf/8NRstg54542Hoy1HqcSkujAE+Mc0jd5JWcqBaOw1bmeJyG2oAYrgv9Flg== X-Received: by 2002:ae9:c00f:: with SMTP id u15mr1806330qkk.689.1642039390577; Wed, 12 Jan 2022 18:03:10 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id v1sm1045961qtc.95.2022.01.12.18.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:03:10 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:02:24 -0300 Message-Id: <20220113020242.661-12-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 191/281] atrac3: 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: Anton Khirnov Signed-off-by: James Almer --- libavcodec/atrac3.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 2376a7cd02..772937f5a3 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -646,6 +646,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, ATRAC3Context *q = avctx->priv_data; int ret, i, ch; uint8_t *ptr1; + int channels = avctx->ch_layout.nb_channels; if (q->coding_mode == JOINT_STEREO) { /* channel coupling mode */ @@ -655,9 +656,9 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, const uint8_t *js_databuf; int js_pair, js_block_align; - js_block_align = (avctx->block_align / avctx->channels) * 2; /* block pair */ + js_block_align = (avctx->block_align / channels) * 2; /* block pair */ - for (ch = 0; ch < avctx->channels; ch = ch + 2) { + for (ch = 0; ch < channels; ch = ch + 2) { js_pair = ch/2; js_databuf = databuf + js_pair * js_block_align; /* align to current pair */ @@ -726,11 +727,11 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, } else { /* single channels */ /* Decode the channel sound units. */ - for (i = 0; i < avctx->channels; i++) { + for (i = 0; i < channels; i++) { /* Set the bitstream reader at the start of a channel sound unit. */ init_get_bits(&q->gb, - databuf + i * avctx->block_align / avctx->channels, - avctx->block_align * 8 / avctx->channels); + databuf + i * avctx->block_align / channels, + avctx->block_align * 8 / channels); ret = decode_channel_sound_unit(q, &q->gb, &q->units[i], out_samples[i], i, q->coding_mode); @@ -740,7 +741,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, } /* Apply the iQMF synthesis filter. */ - for (i = 0; i < avctx->channels; i++) { + for (i = 0; i < channels; i++) { float *p1 = out_samples[i]; float *p2 = p1 + 256; float *p3 = p2 + 256; @@ -757,24 +758,25 @@ static int al_decode_frame(AVCodecContext *avctx, const uint8_t *databuf, int size, float **out_samples) { ATRAC3Context *q = avctx->priv_data; + int channels = avctx->ch_layout.nb_channels; int ret, i; /* Set the bitstream reader at the start of a channel sound unit. */ init_get_bits(&q->gb, databuf, size * 8); /* single channels */ /* Decode the channel sound units. */ - for (i = 0; i < avctx->channels; i++) { + for (i = 0; i < channels; i++) { ret = decode_channel_sound_unit(q, &q->gb, &q->units[i], out_samples[i], i, q->coding_mode); if (ret != 0) return ret; - while (i < avctx->channels && get_bits_left(&q->gb) > 6 && show_bits(&q->gb, 6) != 0x28) { + while (i < channels && get_bits_left(&q->gb) > 6 && show_bits(&q->gb, 6) != 0x28) { skip_bits(&q->gb, 1); } } /* Apply the iQMF synthesis filter. */ - for (i = 0; i < avctx->channels; i++) { + for (i = 0; i < channels; i++) { float *p1 = out_samples[i]; float *p2 = p1 + 256; float *p3 = p2 + 256; @@ -879,8 +881,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) const uint8_t *edata_ptr = avctx->extradata; ATRAC3Context *q = avctx->priv_data; AVFloatDSPContext *fdsp; + int channels = avctx->ch_layout.nb_channels; - if (avctx->channels < MIN_CHANNELS || avctx->channels > MAX_CHANNELS) { + if (channels < MIN_CHANNELS || channels > MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); return AVERROR(EINVAL); } @@ -888,7 +891,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) /* Take care of the codec-specific extradata. */ if (avctx->codec_id == AV_CODEC_ID_ATRAC3AL) { version = 4; - samples_per_frame = SAMPLES_PER_FRAME * avctx->channels; + samples_per_frame = SAMPLES_PER_FRAME * channels; delay = 0x88E; q->coding_mode = SINGLE; } else if (avctx->extradata_size == 14) { @@ -904,18 +907,18 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) bytestream_get_le16(&edata_ptr)); // Unknown always 0 /* setup */ - samples_per_frame = SAMPLES_PER_FRAME * avctx->channels; + samples_per_frame = SAMPLES_PER_FRAME * channels; version = 4; delay = 0x88E; q->coding_mode = q->coding_mode ? JOINT_STEREO : SINGLE; q->scrambled_stream = 0; - if (avctx->block_align != 96 * avctx->channels * frame_factor && - avctx->block_align != 152 * avctx->channels * frame_factor && - avctx->block_align != 192 * avctx->channels * frame_factor) { + if (avctx->block_align != 96 * channels * frame_factor && + avctx->block_align != 152 * channels * frame_factor && + avctx->block_align != 192 * channels * frame_factor) { av_log(avctx, AV_LOG_ERROR, "Unknown frame/channel/frame_factor " "configuration %d/%d/%d\n", avctx->block_align, - avctx->channels, frame_factor); + channels, frame_factor); return AVERROR_INVALIDDATA; } } else if (avctx->extradata_size == 12 || avctx->extradata_size == 10) { @@ -939,7 +942,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } - if (samples_per_frame != SAMPLES_PER_FRAME * avctx->channels) { + if (samples_per_frame != SAMPLES_PER_FRAME * channels) { av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n", samples_per_frame); return AVERROR_INVALIDDATA; @@ -954,7 +957,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) if (q->coding_mode == SINGLE) av_log(avctx, AV_LOG_DEBUG, "Single channels detected.\n"); else if (q->coding_mode == JOINT_STEREO) { - if (avctx->channels % 2 == 1) { /* Joint stereo channels must be even */ + if (channels % 2 == 1) { /* Joint stereo channels must be even */ av_log(avctx, AV_LOG_ERROR, "Invalid joint stereo channel configuration.\n"); return AVERROR_INVALIDDATA; } @@ -1004,7 +1007,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) q->vector_fmul = fdsp->vector_fmul; av_free(fdsp); - q->units = av_calloc(avctx->channels, sizeof(*q->units)); + q->units = av_calloc(channels, sizeof(*q->units)); if (!q->units) return AVERROR(ENOMEM); -- 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".