mirror of
https://github.com/androidx/media.git
synced 2025-05-14 19:19:58 +08:00
Include missing durations in AC3/DTS formats.
This commit is contained in:
parent
e13e23e3e0
commit
59a789b340
@ -635,17 +635,17 @@ import java.util.List;
|
|||||||
// TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
|
// TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
|
||||||
// TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
|
// TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
|
||||||
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
||||||
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent);
|
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, durationUs);
|
||||||
return;
|
return;
|
||||||
} else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) {
|
} else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) {
|
||||||
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
||||||
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent);
|
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, durationUs);
|
||||||
return;
|
return;
|
||||||
} else if ((atomType == Atom.TYPE_dtsc || atomType == Atom.TYPE_dtse
|
} else if ((atomType == Atom.TYPE_dtsc || atomType == Atom.TYPE_dtse
|
||||||
|| atomType == Atom.TYPE_dtsh || atomType == Atom.TYPE_dtsl)
|
|| atomType == Atom.TYPE_dtsh || atomType == Atom.TYPE_dtsl)
|
||||||
&& childAtomType == Atom.TYPE_ddts) {
|
&& childAtomType == Atom.TYPE_ddts) {
|
||||||
out.mediaFormat = MediaFormat.createAudioFormat(mimeType, MediaFormat.NO_VALUE,
|
out.mediaFormat = MediaFormat.createAudioFormat(mimeType, MediaFormat.NO_VALUE,
|
||||||
MediaFormat.NO_VALUE, channelCount, sampleRate, null);
|
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
childPosition += childAtomSize;
|
childPosition += childAtomSize;
|
||||||
|
@ -37,7 +37,7 @@ public final class Ac3Util {
|
|||||||
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
|
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
|
||||||
* ETSI TS 102 366 Annex F.
|
* ETSI TS 102 366 Annex F.
|
||||||
*/
|
*/
|
||||||
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data) {
|
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, long durationUs) {
|
||||||
// fscod (sample rate code)
|
// fscod (sample rate code)
|
||||||
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
|
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
|
||||||
int sampleRate = SAMPLE_RATES[fscod];
|
int sampleRate = SAMPLE_RATES[fscod];
|
||||||
@ -49,14 +49,14 @@ public final class Ac3Util {
|
|||||||
channelCount++;
|
channelCount++;
|
||||||
}
|
}
|
||||||
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
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
|
* Returns the AC-3 format given {@code data} containing the EC3SpecificBox according to
|
||||||
* ETSI TS 102 366 Annex F.
|
* 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.
|
data.skipBytes(2); // Skip data_rate and num_ind_sub.
|
||||||
|
|
||||||
// Read only the first substream.
|
// Read only the first substream.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user