@svta/cml-iso-bmff 1.0.5 → 1.0.7
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/README.md +2 -2
- package/dist/index.d.ts +2394 -2396
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -422
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { UTF_8, decodeText, encodeText, isArrayBufferLike } from "@svta/cml-utils";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/createWriterConfig.ts
|
|
4
3
|
function createWriterConfig(config) {
|
|
5
4
|
return { writers: config?.writers ?? {} };
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
//#endregion
|
|
9
7
|
//#region src/utils/CONTAINERS.ts
|
|
10
8
|
/**
|
|
@@ -33,7 +31,6 @@ const CONTAINERS = [
|
|
|
33
31
|
"udta",
|
|
34
32
|
"vttc"
|
|
35
33
|
];
|
|
36
|
-
|
|
37
34
|
//#endregion
|
|
38
35
|
//#region src/utils/isContainer.ts
|
|
39
36
|
/**
|
|
@@ -48,7 +45,6 @@ const CONTAINERS = [
|
|
|
48
45
|
function isContainer(box) {
|
|
49
46
|
return "boxes" in box || CONTAINERS.includes(box.type);
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
//#endregion
|
|
53
49
|
//#region src/IsoBoxFields.ts
|
|
54
50
|
/**
|
|
@@ -95,13 +91,12 @@ const DATA = "data";
|
|
|
95
91
|
*/
|
|
96
92
|
const IsoBoxFields = {
|
|
97
93
|
DATA,
|
|
98
|
-
INT,
|
|
94
|
+
INT: "int",
|
|
99
95
|
STRING,
|
|
100
96
|
TEMPLATE,
|
|
101
97
|
UINT,
|
|
102
98
|
UTF8
|
|
103
99
|
};
|
|
104
|
-
|
|
105
100
|
//#endregion
|
|
106
101
|
//#region src/IsoBoxWriteView.ts
|
|
107
102
|
/**
|
|
@@ -116,9 +111,9 @@ var IsoBoxWriteView = class {
|
|
|
116
111
|
* @param size - The size of the data view.
|
|
117
112
|
*/
|
|
118
113
|
constructor(type, size) {
|
|
119
|
-
this.writeUint = (value, size
|
|
114
|
+
this.writeUint = (value, size) => {
|
|
120
115
|
const { dataView, cursor } = this;
|
|
121
|
-
switch (size
|
|
116
|
+
switch (size) {
|
|
122
117
|
case 1:
|
|
123
118
|
dataView.setUint8(cursor, value);
|
|
124
119
|
break;
|
|
@@ -143,11 +138,11 @@ var IsoBoxWriteView = class {
|
|
|
143
138
|
break;
|
|
144
139
|
}
|
|
145
140
|
}
|
|
146
|
-
this.cursor += size
|
|
141
|
+
this.cursor += size;
|
|
147
142
|
};
|
|
148
|
-
this.writeInt = (value, size
|
|
143
|
+
this.writeInt = (value, size) => {
|
|
149
144
|
const { dataView, cursor } = this;
|
|
150
|
-
switch (size
|
|
145
|
+
switch (size) {
|
|
151
146
|
case 1:
|
|
152
147
|
dataView.setInt8(cursor, value);
|
|
153
148
|
break;
|
|
@@ -162,9 +157,8 @@ var IsoBoxWriteView = class {
|
|
|
162
157
|
const s2 = value - s1 * Math.pow(2, 32);
|
|
163
158
|
dataView.setUint32(cursor, s1);
|
|
164
159
|
dataView.setUint32(cursor + 4, s2);
|
|
165
|
-
break;
|
|
166
160
|
}
|
|
167
|
-
this.cursor += size
|
|
161
|
+
this.cursor += size;
|
|
168
162
|
};
|
|
169
163
|
this.writeString = (value) => {
|
|
170
164
|
for (let c = 0, len = value.length; c < len; c++) this.writeUint(value.charCodeAt(c), 1);
|
|
@@ -186,23 +180,22 @@ var IsoBoxWriteView = class {
|
|
|
186
180
|
this.cursor += bytes.length;
|
|
187
181
|
}
|
|
188
182
|
};
|
|
189
|
-
this.writeArray = (data, type
|
|
190
|
-
const write = type
|
|
191
|
-
for (let i = 0; i < length; i++) write(data[i] ?? 0, size
|
|
183
|
+
this.writeArray = (data, type, size, length) => {
|
|
184
|
+
const write = type === "uint" ? this.writeUint : type === "template" ? this.writeTemplate : this.writeInt;
|
|
185
|
+
for (let i = 0; i < length; i++) write(data[i] ?? 0, size);
|
|
192
186
|
};
|
|
193
|
-
this.writeTemplate = (value, size
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
this.writeUint(fixedPoint, size$1);
|
|
187
|
+
this.writeTemplate = (value, size) => {
|
|
188
|
+
const fixedPoint = Math.round(value * Math.pow(2, size === 4 ? 16 : 8));
|
|
189
|
+
this.writeUint(fixedPoint, size);
|
|
197
190
|
};
|
|
198
|
-
this.writeBoxHeader = (type
|
|
199
|
-
if (size
|
|
191
|
+
this.writeBoxHeader = (type, size) => {
|
|
192
|
+
if (size > 4294967295) {
|
|
200
193
|
this.writeUint(1, 4);
|
|
201
|
-
this.writeString(type
|
|
202
|
-
this.writeUint(size
|
|
194
|
+
this.writeString(type);
|
|
195
|
+
this.writeUint(size, 8);
|
|
203
196
|
} else {
|
|
204
|
-
this.writeUint(size
|
|
205
|
-
this.writeString(type
|
|
197
|
+
this.writeUint(size, 4);
|
|
198
|
+
this.writeString(type);
|
|
206
199
|
}
|
|
207
200
|
};
|
|
208
201
|
this.dataView = new DataView(new ArrayBuffer(size));
|
|
@@ -244,7 +237,6 @@ var IsoBoxWriteView = class {
|
|
|
244
237
|
this.writeUint(flags, 3);
|
|
245
238
|
}
|
|
246
239
|
};
|
|
247
|
-
|
|
248
240
|
//#endregion
|
|
249
241
|
//#region src/utils/writeBoxes.ts
|
|
250
242
|
/**
|
|
@@ -260,7 +252,6 @@ var IsoBoxWriteView = class {
|
|
|
260
252
|
function writeBoxes(boxes, config) {
|
|
261
253
|
return Array.from(boxes, (box) => writeBox(box, config));
|
|
262
254
|
}
|
|
263
|
-
|
|
264
255
|
//#endregion
|
|
265
256
|
//#region src/utils/writeChildBoxes.ts
|
|
266
257
|
/**
|
|
@@ -280,7 +271,6 @@ function writeChildBoxes(boxes, config) {
|
|
|
280
271
|
size: bytes.reduce((size, byte) => size + byte.byteLength, 0)
|
|
281
272
|
};
|
|
282
273
|
}
|
|
283
|
-
|
|
284
274
|
//#endregion
|
|
285
275
|
//#region src/utils/writeContainerBox.ts
|
|
286
276
|
/**
|
|
@@ -303,7 +293,6 @@ function writeContainerBox(box, config) {
|
|
|
303
293
|
writer.writeBytes(bytes);
|
|
304
294
|
return writer;
|
|
305
295
|
}
|
|
306
|
-
|
|
307
296
|
//#endregion
|
|
308
297
|
//#region src/utils/writeBox.ts
|
|
309
298
|
/**
|
|
@@ -329,7 +318,6 @@ function writeBox(box, config) {
|
|
|
329
318
|
if (!view) throw new Error("Invalid box");
|
|
330
319
|
return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
331
320
|
}
|
|
332
|
-
|
|
333
321
|
//#endregion
|
|
334
322
|
//#region src/writeIsoBox.ts
|
|
335
323
|
/**
|
|
@@ -345,7 +333,6 @@ function writeBox(box, config) {
|
|
|
345
333
|
function writeIsoBox(box, config) {
|
|
346
334
|
return writeBox(box, createWriterConfig(config));
|
|
347
335
|
}
|
|
348
|
-
|
|
349
336
|
//#endregion
|
|
350
337
|
//#region src/IsoBoxReadableStream.ts
|
|
351
338
|
const ReadableStreamBase = /* @__PURE__ */ (() => typeof ReadableStream === "undefined" ? class {
|
|
@@ -382,7 +369,6 @@ var IsoBoxReadableStream = class extends ReadableStreamBase {
|
|
|
382
369
|
});
|
|
383
370
|
}
|
|
384
371
|
};
|
|
385
|
-
|
|
386
372
|
//#endregion
|
|
387
373
|
//#region src/createIsoBoxReadableStream.ts
|
|
388
374
|
/**
|
|
@@ -401,7 +387,6 @@ var IsoBoxReadableStream = class extends ReadableStreamBase {
|
|
|
401
387
|
function createIsoBoxReadableStream(boxes, config) {
|
|
402
388
|
return new IsoBoxReadableStream(boxes, config);
|
|
403
389
|
}
|
|
404
|
-
|
|
405
390
|
//#endregion
|
|
406
391
|
//#region src/traverseIsoBoxes.ts
|
|
407
392
|
/**
|
|
@@ -441,7 +426,6 @@ function* traverseIsoBoxes(boxes, config) {
|
|
|
441
426
|
}
|
|
442
427
|
}
|
|
443
428
|
}
|
|
444
|
-
|
|
445
429
|
//#endregion
|
|
446
430
|
//#region src/filterIsoBoxes.ts
|
|
447
431
|
function filterIsoBoxes(boxes, callback, config) {
|
|
@@ -449,14 +433,12 @@ function filterIsoBoxes(boxes, callback, config) {
|
|
|
449
433
|
for (const box of traverseIsoBoxes(boxes, config)) if (callback(box)) result.push(box);
|
|
450
434
|
return result;
|
|
451
435
|
}
|
|
452
|
-
|
|
453
436
|
//#endregion
|
|
454
437
|
//#region src/findIsoBox.ts
|
|
455
438
|
function findIsoBox(boxes, callback, config) {
|
|
456
439
|
for (const box of traverseIsoBoxes(boxes, config)) if (callback(box)) return box;
|
|
457
440
|
return null;
|
|
458
441
|
}
|
|
459
|
-
|
|
460
442
|
//#endregion
|
|
461
443
|
//#region src/isIsoBoxType.ts
|
|
462
444
|
/**
|
|
@@ -472,14 +454,12 @@ function findIsoBox(boxes, callback, config) {
|
|
|
472
454
|
function isIsoBoxType(type, box) {
|
|
473
455
|
return "type" in box && box.type === type;
|
|
474
456
|
}
|
|
475
|
-
|
|
476
457
|
//#endregion
|
|
477
458
|
//#region src/utils/readData.ts
|
|
478
459
|
function readData(dataView, offset, size) {
|
|
479
460
|
const length = size > 0 ? size : dataView.byteLength - (offset - dataView.byteOffset);
|
|
480
461
|
return new Uint8Array(dataView.buffer, offset, Math.max(length, 0));
|
|
481
462
|
}
|
|
482
|
-
|
|
483
463
|
//#endregion
|
|
484
464
|
//#region src/utils/readInt.ts
|
|
485
465
|
function readInt(dataView, offset, size) {
|
|
@@ -499,11 +479,9 @@ function readInt(dataView, offset, size) {
|
|
|
499
479
|
const s1 = dataView.getInt32(cursor);
|
|
500
480
|
const s2 = dataView.getInt32(cursor + 4);
|
|
501
481
|
result = s1 * Math.pow(2, 32) + s2;
|
|
502
|
-
break;
|
|
503
482
|
}
|
|
504
483
|
return result;
|
|
505
484
|
}
|
|
506
|
-
|
|
507
485
|
//#endregion
|
|
508
486
|
//#region src/utils/readUint.ts
|
|
509
487
|
function readUint(dataView, offset, size) {
|
|
@@ -530,11 +508,9 @@ function readUint(dataView, offset, size) {
|
|
|
530
508
|
s1 = dataView.getUint32(cursor);
|
|
531
509
|
s2 = dataView.getUint32(cursor + 4);
|
|
532
510
|
value = s1 * Math.pow(2, 32) + s2;
|
|
533
|
-
break;
|
|
534
511
|
}
|
|
535
512
|
return value;
|
|
536
513
|
}
|
|
537
|
-
|
|
538
514
|
//#endregion
|
|
539
515
|
//#region src/utils/readString.ts
|
|
540
516
|
function readString(dataView, offset, length) {
|
|
@@ -545,14 +521,12 @@ function readString(dataView, offset, length) {
|
|
|
545
521
|
}
|
|
546
522
|
return str;
|
|
547
523
|
}
|
|
548
|
-
|
|
549
524
|
//#endregion
|
|
550
525
|
//#region src/utils/readTemplate.ts
|
|
551
526
|
function readTemplate(dataView, offset, size) {
|
|
552
527
|
const half = size / 2;
|
|
553
528
|
return readUint(dataView, offset, half) + readUint(dataView, offset + half, half) / Math.pow(2, half);
|
|
554
529
|
}
|
|
555
|
-
|
|
556
530
|
//#endregion
|
|
557
531
|
//#region src/utils/readTerminatedString.ts
|
|
558
532
|
function readTerminatedString(dataView, offset) {
|
|
@@ -566,7 +540,6 @@ function readTerminatedString(dataView, offset) {
|
|
|
566
540
|
}
|
|
567
541
|
return str;
|
|
568
542
|
}
|
|
569
|
-
|
|
570
543
|
//#endregion
|
|
571
544
|
//#region src/utils/readUtf8String.ts
|
|
572
545
|
/**
|
|
@@ -582,7 +555,6 @@ function readUtf8String(dataView, offset) {
|
|
|
582
555
|
const length = dataView.byteLength - (offset - dataView.byteOffset);
|
|
583
556
|
return length > 0 ? decodeText(new DataView(dataView.buffer, offset, length), { encoding: UTF_8 }) : "";
|
|
584
557
|
}
|
|
585
|
-
|
|
586
558
|
//#endregion
|
|
587
559
|
//#region src/utils/readUtf8TerminatedString.ts
|
|
588
560
|
/**
|
|
@@ -605,7 +577,6 @@ function readUtf8TerminatedString(dataView, offset) {
|
|
|
605
577
|
}
|
|
606
578
|
return data;
|
|
607
579
|
}
|
|
608
|
-
|
|
609
580
|
//#endregion
|
|
610
581
|
//#region src/IsoBoxReadView.ts
|
|
611
582
|
/**
|
|
@@ -626,7 +597,8 @@ var IsoBoxReadView = class IsoBoxReadView {
|
|
|
626
597
|
constructor(raw, config) {
|
|
627
598
|
this.truncated = false;
|
|
628
599
|
this.slice = (offset, size) => {
|
|
629
|
-
const
|
|
600
|
+
const dataView = new DataView(this.dataView.buffer, offset, size);
|
|
601
|
+
const isoView = new IsoBoxReadView(dataView, this.config);
|
|
630
602
|
const headerSize = this.offset - offset;
|
|
631
603
|
const bodySize = size - headerSize;
|
|
632
604
|
this.offset += bodySize;
|
|
@@ -641,7 +613,7 @@ var IsoBoxReadView = class IsoBoxReadView {
|
|
|
641
613
|
case UINT:
|
|
642
614
|
result = readUint(dataView, offset, size);
|
|
643
615
|
break;
|
|
644
|
-
case
|
|
616
|
+
case "int":
|
|
645
617
|
result = readInt(dataView, offset, size);
|
|
646
618
|
break;
|
|
647
619
|
case TEMPLATE:
|
|
@@ -672,7 +644,7 @@ var IsoBoxReadView = class IsoBoxReadView {
|
|
|
672
644
|
return this.read(UINT, size);
|
|
673
645
|
};
|
|
674
646
|
this.readInt = (size) => {
|
|
675
|
-
return this.read(
|
|
647
|
+
return this.read("int", size);
|
|
676
648
|
};
|
|
677
649
|
this.readString = (size) => {
|
|
678
650
|
return this.read(STRING, size);
|
|
@@ -801,7 +773,6 @@ var IsoBoxReadView = class IsoBoxReadView {
|
|
|
801
773
|
}
|
|
802
774
|
}
|
|
803
775
|
};
|
|
804
|
-
|
|
805
776
|
//#endregion
|
|
806
777
|
//#region src/readIsoBoxes.ts
|
|
807
778
|
function readIsoBoxes(raw, config) {
|
|
@@ -809,7 +780,6 @@ function readIsoBoxes(raw, config) {
|
|
|
809
780
|
for (const box of new IsoBoxReadView(raw, config)) boxes.push(box);
|
|
810
781
|
return boxes;
|
|
811
782
|
}
|
|
812
|
-
|
|
813
783
|
//#endregion
|
|
814
784
|
//#region src/writeIsoBoxes.ts
|
|
815
785
|
/**
|
|
@@ -828,7 +798,6 @@ function readIsoBoxes(raw, config) {
|
|
|
828
798
|
function writeIsoBoxes(boxes, config) {
|
|
829
799
|
return writeBoxes(boxes, createWriterConfig(config));
|
|
830
800
|
}
|
|
831
|
-
|
|
832
801
|
//#endregion
|
|
833
802
|
//#region src/readers/readAudioSampleEntryBox.ts
|
|
834
803
|
/**
|
|
@@ -842,21 +811,20 @@ function writeIsoBoxes(boxes, config) {
|
|
|
842
811
|
* @public
|
|
843
812
|
*/
|
|
844
813
|
function readAudioSampleEntryBox(type, view) {
|
|
845
|
-
const { readArray, readUint
|
|
814
|
+
const { readArray, readUint, readTemplate, readBoxes } = view;
|
|
846
815
|
return {
|
|
847
816
|
type,
|
|
848
817
|
reserved1: readArray(UINT, 1, 6),
|
|
849
|
-
dataReferenceIndex: readUint
|
|
818
|
+
dataReferenceIndex: readUint(2),
|
|
850
819
|
reserved2: readArray(UINT, 4, 2),
|
|
851
|
-
channelcount: readUint
|
|
852
|
-
samplesize: readUint
|
|
853
|
-
preDefined: readUint
|
|
854
|
-
reserved3: readUint
|
|
855
|
-
samplerate: readTemplate
|
|
820
|
+
channelcount: readUint(2),
|
|
821
|
+
samplesize: readUint(2),
|
|
822
|
+
preDefined: readUint(2),
|
|
823
|
+
reserved3: readUint(2),
|
|
824
|
+
samplerate: readTemplate(4),
|
|
856
825
|
boxes: readBoxes()
|
|
857
826
|
};
|
|
858
827
|
}
|
|
859
|
-
|
|
860
828
|
//#endregion
|
|
861
829
|
//#region src/readers/createAudioSampleEntryReader.ts
|
|
862
830
|
/**
|
|
@@ -884,7 +852,6 @@ function readAudioSampleEntryBox(type, view) {
|
|
|
884
852
|
function createAudioSampleEntryReader(type) {
|
|
885
853
|
return (view) => readAudioSampleEntryBox(type, view);
|
|
886
854
|
}
|
|
887
|
-
|
|
888
855
|
//#endregion
|
|
889
856
|
//#region src/readers/readVisualSampleEntryBox.ts
|
|
890
857
|
/**
|
|
@@ -898,27 +865,26 @@ function createAudioSampleEntryReader(type) {
|
|
|
898
865
|
* @public
|
|
899
866
|
*/
|
|
900
867
|
function readVisualSampleEntryBox(type, view) {
|
|
901
|
-
const { readArray, readUint
|
|
868
|
+
const { readArray, readUint, readInt, readTemplate, readBoxes } = view;
|
|
902
869
|
return {
|
|
903
870
|
type,
|
|
904
871
|
reserved1: readArray(UINT, 1, 6),
|
|
905
|
-
dataReferenceIndex: readUint
|
|
906
|
-
preDefined1: readUint
|
|
907
|
-
reserved2: readUint
|
|
872
|
+
dataReferenceIndex: readUint(2),
|
|
873
|
+
preDefined1: readUint(2),
|
|
874
|
+
reserved2: readUint(2),
|
|
908
875
|
preDefined2: readArray(UINT, 4, 3),
|
|
909
|
-
width: readUint
|
|
910
|
-
height: readUint
|
|
911
|
-
horizresolution: readTemplate
|
|
912
|
-
vertresolution: readTemplate
|
|
913
|
-
reserved3: readUint
|
|
914
|
-
frameCount: readUint
|
|
876
|
+
width: readUint(2),
|
|
877
|
+
height: readUint(2),
|
|
878
|
+
horizresolution: readTemplate(4),
|
|
879
|
+
vertresolution: readTemplate(4),
|
|
880
|
+
reserved3: readUint(4),
|
|
881
|
+
frameCount: readUint(2),
|
|
915
882
|
compressorName: readArray(UINT, 1, 32),
|
|
916
|
-
depth: readUint
|
|
917
|
-
preDefined3: readInt
|
|
883
|
+
depth: readUint(2),
|
|
884
|
+
preDefined3: readInt(2),
|
|
918
885
|
boxes: readBoxes()
|
|
919
886
|
};
|
|
920
887
|
}
|
|
921
|
-
|
|
922
888
|
//#endregion
|
|
923
889
|
//#region src/readers/createVisualSampleEntryReader.ts
|
|
924
890
|
/**
|
|
@@ -946,7 +912,6 @@ function readVisualSampleEntryBox(type, view) {
|
|
|
946
912
|
function createVisualSampleEntryReader(type) {
|
|
947
913
|
return (view) => readVisualSampleEntryBox(type, view);
|
|
948
914
|
}
|
|
949
|
-
|
|
950
915
|
//#endregion
|
|
951
916
|
//#region src/readers/readArdi.ts
|
|
952
917
|
/**
|
|
@@ -965,7 +930,6 @@ function readArdi(view) {
|
|
|
965
930
|
audioRenderingIndication: view.readUint(1)
|
|
966
931
|
};
|
|
967
932
|
}
|
|
968
|
-
|
|
969
933
|
//#endregion
|
|
970
934
|
//#region src/readers/readAvc1.ts
|
|
971
935
|
/**
|
|
@@ -980,7 +944,6 @@ function readArdi(view) {
|
|
|
980
944
|
function readAvc1(view) {
|
|
981
945
|
return readVisualSampleEntryBox("avc1", view);
|
|
982
946
|
}
|
|
983
|
-
|
|
984
947
|
//#endregion
|
|
985
948
|
//#region src/readers/readAvc2.ts
|
|
986
949
|
/**
|
|
@@ -995,7 +958,6 @@ function readAvc1(view) {
|
|
|
995
958
|
function readAvc2(view) {
|
|
996
959
|
return readVisualSampleEntryBox("avc2", view);
|
|
997
960
|
}
|
|
998
|
-
|
|
999
961
|
//#endregion
|
|
1000
962
|
//#region src/readers/readAvc3.ts
|
|
1001
963
|
/**
|
|
@@ -1010,7 +972,6 @@ function readAvc2(view) {
|
|
|
1010
972
|
function readAvc3(view) {
|
|
1011
973
|
return readVisualSampleEntryBox("avc3", view);
|
|
1012
974
|
}
|
|
1013
|
-
|
|
1014
975
|
//#endregion
|
|
1015
976
|
//#region src/readers/readAvc4.ts
|
|
1016
977
|
/**
|
|
@@ -1025,7 +986,6 @@ function readAvc3(view) {
|
|
|
1025
986
|
function readAvc4(view) {
|
|
1026
987
|
return readVisualSampleEntryBox("avc4", view);
|
|
1027
988
|
}
|
|
1028
|
-
|
|
1029
989
|
//#endregion
|
|
1030
990
|
//#region src/readers/readCtts.ts
|
|
1031
991
|
/**
|
|
@@ -1052,7 +1012,6 @@ function readCtts(view) {
|
|
|
1052
1012
|
}))
|
|
1053
1013
|
};
|
|
1054
1014
|
}
|
|
1055
|
-
|
|
1056
1015
|
//#endregion
|
|
1057
1016
|
//#region src/readers/readDref.ts
|
|
1058
1017
|
/**
|
|
@@ -1075,7 +1034,6 @@ function readDref(view) {
|
|
|
1075
1034
|
entries: view.readBoxes(entryCount)
|
|
1076
1035
|
};
|
|
1077
1036
|
}
|
|
1078
|
-
|
|
1079
1037
|
//#endregion
|
|
1080
1038
|
//#region src/readers/readElng.ts
|
|
1081
1039
|
/**
|
|
@@ -1094,7 +1052,6 @@ function readElng(view) {
|
|
|
1094
1052
|
extendedLanguage: view.readUtf8(-1)
|
|
1095
1053
|
};
|
|
1096
1054
|
}
|
|
1097
|
-
|
|
1098
1055
|
//#endregion
|
|
1099
1056
|
//#region src/readers/readElst.ts
|
|
1100
1057
|
/**
|
|
@@ -1123,7 +1080,6 @@ function readElst(view) {
|
|
|
1123
1080
|
}))
|
|
1124
1081
|
};
|
|
1125
1082
|
}
|
|
1126
|
-
|
|
1127
1083
|
//#endregion
|
|
1128
1084
|
//#region src/readers/readEmsg.ts
|
|
1129
1085
|
/**
|
|
@@ -1136,34 +1092,33 @@ function readElst(view) {
|
|
|
1136
1092
|
* @public
|
|
1137
1093
|
*/
|
|
1138
1094
|
function readEmsg(view) {
|
|
1139
|
-
const { readUint
|
|
1095
|
+
const { readUint, readString, readData } = view;
|
|
1140
1096
|
const { version, flags } = view.readFullBox();
|
|
1141
1097
|
if (version === 1) return {
|
|
1142
1098
|
type: "emsg",
|
|
1143
1099
|
version: 1,
|
|
1144
1100
|
flags,
|
|
1145
|
-
timescale: readUint
|
|
1146
|
-
presentationTime: readUint
|
|
1147
|
-
eventDuration: readUint
|
|
1148
|
-
id: readUint
|
|
1149
|
-
schemeIdUri: readString
|
|
1150
|
-
value: readString
|
|
1151
|
-
messageData: readData
|
|
1101
|
+
timescale: readUint(4),
|
|
1102
|
+
presentationTime: readUint(8),
|
|
1103
|
+
eventDuration: readUint(4),
|
|
1104
|
+
id: readUint(4),
|
|
1105
|
+
schemeIdUri: readString(-1),
|
|
1106
|
+
value: readString(-1),
|
|
1107
|
+
messageData: readData(-1)
|
|
1152
1108
|
};
|
|
1153
1109
|
return {
|
|
1154
1110
|
type: "emsg",
|
|
1155
1111
|
version: 0,
|
|
1156
1112
|
flags,
|
|
1157
|
-
schemeIdUri: readString
|
|
1158
|
-
value: readString
|
|
1159
|
-
timescale: readUint
|
|
1160
|
-
presentationTimeDelta: readUint
|
|
1161
|
-
eventDuration: readUint
|
|
1162
|
-
id: readUint
|
|
1163
|
-
messageData: readData
|
|
1113
|
+
schemeIdUri: readString(-1),
|
|
1114
|
+
value: readString(-1),
|
|
1115
|
+
timescale: readUint(4),
|
|
1116
|
+
presentationTimeDelta: readUint(4),
|
|
1117
|
+
eventDuration: readUint(4),
|
|
1118
|
+
id: readUint(4),
|
|
1119
|
+
messageData: readData(-1)
|
|
1164
1120
|
};
|
|
1165
1121
|
}
|
|
1166
|
-
|
|
1167
1122
|
//#endregion
|
|
1168
1123
|
//#region src/readers/readEnca.ts
|
|
1169
1124
|
/**
|
|
@@ -1178,7 +1133,6 @@ function readEmsg(view) {
|
|
|
1178
1133
|
function readEnca(view) {
|
|
1179
1134
|
return readAudioSampleEntryBox("enca", view);
|
|
1180
1135
|
}
|
|
1181
|
-
|
|
1182
1136
|
//#endregion
|
|
1183
1137
|
//#region src/readers/readEncv.ts
|
|
1184
1138
|
/**
|
|
@@ -1193,7 +1147,6 @@ function readEnca(view) {
|
|
|
1193
1147
|
function readEncv(view) {
|
|
1194
1148
|
return readVisualSampleEntryBox("encv", view);
|
|
1195
1149
|
}
|
|
1196
|
-
|
|
1197
1150
|
//#endregion
|
|
1198
1151
|
//#region src/readers/readFree.ts
|
|
1199
1152
|
/**
|
|
@@ -1211,7 +1164,6 @@ function readFree(view) {
|
|
|
1211
1164
|
data: view.readData(-1)
|
|
1212
1165
|
};
|
|
1213
1166
|
}
|
|
1214
|
-
|
|
1215
1167
|
//#endregion
|
|
1216
1168
|
//#region src/readers/readFrma.ts
|
|
1217
1169
|
/**
|
|
@@ -1229,7 +1181,6 @@ function readFrma(view) {
|
|
|
1229
1181
|
dataFormat: view.readUint(4)
|
|
1230
1182
|
};
|
|
1231
1183
|
}
|
|
1232
|
-
|
|
1233
1184
|
//#endregion
|
|
1234
1185
|
//#region src/readers/readFtyp.ts
|
|
1235
1186
|
/**
|
|
@@ -1253,7 +1204,6 @@ function readFtyp(view) {
|
|
|
1253
1204
|
compatibleBrands: view.readArray(STRING, size, length)
|
|
1254
1205
|
};
|
|
1255
1206
|
}
|
|
1256
|
-
|
|
1257
1207
|
//#endregion
|
|
1258
1208
|
//#region src/readers/readHdlr.ts
|
|
1259
1209
|
/**
|
|
@@ -1275,7 +1225,6 @@ function readHdlr(view) {
|
|
|
1275
1225
|
name: view.readString(-1)
|
|
1276
1226
|
};
|
|
1277
1227
|
}
|
|
1278
|
-
|
|
1279
1228
|
//#endregion
|
|
1280
1229
|
//#region src/readers/readHev1.ts
|
|
1281
1230
|
/**
|
|
@@ -1290,7 +1239,6 @@ function readHdlr(view) {
|
|
|
1290
1239
|
function readHev1(view) {
|
|
1291
1240
|
return readVisualSampleEntryBox("hev1", view);
|
|
1292
1241
|
}
|
|
1293
|
-
|
|
1294
1242
|
//#endregion
|
|
1295
1243
|
//#region src/readers/readHvc1.ts
|
|
1296
1244
|
/**
|
|
@@ -1305,7 +1253,6 @@ function readHev1(view) {
|
|
|
1305
1253
|
function readHvc1(view) {
|
|
1306
1254
|
return readVisualSampleEntryBox("hvc1", view);
|
|
1307
1255
|
}
|
|
1308
|
-
|
|
1309
1256
|
//#endregion
|
|
1310
1257
|
//#region src/readers/readIden.ts
|
|
1311
1258
|
/**
|
|
@@ -1323,7 +1270,6 @@ function readIden(view) {
|
|
|
1323
1270
|
cueId: view.readUtf8(-1)
|
|
1324
1271
|
};
|
|
1325
1272
|
}
|
|
1326
|
-
|
|
1327
1273
|
//#endregion
|
|
1328
1274
|
//#region src/readers/readImda.ts
|
|
1329
1275
|
/**
|
|
@@ -1342,7 +1288,6 @@ function readImda(view) {
|
|
|
1342
1288
|
data: view.readData(-1)
|
|
1343
1289
|
};
|
|
1344
1290
|
}
|
|
1345
|
-
|
|
1346
1291
|
//#endregion
|
|
1347
1292
|
//#region src/readers/readKind.ts
|
|
1348
1293
|
/**
|
|
@@ -1362,7 +1307,6 @@ function readKind(view) {
|
|
|
1362
1307
|
value: view.readUtf8(-1)
|
|
1363
1308
|
};
|
|
1364
1309
|
}
|
|
1365
|
-
|
|
1366
1310
|
//#endregion
|
|
1367
1311
|
//#region src/readers/readLabl.ts
|
|
1368
1312
|
/**
|
|
@@ -1386,7 +1330,6 @@ function readLabl(view) {
|
|
|
1386
1330
|
label: view.readUtf8(-1)
|
|
1387
1331
|
};
|
|
1388
1332
|
}
|
|
1389
|
-
|
|
1390
1333
|
//#endregion
|
|
1391
1334
|
//#region src/readers/readMdat.ts
|
|
1392
1335
|
/**
|
|
@@ -1404,7 +1347,6 @@ function readMdat(view) {
|
|
|
1404
1347
|
data: view.readData(-1)
|
|
1405
1348
|
};
|
|
1406
1349
|
}
|
|
1407
|
-
|
|
1408
1350
|
//#endregion
|
|
1409
1351
|
//#region src/readers/readMdhd.ts
|
|
1410
1352
|
/**
|
|
@@ -1435,7 +1377,6 @@ function readMdhd(view) {
|
|
|
1435
1377
|
preDefined: view.readUint(2)
|
|
1436
1378
|
};
|
|
1437
1379
|
}
|
|
1438
|
-
|
|
1439
1380
|
//#endregion
|
|
1440
1381
|
//#region src/readers/readMehd.ts
|
|
1441
1382
|
/**
|
|
@@ -1456,7 +1397,6 @@ function readMehd(view) {
|
|
|
1456
1397
|
fragmentDuration: view.readUint(version === 1 ? 8 : 4)
|
|
1457
1398
|
};
|
|
1458
1399
|
}
|
|
1459
|
-
|
|
1460
1400
|
//#endregion
|
|
1461
1401
|
//#region src/readers/readMeta.ts
|
|
1462
1402
|
/**
|
|
@@ -1475,7 +1415,6 @@ function readMeta(view) {
|
|
|
1475
1415
|
boxes: view.readBoxes()
|
|
1476
1416
|
};
|
|
1477
1417
|
}
|
|
1478
|
-
|
|
1479
1418
|
//#endregion
|
|
1480
1419
|
//#region src/readers/readMfhd.ts
|
|
1481
1420
|
/**
|
|
@@ -1494,7 +1433,6 @@ function readMfhd(view) {
|
|
|
1494
1433
|
sequenceNumber: view.readUint(4)
|
|
1495
1434
|
};
|
|
1496
1435
|
}
|
|
1497
|
-
|
|
1498
1436
|
//#endregion
|
|
1499
1437
|
//#region src/readers/readMfro.ts
|
|
1500
1438
|
/**
|
|
@@ -1513,7 +1451,6 @@ function readMfro(view) {
|
|
|
1513
1451
|
mfraSize: view.readUint(4)
|
|
1514
1452
|
};
|
|
1515
1453
|
}
|
|
1516
|
-
|
|
1517
1454
|
//#endregion
|
|
1518
1455
|
//#region src/readers/readMp4a.ts
|
|
1519
1456
|
/**
|
|
@@ -1528,7 +1465,6 @@ function readMfro(view) {
|
|
|
1528
1465
|
function readMp4a(view) {
|
|
1529
1466
|
return readAudioSampleEntryBox("mp4a", view);
|
|
1530
1467
|
}
|
|
1531
|
-
|
|
1532
1468
|
//#endregion
|
|
1533
1469
|
//#region src/readers/readMvhd.ts
|
|
1534
1470
|
/**
|
|
@@ -1541,27 +1477,26 @@ function readMp4a(view) {
|
|
|
1541
1477
|
* @public
|
|
1542
1478
|
*/
|
|
1543
1479
|
function readMvhd(view) {
|
|
1544
|
-
const { readUint
|
|
1480
|
+
const { readUint, readTemplate, readArray } = view;
|
|
1545
1481
|
const { version, flags } = view.readFullBox();
|
|
1546
1482
|
const size = version == 1 ? 8 : 4;
|
|
1547
1483
|
return {
|
|
1548
1484
|
type: "mvhd",
|
|
1549
1485
|
version,
|
|
1550
1486
|
flags,
|
|
1551
|
-
creationTime: readUint
|
|
1552
|
-
modificationTime: readUint
|
|
1553
|
-
timescale: readUint
|
|
1554
|
-
duration: readUint
|
|
1555
|
-
rate: readTemplate
|
|
1556
|
-
volume: readTemplate
|
|
1557
|
-
reserved1: readUint
|
|
1487
|
+
creationTime: readUint(size),
|
|
1488
|
+
modificationTime: readUint(size),
|
|
1489
|
+
timescale: readUint(4),
|
|
1490
|
+
duration: readUint(size),
|
|
1491
|
+
rate: readTemplate(4),
|
|
1492
|
+
volume: readTemplate(2),
|
|
1493
|
+
reserved1: readUint(2),
|
|
1558
1494
|
reserved2: readArray(UINT, 4, 2),
|
|
1559
1495
|
matrix: readArray(TEMPLATE, 4, 9),
|
|
1560
1496
|
preDefined: readArray(UINT, 4, 6),
|
|
1561
|
-
nextTrackId: readUint
|
|
1497
|
+
nextTrackId: readUint(4)
|
|
1562
1498
|
};
|
|
1563
1499
|
}
|
|
1564
|
-
|
|
1565
1500
|
//#endregion
|
|
1566
1501
|
//#region src/readers/readPayl.ts
|
|
1567
1502
|
/**
|
|
@@ -1579,7 +1514,6 @@ function readPayl(view) {
|
|
|
1579
1514
|
cueText: view.readUtf8(-1)
|
|
1580
1515
|
};
|
|
1581
1516
|
}
|
|
1582
|
-
|
|
1583
1517
|
//#endregion
|
|
1584
1518
|
//#region src/readers/readPrft.ts
|
|
1585
1519
|
/**
|
|
@@ -1603,7 +1537,6 @@ function readPrft(view) {
|
|
|
1603
1537
|
mediaTime: view.readUint(version === 1 ? 8 : 4)
|
|
1604
1538
|
};
|
|
1605
1539
|
}
|
|
1606
|
-
|
|
1607
1540
|
//#endregion
|
|
1608
1541
|
//#region src/readers/readPrsl.ts
|
|
1609
1542
|
/**
|
|
@@ -1632,7 +1565,6 @@ function readPrsl(view) {
|
|
|
1632
1565
|
boxes: view.readBoxes()
|
|
1633
1566
|
};
|
|
1634
1567
|
}
|
|
1635
|
-
|
|
1636
1568
|
//#endregion
|
|
1637
1569
|
//#region src/readers/readPssh.ts
|
|
1638
1570
|
/**
|
|
@@ -1645,16 +1577,16 @@ function readPrsl(view) {
|
|
|
1645
1577
|
* @public
|
|
1646
1578
|
*/
|
|
1647
1579
|
function readPssh(view) {
|
|
1648
|
-
const { readUint
|
|
1580
|
+
const { readUint, readArray } = view;
|
|
1649
1581
|
const { version, flags } = view.readFullBox();
|
|
1650
1582
|
const systemId = readArray(UINT, 1, 16);
|
|
1651
1583
|
let kidCount = 0;
|
|
1652
1584
|
let kid = [];
|
|
1653
1585
|
if (version > 0) {
|
|
1654
|
-
kidCount = readUint
|
|
1586
|
+
kidCount = readUint(4);
|
|
1655
1587
|
kid = readArray(UINT, 1, kidCount);
|
|
1656
1588
|
}
|
|
1657
|
-
const dataSize = readUint
|
|
1589
|
+
const dataSize = readUint(4);
|
|
1658
1590
|
const data = readArray(UINT, 1, dataSize);
|
|
1659
1591
|
return {
|
|
1660
1592
|
type: "pssh",
|
|
@@ -1667,7 +1599,6 @@ function readPssh(view) {
|
|
|
1667
1599
|
data
|
|
1668
1600
|
};
|
|
1669
1601
|
}
|
|
1670
|
-
|
|
1671
1602
|
//#endregion
|
|
1672
1603
|
//#region src/readers/readSchm.ts
|
|
1673
1604
|
/**
|
|
@@ -1690,7 +1621,6 @@ function readSchm(view) {
|
|
|
1690
1621
|
schemeUri: flags & 1 ? view.readString(-1) : void 0
|
|
1691
1622
|
};
|
|
1692
1623
|
}
|
|
1693
|
-
|
|
1694
1624
|
//#endregion
|
|
1695
1625
|
//#region src/readers/readSdtp.ts
|
|
1696
1626
|
/**
|
|
@@ -1709,7 +1639,6 @@ function readSdtp(view) {
|
|
|
1709
1639
|
sampleDependencyTable: view.readArray(UINT, 1, view.bytesRemaining)
|
|
1710
1640
|
};
|
|
1711
1641
|
}
|
|
1712
|
-
|
|
1713
1642
|
//#endregion
|
|
1714
1643
|
//#region src/readers/readSidx.ts
|
|
1715
1644
|
/**
|
|
@@ -1722,15 +1651,15 @@ function readSdtp(view) {
|
|
|
1722
1651
|
* @public
|
|
1723
1652
|
*/
|
|
1724
1653
|
function readSidx(view) {
|
|
1725
|
-
const { readUint
|
|
1654
|
+
const { readUint } = view;
|
|
1726
1655
|
const { version, flags } = view.readFullBox();
|
|
1727
1656
|
const size = version === 1 ? 8 : 4;
|
|
1728
|
-
const referenceId = readUint
|
|
1729
|
-
const timescale = readUint
|
|
1730
|
-
const earliestPresentationTime = readUint
|
|
1731
|
-
const firstOffset = readUint
|
|
1732
|
-
const reserved = readUint
|
|
1733
|
-
const referenceCount = readUint
|
|
1657
|
+
const referenceId = readUint(4);
|
|
1658
|
+
const timescale = readUint(4);
|
|
1659
|
+
const earliestPresentationTime = readUint(size);
|
|
1660
|
+
const firstOffset = readUint(size);
|
|
1661
|
+
const reserved = readUint(2);
|
|
1662
|
+
const referenceCount = readUint(2);
|
|
1734
1663
|
return {
|
|
1735
1664
|
type: "sidx",
|
|
1736
1665
|
version,
|
|
@@ -1742,9 +1671,9 @@ function readSidx(view) {
|
|
|
1742
1671
|
reserved,
|
|
1743
1672
|
references: view.readEntries(referenceCount, () => {
|
|
1744
1673
|
const entry = {};
|
|
1745
|
-
entry.reference = readUint
|
|
1746
|
-
entry.subsegmentDuration = readUint
|
|
1747
|
-
entry.sap = readUint
|
|
1674
|
+
entry.reference = readUint(4);
|
|
1675
|
+
entry.subsegmentDuration = readUint(4);
|
|
1676
|
+
entry.sap = readUint(4);
|
|
1748
1677
|
entry.referenceType = entry.reference >> 31 & 1;
|
|
1749
1678
|
entry.referencedSize = entry.reference & 2147483647;
|
|
1750
1679
|
entry.startsWithSap = entry.sap >> 31 & 1;
|
|
@@ -1754,7 +1683,6 @@ function readSidx(view) {
|
|
|
1754
1683
|
})
|
|
1755
1684
|
};
|
|
1756
1685
|
}
|
|
1757
|
-
|
|
1758
1686
|
//#endregion
|
|
1759
1687
|
//#region src/readers/readSkip.ts
|
|
1760
1688
|
/**
|
|
@@ -1772,7 +1700,6 @@ function readSkip(view) {
|
|
|
1772
1700
|
type: "skip"
|
|
1773
1701
|
};
|
|
1774
1702
|
}
|
|
1775
|
-
|
|
1776
1703
|
//#endregion
|
|
1777
1704
|
//#region src/readers/readSmhd.ts
|
|
1778
1705
|
/**
|
|
@@ -1792,7 +1719,6 @@ function readSmhd(view) {
|
|
|
1792
1719
|
reserved: view.readUint(2)
|
|
1793
1720
|
};
|
|
1794
1721
|
}
|
|
1795
|
-
|
|
1796
1722
|
//#endregion
|
|
1797
1723
|
//#region src/readers/readSsix.ts
|
|
1798
1724
|
/**
|
|
@@ -1824,7 +1750,6 @@ function readSsix(view) {
|
|
|
1824
1750
|
})
|
|
1825
1751
|
};
|
|
1826
1752
|
}
|
|
1827
|
-
|
|
1828
1753
|
//#endregion
|
|
1829
1754
|
//#region src/readers/readSthd.ts
|
|
1830
1755
|
/**
|
|
@@ -1842,7 +1767,6 @@ function readSthd(view) {
|
|
|
1842
1767
|
...view.readFullBox()
|
|
1843
1768
|
};
|
|
1844
1769
|
}
|
|
1845
|
-
|
|
1846
1770
|
//#endregion
|
|
1847
1771
|
//#region src/readers/readStsd.ts
|
|
1848
1772
|
/**
|
|
@@ -1865,7 +1789,6 @@ function readStsd(view) {
|
|
|
1865
1789
|
entries: view.readBoxes(entryCount)
|
|
1866
1790
|
};
|
|
1867
1791
|
}
|
|
1868
|
-
|
|
1869
1792
|
//#endregion
|
|
1870
1793
|
//#region src/readers/readStss.ts
|
|
1871
1794
|
/**
|
|
@@ -1888,7 +1811,6 @@ function readStss(view) {
|
|
|
1888
1811
|
entries: view.readEntries(entryCount, () => ({ sampleNumber: view.readUint(4) }))
|
|
1889
1812
|
};
|
|
1890
1813
|
}
|
|
1891
|
-
|
|
1892
1814
|
//#endregion
|
|
1893
1815
|
//#region src/readers/readSttg.ts
|
|
1894
1816
|
/**
|
|
@@ -1906,7 +1828,6 @@ function readSttg(view) {
|
|
|
1906
1828
|
settings: view.readUtf8(-1)
|
|
1907
1829
|
};
|
|
1908
1830
|
}
|
|
1909
|
-
|
|
1910
1831
|
//#endregion
|
|
1911
1832
|
//#region src/readers/readStts.ts
|
|
1912
1833
|
/**
|
|
@@ -1932,7 +1853,6 @@ function readStts(view) {
|
|
|
1932
1853
|
}))
|
|
1933
1854
|
};
|
|
1934
1855
|
}
|
|
1935
|
-
|
|
1936
1856
|
//#endregion
|
|
1937
1857
|
//#region src/readers/readStyp.ts
|
|
1938
1858
|
/**
|
|
@@ -1950,7 +1870,6 @@ function readStyp(view) {
|
|
|
1950
1870
|
type: "styp"
|
|
1951
1871
|
};
|
|
1952
1872
|
}
|
|
1953
|
-
|
|
1954
1873
|
//#endregion
|
|
1955
1874
|
//#region src/readers/readSubs.ts
|
|
1956
1875
|
/**
|
|
@@ -1986,7 +1905,6 @@ function readSubs(view) {
|
|
|
1986
1905
|
})
|
|
1987
1906
|
};
|
|
1988
1907
|
}
|
|
1989
|
-
|
|
1990
1908
|
//#endregion
|
|
1991
1909
|
//#region src/readers/readTenc.ts
|
|
1992
1910
|
/**
|
|
@@ -2007,7 +1925,6 @@ function readTenc(view) {
|
|
|
2007
1925
|
defaultKid: view.readArray(UINT, 1, 16)
|
|
2008
1926
|
};
|
|
2009
1927
|
}
|
|
2010
|
-
|
|
2011
1928
|
//#endregion
|
|
2012
1929
|
//#region src/readers/readTfdt.ts
|
|
2013
1930
|
/**
|
|
@@ -2028,7 +1945,6 @@ function readTfdt(view) {
|
|
|
2028
1945
|
baseMediaDecodeTime: view.readUint(version == 1 ? 8 : 4)
|
|
2029
1946
|
};
|
|
2030
1947
|
}
|
|
2031
|
-
|
|
2032
1948
|
//#endregion
|
|
2033
1949
|
//#region src/readers/readTfhd.ts
|
|
2034
1950
|
/**
|
|
@@ -2054,7 +1970,6 @@ function readTfhd(view) {
|
|
|
2054
1970
|
defaultSampleFlags: flags & 32 ? view.readUint(4) : void 0
|
|
2055
1971
|
};
|
|
2056
1972
|
}
|
|
2057
|
-
|
|
2058
1973
|
//#endregion
|
|
2059
1974
|
//#region src/readers/readTfra.ts
|
|
2060
1975
|
/**
|
|
@@ -2093,7 +2008,6 @@ function readTfra(view) {
|
|
|
2093
2008
|
}))
|
|
2094
2009
|
};
|
|
2095
2010
|
}
|
|
2096
|
-
|
|
2097
2011
|
//#endregion
|
|
2098
2012
|
//#region src/readers/readTkhd.ts
|
|
2099
2013
|
/**
|
|
@@ -2127,7 +2041,6 @@ function readTkhd(view) {
|
|
|
2127
2041
|
height: view.readTemplate(4)
|
|
2128
2042
|
};
|
|
2129
2043
|
}
|
|
2130
|
-
|
|
2131
2044
|
//#endregion
|
|
2132
2045
|
//#region src/readers/readTrex.ts
|
|
2133
2046
|
/**
|
|
@@ -2150,7 +2063,6 @@ function readTrex(view) {
|
|
|
2150
2063
|
defaultSampleFlags: view.readUint(4)
|
|
2151
2064
|
};
|
|
2152
2065
|
}
|
|
2153
|
-
|
|
2154
2066
|
//#endregion
|
|
2155
2067
|
//#region src/readers/readTrun.ts
|
|
2156
2068
|
/**
|
|
@@ -2187,7 +2099,6 @@ function readTrun(view) {
|
|
|
2187
2099
|
samples
|
|
2188
2100
|
};
|
|
2189
2101
|
}
|
|
2190
|
-
|
|
2191
2102
|
//#endregion
|
|
2192
2103
|
//#region src/readers/readUrl.ts
|
|
2193
2104
|
/**
|
|
@@ -2206,7 +2117,6 @@ function readUrl(view) {
|
|
|
2206
2117
|
location: view.readString(-1)
|
|
2207
2118
|
};
|
|
2208
2119
|
}
|
|
2209
|
-
|
|
2210
2120
|
//#endregion
|
|
2211
2121
|
//#region src/readers/readUrn.ts
|
|
2212
2122
|
/**
|
|
@@ -2226,7 +2136,6 @@ function readUrn(view) {
|
|
|
2226
2136
|
location: view.readString(-1)
|
|
2227
2137
|
};
|
|
2228
2138
|
}
|
|
2229
|
-
|
|
2230
2139
|
//#endregion
|
|
2231
2140
|
//#region src/readers/readVlab.ts
|
|
2232
2141
|
/**
|
|
@@ -2244,7 +2153,6 @@ function readVlab(view) {
|
|
|
2244
2153
|
sourceLabel: view.readUtf8(-1)
|
|
2245
2154
|
};
|
|
2246
2155
|
}
|
|
2247
|
-
|
|
2248
2156
|
//#endregion
|
|
2249
2157
|
//#region src/readers/readVmhd.ts
|
|
2250
2158
|
/**
|
|
@@ -2264,7 +2172,6 @@ function readVmhd(view) {
|
|
|
2264
2172
|
opcolor: view.readArray(UINT, 2, 3)
|
|
2265
2173
|
};
|
|
2266
2174
|
}
|
|
2267
|
-
|
|
2268
2175
|
//#endregion
|
|
2269
2176
|
//#region src/readers/readVttC.ts
|
|
2270
2177
|
/**
|
|
@@ -2282,7 +2189,6 @@ function readVttC(view) {
|
|
|
2282
2189
|
config: view.readUtf8()
|
|
2283
2190
|
};
|
|
2284
2191
|
}
|
|
2285
|
-
|
|
2286
2192
|
//#endregion
|
|
2287
2193
|
//#region src/readers/readVtte.ts
|
|
2288
2194
|
/**
|
|
@@ -2295,7 +2201,6 @@ function readVttC(view) {
|
|
|
2295
2201
|
function readVtte(_) {
|
|
2296
2202
|
return { type: "vtte" };
|
|
2297
2203
|
}
|
|
2298
|
-
|
|
2299
2204
|
//#endregion
|
|
2300
2205
|
//#region src/readers/defaultReaderConfig.ts
|
|
2301
2206
|
/**
|
|
@@ -2369,7 +2274,6 @@ function defaultReaderConfig() {
|
|
|
2369
2274
|
vtte: readVtte
|
|
2370
2275
|
} };
|
|
2371
2276
|
}
|
|
2372
|
-
|
|
2373
2277
|
//#endregion
|
|
2374
2278
|
//#region src/utils/fourCcToUint32.ts
|
|
2375
2279
|
/**
|
|
@@ -2387,7 +2291,6 @@ function defaultReaderConfig() {
|
|
|
2387
2291
|
function fourCcToUint32(str) {
|
|
2388
2292
|
return (str.charCodeAt(0) << 24 | str.charCodeAt(1) << 16 | str.charCodeAt(2) << 8 | str.charCodeAt(3)) >>> 0;
|
|
2389
2293
|
}
|
|
2390
|
-
|
|
2391
2294
|
//#endregion
|
|
2392
2295
|
//#region src/utils/isFullBox.ts
|
|
2393
2296
|
/**
|
|
@@ -2402,7 +2305,6 @@ function fourCcToUint32(str) {
|
|
|
2402
2305
|
function isFullBox(box) {
|
|
2403
2306
|
return "version" in box && "flags" in box;
|
|
2404
2307
|
}
|
|
2405
|
-
|
|
2406
2308
|
//#endregion
|
|
2407
2309
|
//#region src/writers/writeArdi.ts
|
|
2408
2310
|
/**
|
|
@@ -2420,7 +2322,6 @@ function writeArdi(box) {
|
|
|
2420
2322
|
writer.writeUint(box.audioRenderingIndication, 1);
|
|
2421
2323
|
return writer;
|
|
2422
2324
|
}
|
|
2423
|
-
|
|
2424
2325
|
//#endregion
|
|
2425
2326
|
//#region src/writers/writeVisualSampleEntryBox.ts
|
|
2426
2327
|
/**
|
|
@@ -2436,23 +2337,8 @@ function writeArdi(box) {
|
|
|
2436
2337
|
* @public
|
|
2437
2338
|
*/
|
|
2438
2339
|
function writeVisualSampleEntryBox(box, config) {
|
|
2439
|
-
const headerSize = 8;
|
|
2440
|
-
const reserved1Size = 6;
|
|
2441
|
-
const dataReferenceIndexSize = 2;
|
|
2442
|
-
const preDefined1Size = 2;
|
|
2443
|
-
const reserved2Size = 2;
|
|
2444
|
-
const preDefined2Size = 12;
|
|
2445
|
-
const widthSize = 2;
|
|
2446
|
-
const heightSize = 2;
|
|
2447
|
-
const horizresolutionSize = 4;
|
|
2448
|
-
const vertresolutionSize = 4;
|
|
2449
|
-
const reserved3Size = 4;
|
|
2450
|
-
const frameCountSize = 2;
|
|
2451
|
-
const compressorNameSize = 32;
|
|
2452
|
-
const depthSize = 2;
|
|
2453
|
-
const preDefined3Size = 2;
|
|
2454
2340
|
const { bytes, size } = writeChildBoxes(box.boxes, config);
|
|
2455
|
-
const totalSize =
|
|
2341
|
+
const totalSize = 86 + size;
|
|
2456
2342
|
const writer = new IsoBoxWriteView(box.type, totalSize);
|
|
2457
2343
|
writer.writeArray(box.reserved1, UINT, 1, 6);
|
|
2458
2344
|
writer.writeUint(box.dataReferenceIndex, 2);
|
|
@@ -2471,7 +2357,6 @@ function writeVisualSampleEntryBox(box, config) {
|
|
|
2471
2357
|
writer.writeBytes(bytes);
|
|
2472
2358
|
return writer;
|
|
2473
2359
|
}
|
|
2474
|
-
|
|
2475
2360
|
//#endregion
|
|
2476
2361
|
//#region src/writers/writeAvc1.ts
|
|
2477
2362
|
/**
|
|
@@ -2489,7 +2374,6 @@ function writeVisualSampleEntryBox(box, config) {
|
|
|
2489
2374
|
function writeAvc1(box, config) {
|
|
2490
2375
|
return writeVisualSampleEntryBox(box, config);
|
|
2491
2376
|
}
|
|
2492
|
-
|
|
2493
2377
|
//#endregion
|
|
2494
2378
|
//#region src/writers/writeAvc2.ts
|
|
2495
2379
|
/**
|
|
@@ -2505,7 +2389,6 @@ function writeAvc1(box, config) {
|
|
|
2505
2389
|
function writeAvc2(box, config) {
|
|
2506
2390
|
return writeVisualSampleEntryBox(box, config);
|
|
2507
2391
|
}
|
|
2508
|
-
|
|
2509
2392
|
//#endregion
|
|
2510
2393
|
//#region src/writers/writeAvc3.ts
|
|
2511
2394
|
/**
|
|
@@ -2521,7 +2404,6 @@ function writeAvc2(box, config) {
|
|
|
2521
2404
|
function writeAvc3(box, config) {
|
|
2522
2405
|
return writeVisualSampleEntryBox(box, config);
|
|
2523
2406
|
}
|
|
2524
|
-
|
|
2525
2407
|
//#endregion
|
|
2526
2408
|
//#region src/writers/writeAvc4.ts
|
|
2527
2409
|
/**
|
|
@@ -2537,7 +2419,6 @@ function writeAvc3(box, config) {
|
|
|
2537
2419
|
function writeAvc4(box, config) {
|
|
2538
2420
|
return writeVisualSampleEntryBox(box, config);
|
|
2539
2421
|
}
|
|
2540
|
-
|
|
2541
2422
|
//#endregion
|
|
2542
2423
|
//#region src/writers/writeCtts.ts
|
|
2543
2424
|
/**
|
|
@@ -2552,11 +2433,7 @@ function writeAvc4(box, config) {
|
|
|
2552
2433
|
* @public
|
|
2553
2434
|
*/
|
|
2554
2435
|
function writeCtts(box) {
|
|
2555
|
-
const
|
|
2556
|
-
const fullBoxSize = 4;
|
|
2557
|
-
const entryCountSize = 4;
|
|
2558
|
-
const entriesSize = box.entryCount * 8;
|
|
2559
|
-
const writer = new IsoBoxWriteView("ctts", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
2436
|
+
const writer = new IsoBoxWriteView("ctts", 16 + box.entryCount * 8);
|
|
2560
2437
|
writer.writeFullBox(box.version, box.flags);
|
|
2561
2438
|
writer.writeUint(box.entryCount, 4);
|
|
2562
2439
|
for (const entry of box.entries) {
|
|
@@ -2565,7 +2442,6 @@ function writeCtts(box) {
|
|
|
2565
2442
|
}
|
|
2566
2443
|
return writer;
|
|
2567
2444
|
}
|
|
2568
|
-
|
|
2569
2445
|
//#endregion
|
|
2570
2446
|
//#region src/writers/writeDref.ts
|
|
2571
2447
|
/**
|
|
@@ -2579,18 +2455,14 @@ function writeCtts(box) {
|
|
|
2579
2455
|
* @public
|
|
2580
2456
|
*/
|
|
2581
2457
|
function writeDref(box, config) {
|
|
2582
|
-
const headerSize = 8;
|
|
2583
|
-
const fullBoxSize = 4;
|
|
2584
|
-
const entryCountSize = 4;
|
|
2585
2458
|
const entryCount = box.entries.length;
|
|
2586
2459
|
const { bytes, size } = writeChildBoxes(box.entries, config);
|
|
2587
|
-
const writer = new IsoBoxWriteView("dref",
|
|
2460
|
+
const writer = new IsoBoxWriteView("dref", 16 + size);
|
|
2588
2461
|
writer.writeFullBox(box.version, box.flags);
|
|
2589
2462
|
writer.writeUint(entryCount, 4);
|
|
2590
2463
|
writer.writeBytes(bytes);
|
|
2591
2464
|
return writer;
|
|
2592
2465
|
}
|
|
2593
|
-
|
|
2594
2466
|
//#endregion
|
|
2595
2467
|
//#region src/writers/writeElng.ts
|
|
2596
2468
|
/**
|
|
@@ -2605,16 +2477,11 @@ function writeDref(box, config) {
|
|
|
2605
2477
|
* @public
|
|
2606
2478
|
*/
|
|
2607
2479
|
function writeElng(box) {
|
|
2608
|
-
const
|
|
2609
|
-
const headerSize = 8;
|
|
2610
|
-
const fullBoxSize = 4;
|
|
2611
|
-
const extendedLanguageSize = extendedLanguageBytes.length + 1;
|
|
2612
|
-
const writer = new IsoBoxWriteView("elng", headerSize + fullBoxSize + extendedLanguageSize);
|
|
2480
|
+
const writer = new IsoBoxWriteView("elng", 12 + (encodeText(box.extendedLanguage).length + 1));
|
|
2613
2481
|
writer.writeFullBox(box.version, box.flags);
|
|
2614
2482
|
writer.writeUtf8TerminatedString(box.extendedLanguage);
|
|
2615
2483
|
return writer;
|
|
2616
2484
|
}
|
|
2617
|
-
|
|
2618
2485
|
//#endregion
|
|
2619
2486
|
//#region src/writers/writeElst.ts
|
|
2620
2487
|
/**
|
|
@@ -2630,12 +2497,8 @@ function writeElng(box) {
|
|
|
2630
2497
|
*/
|
|
2631
2498
|
function writeElst(box) {
|
|
2632
2499
|
const size = box.version === 1 ? 8 : 4;
|
|
2633
|
-
const headerSize = 8;
|
|
2634
|
-
const fullBoxSize = 4;
|
|
2635
|
-
const entryCountSize = 4;
|
|
2636
2500
|
const entrySize = size + size + 2 + 2;
|
|
2637
|
-
const
|
|
2638
|
-
const writer = new IsoBoxWriteView("elst", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
2501
|
+
const writer = new IsoBoxWriteView("elst", 16 + box.entryCount * entrySize);
|
|
2639
2502
|
writer.writeFullBox(box.version, box.flags);
|
|
2640
2503
|
writer.writeUint(box.entryCount, 4);
|
|
2641
2504
|
for (const entry of box.entries) {
|
|
@@ -2646,7 +2509,6 @@ function writeElst(box) {
|
|
|
2646
2509
|
}
|
|
2647
2510
|
return writer;
|
|
2648
2511
|
}
|
|
2649
|
-
|
|
2650
2512
|
//#endregion
|
|
2651
2513
|
//#region src/writers/writeEmsg.ts
|
|
2652
2514
|
/**
|
|
@@ -2661,12 +2523,10 @@ function writeElst(box) {
|
|
|
2661
2523
|
* @public
|
|
2662
2524
|
*/
|
|
2663
2525
|
function writeEmsg(box) {
|
|
2664
|
-
const headerSize = 8;
|
|
2665
|
-
const fullBoxSize = 4;
|
|
2666
2526
|
let contentSize;
|
|
2667
2527
|
if (box.version === 0) contentSize = box.schemeIdUri.length + 1 + (box.value.length + 1) + 4 + 4 + 4 + 4 + box.messageData.length;
|
|
2668
2528
|
else contentSize = 20 + (box.schemeIdUri.length + 1) + (box.value.length + 1) + box.messageData.length;
|
|
2669
|
-
const writer = new IsoBoxWriteView("emsg",
|
|
2529
|
+
const writer = new IsoBoxWriteView("emsg", 12 + contentSize);
|
|
2670
2530
|
writer.writeFullBox(box.version, box.flags);
|
|
2671
2531
|
if (box.version === 0) {
|
|
2672
2532
|
writer.writeTerminatedString(box.schemeIdUri);
|
|
@@ -2686,7 +2546,6 @@ function writeEmsg(box) {
|
|
|
2686
2546
|
writer.writeBytes(box.messageData);
|
|
2687
2547
|
return writer;
|
|
2688
2548
|
}
|
|
2689
|
-
|
|
2690
2549
|
//#endregion
|
|
2691
2550
|
//#region src/writers/writeAudioSampleEntryBox.ts
|
|
2692
2551
|
/**
|
|
@@ -2702,17 +2561,8 @@ function writeEmsg(box) {
|
|
|
2702
2561
|
* @public
|
|
2703
2562
|
*/
|
|
2704
2563
|
function writeAudioSampleEntryBox(box, config) {
|
|
2705
|
-
const headerSize = 8;
|
|
2706
|
-
const reserved1Size = 6;
|
|
2707
|
-
const dataReferenceIndexSize = 2;
|
|
2708
|
-
const reserved2Size = 8;
|
|
2709
|
-
const channelcountSize = 2;
|
|
2710
|
-
const samplesizeSize = 2;
|
|
2711
|
-
const preDefinedSize = 2;
|
|
2712
|
-
const reserved3Size = 2;
|
|
2713
|
-
const samplerateSize = 4;
|
|
2714
2564
|
const { bytes, size } = writeChildBoxes(box.boxes, config);
|
|
2715
|
-
const totalSize =
|
|
2565
|
+
const totalSize = 36 + size;
|
|
2716
2566
|
const writer = new IsoBoxWriteView(box.type, totalSize);
|
|
2717
2567
|
writer.writeArray(box.reserved1, UINT, 1, 6);
|
|
2718
2568
|
writer.writeUint(box.dataReferenceIndex, 2);
|
|
@@ -2725,7 +2575,6 @@ function writeAudioSampleEntryBox(box, config) {
|
|
|
2725
2575
|
writer.writeBytes(bytes);
|
|
2726
2576
|
return writer;
|
|
2727
2577
|
}
|
|
2728
|
-
|
|
2729
2578
|
//#endregion
|
|
2730
2579
|
//#region src/writers/writeEnca.ts
|
|
2731
2580
|
/**
|
|
@@ -2741,7 +2590,6 @@ function writeAudioSampleEntryBox(box, config) {
|
|
|
2741
2590
|
function writeEnca(box, config) {
|
|
2742
2591
|
return writeAudioSampleEntryBox(box, config);
|
|
2743
2592
|
}
|
|
2744
|
-
|
|
2745
2593
|
//#endregion
|
|
2746
2594
|
//#region src/writers/writeEncv.ts
|
|
2747
2595
|
/**
|
|
@@ -2757,7 +2605,6 @@ function writeEnca(box, config) {
|
|
|
2757
2605
|
function writeEncv(box, config) {
|
|
2758
2606
|
return writeVisualSampleEntryBox(box, config);
|
|
2759
2607
|
}
|
|
2760
|
-
|
|
2761
2608
|
//#endregion
|
|
2762
2609
|
//#region src/writers/writeFree.ts
|
|
2763
2610
|
/**
|
|
@@ -2776,7 +2623,6 @@ function writeFree(box) {
|
|
|
2776
2623
|
writer.writeBytes(box.data);
|
|
2777
2624
|
return writer;
|
|
2778
2625
|
}
|
|
2779
|
-
|
|
2780
2626
|
//#endregion
|
|
2781
2627
|
//#region src/writers/writeFrma.ts
|
|
2782
2628
|
/**
|
|
@@ -2795,7 +2641,6 @@ function writeFrma(box) {
|
|
|
2795
2641
|
writer.writeUint(box.dataFormat, 4);
|
|
2796
2642
|
return writer;
|
|
2797
2643
|
}
|
|
2798
|
-
|
|
2799
2644
|
//#endregion
|
|
2800
2645
|
//#region src/writers/writeFtyp.ts
|
|
2801
2646
|
/**
|
|
@@ -2810,17 +2655,12 @@ function writeFrma(box) {
|
|
|
2810
2655
|
* @public
|
|
2811
2656
|
*/
|
|
2812
2657
|
function writeFtyp(box) {
|
|
2813
|
-
const
|
|
2814
|
-
const majorBrandSize = 4;
|
|
2815
|
-
const minorVersionSize = 4;
|
|
2816
|
-
const compatibleBrandsSize = box.compatibleBrands.length * 4;
|
|
2817
|
-
const writer = new IsoBoxWriteView("ftyp", headerSize + majorBrandSize + minorVersionSize + compatibleBrandsSize);
|
|
2658
|
+
const writer = new IsoBoxWriteView("ftyp", 16 + box.compatibleBrands.length * 4);
|
|
2818
2659
|
writer.writeString(box.majorBrand);
|
|
2819
2660
|
writer.writeUint(box.minorVersion, 4);
|
|
2820
2661
|
for (const brand of box.compatibleBrands) writer.writeString(brand);
|
|
2821
2662
|
return writer;
|
|
2822
2663
|
}
|
|
2823
|
-
|
|
2824
2664
|
//#endregion
|
|
2825
2665
|
//#region src/writers/writeHdlr.ts
|
|
2826
2666
|
/**
|
|
@@ -2835,13 +2675,7 @@ function writeFtyp(box) {
|
|
|
2835
2675
|
* @public
|
|
2836
2676
|
*/
|
|
2837
2677
|
function writeHdlr(box) {
|
|
2838
|
-
const
|
|
2839
|
-
const fullBoxSize = 4;
|
|
2840
|
-
const preDefinedSize = 4;
|
|
2841
|
-
const handlerTypeSize = 4;
|
|
2842
|
-
const reservedSize = 12;
|
|
2843
|
-
const nameSize = box.name.length + 1;
|
|
2844
|
-
const writer = new IsoBoxWriteView("hdlr", headerSize + fullBoxSize + preDefinedSize + handlerTypeSize + reservedSize + nameSize);
|
|
2678
|
+
const writer = new IsoBoxWriteView("hdlr", 32 + (box.name.length + 1));
|
|
2845
2679
|
writer.writeFullBox(box.version, box.flags);
|
|
2846
2680
|
writer.writeUint(box.preDefined, 4);
|
|
2847
2681
|
writer.writeString(box.handlerType);
|
|
@@ -2849,7 +2683,6 @@ function writeHdlr(box) {
|
|
|
2849
2683
|
writer.writeTerminatedString(box.name);
|
|
2850
2684
|
return writer;
|
|
2851
2685
|
}
|
|
2852
|
-
|
|
2853
2686
|
//#endregion
|
|
2854
2687
|
//#region src/writers/writeHev1.ts
|
|
2855
2688
|
/**
|
|
@@ -2865,7 +2698,6 @@ function writeHdlr(box) {
|
|
|
2865
2698
|
function writeHev1(box, config) {
|
|
2866
2699
|
return writeVisualSampleEntryBox(box, config);
|
|
2867
2700
|
}
|
|
2868
|
-
|
|
2869
2701
|
//#endregion
|
|
2870
2702
|
//#region src/writers/writeHvc1.ts
|
|
2871
2703
|
/**
|
|
@@ -2881,7 +2713,6 @@ function writeHev1(box, config) {
|
|
|
2881
2713
|
function writeHvc1(box, config) {
|
|
2882
2714
|
return writeVisualSampleEntryBox(box, config);
|
|
2883
2715
|
}
|
|
2884
|
-
|
|
2885
2716
|
//#endregion
|
|
2886
2717
|
//#region src/writers/writeIden.ts
|
|
2887
2718
|
/**
|
|
@@ -2898,7 +2729,6 @@ function writeIden(box) {
|
|
|
2898
2729
|
writer.writeUtf8TerminatedString(box.cueId);
|
|
2899
2730
|
return writer;
|
|
2900
2731
|
}
|
|
2901
|
-
|
|
2902
2732
|
//#endregion
|
|
2903
2733
|
//#region src/writers/writeImda.ts
|
|
2904
2734
|
/**
|
|
@@ -2911,15 +2741,11 @@ function writeIden(box) {
|
|
|
2911
2741
|
* @public
|
|
2912
2742
|
*/
|
|
2913
2743
|
function writeImda(box) {
|
|
2914
|
-
const
|
|
2915
|
-
const imdaIdentifierSize = 4;
|
|
2916
|
-
const dataSize = box.data.length;
|
|
2917
|
-
const writer = new IsoBoxWriteView("imda", headerSize + imdaIdentifierSize + dataSize);
|
|
2744
|
+
const writer = new IsoBoxWriteView("imda", 12 + box.data.length);
|
|
2918
2745
|
writer.writeUint(box.imdaIdentifier, 4);
|
|
2919
2746
|
writer.writeBytes(box.data);
|
|
2920
2747
|
return writer;
|
|
2921
2748
|
}
|
|
2922
|
-
|
|
2923
2749
|
//#endregion
|
|
2924
2750
|
//#region src/writers/writeKind.ts
|
|
2925
2751
|
/**
|
|
@@ -2934,17 +2760,14 @@ function writeImda(box) {
|
|
|
2934
2760
|
function writeKind(box) {
|
|
2935
2761
|
const schemeUriBytes = encodeText(box.schemeUri);
|
|
2936
2762
|
const valueBytes = encodeText(box.value);
|
|
2937
|
-
const headerSize = 8;
|
|
2938
|
-
const fullBoxSize = 4;
|
|
2939
2763
|
const schemeUriSize = schemeUriBytes.length + 1;
|
|
2940
2764
|
const valueSize = valueBytes.length + 1;
|
|
2941
|
-
const writer = new IsoBoxWriteView("kind",
|
|
2765
|
+
const writer = new IsoBoxWriteView("kind", 12 + schemeUriSize + valueSize);
|
|
2942
2766
|
writer.writeFullBox(box.version, box.flags);
|
|
2943
2767
|
writer.writeUtf8TerminatedString(box.schemeUri);
|
|
2944
2768
|
writer.writeUtf8TerminatedString(box.value);
|
|
2945
2769
|
return writer;
|
|
2946
2770
|
}
|
|
2947
|
-
|
|
2948
2771
|
//#endregion
|
|
2949
2772
|
//#region src/writers/writeLabl.ts
|
|
2950
2773
|
/**
|
|
@@ -2959,19 +2782,15 @@ function writeKind(box) {
|
|
|
2959
2782
|
function writeLabl(box) {
|
|
2960
2783
|
const languageBytes = encodeText(box.language);
|
|
2961
2784
|
const labelBytes = encodeText(box.label);
|
|
2962
|
-
const headerSize = 8;
|
|
2963
|
-
const fullBoxSize = 4;
|
|
2964
|
-
const labelIdSize = 2;
|
|
2965
2785
|
const languageSize = languageBytes.length + 1;
|
|
2966
2786
|
const labelSize = labelBytes.length + 1;
|
|
2967
|
-
const writer = new IsoBoxWriteView("labl",
|
|
2787
|
+
const writer = new IsoBoxWriteView("labl", 14 + languageSize + labelSize);
|
|
2968
2788
|
writer.writeFullBox(box.version, box.flags);
|
|
2969
2789
|
writer.writeUint(box.labelId, 2);
|
|
2970
2790
|
writer.writeUtf8TerminatedString(box.language);
|
|
2971
2791
|
writer.writeUtf8TerminatedString(box.label);
|
|
2972
2792
|
return writer;
|
|
2973
2793
|
}
|
|
2974
|
-
|
|
2975
2794
|
//#endregion
|
|
2976
2795
|
//#region src/writers/writeMdat.ts
|
|
2977
2796
|
/**
|
|
@@ -2990,7 +2809,6 @@ function writeMdat(box) {
|
|
|
2990
2809
|
writer.writeBytes(box.data);
|
|
2991
2810
|
return writer;
|
|
2992
2811
|
}
|
|
2993
|
-
|
|
2994
2812
|
//#endregion
|
|
2995
2813
|
//#region src/writers/writeMdhd.ts
|
|
2996
2814
|
/**
|
|
@@ -3006,10 +2824,7 @@ function writeMdat(box) {
|
|
|
3006
2824
|
*/
|
|
3007
2825
|
function writeMdhd(box) {
|
|
3008
2826
|
const size = box.version === 1 ? 8 : 4;
|
|
3009
|
-
const
|
|
3010
|
-
const fullBoxSize = 4;
|
|
3011
|
-
const timesSize = size * 3;
|
|
3012
|
-
const writer = new IsoBoxWriteView("mdhd", headerSize + fullBoxSize + timesSize + 4 + 2 + 2);
|
|
2827
|
+
const writer = new IsoBoxWriteView("mdhd", 12 + size * 3 + 4 + 2 + 2);
|
|
3013
2828
|
writer.writeFullBox(box.version, box.flags);
|
|
3014
2829
|
writer.writeUint(box.creationTime, size);
|
|
3015
2830
|
writer.writeUint(box.modificationTime, size);
|
|
@@ -3020,7 +2835,6 @@ function writeMdhd(box) {
|
|
|
3020
2835
|
writer.writeUint(box.preDefined, 2);
|
|
3021
2836
|
return writer;
|
|
3022
2837
|
}
|
|
3023
|
-
|
|
3024
2838
|
//#endregion
|
|
3025
2839
|
//#region src/writers/writeMehd.ts
|
|
3026
2840
|
/**
|
|
@@ -3036,15 +2850,11 @@ function writeMdhd(box) {
|
|
|
3036
2850
|
*/
|
|
3037
2851
|
function writeMehd(box) {
|
|
3038
2852
|
const size = box.version === 1 ? 8 : 4;
|
|
3039
|
-
const
|
|
3040
|
-
const fullBoxSize = 4;
|
|
3041
|
-
const fragmentDurationSize = size;
|
|
3042
|
-
const writer = new IsoBoxWriteView("mehd", headerSize + fullBoxSize + fragmentDurationSize);
|
|
2853
|
+
const writer = new IsoBoxWriteView("mehd", 12 + size);
|
|
3043
2854
|
writer.writeFullBox(box.version, box.flags);
|
|
3044
2855
|
writer.writeUint(box.fragmentDuration, size);
|
|
3045
2856
|
return writer;
|
|
3046
2857
|
}
|
|
3047
|
-
|
|
3048
2858
|
//#endregion
|
|
3049
2859
|
//#region src/writers/writeMeta.ts
|
|
3050
2860
|
/**
|
|
@@ -3060,15 +2870,12 @@ function writeMehd(box) {
|
|
|
3060
2870
|
* @public
|
|
3061
2871
|
*/
|
|
3062
2872
|
function writeMeta(box, config) {
|
|
3063
|
-
const headerSize = 8;
|
|
3064
|
-
const fullBoxSize = 4;
|
|
3065
2873
|
const { bytes, size } = writeChildBoxes(box.boxes, config);
|
|
3066
|
-
const writer = new IsoBoxWriteView("meta",
|
|
2874
|
+
const writer = new IsoBoxWriteView("meta", 12 + size);
|
|
3067
2875
|
writer.writeFullBox(box.version, box.flags);
|
|
3068
2876
|
writer.writeBytes(bytes);
|
|
3069
2877
|
return writer;
|
|
3070
2878
|
}
|
|
3071
|
-
|
|
3072
2879
|
//#endregion
|
|
3073
2880
|
//#region src/writers/writeMfhd.ts
|
|
3074
2881
|
/**
|
|
@@ -3088,7 +2895,6 @@ function writeMfhd(box) {
|
|
|
3088
2895
|
writer.writeUint(box.sequenceNumber, 4);
|
|
3089
2896
|
return writer;
|
|
3090
2897
|
}
|
|
3091
|
-
|
|
3092
2898
|
//#endregion
|
|
3093
2899
|
//#region src/writers/writeMfro.ts
|
|
3094
2900
|
/**
|
|
@@ -3108,7 +2914,6 @@ function writeMfro(box) {
|
|
|
3108
2914
|
writer.writeUint(box.mfraSize, 4);
|
|
3109
2915
|
return writer;
|
|
3110
2916
|
}
|
|
3111
|
-
|
|
3112
2917
|
//#endregion
|
|
3113
2918
|
//#region src/writers/writeMp4a.ts
|
|
3114
2919
|
/**
|
|
@@ -3125,7 +2930,6 @@ function writeMfro(box) {
|
|
|
3125
2930
|
function writeMp4a(box, config) {
|
|
3126
2931
|
return writeAudioSampleEntryBox(box, config);
|
|
3127
2932
|
}
|
|
3128
|
-
|
|
3129
2933
|
//#endregion
|
|
3130
2934
|
//#region src/writers/writeMvhd.ts
|
|
3131
2935
|
/**
|
|
@@ -3141,10 +2945,7 @@ function writeMp4a(box, config) {
|
|
|
3141
2945
|
*/
|
|
3142
2946
|
function writeMvhd(box) {
|
|
3143
2947
|
const size = box.version === 1 ? 8 : 4;
|
|
3144
|
-
const
|
|
3145
|
-
const fullBoxSize = 4;
|
|
3146
|
-
const timesSize = size * 3;
|
|
3147
|
-
const writer = new IsoBoxWriteView("mvhd", headerSize + fullBoxSize + timesSize + 4 + 4 + 2 + 2 + 8 + 36 + 24 + 4);
|
|
2948
|
+
const writer = new IsoBoxWriteView("mvhd", 12 + size * 3 + 4 + 4 + 2 + 2 + 8 + 36 + 24 + 4);
|
|
3148
2949
|
writer.writeFullBox(box.version, box.flags);
|
|
3149
2950
|
writer.writeUint(box.creationTime, size);
|
|
3150
2951
|
writer.writeUint(box.modificationTime, size);
|
|
@@ -3159,7 +2960,6 @@ function writeMvhd(box) {
|
|
|
3159
2960
|
writer.writeUint(box.nextTrackId, 4);
|
|
3160
2961
|
return writer;
|
|
3161
2962
|
}
|
|
3162
|
-
|
|
3163
2963
|
//#endregion
|
|
3164
2964
|
//#region src/writers/writePayl.ts
|
|
3165
2965
|
/**
|
|
@@ -3176,7 +2976,6 @@ function writePayl(box) {
|
|
|
3176
2976
|
writer.writeUtf8TerminatedString(box.cueText);
|
|
3177
2977
|
return writer;
|
|
3178
2978
|
}
|
|
3179
|
-
|
|
3180
2979
|
//#endregion
|
|
3181
2980
|
//#region src/writers/writePrft.ts
|
|
3182
2981
|
/**
|
|
@@ -3200,7 +2999,6 @@ function writePrft(box) {
|
|
|
3200
2999
|
writer.writeUint(box.mediaTime, mediaTimeSize);
|
|
3201
3000
|
return writer;
|
|
3202
3001
|
}
|
|
3203
|
-
|
|
3204
3002
|
//#endregion
|
|
3205
3003
|
//#region src/writers/writePrsl.ts
|
|
3206
3004
|
/**
|
|
@@ -3216,16 +3014,12 @@ function writePrft(box) {
|
|
|
3216
3014
|
function writePrsl(box, config) {
|
|
3217
3015
|
const preselectionTagBytes = box.flags & 4096 && box.preselectionTag ? encodeText(box.preselectionTag) : null;
|
|
3218
3016
|
const interleavingTagBytes = box.flags & 16384 && box.interleavingTag ? encodeText(box.interleavingTag) : null;
|
|
3219
|
-
const headerSize = 8;
|
|
3220
|
-
const fullBoxSize = 4;
|
|
3221
|
-
const groupIdSize = 4;
|
|
3222
|
-
const numEntitiesInGroupSize = 4;
|
|
3223
3017
|
const entitiesSize = box.numEntitiesInGroup * 4;
|
|
3224
3018
|
const preselectionTagSize = preselectionTagBytes ? preselectionTagBytes.length + 1 : 0;
|
|
3225
3019
|
const selectionPrioritySize = box.flags & 8192 ? 1 : 0;
|
|
3226
3020
|
const interleavingTagSize = interleavingTagBytes ? interleavingTagBytes.length + 1 : 0;
|
|
3227
3021
|
const { bytes, size } = writeChildBoxes(box.boxes, config);
|
|
3228
|
-
const writer = new IsoBoxWriteView("prsl",
|
|
3022
|
+
const writer = new IsoBoxWriteView("prsl", 20 + entitiesSize + preselectionTagSize + selectionPrioritySize + interleavingTagSize + size);
|
|
3229
3023
|
writer.writeFullBox(box.version, box.flags);
|
|
3230
3024
|
writer.writeUint(box.groupId, 4);
|
|
3231
3025
|
writer.writeUint(box.numEntitiesInGroup, 4);
|
|
@@ -3236,7 +3030,6 @@ function writePrsl(box, config) {
|
|
|
3236
3030
|
writer.writeBytes(bytes);
|
|
3237
3031
|
return writer;
|
|
3238
3032
|
}
|
|
3239
|
-
|
|
3240
3033
|
//#endregion
|
|
3241
3034
|
//#region src/writers/writePssh.ts
|
|
3242
3035
|
/**
|
|
@@ -3251,14 +3044,11 @@ function writePrsl(box, config) {
|
|
|
3251
3044
|
* @public
|
|
3252
3045
|
*/
|
|
3253
3046
|
function writePssh(box) {
|
|
3254
|
-
const headerSize = 8;
|
|
3255
|
-
const fullBoxSize = 4;
|
|
3256
|
-
const systemIdSize = 16;
|
|
3257
3047
|
const kidCountSize = box.version > 0 ? 4 : 0;
|
|
3258
3048
|
const kidSize = box.version > 0 ? box.kidCount * 16 : 0;
|
|
3259
3049
|
const dataSizeField = 4;
|
|
3260
3050
|
const dataSize = box.dataSize;
|
|
3261
|
-
const writer = new IsoBoxWriteView("pssh",
|
|
3051
|
+
const writer = new IsoBoxWriteView("pssh", 28 + kidCountSize + kidSize + dataSizeField + dataSize);
|
|
3262
3052
|
writer.writeFullBox(box.version, box.flags);
|
|
3263
3053
|
writer.writeArray(box.systemId, UINT, 1, 16);
|
|
3264
3054
|
if (box.version > 0) {
|
|
@@ -3269,7 +3059,6 @@ function writePssh(box) {
|
|
|
3269
3059
|
writer.writeArray(box.data, UINT, 1, box.dataSize);
|
|
3270
3060
|
return writer;
|
|
3271
3061
|
}
|
|
3272
|
-
|
|
3273
3062
|
//#endregion
|
|
3274
3063
|
//#region src/writers/writeSchm.ts
|
|
3275
3064
|
/**
|
|
@@ -3284,19 +3073,13 @@ function writePssh(box) {
|
|
|
3284
3073
|
* @public
|
|
3285
3074
|
*/
|
|
3286
3075
|
function writeSchm(box) {
|
|
3287
|
-
const
|
|
3288
|
-
const fullBoxSize = 4;
|
|
3289
|
-
const schemeTypeSize = 4;
|
|
3290
|
-
const schemeVersionSize = 4;
|
|
3291
|
-
const schemeUriSize = box.flags & 1 && box.schemeUri ? box.schemeUri.length + 1 : 0;
|
|
3292
|
-
const writer = new IsoBoxWriteView("schm", headerSize + fullBoxSize + schemeTypeSize + schemeVersionSize + schemeUriSize);
|
|
3076
|
+
const writer = new IsoBoxWriteView("schm", 20 + (box.flags & 1 && box.schemeUri ? box.schemeUri.length + 1 : 0));
|
|
3293
3077
|
writer.writeFullBox(box.version, box.flags);
|
|
3294
3078
|
writer.writeUint(box.schemeType, 4);
|
|
3295
3079
|
writer.writeUint(box.schemeVersion, 4);
|
|
3296
3080
|
if (box.flags & 1 && box.schemeUri) writer.writeTerminatedString(box.schemeUri);
|
|
3297
3081
|
return writer;
|
|
3298
3082
|
}
|
|
3299
|
-
|
|
3300
3083
|
//#endregion
|
|
3301
3084
|
//#region src/writers/writeSdtp.ts
|
|
3302
3085
|
/**
|
|
@@ -3311,15 +3094,11 @@ function writeSchm(box) {
|
|
|
3311
3094
|
* @public
|
|
3312
3095
|
*/
|
|
3313
3096
|
function writeSdtp(box) {
|
|
3314
|
-
const
|
|
3315
|
-
const fullBoxSize = 4;
|
|
3316
|
-
const sampleDependencyTableSize = box.sampleDependencyTable.length;
|
|
3317
|
-
const writer = new IsoBoxWriteView("sdtp", headerSize + fullBoxSize + sampleDependencyTableSize);
|
|
3097
|
+
const writer = new IsoBoxWriteView("sdtp", 12 + box.sampleDependencyTable.length);
|
|
3318
3098
|
writer.writeFullBox(box.version, box.flags);
|
|
3319
3099
|
for (const entry of box.sampleDependencyTable) writer.writeUint(entry, 1);
|
|
3320
3100
|
return writer;
|
|
3321
3101
|
}
|
|
3322
|
-
|
|
3323
3102
|
//#endregion
|
|
3324
3103
|
//#region src/writers/writeSidx.ts
|
|
3325
3104
|
/**
|
|
@@ -3335,16 +3114,12 @@ function writeSdtp(box) {
|
|
|
3335
3114
|
*/
|
|
3336
3115
|
function writeSidx(box) {
|
|
3337
3116
|
const size = box.version === 1 ? 8 : 4;
|
|
3338
|
-
const headerSize = 8;
|
|
3339
|
-
const fullBoxSize = 4;
|
|
3340
|
-
const referenceIdSize = 4;
|
|
3341
|
-
const timescaleSize = 4;
|
|
3342
3117
|
const earliestPresentationTimeSize = size;
|
|
3343
3118
|
const firstOffsetSize = size;
|
|
3344
3119
|
const reservedSize = 2;
|
|
3345
3120
|
const referenceCountSize = 2;
|
|
3346
3121
|
const referencesSize = box.references.length * 12;
|
|
3347
|
-
const writer = new IsoBoxWriteView("sidx",
|
|
3122
|
+
const writer = new IsoBoxWriteView("sidx", 20 + earliestPresentationTimeSize + firstOffsetSize + reservedSize + referenceCountSize + referencesSize);
|
|
3348
3123
|
writer.writeFullBox(box.version, box.flags);
|
|
3349
3124
|
writer.writeUint(box.referenceId, 4);
|
|
3350
3125
|
writer.writeUint(box.timescale, 4);
|
|
@@ -3361,7 +3136,6 @@ function writeSidx(box) {
|
|
|
3361
3136
|
}
|
|
3362
3137
|
return writer;
|
|
3363
3138
|
}
|
|
3364
|
-
|
|
3365
3139
|
//#endregion
|
|
3366
3140
|
//#region src/writers/writeSkip.ts
|
|
3367
3141
|
/**
|
|
@@ -3380,7 +3154,6 @@ function writeSkip(box) {
|
|
|
3380
3154
|
writer.writeBytes(box.data);
|
|
3381
3155
|
return writer;
|
|
3382
3156
|
}
|
|
3383
|
-
|
|
3384
3157
|
//#endregion
|
|
3385
3158
|
//#region src/writers/writeSmhd.ts
|
|
3386
3159
|
/**
|
|
@@ -3401,7 +3174,6 @@ function writeSmhd(box) {
|
|
|
3401
3174
|
writer.writeUint(box.reserved, 2);
|
|
3402
3175
|
return writer;
|
|
3403
3176
|
}
|
|
3404
|
-
|
|
3405
3177
|
//#endregion
|
|
3406
3178
|
//#region src/writers/writeSsix.ts
|
|
3407
3179
|
/**
|
|
@@ -3416,15 +3188,12 @@ function writeSmhd(box) {
|
|
|
3416
3188
|
* @public
|
|
3417
3189
|
*/
|
|
3418
3190
|
function writeSsix(box) {
|
|
3419
|
-
const headerSize = 8;
|
|
3420
|
-
const fullBoxSize = 4;
|
|
3421
|
-
const subsegmentCountSize = 4;
|
|
3422
3191
|
let rangesSize = 0;
|
|
3423
3192
|
for (const subsegment of box.subsegments) {
|
|
3424
3193
|
rangesSize += 4;
|
|
3425
3194
|
rangesSize += subsegment.rangesCount * 4;
|
|
3426
3195
|
}
|
|
3427
|
-
const writer = new IsoBoxWriteView("ssix",
|
|
3196
|
+
const writer = new IsoBoxWriteView("ssix", 16 + rangesSize);
|
|
3428
3197
|
writer.writeFullBox(box.version, box.flags);
|
|
3429
3198
|
writer.writeUint(box.subsegmentCount, 4);
|
|
3430
3199
|
for (const subsegment of box.subsegments) {
|
|
@@ -3436,7 +3205,6 @@ function writeSsix(box) {
|
|
|
3436
3205
|
}
|
|
3437
3206
|
return writer;
|
|
3438
3207
|
}
|
|
3439
|
-
|
|
3440
3208
|
//#endregion
|
|
3441
3209
|
//#region src/writers/writeStco.ts
|
|
3442
3210
|
/**
|
|
@@ -3451,17 +3219,12 @@ function writeSsix(box) {
|
|
|
3451
3219
|
* @public
|
|
3452
3220
|
*/
|
|
3453
3221
|
function writeStco(box) {
|
|
3454
|
-
const
|
|
3455
|
-
const fullBoxSize = 4;
|
|
3456
|
-
const entryCountSize = 4;
|
|
3457
|
-
const entriesSize = box.entryCount * 4;
|
|
3458
|
-
const writer = new IsoBoxWriteView("stco", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
3222
|
+
const writer = new IsoBoxWriteView("stco", 16 + box.entryCount * 4);
|
|
3459
3223
|
writer.writeFullBox(box.version, box.flags);
|
|
3460
3224
|
writer.writeUint(box.entryCount, 4);
|
|
3461
3225
|
for (const offset of box.chunkOffset) writer.writeUint(offset, 4);
|
|
3462
3226
|
return writer;
|
|
3463
3227
|
}
|
|
3464
|
-
|
|
3465
3228
|
//#endregion
|
|
3466
3229
|
//#region src/writers/writeSthd.ts
|
|
3467
3230
|
/**
|
|
@@ -3480,7 +3243,6 @@ function writeSthd(box) {
|
|
|
3480
3243
|
writer.writeFullBox(box.version, box.flags);
|
|
3481
3244
|
return writer;
|
|
3482
3245
|
}
|
|
3483
|
-
|
|
3484
3246
|
//#endregion
|
|
3485
3247
|
//#region src/writers/writeStsc.ts
|
|
3486
3248
|
/**
|
|
@@ -3495,11 +3257,7 @@ function writeSthd(box) {
|
|
|
3495
3257
|
* @public
|
|
3496
3258
|
*/
|
|
3497
3259
|
function writeStsc(box) {
|
|
3498
|
-
const
|
|
3499
|
-
const fullBoxSize = 4;
|
|
3500
|
-
const entryCountSize = 4;
|
|
3501
|
-
const entriesSize = box.entryCount * 12;
|
|
3502
|
-
const writer = new IsoBoxWriteView("stsc", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
3260
|
+
const writer = new IsoBoxWriteView("stsc", 16 + box.entryCount * 12);
|
|
3503
3261
|
writer.writeFullBox(box.version, box.flags);
|
|
3504
3262
|
writer.writeUint(box.entryCount, 4);
|
|
3505
3263
|
for (const entry of box.entries) {
|
|
@@ -3509,7 +3267,6 @@ function writeStsc(box) {
|
|
|
3509
3267
|
}
|
|
3510
3268
|
return writer;
|
|
3511
3269
|
}
|
|
3512
|
-
|
|
3513
3270
|
//#endregion
|
|
3514
3271
|
//#region src/writers/writeStsd.ts
|
|
3515
3272
|
/**
|
|
@@ -3523,18 +3280,14 @@ function writeStsc(box) {
|
|
|
3523
3280
|
* @public
|
|
3524
3281
|
*/
|
|
3525
3282
|
function writeStsd(box, config) {
|
|
3526
|
-
const headerSize = 8;
|
|
3527
|
-
const fullBoxSize = 4;
|
|
3528
|
-
const entryCountSize = 4;
|
|
3529
3283
|
const entryCount = box.entries.length;
|
|
3530
3284
|
const { bytes, size } = writeChildBoxes(box.entries, config);
|
|
3531
|
-
const writer = new IsoBoxWriteView("stsd",
|
|
3285
|
+
const writer = new IsoBoxWriteView("stsd", 16 + size);
|
|
3532
3286
|
writer.writeFullBox(box.version, box.flags);
|
|
3533
3287
|
writer.writeUint(entryCount, 4);
|
|
3534
3288
|
writer.writeBytes(bytes);
|
|
3535
3289
|
return writer;
|
|
3536
3290
|
}
|
|
3537
|
-
|
|
3538
3291
|
//#endregion
|
|
3539
3292
|
//#region src/writers/writeStss.ts
|
|
3540
3293
|
/**
|
|
@@ -3549,17 +3302,12 @@ function writeStsd(box, config) {
|
|
|
3549
3302
|
* @public
|
|
3550
3303
|
*/
|
|
3551
3304
|
function writeStss(box) {
|
|
3552
|
-
const
|
|
3553
|
-
const fullBoxSize = 4;
|
|
3554
|
-
const entryCountSize = 4;
|
|
3555
|
-
const entriesSize = box.entryCount * 4;
|
|
3556
|
-
const writer = new IsoBoxWriteView("stss", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
3305
|
+
const writer = new IsoBoxWriteView("stss", 16 + box.entryCount * 4);
|
|
3557
3306
|
writer.writeFullBox(box.version, box.flags);
|
|
3558
3307
|
writer.writeUint(box.entryCount, 4);
|
|
3559
3308
|
for (const entry of box.entries) writer.writeUint(entry.sampleNumber, 4);
|
|
3560
3309
|
return writer;
|
|
3561
3310
|
}
|
|
3562
|
-
|
|
3563
3311
|
//#endregion
|
|
3564
3312
|
//#region src/writers/writeStsz.ts
|
|
3565
3313
|
/**
|
|
@@ -3574,19 +3322,13 @@ function writeStss(box) {
|
|
|
3574
3322
|
* @public
|
|
3575
3323
|
*/
|
|
3576
3324
|
function writeStsz(box) {
|
|
3577
|
-
const
|
|
3578
|
-
const fullBoxSize = 4;
|
|
3579
|
-
const sampleSizeFieldSize = 4;
|
|
3580
|
-
const sampleCountFieldSize = 4;
|
|
3581
|
-
const entrySizeSize = box.sampleSize === 0 ? box.sampleCount * 4 : 0;
|
|
3582
|
-
const writer = new IsoBoxWriteView("stsz", headerSize + fullBoxSize + sampleSizeFieldSize + sampleCountFieldSize + entrySizeSize);
|
|
3325
|
+
const writer = new IsoBoxWriteView("stsz", 20 + (box.sampleSize === 0 ? box.sampleCount * 4 : 0));
|
|
3583
3326
|
writer.writeFullBox(box.version, box.flags);
|
|
3584
3327
|
writer.writeUint(box.sampleSize, 4);
|
|
3585
3328
|
writer.writeUint(box.sampleCount, 4);
|
|
3586
3329
|
if (box.sampleSize === 0 && box.entrySize) for (const size of box.entrySize) writer.writeUint(size, 4);
|
|
3587
3330
|
return writer;
|
|
3588
3331
|
}
|
|
3589
|
-
|
|
3590
3332
|
//#endregion
|
|
3591
3333
|
//#region src/writers/writeSttg.ts
|
|
3592
3334
|
/**
|
|
@@ -3603,7 +3345,6 @@ function writeSttg(box) {
|
|
|
3603
3345
|
writer.writeUtf8TerminatedString(box.settings);
|
|
3604
3346
|
return writer;
|
|
3605
3347
|
}
|
|
3606
|
-
|
|
3607
3348
|
//#endregion
|
|
3608
3349
|
//#region src/writers/writeStts.ts
|
|
3609
3350
|
/**
|
|
@@ -3618,11 +3359,7 @@ function writeSttg(box) {
|
|
|
3618
3359
|
* @public
|
|
3619
3360
|
*/
|
|
3620
3361
|
function writeStts(box) {
|
|
3621
|
-
const
|
|
3622
|
-
const fullBoxSize = 4;
|
|
3623
|
-
const entryCountSize = 4;
|
|
3624
|
-
const entriesSize = box.entryCount * 8;
|
|
3625
|
-
const writer = new IsoBoxWriteView("stts", headerSize + fullBoxSize + entryCountSize + entriesSize);
|
|
3362
|
+
const writer = new IsoBoxWriteView("stts", 16 + box.entryCount * 8);
|
|
3626
3363
|
writer.writeFullBox(box.version, box.flags);
|
|
3627
3364
|
writer.writeUint(box.entryCount, 4);
|
|
3628
3365
|
for (const entry of box.entries) {
|
|
@@ -3631,7 +3368,6 @@ function writeStts(box) {
|
|
|
3631
3368
|
}
|
|
3632
3369
|
return writer;
|
|
3633
3370
|
}
|
|
3634
|
-
|
|
3635
3371
|
//#endregion
|
|
3636
3372
|
//#region src/writers/writeStyp.ts
|
|
3637
3373
|
/**
|
|
@@ -3646,17 +3382,12 @@ function writeStts(box) {
|
|
|
3646
3382
|
* @public
|
|
3647
3383
|
*/
|
|
3648
3384
|
function writeStyp(box) {
|
|
3649
|
-
const
|
|
3650
|
-
const majorBrandSize = 4;
|
|
3651
|
-
const minorVersionSize = 4;
|
|
3652
|
-
const compatibleBrandsSize = box.compatibleBrands.length * 4;
|
|
3653
|
-
const writer = new IsoBoxWriteView("styp", headerSize + majorBrandSize + minorVersionSize + compatibleBrandsSize);
|
|
3385
|
+
const writer = new IsoBoxWriteView("styp", 16 + box.compatibleBrands.length * 4);
|
|
3654
3386
|
writer.writeString(box.majorBrand);
|
|
3655
3387
|
writer.writeUint(box.minorVersion, 4);
|
|
3656
3388
|
for (const brand of box.compatibleBrands) writer.writeString(brand);
|
|
3657
3389
|
return writer;
|
|
3658
3390
|
}
|
|
3659
|
-
|
|
3660
3391
|
//#endregion
|
|
3661
3392
|
//#region src/writers/writeSubs.ts
|
|
3662
3393
|
/**
|
|
@@ -3693,7 +3424,6 @@ function writeSubs(box) {
|
|
|
3693
3424
|
}
|
|
3694
3425
|
return writer;
|
|
3695
3426
|
}
|
|
3696
|
-
|
|
3697
3427
|
//#endregion
|
|
3698
3428
|
//#region src/writers/writeTenc.ts
|
|
3699
3429
|
/**
|
|
@@ -3715,7 +3445,6 @@ function writeTenc(box) {
|
|
|
3715
3445
|
writer.writeArray(box.defaultKid, UINT, 1, 16);
|
|
3716
3446
|
return writer;
|
|
3717
3447
|
}
|
|
3718
|
-
|
|
3719
3448
|
//#endregion
|
|
3720
3449
|
//#region src/writers/writeTfdt.ts
|
|
3721
3450
|
/**
|
|
@@ -3731,15 +3460,11 @@ function writeTenc(box) {
|
|
|
3731
3460
|
*/
|
|
3732
3461
|
function writeTfdt(box) {
|
|
3733
3462
|
const size = box.version === 1 ? 8 : 4;
|
|
3734
|
-
const
|
|
3735
|
-
const fullBoxSize = 4;
|
|
3736
|
-
const baseMediaDecodeTimeSize = size;
|
|
3737
|
-
const writer = new IsoBoxWriteView("tfdt", headerSize + fullBoxSize + baseMediaDecodeTimeSize);
|
|
3463
|
+
const writer = new IsoBoxWriteView("tfdt", 12 + size);
|
|
3738
3464
|
writer.writeFullBox(box.version, box.flags);
|
|
3739
3465
|
writer.writeUint(box.baseMediaDecodeTime, size);
|
|
3740
3466
|
return writer;
|
|
3741
3467
|
}
|
|
3742
|
-
|
|
3743
3468
|
//#endregion
|
|
3744
3469
|
//#region src/writers/writeTfhd.ts
|
|
3745
3470
|
/**
|
|
@@ -3754,15 +3479,12 @@ function writeTfdt(box) {
|
|
|
3754
3479
|
* @public
|
|
3755
3480
|
*/
|
|
3756
3481
|
function writeTfhd(box) {
|
|
3757
|
-
const headerSize = 8;
|
|
3758
|
-
const fullBoxSize = 4;
|
|
3759
|
-
const trackIdSize = 4;
|
|
3760
3482
|
const baseDataOffsetSize = box.flags & 1 ? 8 : 0;
|
|
3761
3483
|
const sampleDescriptionIndexSize = box.flags & 2 ? 4 : 0;
|
|
3762
3484
|
const defaultSampleDurationSize = box.flags & 8 ? 4 : 0;
|
|
3763
3485
|
const defaultSampleSizeSize = box.flags & 16 ? 4 : 0;
|
|
3764
3486
|
const defaultSampleFlagsSize = box.flags & 32 ? 4 : 0;
|
|
3765
|
-
const writer = new IsoBoxWriteView("tfhd",
|
|
3487
|
+
const writer = new IsoBoxWriteView("tfhd", 16 + baseDataOffsetSize + sampleDescriptionIndexSize + defaultSampleDurationSize + defaultSampleSizeSize + defaultSampleFlagsSize);
|
|
3766
3488
|
writer.writeFullBox(box.version, box.flags);
|
|
3767
3489
|
writer.writeUint(box.trackId, 4);
|
|
3768
3490
|
if (box.flags & 1) writer.writeUint(box.baseDataOffset ?? 0, 8);
|
|
@@ -3772,7 +3494,6 @@ function writeTfhd(box) {
|
|
|
3772
3494
|
if (box.flags & 32) writer.writeUint(box.defaultSampleFlags ?? 0, 4);
|
|
3773
3495
|
return writer;
|
|
3774
3496
|
}
|
|
3775
|
-
|
|
3776
3497
|
//#endregion
|
|
3777
3498
|
//#region src/writers/writeTfra.ts
|
|
3778
3499
|
/**
|
|
@@ -3789,13 +3510,7 @@ function writeTfhd(box) {
|
|
|
3789
3510
|
function writeTfra(box) {
|
|
3790
3511
|
const timeSize = box.version === 1 ? 8 : 4;
|
|
3791
3512
|
const entrySize = timeSize + timeSize + (box.lengthSizeOfTrafNum + 1) + (box.lengthSizeOfTrunNum + 1) + (box.lengthSizeOfSampleNum + 1);
|
|
3792
|
-
const
|
|
3793
|
-
const fullBoxSize = 4;
|
|
3794
|
-
const trackIdSize = 4;
|
|
3795
|
-
const reservedSize = 4;
|
|
3796
|
-
const numberOfEntrySize = 4;
|
|
3797
|
-
const entriesSize = box.numberOfEntry * entrySize;
|
|
3798
|
-
const writer = new IsoBoxWriteView("tfra", headerSize + fullBoxSize + trackIdSize + reservedSize + numberOfEntrySize + entriesSize);
|
|
3513
|
+
const writer = new IsoBoxWriteView("tfra", 24 + box.numberOfEntry * entrySize);
|
|
3799
3514
|
writer.writeFullBox(box.version, box.flags);
|
|
3800
3515
|
writer.writeUint(box.trackId, 4);
|
|
3801
3516
|
const reserved = box.lengthSizeOfTrafNum << 4 | box.lengthSizeOfTrunNum << 2 | box.lengthSizeOfSampleNum;
|
|
@@ -3810,7 +3525,6 @@ function writeTfra(box) {
|
|
|
3810
3525
|
}
|
|
3811
3526
|
return writer;
|
|
3812
3527
|
}
|
|
3813
|
-
|
|
3814
3528
|
//#endregion
|
|
3815
3529
|
//#region src/writers/writeTkhd.ts
|
|
3816
3530
|
/**
|
|
@@ -3826,10 +3540,7 @@ function writeTfra(box) {
|
|
|
3826
3540
|
*/
|
|
3827
3541
|
function writeTkhd(box) {
|
|
3828
3542
|
const size = box.version === 1 ? 8 : 4;
|
|
3829
|
-
const
|
|
3830
|
-
const fullBoxSize = 4;
|
|
3831
|
-
const timesSize = size * 3;
|
|
3832
|
-
const writer = new IsoBoxWriteView("tkhd", headerSize + fullBoxSize + timesSize + 4 + 4 + 8 + 2 + 2 + 2 + 2 + 36 + 4 + 4);
|
|
3543
|
+
const writer = new IsoBoxWriteView("tkhd", 12 + size * 3 + 4 + 4 + 8 + 2 + 2 + 2 + 2 + 36 + 4 + 4);
|
|
3833
3544
|
writer.writeFullBox(box.version, box.flags);
|
|
3834
3545
|
writer.writeUint(box.creationTime, size);
|
|
3835
3546
|
writer.writeUint(box.modificationTime, size);
|
|
@@ -3846,7 +3557,6 @@ function writeTkhd(box) {
|
|
|
3846
3557
|
writer.writeTemplate(box.height, 4);
|
|
3847
3558
|
return writer;
|
|
3848
3559
|
}
|
|
3849
|
-
|
|
3850
3560
|
//#endregion
|
|
3851
3561
|
//#region src/writers/writeTrex.ts
|
|
3852
3562
|
/**
|
|
@@ -3870,7 +3580,6 @@ function writeTrex(box) {
|
|
|
3870
3580
|
writer.writeUint(box.defaultSampleFlags, 4);
|
|
3871
3581
|
return writer;
|
|
3872
3582
|
}
|
|
3873
|
-
|
|
3874
3583
|
//#endregion
|
|
3875
3584
|
//#region src/writers/writeTrun.ts
|
|
3876
3585
|
/**
|
|
@@ -3885,9 +3594,6 @@ function writeTrex(box) {
|
|
|
3885
3594
|
* @public
|
|
3886
3595
|
*/
|
|
3887
3596
|
function writeTrun(box) {
|
|
3888
|
-
const headerSize = 8;
|
|
3889
|
-
const fullBoxSize = 4;
|
|
3890
|
-
const sampleCountSize = 4;
|
|
3891
3597
|
const dataOffsetSize = box.flags & 1 ? 4 : 0;
|
|
3892
3598
|
const firstSampleFlagsSize = box.flags & 4 ? 4 : 0;
|
|
3893
3599
|
let sampleSize = 0;
|
|
@@ -3896,7 +3602,7 @@ function writeTrun(box) {
|
|
|
3896
3602
|
if (box.flags & 1024) sampleSize += 4;
|
|
3897
3603
|
if (box.flags & 2048) sampleSize += 4;
|
|
3898
3604
|
const samplesSize = sampleSize * box.sampleCount;
|
|
3899
|
-
const writer = new IsoBoxWriteView("trun",
|
|
3605
|
+
const writer = new IsoBoxWriteView("trun", 16 + dataOffsetSize + firstSampleFlagsSize + samplesSize);
|
|
3900
3606
|
writer.writeFullBox(box.version, box.flags);
|
|
3901
3607
|
writer.writeUint(box.sampleCount, 4);
|
|
3902
3608
|
if (box.flags & 1) writer.writeUint(box.dataOffset ?? 0, 4);
|
|
@@ -3909,7 +3615,6 @@ function writeTrun(box) {
|
|
|
3909
3615
|
}
|
|
3910
3616
|
return writer;
|
|
3911
3617
|
}
|
|
3912
|
-
|
|
3913
3618
|
//#endregion
|
|
3914
3619
|
//#region src/writers/writeUrl.ts
|
|
3915
3620
|
/**
|
|
@@ -3924,15 +3629,11 @@ function writeTrun(box) {
|
|
|
3924
3629
|
* @public
|
|
3925
3630
|
*/
|
|
3926
3631
|
function writeUrl(box) {
|
|
3927
|
-
const
|
|
3928
|
-
const fullBoxSize = 4;
|
|
3929
|
-
const locationSize = box.location.length + 1;
|
|
3930
|
-
const writer = new IsoBoxWriteView("url ", headerSize + fullBoxSize + locationSize);
|
|
3632
|
+
const writer = new IsoBoxWriteView("url ", 12 + (box.location.length + 1));
|
|
3931
3633
|
writer.writeFullBox(box.version, box.flags);
|
|
3932
3634
|
writer.writeTerminatedString(box.location);
|
|
3933
3635
|
return writer;
|
|
3934
3636
|
}
|
|
3935
|
-
|
|
3936
3637
|
//#endregion
|
|
3937
3638
|
//#region src/writers/writeUrn.ts
|
|
3938
3639
|
/**
|
|
@@ -3947,17 +3648,14 @@ function writeUrl(box) {
|
|
|
3947
3648
|
* @public
|
|
3948
3649
|
*/
|
|
3949
3650
|
function writeUrn(box) {
|
|
3950
|
-
const headerSize = 8;
|
|
3951
|
-
const fullBoxSize = 4;
|
|
3952
3651
|
const nameSize = box.name.length + 1;
|
|
3953
3652
|
const locationSize = box.location.length + 1;
|
|
3954
|
-
const writer = new IsoBoxWriteView("urn ",
|
|
3653
|
+
const writer = new IsoBoxWriteView("urn ", 12 + nameSize + locationSize);
|
|
3955
3654
|
writer.writeFullBox(box.version, box.flags);
|
|
3956
3655
|
writer.writeTerminatedString(box.name);
|
|
3957
3656
|
writer.writeTerminatedString(box.location);
|
|
3958
3657
|
return writer;
|
|
3959
3658
|
}
|
|
3960
|
-
|
|
3961
3659
|
//#endregion
|
|
3962
3660
|
//#region src/writers/writeVlab.ts
|
|
3963
3661
|
/**
|
|
@@ -3974,7 +3672,6 @@ function writeVlab(box) {
|
|
|
3974
3672
|
writer.writeUtf8TerminatedString(box.sourceLabel);
|
|
3975
3673
|
return writer;
|
|
3976
3674
|
}
|
|
3977
|
-
|
|
3978
3675
|
//#endregion
|
|
3979
3676
|
//#region src/writers/writeVmhd.ts
|
|
3980
3677
|
/**
|
|
@@ -3995,7 +3692,6 @@ function writeVmhd(box) {
|
|
|
3995
3692
|
writer.writeArray(box.opcolor, UINT, 2, 3);
|
|
3996
3693
|
return writer;
|
|
3997
3694
|
}
|
|
3998
|
-
|
|
3999
3695
|
//#endregion
|
|
4000
3696
|
//#region src/writers/writeVttC.ts
|
|
4001
3697
|
/**
|
|
@@ -4013,7 +3709,6 @@ function writeVttC(box) {
|
|
|
4013
3709
|
writer.writeBytes(configBytes);
|
|
4014
3710
|
return writer;
|
|
4015
3711
|
}
|
|
4016
|
-
|
|
4017
3712
|
//#endregion
|
|
4018
3713
|
//#region src/writers/writeVtte.ts
|
|
4019
3714
|
/**
|
|
@@ -4026,7 +3721,6 @@ function writeVttC(box) {
|
|
|
4026
3721
|
function writeVtte(_) {
|
|
4027
3722
|
return new IsoBoxWriteView("vtte", 8);
|
|
4028
3723
|
}
|
|
4029
|
-
|
|
4030
3724
|
//#endregion
|
|
4031
3725
|
//#region src/writers/defaultWriterConfig.ts
|
|
4032
3726
|
/**
|
|
@@ -4103,7 +3797,7 @@ function defaultWriterConfig() {
|
|
|
4103
3797
|
vtte: writeVtte
|
|
4104
3798
|
} };
|
|
4105
3799
|
}
|
|
4106
|
-
|
|
4107
3800
|
//#endregion
|
|
4108
3801
|
export { CONTAINERS, DATA, INT, IsoBoxFields, IsoBoxReadView, IsoBoxReadableStream, IsoBoxWriteView, STRING, TEMPLATE, UINT, UTF8, createAudioSampleEntryReader, createIsoBoxReadableStream, createVisualSampleEntryReader, defaultReaderConfig, defaultWriterConfig, filterIsoBoxes, findIsoBox, fourCcToUint32, isContainer, isFullBox, isIsoBoxType, readArdi, readAudioSampleEntryBox, readAvc1, readAvc2, readAvc3, readAvc4, readCtts, readDref, readElng, readElst, readEmsg, readEnca, readEncv, readFree, readFrma, readFtyp, readHdlr, readHev1, readHvc1, readIden, readImda, readIsoBoxes, readKind, readLabl, readMdat, readMdhd, readMehd, readMeta, readMfhd, readMfro, readMp4a, readMvhd, readPayl, readPrft, readPrsl, readPssh, readSchm, readSdtp, readSidx, readSkip, readSmhd, readSsix, readSthd, readStsd, readStss, readSttg, readStts, readStyp, readSubs, readTenc, readTfdt, readTfhd, readTfra, readTkhd, readTrex, readTrun, readUrl, readUrn, readVisualSampleEntryBox, readVlab, readVmhd, readVttC, readVtte, traverseIsoBoxes, writeArdi, writeAudioSampleEntryBox, writeAvc1, writeAvc2, writeAvc3, writeAvc4, writeCtts, writeDref, writeElng, writeElst, writeEmsg, writeEnca, writeEncv, writeFree, writeFrma, writeFtyp, writeHdlr, writeHev1, writeHvc1, writeIden, writeImda, writeIsoBox, writeIsoBoxes, writeKind, writeLabl, writeMdat, writeMdhd, writeMehd, writeMeta, writeMfhd, writeMfro, writeMp4a, writeMvhd, writePayl, writePrft, writePrsl, writePssh, writeSchm, writeSdtp, writeSidx, writeSkip, writeSmhd, writeSsix, writeStco, writeSthd, writeStsc, writeStsd, writeStss, writeStsz, writeSttg, writeStts, writeStyp, writeSubs, writeTenc, writeTfdt, writeTfhd, writeTfra, writeTkhd, writeTrex, writeTrun, writeUrl, writeUrn, writeVisualSampleEntryBox, writeVlab, writeVmhd, writeVttC, writeVtte };
|
|
3802
|
+
|
|
4109
3803
|
//# sourceMappingURL=index.js.map
|