⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpeglayer2.cpp

📁 This code is based on mpeg_play, available from: http://bmrc.berkeley.edu/frame/research/mpeg/
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  4.0/9.0,-4.0/9.0, 4.0/9.0,  6.0/9.0,-4.0/9.0, 4.0/9.0,  8.0/9.0,-4.0/9.0, 4.0/9.0, -8.0/9.0,-2.0/9.0, 4.0/9.0, -6.0/9.0,-2.0/9.0, 4.0/9.0, -4.0/9.0,-2.0/9.0, 4.0/9.0, -2.0/9.0,-2.0/9.0, 4.0/9.0,      0.0,-2.0/9.0, 4.0/9.0,  2.0/9.0,-2.0/9.0, 4.0/9.0,  4.0/9.0,-2.0/9.0, 4.0/9.0,  6.0/9.0,-2.0/9.0, 4.0/9.0,  8.0/9.0,-2.0/9.0, 4.0/9.0, -8.0/9.0,     0.0, 4.0/9.0, -6.0/9.0,     0.0, 4.0/9.0, -4.0/9.0,     0.0, 4.0/9.0, -2.0/9.0,     0.0, 4.0/9.0,      0.0,     0.0, 4.0/9.0,  2.0/9.0,     0.0, 4.0/9.0,  4.0/9.0,     0.0, 4.0/9.0,  6.0/9.0,     0.0, 4.0/9.0,  8.0/9.0,     0.0, 4.0/9.0, -8.0/9.0, 2.0/9.0, 4.0/9.0, -6.0/9.0, 2.0/9.0, 4.0/9.0, -4.0/9.0, 2.0/9.0, 4.0/9.0, -2.0/9.0, 2.0/9.0, 4.0/9.0,      0.0, 2.0/9.0, 4.0/9.0,  2.0/9.0, 2.0/9.0, 4.0/9.0,  4.0/9.0, 2.0/9.0, 4.0/9.0,  6.0/9.0, 2.0/9.0, 4.0/9.0,  8.0/9.0, 2.0/9.0, 4.0/9.0, -8.0/9.0, 4.0/9.0, 4.0/9.0, -6.0/9.0, 4.0/9.0, 4.0/9.0, -4.0/9.0, 4.0/9.0, 4.0/9.0, -2.0/9.0, 4.0/9.0, 4.0/9.0,      0.0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9.0, 2.0/9.0, 8.0/9.0, -8.0/9.0, 4.0/9.0, 8.0/9.0, -6.0/9.0, 4.0/9.0, 8.0/9.0, -4.0/9.0, 4.0/9.0, 8.0/9.0, -2.0/9.0, 4.0/9.0, 8.0/9.0,      0.0, 4.0/9.0, 8.0/9.0,  2.0/9.0, 4.0/9.0, 8.0/9.0,  4.0/9.0, 4.0/9.0, 8.0/9.0,  6.0/9.0, 4.0/9.0, 8.0/9.0,  8.0/9.0, 4.0/9.0, 8.0/9.0, -8.0/9.0, 6.0/9.0, 8.0/9.0, -6.0/9.0, 6.0/9.0, 8.0/9.0, -4.0/9.0, 6.0/9.0, 8.0/9.0, -2.0/9.0, 6.0/9.0, 8.0/9.0,      0.0, 6.0/9.0, 8.0/9.0,  2.0/9.0, 6.0/9.0, 8.0/9.0,  4.0/9.0, 6.0/9.0, 8.0/9.0,  6.0/9.0, 6.0/9.0, 8.0/9.0,  8.0/9.0, 6.0/9.0, 8.0/9.0, -8.0/9.0, 8.0/9.0, 8.0/9.0, -6.0/9.0, 8.0/9.0, 8.0/9.0, -4.0/9.0, 8.0/9.0, 8.0/9.0, -2.0/9.0, 8.0/9.0, 8.0/9.0,      0.0, 8.0/9.0, 8.0/9.0,  2.0/9.0, 8.0/9.0, 8.0/9.0,  4.0/9.0, 8.0/9.0, 8.0/9.0,  6.0/9.0, 8.0/9.0, 8.0/9.0,  8.0/9.0, 8.0/9.0, 8.0/9.0};static const REAL *grouptableA[16] ={ 0,group5bits,group7bits,group10bits,0,0,0,0,0,0,0,0,0,0,0,0};static const REAL *grouptableB1[16] ={ 0,group5bits,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };static const REAL *grouptableB234[16] ={ 0,group5bits,group7bits,0,group10bits,0,0,0,0,0,0,0,0,0,0,0};static const int codelengthtableA[16] ={ 0, 5, 7, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };static const int codelengthtableB1[16] ={ 0, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };static const int codelengthtableB2[16] ={ 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 };static const int codelengthtableB3[8] = { 0, 5, 7, 3, 10, 4, 5, 16 };static const int codelengthtableB4[4] = { 0, 5, 7, 16 };static const REAL factortableA[16] ={ 0.0,        1.0/2.0,    1.0/4.0,    1.0/8.0,  1.0/8.0,    1.0/16.0,   1.0/32.0,   1.0/64.0,  1.0/128.0,  1.0/256.0,  1.0/512.0,  1.0/1024.0,  1.0/2048.0, 1.0/4096.0, 1.0/8192.0, 1.0/16384.0 };static const REAL factortableB1[16] ={ 0.0,        1.0/2.0,    1.0/4.0,     1.0/8.0,   1.0/16.0,   1.0/32.0,   1.0/64.0,    1.0/128.0,   1.0/256.0,  1.0/512.0,  1.0/1024.0,  1.0/2048.0,  1.0/4096.0, 1.0/8192.0, 1.0/16384.0, 1.0/32768.0 };static const REAL factortableB2[16] ={ 0.0,        1.0/2.0,    1.0/4.0,    1.0/4.0,  1.0/8.0,    1.0/8.0,    1.0/16.0,   1.0/32.0,  1.0/64.0,   1.0/128.0,  1.0/256.0,  1.0/512.0,  1.0/1024.0, 1.0/2048.0, 1.0/4096.0, 1.0/32768.0 };static const REAL factortableB3[8] ={ 0.0, 1.0/2.0, 1.0/4.0, 1.0/4.0, 1.0/8.0, 1.0/8.0, 1.0/16.0, 1.0/32768.0 };static const REAL factortableB4[4] = { 0.0, 1.0/2.0, 1.0/4.0, 1.0/32768.0 };static const REAL ctableA[16]={           0.0, 1.33333333333, 1.60000000000, 1.77777777777,  1.06666666666, 1.03225806452, 1.01587301587, 1.00787401575,  1.00392156863, 1.00195694716, 1.00097751711, 1.00048851979,  1.00024420024, 1.00012208522, 1.00006103888, 1.00003051851};static const REAL ctableB1[16]={           0.0, 1.33333333333, 1.14285714286, 1.06666666666,  1.03225806452, 1.01587301587, 1.00787401575, 1.00392156863,  1.00195694716, 1.00097751711, 1.00048851979, 1.00024420024,  1.00012208522, 1.00006103888, 1.00003051851, 1.00001525902};static const REAL ctableB2[16] ={           0.0, 1.33333333333, 1.60000000000, 1.14285714286,  1.77777777777, 1.06666666666, 1.03225806452, 1.01587301587,  1.00787401575, 1.00392156863, 1.00195694716, 1.00097751711,  1.00048851979, 1.00024420024, 1.00012208522, 1.00001525902};static const REAL ctableB3[8] ={           0.0, 1.33333333333, 1.60000000000, 1.14285714286,  1.77777777777, 1.06666666666, 1.03225806452, 1.00001525902 };static const REAL ctableB4[4] = { 0.0, 1.33333333333, 1.60000000000, 1.00001525902 };static const REAL dtableA[16]={           0.0, 0.50000000000, 0.50000000000, 0.50000000000,  0.12500000000, 0.06250000000, 0.03125000000, 0.01562500000,  0.00781250000, 0.00390625000, 0.00195312500, 0.00097656250,  0.00048828125, 0.00024414063, 0.00012207031, 0.00006103516};static const REAL dtableB1[16]={           0.0, 0.50000000000, 0.25000000000, 0.12500000000,  0.06250000000, 0.03125000000, 0.01562500000, 0.00781250000,  0.00390625000, 0.00195312500, 0.00097656250, 0.00048828125,  0.00024414063, 0.00012207031, 0.00006103516, 0.00003051758};static const REAL dtableB2[16]={ 0.0,           0.50000000000, 0.50000000000, 0.25000000000,  0.50000000000, 0.12500000000, 0.06250000000, 0.03125000000,  0.01562500000, 0.00781250000, 0.00390625000, 0.00195312500,  0.00097656250, 0.00048828125, 0.00024414063, 0.00003051758};static const REAL dtableB3[8]={           0.0, 0.50000000000, 0.50000000000, 0.25000000000,  0.50000000000, 0.12500000000, 0.06250000000, 0.00003051758};static const REAL dtableB4[4]={0.0, 0.50000000000, 0.50000000000, 0.00003051758};// Mpeg layer 2void MPEGaudio::extractlayer2(void){  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<s;i++,t++)    {      bitalloc[LS][i]=getbits(*t);      bitalloc[RS][i]=getbits(*t);    }    for(;i<n;i++,t++)      bitalloc[LS][i]=bitalloc[RS][i]=getbits(*t);  }  // Scale selector  if(inputstereo)    for(register int i=0;i<n;i++)    {      if(bitalloc[LS][i])scaleselector[LS][i]=getbits(2);      if(bitalloc[RS][i])scaleselector[RS][i]=getbits(2);    }  else    for(register int i=0;i<n;i++)      if(bitalloc[LS][i])scaleselector[LS][i]=getbits(2);  // Scale index  {    register int i,j;    for(i=0;i<n;i++)    {      if((j=bitalloc[LS][i]))      {	if(!tableindex)	{	  group[LS][i]=grouptableA[j];	  codelength[LS][i]=codelengthtableA[j];	  factor[LS][i]=factortableA[j];	  c[LS][i]=ctableA[j];	  d[LS][i]=dtableA[j];	}	else	{	  if(i<=2)	  {	    group[LS][i]=grouptableB1[j];	    codelength[LS][i]=codelengthtableB1[j];	    factor[LS][i]=factortableB1[j];	    c[LS][i]=ctableB1[j];	    d[LS][i]=dtableB1[j];	  }	  else	  {	    group[LS][i]=grouptableB234[j];	    if(i<=10)	    {	      codelength[LS][i]=codelengthtableB2[j];	      factor[LS][i]=factortableB2[j];	      c[LS][i]=ctableB2[j];	      d[LS][i]=dtableB2[j];	    }	    else if(i<=22)	    {	      codelength[LS][i]=codelengthtableB3[j];	      factor[LS][i]=factortableB3[j];	      c[LS][i]=ctableB3[j];	      d[LS][i]=dtableB3[j];	    }	    else	    {	      codelength[LS][i]=codelengthtableB4[j];	      factor[LS][i]=factortableB4[j];	      c[LS][i]=ctableB4[j];	      d[LS][i]=dtableB4[j];	    }	  }	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -