2011-02-04 Jer Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 23:48:25 +0000 (23:48 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 23:48:25 +0000 (23:48 +0000)
        Reviewed by Eric Carlson.

        Frame accurate seeking isn't always accurate
        https://bugs.webkit.org/show_bug.cgi?id=52697

        New pixel test that seeks to specific currentTimes and records the rendered frame.

        * media/content/test-25fps.mp4: Added.
        * media/content/test-25fps.ogv: Added.
        * media/video-frame-accurate-seek-expected.txt: Added.
        * media/video-frame-accurate-seek.html: Added.
        * platform/mac/media/video-frame-accurate-seek-expected.checksum: Added.
        * platform/mac/media/video-frame-accurate-seek-expected.png: Added.
2011-02-04  Jer Noble  <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        Frame accurate seeking isn't always accurate
        https://bugs.webkit.org/show_bug.cgi?id=52697

        Test: media/video-frame-accurate-seek.html

        Make seeking slightly more accurate by rounding instead of truncating
        when converting from seconds-in-float to time/timeScale.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivateQTKit::createQTTime):
        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::mediaTimeForTimeValue):
        * platform/graphics/win/QTMovie.cpp:
        (QTMovie::setCurrentTime):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77690 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/content/test-25fps.mp4 [new file with mode: 0644]
LayoutTests/media/content/test-25fps.ogv [new file with mode: 0644]
LayoutTests/media/video-frame-accurate-seek-expected.txt [new file with mode: 0644]
LayoutTests/media/video-frame-accurate-seek.html [new file with mode: 0644]
LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
Source/WebCore/platform/graphics/win/QTMovie.cpp

index 34803a3076dcfe700968d60610c2b30a378a2efb..1e0a7b67161162bea7d5df6a59cbf79f8e3d4ee2 100644 (file)
@@ -1,3 +1,19 @@
+2011-02-04  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Frame accurate seeking isn't always accurate
+        https://bugs.webkit.org/show_bug.cgi?id=52697
+
+        New pixel test that seeks to specific currentTimes and records the rendered frame.
+
+        * media/content/test-25fps.mp4: Added.
+        * media/content/test-25fps.ogv: Added.
+        * media/video-frame-accurate-seek-expected.txt: Added.
+        * media/video-frame-accurate-seek.html: Added.
+        * platform/mac/media/video-frame-accurate-seek-expected.checksum: Added.
+        * platform/mac/media/video-frame-accurate-seek-expected.png: Added.
+
 2011-02-04  Jeremy Orlow  <jorlow@chromium.org>
 
         Reviewed by Nate Chapin.
diff --git a/LayoutTests/media/content/test-25fps.mp4 b/LayoutTests/media/content/test-25fps.mp4
new file mode 100644 (file)
index 0000000..bb15fd4
Binary files /dev/null and b/LayoutTests/media/content/test-25fps.mp4 differ
diff --git a/LayoutTests/media/content/test-25fps.ogv b/LayoutTests/media/content/test-25fps.ogv
new file mode 100644 (file)
index 0000000..4687094
Binary files /dev/null and b/LayoutTests/media/content/test-25fps.ogv differ
diff --git a/LayoutTests/media/video-frame-accurate-seek-expected.txt b/LayoutTests/media/video-frame-accurate-seek-expected.txt
new file mode 100644 (file)
index 0000000..78d55b9
--- /dev/null
@@ -0,0 +1,19 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x546
+  RenderBlock {HTML} at (0,0) size 800x546
+    RenderBody {BODY} at (8,16) size 784x522
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 715x18
+          text run at (0,0) width 715: "Test that setting currentTime is frame-accurate. The three videos below should be showing frames 12, 13, and 14."
+      RenderBlock (anonymous) at (0,34) size 784x488
+        RenderText {#text} at (320,226) size 4x18
+          text run at (320,226) width 4: " "
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+layer at (8,50) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (332,50) size 320x240
+  RenderVideo {VIDEO} at (324,0) size 320x240
+layer at (8,294) size 320x240
+  RenderVideo {VIDEO} at (0,244) size 320x240
diff --git a/LayoutTests/media/video-frame-accurate-seek.html b/LayoutTests/media/video-frame-accurate-seek.html
new file mode 100644 (file)
index 0000000..07c936a
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="media-file.js"></script>
+        <script src="video-paint-test.js"></script>
+    </head>
+    <body onload="setSrcByTagName('video', findMediaFile('video', 'content/test-25fps')); init()">
+        <p>Test that setting currentTime is frame-accurate. The three videos below should be showing frames 12, 13, and 14.</p>
+        <video oncanplaythrough='event.target.currentTime=(12/25)'></video>
+        <video oncanplaythrough='event.target.currentTime=(13/25)'></video>
+        <video oncanplaythrough='event.target.currentTime=(14.6/25)'></video>
+    </body>
+</html>
diff --git a/LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.checksum b/LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.checksum
new file mode 100644 (file)
index 0000000..f2098b4
--- /dev/null
@@ -0,0 +1 @@
+d19012c97a2b645cba7ae1db65dc7249
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.png b/LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.png
new file mode 100644 (file)
index 0000000..c984c37
Binary files /dev/null and b/LayoutTests/platform/mac/media/video-frame-accurate-seek-expected.png differ
index 9bf5c0925e563fd061cae9a9142449e2ef5f6909..213bb1b713f85b1d54732862df906bca282a59a3 100644 (file)
@@ -1,3 +1,22 @@
+2011-02-04  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Frame accurate seeking isn't always accurate
+        https://bugs.webkit.org/show_bug.cgi?id=52697
+
+        Test: media/video-frame-accurate-seek.html
+
+        Make seeking slightly more accurate by rounding instead of truncating
+        when converting from seconds-in-float to time/timeScale.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::createQTTime):
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::mediaTimeForTimeValue):
+        * platform/graphics/win/QTMovie.cpp:
+        (QTMovie::setCurrentTime):
+
 2011-02-04  Jeremy Orlow  <jorlow@chromium.org>
 
         Reviewed by Nate Chapin.
index 2361f6a7947bf31cff29e4389d039a31ed0f1985..8b1fb924c703f8754eef7f06bcb2f499e06a9123 100644 (file)
@@ -616,7 +616,7 @@ QTTime MediaPlayerPrivateQTKit::createQTTime(float time) const
     if (!metaDataAvailable())
         return QTMakeTime(0, 600);
     long timeScale = [[m_qtMovie.get() attributeForKey:QTMovieTimeScaleAttribute] longValue];
-    return QTMakeTime(time * timeScale, timeScale);
+    return QTMakeTime(lroundf(time * timeScale), timeScale);
 }
 
 void MediaPlayerPrivateQTKit::resumeLoad()
index 0b91455ea343895ff04607be20ca8575edfbc70c..d47de2b7773e01e9aef276861a0bc971dedf623b 100644 (file)
@@ -1059,7 +1059,7 @@ float MediaPlayerPrivateQuickTimeVisualContext::mediaTimeForTimeValue(float time
     if (m_readyState < MediaPlayer::HaveMetadata || !(timeScale = m_movie->timeScale()))
         return timeValue;
 
-    long mediaTimeValue = static_cast<long>(timeValue * timeScale);
+    long mediaTimeValue = lroundf(timeValue * timeScale);
     return static_cast<float>(mediaTimeValue) / timeScale;
 }
 
index ef7b1931660f53f15145a8b1eede32a6e3d41e2d..797571ef0c4159fc2df2592ca09444d4d548ee12 100644 (file)
@@ -35,6 +35,7 @@
 #include <QuickTimeComponents.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/Assertions.h>
+#include <wtf/MathExtras.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 
@@ -375,10 +376,10 @@ void QTMovie::setCurrentTime(float time) const
     m_private->m_seeking = true;
     TimeScale scale = GetMovieTimeScale(m_private->m_movie);
     if (m_private->m_movieController) {
-        QTRestartAtTimeRecord restart = { time * scale , 0 };
+        QTRestartAtTimeRecord restart = { lroundf(time * scale) , 0 };
         MCDoAction(m_private->m_movieController, mcActionRestartAtTime, (void *)&restart);
     } else
-        SetMovieTimeValue(m_private->m_movie, TimeValue(time * scale));
+        SetMovieTimeValue(m_private->m_movie, TimeValue(lroundf(time * scale)));
     QTMovieTask::sharedTask()->updateTaskTimer();
 }