7 #include "packager/media/codecs/ac3_audio_util.h" 9 #include "packager/base/strings/string_number_conversions.h" 10 #include "packager/media/base/bit_reader.h" 11 #include "packager/media/base/rcheck.h" 19 const uint8_t kAc3NumChannelsTable[] = {2, 1, 2, 3, 3, 4, 4, 5};
21 bool ExtractAc3Data(
const std::vector<uint8_t>& ac3_data,
22 uint8_t* audio_coding_mode,
23 bool* lfe_channel_on) {
24 BitReader bit_reader(ac3_data.data(), ac3_data.size());
32 RCHECK(bit_reader.SkipBits(10));
33 RCHECK(bit_reader.ReadBits(3, audio_coding_mode));
34 RCHECK(bit_reader.ReadBits(1, lfe_channel_on));
40 size_t GetAc3NumChannels(
const std::vector<uint8_t>& ac3_data) {
41 uint8_t audio_coding_mode;
43 if (!ExtractAc3Data(ac3_data, &audio_coding_mode, &lfe_channel_on)) {
44 LOG(WARNING) <<
"Seeing invalid AC3 data: " 45 << base::HexEncode(ac3_data.data(), ac3_data.size());
48 return kAc3NumChannelsTable[audio_coding_mode] + (lfe_channel_on ? 1 : 0);
All the methods that are virtual are virtual for mocking.