internal void trancate_smallspectrums(LameInternalFlags gfc, GrInfo gi, float[] l3_xmin, float[] work) { var distort = new float[L3Side.SFBMAX]; if (0 == (gfc.substep_shaping & 4) && gi.block_type == Encoder.SHORT_TYPE || (gfc.substep_shaping & 0x80) != 0) { return; } qupvt.calc_noise(gi, l3_xmin, distort, new CalcNoiseResult(), null); for (var jj = 0; jj < 576; jj++) { var xr = 0.0f; if (gi.l3_enc[jj] != 0) { xr = Math.Abs(gi.xr[jj]); } work[jj] = xr; } var j = 0; var sfb = 8; if (gi.block_type == Encoder.SHORT_TYPE) { sfb = 6; } do { float allowedNoise, trancateThreshold; int nsame, start; var width = gi.width[sfb]; j += width; if (distort[sfb] >= 1.0) { continue; } Arrays.Sort(work, j - width, width); if (BitStream.EQ(work[j - 1], 0.0f)) { continue; } allowedNoise = (1.0f - distort[sfb]) * l3_xmin[sfb]; trancateThreshold = 0.0f; start = 0; do { float noise; for (nsame = 1; start + nsame < width; nsame++) { if (BitStream.NEQ(work[start + j - width], work[start + j + nsame - width])) { break; } } noise = work[start + j - width] * work[start + j - width] * nsame; if (allowedNoise < noise) { if (start != 0) { trancateThreshold = work[start + j - width - 1]; } break; } allowedNoise -= noise; start += nsame; }while (start < width); if (BitStream.EQ(trancateThreshold, 0.0f)) { continue; } do { if (Math.Abs(gi.xr[j - width]) <= trancateThreshold) { gi.l3_enc[j - width] = 0; } }while (--width > 0); }while (++sfb < gi.psymax); gi.part2_3_length = tk.noquant_count_bits(gfc, gi, null); }
private int quantizeAndCountBits(algo_t that) { quantize_x34(that); that.cod_info.part2_3_length = tak.noquant_count_bits(that.gfc, that.cod_info, null); return(that.cod_info.part2_3_length); }