MCPcopy Create free account
hub / github.com/zhuker/lamejs / outer_loop

Method outer_loop

src/main/java/mp3/Quantize.java:847–1029  ·  view source on GitHub ↗

Function: The outer iteration loop controls the masking conditions of all scalefactorbands. It computes the best scalefac and global gain. This module calls the inner iteration loop mt 5/99 completely rewritten to allow for bit reservoir control, mid/side channels with L/R or mid/side ma

(final LameGlobalFlags gfp,
			final GrInfo cod_info, final float[] l3_xmin, float xrpow[],
			final int ch, final int targ_bits)

Source from the content-addressed store, hash-verified

845 * maximum allowed bits
846 */
847 public final int outer_loop(final LameGlobalFlags gfp,
848 final GrInfo cod_info, final float[] l3_xmin, float xrpow[],
849 final int ch, final int targ_bits) {
850 final LameInternalFlags gfc = gfp.internal_flags;
851 GrInfo cod_info_w = new GrInfo();
852 float save_xrpow[] = new float[576];
853 float distort[] = new float[L3Side.SFBMAX];
854 CalcNoiseResult best_noise_info = new CalcNoiseResult();
855 int better;
856 CalcNoiseData prev_noise = new CalcNoiseData();
857 int best_part2_3_length = 9999999;
858 boolean bEndOfSearch = false;
859 boolean bRefine = false;
860 int best_ggain_pass1 = 0;
861
862 bin_search_StepSize(gfc, cod_info, targ_bits, ch, xrpow);
863
864 if (0 == gfc.noise_shaping)
865 /* fast mode, no noise shaping, we are ready */
866 return 100; /* default noise_info.over_count */
867
868 /* compute the distortion in this quantization */
869 /* coefficients and thresholds both l/r (or both mid/side) */
870 qupvt.calc_noise(cod_info, l3_xmin, distort, best_noise_info,
871 prev_noise);
872 best_noise_info.bits = cod_info.part2_3_length;
873
874 cod_info_w.assign(cod_info);
875 int age = 0;
876 System.arraycopy(xrpow, 0, save_xrpow, 0, 576);
877
878 while (!bEndOfSearch) {
879 /* BEGIN MAIN LOOP */
880 do {
881 CalcNoiseResult noise_info = new CalcNoiseResult();
882 int search_limit;
883 int maxggain = 255;
884
885 /*
886 * When quantization with no distorted bands is found, allow up
887 * to X new unsuccesful tries in serial. This gives us more
888 * possibilities for different quant_compare modes. Much more
889 * than 3 makes not a big difference, it is only slower.
890 */
891
892 if ((gfc.substep_shaping & 2) != 0) {
893 search_limit = 20;
894 } else {
895 search_limit = 3;
896 }
897
898 /*
899 * Check if the last scalefactor band is distorted. in VBR mode
900 * we can't get rid of the distortion, so quit now and VBR mode
901 * will try again with more bits. (makes a 10% speed increase,
902 * the files I tested were binary identical, 2000/05/20 Robert
903 * Hegemann) distort[] > 1 means noise > allowed noise
904 */

Callers 6

VBR_encode_granuleMethod · 0.95
CBRNewIterationLoopFunction · 0.80
BcFunction · 0.80
CBRNewIterationLoopFunction · 0.80
iteration_loopMethod · 0.80
iteration_loopMethod · 0.80

Calls 7

bin_search_StepSizeMethod · 0.95
assignMethod · 0.95
balance_noiseMethod · 0.95
quant_compareMethod · 0.95
calc_noiseMethod · 0.80
count_bitsMethod · 0.80

Tested by

no test coverage detected