[FFmpeg-devel] [PATCH 2/3] [GSoC] [AAC] aaccoder: Implement Perceptual Noise Substitution
Claudio Freire
klaussfreire at gmail.com
Mon Apr 13 05:01:44 CEST 2015
On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
<atomnuker at gmail.com> wrote:
> @@ -245,6 +258,8 @@ static float (*const quantize_and_encode_band_cost_arr[])(
> quantize_and_encode_band_cost_UPAIR,
> quantize_and_encode_band_cost_UPAIR,
> quantize_and_encode_band_cost_ESC,
> + NULL,
> + quantize_and_encode_band_cost_NOISE,
> };
Make a function that has the same signature as the
quantize_and_encode_band_cost_X functions here, but whose only
contents are an assert(false), and add it instead of the NULL.
> + energies[w*16+g] = log2f(2*(energy*energy));
> + energy_avg = (energies[w*16+g] + energy_avg)/2;
Not sure I follow the math there. Why the average?
It seems to me that you're trying to compensate for the encoding error
on the first patch (failing to initialize off_pns with -90).
> - if (sce->sf_idx[i] < 218 - qstep)
> + if (sce->sf_idx[i] < 218 - qstep && sce->band_type[i] < NOISE_BT)
> sce->sf_idx[i] += qstep;
> } else {
> for (i = 0; i < 128; i++)
> - if (sce->sf_idx[i] > 60 - qstep)
> + if (sce->sf_idx[i] > 60 - qstep && sce->band_type[i] < NOISE_BT)
> sce->sf_idx[i] -= qstep;
Careful here. You're using band_type[i], but not all of them will have
been initialize to NOISE_BT (ie: consider window groups, only w*16+g
is intialized, with w the first window in the group, the rest are not
initialized.
Probably the easiest solution is to initialize them all to NOISE_BT.
> + if (freq > 4000.0f && energy <= uplim * 1.52f) {
4000.0f should probably be a constant somewhere.
> + float freq = (w*16+g)*(avctx->sample_rate/(1024/sce->ics.num_windows)/2);
This is wrong. Should be
start*avctx->sample_rate/(1024/sce->ics.num_windows)/2
More precisely, the window doesn't count for this calculation, you
don't care which window it is, only which coefficient.
And that will be an int, not a float.
Other than that, it looks fine.
You should try to fix the off_pns issue, retest, and resubmit.
More information about the ffmpeg-devel
mailing list