Esempio n. 1
0
av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *avctx)
{
  FFPsyPreprocessContext *ctx;
  int i;
  float cutoff_coeff = 0;
  ctx        = av_mallocz(sizeof(FFPsyPreprocessContext));
  ctx->avctx = avctx;

  if (avctx->cutoff > 0)
    cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate;

  if (!cutoff_coeff && avctx->codec_id == AV_CODEC_ID_AAC)
    cutoff_coeff = 2.0 * AAC_CUTOFF(avctx) / avctx->sample_rate;

  if (cutoff_coeff && cutoff_coeff < 0.98)
    ctx->fcoeffs = ff_iir_filter_init_coeffs(avctx, FF_FILTER_TYPE_BUTTERWORTH,
                                             FF_FILTER_MODE_LOWPASS, FILT_ORDER,
                                             cutoff_coeff, 0.0, 0.0);
  if (ctx->fcoeffs) {
    ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
    for (i = 0; i < avctx->channels; i++)
      ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
  }

  ff_iir_filter_init(&ctx->fiir);

  return ctx;
}
Esempio n. 2
0
int main(void)
{
    struct FFIIRFilterCoeffs *fcoeffs = NULL;
    struct FFIIRFilterState  *fstate  = NULL;
    float cutoff_coeff = 0.4;
    int16_t x[SIZE], y[SIZE];
    int i;

    fcoeffs = ff_iir_filter_init_coeffs(NULL, FF_FILTER_TYPE_BUTTERWORTH,
                                        FF_FILTER_MODE_LOWPASS, FILT_ORDER,
                                        cutoff_coeff, 0.0, 0.0);
    fstate  = ff_iir_filter_init_state(FILT_ORDER);

    for (i = 0; i < SIZE; i++)
        x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE));

    ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1);

    for (i = 0; i < SIZE; i++)
        printf("%6d %6d\n", x[i], y[i]);

    ff_iir_filter_free_coeffsp(&fcoeffs);
    ff_iir_filter_free_statep(&fstate);
    return 0;
}