mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 08:43:49 +02:00
Add toDataView
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ import {
|
|||||||
last,
|
last,
|
||||||
readBits,
|
readBits,
|
||||||
reverseBitsU32,
|
reverseBitsU32,
|
||||||
|
toDataView,
|
||||||
} from './misc';
|
} from './misc';
|
||||||
import { SubtitleMetadata } from './subtitles';
|
import { SubtitleMetadata } from './subtitles';
|
||||||
|
|
||||||
@@ -306,7 +307,7 @@ export const extractVideoCodecString = (trackInfo: {
|
|||||||
throw new TypeError('HEVC description must be provided.');
|
throw new TypeError('HEVC description must be provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const view = new DataView(description.buffer, description.byteOffset, description.byteLength);
|
const view = toDataView(description);
|
||||||
let codecString = 'hev1.';
|
let codecString = 'hev1.';
|
||||||
|
|
||||||
// general_profile_space and general_profile_idc
|
// general_profile_space and general_profile_idc
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@ import {
|
|||||||
mapAsyncGenerator,
|
mapAsyncGenerator,
|
||||||
promiseWithResolvers,
|
promiseWithResolvers,
|
||||||
toAsyncIterator,
|
toAsyncIterator,
|
||||||
|
toDataView,
|
||||||
validateAnyIterable,
|
validateAnyIterable,
|
||||||
} from './misc';
|
} from './misc';
|
||||||
import { fromAlaw, fromUlaw } from './pcm';
|
import { fromAlaw, fromUlaw } from './pcm';
|
||||||
@@ -1015,7 +1016,7 @@ class PcmAudioDecoderWrapper extends DecoderWrapper<EncodedAudioSample, AudioDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
decode(sample: EncodedAudioSample) {
|
decode(sample: EncodedAudioSample) {
|
||||||
const inputView = new DataView(sample.data.buffer, sample.data.byteOffset, sample.byteLength);
|
const inputView = toDataView(sample.data);
|
||||||
|
|
||||||
const numberOfFrames = sample.byteLength / this.decoderConfig.numberOfChannels / this.inputSampleSize;
|
const numberOfFrames = sample.byteLength / this.decoderConfig.numberOfChannels / this.inputSampleSize;
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const toDataView = (bytes: Uint8Array) => {
|
||||||
|
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||||
|
};
|
||||||
|
|
||||||
export const textEncoder = new TextEncoder();
|
export const textEncoder = new TextEncoder();
|
||||||
|
|
||||||
const invertObject = <K extends PropertyKey, V extends PropertyKey>(object: Record<K, V>) => {
|
const invertObject = <K extends PropertyKey, V extends PropertyKey>(object: Record<K, V>) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { assert } from '../misc';
|
import { assert, toDataView } from '../misc';
|
||||||
import { Muxer } from '../muxer';
|
import { Muxer } from '../muxer';
|
||||||
import { Output, OutputAudioTrack } from '../output';
|
import { Output, OutputAudioTrack } from '../output';
|
||||||
import { EncodedAudioSample } from '../sample';
|
import { EncodedAudioSample } from '../sample';
|
||||||
@@ -36,7 +36,7 @@ export class Mp3Muxer extends Muxer {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.xingFrameData) {
|
if (!this.xingFrameData) {
|
||||||
const view = new DataView(sample.data.buffer, sample.data.byteOffset, sample.data.byteLength);
|
const view = toDataView(sample.data);
|
||||||
if (view.byteLength < 4) {
|
if (view.byteLength < 4) {
|
||||||
throw new Error('Invalid MP3 header in sample.');
|
throw new Error('Invalid MP3 header in sample.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user