mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Parse Projection, ProjectionPrivate
As described in https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md. Also parse StereoMode as per standard matroska spec. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134302208
This commit is contained in:
parent
f5ebcb8d04
commit
d74166cd35
1 changed files with 30 additions and 1 deletions
|
|
@ -163,6 +163,9 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
private static final int ID_CUE_TRACK_POSITIONS = 0xB7;
|
private static final int ID_CUE_TRACK_POSITIONS = 0xB7;
|
||||||
private static final int ID_CUE_CLUSTER_POSITION = 0xF1;
|
private static final int ID_CUE_CLUSTER_POSITION = 0xF1;
|
||||||
private static final int ID_LANGUAGE = 0x22B59C;
|
private static final int ID_LANGUAGE = 0x22B59C;
|
||||||
|
private static final int ID_PROJECTION = 0x7670;
|
||||||
|
private static final int ID_PROJECTION_PRIVATE = 0x7672;
|
||||||
|
private static final int ID_STEREO_MODE = 0x53B8;
|
||||||
|
|
||||||
private static final int LACING_NONE = 0;
|
private static final int LACING_NONE = 0;
|
||||||
private static final int LACING_XIPH = 1;
|
private static final int LACING_XIPH = 1;
|
||||||
|
|
@ -362,6 +365,7 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
case ID_CUE_POINT:
|
case ID_CUE_POINT:
|
||||||
case ID_CUE_TRACK_POSITIONS:
|
case ID_CUE_TRACK_POSITIONS:
|
||||||
case ID_BLOCK_GROUP:
|
case ID_BLOCK_GROUP:
|
||||||
|
case ID_PROJECTION:
|
||||||
return EbmlReader.TYPE_MASTER;
|
return EbmlReader.TYPE_MASTER;
|
||||||
case ID_EBML_READ_VERSION:
|
case ID_EBML_READ_VERSION:
|
||||||
case ID_DOC_TYPE_READ_VERSION:
|
case ID_DOC_TYPE_READ_VERSION:
|
||||||
|
|
@ -391,6 +395,7 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
case ID_CUE_TIME:
|
case ID_CUE_TIME:
|
||||||
case ID_CUE_CLUSTER_POSITION:
|
case ID_CUE_CLUSTER_POSITION:
|
||||||
case ID_REFERENCE_BLOCK:
|
case ID_REFERENCE_BLOCK:
|
||||||
|
case ID_STEREO_MODE:
|
||||||
return EbmlReader.TYPE_UNSIGNED_INT;
|
return EbmlReader.TYPE_UNSIGNED_INT;
|
||||||
case ID_DOC_TYPE:
|
case ID_DOC_TYPE:
|
||||||
case ID_CODEC_ID:
|
case ID_CODEC_ID:
|
||||||
|
|
@ -402,6 +407,7 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
case ID_SIMPLE_BLOCK:
|
case ID_SIMPLE_BLOCK:
|
||||||
case ID_BLOCK:
|
case ID_BLOCK:
|
||||||
case ID_CODEC_PRIVATE:
|
case ID_CODEC_PRIVATE:
|
||||||
|
case ID_PROJECTION_PRIVATE:
|
||||||
return EbmlReader.TYPE_BINARY;
|
return EbmlReader.TYPE_BINARY;
|
||||||
case ID_DURATION:
|
case ID_DURATION:
|
||||||
case ID_SAMPLING_FREQUENCY:
|
case ID_SAMPLING_FREQUENCY:
|
||||||
|
|
@ -656,6 +662,22 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
case ID_BLOCK_DURATION:
|
case ID_BLOCK_DURATION:
|
||||||
blockDurationUs = scaleTimecodeToUs(value);
|
blockDurationUs = scaleTimecodeToUs(value);
|
||||||
return;
|
return;
|
||||||
|
case ID_STEREO_MODE:
|
||||||
|
int layout = (int) value;
|
||||||
|
switch (layout) {
|
||||||
|
case 0:
|
||||||
|
currentTrack.stereoMode = C.STEREO_MODE_MONO;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
currentTrack.stereoMode = C.STEREO_MODE_LEFT_RIGHT;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
currentTrack.stereoMode = C.STEREO_MODE_TOP_BOTTOM;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -706,6 +728,10 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
currentTrack.codecPrivate = new byte[contentSize];
|
currentTrack.codecPrivate = new byte[contentSize];
|
||||||
input.readFully(currentTrack.codecPrivate, 0, contentSize);
|
input.readFully(currentTrack.codecPrivate, 0, contentSize);
|
||||||
return;
|
return;
|
||||||
|
case ID_PROJECTION_PRIVATE:
|
||||||
|
currentTrack.projectionData = new byte[contentSize];
|
||||||
|
input.readFully(currentTrack.projectionData, 0, contentSize);
|
||||||
|
return;
|
||||||
case ID_CONTENT_COMPRESSION_SETTINGS:
|
case ID_CONTENT_COMPRESSION_SETTINGS:
|
||||||
// This extractor only supports header stripping, so the payload is the stripped bytes.
|
// This extractor only supports header stripping, so the payload is the stripped bytes.
|
||||||
currentTrack.sampleStrippedBytes = new byte[contentSize];
|
currentTrack.sampleStrippedBytes = new byte[contentSize];
|
||||||
|
|
@ -1292,6 +1318,9 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
public int displayWidth = Format.NO_VALUE;
|
public int displayWidth = Format.NO_VALUE;
|
||||||
public int displayHeight = Format.NO_VALUE;
|
public int displayHeight = Format.NO_VALUE;
|
||||||
public int displayUnit = DISPLAY_UNIT_PIXELS;
|
public int displayUnit = DISPLAY_UNIT_PIXELS;
|
||||||
|
public byte[] projectionData = null;
|
||||||
|
@C.StereoMode
|
||||||
|
public int stereoMode = Format.NO_VALUE;
|
||||||
|
|
||||||
// Audio elements. Initially set to their default values.
|
// Audio elements. Initially set to their default values.
|
||||||
public int channelCount = 1;
|
public int channelCount = 1;
|
||||||
|
|
@ -1450,7 +1479,7 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
}
|
}
|
||||||
format = Format.createVideoSampleFormat(Integer.toString(trackId), mimeType, null,
|
format = Format.createVideoSampleFormat(Integer.toString(trackId), mimeType, null,
|
||||||
Format.NO_VALUE, maxInputSize, width, height, Format.NO_VALUE, initializationData,
|
Format.NO_VALUE, maxInputSize, width, height, Format.NO_VALUE, initializationData,
|
||||||
Format.NO_VALUE, pixelWidthHeightRatio, drmInitData);
|
Format.NO_VALUE, pixelWidthHeightRatio, projectionData, stereoMode, drmInitData);
|
||||||
} else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) {
|
} else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) {
|
||||||
format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null,
|
format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null,
|
||||||
Format.NO_VALUE, selectionFlags, language, drmInitData);
|
Format.NO_VALUE, selectionFlags, language, drmInitData);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue