Handle rotation signaled in MKV track name from HTC devices

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216704331
This commit is contained in:
andrewlewis 2018-10-11 09:00:00 -07:00 committed by Oliver Woodman
parent db0f107fb3
commit 362a21e17b

View File

@ -157,6 +157,7 @@ public final class MatroskaExtractor implements Extractor {
private static final int ID_FLAG_DEFAULT = 0x88;
private static final int ID_FLAG_FORCED = 0x55AA;
private static final int ID_DEFAULT_DURATION = 0x23E383;
private static final int ID_NAME = 0x536E;
private static final int ID_CODEC_ID = 0x86;
private static final int ID_CODEC_PRIVATE = 0x63A2;
private static final int ID_CODEC_DELAY = 0x56AA;
@ -815,6 +816,9 @@ public final class MatroskaExtractor implements Extractor {
throw new ParserException("DocType " + value + " not supported");
}
break;
case ID_NAME:
currentTrack.name = value;
break;
case ID_CODEC_ID:
currentTrack.codecId = value;
break;
@ -1463,6 +1467,7 @@ public final class MatroskaExtractor implements Extractor {
case ID_MAX_FALL:
return TYPE_UNSIGNED_INT;
case ID_DOC_TYPE:
case ID_NAME:
case ID_CODEC_ID:
case ID_LANGUAGE:
return TYPE_STRING;
@ -1609,6 +1614,7 @@ public final class MatroskaExtractor implements Extractor {
private static final int DEFAULT_MAX_FALL = 200; // nits.
// Common elements.
public String name;
public String codecId;
public int number;
public int type;
@ -1833,9 +1839,33 @@ public final class MatroskaExtractor implements Extractor {
byte[] hdrStaticInfo = getHdrStaticInfo();
colorInfo = new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo);
}
format = Format.createVideoSampleFormat(Integer.toString(trackId), mimeType, null,
Format.NO_VALUE, maxInputSize, width, height, Format.NO_VALUE, initializationData,
Format.NO_VALUE, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo,
int rotationDegrees = Format.NO_VALUE;
// Some HTC devices signal rotation in track names.
if ("htc_video_rotA-000".equals(name)) {
rotationDegrees = 0;
} else if ("htc_video_rotA-090".equals(name)) {
rotationDegrees = 90;
} else if ("htc_video_rotA-180".equals(name)) {
rotationDegrees = 180;
} else if ("htc_video_rotA-270".equals(name)) {
rotationDegrees = 270;
}
format =
Format.createVideoSampleFormat(
Integer.toString(trackId),
mimeType,
/* codecs= */ null,
/* bitrate= */ Format.NO_VALUE,
maxInputSize,
width,
height,
/* frameRate= */ Format.NO_VALUE,
initializationData,
rotationDegrees,
pixelWidthHeightRatio,
projectionData,
stereoMode,
colorInfo,
drmInitData);
} else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) {
type = C.TRACK_TYPE_TEXT;