📄 layeriiidecoder.java
字号:
GRInfo gr_info = (si.ch[ch].gr[gr]);
int cb = 0;
int next_cb_boundary =0;
int cb_begin = 0;
int cb_width = 0;
float g_gain = 0.0f;
// choose correct scalefactor band per block type,initalize boundary
if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
if (gr_info.mixed_block_flag != 0) {
next_cb_boundary = sfBandIndexL[1];
}
// LONG blocks: 0,1,3
else {
cb_width = sfBandIndexS[1];
next_cb_boundary = (cb_width << 2) - cb_width;
cb_begin = 0;
}
} else {
next_cb_boundary = sfBandIndexL[1];
// LONG blocks: 0,1,3
}
// Compute overall (global) scaling.
g_gain = (float)pow((int)2.0,(int)(0.25 * (gr_info.global_gain - 210.0)));
int maxNonZero = (ch == 0) ? nonzero0 : nonzero1;
for (int j = 0; j < maxNonZero; j++) {
reste = j % SSLIMIT;
quotien = (int) ((j - reste) / SSLIMIT);
if (is_1d[j] == 0) {
xr[quotien][reste] = 0.0f;
}
else {
int abv = is_1d[j];
if (is_1d[j] > 0) {
xr[quotien][reste] = g_gain * t_43[abv];
}
else {
xr[quotien][reste] = -g_gain * t_43[-abv];
}
}
}
// apply formula per block type
for (int i=0,j = 0; j < maxNonZero; j++,i++) {
reste = j % SSLIMIT;
quotien = (int) ((j - reste) / SSLIMIT);
if (i == next_cb_boundary) {
/*
* Adjust critical band boundary
*/
if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
if (gr_info.mixed_block_flag != 0) {
if (i == sfBandIndexL[8]) {
next_cb_boundary = sfBandIndexS[4];
next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
cb = 3;
cb_width = sfBandIndexS[4] - sfBandIndexS[3];
cb_begin = sfBandIndexS[3];
cb_begin = (cb_begin << 2) - cb_begin;
} else if (i < sfBandIndexL[8]) {
next_cb_boundary = sfBandIndexL[(++cb) + 1];
} else {
next_cb_boundary = sfBandIndexS[(++cb) + 1];
next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
cb_begin = sfBandIndexS[cb];
cb_width = sfBandIndexS[cb + 1] - cb_begin;
cb_begin = (cb_begin << 2) - cb_begin;
}
} else {
next_cb_boundary = sfBandIndexS[(++cb) + 1];
next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
cb_begin = sfBandIndexS[cb];
cb_width = sfBandIndexS[cb + 1] - cb_begin;
cb_begin = (cb_begin << 2) - cb_begin;
}
} else {
// long blocks
next_cb_boundary = sfBandIndexL[(++cb) + 1];
}
}
int s[][] = (ch==0)?scalefac0S:scalefac1S;
int l[] = (ch==0)?scalefac0L:scalefac1L;
// Do long/short dependent scaling operations
if ((gr_info.window_switching_flag != 0) && (((gr_info.block_type == 2) && (gr_info.mixed_block_flag == 0)) || ((gr_info.block_type == 2) && (gr_info.mixed_block_flag != 0) && (j >= 36)))) {
int t_index = (i - cb_begin) / cb_width;
int idx = s[t_index][cb] << gr_info.scalefac_scale;
idx += (gr_info.subblock_gain[t_index] << 2);
xr[quotien][reste] *= two_to_negative_half_pow[idx];
} else {
// LONG block types 0,1,3 & 1st 2 subbands of switched blocks
int idx = l[cb];
if (gr_info.preflag != 0) {
idx += pretab[cb];
}
idx = idx << gr_info.scalefac_scale;
xr[quotien][reste] *= two_to_negative_half_pow[idx];
}
}
int reste;
int quotien;
for(int j = maxNonZero; j < 576; j++) {
reste = j % SSLIMIT;
quotien = (int) ((j - reste) / SSLIMIT);
xr[quotien][reste] = 0.0f;
}
}
static int freq,freq3,src_line,des_line,sfb_start,sfb_start3,sfb_lines,reste,quotien;
private final void reorder(final float xr[][],final int ch,final int gr) {
GRInfo gr_info = (si.ch[ch].gr[gr]);
if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
if (gr_info.mixed_block_flag != 0) {
// NO REORDER FOR LOW 2 SUBBANDS
for(int i = 36; --i >= 0;){//i = 0; i < 36; i++) {
reste = i % SSLIMIT;
quotien = (int) ((i - reste) / SSLIMIT);
out_1d[i] = xr[quotien][reste];
}
// REORDERING FOR REST SWITCHED SHORT
for (int sfb = 3,sfb_start = sfBandIndexS[3],sfb_lines = sfBandIndexS[4] - sfb_start; sfb < 13;
sfb++,sfb_start = sfBandIndexS[sfb],sfb_lines = sfBandIndexS[sfb + 1] - sfb_start) {
sfb_start3 = (sfb_start << 2) - sfb_start;
for (freq = 0,freq3 = 0; freq < sfb_lines; freq++,freq3 += 3) {
src_line = sfb_start3 + freq;
des_line = sfb_start3 + freq3;
reste = src_line % SSLIMIT;
quotien = (int) ((src_line - reste) / SSLIMIT);
out_1d[des_line] = xr[quotien][reste];
src_line += sfb_lines;
des_line++;
reste = src_line % SSLIMIT;
quotien = (int) ((src_line - reste) / SSLIMIT);
out_1d[des_line] = xr[quotien][reste];
src_line += sfb_lines;
des_line++;
reste = src_line % SSLIMIT;
quotien = (int) ((src_line - reste) / SSLIMIT);
out_1d[des_line] = xr[quotien][reste];
}
}
} else {
// pure short
int reorder[] = reorder_table[sfreq];
for(int i = 576; --i >= 0;){//while(i < 576){
int j = reorder[i];
reste = j % SSLIMIT;
quotien = (int) ((j - reste) / SSLIMIT);
out_1d[i] = xr[quotien][reste];
}
}
}
else {
// long blocks
for(int i = 576; --i >= 0;){
reste = i % SSLIMIT;
quotien = (int) ((i - reste) / SSLIMIT);
out_1d[i] = xr[quotien][reste];
}
}
}
private final void stereo(final int gr) {
if (channels == 2) {
//System.out.println("channels 3");
for(int sb = SBLIMIT; --sb >= 0;) {
float l[] = lr[0][sb];
float r[] = ro[0][sb];
for (int ss = 0; ss < SSLIMIT; ss+=3) {
l[ss] = r[ss];
l[ss + 1] = r[ss + 1];
l[ss + 2] = r[ss + 2];
}
}
}
else {
System.out.println("channels 3" + channels);
GRInfo gr_info = (si.ch[0].gr[gr]);
int mode_ext = header.mode_extension();
// boolean ms_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2) != 0));
boolean i_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1) != 0));
//boolean lsf = ((header.version() == Header.MPEG2_LSF));
int io_type = (gr_info.scalefac_compress & 1);
// initialization
/*
for (i = 0; i < 576;) {
is_pos[i] = 7;
is_ratio[i++] = 0.0f;
is_pos[i] = 7;
is_ratio[i++] = 0.0f;
is_pos[i] = 7;
is_ratio[i++] = 0.0f;
is_pos[i] = 7;
is_ratio[i++] = 0.0f;
}
*/
for (int ii = 0; ii < is_pos.length;ii++) {
is_pos[ii]=7;
}
//Arrays.fill(is_pos,7);
//Arrays.fill(is_ratio,0);
if (i_stereo) {
if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
if (gr_info.mixed_block_flag != 0) {
int max_sfb = 0;
for (int j = 0; j < 3; j++) {
int sfbcnt;
sfbcnt = 2;
for (int sfb = 12; sfb >= 3; sfb--) {
int i = sfBandIndexS[sfb];
int lines = sfBandIndexS[sfb + 1] - i;
i = (i << 2) - i + (j + 1) * lines - 1;
while (lines > 0) {
if (ro[1][i / 18][i % 18] != 0.0f) {
sfbcnt = sfb;
sfb = -10;
lines = -10;
}
lines--;
i--;
}
}
int sfb = sfbcnt + 1;
if (sfb > max_sfb) {
max_sfb = sfb;
}
int stemp[][] = scalefac1S;
while (sfb < 12) {
int temp = sfBandIndexS[sfb];
int sb = sfBandIndexS[sfb + 1] - temp;
int i = (temp << 2) - temp + j * sb;
for (; sb > 0; sb--) {
is_pos[i] = stemp[j][sfb];
if (is_pos[i] != 7) {
//if (lsf) {
// i_stereo_k_values(is_pos[i],io_type,i);
//}
//else {
is_ratio[i] = TAN12[is_pos[i]];
//}
}
i++;
}
sfb++;
}
sfb = sfBandIndexS[10];
int sb = sfBandIndexS[11] - sfb;
sfb = (sfb << 2) - sfb + j * sb;
int temp = sfBandIndexS[11];
sb = sfBandIndexS[12] - temp;
int i = (temp << 2) - temp + j * sb;
for (; sb > 0; sb--) {
is_pos[i] = is_pos[sfb];
//if (lsf) {
// k[0][i] = k[0][sfb];
// k[1][i] = k[1][sfb];
//} else {
is_ratio[i] = is_ratio[sfb];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -