1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

check for framesize validity, return -1 (error) for zero size (bug found by pl)

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7911 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-10-25 14:33:51 +00:00
parent 6f3e7cffaa
commit 0bb18f0541

View File

@ -6,13 +6,13 @@
//----------------------- mp3 audio frame header parser -----------------------
static int tabsel_123[2][3][16] = {
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0},
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0} },
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,0},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0} }
};
static long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
@ -96,7 +96,13 @@ int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate){
ssize = (stereo == 1) ? 17 : 32;
if(crc) ssize += 2;
framesize = (long) tabsel_123[lsf][2][bitrate_index] * 144000;
framesize = tabsel_123[lsf][2][bitrate_index] * 144000;
if(!framesize){
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n");
return -1; // valid: 1..14
}
framesize /= freqs[sampling_frequency]<<lsf;
framesize += padding;