Example #1
0
void psycho_3 (short buffer[2][1152], double scale[2][SBLIMIT],
	       double ltmin[2][SBLIMIT], frame_info * frame, options *glopts)
{
  int nch = frame->nch;
  int sblimit = frame->sblimit;
  int k, i;
  static char init = 0;
  static int off[2] = { 256, 256 };
  FLOAT sample[BLKSIZE];

  FLOAT energy[BLKSIZE];
  FLOAT power[HBLKSIZE];
  FLOAT Xtm[HBLKSIZE], Xnm[HBLKSIZE];
  int tonelabel[HBLKSIZE], noiselabel[HBLKSIZE];
  FLOAT LTg[HBLKSIZE];
  double Lsb[SBLIMIT];

  header = frame->header;

  if (init==0) {		
    psycho_3_init(glopts);
    init++;
  }
  

  for (k = 0; k < nch; k++) {
    int ok = off[k] % 1408;
    for (i = 0; i < 1152; i++) {
      fft_buf[k][ok++] = (FLOAT) buffer[k][i] / SCALE;
      if (ok >= 1408)
	ok = 0;
    }
    ok = (off[k] + 1216) % 1408;
    for (i = 0; i < BLKSIZE; i++) {
      sample[i] = fft_buf[k][ok++];
      if (ok >= 1408)
	ok = 0;
    }

    off[k] += 1152;
    off[k] %= 1408;

    psycho_3_fft(sample, energy);
    psycho_3_powerdensityspectrum(energy, power);    
    psycho_3_spl(Lsb, power, &scale[k][0]);
    psycho_3_tonal_label (power, tonelabel, Xtm);
    psycho_3_noise_label (power, energy, tonelabel, noiselabel, Xnm);
    if (glopts->verbosity > 20)
      psycho_3_dump(tonelabel, Xtm, noiselabel, Xnm);
    psycho_3_decimation(ath, tonelabel, Xtm, noiselabel, Xnm, bark);
    psycho_3_threshold(LTg, tonelabel, Xtm, noiselabel, Xnm, bark, ath, bitrate[header->version][header->bitrate_index] / nch, freq_subset);
    psycho_3_minimummasking(LTg, &ltmin[k][0], freq_subset);
    psycho_3_smr(&ltmin[k][0], Lsb);
  }
}
Example #2
0
void psycho_3(twolame_options * glopts, short int buffer[2][1152], FLOAT scale[2][32],
              FLOAT ltmin[2][32])
{
    psycho_3_mem *mem;
    int nch = glopts->num_channels_out;
    int k, i;
    FLOAT sample[BLKSIZE];

    FLOAT energy[BLKSIZE];
    FLOAT power[HBLKSIZE];
    FLOAT Xtm[HBLKSIZE], Xnm[HBLKSIZE];
    int tonelabel[HBLKSIZE], noiselabel[HBLKSIZE];
    FLOAT LTg[HBLKSIZE];
    FLOAT Lsb[SBLIMIT];

    if (!glopts->p3mem) {
        glopts->p3mem = psycho_3_init(glopts);
    }
    mem = glopts->p3mem;

    for (k = 0; k < nch; k++) {
        int ok = mem->off[k] % 1408;
        for (i = 0; i < 1152; i++) {
            mem->fft_buf[k][ok++] = (FLOAT) buffer[k][i] / SCALE;
            if (ok >= 1408)
                ok = 0;
        }
        ok = (mem->off[k] + 1216) % 1408;
        for (i = 0; i < BLKSIZE; i++) {
            sample[i] = mem->fft_buf[k][ok++];
            if (ok >= 1408)
                ok = 0;
        }

        mem->off[k] += 1152;
        mem->off[k] %= 1408;

        psycho_3_fft(sample, energy);
        psycho_3_powerdensityspectrum(energy, power);
        psycho_3_spl(Lsb, power, &scale[k][0]);
        psycho_3_tonal_label(mem, power, tonelabel, Xtm);
        psycho_3_noise_label(mem, power, energy, tonelabel, noiselabel, Xnm);
        if (glopts->verbosity > 8)
            psycho_3_dump(tonelabel, Xtm, noiselabel, Xnm);
        psycho_3_decimation(mem->ath, tonelabel, Xtm, noiselabel, Xnm, mem->bark);
        psycho_3_threshold(mem, LTg, tonelabel, Xtm, noiselabel, Xnm, mem->bark, mem->ath,
                           glopts->bitrate / nch, mem->freq_subset);
        psycho_3_minimummasking(LTg, &ltmin[k][0], mem->freq_subset);
        psycho_3_smr(&ltmin[k][0], Lsb);
    }
}