mirror of
https://github.com/mpv-player/mpv
synced 2025-02-25 01:37:21 +00:00
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
This commit is contained in:
parent
fa669fa2ee
commit
52668414f9
6
adpcm.c
6
adpcm.c
@ -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
|
||||
|
5
adpcm.h
5
adpcm.h
@ -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);
|
||||
|
||||
|
21
dec_audio.c
21
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:
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user