本文整理汇总了C++中BitArray::ReadFromBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ BitArray::ReadFromBuffer方法的具体用法?C++ BitArray::ReadFromBuffer怎么用?C++ BitArray::ReadFromBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitArray
的用法示例。
在下文中一共展示了BitArray::ReadFromBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool _AUDIO_AAC::Init(const uint8_t *pBuffer, uint32_t length) {
Clear();
//http://wiki.multimedia.cx/index.php?title=MP4A#Audio_Specific_Config
if (length < 2) {
FATAL("Invalid length: %u", length);
return false;
}
//1. Prepare the bit array
BitArray ba;
ba.ReadFromBuffer(pBuffer, length);
//2. Read the audio object type
_audioObjectType = ba.ReadBits<uint8_t > (5);
if ((_audioObjectType != 1)
&& (_audioObjectType != 2)
&& (_audioObjectType != 3)
&& (_audioObjectType != 4)
&& (_audioObjectType != 6)
&& (_audioObjectType != 17)
&& (_audioObjectType != 19)
&& (_audioObjectType != 20)
&& (_audioObjectType != 23)
&& (_audioObjectType != 39)) {
FATAL("Invalid _audioObjectType: %hhu", _audioObjectType);
return false;
}
//3. Read the sample rate index
_sampleRateIndex = ba.ReadBits<uint8_t > (4);
if ((_sampleRateIndex == 13)
|| (_sampleRateIndex == 14)) {
FATAL("Invalid sample rate: %hhu", _sampleRateIndex);
return false;
}
if (_sampleRateIndex == 15) {
if (length < 5) {
FATAL("Invalid length: %u", length);
return false;
}
_sampleRate = ba.ReadBits<uint32_t > (24);
} else {
uint32_t rates[] = {
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000,
12000, 11025, 8000, 7350
};
_sampleRate = rates[_sampleRateIndex];
}
//4. read the channel configuration index
_channelConfigurationIndex = ba.ReadBits<uint8_t > (4);
if ((_channelConfigurationIndex == 0)
|| (_channelConfigurationIndex >= 8)) {
FATAL("Invalid _channelConfigurationIndex: %hhu", _channelConfigurationIndex);
return false;
}
_pAAC = new uint8_t[length];
memcpy(_pAAC, pBuffer, length);
_aacLength = length;
return true;
}