From 618aec2ae2825346cda086e30082424f1baa126f Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Fri, 20 Nov 2015 16:39:35 +0100 Subject: [PATCH 1/5] Backed out changeset 74caf0456e1e (bug 1222866) --- dom/media/gtest/TestTimeUnit.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 dom/media/gtest/TestTimeUnit.cpp diff --git a/dom/media/gtest/TestTimeUnit.cpp b/dom/media/gtest/TestTimeUnit.cpp deleted file mode 100644 index 605e0e90c902..000000000000 --- a/dom/media/gtest/TestTimeUnit.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "gtest/gtest.h" -#include "TimeUnits.h" -#include -#include - -using namespace mozilla; - -TEST(TimeUnit, Rounding) -{ - int64_t usecs = 66261715; - double seconds = media::TimeUnit::FromMicroseconds(usecs).ToSeconds(); - EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs); - - seconds = 4.169470; - usecs = 4169470; - EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs); -} From 5b0d94ec876bd67c2d1bd853fd90c147714bcc88 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Fri, 20 Nov 2015 16:39:37 +0100 Subject: [PATCH 2/5] Backed out changeset 002714e2ccba (bug 1222866) --- dom/media/TimeUnits.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dom/media/TimeUnits.h b/dom/media/TimeUnits.h index d815b9d4032b..2f03fded7726 100644 --- a/dom/media/TimeUnits.h +++ b/dom/media/TimeUnits.h @@ -93,9 +93,7 @@ public: if (mozilla::IsInfinite(aValue)) { return FromInfinity(); } - // Due to internal double representation, this - // operation is not commutative, do not attempt to simplify. - double val = (aValue + .0000005) * USECS_PER_S; + double val = aValue * USECS_PER_S; if (val >= double(INT64_MAX)) { return FromMicroseconds(INT64_MAX); } else if (val <= double(INT64_MIN)) { From d316442a2d8597661e2ee89e9571066d5076c23d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 19 Nov 2015 16:07:00 +0100 Subject: [PATCH 3/5] Bug 1222866: P1. Round second to closest microseconds. r=gerald. Due to the internal double representation as per IEEE 754, during conversion the use of ints would have rounded down our value. --- dom/media/TimeUnits.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dom/media/TimeUnits.h b/dom/media/TimeUnits.h index 2f03fded7726..d815b9d4032b 100644 --- a/dom/media/TimeUnits.h +++ b/dom/media/TimeUnits.h @@ -93,7 +93,9 @@ public: if (mozilla::IsInfinite(aValue)) { return FromInfinity(); } - double val = aValue * USECS_PER_S; + // Due to internal double representation, this + // operation is not commutative, do not attempt to simplify. + double val = (aValue + .0000005) * USECS_PER_S; if (val >= double(INT64_MAX)) { return FromMicroseconds(INT64_MAX); } else if (val <= double(INT64_MIN)) { From 1b4c99671f2c93800673bdf7218fdf57b6dd36b7 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 19 Nov 2015 16:08:00 +0100 Subject: [PATCH 4/5] Bug 1222866: P2. Add gtest checking on seconds -> microseconds -> seconds. r=gerald --- dom/media/gtest/TestTimeUnit.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 dom/media/gtest/TestTimeUnit.cpp diff --git a/dom/media/gtest/TestTimeUnit.cpp b/dom/media/gtest/TestTimeUnit.cpp new file mode 100644 index 000000000000..605e0e90c902 --- /dev/null +++ b/dom/media/gtest/TestTimeUnit.cpp @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gtest/gtest.h" +#include "TimeUnits.h" +#include +#include + +using namespace mozilla; + +TEST(TimeUnit, Rounding) +{ + int64_t usecs = 66261715; + double seconds = media::TimeUnit::FromMicroseconds(usecs).ToSeconds(); + EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs); + + seconds = 4.169470; + usecs = 4169470; + EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs); +} From e4f9d8efb22f39dc349616b4ca1d3bb33d5e9d5d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 20 Nov 2015 20:14:51 +1100 Subject: [PATCH 5/5] Bug 1222866: P3. Fix mochitest. r=me a=tomcat for fixing perma failure Actual calculated duration was 9.2879819869995117. The new behaviour and rounded value is as such more correct --HG-- extra : amend_source : 3c586cd3e43d37033f94a94552fcddf6f1021152 --- dom/media/test/manifest.js | 8 ++++---- dom/media/test/test_fragment_play.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dom/media/test/manifest.js b/dom/media/test/manifest.js index 2477d29db280..eea01e9cd208 100644 --- a/dom/media/test/manifest.js +++ b/dom/media/test/manifest.js @@ -68,7 +68,7 @@ var gLongerTests = [ // during resource download. var gProgressTests = [ { name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0, size:11069 }, - { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 }, + { name:"big.wav", type:"audio/x-wav", duration:9.278982, size:102444 }, { name:"seek.ogv", type:"video/ogg", duration:3.966, size:285310 }, { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266, size:28942 }, { name:"seek.webm", type:"video/webm", duration:3.966, size:215529 }, @@ -115,7 +115,7 @@ var gPausedAfterEndedTests = gSmallTests.concat([ // Test the mozHasAudio property, and APIs that detect different kinds of // tracks var gTrackTests = [ - { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444, hasAudio:true, hasVideo:false }, + { name:"big.wav", type:"audio/x-wav", duration:9.278982, size:102444, hasAudio:true, hasVideo:false }, { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266, size:28942, hasAudio:false, hasVideo:true }, { name:"short-video.ogv", type:"video/ogg", duration:1.081, hasAudio:true, hasVideo:true }, { name:"seek.webm", type:"video/webm", duration:3.966, size:215529, hasAudio:false, hasVideo:true }, @@ -267,7 +267,7 @@ var gPlayTests = [ // A file for each type we can support. var gSnifferTests = [ - { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 }, + { name:"big.wav", type:"audio/x-wav", duration:9.278982, size:102444 }, { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233, size:28942 }, { name:"seek.webm", type:"video/webm", duration:3.966, size:215529 }, { name:"gizmo.mp4", type:"video/mp4", duration:5.56, size:383631 }, @@ -560,7 +560,7 @@ var gDecodeErrorTests = [ // These are files that are used for media fragments tests var gFragmentTests = [ - { name:"big.wav", type:"audio/x-wav", duration:9.278981, size:102444 } + { name:"big.wav", type:"audio/x-wav", duration:9.278982, size:102444 } ]; // Used by test_chaining.html. The |links| attributes is the number of links in diff --git a/dom/media/test/test_fragment_play.html b/dom/media/test/test_fragment_play.html index 13dfef6313be..cd6e9d141f24 100644 --- a/dom/media/test/test_fragment_play.html +++ b/dom/media/test/test_fragment_play.html @@ -23,7 +23,7 @@ var gFragmentParams = [ { fragment: "#t=3,3", start: null, end: null }, { fragment: "#t=7,3", start: null, end: null }, { fragment: "#t=7,15", start: 7, end: null }, - { fragment: "#t=15,20", start: 9.287981, end: null }, + { fragment: "#t=15,20", start: 9.287982, end: null }, { fragment: "#t=5", start: 5, end: null }, { fragment: "#t=5.5", start: 5.5, end: null }, { fragment: "#t=5,", start: null, end: null },