Title: [267367] trunk
Revision
267367
Author
[email protected]
Date
2020-09-21 14:17:46 -0700 (Mon, 21 Sep 2020)

Log Message

AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
https://bugs.webkit.org/show_bug.cgi?id=216790

Reviewed by Eric Carlson.

Source/WebCore:

AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values.
The specification [1] says:
"If V0 and V1 have opposite signs or if V0 is zero, then v(t) = V0 for T0 <= t < T1."

Our implementation did not match the specification and would just special-case if either
V0 or V1 was negative.

[1] https://www.w3.org/TR/webaudio/#dom-audioparam-exponentialramptovalueattime

No new tests, rebaselined existing test.

* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::AudioParamTimeline::valuesForTimeRangeImpl):

LayoutTests:

Rebaseline test that is now passing.

* webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (267366 => 267367)


--- trunk/LayoutTests/ChangeLog	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/LayoutTests/ChangeLog	2020-09-21 21:17:46 UTC (rev 267367)
@@ -1,3 +1,14 @@
+2020-09-21  Chris Dumez  <[email protected]>
+
+        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
+        https://bugs.webkit.org/show_bug.cgi?id=216790
+
+        Reviewed by Eric Carlson.
+
+        Rebaseline test that is now passing.
+
+        * webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt:
+
 2020-09-21  Youenn Fablet  <[email protected]>
 
         [iOS] MediaRecorder incorrect screen orientation handling

Modified: trunk/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt (267366 => 267367)


--- trunk/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt	2020-09-21 21:17:46 UTC (rev 267367)
@@ -6,41 +6,17 @@
 PASS Executing "propagate" 
 PASS Audit report 
 PASS > [both negative values]  
-FAIL X Negative exponential ramp from -1 to -2 expected to be equal to the array [-1,-1.0001155138015747,-1.0002310276031494,-1.0003465414047241,-1.0004620552062988,-1.0005775690078735,-1.0006932020187378,-1.000808835029602,-1.0009244680404663,-1.0010401010513306,-1.0011557340621948,-1.001271367073059,-1.0013870000839233,-1.0015026330947876,-1.0016182661056519,-1.0017340183258057...] but differs in 6000 places:
-	Index	Actual			Expected
-	[0]	1.0000000000000000e+0	-1.0000000000000000e+0
-	[1]	1.0000000000000000e+0	-1.0001155138015747e+0
-	[2]	1.0000000000000000e+0	-1.0002310276031494e+0
-	[3]	1.0000000000000000e+0	-1.0003465414047241e+0
-	...and 5996 more errors. assert_true: expected true got false
-FAIL < [both negative values] 1 out of 1 assertions were failed. assert_true: expected true got false
+PASS   Negative exponential ramp from -1 to -2 is identical to the array [expected array]. 
+PASS < [both negative values] All assertions passed. (total 1 assertions) 
 PASS > [negative-end]  
-FAIL X Exponential ramp from 2 to -1: Expected 2 for all values but found 6000 unexpected values: 
-	Index	Actual
-	[0]	1
-	[1]	1
-	[2]	1
-	[3]	1
-	...and 5996 more errors. assert_true: expected true got false
-FAIL < [negative-end] 1 out of 1 assertions were failed. assert_true: expected true got false
+PASS   Exponential ramp from 2 to -1 contains only the constant 2. 
+PASS < [negative-end] All assertions passed. (total 1 assertions) 
 PASS > [positive-end]  
-FAIL X Exponential ramp from -1 to 1: Expected -1 for all values but found 6000 unexpected values: 
-	Index	Actual
-	[0]	1
-	[1]	1
-	[2]	1
-	[3]	1
-	...and 5996 more errors. assert_true: expected true got false
-FAIL < [positive-end] 1 out of 1 assertions were failed. assert_true: expected true got false
+PASS   Exponential ramp from -1 to 1 contains only the constant -1. 
+PASS < [positive-end] All assertions passed. (total 1 assertions) 
 PASS > [propagate]  
-FAIL X Exponential ramp from -1 to 1 after the end of the linear ramp: Expected -1 for all values but found 1500 unexpected values: 
-	Index	Actual
-	[0]	-0.9980001449584961
-	[1]	-0.9980001449584961
-	[2]	-0.9980001449584961
-	[3]	-0.9980001449584961
-	...and 1496 more errors. assert_true: expected true got false
+PASS   Exponential ramp from -1 to 1 after the end of the linear ramp contains only the constant -1. 
 PASS   Exponential ramp after end of ramp contains only the constant 1. 
-FAIL < [propagate] 1 out of 2 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 4 out of 4 tasks were failed. assert_true: expected true got false
+PASS < [propagate] All assertions passed. (total 2 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 4 tasks ran successfully. 
 

Modified: trunk/LayoutTests/webaudio/AudioParam/audioparam-setTargetAtTime-continuous-expected.txt (267366 => 267367)


--- trunk/LayoutTests/webaudio/AudioParam/audioparam-setTargetAtTime-continuous-expected.txt	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/LayoutTests/webaudio/AudioParam/audioparam-setTargetAtTime-continuous-expected.txt	2020-09-21 21:17:46 UTC (rev 267367)
@@ -42,16 +42,15 @@
 PASS   Exponential ramp: SetTarget part was correctly replaced by the ramp 
 FAIL X Exponential ramp does not equal [1,1.00030517578125,1.0006103515625,1.0009156465530396,1.0012210607528687,1.0015265941619873,1.001832127571106,1.0021378993988037,1.0024436712265015,1.0027495622634888,1.003055453300476,1.0033615827560425,1.0036677122116089,1.0039739608764648,1.0042803287506104,1.0045866966247559...] with an element-wise tolerance of {"absoluteThreshold":0.0000114441,"relativeThreshold":0}.
 	Index	Actual			Expected		AbsError		RelError		Test threshold
-	[1]	1.0000000000000000e+0	1.0003051757812500e+0	3.0517578125000000e-4	3.0508267740557692e-4	1.1444099999999999e-5
-	[2]	1.0000000000000000e+0	1.0006103515625000e+0	6.1035156250000000e-4	6.0997926070513605e-4	1.1444099999999999e-5
-	[3]	1.0000000000000000e+0	1.0009156465530396e+0	9.1564655303955078e-4	9.1480891141312545e-4	1.1444099999999999e-5
-	[4]	1.0000000000000000e+0	1.0012210607528687e+0	1.2210607528686523e-3	1.2195715818747112e-3	1.1444099999999999e-5
-	[5]	1.0000000000000000e+0	1.0015265941619873e+0	1.5265941619873047e-3	1.5242672245410118e-3	1.1444099999999999e-5
-	...and 2266 more errors.
-	Max AbsError of 9.9938988685607910e-1 at index of 2271.
-	[2271]	1.0000000000000000e+0	1.9993898868560791e+0	9.9938988685607910e-1	4.9984742517006520e-1	1.1444099999999999e-5
-	Max RelError of 4.9984742517006520e-1 at index of 2271.
-	[2271]	1.0000000000000000e+0	1.9993898868560791e+0	9.9938988685607910e-1	4.9984742517006520e-1	1.1444099999999999e-5
+	[0]	0.0000000000000000e+0	1.0000000000000000e+0	1.0000000000000000e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	[1]	0.0000000000000000e+0	1.0003051757812500e+0	1.0003051757812500e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	[2]	0.0000000000000000e+0	1.0006103515625000e+0	1.0006103515625000e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	[3]	0.0000000000000000e+0	1.0009156465530396e+0	1.0009156465530396e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	[4]	0.0000000000000000e+0	1.0012210607528687e+0	1.0012210607528687e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	...and 2267 more errors.
+	Max AbsError of 1.9993898868560791e+0 at index of 2271.
+	[2271]	0.0000000000000000e+0	1.9993898868560791e+0	1.9993898868560791e+0	1.0000000000000000e+0	1.1444099999999999e-5
+	Max RelError of 1.0000000000000000e+0 at index of 0.
  assert_true: expected true got false
 PASS   Exponential ramp: Tail part equals [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 
 FAIL < [expo ramp replace] 1 out of 4 assertions were failed. assert_true: expected true got false
@@ -60,16 +59,15 @@
 PASS   Delayed exponential ramp: SetTarget part equals [expected array] with an element-wise tolerance of {"absoluteThreshold":3.43632e-7,"relativeThreshold":0}. 
 FAIL X Delayed exponential ramp does not equal [0.4493289589881897,0.4496844708919525,0.45004022121429443,0.4503962993621826,0.4507526457309723,0.45110926032066345,0.4514661729335785,0.451823353767395,0.4521808326244354,0.4525385797023773,0.4528966248035431,0.45325493812561035,0.4536135494709015,0.4539724290370941,0.4543316066265106,0.4546910524368286...] with an element-wise tolerance of {"absoluteThreshold":0.00000429154,"relativeThreshold":0}.
 	Index	Actual			Expected		AbsError		RelError		Test threshold
-	[0]	4.5026594400405884e-1	4.4932895898818970e-1	9.3698501586914063e-4	2.0852985260043492e-3	4.2915399999999997e-6
-	[1]	4.5026594400405884e-1	4.4968447089195251e-1	5.8147311210632324e-4	1.2930691401305608e-3	4.2915399999999997e-6
-	[2]	4.5026594400405884e-1	4.5004022121429443e-1	2.2572278976440430e-4	5.0156136968238332e-4	4.2915399999999997e-6
-	[3]	4.5026594400405884e-1	4.5039629936218262e-1	1.3035535812377930e-4	2.8942368822385700e-4	4.2915399999999997e-6
-	[4]	4.5026594400405884e-1	4.5075264573097229e-1	4.8670172691345215e-4	1.0797534557432987e-3	4.2915399999999997e-6
+	[0]	0.0000000000000000e+0	4.4932895898818970e-1	4.4932895898818970e-1	1.0000000000000000e+0	4.2915399999999997e-6
+	[1]	0.0000000000000000e+0	4.4968447089195251e-1	4.4968447089195251e-1	1.0000000000000000e+0	4.2915399999999997e-6
+	[2]	0.0000000000000000e+0	4.5004022121429443e-1	4.5004022121429443e-1	1.0000000000000000e+0	4.2915399999999997e-6
+	[3]	0.0000000000000000e+0	4.5039629936218262e-1	4.5039629936218262e-1	1.0000000000000000e+0	4.2915399999999997e-6
+	[4]	0.0000000000000000e+0	4.5075264573097229e-1	4.5075264573097229e-1	1.0000000000000000e+0	4.2915399999999997e-6
 	...and 1883 more errors.
-	Max AbsError of 1.5481528639793396e+0 at index of 1887.
-	[1887]	4.5026594400405884e-1	1.9984188079833984e+0	1.5481528639793396e+0	7.7468889794005613e-1	4.2915399999999997e-6
-	Max RelError of 7.7468889794005613e-1 at index of 1887.
-	[1887]	4.5026594400405884e-1	1.9984188079833984e+0	1.5481528639793396e+0	7.7468889794005613e-1	4.2915399999999997e-6
+	Max AbsError of 1.9984188079833984e+0 at index of 1887.
+	[1887]	0.0000000000000000e+0	1.9984188079833984e+0	1.9984188079833984e+0	1.0000000000000000e+0	4.2915399999999997e-6
+	Max RelError of 1.0000000000000000e+0 at index of 0.
  assert_true: expected true got false
 PASS   Delayed exponential ramp: Tail part equals [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 
 FAIL < [delayed expo ramp] 1 out of 4 assertions were failed. assert_true: expected true got false

Modified: trunk/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end-expected.txt (267366 => 267367)


--- trunk/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end-expected.txt	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end-expected.txt	2020-09-21 21:17:46 UTC (rev 267367)
@@ -14,10 +14,10 @@
 FAIL X setValueCurve(..., 0, 0.0100390625).linearRampToValueAtTime(2, 0.02): value at time 0.010078125 is not close to 0.3066666666666668 within a relative error of 1.8141e-8 (RelErr=2.2863451086956506). Got 1.0078125. assert_true: expected true got false
 FAIL < [1: linearRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
 PASS > [2: exponentialRampToValueAtTime]  
-FAIL X setValueCurve(..., 0, 0.01).exponentialRampToValueAtTime(2, 0.02): value at time 0.01 is not close to 0.3 within a relative error of 3.9737e-8 (RelErr=2.3333333333333335). Got 1. assert_true: expected true got false
+FAIL X setValueCurve(..., 0, 0.01).exponentialRampToValueAtTime(2, 0.02): value at time 0.01 is not close to 0.3 within a relative error of 3.9737e-8 (RelErr=1). Got 0. assert_true: expected true got false
 FAIL < [2: exponentialRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
 PASS > [3: exponentialRampToValueAtTime]  
-FAIL X setValueCurve(..., 0, 0.0100390625).exponentialRampToValueAtTime(2, 0.02): value at time 0.010078125 is not close to 0.30224022883150364 within a relative error of 7.8294e-8 (RelErr=2.308626399159761). Got 1. assert_true: expected true got false
+FAIL X setValueCurve(..., 0, 0.0100390625).exponentialRampToValueAtTime(2, 0.02): value at time 0.010078125 is not close to 0.30224022883150364 within a relative error of 7.8294e-8 (RelErr=1). Got 0. assert_true: expected true got false
 FAIL < [3: exponentialRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
 PASS > [4: setTargetAtTime]  
 PASS   setValueCurve(..., 0, 0.01).setTargetAtTime(2, 0.02, 0.01): value at time 0.01 is 0.30000000000000004 within an error of 1.5895e-7. 

Modified: trunk/Source/WebCore/ChangeLog (267366 => 267367)


--- trunk/Source/WebCore/ChangeLog	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/Source/WebCore/ChangeLog	2020-09-21 21:17:46 UTC (rev 267367)
@@ -1,3 +1,24 @@
+2020-09-21  Chris Dumez  <[email protected]>
+
+        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
+        https://bugs.webkit.org/show_bug.cgi?id=216790
+
+        Reviewed by Eric Carlson.
+
+        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values.
+        The specification [1] says:
+        "If V0 and V1 have opposite signs or if V0 is zero, then v(t) = V0 for T0 <= t < T1."
+
+        Our implementation did not match the specification and would just special-case if either
+        V0 or V1 was negative.
+
+        [1] https://www.w3.org/TR/webaudio/#dom-audioparam-exponentialramptovalueattime
+
+        No new tests, rebaselined existing test.
+
+        * Modules/webaudio/AudioParamTimeline.cpp:
+        (WebCore::AudioParamTimeline::valuesForTimeRangeImpl):
+
 2020-09-21  Youenn Fablet  <[email protected]>
 
         [iOS] MediaRecorder incorrect screen orientation handling

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp (267366 => 267367)


--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp	2020-09-21 20:57:17 UTC (rev 267366)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp	2020-09-21 21:17:46 UTC (rev 267367)
@@ -420,8 +420,10 @@
         if (nextEventType == ParamEvent::LinearRampToValue)
             processLinearRamp(values, writeIndex, fillToFrame, value, value1, value2, deltaTime, time1, samplingPeriod, currentFrame);
         else if (nextEventType == ParamEvent::ExponentialRampToValue) {
-            if (value1 <= 0 || value2 <= 0) {
-                // Handle negative values error case by propagating previous value.
+            if (!value1 || value1 * value2 < 0) {
+                // Per the specification:
+                // If value1 and value2 have opposite signs or if value1 is zero, then v(t) = value1 for T0 <= t < T1.
+                value = value1;
                 for (; writeIndex < fillToFrame; ++writeIndex)
                     values[writeIndex] = value;
             } else {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to