From 550b849235cf6502d8fc5a614305da872eedd8e4 Mon Sep 17 00:00:00 2001 From: Vanilagy <1696106+Vanilagy@users.noreply.github.com> Date: Mon, 12 May 2025 15:16:30 +0200 Subject: [PATCH] Rename --- src/codec-data.ts | 24 ++++++++++++------------ src/isobmff/isobmff-demuxer.ts | 8 ++++---- src/matroska/matroska-demuxer.ts | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/codec-data.ts b/src/codec-data.ts index dc2067c..b4d4ec8 100644 --- a/src/codec-data.ts +++ b/src/codec-data.ts @@ -864,38 +864,38 @@ export type Vp9CodecInfo = { matrixCoefficients: number; }; -export const extractVp9CodecInfoFromFrame = ( - frame: Uint8Array, +export const extractVp9CodecInfoFromPacket = ( + packet: Uint8Array, ): Vp9CodecInfo | null => { // eslint-disable-next-line @stylistic/max-len // https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.7-20170222-draft.pdf // http://downloads.webmproject.org/docs/vp9/vp9-bitstream_superframe-and-uncompressed-header_v1.0.pdf // Handle superframe - const lastByte = frame[frame.length - 1]; + const lastByte = packet[packet.length - 1]; if (lastByte && (lastByte & 0xe0) === 0xc0) { // Is superframe const bytesPerFrameSize = ((lastByte & 0x18) >> 3) + 1; const numFrames = (lastByte & 0x07) + 1; const indexSize = 2 + numFrames * bytesPerFrameSize; // Verify matching marker bytes - if (frame[frame.length - indexSize] !== lastByte) { + if (packet[packet.length - indexSize] !== lastByte) { return null; } // Get first frame size let frameSize = 0; - const offset = frame.length - indexSize + 1; + const offset = packet.length - indexSize + 1; for (let i = 0; i < bytesPerFrameSize; i++) { - if (!frame[offset + i]) return null; - frameSize |= frame[offset + i]! << (8 * i); + if (!packet[offset + i]) return null; + frameSize |= packet[offset + i]! << (8 * i); } - frame = frame.subarray(0, frameSize); + packet = packet.subarray(0, frameSize); } - const bitstream = new Bitstream(frame); + const bitstream = new Bitstream(packet); // Frame marker (0b10) const frameMarker = bitstream.readBits(2); @@ -1044,12 +1044,12 @@ export type Av1CodecInfo = { * When AV1 codec information is not provided by the container, we can still try to extract the information by digging * into the AV1 bitstream. */ -export const extractAv1CodecInfoFromFrame = ( - data: Uint8Array, +export const extractAv1CodecInfoFromPacket = ( + packet: Uint8Array, ): Av1CodecInfo | null => { // https://aomediacodec.github.io/av1-spec/av1-spec.pdf - const bitstream = new Bitstream(data); + const bitstream = new Bitstream(packet); const readLeb128 = (): number | null => { let value = 0; diff --git a/src/isobmff/isobmff-demuxer.ts b/src/isobmff/isobmff-demuxer.ts index 7ac5663..afd96e6 100644 --- a/src/isobmff/isobmff-demuxer.ts +++ b/src/isobmff/isobmff-demuxer.ts @@ -13,8 +13,8 @@ import { HevcDecoderConfigurationRecord, Vp9CodecInfo, Av1CodecInfo, - extractVp9CodecInfoFromFrame, - extractAv1CodecInfoFromFrame, + extractVp9CodecInfoFromPacket, + extractAv1CodecInfoFromPacket, } from '../codec-data'; import { Demuxer } from '../demuxer'; import { Input } from '../input'; @@ -2360,10 +2360,10 @@ class IsobmffVideoTrackBacking extends IsobmffTrackBacking implements InputVideo return this.decoderConfigPromise ??= (async (): Promise => { if (this.internalTrack.info.codec === 'vp9' && !this.internalTrack.info.vp9CodecInfo) { const firstPacket = await this.getFirstPacket({}); - this.internalTrack.info.vp9CodecInfo = firstPacket && extractVp9CodecInfoFromFrame(firstPacket.data); + this.internalTrack.info.vp9CodecInfo = firstPacket && extractVp9CodecInfoFromPacket(firstPacket.data); } else if (this.internalTrack.info.codec === 'av1' && !this.internalTrack.info.av1CodecInfo) { const firstPacket = await this.getFirstPacket({}); - this.internalTrack.info.av1CodecInfo = firstPacket && extractAv1CodecInfoFromFrame(firstPacket.data); + this.internalTrack.info.av1CodecInfo = firstPacket && extractAv1CodecInfoFromPacket(firstPacket.data); } return { diff --git a/src/matroska/matroska-demuxer.ts b/src/matroska/matroska-demuxer.ts index 495f27d..7b5000f 100644 --- a/src/matroska/matroska-demuxer.ts +++ b/src/matroska/matroska-demuxer.ts @@ -1,8 +1,8 @@ import { - extractAv1CodecInfoFromFrame, + extractAv1CodecInfoFromPacket, extractAvcDecoderConfigurationRecord, extractHevcDecoderConfigurationRecord, - extractVp9CodecInfoFromFrame, + extractVp9CodecInfoFromPacket, } from '../codec-data'; import { AacCodecInfo, @@ -1577,10 +1577,10 @@ class MatroskaVideoTrackBacking extends MatroskaTrackBacking implements InputVid ? extractHevcDecoderConfigurationRecord(firstPacket.data) : null, vp9CodecInfo: this.internalTrack.info.codec === 'vp9' && firstPacket - ? extractVp9CodecInfoFromFrame(firstPacket.data) + ? extractVp9CodecInfoFromPacket(firstPacket.data) : null, av1CodecInfo: this.internalTrack.info.codec === 'av1' && firstPacket - ? extractAv1CodecInfoFromFrame(firstPacket.data) + ? extractAv1CodecInfoFromPacket(firstPacket.data) : null, }), codedWidth: this.internalTrack.info.width,