Mercurial > mplayer.hg
changeset 6763:e29f95ed5d36
Fix vbr muxing and win32 codec crash on init
author | albeu |
---|---|
date | Sun, 21 Jul 2002 14:36:33 +0000 |
parents | 8411ea0d9078 |
children | 7755d1d59394 |
files | libmpdemux/demux_audio.c libmpdemux/mp3_hdr.c libmpdemux/mp3_hdr.h |
diffstat | 3 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 <string.h> #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)
--- 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; }
--- 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 ||