mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Drop big-endian PCM support for WaveDemuxer
This commit is contained in:
@@ -20,7 +20,6 @@ export class WaveDemuxer extends Demuxer {
|
|||||||
riffReader: RiffReader;
|
riffReader: RiffReader;
|
||||||
chunkReader: RiffReader;
|
chunkReader: RiffReader;
|
||||||
|
|
||||||
littleEndian = true;
|
|
||||||
metadataPromise: Promise<void> | null = null;
|
metadataPromise: Promise<void> | null = null;
|
||||||
dataStart = -1;
|
dataStart = -1;
|
||||||
dataSize = -1;
|
dataSize = -1;
|
||||||
@@ -44,7 +43,7 @@ export class WaveDemuxer extends Demuxer {
|
|||||||
async readMetadata() {
|
async readMetadata() {
|
||||||
return this.metadataPromise ??= (async () => {
|
return this.metadataPromise ??= (async () => {
|
||||||
const riffType = this.riffReader.readAscii(4);
|
const riffType = this.riffReader.readAscii(4);
|
||||||
this.littleEndian = this.riffReader.littleEndian = riffType === 'RIFF';
|
this.riffReader.littleEndian = riffType === 'RIFF';
|
||||||
|
|
||||||
const totalFileSize = this.riffReader.readU32() + 8;
|
const totalFileSize = this.riffReader.readU32() + 8;
|
||||||
const format = this.riffReader.readAscii(4);
|
const format = this.riffReader.readAscii(4);
|
||||||
@@ -141,19 +140,20 @@ export class WaveDemuxer extends Demuxer {
|
|||||||
return 'alaw';
|
return 'alaw';
|
||||||
}
|
}
|
||||||
if (this.audioInfo.format === WaveFormat.PCM) {
|
if (this.audioInfo.format === WaveFormat.PCM) {
|
||||||
|
// All formats are little-endian
|
||||||
if (this.audioInfo.sampleSizeInBytes === 1) {
|
if (this.audioInfo.sampleSizeInBytes === 1) {
|
||||||
return 'pcm-u8';
|
return 'pcm-u8';
|
||||||
} else if (this.audioInfo.sampleSizeInBytes === 2) {
|
} else if (this.audioInfo.sampleSizeInBytes === 2) {
|
||||||
return this.littleEndian ? 'pcm-s16' : 'pcm-s16be';
|
return 'pcm-s16';
|
||||||
} else if (this.audioInfo.sampleSizeInBytes === 3) {
|
} else if (this.audioInfo.sampleSizeInBytes === 3) {
|
||||||
return this.littleEndian ? 'pcm-s24' : 'pcm-s24be';
|
return 'pcm-s24';
|
||||||
} else if (this.audioInfo.sampleSizeInBytes === 4) {
|
} else if (this.audioInfo.sampleSizeInBytes === 4) {
|
||||||
return this.littleEndian ? 'pcm-s32' : 'pcm-s32be';
|
return 'pcm-s32';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.audioInfo.format === WaveFormat.IEEE_FLOAT) {
|
if (this.audioInfo.format === WaveFormat.IEEE_FLOAT) {
|
||||||
if (this.audioInfo.sampleSizeInBytes === 4) {
|
if (this.audioInfo.sampleSizeInBytes === 4) {
|
||||||
return this.littleEndian ? 'pcm-f32' : 'pcm-f32be';
|
return 'pcm-f32';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user