[MPlayer-cvslog] CVS: main/libmpdemux mp3_hdr.c,1.8,1.9
Nico Sabbi CVS
syncmail at mplayerhq.hu
Sat Apr 2 12:30:21 CEST 2005
CVS change done by Nico Sabbi CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv29242
Modified Files:
mp3_hdr.c
Log Message:
added support for mpa layers 1 and 2
Index: mp3_hdr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/mp3_hdr.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mp3_hdr.c 4 Jul 2003 21:04:14 -0000 1.8
+++ mp3_hdr.c 2 Apr 2005 10:30:19 -0000 1.9
@@ -36,6 +36,7 @@
*/
int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate){
int stereo,ssize,lsf,framesize,padding,bitrate_index,sampling_frequency;
+ int layer, mult[3] = { 12000, 144000, 144000 };
unsigned long newhead =
hbuf[0] << 24 |
hbuf[1] << 16 |
@@ -52,8 +53,9 @@
}
#endif
- if((4-((newhead>>17)&3))!=3){
- mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-3\n");
+ layer = 4-((newhead>>17)&3);
+ if(layer==4){
+ mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-1/2/3\n");
return -1;
}
@@ -97,15 +99,20 @@
ssize = (stereo == 1) ? 17 : 32;
if(!((newhead>>16)&0x1)) ssize += 2; // CRC
- framesize = tabsel_123[lsf][2][bitrate_index] * 144000;
+ framesize = tabsel_123[lsf][layer-1][bitrate_index] * mult[layer-1];
+ mp_msg(MSGT_DEMUXER,MSGL_DBG2,"FRAMESIZE: %d, layer: %d, bitrate: %d, mult: %d\n",
+ framesize, layer, tabsel_123[lsf][layer-1][bitrate_index], mult[layer-1]);
if(!framesize){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n");
return -1;
}
framesize /= freqs[sampling_frequency]<<lsf;
- framesize += padding;
+ if(layer==1)
+ framesize = (framesize+padding)*4;
+ else
+ framesize += padding;
// if(framesize<=0 || framesize>MAXFRAMESIZE) return FALSE;
if(srate) *srate = freqs[sampling_frequency];
More information about the MPlayer-cvslog
mailing list