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: Doubt in HE-AACv2 header. (Read 3937 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Doubt in HE-AACv2 header.

Hai all,

Currently I am working on HE-AACv2 (LC-AAC + SBR + PS) code.

For this type of streams the input for PS Decoding module is mono and the output of PS Decoding module is stereo.

Currently in the code I allocate the output buffer memory based on the number of channels extracted from the Unpack_ADTS_header function. Then, if PS is present in the first frame, I doubled the output buffer before writing the data in the output file.

For the streams in which from the first frame itself, PS Data is present, then no issue.

I have one stream. It has totally 106 frames. The first 53 frames dont have PS data. So if i check 'whether PS is present in the first frame?', it says 'No'. So I allocate single channel buffer. But from 54th frame onwards all the frames contain PS Data and PS_Present flag. Since I write the wave header and allocate the output buffer based on the information extracted from the very first frame, I write the output file as mono and the right channel data coming from 54th frame is getting treated as consecutive left channel data.

Result?
Breaks/ clipping/ Boosted noise floor in the second half of the output wave file.

Unfortunately, this stream is ISO stream. I can't skip it from testing. 

In the spec (ISO_IEC_14496-3_2001_Amd_2_2004), they mention like this.(section 8.2.1)

//
Frame
Basic unit that can be decoded on itself (file header information is required for general decoder settings).
//

My doubt :

1.Is there any file header (apart from frame headers) in the starting of the bitstream, to indicate that 'this stream is PS enabled stream.' So i can allocate the required buffer size before writing the first frame output.

2. Is it correct, that in a PS stream some frames have PS enabled and some not.

Thanking You. Please help me, It's urgent..!!

Regards,
Vasanth.
Prove the worth of being You.

Doubt in HE-AACv2 header.

Reply #1
I am no expert in the field, but these formats were thought as streams, not as files. I mean that a stream does not necessarily need to maintain each value constant.

Since it is obvious that a file cannot be mono and stereo at the same time, i believe the correct approach is to start over with stereo after the first PS frame is received (like a player would do, when playing a live stream).

I believe other players have opted to play all streams as stereo, even if it starts as mono.

Doubt in HE-AACv2 header.

Reply #2

I believe other players have opted to play all streams as stereo, even if it starts as mono.

Players have not opted for this, it's a requirement in the MPEG-4 standard. So it's also the only solution.

 

Doubt in HE-AACv2 header.

Reply #3

I believe other players have opted to play all streams as stereo, even if it starts as mono.

Players have not opted for this, it's a requirement in the MPEG-4 standard. So it's also the only solution.


Hai all,

Thanks for your kind replies.

1. I found that the indication of 'this is the PS Stream' is present in mp4 container. I tested the mp4 stripped mpeg2 stream. Thats why i struggled to find the 'PS presence' information. (But i doubt how winamp finds the PS presnece from the mpeg2 stream itself..?)

2. For this query, i understood one thing. If a stream is PS enabled, it is not necessary that all the frames should have PS data. Because, if in a particular frame, the left and right channel contents are exactly same, then derving IID, ICC, IPD, and OPD is not required, right? We can simply copy the left data and paste in the right channel in the decoder. So for those frames PS data wont present. For the other frames, where left and right channel data are differed in intensity and/or phase parameters, then applying PS is more efficient.

I understood this explanation from the following description.

//
A conformant HE-AAC v2 profile decoder that receives a PS enhanced data stream shall output the mono signal in the two output channels until a first ps_data() element with enable_ps_header==1 is received, ensuring that the PS data can be decoded correctly.
//

ref :: http://www.itscj.ipsj.or.jp/sc29/open/29view/29n6681t.doc

so, i simply do L->R if PS data is not present and if present, allow the PS to do that work.

Thanks.
Prove the worth of being You.