Generate object type properly for MPEG-1 audio

Fix #905.
This commit is contained in:
Daniel Cantarín 2021-04-05 02:47:31 -03:00 committed by GitHub
parent d48bf0f48e
commit f6c02e629d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -196,7 +196,16 @@ void Mpeg1Header::GetAudioSpecificConfig(std::vector<uint8_t>* buffer) const {
DCHECK(buffer); DCHECK(buffer);
buffer->clear(); buffer->clear();
BitWriter config(buffer); BitWriter config(buffer);
config.WriteBits(GetObjectType(), 5);
// ISO/IEC 14496:3 Table 1.16 Syntax of GetAudioObjetType()
auto object_type = GetObjectType();
if (object_type <= 31) {
config.WriteBits(object_type, 5);
} else {
config.WriteBits(31, 5);
config.WriteBits(object_type - 32, 6);
}
config.WriteBits(cft_idx, 4); config.WriteBits(cft_idx, 4);
/* /*
* NOTE: Number of channels matches channel_configuration index, * NOTE: Number of channels matches channel_configuration index,