[libav-devel] [PATCH 1/2] adpcm: Store the last predictor properly for IMA QT

Martin Storsjö martin at martin.st
Thu Jun 5 14:16:38 CEST 2014


In general - clear the lowest few bits of the predictor
after each block - this is the actual predictor that the decoder
will use, since no more than 9 bits of it are transmitted.
This was removed in b304244b without any explanation of
why.

Also store the actual used predictor in the trellis case.
The actual predictor value, set by the trellis code, never
was written back into the variable that was written into
the block header. This was also removed without explanation
in b304244b.

This significantly improves the audio quality of the trellis
case, which was plain broken since b304244b.

CC: libav-stable at libav.org
---
 libavcodec/adpcmenc.c         | 2 ++
 tests/ref/acodec/adpcm-ima_qt | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 2cf8d6f..a5a6d0c 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -553,6 +553,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                                        64, 1);
                 for (i = 0; i < 64; i++)
                     put_bits(&pb, 4, buf[i ^ 1]);
+                status->prev_sample = status->predictor & ~0x7F;
             } else {
                 for (i = 0; i < 64; i += 2) {
                     int t1, t2;
@@ -561,6 +562,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                     put_bits(&pb, 4, t2);
                     put_bits(&pb, 4, t1);
                 }
+                status->prev_sample &= ~0x7F;
             }
         }
 
diff --git a/tests/ref/acodec/adpcm-ima_qt b/tests/ref/acodec/adpcm-ima_qt
index 8001527..6d018eb 100644
--- a/tests/ref/acodec/adpcm-ima_qt
+++ b/tests/ref/acodec/adpcm-ima_qt
@@ -1,4 +1,4 @@
-23cbae1182e150ebf28e0abfb9cba127 *tests/data/fate/acodec-adpcm-ima_qt.aiff
+6609b0d57259a6e905807fd8b6a1e482 *tests/data/fate/acodec-adpcm-ima_qt.aiff
 281252 tests/data/fate/acodec-adpcm-ima_qt.aiff
-b0fafd002c38fb70acaddfda1a31ed61 *tests/data/fate/acodec-adpcm-ima_qt.out.wav
-stddev:  904.76 PSNR: 37.20 MAXDIFF:34029 bytes:  1058400/  1058560
+c574b797e31fbbc3ae5bf3533bb5888c *tests/data/fate/acodec-adpcm-ima_qt.out.wav
+stddev:  904.39 PSNR: 37.20 MAXDIFF:34029 bytes:  1058400/  1058560
-- 
1.8.5.2 (Apple Git-48)



More information about the libav-devel mailing list