@remotion/media-parser 4.0.207 → 4.0.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/av1-codec-string.d.ts +3 -0
- package/dist/av1-codec-string.js +91 -0
- package/dist/boxes/iso-base-media/ftype.d.ts +9 -0
- package/dist/boxes/iso-base-media/ftype.js +31 -0
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +20 -0
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +73 -0
- package/dist/boxes/iso-base-media/stts/stts.d.ts +15 -0
- package/dist/boxes/iso-base-media/stts/stts.js +35 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +14 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +67 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +11 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +14 -0
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +6 -0
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +9 -0
- package/dist/boxes/webm/bitstream/av1/color-config.d.ts +16 -0
- package/dist/boxes/webm/bitstream/av1/color-config.js +103 -0
- package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +14 -0
- package/dist/boxes/webm/bitstream/av1/color-primaries.js +17 -0
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +9 -0
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +17 -0
- package/dist/boxes/webm/bitstream/av1/frame.d.ts +0 -0
- package/dist/boxes/webm/bitstream/av1/frame.js +1 -0
- package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +51 -0
- package/dist/boxes/webm/bitstream/av1/header-segment.js +183 -0
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +17 -0
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +20 -0
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +10 -0
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +15 -0
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +5 -0
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +8 -0
- package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +8 -0
- package/dist/boxes/webm/bitstream/av1/timing-info.js +20 -0
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +21 -0
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +24 -0
- package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +2 -0
- package/dist/boxes/webm/bitstream/av1/uvlc.js +20 -0
- package/dist/boxes/webm/bitstream/av1.d.ts +20 -0
- package/dist/boxes/webm/bitstream/av1.js +118 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +1 -0
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/segments/duration.d.ts +6 -0
- package/dist/boxes/webm/segments/duration.js +19 -0
- package/dist/boxes/webm/segments/info.d.ts +9 -0
- package/dist/boxes/webm/segments/info.js +22 -0
- package/dist/boxes/webm/segments/main.d.ts +5 -0
- package/dist/boxes/webm/segments/main.js +2 -0
- package/dist/boxes/webm/segments/muxing.d.ts +6 -0
- package/dist/boxes/webm/segments/muxing.js +11 -0
- package/dist/boxes/webm/segments/seek-head.d.ts +9 -0
- package/dist/boxes/webm/segments/seek-head.js +22 -0
- package/dist/boxes/webm/segments/seek-position.d.ts +6 -0
- package/dist/boxes/webm/segments/seek-position.js +11 -0
- package/dist/boxes/webm/segments/seek.d.ts +13 -0
- package/dist/boxes/webm/segments/seek.js +35 -0
- package/dist/boxes/webm/segments/timestamp-scale.d.ts +6 -0
- package/dist/boxes/webm/segments/timestamp-scale.js +11 -0
- package/dist/boxes/webm/segments/tracks.d.ts +8 -0
- package/dist/boxes/webm/segments/tracks.js +21 -0
- package/dist/boxes/webm/segments/unknown.d.ts +6 -0
- package/dist/boxes/webm/segments/unknown.js +11 -0
- package/dist/boxes/webm/segments/void.d.ts +6 -0
- package/dist/boxes/webm/segments/void.js +11 -0
- package/dist/boxes/webm/segments/writing.d.ts +6 -0
- package/dist/boxes/webm/segments/writing.js +11 -0
- package/dist/boxes/webm/tracks.d.ts +8 -0
- package/dist/boxes/webm/tracks.js +21 -0
- package/dist/combine-uint8array.d.ts +1 -0
- package/dist/combine-uint8array.js +13 -0
- package/dist/from-web.d.ts +2 -0
- package/dist/from-web.js +45 -0
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +44 -0
- package/dist/read-and-increment-offset.d.ts +28 -0
- package/dist/read-and-increment-offset.js +177 -0
- package/dist/understand-vorbis.d.ts +1 -0
- package/dist/understand-vorbis.js +12 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ColorParameterBox } from './boxes/iso-base-media/stsd/colr';
|
|
2
|
+
import type { Av1BitstreamHeaderSegment } from './boxes/webm/bitstream/av1/header-segment';
|
|
3
|
+
export declare const constructAv1CodecString: (av1BitstreamHeader: Av1BitstreamHeaderSegment, colrAtom: ColorParameterBox | null) => string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// https://aomediacodec.github.io/av1-isobmff/#codecsparam
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.constructAv1CodecString = void 0;
|
|
5
|
+
const constructAv1CodecString = (av1BitstreamHeader, colrAtom) => {
|
|
6
|
+
let str = 'av01.';
|
|
7
|
+
// Profile
|
|
8
|
+
str += av1BitstreamHeader.seq_profile;
|
|
9
|
+
str += '.';
|
|
10
|
+
// Level
|
|
11
|
+
// The level parameter value SHALL equal the first level value indicated by seq_level_idx in the Sequence Header OBU
|
|
12
|
+
str += av1BitstreamHeader.seq_level[0].seq_level_idx
|
|
13
|
+
.toString()
|
|
14
|
+
.padStart(2, '0');
|
|
15
|
+
// Tier
|
|
16
|
+
// The tier parameter value SHALL be equal to M when the first seq_tier value in the Sequence Header OBU is equal to 0, and H when it is equal to 1
|
|
17
|
+
str += av1BitstreamHeader.seq_level[0].seq_tier ? 'H' : 'M';
|
|
18
|
+
str += '.';
|
|
19
|
+
// bitDepth
|
|
20
|
+
// The bitDepth parameter value SHALL equal the value of BitDepth variable as defined in [AV1] derived from the Sequence Header OBU
|
|
21
|
+
str += av1BitstreamHeader.color_config.bitDepth.toString().padStart(2, '0');
|
|
22
|
+
str += '.';
|
|
23
|
+
// monochrome
|
|
24
|
+
// The monochrome parameter value, represented by a single digit decimal, SHALL equal the value of mono_chrome in the Sequence Header OBU
|
|
25
|
+
str += av1BitstreamHeader.color_config.mono_chrome ? '1' : '0';
|
|
26
|
+
str += '.';
|
|
27
|
+
// The chromaSubsampling parameter value, represented by a three-digit decimal,
|
|
28
|
+
// SHALL have its first digit equal to subsampling_x
|
|
29
|
+
str += av1BitstreamHeader.color_config.subsampling_x ? '1' : '0';
|
|
30
|
+
// and its second digit equal to subsampling_y.
|
|
31
|
+
str += av1BitstreamHeader.color_config.subsampling_y ? '1' : '0';
|
|
32
|
+
// If both subsampling_x and subsampling_y are set to 1, then the third digit SHALL be equal to chroma_sample_position, otherwise it SHALL be set to 0
|
|
33
|
+
str +=
|
|
34
|
+
av1BitstreamHeader.color_config.subsampling_x &&
|
|
35
|
+
av1BitstreamHeader.color_config.subsampling_y
|
|
36
|
+
? av1BitstreamHeader.color_config.chroma_sample_position === 1
|
|
37
|
+
? '1'
|
|
38
|
+
: '0'
|
|
39
|
+
: '0';
|
|
40
|
+
str += '.';
|
|
41
|
+
// The colorPrimaries, transferCharacteristics, matrixCoefficients, and videoFullRangeFlag parameter values are set as follows:
|
|
42
|
+
// If a colr box with colour_type set to nclx is present, the colorPrimaries, transferCharacteristics, matrixCoefficients, and videoFullRangeFlag parameter values SHALL equal the values of matching fields in the colr box.
|
|
43
|
+
if (colrAtom) {
|
|
44
|
+
str += colrAtom.primaries.toString().padStart(2, '0');
|
|
45
|
+
str += '.';
|
|
46
|
+
str += colrAtom.transfer.toString().padStart(2, '0');
|
|
47
|
+
str += '.';
|
|
48
|
+
str += colrAtom.matrixIndex.toString().padStart(2, '0');
|
|
49
|
+
str += '.';
|
|
50
|
+
str += colrAtom.fullRangeFlag ? '1' : '0';
|
|
51
|
+
}
|
|
52
|
+
// Otherwise, a colr box with colour_type set to nclx is absent.
|
|
53
|
+
// If the color_description_present_flag is set to 1 in the Sequence Header OBU, the colorPrimaries, transferCharacteristics, and matrixCoefficients parameter values SHALL equal the values of matching fields in the Sequence Header OBU.
|
|
54
|
+
else if (av1BitstreamHeader.color_config.color_description_present_flag) {
|
|
55
|
+
str += av1BitstreamHeader.color_config.color_primaries
|
|
56
|
+
.toString()
|
|
57
|
+
.padStart(2, '0');
|
|
58
|
+
str += '.';
|
|
59
|
+
str += av1BitstreamHeader.color_config.transfer_characteristics
|
|
60
|
+
.toString()
|
|
61
|
+
.padStart(2, '0');
|
|
62
|
+
str += '.';
|
|
63
|
+
str += av1BitstreamHeader.color_config.matrix_coefficients
|
|
64
|
+
.toString()
|
|
65
|
+
.padStart(2, '0');
|
|
66
|
+
str += '.';
|
|
67
|
+
// The videoFullRangeFlag parameter value SHALL equal the color_range flag in the Sequence Header OBU.
|
|
68
|
+
str += av1BitstreamHeader.color_config.color_range ? '1' : '0';
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Otherwise, the color_description_present_flag is set to 0 in the Sequence Header OBU. The colorPrimaries, transferCharacteristics, and matrixCoefficients parameter values SHOULD be set to the default values below.
|
|
72
|
+
// colorPrimaries 01 (ITU-R BT.709)
|
|
73
|
+
str += '01';
|
|
74
|
+
str += '.';
|
|
75
|
+
// transferCharacteristics 01 (ITU-R BT.709)
|
|
76
|
+
str += '01';
|
|
77
|
+
str += '.';
|
|
78
|
+
// matrixCoefficients 00 (ITU-R BT.709)
|
|
79
|
+
str += '01';
|
|
80
|
+
str += '.';
|
|
81
|
+
// videoFullRangeFlag 0 (studio swing representation)
|
|
82
|
+
str += '0';
|
|
83
|
+
}
|
|
84
|
+
// If the codecs parameter string ends with ".0.110.01.01.01.0" (containing all the default values below), that trailing part of the string SHOULD be omitted.
|
|
85
|
+
const suffix = '.0.110.01.01.01.0';
|
|
86
|
+
if (str.endsWith(suffix)) {
|
|
87
|
+
str = str.slice(0, -suffix.length);
|
|
88
|
+
}
|
|
89
|
+
return str;
|
|
90
|
+
};
|
|
91
|
+
exports.constructAv1CodecString = constructAv1CodecString;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseBox } from './base-type';
|
|
2
|
+
export interface FtypBox extends BaseBox {
|
|
3
|
+
type: 'ftyp-box';
|
|
4
|
+
majorBrand: string;
|
|
5
|
+
minorVersion: number;
|
|
6
|
+
compatibleBrands: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const fourByteToNumber: (data: ArrayBuffer, from: number) => number;
|
|
9
|
+
export declare const parseFtyp: (data: ArrayBuffer, offset: number) => FtypBox;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFtyp = exports.fourByteToNumber = void 0;
|
|
4
|
+
const fourByteToNumber = (data, from) => {
|
|
5
|
+
const view = new DataView(data);
|
|
6
|
+
return ((view.getUint8(from + 0) << 24) |
|
|
7
|
+
(view.getUint8(from + 1) << 16) |
|
|
8
|
+
(view.getUint8(from + 2) << 8) |
|
|
9
|
+
view.getUint8(from + 3));
|
|
10
|
+
};
|
|
11
|
+
exports.fourByteToNumber = fourByteToNumber;
|
|
12
|
+
const parseFtyp = (data, offset) => {
|
|
13
|
+
const majorBrand = new TextDecoder().decode(data.slice(8, 12)).trim();
|
|
14
|
+
const minorVersion = (0, exports.fourByteToNumber)(data, 12);
|
|
15
|
+
const rest = data.slice(16);
|
|
16
|
+
const types = rest.byteLength / 4;
|
|
17
|
+
const compatibleBrands = [];
|
|
18
|
+
for (let i = 0; i < types; i++) {
|
|
19
|
+
const fourBytes = rest.slice(i * 4, i * 4 + 4);
|
|
20
|
+
compatibleBrands.push(new TextDecoder().decode(fourBytes).trim());
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
type: 'ftyp-box',
|
|
24
|
+
majorBrand,
|
|
25
|
+
minorVersion,
|
|
26
|
+
compatibleBrands,
|
|
27
|
+
offset,
|
|
28
|
+
boxSize: data.byteLength,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.parseFtyp = parseFtyp;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export interface AvccBox {
|
|
3
|
+
type: 'avcc-box';
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
configurationString: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const parseAvcc: ({ data, size, }: {
|
|
8
|
+
data: BufferIterator;
|
|
9
|
+
size: number;
|
|
10
|
+
}) => AvccBox;
|
|
11
|
+
export interface HvccBox {
|
|
12
|
+
type: 'hvcc-box';
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
configurationString: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const parseHvcc: ({ data, size, offset, }: {
|
|
17
|
+
data: BufferIterator;
|
|
18
|
+
size: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
}) => HvccBox;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseHvcc = exports.parseAvcc = void 0;
|
|
4
|
+
const parseAvcc = ({ data, size, }) => {
|
|
5
|
+
const confVersion = data.getUint8();
|
|
6
|
+
if (confVersion !== 1) {
|
|
7
|
+
throw new Error(`Unsupported AVCC version ${confVersion}`);
|
|
8
|
+
}
|
|
9
|
+
const profile = data.getUint8();
|
|
10
|
+
const profileCompatibility = data.getUint8();
|
|
11
|
+
const level = data.getUint8();
|
|
12
|
+
const str = `${profile.toString(16).padStart(2, '0')}${profileCompatibility.toString(16).padStart(2, '0')}${level.toString(16).padStart(2, '0')}`;
|
|
13
|
+
data.counter.decrement(4);
|
|
14
|
+
return {
|
|
15
|
+
type: 'avcc-box',
|
|
16
|
+
data: data.getSlice(size - 8),
|
|
17
|
+
configurationString: str,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.parseAvcc = parseAvcc;
|
|
21
|
+
const parseHvcc = ({ data, size, offset, }) => {
|
|
22
|
+
const raw = data.getSlice(size - 8);
|
|
23
|
+
data.counter.decrement(size - 8);
|
|
24
|
+
const configurationVersion = data.getUint8();
|
|
25
|
+
if (configurationVersion !== 1) {
|
|
26
|
+
throw new Error(`Unsupported HVCC version ${configurationVersion}`);
|
|
27
|
+
}
|
|
28
|
+
const generalProfileSpaceTierFlagAndIdc = data.getUint8();
|
|
29
|
+
let generalProfileCompatibility = data.getUint32();
|
|
30
|
+
// unsigned int(2) general_profile_space;
|
|
31
|
+
// unsigned int(1) general_tier_flag;
|
|
32
|
+
// unsigned int(5) general_profile_idc;
|
|
33
|
+
const generalProfileSpace = generalProfileSpaceTierFlagAndIdc >> 6;
|
|
34
|
+
const generalTierFlag = generalProfileSpaceTierFlagAndIdc >> 5;
|
|
35
|
+
const generalProfileIdc = generalProfileSpaceTierFlagAndIdc >> 0;
|
|
36
|
+
// general_constraint_indicator_flags(48)
|
|
37
|
+
const generalConstraintIndicator = data.getSlice(6);
|
|
38
|
+
const generalLevelIdc = data.getUint8();
|
|
39
|
+
let reversedGeneralProfileSpace = 0;
|
|
40
|
+
for (let i = 0; i < 32; i++) {
|
|
41
|
+
reversedGeneralProfileSpace |= generalProfileCompatibility & 1;
|
|
42
|
+
if (i === 31)
|
|
43
|
+
break;
|
|
44
|
+
reversedGeneralProfileSpace <<= 1;
|
|
45
|
+
generalProfileCompatibility >>= 1;
|
|
46
|
+
}
|
|
47
|
+
const profileSpaceChar = generalProfileSpace === 0
|
|
48
|
+
? ''
|
|
49
|
+
: generalProfileSpace === 1
|
|
50
|
+
? 'A'
|
|
51
|
+
: generalProfileSpace === 2
|
|
52
|
+
? 'B'
|
|
53
|
+
: 'C';
|
|
54
|
+
const generalTierChar = generalTierFlag === 0 ? 'L' : 'H';
|
|
55
|
+
let hasByte = false;
|
|
56
|
+
let generalConstraintString = '';
|
|
57
|
+
for (let i = 5; i >= 0; i--) {
|
|
58
|
+
if (generalConstraintIndicator[i] || hasByte) {
|
|
59
|
+
generalConstraintString =
|
|
60
|
+
generalConstraintIndicator[i].toString(16) + generalConstraintString;
|
|
61
|
+
hasByte = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const constraintString = `${profileSpaceChar}${generalProfileIdc.toString(16)}.${reversedGeneralProfileSpace.toString(16)}.${generalTierChar}${generalLevelIdc}.${generalConstraintString}`;
|
|
65
|
+
const remaining = size - (data.counter.getOffset() - offset);
|
|
66
|
+
data.discard(remaining);
|
|
67
|
+
return {
|
|
68
|
+
type: 'hvcc-box',
|
|
69
|
+
data: raw,
|
|
70
|
+
configurationString: constraintString,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.parseHvcc = parseHvcc;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export interface SttsBox {
|
|
3
|
+
type: 'stts-box';
|
|
4
|
+
sampleDistribution: SampleDistribution[];
|
|
5
|
+
}
|
|
6
|
+
type SampleDistribution = {
|
|
7
|
+
sampleCount: number;
|
|
8
|
+
sampleDelta: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const parseStts: ({ data, size, fileOffset, }: {
|
|
11
|
+
data: BufferIterator;
|
|
12
|
+
size: number;
|
|
13
|
+
fileOffset: number;
|
|
14
|
+
}) => SttsBox;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStts = void 0;
|
|
4
|
+
const parseStts = ({ data, size, fileOffset, }) => {
|
|
5
|
+
const initialOffset = data.counter.getOffset();
|
|
6
|
+
const initialCounter = initialOffset - fileOffset;
|
|
7
|
+
const version = data.getUint8();
|
|
8
|
+
if (version !== 0) {
|
|
9
|
+
throw new Error(`Unsupported STTS version ${version}`);
|
|
10
|
+
}
|
|
11
|
+
// flags, we discard them
|
|
12
|
+
data.discard(3);
|
|
13
|
+
// entry count
|
|
14
|
+
const entryCount = data.getUint32();
|
|
15
|
+
const sampleDistributions = [];
|
|
16
|
+
// entries
|
|
17
|
+
for (let i = 0; i < entryCount; i++) {
|
|
18
|
+
const sampleCount = data.getUint32();
|
|
19
|
+
const sampleDelta = data.getUint32();
|
|
20
|
+
const sampleDistribution = {
|
|
21
|
+
sampleCount,
|
|
22
|
+
sampleDelta,
|
|
23
|
+
};
|
|
24
|
+
sampleDistributions.push(sampleDistribution);
|
|
25
|
+
}
|
|
26
|
+
const bytesUsed = data.counter.getOffset() - initialOffset + initialCounter;
|
|
27
|
+
if (bytesUsed !== size) {
|
|
28
|
+
throw new Error(`Expected stts box to be ${size} bytes, but was ${bytesUsed} bytes`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
type: 'stts-box',
|
|
32
|
+
sampleDistribution: sampleDistributions,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.parseStts = parseStts;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../../buffer-iterator';
|
|
2
|
+
import type { Av1BitstreamHeaderSegment } from './header-segment';
|
|
3
|
+
type FrameType = 'key' | 'delta' | 'intra' | 'switch';
|
|
4
|
+
export type Av1FrameHeader = {
|
|
5
|
+
type: 'av1-frame-header';
|
|
6
|
+
frameType: FrameType;
|
|
7
|
+
temporalPointInfo: number | null;
|
|
8
|
+
};
|
|
9
|
+
export declare const getFrameType: (frameType: number) => FrameType;
|
|
10
|
+
export declare const parseAv1FrameHeader: ({ stream, headerSegment, }: {
|
|
11
|
+
stream: BufferIterator;
|
|
12
|
+
headerSegment: Av1BitstreamHeaderSegment;
|
|
13
|
+
}) => Av1FrameHeader;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAv1FrameHeader = exports.getFrameType = void 0;
|
|
4
|
+
const temporal_point_info_1 = require("./temporal-point-info");
|
|
5
|
+
const getFrameType = (frameType) => {
|
|
6
|
+
switch (frameType) {
|
|
7
|
+
case 0:
|
|
8
|
+
return 'key';
|
|
9
|
+
case 1:
|
|
10
|
+
return 'delta';
|
|
11
|
+
case 2:
|
|
12
|
+
return 'intra';
|
|
13
|
+
case 3:
|
|
14
|
+
return 'switch';
|
|
15
|
+
default:
|
|
16
|
+
throw new Error('Unknown frame type');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.getFrameType = getFrameType;
|
|
20
|
+
// https://aomediacodec.github.io/av1-spec/#uncompressed-header-syntax
|
|
21
|
+
// Only implmementing to get the basic stuff
|
|
22
|
+
const parseAv1FrameHeader = ({ stream, headerSegment, }) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (headerSegment.reduced_still_picture_header) {
|
|
25
|
+
return {
|
|
26
|
+
type: 'av1-frame-header',
|
|
27
|
+
frameType: 'key',
|
|
28
|
+
temporalPointInfo: null,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
let temporalPointInfo = null;
|
|
32
|
+
const show_existing_frame = Boolean(stream.getBits(1));
|
|
33
|
+
if (show_existing_frame) {
|
|
34
|
+
const frame_to_show_map_idx = stream.getBits(3);
|
|
35
|
+
if (headerSegment.decoder_model_info &&
|
|
36
|
+
!((_a = headerSegment.timing_info) === null || _a === void 0 ? void 0 : _a.equal_picture_interval)) {
|
|
37
|
+
temporalPointInfo = (0, temporal_point_info_1.getTemporalPointInfo)({
|
|
38
|
+
stream,
|
|
39
|
+
frame_presentation_time_length_minus_1: headerSegment.decoder_model_info
|
|
40
|
+
.frame_presentation_time_length_minus_1,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// TODO: this is wrong, there should be a store
|
|
44
|
+
const frame_type = (0, exports.getFrameType)(frame_to_show_map_idx);
|
|
45
|
+
return {
|
|
46
|
+
type: 'av1-frame-header',
|
|
47
|
+
frameType: frame_type,
|
|
48
|
+
temporalPointInfo,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const frameType = (0, exports.getFrameType)(stream.getBits(2));
|
|
52
|
+
const showFrame = Boolean(stream.getBits(1));
|
|
53
|
+
if (showFrame &&
|
|
54
|
+
headerSegment.decoder_model_info &&
|
|
55
|
+
!((_b = headerSegment.timing_info) === null || _b === void 0 ? void 0 : _b.equal_picture_interval)) {
|
|
56
|
+
temporalPointInfo = (0, temporal_point_info_1.getTemporalPointInfo)({
|
|
57
|
+
stream,
|
|
58
|
+
frame_presentation_time_length_minus_1: headerSegment.decoder_model_info.frame_presentation_time_length_minus_1,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
type: 'av1-frame-header',
|
|
63
|
+
frameType,
|
|
64
|
+
temporalPointInfo,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.parseAv1FrameHeader = parseAv1FrameHeader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../../buffer-iterator';
|
|
2
|
+
import { type Av1FrameHeader } from './bitstream-frame-header';
|
|
3
|
+
import type { Av1BitstreamHeaderSegment } from './header-segment';
|
|
4
|
+
export type Av1Frame = {
|
|
5
|
+
type: 'av1-frame';
|
|
6
|
+
header: Av1FrameHeader;
|
|
7
|
+
};
|
|
8
|
+
export declare const parseAv1Frame: ({ stream, headerSegment, }: {
|
|
9
|
+
stream: BufferIterator;
|
|
10
|
+
headerSegment: Av1BitstreamHeaderSegment;
|
|
11
|
+
}) => Av1Frame;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAv1Frame = void 0;
|
|
4
|
+
const bitstream_frame_header_1 = require("./bitstream-frame-header");
|
|
5
|
+
const parseAv1Frame = ({ stream, headerSegment, }) => {
|
|
6
|
+
return {
|
|
7
|
+
type: 'av1-frame',
|
|
8
|
+
header: (0, bitstream_frame_header_1.parseAv1FrameHeader)({
|
|
9
|
+
stream,
|
|
10
|
+
headerSegment,
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.parseAv1Frame = parseAv1Frame;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../../buffer-iterator';
|
|
2
|
+
export type ColorConfig = {
|
|
3
|
+
bitDepth: number;
|
|
4
|
+
numPlanes: number;
|
|
5
|
+
color_primaries: number;
|
|
6
|
+
transfer_characteristics: number;
|
|
7
|
+
matrix_coefficients: number;
|
|
8
|
+
separate_uv_delta_q: number;
|
|
9
|
+
color_range: boolean;
|
|
10
|
+
subsampling_x: boolean;
|
|
11
|
+
subsampling_y: boolean;
|
|
12
|
+
chroma_sample_position: number;
|
|
13
|
+
mono_chrome: boolean;
|
|
14
|
+
color_description_present_flag: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const getColorConfig: (stream: BufferIterator, seq_profile: number) => ColorConfig;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColorConfig = void 0;
|
|
4
|
+
const chroma_sample_position_1 = require("./chroma-sample-position");
|
|
5
|
+
const color_primaries_1 = require("./color-primaries");
|
|
6
|
+
const matrix_coefficients_1 = require("./matrix-coefficients");
|
|
7
|
+
const transfer_characteristics_1 = require("./transfer-characteristics");
|
|
8
|
+
const getColorConfig = (stream, seq_profile) => {
|
|
9
|
+
const high_bitdepth = Boolean(stream.getBits(1));
|
|
10
|
+
let bitDepth = 0;
|
|
11
|
+
if (seq_profile === 2 && high_bitdepth) {
|
|
12
|
+
const twelve_bit = Boolean(stream.getBits(1));
|
|
13
|
+
bitDepth = twelve_bit ? 12 : 10;
|
|
14
|
+
}
|
|
15
|
+
else if (seq_profile <= 2) {
|
|
16
|
+
bitDepth = high_bitdepth ? 10 : 8;
|
|
17
|
+
}
|
|
18
|
+
const mono_chrome = seq_profile === 1 ? true : Boolean(stream.getBits(1));
|
|
19
|
+
const numPlanes = mono_chrome ? 1 : 3;
|
|
20
|
+
const color_description_present_flag = Boolean(stream.getBits(1));
|
|
21
|
+
const color_primaries = color_description_present_flag
|
|
22
|
+
? stream.getBits(8)
|
|
23
|
+
: color_primaries_1.colorPrimaries.CP_UNSPECIFIED;
|
|
24
|
+
const transfer_characteristics = color_description_present_flag
|
|
25
|
+
? stream.getBits(8)
|
|
26
|
+
: transfer_characteristics_1.transferCharacteristics.TC_UNSPECIFIED;
|
|
27
|
+
const matrix_coefficients = color_description_present_flag
|
|
28
|
+
? stream.getBits(8)
|
|
29
|
+
: matrix_coefficients_1.matrixCoefficients.MC_UNSPECIFIED;
|
|
30
|
+
let chroma_sample_position = chroma_sample_position_1.chromaSamplePositions.CSP_UNKNOWN;
|
|
31
|
+
let color_range = false;
|
|
32
|
+
let subsampling_x = false;
|
|
33
|
+
let subsampling_y = false;
|
|
34
|
+
if (mono_chrome) {
|
|
35
|
+
color_range = Boolean(stream.getBits(1));
|
|
36
|
+
subsampling_x = true;
|
|
37
|
+
subsampling_y = true;
|
|
38
|
+
return {
|
|
39
|
+
bitDepth,
|
|
40
|
+
numPlanes,
|
|
41
|
+
color_primaries,
|
|
42
|
+
transfer_characteristics,
|
|
43
|
+
matrix_coefficients,
|
|
44
|
+
separate_uv_delta_q: 0,
|
|
45
|
+
color_range,
|
|
46
|
+
subsampling_x,
|
|
47
|
+
subsampling_y,
|
|
48
|
+
chroma_sample_position,
|
|
49
|
+
mono_chrome,
|
|
50
|
+
color_description_present_flag,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (color_primaries === color_primaries_1.colorPrimaries.CP_BT_709 &&
|
|
54
|
+
transfer_characteristics === transfer_characteristics_1.transferCharacteristics.TC_SRGB &&
|
|
55
|
+
matrix_coefficients === matrix_coefficients_1.matrixCoefficients.MC_IDENTITY) {
|
|
56
|
+
color_range = true;
|
|
57
|
+
subsampling_x = false;
|
|
58
|
+
subsampling_y = false;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
color_range = Boolean(stream.getBits(1));
|
|
62
|
+
if (seq_profile === 0) {
|
|
63
|
+
subsampling_x = true;
|
|
64
|
+
subsampling_y = true;
|
|
65
|
+
}
|
|
66
|
+
else if (seq_profile === 1) {
|
|
67
|
+
subsampling_x = false;
|
|
68
|
+
subsampling_y = false;
|
|
69
|
+
}
|
|
70
|
+
else if (bitDepth === 12) {
|
|
71
|
+
subsampling_x = Boolean(stream.getBits(1));
|
|
72
|
+
if (subsampling_x) {
|
|
73
|
+
subsampling_y = Boolean(stream.getBits(1));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
subsampling_y = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
subsampling_x = true;
|
|
81
|
+
subsampling_y = false;
|
|
82
|
+
}
|
|
83
|
+
if (subsampling_x && subsampling_y) {
|
|
84
|
+
chroma_sample_position = stream.getBits(2);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const separate_uv_delta_q = stream.getBits(1);
|
|
88
|
+
return {
|
|
89
|
+
bitDepth,
|
|
90
|
+
numPlanes,
|
|
91
|
+
color_primaries,
|
|
92
|
+
transfer_characteristics,
|
|
93
|
+
matrix_coefficients,
|
|
94
|
+
separate_uv_delta_q,
|
|
95
|
+
chroma_sample_position,
|
|
96
|
+
color_range,
|
|
97
|
+
subsampling_x,
|
|
98
|
+
subsampling_y,
|
|
99
|
+
mono_chrome,
|
|
100
|
+
color_description_present_flag,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
exports.getColorConfig = getColorConfig;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const colorPrimaries: {
|
|
2
|
+
CP_BT_709: number;
|
|
3
|
+
CP_UNSPECIFIED: number;
|
|
4
|
+
CP_BT_470_M: number;
|
|
5
|
+
CP_BT_470_B_G: number;
|
|
6
|
+
CP_BT_601: number;
|
|
7
|
+
CP_SMPTE_240: number;
|
|
8
|
+
CP_GENERIC_FILM: number;
|
|
9
|
+
CP_BT_2020: number;
|
|
10
|
+
CP_XYZ: number;
|
|
11
|
+
CP_SMPTE_431: number;
|
|
12
|
+
CP_SMPTE_432: number;
|
|
13
|
+
CP_EBU_3213: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colorPrimaries = void 0;
|
|
4
|
+
exports.colorPrimaries = {
|
|
5
|
+
CP_BT_709: 1,
|
|
6
|
+
CP_UNSPECIFIED: 2,
|
|
7
|
+
CP_BT_470_M: 4,
|
|
8
|
+
CP_BT_470_B_G: 5,
|
|
9
|
+
CP_BT_601: 6,
|
|
10
|
+
CP_SMPTE_240: 7,
|
|
11
|
+
CP_GENERIC_FILM: 8,
|
|
12
|
+
CP_BT_2020: 9,
|
|
13
|
+
CP_XYZ: 10,
|
|
14
|
+
CP_SMPTE_431: 11,
|
|
15
|
+
CP_SMPTE_432: 12,
|
|
16
|
+
CP_EBU_3213: 22,
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../../buffer-iterator';
|
|
2
|
+
export type DecoderModelInfo = {
|
|
3
|
+
type: 'decoder-model-info';
|
|
4
|
+
buffer_delay_length_minus_1: number;
|
|
5
|
+
num_units_in_decoding_tick: number;
|
|
6
|
+
buffer_removal_time_length_minus_1: number;
|
|
7
|
+
frame_presentation_time_length_minus_1: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const parseDecoderModelInfo: (stream: BufferIterator) => DecoderModelInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDecoderModelInfo = void 0;
|
|
4
|
+
const parseDecoderModelInfo = (stream) => {
|
|
5
|
+
const buffer_delay_length_minus_1 = stream.getBits(5);
|
|
6
|
+
const num_units_in_decoding_tick = stream.getBits(32);
|
|
7
|
+
const buffer_removal_time_length_minus_1 = stream.getBits(5);
|
|
8
|
+
const frame_presentation_time_length_minus_1 = stream.getBits(5);
|
|
9
|
+
return {
|
|
10
|
+
type: 'decoder-model-info',
|
|
11
|
+
buffer_delay_length_minus_1,
|
|
12
|
+
num_units_in_decoding_tick,
|
|
13
|
+
buffer_removal_time_length_minus_1,
|
|
14
|
+
frame_presentation_time_length_minus_1,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.parseDecoderModelInfo = parseDecoderModelInfo;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../../buffer-iterator';
|
|
2
|
+
import type { ColorConfig } from './color-config';
|
|
3
|
+
import { type DecoderModelInfo } from './decoder-model-info';
|
|
4
|
+
import { type OperatingParametersInfo } from './operating-parameters-info';
|
|
5
|
+
import { type TimingInfo } from './timing-info';
|
|
6
|
+
type SeqLevelIndex = {
|
|
7
|
+
operating_point_idc: number;
|
|
8
|
+
seq_level_idx: number;
|
|
9
|
+
seq_tier: number;
|
|
10
|
+
};
|
|
11
|
+
export type Av1BitstreamHeaderSegment = {
|
|
12
|
+
type: 'av1-bitstream-header';
|
|
13
|
+
seq_profile: number;
|
|
14
|
+
still_picture: boolean;
|
|
15
|
+
reduced_still_picture_header: boolean;
|
|
16
|
+
timing_info_present_flag: boolean;
|
|
17
|
+
decoder_model_info_present_flag: boolean;
|
|
18
|
+
initial_display_delay_present_flag: boolean;
|
|
19
|
+
operating_points_cnt_minus_1: number;
|
|
20
|
+
seq_level: SeqLevelIndex[];
|
|
21
|
+
timing_info: TimingInfo | null;
|
|
22
|
+
decoder_model_info: DecoderModelInfo | null;
|
|
23
|
+
operating_parameters_info: OperatingParametersInfo[];
|
|
24
|
+
initial_display_delay_minus_1: number[];
|
|
25
|
+
frame_width_bits_minus_1: number;
|
|
26
|
+
frame_height_bits_minus_1: number;
|
|
27
|
+
max_frame_width_minus_1: number;
|
|
28
|
+
max_frame_height_minus_1: number;
|
|
29
|
+
delta_frame_id_length_minus_2: number | null;
|
|
30
|
+
additional_frame_id_length_minus_1: number | null;
|
|
31
|
+
use_128x128_superblock: boolean;
|
|
32
|
+
enable_filter_intra: boolean;
|
|
33
|
+
enable_intra_edge_filter: boolean;
|
|
34
|
+
color_config: ColorConfig;
|
|
35
|
+
film_grain_params_present: boolean;
|
|
36
|
+
enable_interintra_compound: number;
|
|
37
|
+
enable_masked_compound: number;
|
|
38
|
+
enable_warped_motion: number;
|
|
39
|
+
enable_order_hint: number;
|
|
40
|
+
enable_dual_filter: number;
|
|
41
|
+
enable_jnt_comp: boolean;
|
|
42
|
+
enable_ref_frame_mvs: boolean;
|
|
43
|
+
seq_force_screen_content_tools: number;
|
|
44
|
+
seq_force_integer_mv: number;
|
|
45
|
+
enable_superres: boolean;
|
|
46
|
+
enable_cdef: boolean;
|
|
47
|
+
enable_restoration: boolean;
|
|
48
|
+
orderHintBits: number;
|
|
49
|
+
};
|
|
50
|
+
export declare const parseAv1BitstreamHeaderSegment: (stream: BufferIterator) => Av1BitstreamHeaderSegment;
|
|
51
|
+
export {};
|