?? decode.c
字號:
else { /* pure short */
for(sfb=0,sfb_start=0,sfb_lines=sfBandIndex[sfreq].s[1];
sfb < 13; sfb++,sfb_start=sfBandIndex[sfreq].s[sfb],
(sfb_lines=sfBandIndex[sfreq].s[sfb+1] - sfb_start))
for(window=0; window<3; window++)
for(freq=0;freq<sfb_lines;freq++)
{
src_line = sfb_start*3 + window*sfb_lines + freq;
des_line = sfb_start*3 + window + (freq*3);
ro[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
}
}
for (sb=0 ; sb < SBLIMIT ; sb++)
for (ss=0 ; ss < SSLIMIT ; ss++)
xr[sb][ss] = ro[sb][ss];
}
}
void III_stereo(double xr[2][SBLIMIT][SSLIMIT],III_scalefac_t *scalefac, struct Granule *gr_info)
{
int sfreq = fr_ps.header->sampling_frequency;
int stereo = fr_ps.stereo;
int ms_stereo = (fr_ps.header->mode == MPG_MD_JOINT_STEREO) &&
(fr_ps.header->mode_ext & 0x2);
int i_stereo = (fr_ps.header->mode == MPG_MD_JOINT_STEREO) &&
(fr_ps.header->mode_ext & 0x1);
int sfb;
int i,j,sb,ss,is_pos[576];
double is_ratio[576];
/* intialization */
for ( i=0; i<576; i++ )
is_pos[i] = 7;
if ((stereo == 2) && i_stereo )
{ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
{ if( gr_info->mixed_block_flag )
{ int max_sfb = 0;
for ( j=0; j<3; j++ )
{ int sfbcnt;
sfbcnt = 2;
for( sfb=12; sfb >=3; sfb-- )
{ int lines;
lines = sfBandIndex[sfreq].s[sfb+1]-sfBandIndex[sfreq].s[sfb];
i = 3*sfBandIndex[sfreq].s[sfb] + (j+1) * lines - 1;
while ( lines > 0 )
{ if ( xr[1][i/SSLIMIT][i%SSLIMIT] != 0.0 )
{ sfbcnt = sfb;
sfb = -10;
lines = -10;
}
lines--;
i--;
}
}
sfb = sfbcnt + 1;
if ( sfb > max_sfb )
max_sfb = sfb;
while( sfb<12 )
{ sb = sfBandIndex[sfreq].s[sfb+1]-sfBandIndex[sfreq].s[sfb];
i = 3*sfBandIndex[sfreq].s[sfb] + j * sb;
for ( ; sb > 0; sb--)
{ is_pos[i] = (*scalefac)[1].s[j][sfb];
if ( is_pos[i] != 7 )
is_ratio[i] = tan( is_pos[i] * (PI / 12));
i++;
}
sfb++;
}
sb = sfBandIndex[sfreq].s[11]-sfBandIndex[sfreq].s[10];
sfb = 3*sfBandIndex[sfreq].s[10] + j * sb;
sb = sfBandIndex[sfreq].s[12]-sfBandIndex[sfreq].s[11];
i = 3*sfBandIndex[sfreq].s[11] + j * sb;
for ( ; sb > 0; sb-- )
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
if ( max_sfb <= 3 )
{ i = 2;
ss = 17;
sb = -1;
while ( i >= 0 )
{ if ( xr[1][i][ss] != 0.0 )
{ sb = i*18+ss;
i = -1;
} else
{ ss--;
if ( ss < 0 )
{ i--;
ss = 17;
}
}
}
i = 0;
while ( sfBandIndex[sfreq].l[i] <= sb )
i++;
sfb = i;
i = sfBandIndex[sfreq].l[i];
for ( ; sfb<8; sfb++ )
{ sb = sfBandIndex[sfreq].l[sfb+1]-sfBandIndex[sfreq].l[sfb];
for ( ; sb > 0; sb--)
{ is_pos[i] = (*scalefac)[1].l[sfb];
if ( is_pos[i] != 7 )
is_ratio[i] = tan( is_pos[i] * (PI / 12));
i++;
}
}
}
} else
{ for ( j=0; j<3; j++ )
{ int sfbcnt;
sfbcnt = -1;
for( sfb=12; sfb >=0; sfb-- )
{ int lines;
lines = sfBandIndex[sfreq].s[sfb+1]-sfBandIndex[sfreq].s[sfb];
i = 3*sfBandIndex[sfreq].s[sfb] + (j+1) * lines - 1;
while ( lines > 0 )
{ if ( xr[1][i/SSLIMIT][i%SSLIMIT] != 0.0 )
{ sfbcnt = sfb;
sfb = -10;
lines = -10;
}
lines--;
i--;
}
}
sfb = sfbcnt + 1;
while( sfb<12 )
{ sb = sfBandIndex[sfreq].s[sfb+1]-sfBandIndex[sfreq].s[sfb];
i = 3*sfBandIndex[sfreq].s[sfb] + j * sb;
for ( ; sb > 0; sb--)
{ is_pos[i] = (*scalefac)[1].s[j][sfb];
if ( is_pos[i] != 7 )
is_ratio[i] = tan( is_pos[i] * (PI / 12));
i++;
}
sfb++;
}
sb = sfBandIndex[sfreq].s[11]-sfBandIndex[sfreq].s[10];
sfb = 3*sfBandIndex[sfreq].s[10] + j * sb;
sb = sfBandIndex[sfreq].s[12]-sfBandIndex[sfreq].s[11];
i = 3*sfBandIndex[sfreq].s[11] + j * sb;
for ( ; sb > 0; sb-- )
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
}
} else
{ i = 31;
ss = 17;
sb = 0;
while ( i >= 0 )
{ if ( xr[1][i][ss] != 0.0 )
{ sb = i*18+ss;
i = -1;
} else
{ ss--;
if ( ss < 0 )
{ i--;
ss = 17;
}
}
}
i = 0;
while ( sfBandIndex[sfreq].l[i] <= sb )
i++;
sfb = i;
i = sfBandIndex[sfreq].l[i];
for ( ; sfb<21; sfb++ )
{ sb = sfBandIndex[sfreq].l[sfb+1] - sfBandIndex[sfreq].l[sfb];
for ( ; sb > 0; sb--)
{ is_pos[i] = (*scalefac)[1].l[sfb];
if ( is_pos[i] != 7 )
is_ratio[i] = tan( is_pos[i] * (PI / 12));
i++;
}
}
sfb = sfBandIndex[sfreq].l[20];
for ( sb = 576 - sfBandIndex[sfreq].l[21]; sb > 0; sb-- )
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
}
if (stereo==2)
for(sb=0;sb<SBLIMIT;sb++)
for(ss=0;ss<SSLIMIT;ss++)
{
double xr0,xr1;
i = (sb*18)+ss;
xr0=xr[0][sb][ss];
xr1=xr[1][sb][ss];
if ( is_pos[i] == 7 ) {
if ( ms_stereo ) {
xr[0][sb][ss] = (xr0+xr1)/1.41421356;
xr[1][sb][ss] = (xr0-xr1)/1.41421356;
}
else {
xr[0][sb][ss] = xr0;
xr[1][sb][ss] = xr1;
}
}
else if (i_stereo ) {
xr[0][sb][ss] = xr0 * (is_ratio[i]/(1+is_ratio[i]));
xr[1][sb][ss] = xr0 * (1/(1+is_ratio[i]));
}
// else
// printf("Error in streo processing\n");
}
}
double Ci[8]={-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
void III_antialias(SS hybridIn, struct Granule *gr_info)
{
static int init = 1;
static double ca[8],cs[8];
double bu,bd; /* upper and lower butterfly inputs */
int ss,sb,sblim;
if (init) {
int i;
double sq;
for (i=0;i<8;i++) {
sq=sqrt(1.0+Ci[i]*Ci[i]);
cs[i] = 1.0/sq;
ca[i] = Ci[i]/sq;
}
init = 0;
}
/* clear all inputs */
if (gr_info->window_switching_flag && (gr_info->block_type == 2) &&
!gr_info->mixed_block_flag ) return;
if ( gr_info->window_switching_flag && gr_info->mixed_block_flag &&
(gr_info->block_type == 2))
sblim = 1;
else
sblim = SBLIMIT-1;
/* 31 alias-reduction operations between each pair of sub-bands */
/* with 8 butterflies between each pair */
for(sb=0;sb<sblim;sb++)
for(ss=0;ss<8;ss++)
{
bu = hybridIn[sb][17-ss];
bd = hybridIn[sb+1][ss];
hybridIn[sb][17-ss] =(bu * cs[ss]) - (bd * ca[ss]);
hybridIn[sb+1][ss] = (bd * cs[ss]) + (bu * ca[ss]);
}
}
/*
void out_fifo(short SAM[2][SSLIMIT][SBLIMIT], FILE *outFile)
{
short *pcm=&SAM[0][0][0];
fwrite(pcm,2,SBLIMIT*SSLIMIT*2,outFile);
}
*/
void buffer_CRC()
{
getbit(16);
}
extern int bitrate[3][15];
extern double s_freq[4];
/* Return the number of slots for main data of current frame, */
int main_data_slots()
{
unsigned int nSlots;
nSlots = (unsigned int)((144 * bitrate[2][fr_ps.header->bitrate_index])
/ s_freq[fr_ps.header->sampling_frequency]);
if (fr_ps.header->padding) nSlots++;
nSlots -= 4; //減去4字節的頭
if (fr_ps.header->error_protection) //如有CRC 則減2字節
nSlots -= 2;
if (fr_ps.stereo == 1) //單聲道-17字節的side 信息
nSlots -= 17;
else
nSlots -=32; //單聲道-32字節的side 信息
return(nSlots);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -