public final void quant(final float[] lsp,
                          final float[] qlsp,
                          final int order,
                          final Bits bits)
  {
    int i;
    float tmp1, tmp2;
    int id;
    float[] quant_weight = new float[MAX_LSP_SIZE];

    for (i=0;i<order;i++)
      qlsp[i]=lsp[i];
    quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
    quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
    for (i=1;i<order-1;i++) {
      tmp1 = 1/((.15f+qlsp[i]-qlsp[i-1])*(.15f+qlsp[i]-qlsp[i-1]));
      tmp2 = 1/((.15f+qlsp[i+1]-qlsp[i])*(.15f+qlsp[i+1]-qlsp[i]));
      quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
    }

    for (i=0;i<order;i++)
      qlsp[i]-=(.25*i+.25);
    for (i=0;i<order;i++)
      qlsp[i]*=256;
    
    id = lsp_quant(qlsp, 0, cdbk_nb, NB_CDBK_SIZE, order);
    bits.pack(id, 6);

    for (i=0;i<order;i++)
      qlsp[i]*=2;
    id = lsp_weight_quant(qlsp, 0, quant_weight, 0, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5);
    bits.pack(id, 6);
    id = lsp_weight_quant(qlsp, 5, quant_weight, 5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
    bits.pack(id, 6);

    for (i=0;i<order;i++)
      qlsp[i]*=0.0019531;
    for (i=0;i<order;i++)
      qlsp[i]=lsp[i]-qlsp[i];
  }