Merge "Audio: Add Dolby MAT format"

This commit is contained in:
TreeHugger Robot
2018-11-05 18:32:18 +00:00
committed by Android (Google) Code Review
3 changed files with 114 additions and 88 deletions

View File

@@ -22714,6 +22714,7 @@ package android.media {
field public static final int ENCODING_AC3 = 5; // 0x5
field public static final int ENCODING_AC4 = 17; // 0x11
field public static final int ENCODING_DEFAULT = 1; // 0x1
field public static final int ENCODING_DOLBY_MAT = 19; // 0x13
field public static final int ENCODING_DOLBY_TRUEHD = 14; // 0xe
field public static final int ENCODING_DTS = 7; // 0x7
field public static final int ENCODING_DTS_HD = 8; // 0x8

View File

@@ -37,6 +37,7 @@
#define ENCODING_AAC_XHE 16
#define ENCODING_AC4 17
#define ENCODING_E_AC3_JOC 18
#define ENCODING_DOLBY_MAT 19
#define ENCODING_INVALID 0
#define ENCODING_DEFAULT 1
@@ -85,6 +86,8 @@ static inline audio_format_t audioFormatToNative(int audioFormat)
return AUDIO_FORMAT_E_AC3_JOC;
case ENCODING_DEFAULT:
return AUDIO_FORMAT_DEFAULT;
case ENCODING_DOLBY_MAT:
return AUDIO_FORMAT_MAT;
default:
return AUDIO_FORMAT_INVALID;
}
@@ -134,6 +137,11 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat)
return ENCODING_AC4;
case AUDIO_FORMAT_E_AC3_JOC:
return ENCODING_E_AC3_JOC;
case AUDIO_FORMAT_MAT:
case AUDIO_FORMAT_MAT_1_0:
case AUDIO_FORMAT_MAT_2_0:
case AUDIO_FORMAT_MAT_2_1:
return ENCODING_DOLBY_MAT;
case AUDIO_FORMAT_DEFAULT:
return ENCODING_DEFAULT;
default:

View File

@@ -273,6 +273,11 @@ public final class AudioFormat implements Parcelable {
* supports {@link #ENCODING_E_AC3} but not {@link #ENCODING_E_AC3_JOC}.
**/
public static final int ENCODING_E_AC3_JOC = 18;
/** Audio data format: Dolby MAT (Metadata-enhanced Audio Transmission)
* Dolby MAT bitstreams are used to transmit Dolby TrueHD, channel-based PCM, or PCM with
* metadata (object audio) over HDMI (e.g. Dolby Atmos content).
**/
public static final int ENCODING_DOLBY_MAT = 19;
/** @hide */
public static String toLogFriendlyEncoding(int enc) {
@@ -313,6 +318,8 @@ public final class AudioFormat implements Parcelable {
return "ENCODING_AC4";
case ENCODING_E_AC3_JOC:
return "ENCODING_E_AC3_JOC";
case ENCODING_DOLBY_MAT:
return "ENCODING_DOLBY_MAT";
default :
return "invalid encoding " + enc;
}
@@ -520,26 +527,27 @@ public final class AudioFormat implements Parcelable {
public static boolean isValidEncoding(int audioFormat)
{
switch (audioFormat) {
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
return true;
default:
return false;
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
case ENCODING_DOLBY_MAT:
return true;
default:
return false;
}
}
@@ -547,26 +555,27 @@ public final class AudioFormat implements Parcelable {
public static boolean isPublicEncoding(int audioFormat)
{
switch (audioFormat) {
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
return true;
default:
return false;
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
case ENCODING_DOLBY_MAT:
return true;
default:
return false;
}
}
@@ -575,29 +584,30 @@ public final class AudioFormat implements Parcelable {
public static boolean isEncodingLinearPcm(int audioFormat)
{
switch (audioFormat) {
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_DEFAULT:
return true;
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937: // wrapped in PCM but compressed
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
return false;
case ENCODING_INVALID:
default:
throw new IllegalArgumentException("Bad audio format " + audioFormat);
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_DEFAULT:
return true;
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_IEC61937: // wrapped in PCM but compressed
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
case ENCODING_DOLBY_MAT:
return false;
case ENCODING_INVALID:
default:
throw new IllegalArgumentException("Bad audio format " + audioFormat);
}
}
@@ -605,29 +615,30 @@ public final class AudioFormat implements Parcelable {
public static boolean isEncodingLinearFrames(int audioFormat)
{
switch (audioFormat) {
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_IEC61937: // same size as stereo PCM
case ENCODING_DEFAULT:
return true;
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
return false;
case ENCODING_INVALID:
default:
throw new IllegalArgumentException("Bad audio format " + audioFormat);
case ENCODING_PCM_16BIT:
case ENCODING_PCM_8BIT:
case ENCODING_PCM_FLOAT:
case ENCODING_IEC61937: // same size as stereo PCM
case ENCODING_DEFAULT:
return true;
case ENCODING_AC3:
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
case ENCODING_MP3:
case ENCODING_AAC_LC:
case ENCODING_AAC_HE_V1:
case ENCODING_AAC_HE_V2:
case ENCODING_DOLBY_TRUEHD:
case ENCODING_AAC_ELD:
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
case ENCODING_DOLBY_MAT:
return false;
case ENCODING_INVALID:
default:
throw new IllegalArgumentException("Bad audio format " + audioFormat);
}
}
/**
@@ -867,6 +878,7 @@ public final class AudioFormat implements Parcelable {
case ENCODING_AAC_XHE:
case ENCODING_AC4:
case ENCODING_E_AC3_JOC:
case ENCODING_DOLBY_MAT:
mEncoding = encoding;
break;
case ENCODING_INVALID:
@@ -1083,7 +1095,8 @@ public final class AudioFormat implements Parcelable {
ENCODING_AAC_ELD,
ENCODING_AAC_XHE,
ENCODING_AC4,
ENCODING_E_AC3_JOC }
ENCODING_E_AC3_JOC,
ENCODING_DOLBY_MAT }
)
@Retention(RetentionPolicy.SOURCE)
public @interface Encoding {}
@@ -1098,6 +1111,7 @@ public final class AudioFormat implements Parcelable {
ENCODING_DOLBY_TRUEHD,
ENCODING_AC4,
ENCODING_E_AC3_JOC,
ENCODING_DOLBY_MAT,
};
/** @hide */
@@ -1109,7 +1123,8 @@ public final class AudioFormat implements Parcelable {
ENCODING_AAC_LC,
ENCODING_DOLBY_TRUEHD,
ENCODING_AC4,
ENCODING_E_AC3_JOC }
ENCODING_E_AC3_JOC,
ENCODING_DOLBY_MAT }
)
@Retention(RetentionPolicy.SOURCE)
public @interface SurroundSoundEncoding {}
@@ -1141,6 +1156,8 @@ public final class AudioFormat implements Parcelable {
return "Dolby AC-4";
case ENCODING_E_AC3_JOC:
return "Dolby Atmos in Dolby Digital Plus";
case ENCODING_DOLBY_MAT:
return "Dolby MAT";
default:
return "Unknown surround sound format";
}