[FFmpeg-devel] [PATCH] scale msadpcm table to fit in int8_t

Reimar Döffinger Reimar.Doeffinger
Fri Jul 11 21:11:56 CEST 2008


Hello,
this implements the same change I did to the MPlayer decoder.
Saves only a few bytes though and would probably be slower on an 8-bit
CPU without good shift support (e.g. Atmel AVR) if someone cares...

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/adpcm.c
===================================================================
--- libavcodec/adpcm.c	(revision 14169)
+++ libavcodec/adpcm.c	(working copy)
@@ -85,12 +85,12 @@
         768, 614, 512, 409, 307, 230, 230, 230
 };
 
-static const int AdaptCoeff1[] = {
-        256, 512, 0, 192, 240, 460, 392
+static const int8_t AdaptCoeff1[] = {
+        64, 128, 0, 48, 60, 115, 98
 };
 
-static const int AdaptCoeff2[] = {
-        0, -256, 0, 64, 0, -208, -232
+static const int8_t AdaptCoeff2[] = {
+        0, -64, 0, 16, 0, -52, -58
 };
 
 /* These are for CD-ROM XA ADPCM */
@@ -226,7 +226,7 @@
 {
     int predictor, nibble, bias;
 
-    predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
+    predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
 
     nibble= sample - predictor;
     if(nibble>=0) bias= c->idelta/2;
@@ -330,7 +330,7 @@
             const int step = nodes[j]->step;
             int nidx;
             if(version == CODEC_ID_ADPCM_MS) {
-                const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256;
+                const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 64;
                 const int div = (sample - predictor) / step;
                 const int nmin = av_clip(div-range, -8, 6);
                 const int nmax = av_clip(div+range, -7, 7);



More information about the ffmpeg-devel mailing list