/* MPEG/WAVE Sound library (C) 1997 by Jung woo-jae */ // Mpeglayer2.cc // It's for MPEG Layer 2 #include "mpegsound.h" #include "synthesis.h" #include using namespace std; #define BUGFIX #include "mpeg2tables.h" // workaround for buggy mpeg2 streams. // tested with 12 monkey cdi, worgked fine. // problem was: the stream produced ints // with access out of the tables // if we have such an access we set it to a zero entry #ifdef BUGFIX static int checkCodeRange(int code,const REAL* group) { int back=0; if (group == NULL) { cout << "group null"< 27*3) { // redirect to zero value back=3; } return back; } if (group == group7bits) { if (back > 125*3) { back=6; } return back; } if (group == group10bits) { if (back > 729*3) { back=12; } return back; } DEBUG_LAYER(cout << "unknown group found!"<getInputstereo(); int tableindex=mpegAudioHeader->getTableindex(); int subbandnumber=mpegAudioHeader->getSubbandnumber(); int stereobound=mpegAudioHeader->getStereobound(); REAL fraction[MAXCHANNEL][3][MAXSUBBAND]; unsigned int bitalloc[MAXCHANNEL][MAXSUBBAND], scaleselector[MAXCHANNEL][MAXSUBBAND]; REAL scalefactor[2][3][MAXSUBBAND]; const REAL *group[MAXCHANNEL][MAXSUBBAND]; unsigned int codelength[MAXCHANNEL][MAXSUBBAND]; REAL factor[MAXCHANNEL][MAXSUBBAND]; REAL c[MAXCHANNEL][MAXSUBBAND],d[MAXCHANNEL][MAXSUBBAND]; int s=stereobound,n=subbandnumber; // Bitalloc { register int i; register const int *t=bitalloclengthtable[tableindex]; for(i=0;i>2][i]; fraction[LS][0][i]*=t; fraction[LS][1][i]*=t; fraction[LS][2][i]*=t; } if(bitalloc[RS][i]) { if(!group[RS][i]) { fraction[RS][0][i]=(fraction[RS][0][i]+d[RS][i])*c[LS][i]; fraction[RS][1][i]=(fraction[RS][1][i]+d[RS][i])*c[LS][i]; fraction[RS][2][i]=(fraction[RS][2][i]+d[RS][i])*c[LS][i]; } register REAL t=scalefactor[RS][l>>2][i]; fraction[RS][0][i]*=t; fraction[RS][1][i]*=t; fraction[RS][2][i]*=t; } } else for(i=0;i>2][i]; fraction[LS][0][i]*=t; fraction[LS][1][i]*=t; fraction[LS][2][i]*=t; } for(;idoSynth(lDownSample,lOutputStereo, fraction[LS][i],fraction[RS][i]); } } } }