[Mplayer-cvslog] CVS: main adpcm.h,1.3,1.4 adpcm.c,1.4,1.5 dec_audio.c,1.66,1.67
Mike Melanson
melanson at mplayer.dev.hu
Sat Dec 29 05:20:33 CET 2001
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv16828
Modified Files:
adpcm.h adpcm.c dec_audio.c
Log Message:
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
default handler for MS ADPCM data
Index: adpcm.h
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- adpcm.h 28 Dec 2001 06:47:15 -0000 1.3
+++ adpcm.h 29 Dec 2001 04:20:29 -0000 1.4
@@ -7,9 +7,8 @@
((IMA_ADPCM_BLOCK_SIZE - IMA_ADPCM_PREAMBLE_SIZE) * 2)
#define MS_ADPCM_PREAMBLE_SIZE 7
-#define MS_ADPCM_BLOCK_SIZE 256
#define MS_ADPCM_SAMPLES_PER_BLOCK \
- ((MS_ADPCM_BLOCK_SIZE - MS_ADPCM_PREAMBLE_SIZE) * 2)
+ ((sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2)
// pretend there's such a thing as mono for this format
#define FOX62_ADPCM_PREAMBLE_SIZE 8
@@ -20,7 +19,7 @@
int ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
int channels);
int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
- int channels);
+ int channels, int block_size);
int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input,
int channels);
Index: adpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/adpcm.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- adpcm.c 28 Dec 2001 06:47:15 -0000 1.4
+++ adpcm.c 29 Dec 2001 04:20:29 -0000 1.5
@@ -211,7 +211,7 @@
}
int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
- int channels)
+ int channels, int block_size)
{
int current_channel = 0;
int idelta[2];
@@ -267,7 +267,7 @@
SE_16BIT(sample2[1]);
}
- while (stream_ptr < MS_ADPCM_BLOCK_SIZE * channels)
+ while (stream_ptr < block_size)
{
// get the next nibble
if (upper_nibble)
@@ -295,7 +295,7 @@
current_channel ^= channels - 1;
}
- return MS_ADPCM_SAMPLES_PER_BLOCK * channels;
+ return (block_size - (MS_ADPCM_PREAMBLE_SIZE * channels)) * 2;
}
// note: This decoder assumes the format 0x62 data always comes in
Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- dec_audio.c 29 Dec 2001 01:32:46 -0000 1.66
+++ dec_audio.c 29 Dec 2001 04:20:29 -0000 1.67
@@ -369,9 +369,9 @@
sh_audio->ds->ss_mul=IMA_ADPCM_BLOCK_SIZE;
break;
case AFM_MSADPCM:
- sh_audio->audio_out_minsize=4096;
- sh_audio->ds->ss_div=MS_ADPCM_SAMPLES_PER_BLOCK;
- sh_audio->ds->ss_mul=MS_ADPCM_BLOCK_SIZE;
+ sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign * 8;
+ sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK;
+ sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
break;
case AFM_FOX62ADPCM:
sh_audio->audio_out_minsize=FOX62_ADPCM_SAMPLES_PER_BLOCK * 4;
@@ -615,7 +615,7 @@
case AFM_MSADPCM:
sh_audio->channels=sh_audio->wf->nChannels;
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
- sh_audio->i_bps=MS_ADPCM_BLOCK_SIZE*
+ sh_audio->i_bps = sh_audio->wf->nBlockAlign *
(sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK;
break;
case AFM_FOX62ADPCM:
@@ -1034,12 +1034,17 @@
break;
}
case AFM_MSADPCM:
- { unsigned char ibuf[MS_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame
+ { static unsigned char *ibuf = NULL;
+ if (!ibuf)
+ ibuf = (unsigned char *)malloc
+ (sh_audio->wf->nBlockAlign * sh_audio->wf->nChannels);
if (demux_read_data(sh_audio->ds, ibuf,
- MS_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) !=
- MS_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels)
+ sh_audio->wf->nBlockAlign) !=
+ sh_audio->wf->nBlockAlign)
break; // EOF
- len=2*ms_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels);
+ len= 2 * ms_adpcm_decode_block(
+ (unsigned short*)buf,ibuf, sh_audio->wf->nChannels,
+ sh_audio->wf->nBlockAlign);
break;
}
case AFM_FOX62ADPCM:
More information about the MPlayer-cvslog
mailing list