Commit d7bc030495 for ffmpeg

commit d7bc0304952beeef1d2568e00b3b37c6a9a7685c
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date:   Thu Nov 19 19:45:28 2026 -0800

    avcodec/truespeech: fix LPC interpolation and pitch memory update

    With interpolation enabled, weight the previous filter 2:1 in
    subframe 0 and the current filter 2:1 in subframe 1. With
    interpolation disabled, use the current filter in subframe 1.
    Subtract the pulse excitation shifted right by three from the
    pitch history sum.

    Matches the Windows 2000 TrueSpeech decoder (tssoft32.acm 1.1.1.5
    and tsd32.dll 1.3.3.7) bit for bit on FATE's a6.wav and the
    Microsoft-encoded truespeech-mono-8000.wav. Check the entire
    decoded PCM stream in FATE.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>

diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index 1c1b4057a2..a96afa3219 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -152,12 +152,12 @@ static void truespeech_filters_merge(TSContext *dec)
     if(!dec->flag){
         for(i = 0; i < 8; i++){
             dec->filters[i + 0] = dec->prevfilt[i];
-            dec->filters[i + 8] = dec->prevfilt[i];
+            dec->filters[i + 8] = dec->cvector[i];
         }
     }else{
         for(i = 0; i < 8; i++){
-            dec->filters[i + 0]=(dec->cvector[i] * 21846 + dec->prevfilt[i] * 10923 + 16384) >> 15;
-            dec->filters[i + 8]=(dec->cvector[i] * 10923 + dec->prevfilt[i] * 21846 + 16384) >> 15;
+            dec->filters[i + 0]=(dec->cvector[i] * 10923 + dec->prevfilt[i] * 21846 + 16384) >> 15;
+            dec->filters[i + 8]=(dec->cvector[i] * 21846 + dec->prevfilt[i] * 10923 + 16384) >> 15;
         }
     }
     for(i = 0; i < 8; i++){
@@ -241,7 +241,7 @@ static void truespeech_update_filters(TSContext *dec, int16_t *out, int quart)

     memmove(dec->filtbuf, &dec->filtbuf[60], 86 * sizeof(*dec->filtbuf));
     for(i = 0; i < 60; i++){
-        dec->filtbuf[i + 86] = out[i] + dec->newvec[i] - (dec->newvec[i] >> 3);
+        dec->filtbuf[i + 86] = out[i] + dec->newvec[i] - (out[i] >> 3);
         out[i] += dec->newvec[i];
     }
 }
diff --git a/tests/fate/voice.mak b/tests/fate/voice.mak
index 2cfaaced45..219fcef72c 100644
--- a/tests/fate/voice.mak
+++ b/tests/fate/voice.mak
@@ -108,10 +108,8 @@ fate-qcelp: CMP = oneoff
 fate-qcelp: REF = $(SAMPLES)/qcp/0036580847-is733.pcm
 fate-qcelp: FUZZ = 2

-FATE_VOICE-$(call PCM, WAV, TRUESPEECH) += fate-truespeech
-fate-truespeech: CMD = pcm -i $(TARGET_SAMPLES)/truespeech/a6.wav
-fate-truespeech: CMP = oneoff
-fate-truespeech: REF = $(SAMPLES)/truespeech/a6.pcm
+FATE_VOICE-$(call DEMDEC, WAV, TRUESPEECH, PCM_S16LE_ENCODER PCM_S16LE_MUXER) += fate-truespeech
+fate-truespeech: CMD = md5 -i $(TARGET_SAMPLES)/truespeech/a6.wav -bitexact -f s16le

 # This test reproduces a float-cast-overflow in the comfortnoise decoder
 # (cngdec.c) when fed with a 24-byte all-zero G.723.1 frame.
diff --git a/tests/ref/fate/truespeech b/tests/ref/fate/truespeech
new file mode 100644
index 0000000000..93c3381019
--- /dev/null
+++ b/tests/ref/fate/truespeech
@@ -0,0 +1 @@
+d0d4055687afda734c294abcf96a871e