mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=938450 reduce the number of offset parameters to compareChannels() f=ehsan
findFirstNonZeroSample() won't return an offset > buffer length, so clamping the result to <= 2048 is not necessary. --HG-- extra : transplant_source : %28HV%B3%9A%AA%D6%8C6n%FD%18%AE%D6g%83%03%EA%09%D4
This commit is contained in:
parent
dace222cfd
commit
dd57777655
@ -96,11 +96,12 @@ addLoadEvent(function() {
|
|||||||
is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer");
|
is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer");
|
||||||
|
|
||||||
var firstNonZero = findFirstNonZeroSample(e.inputBuffer);
|
var firstNonZero = findFirstNonZeroSample(e.inputBuffer);
|
||||||
|
ok(firstNonZero <= 2048, "First non-zero sample within range");
|
||||||
|
|
||||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero);
|
||||||
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero);
|
||||||
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 2048 - firstNonZero, firstNonZero, 0);
|
||||||
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 2048 - firstNonZero, firstNonZero, 0);
|
||||||
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||||
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||||
|
|
||||||
@ -122,10 +123,10 @@ addLoadEvent(function() {
|
|||||||
is(e.outputBuffer.length, 2048, "Correct length for the output buffer");
|
is(e.outputBuffer.length, 2048, "Correct length for the output buffer");
|
||||||
is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer");
|
is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer");
|
||||||
|
|
||||||
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 0, firstNonZero, 0, 2048 - firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), firstNonZero, 0, 2048 - firstNonZero);
|
||||||
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 0, firstNonZero, 0, 2048 - firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), firstNonZero, 0, 2048 - firstNonZero);
|
||||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), undefined, firstNonZero);
|
||||||
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero);
|
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), undefined, firstNonZero);
|
||||||
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||||
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ function fuzzyCompare(a, b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function compareChannels(buf1, buf2,
|
function compareChannels(buf1, buf2,
|
||||||
/*optional*/ offset,
|
|
||||||
/*optional*/ length,
|
/*optional*/ length,
|
||||||
/*optional*/ sourceOffset,
|
/*optional*/ sourceOffset,
|
||||||
/*optional*/ destOffset,
|
/*optional*/ destOffset,
|
||||||
@ -36,15 +35,15 @@ function compareChannels(buf1, buf2,
|
|||||||
if (!skipLengthCheck) {
|
if (!skipLengthCheck) {
|
||||||
is(buf1.length, buf2.length, "Channels must have the same length");
|
is(buf1.length, buf2.length, "Channels must have the same length");
|
||||||
}
|
}
|
||||||
if (length == undefined) {
|
|
||||||
length = buf1.length - (offset || 0);
|
|
||||||
}
|
|
||||||
sourceOffset = sourceOffset || 0;
|
sourceOffset = sourceOffset || 0;
|
||||||
destOffset = destOffset || 0;
|
destOffset = destOffset || 0;
|
||||||
|
if (length == undefined) {
|
||||||
|
length = buf1.length - sourceOffset;
|
||||||
|
}
|
||||||
var difference = 0;
|
var difference = 0;
|
||||||
var maxDifference = 0;
|
var maxDifference = 0;
|
||||||
var firstBadIndex = -1;
|
var firstBadIndex = -1;
|
||||||
for (var i = offset || 0; i < Math.min(buf1.length, (offset || 0) + length); ++i) {
|
for (var i = 0; i < length; ++i) {
|
||||||
if (!fuzzyCompare(buf1[i + sourceOffset], buf2[i + destOffset])) {
|
if (!fuzzyCompare(buf1[i + sourceOffset], buf2[i + destOffset])) {
|
||||||
difference++;
|
difference++;
|
||||||
maxDifference = Math.max(maxDifference, Math.abs(buf1[i + sourceOffset] - buf2[i + destOffset]));
|
maxDifference = Math.max(maxDifference, Math.abs(buf1[i + sourceOffset] - buf2[i + destOffset]));
|
||||||
@ -79,7 +78,7 @@ function compareBuffers(got, expected) {
|
|||||||
|
|
||||||
for (var i = 0; i < got.numberOfChannels; ++i) {
|
for (var i = 0; i < got.numberOfChannels; ++i) {
|
||||||
compareChannels(got.getChannelData(i), expected.getChannelData(i),
|
compareChannels(got.getChannelData(i), expected.getChannelData(i),
|
||||||
0, got.length, 0, 0, true);
|
got.length, 0, 0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +193,6 @@ function runTest()
|
|||||||
for (var i = 0; i < e.renderedBuffer.numberOfChannels; ++i) {
|
for (var i = 0; i < e.renderedBuffer.numberOfChannels; ++i) {
|
||||||
compareChannels(e.renderedBuffer.getChannelData(i),
|
compareChannels(e.renderedBuffer.getChannelData(i),
|
||||||
expectedBuffer.getChannelData(i),
|
expectedBuffer.getChannelData(i),
|
||||||
undefined,
|
|
||||||
expectedBuffer.length,
|
expectedBuffer.length,
|
||||||
samplesSeen,
|
samplesSeen,
|
||||||
undefined,
|
undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user