From f6c02e629d95e6164d330244ce449b752493064b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Cantar=C3=ADn?= Date: Mon, 5 Apr 2021 02:47:31 -0300 Subject: [PATCH] Generate object type properly for MPEG-1 audio Fix #905. --- packager/media/formats/mp2t/mpeg1_header.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packager/media/formats/mp2t/mpeg1_header.cc b/packager/media/formats/mp2t/mpeg1_header.cc index 7ffb89b458..e335d5b760 100644 --- a/packager/media/formats/mp2t/mpeg1_header.cc +++ b/packager/media/formats/mp2t/mpeg1_header.cc @@ -196,7 +196,16 @@ void Mpeg1Header::GetAudioSpecificConfig(std::vector* buffer) const { DCHECK(buffer); buffer->clear(); 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); /* * NOTE: Number of channels matches channel_configuration index,