| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * @fileOverview This file includes legacy utility functions for the layout | 7 * @fileOverview This file includes legacy utility functions for the layout |
| 8 * test. | 8 * test. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // an exact match between it and the actual floating-point result. | 207 // an exact match between it and the actual floating-point result. |
| 208 if (Math.abs(diff) > scaleFactor) | 208 if (Math.abs(diff) > scaleFactor) |
| 209 diffCount++; | 209 diffCount++; |
| 210 } | 210 } |
| 211 | 211 |
| 212 var snr = 10 * Math.log10(signalPower / noisePower); | 212 var snr = 10 * Math.log10(signalPower / noisePower); |
| 213 var maxErrorULP = maxError * scaleFactor; | 213 var maxErrorULP = maxError * scaleFactor; |
| 214 | 214 |
| 215 Should("SNR", snr).beGreaterThanOrEqualTo(thresholdSNR); | 215 Should("SNR", snr).beGreaterThanOrEqualTo(thresholdSNR); |
| 216 | 216 |
| 217 Should('Maximum difference (in ulp units (' + bitDepth + '-bits))', | 217 Should(options.prefix + ': Maximum difference (in ulp units (' + bitDepth +
'-bits))', |
| 218 maxErrorULP).beLessThanOrEqualTo(thresholdDiffULP); | 218 maxErrorULP).beLessThanOrEqualTo(thresholdDiffULP); |
| 219 | 219 |
| 220 Should('Number of differences between results', diffCount) | 220 Should(options.prefix + ': Number of differences between results', diffCount
) |
| 221 .beLessThanOrEqualTo(thresholdDiffCount); | 221 .beLessThanOrEqualTo(thresholdDiffCount); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Create an impulse in a buffer of length sampleFrameLength | 224 // Create an impulse in a buffer of length sampleFrameLength |
| 225 function createImpulseBuffer(context, sampleFrameLength) { | 225 function createImpulseBuffer(context, sampleFrameLength) { |
| 226 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR
ate); | 226 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR
ate); |
| 227 var n = audioBuffer.length; | 227 var n = audioBuffer.length; |
| 228 var dataL = audioBuffer.getChannelData(0); | 228 var dataL = audioBuffer.getChannelData(0); |
| 229 | 229 |
| 230 for (var k = 0; k < n; ++k) { | 230 for (var k = 0; k < n; ++k) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 var length = Math.min(actual.length, expected.length); | 321 var length = Math.min(actual.length, expected.length); |
| 322 | 322 |
| 323 for (var k = 0; k < length; ++k) { | 323 for (var k = 0; k < length; ++k) { |
| 324 var diff = actual[k] - expected[k]; | 324 var diff = actual[k] - expected[k]; |
| 325 signalPower += expected[k] * expected[k]; | 325 signalPower += expected[k] * expected[k]; |
| 326 noisePower += diff * diff; | 326 noisePower += diff * diff; |
| 327 } | 327 } |
| 328 | 328 |
| 329 return signalPower / noisePower; | 329 return signalPower / noisePower; |
| 330 } | 330 } |
| OLD | NEW |