# HG changeset patch # User nicodvb # Date 1112437819 0 # Node ID c9e2d75a9013b6f0a729a8ab0beef19c7cd8d022 # Parent 2c9d334d244adc83ddc30432a19a7fbe250959ef added support for mpa layers 1 and 2 diff -r 2c9d334d244a -r c9e2d75a9013 libmpdemux/mp3_hdr.c --- a/libmpdemux/mp3_hdr.c Fri Apr 01 19:52:05 2005 +0000 +++ b/libmpdemux/mp3_hdr.c Sat Apr 02 10:30:19 2005 +0000 @@ -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]<MAXFRAMESIZE) return FALSE; if(srate) *srate = freqs[sampling_frequency];