@blockcast/mmt-container 2.2.0-main.60d918495132 → 2.2.0-main.69b0715c82eb
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/browser-runtime.js +1 -92
- package/dist/browser-runtime.js.map +3 -3
- package/dist/cmaf-block-assembler.js +1 -92
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +1 -92
- package/dist/codec-utils.js.map +2 -2
- package/dist/mmtp-container-parser.js +1 -92
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1 -92
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +1 -92
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.js +1 -92
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.js +1 -92
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +1 -92
- package/dist/no-modules.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +1 -92
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/codec-utils.ts +1 -121
package/dist/browser-runtime.js
CHANGED
|
@@ -6099,10 +6099,9 @@ function isH264IntraSlice(nal) {
|
|
|
6099
6099
|
const sliceType = readH264SliceType(nal);
|
|
6100
6100
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
6101
6101
|
}
|
|
6102
|
-
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
6103
6102
|
function readH264SliceType(nal) {
|
|
6104
6103
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6105
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1
|
|
6104
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6106
6105
|
const state = { bitOffset: 0 };
|
|
6107
6106
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6108
6107
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -6471,96 +6470,6 @@ if (void 0) {
|
|
|
6471
6470
|
]))).toBe(false);
|
|
6472
6471
|
});
|
|
6473
6472
|
});
|
|
6474
|
-
describe("readH264SliceType", () => {
|
|
6475
|
-
const wholeNalSliceType = (nal) => {
|
|
6476
|
-
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6477
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6478
|
-
const state = { bitOffset: 0 };
|
|
6479
|
-
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6480
|
-
return readUnsignedExpGolomb(rbsp, state);
|
|
6481
|
-
};
|
|
6482
|
-
const hex3 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
6483
|
-
const ue = (value) => {
|
|
6484
|
-
const code = (value + 1).toString(2);
|
|
6485
|
-
return "0".repeat(code.length - 1) + code;
|
|
6486
|
-
};
|
|
6487
|
-
const sliceNal = (bits) => {
|
|
6488
|
-
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
6489
|
-
const nal = [1];
|
|
6490
|
-
let zeros = 0;
|
|
6491
|
-
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
6492
|
-
if (zeros >= 2 && byte <= 3) {
|
|
6493
|
-
nal.push(3);
|
|
6494
|
-
zeros = 0;
|
|
6495
|
-
}
|
|
6496
|
-
nal.push(byte);
|
|
6497
|
-
zeros = byte === 0 ? zeros + 1 : 0;
|
|
6498
|
-
}
|
|
6499
|
-
return Uint8Array.from(nal);
|
|
6500
|
-
};
|
|
6501
|
-
const x264Slices = [
|
|
6502
|
-
["64x48 P", hex3("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
6503
|
-
["64x48 B", hex3("419e414212fffeeade283707cb70f7"), 6, false],
|
|
6504
|
-
["64x48 non-IDR I", hex3(
|
|
6505
|
-
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
6506
|
-
), 7, true],
|
|
6507
|
-
["1280x720 B, escape at byte 10", hex3(
|
|
6508
|
-
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
6509
|
-
), 6, false],
|
|
6510
|
-
["1280x720 P, escape at byte 15", hex3(
|
|
6511
|
-
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
6512
|
-
), 5, false],
|
|
6513
|
-
["1280x720 B, escape at byte 22", hex3("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
6514
|
-
["7680x4320 IDR, first_mb_in_slice 97440", hex3(
|
|
6515
|
-
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
6516
|
-
), null, true],
|
|
6517
|
-
["7680x4320 P, first_mb_in_slice 32640", hex3(
|
|
6518
|
-
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
6519
|
-
), 5, false],
|
|
6520
|
-
["7680x4320 P, first_mb_in_slice 97440", hex3(
|
|
6521
|
-
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
6522
|
-
), 5, false]
|
|
6523
|
-
];
|
|
6524
|
-
const syntheticSlices = [
|
|
6525
|
-
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
6526
|
-
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
6527
|
-
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
6528
|
-
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
6529
|
-
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
6530
|
-
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
6531
|
-
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
6532
|
-
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
6533
|
-
];
|
|
6534
|
-
test("reads the slice_type of real and synthetic slices", () => {
|
|
6535
|
-
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
6536
|
-
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
6537
|
-
}
|
|
6538
|
-
});
|
|
6539
|
-
test("matches the whole-NAL unescape at every truncation", () => {
|
|
6540
|
-
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
6541
|
-
for (let end = 0; end <= nal.length; end++) {
|
|
6542
|
-
const cut = nal.subarray(0, end);
|
|
6543
|
-
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
6544
|
-
}
|
|
6545
|
-
}
|
|
6546
|
-
});
|
|
6547
|
-
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
6548
|
-
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
6549
|
-
let seed = 1;
|
|
6550
|
-
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
6551
|
-
for (let i = 0; i < 5e3; i++) {
|
|
6552
|
-
const nal = new Uint8Array(2 + next() % 63);
|
|
6553
|
-
nal[0] = 65;
|
|
6554
|
-
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
6555
|
-
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
6556
|
-
}
|
|
6557
|
-
});
|
|
6558
|
-
test("classifies the x264 slices as keyframes or not", () => {
|
|
6559
|
-
for (const [name, nal, , keyframe] of x264Slices) {
|
|
6560
|
-
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
6561
|
-
}
|
|
6562
|
-
});
|
|
6563
|
-
});
|
|
6564
6473
|
describe("avccToAnnexB", () => {
|
|
6565
6474
|
test("converts with SPS/PPS on keyframe", () => {
|
|
6566
6475
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|