[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

philn at webkit.org philn at webkit.org
Fri Feb 26 22:19:47 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit a17f5db8fc2843b498243304a553ecd49325233c
Author: philn at webkit.org <philn at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 15 08:48:04 2010 +0000

    2010-02-10  Philippe Normand  <pnormand at igalia.com>
    
            Reviewed by Gustavo Noronha Silva.
    
            [Gtk] wrong video aspect ratio
            https://bugs.webkit.org/show_bug.cgi?id=34790
    
            Fixed natural size calculation regarding pixel aspect ratio and
            display aspect ratio.
    
            Test: media/video-display-aspect-ratio.html
    
            * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
            (WebCore::greatestCommonDivisor):
            (WebCore::MediaPlayerPrivate::naturalSize):
    
    2010-02-12  Philippe Normand  <pnormand at igalia.com>
    
            Reviewed by Gustavo Noronha Silva.
    
            [Gtk] wrong video aspect ratio
            https://bugs.webkit.org/show_bug.cgi?id=34790
    
            Test checking the size of a 4:3 video with a 16:9 pixel aspect
            ratio.
    
            * media/content/test-par-16-9.mp4: Added.
            * media/video-display-aspect-ratio-expected.txt: Added.
            * media/video-display-aspect-ratio.html: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54766 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ca89bf0..5e81102 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-02-12  Philippe Normand  <pnormand at igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [Gtk] wrong video aspect ratio
+        https://bugs.webkit.org/show_bug.cgi?id=34790
+
+        Test checking the size of a 4:3 video with a 16:9 pixel aspect
+        ratio.
+
+        * media/content/test-par-16-9.mp4: Added.
+        * media/video-display-aspect-ratio-expected.txt: Added.
+        * media/video-display-aspect-ratio.html: Added.
+
 2010-02-14  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/media/content/test-par-16-9.mp4 b/LayoutTests/media/content/test-par-16-9.mp4
new file mode 100644
index 0000000..72f9455
Binary files /dev/null and b/LayoutTests/media/content/test-par-16-9.mp4 differ
diff --git a/LayoutTests/media/video-display-aspect-ratio-expected.txt b/LayoutTests/media/video-display-aspect-ratio-expected.txt
new file mode 100644
index 0000000..576667c
--- /dev/null
+++ b/LayoutTests/media/video-display-aspect-ratio-expected.txt
@@ -0,0 +1,7 @@
+EXPECTED (video.videoWidth == '0') OK
+EXPECTED (video.videoHeight == '0') OK
+EVENT(loadedmetadata)
+EXPECTED (video.videoWidth == '426') OK
+EXPECTED (video.videoHeight == '240') OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-display-aspect-ratio.html b/LayoutTests/media/video-display-aspect-ratio.html
new file mode 100644
index 0000000..b66da18
--- /dev/null
+++ b/LayoutTests/media/video-display-aspect-ratio.html
@@ -0,0 +1,15 @@
+<video controls></video>
+<script src=media-file.js></script>
+<script src=video-test.js></script>
+<script>
+    testExpected("video.videoWidth", 0, "==");
+    testExpected("video.videoHeight", 0, "==");
+
+    waitForEvent('loadedmetadata', function () {
+        testExpected("video.videoWidth", 426, "==");
+        testExpected("video.videoHeight", 240, "==");
+        endTest();
+    } );
+
+    video.src = findMediaFile("video", "content/test-par-16-9");
+</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 26415f9..bc40712 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-02-10  Philippe Normand  <pnormand at igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [Gtk] wrong video aspect ratio
+        https://bugs.webkit.org/show_bug.cgi?id=34790
+
+        Fixed natural size calculation regarding pixel aspect ratio and
+        display aspect ratio.
+
+        Test: media/video-display-aspect-ratio.html
+
+        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::greatestCommonDivisor):
+        (WebCore::MediaPlayerPrivate::naturalSize):
+
 2010-02-14  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
index 1866c36..965bacd 100644
--- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
+++ b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
@@ -55,10 +55,23 @@
 #include <webkit/webkitwebview.h>
 #include <wtf/gtk/GOwnPtr.h>
 
+#define LOG_VERBOSE(channel, fmt, args...) g_printerr(fmt "\n", ##args)
+
 using namespace std;
 
 namespace WebCore {
 
+static int greatestCommonDivisor(int a, int b)
+{
+    while (b) {
+        int temp = a;
+        a = b;
+        b = temp % b;
+    }
+
+    return ABS(a);
+}
+
 gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpointer data)
 {
     GOwnPtr<GError> err;
@@ -473,30 +486,60 @@ IntSize MediaPlayerPrivate::naturalSize() const
     if (!hasVideo())
         return IntSize();
 
+    GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink");
+    if (!pad)
+        return IntSize();
+
+    int width = 0, height = 0;
+    GstCaps* caps = GST_PAD_CAPS(pad);
+    int pixelAspectRatioNumerator, pixelAspectRatioDenominator;
+    int displayWidth, displayHeight, displayAspectRatioGCD;
+    int originalWidth = 0, originalHeight = 0;
+
     // TODO: handle possible clean aperture data. See
     // https://bugzilla.gnome.org/show_bug.cgi?id=596571
     // TODO: handle possible transformation matrix. See
     // https://bugzilla.gnome.org/show_bug.cgi?id=596326
-    int width = 0, height = 0;
-    if (GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink")) {
-        GstCaps* caps = GST_PAD_CAPS(pad);
-        gfloat pixelAspectRatio;
-        gint pixelAspectRatioNumerator, pixelAspectRatioDenominator;
-
-        if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
-            || !gst_video_format_parse_caps(caps, 0, &width, &height)
-            || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
-                                                        &pixelAspectRatioDenominator)) {
-            gst_object_unref(GST_OBJECT(pad));
-            return IntSize();
-        }
 
-        pixelAspectRatio = (gfloat) pixelAspectRatioNumerator / (gfloat) pixelAspectRatioDenominator;
-        width *= pixelAspectRatio;
-        height /= pixelAspectRatio;
+    // Get the video PAR and original size.
+    if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
+        || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight)
+        || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
+                                                    &pixelAspectRatioDenominator)) {
         gst_object_unref(GST_OBJECT(pad));
+        return IntSize();
+    }
+
+    gst_object_unref(GST_OBJECT(pad));
+
+    LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight);
+    LOG_VERBOSE(Media, "Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
+
+    // Calculate DAR based on PAR and video size.
+    displayWidth = originalWidth * pixelAspectRatioNumerator;
+    displayHeight = originalHeight * pixelAspectRatioDenominator;
+
+    // Divide display width and height by their GCD to avoid possible overflows.
+    displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);
+    displayWidth /= displayAspectRatioGCD;
+    displayHeight /= displayAspectRatioGCD;
+
+    // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
+    if (!(originalHeight % displayHeight)) {
+        LOG_VERBOSE(Media, "Keeping video original height");
+        width = gst_util_uint64_scale_int(originalHeight, displayWidth, displayHeight);
+        height = originalHeight;
+    } else if (!(originalWidth % displayWidth)) {
+        LOG_VERBOSE(Media, "Keeping video original width");
+        height = gst_util_uint64_scale_int(originalWidth, displayHeight, displayWidth);
+        width = originalWidth;
+    } else {
+        LOG_VERBOSE(Media, "Approximating while keeping original video height");
+        width = gst_util_uint64_scale_int(originalHeight, displayWidth, displayHeight);
+        height = originalHeight;
     }
 
+    LOG_VERBOSE(Media, "Natural size: %dx%d", width, height);
     return IntSize(width, height);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list