Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

AAC decoder IPP 6.1

scandinaf
Beginner
1,054 Views
Hi to all!
I have Axis camera that provides audio data through network. The format of this data is AAC LC 8000 Hz, 32 kbps. I tried to find an example how to initialize AACDecoder and how to decode frames but I failed. It seems that there is no good example how to do this. And also I have a lot of questions about AAC decoder (e.g. what is the minimal frame size? ).
Could you help me? I think that having good sample may solve my problems.
Thanks.
0 Kudos
14 Replies
Chao_Y_Intel
Moderator
1,054 Views

Hi,

Have you found the example code in UMC manual?

\audio-video-codecs\doc\umc-manual.pdf

Example 5-1 AACDecoder Initialization

and Example 5-2 AACDecoder Usage.

provides the example code on AAC decoder usage.

Thanks,

Chao

0 Kudos
scandinaf
Beginner
1,054 Views
Yes, I've found these examples. But they are not full and I still have questions.

I know that Axis Camera uses AAC LC (MPEG-4 Audio). I need to know:

1) Size of input buffer for AACDecoder->GetFrame() [1024 bytes ??? ] - it always returns me Bad Stream error code.
2) Do I need to use MP4Splitter in order to read frames from the stream?
3) How to initialize MP4Splitter correctly if it is needed.

Actually I could not say that examples are clear enough because sometimes it's difficult to understand purpose of specified variables.
0 Kudos
Chao_Y_Intel
Moderator
1,054 Views


Hi,

Is the input data raw AAC audio data, or the AAC data in the MP4 container? If it is in the MP4 container, it needs the MP4Splitter.

Maybe you can attach one audio data. That will be helpful to check the problem.

Thanks,

Chao

0 Kudos
scandinaf
Beginner
1,054 Views
Hi,

It seems that it is raw AAC audio data. I attached file that contains audio data that I receive from Axis camera (aac_buffer). Maybe it will be helpful for you in order to understand what kind of data I receive and how to deal with it.

But what I can see now is that there is some marker that probably shows where the next frame begins. I mean this set of bytes: 0x00 0x10 0x0F ... 0x01. I am really looking forward your answer.

0 Kudos
scandinaf
Beginner
1,054 Views
Oh, I forgot to say what I know about the format of data: AAC LC 8000Hz, 32kbps, mono(?), 16 bits per sample (?).

[bash]unsigned char data[2];
data[0] = 0x15; /* 5bits: 00010 - LC; 4 bits: 1011 - sample rate index (11 --- 8000Hz)
data[1] = 0x88;    4bits: 0001 - 1 channel (front-center); 1bit: 0 - 1024 frame size;
                   1bit: 0 - depends on core; 1bit: 0 - ext. flag */

UMC::MediaData codecData;
codecData.SetBufferPointer(&data[0],2);
codecData.SetDataSize(2);
		
// where mIppParams is AACDecoderParams
mIppParams.m_info_in.sample_frequency = 8000; 
mIppParams.m_info_in.bitrate = 32000;
mIppParams.m_info_in.bitPerSample = 16;
mIppParams.m_info_in.channels = 1;
mIppParams.m_info_in.stream_type = UMC::AAC_MPEG4_STREAM;
mIppParams.m_pData = &codecData;
mIppParams.profile = AAC_PROFILE_LC;	  
	  
// returns UMC_OK
UMC::Status status = mIppDecoder.Init(&mIppParams);[/bash]

Then I try to pass 1024 (2048, etc.) bytes of audio data (I attached file with audio data in the previous message) to the decoder and it returns OK or BAD_STREAM error code. In my case decoded data is noise.

0 Kudos
scandinaf
Beginner
1,054 Views
I reloaded file that I attached in the previous message (I suppose there was a problem with downloading that file).
0 Kudos
scandinaf
Beginner
1,054 Views
I solved the problem :)

1) I obtaine raw AAC MPEG-4 samples.
2) RTP protocol is used for transmission.
3) Transmission mode: AAC-hbr.
4) RFC 3640 explaines detailes.

Each RTP packet in AAC-hbr mode contains:
1) Access unit headers length field - 2 bytes - size of AU-headers in bits (in my case 0x10 -> 16 -> 2 bytes)
2) Set of AU-headers - Each header has size 2 bytes for AAC-hbr mode.
3) Access unit (AU) - AAC frame(s)

In my case I have 1 AU header + 1 AU per one RTP packet. Thus, I had to remove first 4 bytes of RTP packet payload and pass the rest (AU) to the decoder.
0 Kudos
Chao_Y_Intel
Moderator
1,054 Views

Hello,

Glad to know it works now. Some more comments from our AAC experts on raw AAC data support:

UMC AAC decoder supports ADIF format files only 1 header in the beginning of the stream (to set sample rate, stream type) and then raw AAC data.

Thanks,

Chao

0 Kudos
ltochinski
Beginner
1,054 Views
Hi,
I have the same configuration - AXIS device and AAC stream. I use live555 RTP library.
Do you have sample how to use UMC AAC decoder to decode it?
0 Kudos
Chao_Y_Intel
Moderator
1,054 Views

Hello,

I think scandinaf were using the sample in the manual (audio-video-codecs\doc\umc-manual.pdf)

Example 5-1 AACDecoder Initialization

and Example 5-2 AACDecoder Usage.

but, please note UMC AAC decoder supports ADIF format files, and RTP package payload need to be removed before pass the data to AAC decoders.

Thanks,
Chao

0 Kudos
ltochinski
Beginner
1,054 Views
I've got it working
I have 16kHz 32lbps 1 channel sound
SDP from AXIS looks like
m=audio 0 RTP/AVP 97
b=AS:32
a=control:trackID=2
a=rtpmap:97 mpeg4-generic/16000/1
a=fmtp:97 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1408; sizeLength=13; indexLength=3; indexDeltaLength=3; profile=1; bitrate=32000;
Then I took scandinaf's code above and modify it a little bit
[cpp]  // initialization
  // http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio
  unsigned char data[2];  
      data[0] = 0x14; // 5bits: 00010 - LC; 4 bits: 1000 - sample rate index (8 --- 16000Hz)  
      data[1] = 0x08; //   4bits: 0001 - 1 channel (front-center); 1bit: 0 - 1024 frame size;  
                      //   1bit: 0 - depends on core; 1bit: 0 - ext. flag */  
  
      UMC::MediaData codecData;  
      codecData.SetBufferPointer(&data[0],2);  
      codecData.SetDataSize(2);  
                
      UMC::AACDecoderParams params;      
      params.m_info_in.stream_type = UMC::AAC_MPEG4_STREAM;  
      params.m_pData = &codecData;  
      params.ModeDecodeHEAACprofile = HEAAC_LP_MODE;
      params.ModeDwnsmplHEAACprofile = HEAAC_DWNSMPL_OFF;
      params.flag_SBR_support_lev = SBR_DISABLE;
      // returns UMC_OK  
      UMC::Status status = decoder.Init(&params);  

      decoder.GetInfo(&params);
      Ipp32s needSize = params.m_SuggestedOutputSize;

      // decoding
      // live555 takes care about AU Header removing from data
      UMC::MediaData in;
      status = in.SetBufferPointer((Ipp8u *)data, i_size);
      status = in.SetDataSize(i_size);
      
      UMC::AudioData out;
      status = out.Alloc(needSize);
      status = decoder.GetFrame(&in,&out);
[/cpp]
My impression from playing with UMC - you need more samples how to use UMC classes.
In my case I would love if you give me a clue in manual that for RTP I need to set UMC::AAC_MPEG4_STREAM... It is not obvious as described in your current documentation.
0 Kudos
Chao_Y_Intel
Moderator
1,054 Views


Hi,

Thanks for your update. I agree we could have some improvement on the document in this part. I willcreate an internal request on adding information on this RTP stream part.

Thanks,
Chao
0 Kudos
michael_weaver
Beginner
1,054 Views
Hi,

I'm having trouble getting the decoder working for a raw aac stream, trying to use the code above.

My config code is 0x1190. 2 channels, 48000Hz,. When I get to the call to decoder.GetInfo this returns an error code 3 (decoder not ready). Which I'd probably expect since I have't yet decoded a frame, but does this mean this call in the above example was also returning this error?

Then the value in params.m_SuggestedOutputSize is 40960 which seems very big for one frame of aac (1024 pcm samples)?

Then when I make the call to decoder.GetFrame I get an error -882 (invalid stream), does anyone have any ideas why this results in an error?
0 Kudos
michael_weaver
Beginner
1,054 Views
In fact I've just tried running the code above, with i_size = 2 and I still get a -882 error when calling GetFrame. Can anyone help?

Thanks,
Michael
0 Kudos
Reply