2009-05-04 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2009 15:56:17 +0000 (15:56 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2009 15:56:17 +0000 (15:56 +0000)
        Reviewed by Adam Roben.

        https://bugs.webkit.org/show_bug.cgi?id=25545
        Bug 25545: HTMLMediaElement: display anamorphic video correctly

        Tell QuickTime to use clean aperture mode so movies with non-square pixels are sized
        and displayed correctly.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivate::createQTMovie): Ask QuickTime to use clean aperture mode.
        * platform/graphics/win/QTMovieWin.cpp:
        (QTMovieWin::load): Ditto. Add ASSERT to ensure that static movie property array isn't
        filled beyond capacity.

2009-05-04  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Adam Roben.

        https://bugs.webkit.org/show_bug.cgi?id=25545
        Bug 25545: HTMLMediaElement: display anamorphic video correctly

        Added 720x576i PAL anamorphic movie, extended video-size-intrinsic-scale
        test to check that it is sized correctly.

        * media/content/720x576i-anamorphic.mov: Added.
        * media/video-size-intrinsic-scale-expected.txt:
        * media/video-size-intrinsic-scale.html:

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

LayoutTests/ChangeLog
LayoutTests/media/content/720x576i-anamorphic.mov [new file with mode: 0644]
LayoutTests/media/video-size-intrinsic-scale-expected.txt
LayoutTests/media/video-size-intrinsic-scale.html
WebCore/ChangeLog
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
WebCore/platform/graphics/win/QTMovieWin.cpp

index e5e265c..44a20dc 100644 (file)
@@ -1,3 +1,17 @@
+2009-05-04  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Adam Roben.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25545
+        Bug 25545: HTMLMediaElement: display anamorphic video correctly
+        
+        Added 720x576i PAL anamorphic movie, extended video-size-intrinsic-scale
+        test to check that it is sized correctly.
+
+        * media/content/720x576i-anamorphic.mov: Added.
+        * media/video-size-intrinsic-scale-expected.txt:
+        * media/video-size-intrinsic-scale.html:
+
 2009-05-03  Eric Seidel  <eric@webkit.org>
 
         No review, just adding missing results.
diff --git a/LayoutTests/media/content/720x576i-anamorphic.mov b/LayoutTests/media/content/720x576i-anamorphic.mov
new file mode 100644 (file)
index 0000000..3c14f62
Binary files /dev/null and b/LayoutTests/media/content/720x576i-anamorphic.mov differ
index 8bdd5f5..59e2958 100644 (file)
@@ -1,15 +1,20 @@
-Test that a movie saved with a non identity matrix is sized correctly when opened
-
 Test size before movie is open:
 EXPECTED (video.videoWidth == '0') OK
 EXPECTED (video.videoHeight == '0') OK
 
+Loading "content/scaled-matrix.mov". Movie saved with a non identity matrix.
 EVENT(loadstart)
 EVENT(durationchange)
 EVENT(loadedmetadata)
-
-Test size after movie is open:
 EXPECTED (video.videoWidth == '640') OK
 EXPECTED (video.videoHeight == '480') OK
+
+Loading "content/720x576i-anamorphic.mov". Movie encoded with PAL non-square pixels and clean aperture dimenstions corrects pixel aspect ratio.
+EVENT(loadstart)
+EVENT(durationchange)
+EVENT(loadedmetadata)
+EXPECTED (video.videoWidth == '1024') OK
+EXPECTED (video.videoHeight == '576') OK
+
 END OF TEST
 
index cb5ccf0..033a402 100644 (file)
@@ -5,38 +5,77 @@
         <script src=video-test.js></script>
 
         <script>
+
+            var movieInfo = 
+            {
+                current:0,
+                movies: 
+                [ 
+                    {   
+                        url:"content/scaled-matrix.mov", 
+                        description:"saved with a non identity matrix", 
+                        width:640, 
+                        height:480 
+                    },
+                    {
+                        url:"content/720x576i-anamorphic.mov", 
+                        description:"Movie encoded with PAL non-square pixels, clean aperture corrects pixel aspect ratio when displayed", 
+                        width:1024, 
+                        height:576 
+                    },
+                ]
+            };
+
+            function testSize()
+            {
+                var movie = movieInfo.movies[movieInfo.current];
+
+                testExpected("video.videoWidth", movie.width);
+                testExpected("video.videoHeight", movie.height);
+
+                movieInfo.current++;
+                openNextMovie();
+            }
+            
+            function openNextMovie()
+            {
+                consoleWrite("");
+                if (movieInfo.current >= movieInfo.movies.length)
+                {
+                    endTest();
+                    return;
+                }
+
+                var url = movieInfo.movies[movieInfo.current].url;
+                video.src = url;
+                var desc = "<b>Loading</b> <em>\""+ url + "\"</em>" + 
+                            ". Movie " + movieInfo.movies[movieInfo.current].description + ".</em>";
+                consoleWrite(desc);
+                if (movieInfo.current > 0)
+                    video.load();
+            }
+
             function start()
             {
                 findMediaElement();
-        
+
                 waitForEvent("error");
                 waitForEvent("loadstart");
                 waitForEvent("ratechange");
                 waitForEvent("waiting");
                 waitForEvent("ratechange");
                 waitForEvent("durationchange");
-                waitForEvent("loadeddata");
-                waitForEvent("canplay");
-                waitForEvent("canplaythrough");
                 waitForEvent("pause");
                 waitForEvent("play");
                 waitForEvent("playing");
-        
-                waitForEvent('loadedmetadata', function () { 
-                    consoleWrite("");
-                    consoleWrite("<b>Test size after movie is open:</b>");
-                    testExpected("video.videoWidth", 640);
-                    testExpected("video.videoHeight", 480);
-                    endTest();
-                } );
-        
+
+                waitForEvent('loadedmetadata', testSize);
+
                 consoleWrite("<b>Test size before movie is open:</b>");
                 testExpected("video.videoWidth", 0, "==");
                 testExpected("video.videoHeight", 0, "==");
             
-                consoleWrite("");
-            
-                video.src = "content/scaled-matrix.mov";
+                openNextMovie();
             }
         </script>
     </head>
@@ -45,8 +84,5 @@
 
         <video controls></video>
 
-        <p>Test that a movie saved with a non identity matrix is sized correctly
-        when opened</p>
-
     </body>
 </html>
index 78b7b12..c2192e7 100644 (file)
@@ -1,3 +1,19 @@
+2009-05-04  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Adam Roben.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=25545
+        Bug 25545: HTMLMediaElement: display anamorphic video correctly
+        
+        Tell QuickTime to use clean aperture mode so movies with non-square pixels are sized
+        and displayed correctly.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::createQTMovie): Ask QuickTime to use clean aperture mode.
+        * platform/graphics/win/QTMovieWin.cpp:
+        (QTMovieWin::load): Ditto. Add ASSERT to ensure that static movie property array isn't 
+        filled beyond capacity.
+
 2009-05-03  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Darin Adler.
index a17acad..dd2f1ef 100644 (file)
@@ -92,6 +92,10 @@ SOFT_LINK_POINTER(QTKit, QTMovieURLAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieVolumeDidChangeNotification, NSString *)
 SOFT_LINK_POINTER(QTKit, QTSecurityPolicyNoCrossSiteAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTVideoRendererWebKitOnlyNewImageAvailableNotification, NSString *)
+#ifndef BUILDING_ON_TIGER
+SOFT_LINK_POINTER(QTKit, QTMovieApertureModeClean, NSString *)
+SOFT_LINK_POINTER(QTKit, QTMovieApertureModeAttribute, NSString *)
+#endif
 
 #define QTMovie getQTMovieClass()
 #define QTMovieView getQTMovieViewClass()
@@ -121,6 +125,10 @@ SOFT_LINK_POINTER(QTKit, QTVideoRendererWebKitOnlyNewImageAvailableNotification,
 #define QTMovieVolumeDidChangeNotification getQTMovieVolumeDidChangeNotification()
 #define QTSecurityPolicyNoCrossSiteAttribute getQTSecurityPolicyNoCrossSiteAttribute()
 #define QTVideoRendererWebKitOnlyNewImageAvailableNotification getQTVideoRendererWebKitOnlyNewImageAvailableNotification()
+#ifndef BUILDING_ON_TIGER
+#define QTMovieApertureModeClean getQTMovieApertureModeClean()
+#define QTMovieApertureModeAttribute getQTMovieApertureModeAttribute()
+#endif
 
 // Older versions of the QTKit header don't have these constants.
 #if !defined QTKIT_VERSION_MAX_ALLOWED || QTKIT_VERSION_MAX_ALLOWED <= QTKIT_VERSION_7_0
@@ -229,6 +237,9 @@ void MediaPlayerPrivate::createQTMovie(const String& url)
                                      [NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
                                      [NSNumber numberWithBool:NO], QTMovieAskUnresolvedDataRefsAttribute,
                                      [NSNumber numberWithBool:YES], @"QTMovieOpenForPlaybackAttribute",     // FIXME: Use defined attribute when required version of QT supports this attribute
+#ifndef BUILDING_ON_TIGER
+                                     QTMovieApertureModeClean, QTMovieApertureModeAttribute,
+#endif
                                      nil];
     
     NSError *error = nil;
index 921a69d..1d10006 100644 (file)
@@ -641,6 +641,7 @@ void QTMovieWin::load(const UChar* url, int len)
     movieProps[moviePropCount].propStatus = 0; 
     moviePropCount++; 
 
+    ASSERT(moviePropCount <= sizeof(movieProps)/sizeof(movieProps[0]));
     m_private->m_loadError = NewMovieFromProperties(moviePropCount, movieProps, 0, NULL, &m_private->m_movie);
 
     CFRelease(urlRef);
@@ -649,8 +650,16 @@ end:
     // get the load fail callback quickly 
     if (m_private->m_loadError)
         updateTaskTimer(0);
-    else
+    else {
+        OSType mode = kQTApertureMode_CleanAperture;
+
+        // Set the aperture mode property on a movie to signal that we want aspect ratio
+        // and clean aperture dimensions. Don't worry about errors, we can't do anything if
+        // the installed version of QT doesn't support it and it isn't serious enough to 
+        // warrant failing.
+        QTSetMovieProperty(m_private->m_movie, kQTPropertyClass_Visual, kQTVisualPropertyID_ApertureMode, sizeof(mode), &mode);
         m_private->registerDrawingCallback();
+    }
 
     CFRelease(urlStringRef);
 }