# HG changeset patch # User albeu # Date 1027262193 0 # Node ID e29f95ed5d362b2d2598a7e54b938467c768bfbf # Parent 8411ea0d907886e85deb5b80249b2097197cc91c Fix vbr muxing and win32 codec crash on init diff -r 8411ea0d9078 -r e29f95ed5d36 libmpdemux/demux_audio.c --- a/libmpdemux/demux_audio.c Sun Jul 21 12:13:40 2002 +0000 +++ b/libmpdemux/demux_audio.c Sun Jul 21 14:36:33 2002 +0000 @@ -8,6 +8,7 @@ #include "demuxer.h" #include "stheader.h" #include "genres.h" +#include "mp3_hdr.h" #include #ifdef MP_DEBUG @@ -25,7 +26,6 @@ float last_pts; } da_priv_t; -extern int mp_decode_mp3_header(unsigned char* hbuf); extern void free_sh_audio(sh_audio_t* sh); extern void resync_audio_stream(sh_audio_t *sh_audio); @@ -35,7 +35,7 @@ stream_t *s; sh_audio_t* sh_audio; uint8_t hdr[HDR_SIZE]; - int st_pos = 0,frmt = 0, n = 0, pos = 0, step; + int st_pos = 0,frmt = 0, n = 0, pos = 0, step, mp3_freq,mp3_chans; da_priv_t* priv; #ifdef MP_DEBUG assert(demuxer != NULL); @@ -68,7 +68,7 @@ } else if( hdr[0] == 'f' && hdr[1] == 'm' && hdr[2] == 't' && hdr[3] == ' ' ) { frmt = WAV; break; - } else if((n = mp_decode_mp3_header(hdr)) > 0) { + } else if((n = mp_get_mp3_header(hdr,&mp3_chans,&mp3_freq)) > 0) { frmt = MP3; break; } @@ -87,6 +87,16 @@ case MP3: sh_audio->format = 0x55; demuxer->movi_start = st_pos-HDR_SIZE+n; + sh_audio->audio.dwSampleSize= 0; + sh_audio->audio.dwScale = 1152; + sh_audio->audio.dwRate = mp3_freq; + sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + sh_audio->wf->wFormatTag = sh_audio->format; + sh_audio->wf->nChannels = mp3_chans; + sh_audio->wf->nSamplesPerSec = mp3_freq; + sh_audio->wf->nBlockAlign = 1; + sh_audio->wf->wBitsPerSample = 16; + sh_audio->wf->cbSize = 0; for(n = 0; n < 5 ; n++) { pos = mp_decode_mp3_header(hdr); if(pos < 0) diff -r 8411ea0d9078 -r e29f95ed5d36 libmpdemux/mp3_hdr.c --- a/libmpdemux/mp3_hdr.c Sun Jul 21 12:13:40 2002 +0000 +++ b/libmpdemux/mp3_hdr.c Sun Jul 21 14:36:33 2002 +0000 @@ -31,7 +31,7 @@ /* * return frame size or -1 (bad frame) */ -int mp_decode_mp3_header(unsigned char* hbuf){ +int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate){ int stereo,ssize,crc,lsf,mpeg25,framesize,padding,bitrate_index,sampling_frequency; unsigned long newhead = hbuf[0] << 24 | @@ -101,6 +101,8 @@ framesize += padding; // if(framesize<=0 || framesize>MAXFRAMESIZE) return FALSE; + if(srate) *srate = freqs[sampling_frequency]; + if(chans) *chans = stereo; return framesize; } diff -r 8411ea0d9078 -r e29f95ed5d36 libmpdemux/mp3_hdr.h --- a/libmpdemux/mp3_hdr.h Sun Jul 21 12:13:40 2002 +0000 +++ b/libmpdemux/mp3_hdr.h Sun Jul 21 14:36:33 2002 +0000 @@ -1,5 +1,7 @@ -int mp_decode_mp3_header(unsigned char* hbuf); +int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* freq); + +#define mp_decode_mp3_header(hbuf) mp_get_mp3_header(hbuf,NULL,NULL) static inline int mp_check_mp3_header(unsigned int head){ if( (head & 0x0000e0ff) != 0x0000e0ff ||