[FFmpeg-cvslog] avcodec/adxenc: match prediction used in the decoder

Michael Niedermayer git at videolan.org
Sun Nov 30 12:54:46 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Nov 30 12:40:03 2014 +0100| [6b0ab561d019c12471920ae136c746d3a54878e8] | committer: Michael Niedermayer

avcodec/adxenc: match prediction used in the decoder

The prediction used in the encoder was not correct

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b0ab561d019c12471920ae136c746d3a54878e8
---

 libavcodec/adxenc.c                |   25 +++++++++++++++++++------
 tests/ref/acodec/adpcm-adx         |    6 +++---
 tests/ref/acodec/adpcm-adx-trellis |    6 +++---
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index 05e3245..aee444e 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -43,14 +43,12 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
     int s0, s1, s2, d;
     int max = 0;
     int min = 0;
-    int data[BLOCK_SAMPLES];
 
     s1 = prev->s1;
     s2 = prev->s2;
     for (i = 0, j = 0; j < 32; i += channels, j++) {
         s0 = wav[i];
         d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
-        data[j] = d;
         if (max < d)
             max = d;
         if (min > d)
@@ -58,10 +56,10 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
         s2 = s1;
         s1 = s0;
     }
-    prev->s1 = s1;
-    prev->s2 = s2;
 
     if (max == 0 && min == 0) {
+        prev->s1 = s1;
+        prev->s2 = s2;
         memset(adx, 0, BLOCK_SIZE);
         return;
     }
@@ -77,8 +75,23 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
     AV_WB16(adx, scale);
 
     init_put_bits(&pb, adx + 2, 16);
-    for (i = 0; i < BLOCK_SAMPLES; i++)
-        put_sbits(&pb, 4, av_clip(data[i] / scale, -8, 7));
+
+    s1 = prev->s1;
+    s2 = prev->s2;
+    for (i = 0, j = 0; j < 32; i += channels, j++) {
+        d = ((wav[i] << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
+
+        d = av_clip(d / scale, -8, 7);
+
+        put_sbits(&pb, 4, d);
+
+        s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;
+        s2 = s1;
+        s1 = s0;
+    }
+    prev->s1 = s1;
+    prev->s2 = s2;
+
     flush_put_bits(&pb);
 }
 
diff --git a/tests/ref/acodec/adpcm-adx b/tests/ref/acodec/adpcm-adx
index b96d99a..33a502f 100644
--- a/tests/ref/acodec/adpcm-adx
+++ b/tests/ref/acodec/adpcm-adx
@@ -1,4 +1,4 @@
-0a30509d9296b857e134b762b76dbc31 *tests/data/fate/acodec-adpcm-adx.adx
+d82a87942d6500adb4d07d21cbcbdb78 *tests/data/fate/acodec-adpcm-adx.adx
 297720 tests/data/fate/acodec-adpcm-adx.adx
-7260139001fcac62384dad50a1023e75 *tests/data/fate/acodec-adpcm-adx.out.wav
-stddev: 6989.46 PSNR: 19.44 MAXDIFF:65398 bytes:  1058400/  1058432
+4e78a1153eb8fc4dfc050836f46b62f8 *tests/data/fate/acodec-adpcm-adx.out.wav
+stddev: 3096.24 PSNR: 26.51 MAXDIFF:53110 bytes:  1058400/  1058432
diff --git a/tests/ref/acodec/adpcm-adx-trellis b/tests/ref/acodec/adpcm-adx-trellis
index fff0291..a36e7f9 100644
--- a/tests/ref/acodec/adpcm-adx-trellis
+++ b/tests/ref/acodec/adpcm-adx-trellis
@@ -1,4 +1,4 @@
-0a30509d9296b857e134b762b76dbc31 *tests/data/fate/acodec-adpcm-adx-trellis.adx
+d82a87942d6500adb4d07d21cbcbdb78 *tests/data/fate/acodec-adpcm-adx-trellis.adx
 297720 tests/data/fate/acodec-adpcm-adx-trellis.adx
-7260139001fcac62384dad50a1023e75 *tests/data/fate/acodec-adpcm-adx-trellis.out.wav
-stddev: 6989.46 PSNR: 19.44 MAXDIFF:65398 bytes:  1058400/  1058432
+4e78a1153eb8fc4dfc050836f46b62f8 *tests/data/fate/acodec-adpcm-adx-trellis.out.wav
+stddev: 3096.24 PSNR: 26.51 MAXDIFF:53110 bytes:  1058400/  1058432



More information about the ffmpeg-cvslog mailing list