Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: HE AAC - extra samples at sample start or end (Read 14431 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

HE AAC - extra samples at sample start or end

Hi everyone,
When I encode/decode HE AAC using most of today's available AAC codecs, I
get extra silent samples appended at the beginning and/or at sample end. Is this
behaviour normal (i.e. ISO algorithmicaly standardized, cannot be avoided),
or is there a cure for this (i.e. can be avoided by using proper lookahead,
downsampling, filtering, filterbank implementations, etc)?

Have in mind this is HE AAC, not LC AAC.

Thanks.

HE AAC - extra samples at sample start or end

Reply #1
Just like LC AAC, HE AAC has a algorithmical delay that cannot be avoided. The difference between the 2 is that the delay of the SBR filterbank is not nicely on an AAC frame border (1536 samples IIRC).
The delay can be compensated with external signalling, just like in MP3 usually.

HE AAC - extra samples at sample start or end

Reply #2
Just like LC AAC, HE AAC has a algorithmical delay that cannot be avoided. The difference between the 2 is that the delay of the SBR filterbank is not nicely on an AAC frame border (1536 samples IIRC).
The delay can be compensated with external signalling, just like in MP3 usually.


Thanks Menno.
Is there any calculation, I mean how do you get the number 1536 or whatever it is?
Also, didn't understand what do you mean by "compensated with external signalling".


HE AAC - extra samples at sample start or end

Reply #4
Isn't this standardised in AAC?

How sad.


IIRC early implementations (several years ago) handled this properly, didn't they? I'm sure I remember testing AAC encoding and decoding ~2000 and finding no delay.

Cheers,
David.

HE AAC - extra samples at sample start or end

Reply #5
Isn't this standardised in AAC?

Doesn't look like it. iTunes stores how much to trim in the tag iTunSMPB. FAAD is said to read the trim info the Nero encoder writes, but I haven't been able to figure out what that is, despite looking at the FAAD source code and asking one of the FAAD developers...

HE AAC - extra samples at sample start or end

Reply #6
Isn't this standardised in AAC?

Doesn't look like it. iTunes stores how much to trim in the tag iTunSMPB. FAAD is said to read the trim info the Nero encoder writes, but I haven't been able to figure out what that is, despite looking at the FAAD source code and asking one of the FAAD developers...


It's stored in the MP4/M4A data for that sample - offset and duration.  This is how I implemented gapless playback of FAAC stuff in Winamp and it worked for the few tracks I tested with.

HE AAC - extra samples at sample start or end

Reply #7
It's stored in the MP4/M4A data for that sample - offset and duration.  This is how I implemented gapless playback of FAAC stuff in Winamp and it worked for the few tracks I tested with.

Could you be a bit more specific, please? Do you mean mp4ff_get_sample_offset (based on ctts) and mp4ff_get_sample_duration (based on stts)? If so, I found this which suggests that ctts shouldn't be used for that purpose. And the main Nero AAC encoder developer said (in 2004) that future versions of the encoder would do it differently, though I have no idea how...

HE AAC - extra samples at sample start or end

Reply #8
Yeah ctts and stts should not be used, although current encoder still creates this I think. We use the chapter list.

HE AAC - extra samples at sample start or end

Reply #9
ISO addressed this problem in their 14496-24 Technical Report:

"ISO/IEC TR 14496-24:2008 describes the desired joint behavior of MPEG-4 Systems (MPEG-4 File Format) and MPEG-4 Audio codecs. It is desired that MPEG-4 Audio encoders and decoders permit finite length signals to be encoded to a file (particularly MPEG-4 files) and decoded again to obtain the identical signal, subject to codec distortions. This will allow the use of audio in systems implementations (particularly MPEG-4 Systems), perhaps with other media such as video, in a deterministic fashion. Most importantly, the decoded signal will have nothing extra at the beginning or missing at the end."

HE AAC - extra samples at sample start or end

Reply #10
Interesting, I will have to check that out. Looks like they want to use an edit-list, which sounds needlessly complex, but we'll see.

HE AAC - extra samples at sample start or end

Reply #11
ISO addressed this problem in their 14496-24 Technical Report:

"ISO/IEC TR 14496-24:2008 describes the desired joint behavior of MPEG-4 Systems (MPEG-4 File Format) and MPEG-4 Audio codecs. It is desired that MPEG-4 Audio encoders and decoders permit finite length signals to be encoded to a file (particularly MPEG-4 files) and decoded again to obtain the identical signal, subject to codec distortions. This will allow the use of audio in systems implementations (particularly MPEG-4 Systems), perhaps with other media such as video, in a deterministic fashion. Most importantly, the decoded signal will have nothing extra at the beginning or missing at the end."



Has this maybe been implemented in any AAC enc in the meantime?