Mpeg1 Audio: Support for iso-bmff output (#780)

Issue #779.
This commit is contained in:
Zajcev Evgeny 2020-06-07 03:18:00 +03:00 committed by GitHub
parent f0107beb9e
commit 8913dbda85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 2 deletions

View File

@ -40,7 +40,7 @@ Shaka Packager supports:
| VP9 | I / O | I / O | - | - | - |
| AV1 | I / O | I / O | - | - | - |
| AAC | I / O | - | I / O | I | O |
| MP3 | - | - | I / O | - | O |
| MP3 | O | - | I / O | - | O |
| Dolby AC3 | I / O | - | I / O | - | O |
| Dolby EAC3 | I / O | - | O | - | O |
| DTS | I / O | - | - | - | - |

View File

@ -167,13 +167,17 @@ void DecoderConfigDescriptor::WriteInternal(BufferWriter* writer) {
writer->AppendNBytes(buffer_size_db_, 3);
writer->AppendInt(max_bitrate_);
writer->AppendInt(avg_bitrate_);
decoder_specific_info_descriptor_.Write(writer);
if (!decoder_specific_info_descriptor_.data().empty())
decoder_specific_info_descriptor_.Write(writer);
}
size_t DecoderConfigDescriptor::ComputeDataSize() {
// object_type (1 byte), stream_type (1 byte), decoding_buffer_size (3 bytes),
// max_bitrate (4 bytes), avg_bitrate (4 bytes).
const size_t data_size_without_children = 1 + 1 + 3 + 4 + 4;
if (decoder_specific_info_descriptor_.data().empty())
return data_size_without_children;
return data_size_without_children +
decoder_specific_info_descriptor_.ComputeSize();
}

View File

@ -22,6 +22,8 @@ enum class ObjectType : uint8_t {
kForbidden = 0,
kISO_14496_3 = 0x40, // MPEG4 AAC
kISO_13818_7_AAC_LC = 0x67, // MPEG2 AAC-LC
kISO_13818_3_MPEG1 = 0x69, // MPEG1 ISO/IEC 13818-3, 16,22.05,24kHz
kISO_11172_3_MPEG1 = 0x6B, // MPEG1 ISO/IEC 11172-3, 32,44.1,48kHz
kDTSC = 0xA9, // DTS Coherent Acoustics audio
kDTSE = 0xAC, // DTS Express low bit rate audio
kDTSH = 0xAA, // DTS-HD High Resolution Audio

View File

@ -67,6 +67,7 @@ FourCC CodecToFourCC(Codec codec, H26xStreamFormat h26x_stream_format) {
case kCodecVP9:
return FOURCC_vp09;
case kCodecAAC:
case kCodecMP3:
return FOURCC_mp4a;
case kCodecAC3:
return FOURCC_ac_3;
@ -487,6 +488,25 @@ bool MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info,
case kCodecFlac:
audio.dfla.data = audio_info->codec_config();
break;
case kCodecMP3: {
audio.esds.es_descriptor.set_esid(track_id);
DecoderConfigDescriptor* decoder_config =
audio.esds.es_descriptor.mutable_decoder_config_descriptor();
uint32_t samplerate = audio_info->sampling_frequency();
if (samplerate < 32000)
decoder_config->set_object_type(ObjectType::kISO_13818_3_MPEG1);
else
decoder_config->set_object_type(ObjectType::kISO_11172_3_MPEG1);
decoder_config->set_max_bitrate(audio_info->max_bitrate());
decoder_config->set_avg_bitrate(audio_info->avg_bitrate());
// For values of DecoderConfigDescriptor.objectTypeIndication
// that refer to streams complying with ISO/IEC 11172-3 or
// ISO/IEC 13818-3 the decoder specific information is empty
// since all necessary data is contained in the bitstream frames
// itself.
break;
}
case kCodecOpus:
audio.dops.opus_identification_header = audio_info->codec_config();
break;