[FFmpeg-devel] [PATCH] AAC Decoder - Round 2.
Michael Niedermayer
michaelni
Mon Jun 23 17:15:52 CEST 2008
On Mon, Jun 23, 2008 at 02:10:56PM +0100, Robert Swain wrote:
> 2008/6/20 Michael Niedermayer <michaelni at gmx.at>:
> > On Thu, Jun 19, 2008 at 04:22:57PM +0100, Robert Swain wrote:
> > [...]
> >> +static void vector_fmul_add_add_add(AACContext * ac, float * dst, const float * src0, const float * src1, const float * src2, const float * src3, float src4, int len) {
> >> + int i;
> >> + ac->dsp.vector_fmul_add_add(dst, src0, src1, src2, src4, len, 1);
> >> + for (i = 0; i < len; i++)
> >> + dst[i] += src3[i];
> >> +}
> >
> > why does AAC need this and other codecs not?
> > (iam askng as my gut says there might be a bug but i could be wrong, i didnt
> > investigate this too carefull but IIRC there was some comment somewhere in
> > the src about short windows having artifacts and its strange that other
> > codecs do not need above)
>
> The eight short window sequence has to take saved data both from the
> saved frame and from the saved short window hence the additional
> addition.
This doesnt sound correct. Does window switching even work? Or does it
produce some artifacts?
If it does work i suspect 90% of your windows are 1.0 or 0.0
Also see vorbis_dec.c for how windows switching is done without
vector_fmul_add_add_add()
>
> > [...]
> >> +
> >> + for (g = 0; g < ics->num_window_groups; g++) {
> >> + for (i = 0; i < ics->max_sfb; i++) {
> >> + if (cb[g][i] == NOISE_HCB) {
> >> + for (group = 0; group < ics->group_len[g]; group++) {
> >> + float energy = 0;
> >> + float scale = 1.;// / (float)(offsets[i+1] - offsets[i]);
> >> + for (k = offsets[i]; k < offsets[i+1]; k++)
> >> + energy += (float)icoef[group*128+k] * icoef[group*128+k];
> >> + scale *= sf[g][i] / sqrt(energy);
> >
> > are you sure that the random values have to be normalized like that?
> > I suspect energy is supposed tp be a constant.
>
> That's how it is in the spec. From section 4.6.13 Perceptual Noise
> Substitution (PNS):
Ive checked the spec before my reply, and i belive your code is wrong.
>
> The energy information for percpetual noise substitution decoding is
> represented by a "noise energy" value indicating the overall power of
> the substituted spectral coefficients in steps of 1.5 dB. If noise
> substitution coding is active for a particular group and scalefactor
> band, a noise energy value is transmitted instead of the scalefactor
> of the respective channel.
Doesnt say that the output from the random number generator should be choped
up in bands and each independantly renormalized.
Heres what the spec says:
/* Decode noise energies for this group */
for (sfb=0; sfb<max_sfb; sfb++)
if (is_noise(g,sfb))
noise_nrg[g][sfb] = nrg += dpcm_noise_nrg[g][sfb];
/* Do perceptual noise substitution decoding */
for (b=0; b<window_group_length[g]; b++) {
for (sfb=0; sfb<max_sfb; sfb++) {
if (is_noise(g,sfb)) {
offs = swb_offset[sfb];
size = swb_offset[sfb+1] - offs;
/* Generate random vector */
gen_rand_vector( &spec[g][b][sfb][0], size );
scale = 1/(size * sqrt(MEAN_NRG));
scale *= 2.0^(0.25*noise_nrg [g][sfb]);
/* Scale random vector to desired target energy */
for (i=0; i<len; i++)
spec[g][b][sfb][i] *= scale;
}
}
}
...
The function gen_rand_vector( addr, size ) generates a vector of length <size> with signed random values of
average energy MEAN_NRG per random value. A suitable random number generator can be realized using one
multiplication/accumulation per random value.
No weird renormalization!
also the size factor is commented out in our code, i guess to cancel the
incorrect normalization mostly out.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080623/fde2d66a/attachment.pgp>
More information about the ffmpeg-devel
mailing list