3

How to construct CSD data from ADTS header? I can create ADTS header for CSD data, but how to do the reverse?

/* function to construct ADTS header from CSD
 * header_info - contains CSD
 * frameLength - total frame size */    
void addHeaderADTS(uint8_t header_info[], uint32_t frameLength) {

int profile = (csd_data[0] >> 3) & 0x1F;
int frequency_idx = ((csd_data[0] & 0x7) << 1) | ((csd_data[1] >> 7) & 0x1);
int channels = (csd_data[1] >> 3) & 0xF;

header_info[0] = 0xFF;
header_info[1] = 0xF1;
header_info[2] = (((profile - 1) << 6) + (frequency_idx << 2) + (channels >> 2));
header_info[3] = (((channels & 3) << 6) + (frameLength >> 11));
header_info[4] = ((frameLength & 0x7FF) >> 3);
header_info[5] = (((frameLength & 7) << 5) + 0x1F);
header_info[6] = 0xFC;
return;

}

  • Give us the CSD data? What exactly is it? – Danijel Nov 28 '15 at 13:36
  • Codec Specific Data (CSD) csd_data[0] =0x13, csd_data[1]=0x0x90. To understand csd refer http://wiki.multimedia.cx/index.php?title=Understanding_AAC&redirect=no http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio – Arunraj Shanmugam Nov 30 '15 at 05:43
  • There is no CSD on that wiki page. There is also no csd_data on that wiki page. – Danijel Nov 30 '15 at 09:51
  • my CSD consists of 2 bytes, that wiki page shows how to read these two bytes (bitpacking). These csd data constructed by Android. – Arunraj Shanmugam Nov 30 '15 at 14:19
  • Well, there's your first step. Find out what CSD really is and where does it come from. I don't see how you can reconstruct something from ADTS when you don't even know what it is. – Danijel Nov 30 '15 at 20:22
  • Found. CSD data constructed using MakeAACCodecSpecificData function in [avc_utils.cpp] (https://android.googlesource.com/platform/frameworks/av/+/master/media/libstagefright/avc_utils.cpp) – Arunraj Shanmugam Dec 01 '15 at 06:08
  • It's hardly possible to extract it from the source code. Instead, you should look at the AAC or MP4 ISO specification, or wherever the CSD is defined. Start here maybe: "ISO/IEC 14496-3". – Danijel Dec 01 '15 at 10:54

1 Answers1

2

Found. CSD data constructed using MakeAACCodecSpecificData function in avc_utils.cpp