Add direct passthrough support for DTS audio.
This commit is contained in:
parent
418b2a5f1b
commit
b73d2cc736
@ -595,6 +595,10 @@ public final class MimeTypes {
|
||||
return C.ENCODING_DTS;
|
||||
case MimeTypes.AUDIO_DTS_HD:
|
||||
return C.ENCODING_DTS_HD;
|
||||
case MimeTypes.AUDIO_DTS_EXPRESS:
|
||||
return C.ENCODING_DTS; // This should be ENCODING_DTS_HD when IC platforms support it.
|
||||
case MimeTypes.AUDIO_DTS_X:
|
||||
return C.ENCODING_DTS; // This should be ENCODING_DTS_UHD_P2 when IC platforms support it.
|
||||
case MimeTypes.AUDIO_TRUEHD:
|
||||
return C.ENCODING_DOLBY_TRUEHD;
|
||||
case MimeTypes.AUDIO_OPUS:
|
||||
|
@ -1884,6 +1884,14 @@ public final class Util {
|
||||
return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
|
||||
case 8:
|
||||
return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
||||
case 10:
|
||||
if (Util.SDK_INT > 31) {
|
||||
return AudioFormat.CHANNEL_OUT_5POINT1POINT4;
|
||||
} else {
|
||||
// This is used by DTS:X P2 with Direct Passthrough Playback.
|
||||
// Specifying the audio format as 7.1 for 10 channels does not affect the playback.
|
||||
return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
||||
}
|
||||
case 12:
|
||||
return AudioFormat.CHANNEL_OUT_7POINT1POINT4;
|
||||
default:
|
||||
|
@ -59,8 +59,9 @@ public final class AudioCapabilities {
|
||||
@SuppressWarnings("InlinedApi")
|
||||
private static final AudioCapabilities EXTERNAL_SURROUND_SOUND_CAPABILITIES =
|
||||
new AudioCapabilities(
|
||||
new int[] {
|
||||
AudioFormat.ENCODING_PCM_16BIT, AudioFormat.ENCODING_AC3, AudioFormat.ENCODING_E_AC3
|
||||
new int[]{
|
||||
AudioFormat.ENCODING_PCM_16BIT, AudioFormat.ENCODING_AC3, AudioFormat.ENCODING_E_AC3,
|
||||
AudioFormat.ENCODING_DTS, AudioFormat.ENCODING_DTS_HD
|
||||
},
|
||||
DEFAULT_MAX_CHANNEL_COUNT);
|
||||
|
||||
@ -220,7 +221,13 @@ public final class AudioCapabilities {
|
||||
channelCount = getMaxSupportedChannelCountForPassthrough(encoding, sampleRate);
|
||||
} else {
|
||||
channelCount = format.channelCount;
|
||||
if (channelCount > maxChannelCount) {
|
||||
if (format.sampleMimeType == MimeTypes.AUDIO_DTS_X) {
|
||||
if (channelCount > 10) {
|
||||
// To fix wrong reporting from device. ChannelCount is reported as 8 for DTS:X P2
|
||||
// on some devices.
|
||||
return null;
|
||||
}
|
||||
} else if (channelCount > maxChannelCount) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ public final class DtsUtil {
|
||||
private static final int SYNC_VALUE_14B_BE = 0x1FFFE800;
|
||||
private static final int SYNC_VALUE_LE = 0xFE7F0180;
|
||||
private static final int SYNC_VALUE_14B_LE = 0xFF1F00E8;
|
||||
private static final int SYNC_EXT_SUB_LE = 0x25205864;
|
||||
private static final int SYNC_FTOC_LE = 0xF21B4140;
|
||||
private static final int SYNC_FTOC_NON_SYNC_LE = 0xE842C471;
|
||||
private static final byte FIRST_BYTE_BE = (byte) (SYNC_VALUE_BE >>> 24);
|
||||
private static final byte FIRST_BYTE_14B_BE = (byte) (SYNC_VALUE_14B_BE >>> 24);
|
||||
private static final byte FIRST_BYTE_LE = (byte) (SYNC_VALUE_LE >>> 24);
|
||||
@ -149,6 +152,19 @@ public final class DtsUtil {
|
||||
* @return The number of audio samples represented by the syncframe.
|
||||
*/
|
||||
public static int parseDtsAudioSampleCount(ByteBuffer buffer) {
|
||||
|
||||
// Check for sync or non sync word for DTS:X Profile 2.
|
||||
// DTS:X Profile 2's FrameSize = 1024.
|
||||
if ((buffer.getInt(0) == SYNC_FTOC_LE) ||
|
||||
(buffer.getInt(0) == SYNC_FTOC_NON_SYNC_LE)) {
|
||||
return 1024;
|
||||
}
|
||||
// Check for sync word for DTS Express.
|
||||
// DTS Express's FrameSize = 4096.
|
||||
else if (buffer.getInt(0) == SYNC_EXT_SUB_LE) {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
// See ETSI TS 102 114 subsection 5.4.1.
|
||||
int position = buffer.position();
|
||||
int nblks;
|
||||
|
Loading…
x
Reference in New Issue
Block a user