[Mplayer-cvslog] CVS: main dec_audio.c,1.73,1.74 adpcm.h,1.4,1.5 adpcm.c,1.5,1.6 codec-cfg.c,1.59,1.60 codec-cfg.h,1.33,1.34
Mike Melanson
melanson at mplayer.dev.hu
Tue Jan 1 21:04:56 CET 2002
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv13267
Modified Files:
dec_audio.c adpcm.h adpcm.c codec-cfg.c codec-cfg.h
Log Message:
added initial support for format 0x61 ADPCM (sounds good, but still pops)
Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- dec_audio.c 30 Dec 2001 21:55:58 -0000 1.73
+++ dec_audio.c 1 Jan 2002 20:04:54 -0000 1.74
@@ -412,6 +412,11 @@
sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK;
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
break;
+case AFM_FOX61ADPCM:
+ sh_audio->audio_out_minsize=FOX61_ADPCM_SAMPLES_PER_BLOCK * 4;
+ sh_audio->ds->ss_div=FOX61_ADPCM_SAMPLES_PER_BLOCK;
+ sh_audio->ds->ss_mul=FOX61_ADPCM_BLOCK_SIZE;
+ break;
case AFM_FOX62ADPCM:
sh_audio->audio_out_minsize=FOX62_ADPCM_SAMPLES_PER_BLOCK * 4;
sh_audio->ds->ss_div=FOX62_ADPCM_SAMPLES_PER_BLOCK;
@@ -693,6 +698,12 @@
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
(sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK;
break;
+case AFM_FOX61ADPCM:
+ sh_audio->channels=sh_audio->wf->nChannels;
+ sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
+ sh_audio->i_bps=FOX61_ADPCM_BLOCK_SIZE*
+ (sh_audio->channels*sh_audio->samplerate) / FOX61_ADPCM_SAMPLES_PER_BLOCK;
+ break;
case AFM_FOX62ADPCM:
sh_audio->channels=sh_audio->wf->nChannels;
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
@@ -1122,13 +1133,22 @@
sh_audio->wf->nBlockAlign);
break;
}
+ case AFM_FOX61ADPCM:
+ { unsigned char ibuf[FOX61_ADPCM_BLOCK_SIZE]; // bytes / stereo frame
+ if (demux_read_data(sh_audio->ds, ibuf, FOX61_ADPCM_BLOCK_SIZE) !=
+ FOX61_ADPCM_BLOCK_SIZE)
+ break; // EOF
+ len=2*fox61_adpcm_decode_block((unsigned short*)buf,ibuf);
+ break;
+ }
case AFM_FOX62ADPCM:
{ unsigned char ibuf[FOX62_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame
if (demux_read_data(sh_audio->ds, ibuf,
FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) !=
FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels)
break; // EOF
- len=2*fox62_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels);
+ len = 2 * fox62_adpcm_decode_block(
+ (unsigned short*)buf,ibuf, sh_audio->wf->nChannels);
break;
}
#ifdef USE_LIBAC3
Index: adpcm.h
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- adpcm.h 29 Dec 2001 04:20:29 -0000 1.4
+++ adpcm.h 1 Jan 2002 20:04:54 -0000 1.5
@@ -10,6 +10,11 @@
#define MS_ADPCM_SAMPLES_PER_BLOCK \
((sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2)
+#define FOX61_ADPCM_PREAMBLE_SIZE 4
+#define FOX61_ADPCM_BLOCK_SIZE 0x200
+#define FOX61_ADPCM_SAMPLES_PER_BLOCK \
+ (((FOX61_ADPCM_BLOCK_SIZE - FOX61_ADPCM_PREAMBLE_SIZE) * 2) + 1)
+
// pretend there's such a thing as mono for this format
#define FOX62_ADPCM_PREAMBLE_SIZE 8
#define FOX62_ADPCM_BLOCK_SIZE 0x400
@@ -20,7 +25,7 @@
int channels);
int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
int channels, int block_size);
+int fox61_adpcm_decode_block(unsigned short *output, unsigned char *input);
int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input,
int channels);
-
#endif
Index: adpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- adpcm.c 29 Dec 2001 04:20:29 -0000 1.5
+++ adpcm.c 1 Jan 2002 20:04:54 -0000 1.6
@@ -298,6 +298,68 @@
return (block_size - (MS_ADPCM_PREAMBLE_SIZE * channels)) * 2;
}
+// note: This decoder assumes the format 0x61 data always comes in
+// mono flavor
+int fox61_adpcm_decode_block(unsigned short *output, unsigned char *input)
+{
+ int i;
+ int out_ptr = 0;
+
+ int predictor;
+ int index;
+ int nibble;
+ int sign;
+ int delta;
+ int diff;
+ int step;
+
+ predictor = output[out_ptr++] = LE_16(&input[0]);
+ index = input[2];
+
+ // iterate through and decode the rest of the bytes
+ for (i = 4; i < FOX61_ADPCM_BLOCK_SIZE; i++)
+ {
+ nibble = (input[i] >> 4) & 0x0F;
+
+ step = adpcm_step[index];
+ sign = nibble & 8;
+ delta = nibble & 7;
+ diff = step >> 3;
+ if (delta & 4) diff += step;
+ if (delta & 2) diff += step >> 1;
+ if (delta & 1) diff += step >> 2;
+ if (sign)
+ predictor -= diff;
+ else
+ predictor += diff;
+ CLAMP_S16(predictor);
+ output[out_ptr++] = predictor;
+ index += adpcm_index[nibble];
+ CLAMP_0_TO_88(index);
+
+ nibble = input[i] & 0x0F;
+
+ step = adpcm_step[index];
+ sign = nibble & 8;
+ delta = nibble & 7;
+ diff = step >> 3;
+ if (delta & 4) diff += step;
+ if (delta & 2) diff += step >> 1;
+ if (delta & 1) diff += step >> 2;
+ if (sign)
+ predictor -= diff;
+ else
+ predictor += diff;
+ CLAMP_S16(predictor);
+ output[out_ptr++] = predictor;
+ index += adpcm_index[nibble];
+ CLAMP_0_TO_88(index);
+ }
+
+ return FOX61_ADPCM_SAMPLES_PER_BLOCK;
+}
+
+
// note: This decoder assumes the format 0x62 data always comes in
// stereo flavor
int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input,
Index: codec-cfg.c
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- codec-cfg.c 31 Dec 2001 10:25:11 -0000 1.59
+++ codec-cfg.c 1 Jan 2002 20:04:54 -0000 1.60
@@ -219,6 +219,7 @@
"liba52",
"g72x",
"imaadpcm",
+ "fox61adpcm",
"fox62adpcm",
NULL
};
Index: codec-cfg.h
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- codec-cfg.h 28 Dec 2001 06:47:15 -0000 1.33
+++ codec-cfg.h 1 Jan 2002 20:04:54 -0000 1.34
@@ -34,7 +34,8 @@
#define AFM_A52 14
#define AFM_G72X 15
#define AFM_IMAADPCM 16
-#define AFM_FOX62ADPCM 17
+#define AFM_FOX61ADPCM 17
+#define AFM_FOX62ADPCM 18
#define VFM_MPEG 1
#define VFM_VFW 2
More information about the MPlayer-cvslog
mailing list