ogg-opus-decoder
Advanced tools
Comparing version 1.6.12 to 1.6.13
{ | ||
"name": "ogg-opus-decoder", | ||
"version": "1.6.12", | ||
"version": "1.6.13", | ||
"description": "Web Assembly streaming Ogg Opus decoder", | ||
@@ -57,5 +57,5 @@ "type": "module", | ||
"@wasm-audio-decoders/common": "9.0.5", | ||
"codec-parser": "2.4.3", | ||
"codec-parser": "2.5.0", | ||
"opus-decoder": "0.7.6" | ||
} | ||
} |
# `ogg-opus-decoder` | ||
`ogg-opus-decoder` is a Web Assembly Ogg Opus audio decoder. | ||
* 108.5 KiB minified bundle size | ||
* 108.9 KiB minified bundle size | ||
* Browser and NodeJS support | ||
@@ -6,0 +6,0 @@ * Built in Web Worker support |
@@ -13,4 +13,4 @@ import { WASMAudioDecoderCommon } from "@wasm-audio-decoders/common"; | ||
absoluteGranulePosition, | ||
samples, | ||
data, | ||
totalSamples, | ||
} from "codec-parser"; | ||
@@ -53,3 +53,2 @@ | ||
this._channels = this._forceStereo ? 2 : header[channels]; | ||
this._beginningSampleOffset = null; | ||
@@ -99,13 +98,2 @@ this._decoder = new this._decoderClass({ | ||
// record beginning sample offset for absoluteGranulePosition logic | ||
if ( | ||
this._beginningSampleOffset === null && | ||
Number(oggPage[absoluteGranulePosition]) > -1 | ||
) { | ||
this._beginningSampleOffset = | ||
oggPage[absoluteGranulePosition] - | ||
BigInt(oggPage[samples]) + | ||
BigInt(this._preSkip); | ||
} | ||
if (oggPage[isLastPage]) { | ||
@@ -116,17 +104,16 @@ // in cases where BigInt isn't supported, don't do any absoluteGranulePosition logic (i.e. old iOS versions) | ||
(this._totalSamplesDecoded / this._sampleRate) * 48000; | ||
const totalOggSamples_48000 = Number( | ||
oggPage[absoluteGranulePosition] - this._beginningSampleOffset, | ||
); | ||
// trim any extra samples that are decoded beyond the absoluteGranulePosition, relative to where we started in the stream | ||
const samplesToTrim = Math.round( | ||
((totalDecodedSamples_48000 - totalOggSamples_48000) / 48000) * | ||
((totalDecodedSamples_48000 - oggPage[totalSamples]) / 48000) * | ||
this._sampleRate, | ||
); | ||
for (let i = 0; i < channelData.length; i++) { | ||
channelData[i] = channelData[i].subarray( | ||
0, | ||
samplesDecoded - samplesToTrim, | ||
); | ||
if (samplesToTrim > 0) { | ||
for (let i = 0; i < channelData.length; i++) { | ||
channelData[i] = channelData[i].subarray( | ||
0, | ||
samplesDecoded - samplesToTrim, | ||
); | ||
} | ||
} | ||
@@ -133,0 +120,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195726
725
+ Addedcodec-parser@2.5.0(transitive)
- Removedcodec-parser@2.4.3(transitive)
Updatedcodec-parser@2.5.0