Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lynne via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Lynne <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] aacsbr_template: fix SBR USAC coupling (PR #21548)
Date: Thu, 22 Jan 2026 19:03:26 -0000
Message-ID: <176910860668.25.2125869130031570562@4457048688e7> (raw)

PR #21548 opened by Lynne
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21548
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21548.patch

This issue hid under the radar since the codebooks between coupling
modes very often result in identical bit counts regardless of the encoded
data, leading to no frame-level bitstream desyncs except in rare cases.

AAC Mps212 data is parsed immediately after the SBR data, where a loss
of sync in SBR will result in Mps212 being wildly different.


>From 82b768cfae1a1f69cb5ae927496083b935ce3837 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Thu, 22 Jan 2026 19:58:31 +0100
Subject: [PATCH] aacsbr_template: fix SBR USAC coupling

This issue hid under the radar since the codebooks between coupling
modes very often result in identical bit counts regardless of the encoded
data, leading to no frame-level bitstream desyncs except in rare cases.

AAC Mps212 data is parsed immediately after the SBR data, where a loss
of sync in SBR will result in Mps212 being wildly different.
---
 libavcodec/aacsbr_template.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index 3c39da509d..dd9340ff2c 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -1287,6 +1287,8 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
         if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb)))
             get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]);
     } else if (get_bits1(gb)) { /* bs_coupling == 1 */
+        sbr->coupling = 1;
+
         /* if (harmonicSBR) ... */
 
         if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
@@ -1317,7 +1319,10 @@ int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
         if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb)))
             get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]);
     } else { /* bs_coupling == 0 */
+        sbr->coupling = 0;
+
         /* if (harmonicSBR) ... */
+
         if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
             return -1;
         if (read_sbr_grid(ac, sbr, gb, &sbr->data[1]))
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-01-22 19:03 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=176910860668.25.2125869130031570562@4457048688e7 \
    --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