Title: [151673] trunk/Source/WebCore
Revision
151673
Author
[email protected]
Date
2013-06-18 01:09:55 -0700 (Tue, 18 Jun 2013)

Log Message

[GStreamer] [texmap] upload a video buffer into the video texture
https://bugs.webkit.org/show_bug.cgi?id=116042

Patch by Víctor Manuel Jáquez Leal <[email protected]> on 2013-06-18
Reviewed by Philippe Normand.

This patch prepares more quickly the texture when the video frame is
already in the GPU memory.

It is done using a new buffer's metadata available in GStreamer 1.2,
and its purpose is to upload buffers into a OpenGL texture.

If the decoder provides buffers with this metadata, the buffer will be
uploaded into the texture used for the video display and it will be
rendered, avoiding a expensive mem copies. This is particularly useful
for Full HD videos, where all the processing and display will be done
in the GPU.

No new tests, covered by existing tests.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
(webkitVideoSinkProposeAllocation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (151672 => 151673)


--- trunk/Source/WebCore/ChangeLog	2013-06-18 07:20:45 UTC (rev 151672)
+++ trunk/Source/WebCore/ChangeLog	2013-06-18 08:09:55 UTC (rev 151673)
@@ -1,3 +1,31 @@
+2013-06-18  Víctor Manuel Jáquez Leal  <[email protected]>
+
+        [GStreamer] [texmap] upload a video buffer into the video texture
+        https://bugs.webkit.org/show_bug.cgi?id=116042
+
+        Reviewed by Philippe Normand.
+
+        This patch prepares more quickly the texture when the video frame is
+        already in the GPU memory.
+
+        It is done using a new buffer's metadata available in GStreamer 1.2,
+        and its purpose is to upload buffers into a OpenGL texture.
+
+        If the decoder provides buffers with this metadata, the buffer will be
+        uploaded into the texture used for the video display and it will be
+        rendered, avoiding a expensive mem copies. This is particularly useful
+        for Full HD videos, where all the processing and display will be done
+        in the GPU.
+
+        No new tests, covered by existing tests.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+        * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
+        (webkitVideoSinkProposeAllocation):
+
 2013-06-17  Peter Gal  <[email protected]>
 
         [curl] Set the http response status text

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (151672 => 151673)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-06-18 07:20:45 UTC (rev 151672)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2013-06-18 08:09:55 UTC (rev 151673)
@@ -51,6 +51,10 @@
 #include <gst/interfaces/streamvolume.h>
 #endif
 
+#if GST_CHECK_VERSION(1, 1, 0) && USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
+#include "TextureMapperGL.h"
+#endif
+
 GST_DEBUG_CATEGORY(webkit_media_player_debug);
 #define GST_CAT_DEFAULT webkit_media_player_debug
 
@@ -339,6 +343,21 @@
     if (m_texture->size() != size)
         m_texture->reset(size);
 
+#if GST_CHECK_VERSION(1, 1, 0)
+    GstVideoGLTextureUploadMeta* meta;
+    if ((meta = gst_buffer_get_video_gl_texture_upload_meta(buffer))) {
+        if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture.
+            const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(m_texture.get());
+            guint ids[4] = { textureGL->id(), 0, 0, 0 };
+
+            if (gst_video_gl_texture_upload_meta_upload(meta, ids)) {
+                client()->setPlatformLayerNeedsDisplay();
+                return;
+            }
+        }
+    }
+#endif
+
 #ifdef GST_API_VERSION_1
     GstMapInfo srcInfo;
     gst_buffer_map(buffer, &srcInfo, GST_MAP_READ);
@@ -347,7 +366,6 @@
     srcData = GST_BUFFER_DATA(buffer);
 #endif
 
-    // @TODO: support cropping
     m_texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), size.width() * 4, BitmapTexture::UpdateCannotModifyOriginalImageData);
 
 #ifdef GST_API_VERSION_1

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp (151672 => 151673)


--- trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp	2013-06-18 07:20:45 UTC (rev 151672)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp	2013-06-18 08:09:55 UTC (rev 151673)
@@ -41,19 +41,29 @@
 #include <wtf/FastAllocBase.h>
 
 // CAIRO_FORMAT_RGB24 used to render the video buffers is little/big endian dependant.
+#ifdef GST_API_VERSION_1
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#ifndef GST_API_VERSION_1
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA
+#define GST_CAPS_FORMAT "{ BGRx, BGRA }"
 #else
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ BGRx, BGRA }")
+#define GST_CAPS_FORMAT "{ xRGB, ARGB }"
 #endif
+#if GST_CHECK_VERSION(1, 1, 0)
+#define GST_FEATURED_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, GST_CAPS_FORMAT)
 #else
-#ifndef GST_API_VERSION_1
+#define GST_FEATURED_CAPS
+#endif
+#endif // GST_API_VERSION_1
+
+#ifdef GST_API_VERSION_1
+#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_FEATURED_CAPS ";" GST_VIDEO_CAPS_MAKE(GST_CAPS_FORMAT)
+#else
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA
+#else
 #define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_ARGB
-#else
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ xRGB, ARGB }")
 #endif
-#endif
+#endif // GST_API_VERSION_1
+
 static GstStaticPadTemplate s_sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS(WEBKIT_VIDEO_SINK_PAD_CAPS));
 
 
@@ -351,6 +361,9 @@
 
     gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE, 0);
     gst_query_add_allocation_meta(query, GST_VIDEO_CROP_META_API_TYPE, 0);
+#if GST_CHECK_VERSION(1, 1, 0)
+    gst_query_add_allocation_meta(query, GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, 0);
+#endif
     return TRUE;
 }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to