📄 layeriiidecoder.java
字号:
int curr0 = 15+i;
int curr1 = 12+i;
int curr2 = 9+i;
int curr3 = 6+i;
int curr4 = 3+i;
in[curr0] += in[curr1]; in[curr1] += in[curr2]; in[curr2] += in[curr3];
in[curr3] += in[curr4]; in[curr4] += in[i];
// Input aliasing on odd indices (for 6 point IDCT)
in[curr0] += in[curr2]; in[curr2] += in[curr4];
// 3 point IDCT on even indices
float pp2 = in[curr1] * 0.500000000f;
float pp1 = in[curr3] * 0.866025403f;
float sum = in[i] + pp2;
float tmpf_1 = in[i] - in[curr1];
float tmpf_0 = sum + pp1;
float tmpf_2 = sum - pp1;
// End 3 point IDCT on even indices
// 3 point IDCT on odd indices (for 6 point IDCT)
pp2 = in[curr0] * 0.500000000f;
pp1 = in[curr2] * 0.866025403f;
sum = in[curr4] + pp2;
float tmpf_4 = in[curr4] - in[curr0];
float tmpf_5 = sum + pp1;
float tmpf_3 = sum - pp1;
// End 3 point IDCT on odd indices
// Twiddle factors on odd indices (for 6 point IDCT)
tmpf_3 *= 1.931851653f;
tmpf_4 *= 0.707106781f;
tmpf_5 *= 0.517638090f;
// Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
float save = tmpf_0;
tmpf_0 += tmpf_5;
tmpf_5 = save - tmpf_5;
save = tmpf_1;
tmpf_1 += tmpf_4;
tmpf_4 = save - tmpf_4;
save = tmpf_2;
tmpf_2 += tmpf_3;
tmpf_3 = save - tmpf_3;
// End 6 point IDCT
// Twiddle factors on indices (for 12 point IDCT)
tmpf_0 *= 0.504314480f;
tmpf_1 *= 0.541196100f;
tmpf_2 *= 0.630236207f;
tmpf_3 *= 0.821339815f;
tmpf_4 *= 1.306562965f;
tmpf_5 *= 3.830648788f;
// End 12 point IDCT
// Shift to 12 point modified IDCT,multiply by window type 2
float tmpf_8 = -tmpf_0 * 0.793353340f;
float tmpf_9 = -tmpf_0 * 0.608761429f;
float tmpf_7 = -tmpf_1 * 0.923879532f;
float tmpf_10 = -tmpf_1 * 0.382683432f;
float tmpf_6 = -tmpf_2 * 0.991444861f;
float tmpf_11 = -tmpf_2 * 0.130526192f;
tmpf_0 = tmpf_3;
tmpf_1 = tmpf_4 * 0.382683432f;
tmpf_2 = tmpf_5 * 0.608761429f;
tmpf_3 = -tmpf_5 * 0.793353340f;
tmpf_4 = -tmpf_4 * 0.923879532f;
tmpf_5 = -tmpf_0 * 0.991444861f;
tmpf_0 *= 0.130526192f;
out[six_i + 6] += tmpf_0;
out[six_i + 7] += tmpf_1;
out[six_i + 8] += tmpf_2;
out[six_i + 9] += tmpf_3;
out[six_i + 10] += tmpf_4;
out[six_i + 11] += tmpf_5;
out[six_i + 12] += tmpf_6;
out[six_i + 13] += tmpf_7;
out[six_i + 14] += tmpf_8;
out[six_i + 15] += tmpf_9;
out[six_i + 16] += tmpf_10;
out[six_i + 17] += tmpf_11;
six_i += 6;
}
}
else {
// 36 point IDCT
// input aliasing for 36 point IDCT
in[17] += in[16]; in[16] += in[15]; in[15] += in[14]; in[14] += in[13];
in[13] += in[12]; in[12] += in[11]; in[11] += in[10]; in[10] += in[9];
in[9] += in[8]; in[8] += in[7]; in[7] += in[6]; in[6] += in[5];
in[5] += in[4]; in[4] += in[3]; in[3] += in[2]; in[2] += in[1];
in[1] += in[0];
// 18 point IDCT for odd indices
// input aliasing for 18 point IDCT
in[17] += in[15]; in[15] += in[13]; in[13] += in[11]; in[11] += in[9];
in[9] += in[7]; in[7] += in[5]; in[5] += in[3]; in[3] += in[1];
// Fast 9 Point Inverse Discrete Cosine Transform
//
// By Francois-Raymond Boyer
// mailto:boyerf@iro.umontreal.ca
// http://www.iro.umontreal.ca/~boyerf
//
// The code has been optimized for Intel processors
// (takes a lot of time to convert float to and from iternal FPU representation)
//
// It is a simple "factorization" of the IDCT matrix.
// 9 point IDCT on even indices
// 5 points on odd indices (not realy an IDCT)
float i00 = in[0] + in[0];
float iip12 = i00 + in[12];
float tmp0 = iip12 + in[4] * 1.8793852415718f + in[8] * 1.532088886238f + in[16] * 0.34729635533386f;
float tmp1 = i00 + in[4] - in[8] - in[12] - in[12] - in[16];
float tmp2 = iip12 - in[4] * 0.34729635533386f - in[8] * 1.8793852415718f + in[16] * 1.532088886238f;
float tmp3 = iip12 - in[4] * 1.532088886238f + in[8] * 0.34729635533386f - in[16] * 1.8793852415718f;
float tmp4 = in[0] - in[4] + in[8] - in[12] + in[16];
// 4 points on even indices
float i66_ = in[6] * 1.732050808f; // Sqrt[3]
float tmp0_ = in[2] * 1.9696155060244f + i66_ + in[10] * 1.2855752193731f + in[14] * 0.68404028665134f;
float tmp1_ = (in[2] - in[10] - in[14]) * 1.732050808f;
float tmp2_ = in[2] * 1.2855752193731f - i66_ - in[10] * 0.68404028665134f + in[14] * 1.9696155060244f;
float tmp3_ = in[2] * 0.68404028665134f - i66_ + in[10] * 1.9696155060244f - in[14] * 1.2855752193731f;
// 9 point IDCT on odd indices
// 5 points on odd indices (not realy an IDCT)
float i0 = in[1] + in[1];
float i0p12 = i0 + in[13];
float tmp0o = i0p12 + in[5] * 1.8793852415718f + in[9] * 1.532088886238f + in[17] * 0.34729635533386f;
float tmp1o = i0 + in[5] - in[9] - in[13] - in[13] - in[17];
float tmp2o = i0p12 - in[5] * 0.34729635533386f - in[9] * 1.8793852415718f + in[17] * 1.532088886238f;
float tmp3o = i0p12 - in[5] * 1.532088886238f + in[9] * 0.34729635533386f - in[17] * 1.8793852415718f;
float tmp4o = (in[1] - in[5] + in[9] - in[13] + in[17]) * 0.707106781f; // Twiddled
// 4 points on even indices
float i6_ = in[7] * 1.732050808f; // Sqrt[3]
float tmp0_o = in[3] * 1.9696155060244f + i6_ + in[11] * 1.2855752193731f + in[15] * 0.68404028665134f;
float tmp1_o = (in[3] - in[11] - in[15]) * 1.732050808f;
float tmp2_o = in[3] * 1.2855752193731f - i6_ - in[11] * 0.68404028665134f + in[15] * 1.9696155060244f;
float tmp3_o = in[3] * 0.68404028665134f - i6_ + in[11] * 1.9696155060244f - in[15] * 1.2855752193731f;
// Twiddle factors on odd indices
// and
// Butterflies on 9 point IDCT's
// and
// twiddle factors for 36 point IDCT
float e = tmp0 + tmp0_; float o = (tmp0o + tmp0_o) * 0.501909918f; float tmpf_0 = e + o; float tmpf_17 = e - o; e = tmp1 + tmp1_;
o = (tmp1o + tmp1_o) * 0.517638090f; float tmpf_1 = e + o; float tmpf_16 = e - o;e = tmp2 + tmp2_; o = (tmp2o + tmp2_o) * 0.551688959f;
float tmpf_2 = e + o; float tmpf_15 = e - o; e = tmp3 + tmp3_; o = (tmp3o + tmp3_o) * 0.610387294f; float tmpf_3 = e + o; float tmpf_14 = e - o;
float tmpf_4 = tmp4 + tmp4o; float tmpf_13 = tmp4 - tmp4o; e = tmp3 - tmp3_; o = (tmp3o - tmp3_o) * 0.871723397f;
float tmpf_5 = e + o; float tmpf_12 = e - o; e = tmp2 - tmp2_; o = (tmp2o - tmp2_o) * 1.183100792f; float tmpf_6 = e + o;
float tmpf_11 = e - o; e = tmp1 - tmp1_; o = (tmp1o - tmp1_o) * 1.931851653f; float tmpf_7 = e + o; float tmpf_10 = e - o;
e = tmp0 - tmp0_; o = (tmp0o - tmp0_o) * 5.736856623f; float tmpf_8 = e + o; float tmpf_9 = e - o;
// end 36 point IDCT
// shift to modified IDCT
float[] win_bt = win[block_type];
out[0] = -tmpf_9 * win_bt[0];
out[1] = -tmpf_10 * win_bt[1];
out[2] = -tmpf_11 * win_bt[2];
out[3] = -tmpf_12 * win_bt[3];
out[4] = -tmpf_13 * win_bt[4];
out[5] = -tmpf_14 * win_bt[5];
out[6] = -tmpf_15 * win_bt[6];
out[7] = -tmpf_16 * win_bt[7];
out[8] = -tmpf_17 * win_bt[8];
out[9] = tmpf_17 * win_bt[9];
out[10] = tmpf_16 * win_bt[10];
out[11] = tmpf_15 * win_bt[11];
out[12] = tmpf_14 * win_bt[12];
out[13] = tmpf_13 * win_bt[13];
out[14] = tmpf_12 * win_bt[14];
out[15] = tmpf_11 * win_bt[15];
out[16] = tmpf_10 * win_bt[16];
out[17] = tmpf_9 * win_bt[17];
out[18] = tmpf_8 * win_bt[18];
out[19] = tmpf_7 * win_bt[19];
out[20] = tmpf_6 * win_bt[20];
out[21] = tmpf_5 * win_bt[21];
out[22] = tmpf_4 * win_bt[22];
out[23] = tmpf_3 * win_bt[23];
out[24] = tmpf_2 * win_bt[24];
out[25] = tmpf_1 * win_bt[25];
out[26] = tmpf_0 * win_bt[26];
out[27] = tmpf_0 * win_bt[27];
out[28] = tmpf_1 * win_bt[28];
out[29] = tmpf_2 * win_bt[29];
out[30] = tmpf_3 * win_bt[30];
out[31] = tmpf_4 * win_bt[31];
out[32] = tmpf_5 * win_bt[32];
out[33] = tmpf_6 * win_bt[33];
out[34] = tmpf_7 * win_bt[34];
out[35] = tmpf_8 * win_bt[35];
}
}
/**
* Reads the side info from the stream,assuming the entire. frame has been
* read already. Mono : 136 bits (= 17 bytes) Stereo : 256 bits (= 32
* bytes)
*
*@return Description of the Returned Value
*/
private final boolean get_side_info() {
int ch;
int gr;
if (header.version() == Header.MPEG1) {
si.main_data_begin = stream.readbits(9);
if (channels == 1) {
si.private_bits = stream.readbits(5);
} else {
si.private_bits = stream.readbits(3);
}
for (ch = 0; ch < channels; ch++) {
LayerIIIDecoder.Channel t = si.ch[ch];
t.scfsi[0] = stream.readbits(1);
t.scfsi[1] = stream.readbits(1);
t.scfsi[2] = stream.readbits(1);
t.scfsi[3] = stream.readbits(1);
}
for (gr = 0; gr < 2; gr++) {
for (ch = 0; ch < channels; ch++) {
LayerIIIDecoder.GRInfo s = si.ch[ch].gr[gr];
s.part2_3_length = stream.readbits(12);
s.big_values = stream.readbits(9);
s.global_gain = stream.readbits(8);
s.scalefac_compress = stream.readbits(4);
s.window_switching_flag = stream.readbits(1);
if ((s.window_switching_flag) != 0) {
s.block_type = stream.readbits(2);
s.mixed_block_flag = stream.readbits(1);
s.table_select[0] = stream.readbits(5);
s.table_select[1] = stream.readbits(5);
s.subblock_gain[0] = stream.readbits(3);
s.subblock_gain[1] = stream.readbits(3);
s.subblock_gain[2] = stream.readbits(3);
// Set region_count parameters since they are implicit in this case.
if (s.block_type == 0) {
// Side info bad: block_type == 0 in split block
return false;
} else if (s.block_type == 2 && s.mixed_block_flag == 0) {
s.region0_count = 8;
} else {
s.region0_count = 7;
}
s.region1_count = 20 - s.region0_count;
} else {
s.table_select[0] = stream.readbits(5);
s.table_select[1] = stream.readbits(5);
s.table_select[2] = stream.readbits(5);
s.region0_count = stream.readbits(4);
s.region1_count = stream.readbits(3);
s.block_type = 0;
}
s.preflag = stream.readbits(1);
s.scalefac_scale = stream.readbits(1);
s.count1table_select = stream.readbits(1);
}
}
} else {
//unused currently
// MPEG-2 LSF
si.main_data_begin = stream.readbits(8);
if (channels == 1) {
si.private_bits = stream.readbits(1);
} else {
si.private_bits = stream.readbits(2);
}
for (ch = 0; ch < channels; ch++) {
LayerIIIDecoder.GRInfo s = si.ch[ch].gr[0];
s.part2_3_length = stream.readbits(12);
s.big_values = stream.readbits(9);
s.global_gain = stream.readbits(8);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -