天天看點

AAC ADTS流解析總結

這裡列出Android裡将aac編碼器輸出的音頻幀加上ADTS頭的代碼:

+ int tmpFd;

+ tmpFd = ::open("/data/src.aac", O_WRONLY | O_APPEND );

+ if ( tmpFd < 0 ) {

+    LOGE("No dump decode file %s",strerror(errno));

+ }

+ else

+ {

+    unsigned char adts_hdr[7] = {0xff, 0xf9, 0x5c, 0x80, 0x00,0x1f, 0xfc};

+

+    adts_hdr[3] = 0x80 | ((mConfig->inputBufferCurrentLength >> 11) & 3);

+    adts_hdr[4] = (mConfig->inputBufferCurrentLength >> 3) & 0xff;

+    adts_hdr[5] = ((mConfig->inputBufferCurrentLength & 7) << 5) | 0x1f;

+    ::write(tmpFd,adts_hdr, 7);

+    ::write(tmpFd,(const char *)mConfig->pInputBuffer , mConfig->inputBufferCurrentLength);

+    ::close(tmpFd);

AAC參考知識:

<a href="http://blog.csdn.net/leixiaohua1020/article/details/11822537" target="_blank">http://blog.csdn.net/leixiaohua1020/article/details/11822537</a>

//aac header

<a href="http://yeyingxian.blog.163.com/blog/static/344712420134485613752/" target="_blank">http://yeyingxian.blog.163.com/blog/static/344712420134485613752/</a>

本文轉自 曾永剛 51CTO部落格,原文連結:http://blog.51cto.com/zyg0227/1952766

繼續閱讀