hls.js 1.6.1-0.canary.11107 → 1.6.1-0.canary.11108

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/package.json CHANGED
@@ -134,5 +134,5 @@
134
134
  "url-toolkit": "2.2.5",
135
135
  "wrangler": "3.114.2"
136
136
  },
137
- "version": "1.6.1-0.canary.11107"
137
+ "version": "1.6.1-0.canary.11108"
138
138
  }
@@ -343,11 +343,14 @@ function parseStsd(stsd: Uint8Array): StsdData {
343
343
  case 'avc4': {
344
344
  // extract profile + compatibility + level out of avcC box
345
345
  const avcCBox = findBox(sampleEntriesEnd, ['avcC'])[0];
346
- codec += '.' + toHex(avcCBox[1]) + toHex(avcCBox[2]) + toHex(avcCBox[3]);
347
- supplemental = parseSupplementalDoViCodec(
348
- codecFourCC === 'avc1' ? 'dva1' : 'dvav',
349
- sampleEntriesEnd,
350
- );
346
+ if (avcCBox && avcCBox.length > 3) {
347
+ codec +=
348
+ '.' + toHex(avcCBox[1]) + toHex(avcCBox[2]) + toHex(avcCBox[3]);
349
+ supplemental = parseSupplementalDoViCodec(
350
+ codecFourCC === 'avc1' ? 'dva1' : 'dvav',
351
+ sampleEntriesEnd,
352
+ );
353
+ }
351
354
  break;
352
355
  }
353
356
  case 'mp4a': {
@@ -397,9 +400,8 @@ function parseStsd(stsd: Uint8Array): StsdData {
397
400
  }
398
401
  case 'hvc1':
399
402
  case 'hev1': {
400
- const hvcCBoxes = findBox(sampleEntriesEnd, ['hvcC']);
401
- if (hvcCBoxes) {
402
- const hvcCBox = hvcCBoxes[0];
403
+ const hvcCBox = findBox(sampleEntriesEnd, ['hvcC'])[0];
404
+ if (hvcCBox && hvcCBox.length > 12) {
403
405
  const profileByte = hvcCBox[1];
404
406
  const profileSpace = ['', 'A', 'B', 'C'][profileByte >> 6];
405
407
  const generalProfileIdc = profileByte & 0x1f;
@@ -436,67 +438,71 @@ function parseStsd(stsd: Uint8Array): StsdData {
436
438
  }
437
439
  case 'vp09': {
438
440
  const vpcCBox = findBox(sampleEntriesEnd, ['vpcC'])[0];
439
- const profile = vpcCBox[4];
440
- const level = vpcCBox[5];
441
- const bitDepth = (vpcCBox[6] >> 4) & 0x0f;
442
- codec +=
443
- '.' +
444
- addLeadingZero(profile) +
445
- '.' +
446
- addLeadingZero(level) +
447
- '.' +
448
- addLeadingZero(bitDepth);
441
+ if (vpcCBox && vpcCBox.length > 6) {
442
+ const profile = vpcCBox[4];
443
+ const level = vpcCBox[5];
444
+ const bitDepth = (vpcCBox[6] >> 4) & 0x0f;
445
+ codec +=
446
+ '.' +
447
+ addLeadingZero(profile) +
448
+ '.' +
449
+ addLeadingZero(level) +
450
+ '.' +
451
+ addLeadingZero(bitDepth);
452
+ }
449
453
  break;
450
454
  }
451
455
  case 'av01': {
452
456
  const av1CBox = findBox(sampleEntriesEnd, ['av1C'])[0];
453
- const profile = av1CBox[1] >>> 5;
454
- const level = av1CBox[1] & 0x1f;
455
- const tierFlag = av1CBox[2] >>> 7 ? 'H' : 'M';
456
- const highBitDepth = (av1CBox[2] & 0x40) >> 6;
457
- const twelveBit = (av1CBox[2] & 0x20) >> 5;
458
- const bitDepth =
459
- profile === 2 && highBitDepth
460
- ? twelveBit
461
- ? 12
462
- : 10
463
- : highBitDepth
464
- ? 10
465
- : 8;
466
- const monochrome = (av1CBox[2] & 0x10) >> 4;
467
- const chromaSubsamplingX = (av1CBox[2] & 0x08) >> 3;
468
- const chromaSubsamplingY = (av1CBox[2] & 0x04) >> 2;
469
- const chromaSamplePosition = av1CBox[2] & 0x03;
470
- // TODO: parse color_description_present_flag
471
- // default it to BT.709/limited range for now
472
- // more info https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax
473
- const colorPrimaries = 1;
474
- const transferCharacteristics = 1;
475
- const matrixCoefficients = 1;
476
- const videoFullRangeFlag = 0;
477
- codec +=
478
- '.' +
479
- profile +
480
- '.' +
481
- addLeadingZero(level) +
482
- tierFlag +
483
- '.' +
484
- addLeadingZero(bitDepth) +
485
- '.' +
486
- monochrome +
487
- '.' +
488
- chromaSubsamplingX +
489
- chromaSubsamplingY +
490
- chromaSamplePosition +
491
- '.' +
492
- addLeadingZero(colorPrimaries) +
493
- '.' +
494
- addLeadingZero(transferCharacteristics) +
495
- '.' +
496
- addLeadingZero(matrixCoefficients) +
497
- '.' +
498
- videoFullRangeFlag;
499
- supplemental = parseSupplementalDoViCodec('dav1', sampleEntriesEnd);
457
+ if (av1CBox && av1CBox.length > 2) {
458
+ const profile = av1CBox[1] >>> 5;
459
+ const level = av1CBox[1] & 0x1f;
460
+ const tierFlag = av1CBox[2] >>> 7 ? 'H' : 'M';
461
+ const highBitDepth = (av1CBox[2] & 0x40) >> 6;
462
+ const twelveBit = (av1CBox[2] & 0x20) >> 5;
463
+ const bitDepth =
464
+ profile === 2 && highBitDepth
465
+ ? twelveBit
466
+ ? 12
467
+ : 10
468
+ : highBitDepth
469
+ ? 10
470
+ : 8;
471
+ const monochrome = (av1CBox[2] & 0x10) >> 4;
472
+ const chromaSubsamplingX = (av1CBox[2] & 0x08) >> 3;
473
+ const chromaSubsamplingY = (av1CBox[2] & 0x04) >> 2;
474
+ const chromaSamplePosition = av1CBox[2] & 0x03;
475
+ // TODO: parse color_description_present_flag
476
+ // default it to BT.709/limited range for now
477
+ // more info https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax
478
+ const colorPrimaries = 1;
479
+ const transferCharacteristics = 1;
480
+ const matrixCoefficients = 1;
481
+ const videoFullRangeFlag = 0;
482
+ codec +=
483
+ '.' +
484
+ profile +
485
+ '.' +
486
+ addLeadingZero(level) +
487
+ tierFlag +
488
+ '.' +
489
+ addLeadingZero(bitDepth) +
490
+ '.' +
491
+ monochrome +
492
+ '.' +
493
+ chromaSubsamplingX +
494
+ chromaSubsamplingY +
495
+ chromaSamplePosition +
496
+ '.' +
497
+ addLeadingZero(colorPrimaries) +
498
+ '.' +
499
+ addLeadingZero(transferCharacteristics) +
500
+ '.' +
501
+ addLeadingZero(matrixCoefficients) +
502
+ '.' +
503
+ videoFullRangeFlag;
504
+ supplemental = parseSupplementalDoViCodec('dav1', sampleEntriesEnd);
505
+ }
500
506
  break;
501
507
  }
502
508
  case 'ac-3':