1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

Read extradata for wav files, based on patch by <dimakar(at)yahoo.com>. Required for truespeech files.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9592 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
rtognimp 2003-03-15 14:12:22 +00:00
parent 05ee4cfa8f
commit cde570e129

View File

@ -157,21 +157,32 @@ int demux_audio_open(demuxer_t* demuxer) {
unsigned int chunk_size;
WAVEFORMATEX* w;
int l;
sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX));
l = stream_read_dword_le(s);
if(l < 16) {
printf("Bad wav header length : too short !!!\n");
if(l < sizeof(WAVEFORMATEX)) {
mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] Bad wav header length: too short (%d)!!!\n",l);
free_sh_audio(sh_audio);
return 0;
}
sh_audio->wf = w = (WAVEFORMATEX*)malloc(l);
w->wFormatTag = sh_audio->format = stream_read_word_le(s);
w->nChannels = sh_audio->channels = stream_read_word_le(s);
w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s);
w->nAvgBytesPerSec = stream_read_dword_le(s);
w->nBlockAlign = stream_read_word_le(s);
w->wBitsPerSample = sh_audio->samplesize = stream_read_word_le(s);
w->cbSize = 0;
l -= 16;
w->cbSize = stream_read_word_le(s);
l -= sizeof(WAVEFORMATEX);
if (w->cbSize > 0)
if (l < w->cbSize) {
mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] truncated extradata (%d < %d)\n",
l,w->cbSize);
stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),l);
l = 0;
} else {
stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize);
l -= w->cbSize;
}
if(verbose>0) print_wave_header(w);
if(l)
stream_skip(s,l);