]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/psymodel.c
tablegen: the executable depends on tablegen headers as well
[ffmpeg] / libavcodec / psymodel.c
index 048f270467982635b9fcf89eaa5ec394640c99e4..f87dbcf2776f08905d4b1e1ad6181822e96ceeb2 100644 (file)
@@ -80,15 +80,14 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
 {
     FFPsyPreprocessContext *ctx;
     int i;
-    float cutoff_coeff;
+    float cutoff_coeff = 0;
     ctx        = av_mallocz(sizeof(FFPsyPreprocessContext));
     ctx->avctx = avctx;
 
-    if (avctx->flags & CODEC_FLAG_QSCALE)
-        cutoff_coeff = 1.0f / av_clip(1 + avctx->global_quality / FF_QUALITY_SCALE, 1, 8);
-    else
-        cutoff_coeff = avctx->bit_rate / (4.0f * avctx->sample_rate * avctx->channels);
+    if (avctx->cutoff > 0)
+        cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate;
 
+    if (cutoff_coeff)
     ctx->fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
                                              FILT_ORDER, cutoff_coeff, 0.0, 0.0);
     if (ctx->fcoeffs) {
@@ -105,16 +104,14 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx,
 {
     int ch, i;
     if (ctx->fstate) {
-        for (ch = 0; ch < channels; ch++) {
+        for (ch = 0; ch < channels; ch++)
             ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size,
                           audio + ch, ctx->avctx->channels,
                           dest  + ch, ctx->avctx->channels);
-        }
     } else {
-        for (ch = 0; ch < channels; ch++) {
+        for (ch = 0; ch < channels; ch++)
             for (i = 0; i < ctx->avctx->frame_size; i++)
                 dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch];
-        }
     }
 }