diff options
author | melanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-29 04:20:29 +0000 |
---|---|---|
committer | melanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-29 04:20:29 +0000 |
commit | 52668414f9adef6cac8301a85bca172a77f78228 (patch) | |
tree | f5d33426a9d6950c8fe6af4487a66a3a4a10b0b7 | |
parent | fa669fa2ee90acaf38fc2febef9ffeb19c4f48f0 (diff) | |
download | mpv-52668414f9adef6cac8301a85bca172a77f78228.tar.bz2 mpv-52668414f9adef6cac8301a85bca172a77f78228.tar.xz |
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
default handler for MS ADPCM data
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3876 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | adpcm.c | 6 | ||||
-rw-r--r-- | adpcm.h | 5 | ||||
-rw-r--r-- | dec_audio.c | 21 | ||||
-rw-r--r-- | etc/codecs.conf | 10 |
4 files changed, 23 insertions, 19 deletions
@@ -211,7 +211,7 @@ int ima_adpcm_decode_block(unsigned short *output, unsigned char *input, } 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 @@ int ms_adpcm_decode_block(unsigned short *output, unsigned char *input, 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 @@ int ms_adpcm_decode_block(unsigned short *output, unsigned char *input, 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 @@ -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); diff --git a/dec_audio.c b/dec_audio.c index 336d6df954..b24790f7ad 100644 --- a/dec_audio.c +++ b/dec_audio.c @@ -369,9 +369,9 @@ case AFM_IMAADPCM: 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_IMAADPCM: 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 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ 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: diff --git a/etc/codecs.conf b/etc/codecs.conf index 289fb119c7..03b6773ad2 100644 --- a/etc/codecs.conf +++ b/etc/codecs.conf @@ -324,11 +324,11 @@ audiocodec imaadpcm format 0x34616d69 ; "ima4" (MOV files) driver imaadpcm -;audiocodec msadpcm -; info "MS ADPCM" -; status buggy -; format 0x2 -; driver msadpcm +audiocodec msadpcm + info "MS ADPCM" + status working + format 0x2 + driver msadpcm audiocodec fox62adpcm info "Format 0x62 ADPCM" |