Exemple #1
0
/*
 * bin_search_StepSize:
 * --------------------
 * Succesive approximation approach to obtaining a initial quantizer
 * step size.
 * The following optional code written by Seymour Shlien
 * will speed up the shine_outer_loop code which is called
 * by iteration_loop. When BIN_SEARCH is defined, the
 * shine_outer_loop function precedes the call to the function shine_inner_loop
 * with a call to bin_search gain defined below, which
 * returns a good starting quantizerStepSize.
 */
int bin_search_StepSize(int desired_rate, int ix[GRANULE_SIZE],
                        gr_info * cod_info, shine_global_config *config)
{
  int bit, next, count;

  next  = -120;
  count = 120;

  do {
    int half = count / 2;

    if (quantize(ix, next + half, config) > 8192)
      bit = 100000;  /* fail */
    else
    {
      calc_runlen(ix, cod_info);           /* rzero,count1,big_values */
      bit = count1_bitcount(ix, cod_info); /* count1_table selection */
      subdivide(cod_info, config);         /* bigvalues sfb division */
      bigv_tab_select(ix, cod_info);       /* codebook selection */
      bit += bigv_bitcount(ix, cod_info);  /* bit count */
    }

    if (bit < desired_rate)
      count = half;
    else
    {
      next += half;
      count -= half;
    }
  } while (count > 1);

  return next;
}
Exemple #2
0
/*
 * bin_search_StepSize:
 * --------------------
 * Succesive approximation approach to obtaining a initial quantizer
 * step size.
 * The following optional code written by Seymour Shlien
 * will speed up the outer_loop code which is called
 * by iteration_loop. When BIN_SEARCH is defined, the
 * outer_loop function precedes the call to the function inner_loop
 * with a call to bin_search gain defined below, which
 * returns a good starting quantizerStepSize.
 */
int bin_search_StepSize(int desired_rate, int ix[samp_per_frame2],
                        gr_info * cod_info)
{
  int top,bot,next,last,bit;

  top  = -120;
  bot  = 0;
  next = top;

  do
  {
    last = next;
    next = (top+bot) >> 1;

    if(quantize(ix,next) > 8192)
      bit = 100000;  /* fail */
    else
    {
      calc_runlen(ix,cod_info);            /* rzero,count1,big_values */
      bit = count1_bitcount(ix, cod_info); /* count1_table selection */
      subdivide(cod_info);                 /* bigvalues sfb division */
      bigv_tab_select(ix,cod_info);        /* codebook selection */
      bit += bigv_bitcount(ix,cod_info);   /* bit count */
    }

    if (bit>desired_rate)
      top = next;
    else
      bot = next;
  }
  while((bit!=desired_rate) && abs(last-next)>1);
  return next;
}
Exemple #3
0
/*
 * inner_loop:
 * ----------
 * The code selects the best quantizerStepSize for a particular set
 * of scalefacs.
 */
static int inner_loop(int ix[samp_per_frame2], 
                      int max_bits, gr_info *cod_info, int gr, int ch )
{
  int bits, c1bits, bvbits;

  if(max_bits<0)
    cod_info->quantizerStepSize--;
  do
  {
    while(quantize(ix,++cod_info->quantizerStepSize) > 8192); /* within table range? */

    calc_runlen(ix,cod_info);                        /* rzero,count1,big_values*/
    bits = c1bits = count1_bitcount(ix,cod_info);    /* count1_table selection*/
    subdivide(cod_info);                             /* bigvalues sfb division */
    bigv_tab_select(ix,cod_info);                    /* codebook selection*/
    bits += bvbits = bigv_bitcount( ix, cod_info );  /* bit count */
  }
  while(bits>max_bits);
  return bits;
}
Exemple #4
0
/*
 * shine_inner_loop:
 * ----------
 * The code selects the best quantizerStepSize for a particular set
 * of scalefacs.
 */
int shine_inner_loop(int ix[GRANULE_SIZE],
               int max_bits, gr_info *cod_info, int gr, int ch,
               shine_global_config *config )
{
  int bits, c1bits, bvbits;

  if(max_bits<0)
    cod_info->quantizerStepSize--;
  do
  {
    while(quantize(ix,++cod_info->quantizerStepSize,config) > 8192); /* within table range? */

    calc_runlen(ix,cod_info);                        /* rzero,count1,big_values*/
    bits = c1bits = count1_bitcount(ix,cod_info);    /* count1_table selection*/
    subdivide(cod_info, config);                     /* bigvalues sfb division */
    bigv_tab_select(ix,cod_info);                    /* codebook selection*/
    bits += bvbits = bigv_bitcount( ix, cod_info );  /* bit count */
  }
  while(bits>max_bits);
  return bits;
}