Include missing durations in AC3/DTS formats.

This commit is contained in:
Oliver Woodman 2015-09-10 18:11:18 +01:00
parent e13e23e3e0
commit 59a789b340
2 changed files with 6 additions and 6 deletions

View File

@ -635,17 +635,17 @@ import java.util.List;
// TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
// TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent);
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, durationUs);
return;
} else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) {
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent);
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, durationUs);
return;
} else if ((atomType == Atom.TYPE_dtsc || atomType == Atom.TYPE_dtse
|| atomType == Atom.TYPE_dtsh || atomType == Atom.TYPE_dtsl)
&& childAtomType == Atom.TYPE_ddts) {
out.mediaFormat = MediaFormat.createAudioFormat(mimeType, MediaFormat.NO_VALUE,
MediaFormat.NO_VALUE, channelCount, sampleRate, null);
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null);
return;
}
childPosition += childAtomSize;

View File

@ -37,7 +37,7 @@ public final class Ac3Util {
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
* ETSI TS 102 366 Annex F.
*/
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data) {
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, long durationUs) {
// fscod (sample rate code)
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
int sampleRate = SAMPLE_RATES[fscod];
@ -49,14 +49,14 @@ public final class Ac3Util {
channelCount++;
}
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
MediaFormat.NO_VALUE, channelCount, sampleRate, null);
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null);
}
/**
* Returns the AC-3 format given {@code data} containing the EC3SpecificBox according to
* ETSI TS 102 366 Annex F.
*/
public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data) {
public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data, long durationUs) {
data.skipBytes(2); // Skip data_rate and num_ind_sub.
// Read only the first substream.