private int reduce_bit_usage(final LameInternalFlags gfc, final int gr, final int ch) {
    final GrInfo cod_info = gfc.l3_side.tt[gr][ch];
    // try some better scalefac storage
    tak.best_scalefac_store(gfc, gr, ch, gfc.l3_side);

    // best huffman_divide may save some bits too
    if (gfc.use_best_huffman == 1) tak.best_huffman_divide(gfc, cod_info);
    return cod_info.part2_3_length + cod_info.part2_length;
  }
  private void bitcount(final algo_t that) {
    boolean rc;

    if (that.gfc.mode_gr == 2) {
      rc = tak.scale_bitcount(that.cod_info);
    } else {
      rc = tak.scale_bitcount_lsf(that.gfc, that.cod_info);
    }
    if (!rc) {
      return;
    }
    /* this should not happen due to the way the scalefactors are selected */
    throw new RuntimeException("INTERNAL ERROR IN VBR NEW CODE (986), please send bug report");
  }
 private int quantizeAndCountBits(final 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;
 }
示例#4
0
  /** initialization for iteration_loop */
  public final void iteration_init(final LameGlobalFlags gfp) {
    final LameInternalFlags gfc = gfp.internal_flags;
    final IIISideInfo l3_side = gfc.l3_side;
    int i;

    if (gfc.iteration_init_init == 0) {
      gfc.iteration_init_init = 1;

      l3_side.main_data_begin = 0;
      compute_ath(gfp);

      pow43[0] = 0.0f;
      for (i = 1; i < PRECALC_SIZE; i++) pow43[i] = (float) Math.pow((float) i, 4.0 / 3.0);

      for (i = 0; i < PRECALC_SIZE - 1; i++)
        adj43[i] = (float) ((i + 1) - Math.pow(0.5 * (pow43[i] + pow43[i + 1]), 0.75));
      adj43[i] = 0.5f;

      for (i = 0; i < Q_MAX; i++) ipow20[i] = (float) Math.pow(2.0, (i - 210) * -0.1875);
      for (i = 0; i <= Q_MAX + Q_MAX2; i++)
        pow20[i] = (float) Math.pow(2.0, (i - 210 - Q_MAX2) * 0.25);

      tak.huffman_init(gfc);

      {
        float bass, alto, treble, sfb21;

        i = (gfp.exp_nspsytune >> 2) & 63;
        if (i >= 32) i -= 64;
        bass = (float) Math.pow(10, i / 4.0 / 10.0);

        i = (gfp.exp_nspsytune >> 8) & 63;
        if (i >= 32) i -= 64;
        alto = (float) Math.pow(10, i / 4.0 / 10.0);

        i = (gfp.exp_nspsytune >> 14) & 63;
        if (i >= 32) i -= 64;
        treble = (float) Math.pow(10, i / 4.0 / 10.0);

        /*
         * to be compatible with Naoki's original code, the next 6 bits
         * define only the amount of changing treble for sfb21
         */
        i = (gfp.exp_nspsytune >> 20) & 63;
        if (i >= 32) i -= 64;
        sfb21 = treble * (float) Math.pow(10, i / 4.0 / 10.0);
        for (i = 0; i < Encoder.SBMAX_l; i++) {
          float f;
          if (i <= 6) f = bass;
          else if (i <= 13) f = alto;
          else if (i <= 20) f = treble;
          else f = sfb21;

          gfc.nsPsy.longfact[i] = f;
        }
        for (i = 0; i < Encoder.SBMAX_s; i++) {
          float f;
          if (i <= 5) f = bass;
          else if (i <= 10) f = alto;
          else if (i <= 11) f = treble;
          else f = sfb21;

          gfc.nsPsy.shortfact[i] = f;
        }
      }
    }
  }