Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Daniil Cherednik via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Daniil Cherednik <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec/atrac3: fix inconsistent band num calculation (PR #20308)
Date: Thu, 21 Aug 2025 23:21:37 +0300 (EEST)
Message-ID: <20250821202137.DBEC06800E4@ffbox0-bg.ffmpeg.org> (raw)

PR #20308 opened by Daniil Cherednik (dcherednik)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20308
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20308.patch

'decode_spectrum' reads 5 bits from bitstream to get
number of encoded subbands – so 31 means all 32
subbands are encoded. This value also is used to
determinate the number of used band in the hybrid
filterbank.

'subband_tab' array contains 33 values of MDCT spec
line positions started from 0 line and used to map
subband number in to the range of mdct lines.

Since the subband_num returned by decode_spectrum
actually is number – 1 and subband_tab started from 0
we need to add 1 to make num_bands calculation correct.


From 08cccba8e8bd0e2d0608ec19d195bac3da05a9c9 Mon Sep 17 00:00:00 2001
From: Daniil Cherednik <dan.cherednik@gmail.com>
Date: Wed, 20 Aug 2025 21:29:42 +0200
Subject: [PATCH] avcodec/atrac3: fix inconsistent band num calculation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

'decode_spectrum' reads 5 bits from bitstream to get
number of encoded subbands – so 31 means all 32
subbands are encoded. This value also is used to
determinate the number of used band in the hybrid
filterbank.

'subband_tab' array contains 33 values of MDCT spec
line positions started from 0 line and used to map
subband number in to the range of mdct lines.

Since the subband_num returned by decode_spectrum
actually is number – 1 and subband_tab started from 0
we need to add 1 to make num_bands calculation correct.
---
 libavcodec/atrac3.c  | 2 +-
 tests/fate/atrac.mak | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index fe156fa482..d91bdc79ac 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -616,7 +616,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
 
     /* calculate number of used MLT/QMF bands according to the amount of coded
        spectral lines */
-    num_bands = (subband_tab[num_subbands] - 1) >> 8;
+    num_bands = (subband_tab[num_subbands + 1] - 1) >> 8;
     if (last_tonal >= 0)
         num_bands = FFMAX((last_tonal + 256) >> 8, num_bands);
 
diff --git a/tests/fate/atrac.mak b/tests/fate/atrac.mak
index 098063e298..847eed5b61 100644
--- a/tests/fate/atrac.mak
+++ b/tests/fate/atrac.mak
@@ -11,11 +11,11 @@ FATE_ATRAC1-$(call PCM, AEA, ATRAC1, ARESAMPLE_FILTER) += $(FATE_ATRAC1)
 
 FATE_ATRAC3 += fate-atrac3-1
 fate-atrac3-1: CMD = pcm -i $(TARGET_SAMPLES)/atrac3/mc_sich_at3_066_small.wav
-fate-atrac3-1: REF = $(SAMPLES)/atrac3/mc_sich_at3_066_small.pcm
+fate-atrac3-1: REF = $(SAMPLES)/atrac3/mc_sich_at3_066_small_with_band_fix.pcm
 
 FATE_ATRAC3 += fate-atrac3-2
 fate-atrac3-2: CMD = pcm -i $(TARGET_SAMPLES)/atrac3/mc_sich_at3_105_small.wav
-fate-atrac3-2: REF = $(SAMPLES)/atrac3/mc_sich_at3_105_small.pcm
+fate-atrac3-2: REF = $(SAMPLES)/atrac3/mc_sich_at3_105_small_with_band_fix.pcm
 
 FATE_ATRAC3 += fate-atrac3-3
 fate-atrac3-3: CMD = pcm -i $(TARGET_SAMPLES)/atrac3/mc_sich_at3_132_small.wav
-- 
2.49.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".

                 reply	other threads:[~2025-08-21 20:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250821202137.DBEC06800E4@ffbox0-bg.ffmpeg.org \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git