Improves subjective quality
Formula and testing by: kamedo2 <fujisakihir90@yahoo.co.jp>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -292,7 +292,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { |
292 | 292 |
int i, j, g, start; |
293 | 293 |
float prev, minscale, minath, minsnr, pe_min; |
294 | 294 |
const int chan_bitrate = ctx->avctx->bit_rate / ctx->avctx->channels; |
295 |
- const int bandwidth = ctx->avctx->cutoff ? ctx->avctx->cutoff : ctx->avctx->sample_rate / 2; |
|
295 |
+ const int bandwidth = ctx->avctx->cutoff ? ctx->avctx->cutoff : AAC_CUTOFF(ctx->avctx); |
|
296 | 296 |
const float num_bark = calc_bark((float)bandwidth); |
297 | 297 |
|
298 | 298 |
ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext)); |
... | ... |
@@ -100,6 +100,9 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av |
100 | 100 |
if (avctx->cutoff > 0) |
101 | 101 |
cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate; |
102 | 102 |
|
103 |
+ if (!cutoff_coeff && avctx->codec_id == CODEC_ID_AAC) |
|
104 |
+ cutoff_coeff = 2.0 * AAC_CUTOFF(avctx) / avctx->sample_rate; |
|
105 |
+ |
|
103 | 106 |
if (cutoff_coeff) |
104 | 107 |
ctx->fcoeffs = ff_iir_filter_init_coeffs(avctx, FF_FILTER_TYPE_BUTTERWORTH, |
105 | 108 |
FF_FILTER_MODE_LOWPASS, FILT_ORDER, |
... | ... |
@@ -29,6 +29,8 @@ |
29 | 29 |
/** maximum number of channels */ |
30 | 30 |
#define PSY_MAX_CHANS 20 |
31 | 31 |
|
32 |
+#define AAC_CUTOFF(s) (s->bit_rate ? FFMIN3(4000 + s->bit_rate/8, 12000 + s->bit_rate/32, s->sample_rate / 2) : (s->sample_rate / 2)) |
|
33 |
+ |
|
32 | 34 |
/** |
33 | 35 |
* single band psychoacoustic information |
34 | 36 |
*/ |