[Mplayer-cvslog] CVS: main adpcm.c,1.9,1.10 adpcm.h,1.7,1.8

Mike Melanson melanson at mplayer.dev.hu
Sat Mar 30 23:27:46 CET 2002


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv6419

Modified Files:
	adpcm.c adpcm.h 
Log Message:
reworked ADPCM decoders; changes include:
 * fixed MS IMA ADPCM
 * dissolved adpcm.c/.h into appropriate ad_* decoders
 * DK4 audio is handled directly by IMA ADPCM decoder (this obsoletes
   ad_dk4adpcm.c)


Index: adpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- adpcm.c	25 Feb 2002 02:48:37 -0000	1.9
+++ adpcm.c	30 Mar 2002 22:27:35 -0000	1.10
@@ -9,6 +9,7 @@
     (C) 2001 Mike Melanson
 */
 
+#if 0
 #include "config.h"
 #include "bswap.h"
 #include "adpcm.h"
@@ -119,7 +120,7 @@
   }
 }
 
-int ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
+int qt_ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
   int channels)
 {
   int initial_predictor_l = 0;
@@ -180,6 +181,67 @@
   return IMA_ADPCM_SAMPLES_PER_BLOCK * channels;
 }
 
+int ms_ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
+  int channels, int block_size)
+{
+  int initial_predictor_l = 0;
+  int initial_predictor_r = 0;
+  int initial_index_l = 0;
+  int initial_index_r = 0;
+  int i;
+
+  initial_predictor_l = BE_16(&input[0]);
+  initial_index_l = initial_predictor_l;
+
+  // mask, sign-extend, and clamp the predictor portion
+  initial_predictor_l &= 0xFF80;
+  SE_16BIT(initial_predictor_l);
+  CLAMP_S16(initial_predictor_l);
+
+  // mask and clamp the index portion
+  initial_index_l &= 0x7F;
+  CLAMP_0_TO_88(initial_index_l);
+
+  // handle stereo
+  if (channels > 1)
+  {
+    initial_predictor_r = BE_16(&input[IMA_ADPCM_BLOCK_SIZE]);
+    initial_index_r = initial_predictor_r;
+
+    // mask, sign-extend, and clamp the predictor portion
+    initial_predictor_r &= 0xFF80;
+    SE_16BIT(initial_predictor_r);
+    CLAMP_S16(initial_predictor_r);
+
+    // mask and clamp the index portion
+    initial_index_r &= 0x7F;
+    CLAMP_0_TO_88(initial_index_r);
+  }
+
+  // break apart all of the nibbles in the block
+  if (channels == 1)
+    for (i = 0; i < IMA_ADPCM_SAMPLES_PER_BLOCK / 2; i++)
+    {
+      output[i * 2 + 0] = input[2 + i] & 0x0F;
+      output[i * 2 + 1] = input[2 + i] >> 4;
+    }  
+  else
+    for (i = 0; i < IMA_ADPCM_SAMPLES_PER_BLOCK / 2 * 2; i++)
+    {
+      output[i * 4 + 0] = input[2 + i] & 0x0F;
+      output[i * 4 + 1] = input[2 + IMA_ADPCM_BLOCK_SIZE + i] & 0x0F;
+      output[i * 4 + 2] = input[2 + i] >> 4;
+      output[i * 4 + 3] = input[2 + IMA_ADPCM_BLOCK_SIZE + i] >> 4;
+    }  
+
+  decode_nibbles(output,
+    IMA_ADPCM_SAMPLES_PER_BLOCK * channels, channels,
+    initial_predictor_l, initial_index_l,
+    initial_predictor_r, initial_index_r);
+
+  return IMA_ADPCM_SAMPLES_PER_BLOCK * channels;
+}
+
 int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
   int channels, int block_size)
 {
@@ -439,3 +501,5 @@
 
   return out_ptr;
 }
+#endif
+

Index: adpcm.h
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- adpcm.h	25 Feb 2002 02:48:37 -0000	1.7
+++ adpcm.h	30 Mar 2002 22:27:35 -0000	1.8
@@ -20,8 +20,10 @@
 // this isn't exact
 #define DK3_ADPCM_SAMPLES_PER_BLOCK 6000
 
-int ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
+int qt_ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
   int channels);
+int ms_ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
+  int channels, int block_size);
 int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
   int channels, int block_size);
 int dk4_adpcm_decode_block(unsigned short *output, unsigned char *input,




More information about the MPlayer-cvslog mailing list