为 a2dp 解码 MPEG 2,4 AAC-LC LATM 比特流
Decode MPEG 2,4 AAC-LC LATM bitstream for a2dp
我正在尝试解码从 Apple IPhone 收到的用于蓝牙 A2DP 配置文件的比特流。
根据 Apple 的说法,结构应该是
我的样本比特流是
36 00 47 00 | 80 60 00 01 00 06 3c ab 00 00 00 00 |
47 fc 00 00 b0 90 80 03 00 20 20 66 00 01 98 00 0d e1 20 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c
前四个字节是L2CAP,接下来的12个是AVDTP。但我无法解码其余字节。请帮忙。
我看过定义 AudioMuxElement 的 ISO 14496-3,但我仍然无法将它与字节相关联。
"ISO/IEC 14496-3, Subpart 1: Main, Section 1.6: Interface to 14496-1" 是正确的地方看。
先看看AudioSyncStream()
:
AudioSyncStream()
{
while(nextbits()==0x2B7) // 11-bits
{
audioMuxLengthBytes; // 13-bit
AudioMuxElement(1); // proceed to decode AudioMuxElement
}
}
LATM 应以 11 位长同步字开头:syncword==(2B7)hex==(1010110111)bin
。您的流似乎不是这种情况:(47FC)hex==(0100011111111100)bin
,前 11 位是 (01000111111)bin
。
我能够解码 header 如下:
Use same stream config = 0 (1 bit)
StreamMuxConfig():
AudioMuxVersion = 1 (1 bit)
AudioMuxVersionA = 0 (1 bit)
LATM value Temp Bytes = 00 (2 bit)
Fullness value = 1111 1111 ( 8 Bit)
AllStreamsUseSameTimeFrame = 1 (1 bit)
numSubFrames = 000000 (6 bits)
num program = 0000 (4 bits)
num layer = 000 ( 3 bits)
use same config = 0 (1 bit)
Fill + other bits = 0000 1010 0 (9 bits)
AudioSpecificConfig():
Object Type (aac) = 00010 ( 5 bits)
Sample Type = 0100 ( 4 bits)
Channel = 0010 ( 4 bits)
GAS specific config = 000 (3 bits)
看来我使用的是旧版本的规范。要查找的 Spec 的正确版本是 ISO/IEC 14496-3:2005。 Apple 的蓝牙设计指南文档中也存在拼写错误(它指的是 non-existent doc 13818-3:2005 !)。
最近,我遇到了同样的问题。由于在一张纸上解码比特流不是很方便,我创建了一个简单的 decoder(用于调试目的)基于 ISO/IEC 14496-3 参考实现。
来自问题的正确解码流:
useSameStreamMux:1 = 0 => 0
audioMuxVersion:1 = 1 => 1
audioMuxVersionA:1 = 0 => 0
bytesForValue:2 = 00 => 0
valueTmp:8 = 11111111 => 255 (taraBufferFullness)
allStreamsSameTimeFraming:1 = 1 => 1
numSubFrames:6 = 000000 => 0
numProgram:4 = 0000 => 0
numLayer:3 = 000 => 0
bytesForValue:2 = 00 => 0
valueTmp:8 = 00010110 => 22 (ascLen)
audioObjectType:5 = 00010 => 2
samplingFrequencyIndex:4 = 0100 => 4
channelConfiguration:4 = 0010 => 2
frameLengthFlag:1 = 0 => 0
dependsOnCoreCoder:1 = 0 => 0
extensionFlag:1 = 0 => 0
fillBits:6 = 000000 => 0
frameLengthType:3 = 000 => 0
latmBufferFullness:8 = 11000000 => 192
otherDataPresent:1 = 0 => 0
crcCheckPresent:1 = 0 => 0
tmp:8 = 00100000 => 32 (MuxSlotLengthBytes)
payload:8 = 00100000 => 32
...
payload:8 = 00011100 => 28
byteAlign:0 = 0 => 0
我正在尝试解码从 Apple IPhone 收到的用于蓝牙 A2DP 配置文件的比特流。
根据 Apple 的说法,结构应该是
我的样本比特流是
36 00 47 00 | 80 60 00 01 00 06 3c ab 00 00 00 00 | 47 fc 00 00 b0 90 80 03 00 20 20 66 00 01 98 00 0d e1 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c
前四个字节是L2CAP,接下来的12个是AVDTP。但我无法解码其余字节。请帮忙。
我看过定义 AudioMuxElement 的 ISO 14496-3,但我仍然无法将它与字节相关联。
"ISO/IEC 14496-3, Subpart 1: Main, Section 1.6: Interface to 14496-1" 是正确的地方看。
先看看AudioSyncStream()
:
AudioSyncStream()
{
while(nextbits()==0x2B7) // 11-bits
{
audioMuxLengthBytes; // 13-bit
AudioMuxElement(1); // proceed to decode AudioMuxElement
}
}
LATM 应以 11 位长同步字开头:syncword==(2B7)hex==(1010110111)bin
。您的流似乎不是这种情况:(47FC)hex==(0100011111111100)bin
,前 11 位是 (01000111111)bin
。
我能够解码 header 如下:
Use same stream config = 0 (1 bit)
StreamMuxConfig():
AudioMuxVersion = 1 (1 bit)
AudioMuxVersionA = 0 (1 bit)
LATM value Temp Bytes = 00 (2 bit)
Fullness value = 1111 1111 ( 8 Bit)
AllStreamsUseSameTimeFrame = 1 (1 bit)
numSubFrames = 000000 (6 bits)
num program = 0000 (4 bits)
num layer = 000 ( 3 bits)
use same config = 0 (1 bit)
Fill + other bits = 0000 1010 0 (9 bits)
AudioSpecificConfig():
Object Type (aac) = 00010 ( 5 bits)
Sample Type = 0100 ( 4 bits)
Channel = 0010 ( 4 bits)
GAS specific config = 000 (3 bits)
看来我使用的是旧版本的规范。要查找的 Spec 的正确版本是 ISO/IEC 14496-3:2005。 Apple 的蓝牙设计指南文档中也存在拼写错误(它指的是 non-existent doc 13818-3:2005 !)。
最近,我遇到了同样的问题。由于在一张纸上解码比特流不是很方便,我创建了一个简单的 decoder(用于调试目的)基于 ISO/IEC 14496-3 参考实现。
来自问题的正确解码流:
useSameStreamMux:1 = 0 => 0
audioMuxVersion:1 = 1 => 1
audioMuxVersionA:1 = 0 => 0
bytesForValue:2 = 00 => 0
valueTmp:8 = 11111111 => 255 (taraBufferFullness)
allStreamsSameTimeFraming:1 = 1 => 1
numSubFrames:6 = 000000 => 0
numProgram:4 = 0000 => 0
numLayer:3 = 000 => 0
bytesForValue:2 = 00 => 0
valueTmp:8 = 00010110 => 22 (ascLen)
audioObjectType:5 = 00010 => 2
samplingFrequencyIndex:4 = 0100 => 4
channelConfiguration:4 = 0010 => 2
frameLengthFlag:1 = 0 => 0
dependsOnCoreCoder:1 = 0 => 0
extensionFlag:1 = 0 => 0
fillBits:6 = 000000 => 0
frameLengthType:3 = 000 => 0
latmBufferFullness:8 = 11000000 => 192
otherDataPresent:1 = 0 => 0
crcCheckPresent:1 = 0 => 0
tmp:8 = 00100000 => 32 (MuxSlotLengthBytes)
payload:8 = 00100000 => 32
...
payload:8 = 00011100 => 28
byteAlign:0 = 0 => 0