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

📄 l3psy.c

📁 ISO mp3 sources (distribution 10) Layer 1/2/3, C Source, 512 k Sources of the Mpeg 1,2 layer 1,2
💻 C
📖 第 1 页 / 共 3 页
字号:
		for ( b = 0; b < CBANDS_s; b++ )		{		    nb[b] = ecb[b] * norm_l[b] * exp( (double) SNR_s[b] * LN_TO_LOG10 );		    thr[b] = maximum (qthr_s[b],nb[b]);		}		for ( sb = 0; sb < SBMAX_s; sb++ )		{		    en[sb] = w1_s[sb] * eb[bu_s[sb]] + w2_s[sb] * eb[bo_s[sb]];		    thm[sb] = w1_s[sb] *thr[bu_s[sb]] + w2_s[sb] * thr[bo_s[sb]];		    for ( b = bu_s[sb]+1; b < bo_s[sb]; b++ )		    {			en[sb] += eb[b];			thm[sb] += thr[b];		    }		    if ( en[sb] != 0.0 )			ratio_s[chn][sb][sblock] = thm[sb]/en[sb];		    else			ratio_s[chn][sb][sblock] = 0.0;		}	    }	} 		cod_info->block_type = blocktype_old[chn];	blocktype_old[chn] = blocktype;	if ( cod_info->block_type == NORM_TYPE )	    cod_info->window_switching_flag = 0;	else	    cod_info->window_switching_flag = 1;	cod_info->mixed_block_flag = 0;	break;  default:     printf("error, invalid MPEG/audio coding layer: %d\n",lay); }/* These mem_free() calls must correspond with the mem_alloc() calls     *//* used at the beginning of this function to simulate "automatic"        *//* variables placed on the stack.                                        */ mem_free((void **) &grouped_c); mem_free((void **) &grouped_e); mem_free((void **) &nb); mem_free((void **) &cb); mem_free((void **) &ecb); mem_free((void **) &bc); mem_free((void **) &wsamp_r); mem_free((void **) &wsamp_i); mem_free((void **) &phi); mem_free((void **) &energy); mem_free((void **) &c); mem_free((void **) &fthr); mem_free((void **) &snrtmp);}#ifdef DEBUG#undef DEBUG#endifvoid L3para_read(double sfreq, int *numlines, int *partition_l, double *minval, double *qthr_l, double *norm_l, double (*s3_l)[63], int *partition_s, double *qthr_s, double *norm_s, double *SNR, int *cbw_l, int *bu_l, int *bo_l, double *w1_l, double *w2_l, int *cbw_s, int *bu_s, int *bo_s, double *w1_s, double *w2_s){   double freq_tp;   static double bval_l[CBANDS], bval_s[CBANDS];   int   cbmax, cbmax_tp;   static double s3_s[CBANDS][CBANDS];   FILE *fin;   char tp[256];   int  sbmax ;   int  i,j,k,k2,loop, part_max ;   fin = OpenTableFile( "psy_data" );   if (fin == NULL)       exit( 1 );/* Read long block data */      for(loop=0;loop<6;loop++)      {	fscanf(fin,"freq = %lf partition = %d\n",&freq_tp,&cbmax_tp);	cbmax_tp++;#ifdef DEBUG	printf("freq = %f partition = %d\n",freq_tp,cbmax);#endif	if (sfreq == freq_tp )	  {	     cbmax = cbmax_tp;	     for(i=0,k2=0;i<cbmax_tp;i++)	       {		fscanf(fin,		  "No=%d #lines=%d minval=%lf qthr=%lf norm=%lf bval=%lf\n",		  &j,&numlines[i],&minval[i],&qthr_l[i],&norm_l[i],&bval_l[i]);	        if (j!=i)	         { printf("please check \"psy_data\"");		   exit(-1);	         }		for(k=0;k<numlines[i];k++)		  partition_l[k2++] = i ;#ifdef DEBUG     printf("No=%2d #lines=%2d minval=%4.1f qthr=%8.3f norm=%5.3f bval=%8.3f\n",		     i,numlines[i],minval[i],qthr_l[i],norm_l[i],bval_l[i] );#endif		}	   }	   else	   {	     for(j=0;j<cbmax_tp;j++)	       {		fgets(tp,255,fin);	        sscanf(tp,"No=%d %s\n",&i,tp);	        if (j!=i)	         { printf("please check \"psy_data.\"\n");		   exit(-1);	         }	       }	   }       }/************************************************************************ * Now compute the spreading function, s[j][i], the value of the spread-* * ing function, centered at band j, for band i, store for later use    * ************************************************************************/#ifdef DEBUG	printf("freq = %f\n",sfreq);#endif	  part_max = cbmax ;          for(i=0;i<part_max;i++)	  {	  double tempx,x,tempy,temp;            for(j=0;j<part_max;j++)	    {             tempx = (bval_l[i] - bval_l[j])*1.05;             if (j>=i) tempx = (bval_l[i] - bval_l[j])*3.0;               else    tempx = (bval_l[i] - bval_l[j])*1.5;/*             if (j>=i) tempx = (bval_l[j] - bval_l[i])*3.0;               else    tempx = (bval_l[j] - bval_l[i])*1.5; */             if(tempx>=0.5 && tempx<=2.5)	     {               temp = tempx - 0.5;               x = 8.0 * (temp*temp - 2.0 * temp);             }             else x = 0.0;             tempx += 0.474;             tempy = 15.811389 + 7.5*tempx - 17.5*sqrt(1.0+tempx*tempx);             if (tempy <= -60.0) s3_l[i][j] = 0.0;             else                s3_l[i][j] = exp( (x + tempy)*LN_TO_LOG10 );#ifdef DEBUG_S3	     printf("s[%d][%d]=%f\n",i,j,s3_l[i][j]);#endif#ifdef DEBUGP	     printf("j=%d i=%d tempy=%f s[i][j]=%f \n",i,j,tempy,s[i][j]);	   minval[i] = bmax[j-1];	   printf("minval[%d] = %f, j-1=%d %f\n",i, minval[i] , j,fthr[i]) ;#endif            }          }/* Read short block data */      for(loop=0;loop<6;loop++)      {	fscanf(fin,"freq = %lf partition = %d\n",&freq_tp,&cbmax_tp);	cbmax_tp++;#ifdef DEBUG	printf("freq = %f partition = %d\n",freq_tp,cbmax);#endif	if (sfreq == freq_tp )	  {	     cbmax = cbmax_tp;	     for(i=0,k2=0;i<cbmax_tp;i++)	       {		fscanf(fin,		  "No=%d #lines=%d qthr=%lf norm=%lf SNR=%lf bval=%lf\n",		   &j,&numlines[i],&qthr_s[i],&norm_s[i],&SNR[i],&bval_s[i]);	        if (j!=i)	         { printf("please check \"psy_data\"");		   exit(-1);	         }		for(k=0;k<numlines[i];k++)		  partition_s[k2++] = i ;#ifdef DEBUG      printf("No=%2d #lines=%2d qthr=%8.3f norm=%5.3f SNR=%6.3f bval=%8.3f\n",		      i,numlines[i],qthr_s[i],norm_s[i],SNR[i],bval_s[i] );#endif		}	   }	   else	   {	     for(j=0;j<cbmax_tp;j++)	       {		fgets(tp,255,fin);	        sscanf(tp,"No=%d %s\n",&i,tp);	        if (j!=i)	         { printf("please check \"psy_data.\"\n");		   exit(-1);	         }	       }	   }       }/************************************************************************ * Now compute the spreading function, s[j][i], the value of the spread-* * ing function, centered at band j, for band i, store for later use    * ************************************************************************/#ifdef DEBUG_S3fpp=fopen("s3_s","w");#endif	  part_max = cbmax ;          for(i=0;i<part_max;i++)	  {	  double tempx,x,tempy,temp;            for(j=0;j<part_max;j++)	    {             tempx = (bval_s[i] - bval_s[j])*1.05;             if (j>=i) tempx = (bval_s[i] - bval_s[j])*3.0;               else    tempx = (bval_s[i] - bval_s[j])*1.5;             if(tempx>=0.5 && tempx<=2.5)	     {               temp = tempx - 0.5;               x = 8.0 * (temp*temp - 2.0 * temp);             }             else x = 0.0;             tempx += 0.474;             tempy = 15.811389 + 7.5*tempx - 17.5*sqrt(1.0+tempx*tempx);             if (tempy <= -60.0) s3_s[i][j] = 0.0;             else                s3_s[i][j] = exp( (x + tempy)*LN_TO_LOG10 );#ifdef DEBUG_S3	     fprintf(fpp,"s3_s[%d][%d]=%f\n",i,j,s3_s[i][j]);#endif#ifdef DEBUGP	     printf("j=%d i=%d tempy=%f s[i][j]=%f \n",i,j,tempy,s[i][j]);	   minval[i] = bmax[j-1];	   printf("minval[%d] = %f, j-1=%d %f\n",i, minval[i] , j,fthr[i]) ;#endif            }          }#ifdef DEBUG_S3	fclose(fpp);#endif/* Read long block data for converting threshold calculation    partitions to scale factor bands */      for(loop=0;loop<6;loop++)      {	fscanf(fin,"freq=%lf sb=%d\n",&freq_tp,&sbmax);	sbmax++;#ifdef DEBUG	printf("freq = %f sb = %d\n",freq_tp,sbmax);#endif	if (sfreq == freq_tp)	  {	     for(i=0;i<sbmax;i++)	      {		fscanf(fin,		  "sb=%d cbw=%d bu=%d bo=%d w1=%lf w2=%lf\n",		  &j,&cbw_l[i],&bu_l[i],&bo_l[i],&w1_l[i],&w2_l[i]);	        if (j!=i)	         { printf("30:please check \"psy_data\"\n");		   exit(-1);	         }#ifdef DEBUG		printf(		  "sb=%2d cbw=%1d bu=%2d bo=%2d w1=%5.3f w2=%5.3f\n",		  j,cbw_l[i],bu_l[i],bo_l[i],w1_l[i],w2_l[i]);#endif	        if (i!=0)		 if ( (bo_l[i] != (bu_l[i]+cbw_l[i])) ||				 (fabs(1.0-w1_l[i]-w2_l[i-1]) > 0.01 ) )	         { printf("31:please check \"psy_data.\"\n");		   exit(-1);	         }	      }	   }	   else	   {	     for(j=0;j<sbmax;j++)	       {		fgets(tp,255,fin);	        sscanf(tp,"sb=%d %s\n",&i,tp);	        if (j!=i)	         { printf("please check \"psy_data.\"\n");		   exit(-1);	         }	       }	   }       }/* Read short block data for converting threshold calculation    partitions to scale factor bands */      for(loop=0;loop<6;loop++)      {	fscanf(fin,"freq=%lf sb=%d\n",&freq_tp,&sbmax);	sbmax++;#ifdef DEBUG	printf("freq = %f sb = %d\n",freq_tp,sbmax);#endif	if (sfreq == freq_tp)	  {	     for(i=0;i<sbmax;i++)	      {		fscanf(fin,		  "sb=%d cbw=%d bu=%d bo=%d w1=%lf w2=%lf\n",		  &j,&cbw_s[i],&bu_s[i],&bo_s[i],&w1_s[i],&w2_s[i]);	        if (j!=i)	         { printf("30:please check \"psy_data\"\n");		   exit(-1);	         }#ifdef DEBUG		printf(		  "sb=%2d cbw=%1d bu=%2d bo=%2d w1=%5.3f w2=%5.3f\n",		  j,cbw_s[i],bu_s[i],bo_s[i],w1_s[i],w2_s[i]);#endif	        if (i!=0)		 if ( (bo_s[i] != (bu_s[i]+cbw_s[i])) ||				 (fabs(1.0-w1_s[i]-w2_s[i-1]) > 0.01 ) )	         { printf("31:please check \"psy_data.\"\n");		   exit(-1);	         }	      }	   }	   else	   {	     for(j=0;j<sbmax;j++)	       {		fgets(tp,255,fin);	        sscanf(tp,"sb=%d %s\n",&i,tp);	        if (j!=i)	         { printf("please check \"psy_data.\"\n");		   exit(-1);	         }	       }	   }       }}

⌨️ 快捷键说明

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