[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 <vjaquez@igalia.com> 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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a12b22f3
2013-06-18 Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
[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 <galpeter@inf.u-szeged.hu>
[curl] Set the http response status text
......@@ -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 @@ void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
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 @@ void MediaPlayerPrivateGStreamerBase::updateTexture(GstBuffer* buffer)
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
......
......@@ -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 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 }")
#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
#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 @@ static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment