[b]IMPORTANT ANNOUNCEMENT !!!!
DONT USE HE-AAC IN MKV FILES UNTIL WE COULD UPDATE THE TOOLS !!!![/b]
It was decided today that, different to first opinions, it will be necessary to tag HE-AAC audio tracks in matroska files separately. This became necessary due to a specific 'feature' of M$ DirectShow, still the most used playback platform for all kinds of media files, but mainly for video files.
DirectShow requires that the actual output sampling rate of an audio track is known before building/creating the playback graph. Unfortunately, a HE-AAC ( AAC SBR ) track is marked as half sampling rate only, to allow playback on non-SBR capable decoders/players. The track will be played, but with high frequency information being completey cut off, as the SBR info in the track will be skipped.
For DirectShow playback of matroska files this is giving us a lot of problems, because you actually learn if an AAC track is SBR or not, once you have decoded the first channel element ( IIRC from what menno told us ). This is impossible to do before you have actually built the playback graph, and then with an already incorrect sampling rate, preventing you from using the high frequency sound information. A possible workaround here is to assume all AAC is HE-AAC, and to set output sampling rate from the parser filter always by factor 2 higher ( if its set as 22.050 KHz, you output 44.1 KHz ). Once you decoded the first element, and you find its NOT SBR AAC, you then have to artificially upsample the output sampling rate. While this is a good solution at first sight, it will turn into a major problem if in future 96 KHz input was feed into HE AAC encoders, resulting in a 48 KHz sampling rate reported in the AAC header. In this case you will also have to double the sampling rate always, up to 96 KHz, and thus leave the files unplayable on most systems when soundcards dont support this input sampling rates, or again all the SBR information was lost during playback.
For this reason, we decided to NOT follow menno's recommendation for using the same codec ID for all AAC tracks, and leave SBR detection to the decoder, but now we will try to find out for every track if it actually contains SBR or not. To indicate in the MKV file that AAC is SBR, we will add a new EBML element called KaxOutputSamplingRate , and this will become a mandatory element to read before building DirectShow graphs ( it can be used the very same with MP3Pro and other, future SBR implementations ). To find out about SBR we have 2 ways :
If AAC is coming from MP4 container, its easy, as there are 5 bytes in the mp4 AudioSpecificConfig element that will tell us
If source is an AAC track, we will allow the user to set the HE AAC flag manually, or scan the file for SBR specific patterns in the bitstream
There will be a new way to use HE-AAC in matroska, please dont create those files with released tools now !