[Mplayer-cvslog] CVS: main/libmpdemux mp3_hdr.c,1.4,1.5 mp3_hdr.h,1.1,1.2 demux_audio.c,1.8,1.9
Alban Bedel CVS
albeu at mplayerhq.hu
Sun Jul 21 16:36:45 CEST 2002
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv15562/libmpdemux
Modified Files:
mp3_hdr.c mp3_hdr.h demux_audio.c
Log Message:
Fix vbr muxing and win32 codec crash on init
Index: mp3_hdr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/mp3_hdr.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mp3_hdr.c 24 Apr 2002 00:49:06 -0000 1.4
+++ mp3_hdr.c 21 Jul 2002 14:36:33 -0000 1.5
@@ -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;
}
Index: mp3_hdr.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/mp3_hdr.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mp3_hdr.h 14 Feb 2002 23:41:00 -0000 1.1
+++ mp3_hdr.h 21 Jul 2002 14:36:33 -0000 1.2
@@ -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 ||
Index: demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- demux_audio.c 24 Apr 2002 17:28:23 -0000 1.8
+++ demux_audio.c 21 Jul 2002 14:36:33 -0000 1.9
@@ -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)
More information about the MPlayer-cvslog
mailing list