Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: tangsha via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: tangsha <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec/adpcm: Fix the decoding error caused by incorrect (PR #21075)
Date: Tue, 02 Dec 2025 01:49:17 -0000
Message-ID: <176464015799.39.7816515649552597850@2cb04c0e5124> (raw)

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

The this patch is based on the latest master branch (not a release branch) – I’ve synced with the mainline before submitting the changes.
Attached is error.wav – this is the problematic audio file that gets fixed by the patch. Prior to the change, decoding this file resulted in [briefly describe the issue, e.g., "distorted audio, incorrect step index calculations, or data misalignment"]; after applying the patch, the audio decodes correctly.
 
Regarding the skipped byte: Based on analyzing the ADPCM format of this sample, the skipped byte is padding/reserved space (not part of the step_index field). The original code incorrectly read this padding byte as part of a 16-bit step_index, leading to the decoding error in error.wav.


From ec27e082181600f31c1aaad3e565853cfa81daaa Mon Sep 17 00:00:00 2001
From: tangsha <tangsha@kylinos.cn>
Date: Mon, 1 Dec 2025 16:15:35 +0800
Subject: [PATCH] avcodec/adpcm: Fix the decoding error caused by incorrect

---
 libavcodec/adpcm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 72fbb841a4..7aac254a4c 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -1512,7 +1512,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
             ADPCMChannelStatus *cs = &c->status[i];
             cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16);
 
-            cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
+	    cs->step_index = bytestream2_get_byteu(&gb);
+	    bytestream2_skip(&gb, sizeof(uint8_t));
             if (cs->step_index > 88u){
                 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
                        i, cs->step_index);
-- 
2.49.1

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

                 reply	other threads:[~2025-12-02  1:49 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=176464015799.39.7816515649552597850@2cb04c0e5124 \
    --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