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

📄 layer3.c

📁 神龙卡开发原代码
💻 C
📖 第 1 页 / 共 4 页
字号:
      max[0] = max[1] = max[2] = max[3] = -1;      /* max[3] not really needed in this case */      m = map[sfreq][1];      me = mapend[sfreq][1];    }    for(i=0;i<2;i++) {      int lp = l[i];      struct newhuff *h = ht+gr_info->table_select[i];      for(;lp;lp--,mc--) {        int x,y;        if(!mc) {          mc = *m++;          xrpnt = ((real *) xr[1]) + *m;          xr0pnt = ((real *) xr[0]) + *m++;          lwin = *m++;          cb = *m++;          if(lwin == 3) {            v = gr_info->pow2gain[(*scf++) << shift];            step = 1;          }          else {            v = gr_info->full_gain[lwin][(*scf++) << shift];            step = 3;          }        }        {          register short *val = h->table;          while((y=*val++)<0) {            if (get1bit())              val -= y;            part2remain--;          }          x = y >> 4;          y &= 0xf;        }        if(x == 15) {          max[lwin] = cb;          part2remain -= h->linbits+1;          x += MP3getbits(h->linbits);          if(get1bit()) {            real a = ispow[x] * v;            *xrpnt = *xr0pnt + a;            *xr0pnt -= a;          }          else {            real a = ispow[x] * v;            *xrpnt = *xr0pnt - a;            *xr0pnt += a;          }        }        else if(x) {          max[lwin] = cb;          if(get1bit()) {            real a = ispow[x] * v;            *xrpnt = *xr0pnt + a;            *xr0pnt -= a;          }          else {            real a = ispow[x] * v;            *xrpnt = *xr0pnt - a;            *xr0pnt += a;          }          part2remain--;        }        else          *xrpnt = *xr0pnt;        xrpnt += step;        xr0pnt += step;        if(y == 15) {          max[lwin] = cb;          part2remain -= h->linbits+1;          y += MP3getbits(h->linbits);          if(get1bit()) {            real a = ispow[y] * v;            *xrpnt = *xr0pnt + a;            *xr0pnt -= a;          }          else {            real a = ispow[y] * v;            *xrpnt = *xr0pnt - a;            *xr0pnt += a;          }        }        else if(y) {          max[lwin] = cb;          if(get1bit()) {            real a = ispow[y] * v;            *xrpnt = *xr0pnt + a;            *xr0pnt -= a;          }          else {            real a = ispow[y] * v;            *xrpnt = *xr0pnt - a;            *xr0pnt += a;          }          part2remain--;        }        else          *xrpnt = *xr0pnt;        xrpnt += step;        xr0pnt += step;      }    }    for(;l3 && (part2remain > 0);l3--) {      struct newhuff *h = htc+gr_info->count1table_select;      register short *val = h->table,a;      while((a=*val++)<0) {        part2remain--;        if(part2remain < 0) {          part2remain++;          a = 0;          break;        }        if (get1bit())          val -= a;      }      for(i=0;i<4;i++) {        if(!(i & 1)) {          if(!mc) {            mc = *m++;            xrpnt = ((real *) xr[1]) + *m;            xr0pnt = ((real *) xr[0]) + *m++;            lwin = *m++;            cb = *m++;            if(lwin == 3) {              v = gr_info->pow2gain[(*scf++) << shift];              step = 1;            }            else {              v = gr_info->full_gain[lwin][(*scf++) << shift];              step = 3;            }          }          mc--;        }        if( (a & (0x8>>i)) ) {          max[lwin] = cb;          part2remain--;          if(part2remain < 0) {            part2remain++;            break;          }          if(get1bit()) {            *xrpnt = *xr0pnt + v;            *xr0pnt -= v;          }          else {            *xrpnt = *xr0pnt - v;            *xr0pnt += v;          }        }        else          *xrpnt = *xr0pnt;        xrpnt += step;        xr0pnt += step;      }    }    while( m < me ) {      if(!mc) {        mc = *m++;        xrpnt = ((real *) xr[1]) + *m;        xr0pnt = ((real *) xr[0]) + *m++;        if(*m++ == 3)          step = 1;        else          step = 3;        m++; /* cb */      }      mc--;      *xrpnt = *xr0pnt;      xrpnt += step;      xr0pnt += step;      *xrpnt = *xr0pnt;      xrpnt += step;      xr0pnt += step;/* we could add a little opt. here: * if we finished a band for window 3 or a long band * further bands could copied in a simple loop without a * special 'map' decoding */    }    gr_info->maxband[0] = max[0]+1;    gr_info->maxband[1] = max[1]+1;    gr_info->maxband[2] = max[2]+1;    gr_info->maxbandl = max[3]+1;    {      int rmax = max[0] > max[1] ? max[0] : max[1];      rmax = (rmax > max[2] ? rmax : max[2]) + 1;      gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1];    }  }  else {    int *pretab = gr_info->preflag ? pretab1 : pretab2;    int i,max = -1;    int cb = 0;    register int mc=0,*m = map[sfreq][2];    register real v = 0.0;#if 0    me = mapend[sfreq][2];#endif    for(i=0;i<3;i++) {      int lp = l[i];      struct newhuff *h = ht+gr_info->table_select[i];      for(;lp;lp--,mc--) {        int x,y;        if(!mc) {          mc = *m++;          cb = *m++;          v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];        }        {          register short *val = h->table;          while((y=*val++)<0) {            if (get1bit())              val -= y;            part2remain--;          }          x = y >> 4;          y &= 0xf;        }        if (x == 15) {          max = cb;          part2remain -= h->linbits+1;          x += MP3getbits(h->linbits);          if(get1bit()) {            real a = ispow[x] * v;            *xrpnt++ = *xr0pnt + a;            *xr0pnt++ -= a;          }          else {            real a = ispow[x] * v;            *xrpnt++ = *xr0pnt - a;            *xr0pnt++ += a;          }        }        else if(x) {          max = cb;          if(get1bit()) {            real a = ispow[x] * v;            *xrpnt++ = *xr0pnt + a;            *xr0pnt++ -= a;          }          else {            real a = ispow[x] * v;            *xrpnt++ = *xr0pnt - a;            *xr0pnt++ += a;          }          part2remain--;        }        else          *xrpnt++ = *xr0pnt++;        if (y == 15) {          max = cb;          part2remain -= h->linbits+1;          y += MP3getbits(h->linbits);          if(get1bit()) {            real a = ispow[y] * v;            *xrpnt++ = *xr0pnt + a;            *xr0pnt++ -= a;          }          else {            real a = ispow[y] * v;            *xrpnt++ = *xr0pnt - a;            *xr0pnt++ += a;          }        }        else if(y) {          max = cb;          if(get1bit()) {            real a = ispow[y] * v;            *xrpnt++ = *xr0pnt + a;            *xr0pnt++ -= a;          }          else {            real a = ispow[y] * v;            *xrpnt++ = *xr0pnt - a;            *xr0pnt++ += a;          }          part2remain--;        }        else          *xrpnt++ = *xr0pnt++;      }    }    for(;l3 && (part2remain > 0);l3--) {      struct newhuff *h = htc+gr_info->count1table_select;      register short *val = h->table,a;      while((a=*val++)<0) {        part2remain--;        if(part2remain < 0) {          part2remain++;          a = 0;          break;        }        if (get1bit())          val -= a;      }      for(i=0;i<4;i++) {        if(!(i & 1)) {          if(!mc) {            mc = *m++;            cb = *m++;            v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];          }          mc--;        }        if ( (a & (0x8>>i)) ) {          max = cb;          part2remain--;          if(part2remain <= 0) {            part2remain++;            break;          }          if(get1bit()) {            *xrpnt++ = *xr0pnt + v;            *xr0pnt++ -= v;          }          else {            *xrpnt++ = *xr0pnt - v;            *xr0pnt++ += v;          }        }        else          *xrpnt++ = *xr0pnt++;      }    }    for(i=(&xr[1][SBLIMIT][0]-xrpnt)>>1;i;i--) {      *xrpnt++ = *xr0pnt++;      *xrpnt++ = *xr0pnt++;    }    gr_info->maxbandl = max+1;    gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];  }  while ( part2remain > 16 ) {    MP3getbits(16); /* Dismiss stuffing Bits */    part2remain -= 16;  }  if(part2remain > 0 )    MP3getbits(part2remain);  else if(part2remain < 0) {    //fprintf(stderr,"mpg123_ms: Can't rewind stream by %d bits!\n",-part2remain);    return 1; /* -> error */  }  return 0;}#endif/*  * III_stereo: calculate real channel values for Joint-I-Stereo-mode */static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac,   struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf){      real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf;      struct bandInfoStruct *bi = &bandInfo[sfreq];      real *tab1,*tab2;      if(lsf) {        int p = gr_info->scalefac_compress & 0x1;	    if(ms_stereo) {          tab1 = pow1_2[p]; tab2 = pow2_2[p];        }        else {          tab1 = pow1_1[p]; tab2 = pow2_1[p];        }      }      else {        if(ms_stereo) {          tab1 = tan1_2; tab2 = tan2_2;        }        else {          tab1 = tan1_1; tab2 = tan2_1;        }      }      if (gr_info->block_type == 2)      {         int lwin,do_l = 0;         if( gr_info->mixed_block_flag )           do_l = 1;         for (lwin=0;lwin<3;lwin++) /* process each window */         {             /* get first band with zero values */           int is_p,sb,idx,sfb = gr_info->maxband[lwin];  /* sfb is minimal 3 for mixed mode */           if(sfb > 3)             do_l = 0;           for(;sfb<12;sfb++)           {             is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */              if(is_p != 7) {               real t1,t2;               sb = bi->shortDiff[sfb];               idx = bi->shortIdx[sfb] + lwin;               t1 = tab1[is_p]; t2 = tab2[is_p];               for (; sb > 0; sb--,idx+=3)               {                 real v = xr[0][idx];                 xr[0][idx] = v * t1;                 xr[1][idx] = v * t2;               }             }           }#if 1/* in the original: copy 10 to 11 , here: copy 11 to 12 maybe still wrong??? (copy 12 to 13?) */           is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */           sb = bi->shortDiff[12];           idx = bi->shortIdx[12] + lwin;#else           is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */           sb = bi->shortDiff[11];           idx = bi->shortIdx[11] + lwin;#endif           if(is_p != 7)           {             real t1,t2;             t1 = tab1[is_p]; t2 = tab2[is_p];             for ( ; sb > 0; sb--,idx+=3 )             {                 real v = xr[0][idx];               xr[0][idx] = v * t1;               xr[1][idx] = v * t2;             }           }         } /* end for(lwin; .. ; . ) */         if (do_l)         {/* also check l-part, if ALL bands in the three windows are 'empty' * and mode = mixed_mode  */           int sfb = gr_info->maxbandl;           int idx = bi->longIdx[sfb];           for ( ; sfb<8; sfb++ )           {             int sb = bi->longDiff[sfb];             int is_p = scalefac[sfb]; /* scale: 0-15 */             if(is_p != 7) {               real t1,t2;               t1 = tab1[is_p]; t2 = tab2[is_p];               for ( ; sb > 0; sb--,idx++)               {                 real v = xr[0][idx];                 xr[0][idx] = v * t1;                 xr[1][idx] = v * t2;               }             }             else                idx += sb;           }         }           }       else /* ((gr_info->block_type != 2)) */      {        int sfb = gr_info->maxbandl;        int is_p,idx = bi->longIdx[sfb];        for ( ; sfb<21; sfb++)        {          int sb = bi->longDiff[sfb];          is_p = scalefac[sfb]; /* scale: 0-15 */          if(is_p != 7) {            real t1,t2;            t1 = tab1[is_p]; t2 = tab2[is_p];            for ( ; sb > 0; sb--,idx++)            {               real v = xr[0][idx];               xr[0][idx] = v * t1;               xr[1][idx] = v * t2;            }          }          else            idx += sb;        }        is_p = scalefac[20]; /* copy l-band 20 to l-band 21 */        if(is_p != 7)        {          int sb;          real t1 = tab1[is_p],t2 = tab2[is_p];           for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ )          {            real v = xr[0][idx];            xr[0][idx] = v * t1;            xr[1][idx] = v * t2;

⌨️ 快捷键说明

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