Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitdepth

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitdepth - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0

10

dist/bitdepth-min.js

@@ -1,5 +0,5 @@

var k="function"==typeof Object.defineProperties?Object.defineProperty:function(d,b,a){d!=Array.prototype&&d!=Object.prototype&&(d[b]=a.value)},m="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function n(d,b){if(b){var a=m;d=d.split(".");for(var c=0;c<d.length-1;c++){var e=d[c];e in a||(a[e]={});a=a[e]}d=d[d.length-1];c=a[d];b=b(c);b!=c&&null!=b&&k(a,d,{configurable:!0,writable:!0,value:b})}}
n("Object.is",function(d){return d?d:function(b,a){return b===a?0!==b||1/b===1/a:b!==b&&a!==a}});n("Array.prototype.includes",function(d){return d?d:function(b,a){var c=this;c instanceof String&&(c=String(c));var d=c.length;for(a=a||0;a<d;a++)if(c[a]==b||Object.is(c[a],b))return!0;return!1}});
(function(d){function b(c){if(a[c])return a[c].a;var e=a[c]={v:c,j:!1,a:{}};d[c].call(e.a,e,e.a,b);e.j=!0;return e.a}var a={};b.u=d;b.m=a;b.h=function(c,a){b.i(c)||Object.defineProperty(c,"a",{configurable:!1,enumerable:!0,get:a})};b.o=function(c){var a=c&&c.l?function(){return c["default"]}:function(){return c};b.h(a,a);return a};b.i=function(a){return Object.prototype.hasOwnProperty.call(a,"a")};b.s="";return b(b.w=0)})([function(d){function b(g,f,b){if(f!=b){l(f);l(b);var d=["32f","64"].includes(f)?
["32f","64"].includes(b)?p:e:["32f","64"].includes(b)?q:c;var h={g:Math.pow(2,parseInt(f,10))/2,c:Math.pow(2,parseInt(b,10))/2,f:Math.pow(2,parseInt(f,10))/2-1,b:Math.pow(2,parseInt(b,10))/2-1};a(g,f,!1);for(f=0;f<g.length;f++)g[f]=d(g[f],h);a(g,b,!0)}}function a(b,a,c){if("8"==a)if(c)for(a=0;a<b.length;a++)b[a]+=128;else for(a=0;a<b.length;a++)b[a]-=128}function c(a,b){return a=0<a?parseInt(a/b.f*b.b,10):parseInt(a/b.g*b.c,10)}function e(a,b){return parseInt(0<a?a*b.b:a*b.c,10)}function q(a,b){return 0<
a?a/b.f:a/b.g}function p(a){h[0]=a;return a=h[0]}function l(a){if("32f"!=a&&"64"!=a&&("8">parseInt(a,10)||"53"<parseInt(a,10)))throw Error("Invalid bit depth.");}var h=new Float32Array(1);d.a=b;window.bitDepth=window.bitDepth||{};window.bitDepth.toBitDepth=b}]);
var l="function"==typeof Object.defineProperties?Object.defineProperty:function(c,a,b){c!=Array.prototype&&c!=Object.prototype&&(c[a]=b.value)},n="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function p(c,a){if(a){var b=n;c=c.split(".");for(var d=0;d<c.length-1;d++){var f=c[d];f in b||(b[f]={});b=b[f]}c=c[c.length-1];d=b[c];a=a(d);a!=d&&null!=a&&l(b,c,{configurable:!0,writable:!0,value:a})}}
p("Object.is",function(c){return c?c:function(a,b){return a===b?0!==a||1/a===1/b:a!==a&&b!==b}});p("Array.prototype.includes",function(c){return c?c:function(a,b){var d=this;d instanceof String&&(d=String(d));var c=d.length;for(b=b||0;b<c;b++)if(d[b]==a||Object.is(d[b],a))return!0;return!1}});
(function(c){function a(d){if(b[d])return b[d].a;var f=b[d]={v:d,j:!1,a:{}};c[d].call(f.a,f,f.a,a);f.j=!0;return f.a}var b={};a.u=c;a.m=b;a.h=function(d,b){a.i(d)||Object.defineProperty(d,"a",{configurable:!1,enumerable:!0,get:b})};a.o=function(d){var b=d&&d.l?function(){return d["default"]}:function(){return d};a.h(b,b);return b};a.i=function(b){return Object.prototype.hasOwnProperty.call(b,"a")};a.s="";return a(a.w=0)})([function(c){function a(a,e,c,g){if("64"!=e||"64"!=c){m(e);m(c);g=g||a;var k=
a.length;var h=["32f","64"].includes(e)?["32f","64"].includes(c)?q:d:["32f","64"].includes(c)?f:b;var r={g:Math.pow(2,parseInt(e,10))/2,c:Math.pow(2,parseInt(c,10))/2,f:Math.pow(2,parseInt(e,10))/2-1,b:Math.pow(2,parseInt(c,10))/2-1};if("8"==e)for(e=0;e<k;e++)g[e]=a[e]-=128;for(e=0;e<k;e++)g[e]=h(a[e],r);if("8"==c)for(a=0;a<k;a++)g[a]=g[a]+=128}}function b(a,b){return a=0<a?parseInt(a/b.f*b.b,10):parseInt(a/b.g*b.c,10)}function d(a,b){return parseInt(0<a?a*b.b:a*b.c,10)}function f(a,b){return 0<a?
a/b.f:a/b.g}function q(a){h[0]=a;return a=h[0]}function m(a){if("32f"!=a&&"64"!=a&&("8">parseInt(a,10)||"53"<parseInt(a,10)))throw Error("Invalid bit depth.");}var h=new Float32Array(1);c.a=a;window.bitDepth=window.bitDepth||{};window.bitDepth.toBitDepth=a}]);

@@ -20,39 +20,31 @@ /**

* One of "8" ... "53", "32f", "64"
* @param {Array<number>=} outputArray An optional array to write converted samples to.
* Useful for writing to typed arrays.
*/
function toBitDepth(samples, original, target) {
if (original != target) {
validateBitDepth_(original);
validateBitDepth_(target);
let toFunction = getBitDepthFunction_(original, target);
let options = {
oldMin: Math.pow(2, parseInt(original, 10)) / 2,
newMin: Math.pow(2, parseInt(target, 10)) / 2,
oldMax: (Math.pow(2, parseInt(original, 10)) / 2) - 1,
newMax: (Math.pow(2, parseInt(target, 10)) / 2) - 1,
};
signed8Bit_(samples, original, false);
for (let i=0; i<samples.length; i++) {
samples[i] = toFunction(samples[i], options);
function toBitDepth(samples, original, target, outputArray) {
if (original == "64" && target == "64") {
return;
}
validateBitDepth_(original);
validateBitDepth_(target);
outputArray = outputArray || samples;
const len = samples.length;
let toFunction = getBitDepthFunction_(original, target);
let options = {
oldMin: Math.pow(2, parseInt(original, 10)) / 2,
newMin: Math.pow(2, parseInt(target, 10)) / 2,
oldMax: (Math.pow(2, parseInt(original, 10)) / 2) - 1,
newMax: (Math.pow(2, parseInt(target, 10)) / 2) - 1,
};
if (original == "8") {
for (let i=0; i<len; i++) {
outputArray[i] = samples[i] -= 128;
}
signed8Bit_(samples, target, true);
}
}
/**
* Sign or unsign 8-bit samples.
* The input array is modified in-place.
* @param {!Array<number>} samples The samples.
* @param {!string} bitDepth The original bit depth of the data.
* @param {!boolean} signed True if should sign the samples, false otherwise.
*/
function signed8Bit_(samples, bitDepth, signed) {
if (bitDepth == "8") {
if (signed) {
for (let i=0; i<samples.length; i++) {
samples[i] += 128;
}
} else {
for (let i=0; i<samples.length; i++) {
samples[i] -= 128;
}
for (let i=0; i<len; i++) {
outputArray[i] = toFunction(samples[i], options);
}
if (target == "8") {
for (let i=0; i<len; i++) {
outputArray[i] = outputArray[i] += 128;
}

@@ -59,0 +51,0 @@ }

{
"name": "bitdepth",
"version": "3.0.3",
"version": "3.1.0",
"description": "Change the resolution of samples to and from 8, 11, 12, 16, 20, 24, 32, 48 & 64-bit.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rochars/bitdepth",

@@ -38,8 +38,10 @@ # bitdepth

* @param {!Array<number>} samples The samples.
* @param {!string} originalBitDepth The original bit depth of the data.
* @param {!string} original The original bit depth of the data.
* One of "8" ... "53", "32f", "64"
* @param {!string} targetBitDepth The desired bit depth for the data.
* @param {!string} target The desired bit depth for the data.
* One of "8" ... "53", "32f", "64"
* @param {Array<number>=} outputArray An optional array to write converted samples to.
* Useful for writing to typed arrays.
*/
function toBitDepth(samples, originalBitDepth, targetBitDepth) {}
function toBitDepth(samples, original, target, outputArray) {}
```

@@ -46,0 +48,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc