@blockcast/mmt-container 2.2.0-main.94f541fafcc0 → 2.2.0-main.9771b8926e3e

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.
@@ -11184,10 +11184,51 @@ function decodeFrameNeeds(code, keyframe) {
11184
11184
  }
11185
11185
  return { map: false, distance: code & 63, mayBeNeeded: code > 64 };
11186
11186
  }
11187
- function decoderTolerance(codec, reordered = false) {
11187
+ function decoderTolerance(codec, reordered = false, sample) {
11188
11188
  if (reordered) return "none";
11189
11189
  const lower = codec.toLowerCase();
11190
- return lower.startsWith("avc1") || lower.startsWith("avc3") ? "conceals" : "none";
11190
+ if (lower.startsWith("avc1") || lower.startsWith("avc3")) return "conceals";
11191
+ return lower.startsWith("vp09") && sample !== void 0 && vp9ErrorResilient(sample) ? "conceals" : "none";
11192
+ }
11193
+ function vp9ErrorResilient(sample) {
11194
+ const frames = vp9Frames(sample);
11195
+ return frames.length > 0 && frames.every(vp9FrameErrorResilient);
11196
+ }
11197
+ function vp9Frames(sample) {
11198
+ if (sample.length === 0) return [];
11199
+ const marker = sample[sample.length - 1];
11200
+ if ((marker & 224) !== 192) return [sample];
11201
+ const sizeBytes = (marker >> 3 & 3) + 1;
11202
+ const count = (marker & 7) + 1;
11203
+ const indexSize = 2 + sizeBytes * count;
11204
+ if (sample.length < indexSize || sample[sample.length - indexSize] !== marker) return [sample];
11205
+ const frames = [];
11206
+ let offset = 0;
11207
+ let at2 = sample.length - indexSize + 1;
11208
+ for (let i = 0; i < count; i++) {
11209
+ let size = 0;
11210
+ for (let b = 0; b < sizeBytes; b++) size += sample[at2++] * 2 ** (8 * b);
11211
+ if (size === 0 || offset + size > sample.length - indexSize) return [];
11212
+ frames.push(sample.subarray(offset, offset + size));
11213
+ offset += size;
11214
+ }
11215
+ return offset === sample.length - indexSize ? frames : [];
11216
+ }
11217
+ function vp9FrameErrorResilient(frame) {
11218
+ let bit = 0;
11219
+ const read = () => {
11220
+ const byte = frame[bit >> 3];
11221
+ if (byte === void 0) return void 0;
11222
+ return byte >> 7 - (bit++ & 7) & 1;
11223
+ };
11224
+ if (read() !== 1 || read() !== 0) return false;
11225
+ const low = read();
11226
+ const high = read();
11227
+ if (low === void 0 || high === void 0) return false;
11228
+ if (low === 1 && high === 1 && read() !== 0) return false;
11229
+ if (read() !== 0) return false;
11230
+ if (read() === void 0 || read() === void 0) return false;
11231
+ return read() === 1;
11191
11232
  }
11192
11233
  var VideoFeedGate = class {
11193
11234
  #inert;
@@ -11345,8 +11386,8 @@ var VideoFeedGate = class {
11345
11386
  };
11346
11387
 
11347
11388
  // src/conceal-timeline.ts
11348
- function videoConcealModeForCodec(codec, reordered = false) {
11349
- return decoderTolerance(codec, reordered) === "conceals" ? "feed-through" : "hold-to-rap";
11389
+ function videoConcealModeForCodec(codec, reordered = false, sample) {
11390
+ return decoderTolerance(codec, reordered, sample) === "conceals" ? "feed-through" : "hold-to-rap";
11350
11391
  }
11351
11392
  var U32_MAX = 0xffffffffn;
11352
11393
  var HoldLastTimeline = class {
@@ -36319,6 +36360,7 @@ export {
36319
36360
  videoCodecFamily,
36320
36361
  videoConcealModeForCodec,
36321
36362
  videoSampleEntryFromCodecString,
36363
+ vp9ErrorResilient,
36322
36364
  wireRepairFetch,
36323
36365
  wrapAdtsFrame
36324
36366
  };