mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 13:23:51 +02:00
Add toDataView
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ import {
|
||||
last,
|
||||
readBits,
|
||||
reverseBitsU32,
|
||||
toDataView,
|
||||
} from './misc';
|
||||
import { SubtitleMetadata } from './subtitles';
|
||||
|
||||
@@ -306,7 +307,7 @@ export const extractVideoCodecString = (trackInfo: {
|
||||
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.';
|
||||
|
||||
// general_profile_space and general_profile_idc
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import {
|
||||
mapAsyncGenerator,
|
||||
promiseWithResolvers,
|
||||
toAsyncIterator,
|
||||
toDataView,
|
||||
validateAnyIterable,
|
||||
} from './misc';
|
||||
import { fromAlaw, fromUlaw } from './pcm';
|
||||
@@ -1015,7 +1016,7 @@ class PcmAudioDecoderWrapper extends DecoderWrapper<EncodedAudioSample, AudioDat
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
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 { Output, OutputAudioTrack } from '../output';
|
||||
import { EncodedAudioSample } from '../sample';
|
||||
@@ -36,7 +36,7 @@ export class Mp3Muxer extends Muxer {
|
||||
|
||||
try {
|
||||
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) {
|
||||
throw new Error('Invalid MP3 header in sample.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user