[M4IF Technotes] Re: AAC: PNS scale factors

John Cox jc sj.co.uk
Mon Jun 23 19:28:08 EDT 2003


Dear Ralph
I'm glad that you agree that the standard and reference stuff don't
match at the moment.  Your fix is probably optimal.  However, in my case
where I am implementing a fixed-point decoder, perfoming a square root
on a general number is hard, whereas the individual sample scale factor
can be pulled from a small lookup table (after all there are only about
32 availible values of size).  I don't know how important having the
correct energy in any given frame is vs. having the correct energy over
time - has anyone done any tests?
Ideally there would by synced 'random' number generators in the encoder
and decoder so the encoder knows exactly what to expect, in which case
there would be no need for the final renormalization.
Many thanks
John Cox
SJ Consulting
On Mon, 23 Jun 2023 19:04:10 +0200, you wrote:
>Dear John,
>
>the reference software comes with the following code:
>
>  norm = 1.0 / sqrt( size * MEAN_NRG );
>  for (i=0; i<size; i++) {
>    spec[i] = (Float)(random2( state ) * norm);
>    nrg += spec[i] * spec[i];
>  }
>  s = 1.0 / sqrt( nrg );
>  for (i=0; i<size; i++) {
>    spec[i] *= s;
>  }
>
>Due to the second rescaling, the first scaling is obsolete. Thus, MEAN_NRG can 
>have any non-zero value, the output will always be the same.
>
>Beside this, the rescaling formula in the standard seems to be wrong, and the 
>formula used in the software seems to be correct.
>
>However, the algorithm using MEAN_NRG does not assure that the energy per band 
>fits the requirements, since the delivered random values (its a finite number) 
>might have another mean energy. Therefore, the second rescaling has been added 
>in the software.
>
>Subsequently, we tend to propose a correction of the pseudo code in the standard 
>as follows:
>
>nrg=0;
>gen_rand_vector( &spec[g][b][sfb][0], size );
>for (i=0; i<len; i++) {
>   nrg += spec[g][b][sfb][i] * spec[g][b][sfb][i];
>}
>/* avoid division by zero */
>sqrt_nrg = sqrt (nrg);
>if (sqrt_nrg <= 0.0f ) {
>   sqrt_nrg = FLT_MIN;
>}
>scale = (2.0^(0.25*noise_nrg [g][sfb]))/sqrt_nrg;
>
>/* Scale random vector to desired target energy */
>for (i=0; i<len; i++) {
>   spec[g][b][sfb][i] *= scale;
>}
>
>The subsequent text needs than to be adopted as follows:
>"The function gen_rand_vector( addr, size ) generates a vector of length <size> 
>with signed random values. A suitable random number generator can be realized 
>using one multiplication/accumulation per random value."
>
>What do you think about this?
>
>Best regards,
>
>Ralph
>
>John Cox wrote:
>> Hi
>> 
>> Thanks for the pointer.  If those reference wav files are definitive
>> then the published standard is wrong and the reference software is
>> right.  The scale factor should read:
>> 
>> scale = 1/sqrt(size * MEAN_NRG);
>> 
>> Many thanks
>> 
>> John Cox
>> 
>> 
>>>Dear John,
>>>
>>>I don't have an answer to your first question.  But for the reference wav 
>>>files, you can fetch them from:
>>>ftp://mpaudconf:[email protected]/guests/mpeg4audio/incoming/testSequences/mpeg4audio-conformance/referencesWav/
>>>
>>>Regards,
>>>Eddie
>>>
>>>At 04:09 PM 6/18/2003 +0100, John Cox wrote:
>>>
>>>>Hi
>>>>
>>>>The standard says (ISO/IEC 14496-3:2001(E); 4.6.13.3 page 174) that the
>>>>initial scale factor for PNS values is:
>>>>
>>>>scale = 1/(size * sqrt(MEAN_NRG));
>>>>
>>>>however the reference software from the ISO site (both refSoft &
>>>>rewrite) seems to calculate it as:
>>>>
>>>>scale = 1/sqrt(size * MEAN_NRG));
>>>>
>>>>Which is "correct" and what have other people done?
>>>>
>>>>I've found the PNS reference streams AL18*.mp4 & AL19*.mp4 (though not
>>>>AL09,10,11) but no corresponding .wavs to check against - do they exist
>>>>anywhere?
>>>>
>>>>Many thanks
>>>>
>>>>John Cox
>>>>SJ Consulting
>> 
>> 
>> 
>> _______________________________________________
>> Technotes mailing list
>> Technotes   lists.m4if.org
>> http://lists.m4if.org/mailman/listinfo/technotes



More information about the Mp4-tech mailing list