@ahmedrowaihi/mediabunny 1.65.2-beta.704 → 1.65.2-beta.706

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.
@@ -7813,6 +7813,40 @@ var Mediabunny = (() => {
7813
7813
  var buildMdcvBox = (metadata) => isobmffBox("mdcv", buildMasteringDisplayPayload(metadata));
7814
7814
  var buildClliBox = (contentLight) => isobmffBox("clli", buildContentLightPayload(contentLight));
7815
7815
  var buildHdr10PlusSeiNalUnit = (payload, codec) => buildSeiNalUnit([{ payloadType: USER_DATA_REGISTERED_ITU_T_T35, payload }], codec);
7816
+ var OBU_TEMPORAL_DELIMITER = 2;
7817
+ var OBU_METADATA = 5;
7818
+ var METADATA_TYPE_ITUT_T35 = 4;
7819
+ var OBU_TRAILING_BYTE = 128;
7820
+ var writeLeb128 = (value) => {
7821
+ const out = [];
7822
+ do {
7823
+ const byte = value & 127;
7824
+ value >>>= 7;
7825
+ out.push(value ? byte | 128 : byte);
7826
+ } while (value);
7827
+ return out;
7828
+ };
7829
+ var withHdr10PlusObu = (packetData, payload) => {
7830
+ const obuPayload = [...writeLeb128(METADATA_TYPE_ITUT_T35), ...payload, OBU_TRAILING_BYTE];
7831
+ const obu = Uint8Array.from([
7832
+ OBU_METADATA << 3 | 2,
7833
+ // obu_has_size_field
7834
+ ...writeLeb128(obuPayload.length),
7835
+ ...obuPayload
7836
+ ]);
7837
+ let insertAt = 0;
7838
+ for (const first of iterateAv1PacketObus(packetData)) {
7839
+ if (first.type === OBU_TEMPORAL_DELIMITER) {
7840
+ insertAt = first.data.byteOffset - packetData.byteOffset + first.data.byteLength;
7841
+ }
7842
+ break;
7843
+ }
7844
+ const out = new Uint8Array(packetData.byteLength + obu.byteLength);
7845
+ out.set(packetData.subarray(0, insertAt), 0);
7846
+ out.set(obu, insertAt);
7847
+ out.set(packetData.subarray(insertAt), insertAt + obu.byteLength);
7848
+ return out;
7849
+ };
7816
7850
 
7817
7851
  // src/isobmff/isobmff-demuxer.ts
7818
7852
  var AVC_INTRA_FOURCCS = /* @__PURE__ */ new Set([
@@ -35438,8 +35472,8 @@ var Mediabunny = (() => {
35438
35472
  assert(seiNalUnit);
35439
35473
  return withNalUnitSpliced(packet, decoderConfig, codec, seiNalUnit);
35440
35474
  };
35441
- var withNalUnitSpliced = (packet, decoderConfig, codec, nalUnit) => new EncodedPacket(
35442
- spliceNalUnitBeforeVcl(packet.data, decoderConfig, codec, nalUnit),
35475
+ var withData = (packet, data) => new EncodedPacket(
35476
+ data,
35443
35477
  packet.type,
35444
35478
  packet.timestamp,
35445
35479
  packet.duration,
@@ -35450,6 +35484,7 @@ var Mediabunny = (() => {
35450
35484
  // that does, and the PTS it defaults to is not a decode order a muxer can write
35451
35485
  packet.statesDecodeTimestamp ? packet.decodeTimestamp : void 0
35452
35486
  );
35487
+ var withNalUnitSpliced = (packet, decoderConfig, codec, nalUnit) => withData(packet, spliceNalUnitBeforeVcl(packet.data, decoderConfig, codec, nalUnit));
35453
35488
  var EncodedVideoPacketSource = class extends VideoSource {
35454
35489
  /** Creates a new {@link EncodedVideoPacketSource} whose packets are encoded using `codec`. */
35455
35490
  constructor(codec) {
@@ -36309,11 +36344,11 @@ var Mediabunny = (() => {
36309
36344
  if (!videoSample.hdr10Plus) {
36310
36345
  return;
36311
36346
  }
36312
- if (this.encodingConfig.codec !== "hevc") {
36347
+ if (this.encodingConfig.codec !== "hevc" && this.encodingConfig.codec !== "av1") {
36313
36348
  if (!this.warnedAboutUncarriableHdr10Plus) {
36314
36349
  this.warnedAboutUncarriableHdr10Plus = true;
36315
36350
  Logging._warn(
36316
- `Dropping the HDR10+ metadata stated by the samples: it is written as an SEI in an HEVC bitstream, and this track encodes '${this.encodingConfig.codec}'.`
36351
+ `Dropping the HDR10+ metadata stated by the samples: it rides in an HEVC bitstream's SEI or an AV1 metadata OBU, and this track encodes '${this.encodingConfig.codec}'.`
36317
36352
  );
36318
36353
  }
36319
36354
  return;
@@ -36354,7 +36389,10 @@ var Mediabunny = (() => {
36354
36389
  this.carriesDeclaredCaptions = carriesClosedCaptions(packet.data, this.lastDecoderConfig, codec);
36355
36390
  }
36356
36391
  }
36357
- if (bytePairs || sideData?.dolbyVisionRpu || sideData?.hdr10Plus) {
36392
+ if (sideData?.hdr10Plus && this.encodingConfig.codec === "av1") {
36393
+ packet = withData(packet, withHdr10PlusObu(packet.data, sideData.hdr10Plus));
36394
+ }
36395
+ if (bytePairs || sideData?.dolbyVisionRpu || sideData?.hdr10Plus && this.encodingConfig.codec !== "av1") {
36358
36396
  const codec = this.encodingConfig.codec;
36359
36397
  assert(codec === "avc" || codec === "hevc");
36360
36398
  if (bytePairs) {
@@ -36370,7 +36408,7 @@ var Mediabunny = (() => {
36370
36408
  sideData.dolbyVisionRpu
36371
36409
  );
36372
36410
  }
36373
- if (sideData?.hdr10Plus) {
36411
+ if (sideData?.hdr10Plus && codec === "hevc") {
36374
36412
  assert(this.lastDecoderConfig);
36375
36413
  assert(codec === "hevc");
36376
36414
  const seiNalUnit = buildHdr10PlusSeiNalUnit(sideData.hdr10Plus, codec);