<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169198] releases/WebKitGTK/webkit-2.4/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169198">169198</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-05-22 05:16:49 -0700 (Thu, 22 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/168060">r168060</a> - [GStreamer] Use GstMetaVideo
https://bugs.webkit.org/show_bug.cgi?id=132247
Reviewed by Philippe Normand.
In WebKitVideoSink we announce the usage of GstMetaVideo, but we do
not use it when handling the video frames. This might break
some decoders and filters that rely on buffer's meta, rather
that in the caps structures.
This patch enables the use of GstMetaVideo through the GstVideoFrame
API. And it is used everywhere the buffer mapping is required.
Also this patch changes to nullptr where zeros were used.
Also, compile conditionally the video buffer conversion when it is
ARGB/BGRA, since it is only required for the Cairo backend.
No new tests, already covered by current tests.
* platform/graphics/gstreamer/GStreamerUtilities.cpp:
(WebCore::getVideoSizeAndFormatFromCaps): init the GstVideoInfo before
used and remove caps fixate check since it is done by
gst_video_info_from_caps().
* platform/graphics/gstreamer/ImageGStreamer.h:
* platform/graphics/gstreamer/ImageGStreamerCairo.cpp:
(ImageGStreamer::ImageGStreamer): use GstVideoFrame for buffer mapping
and unmapping.
(ImageGStreamer::~ImageGStreamer): ditto.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): ditto.
(WebCore::MediaPlayerPrivateGStreamerBase::currentVideoSinkCaps):
return nullptr if failed.
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
(webkitVideoSinkRender): rely on GstVideoInfo rather than on the
caps. Use GstVideoFrame for buffer mapping and unmapping. Add guards
for buffer transformation, since it's only used by Cairo.
(webkitVideoSinkDispose): remove glib version guards.
(webkitVideoSinkSetCaps): update the value of the private
GstVideoInfo.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerImageGStreamerh">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerImageGStreamerCairocpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerVideoSinkGStreamercpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit24SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2014-04-30 Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
+
+ [GStreamer] Use GstMetaVideo
+ https://bugs.webkit.org/show_bug.cgi?id=132247
+
+ Reviewed by Philippe Normand.
+
+ In WebKitVideoSink we announce the usage of GstMetaVideo, but we do
+ not use it when handling the video frames. This might break
+ some decoders and filters that rely on buffer's meta, rather
+ that in the caps structures.
+
+ This patch enables the use of GstMetaVideo through the GstVideoFrame
+ API. And it is used everywhere the buffer mapping is required.
+
+ Also this patch changes to nullptr where zeros were used.
+
+ Also, compile conditionally the video buffer conversion when it is
+ ARGB/BGRA, since it is only required for the Cairo backend.
+
+ No new tests, already covered by current tests.
+
+ * platform/graphics/gstreamer/GStreamerUtilities.cpp:
+ (WebCore::getVideoSizeAndFormatFromCaps): init the GstVideoInfo before
+ used and remove caps fixate check since it is done by
+ gst_video_info_from_caps().
+ * platform/graphics/gstreamer/ImageGStreamer.h:
+ * platform/graphics/gstreamer/ImageGStreamerCairo.cpp:
+ (ImageGStreamer::ImageGStreamer): use GstVideoFrame for buffer mapping
+ and unmapping.
+ (ImageGStreamer::~ImageGStreamer): ditto.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): ditto.
+ (WebCore::MediaPlayerPrivateGStreamerBase::currentVideoSinkCaps):
+ return nullptr if failed.
+ * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
+ (webkitVideoSinkRender): rely on GstVideoInfo rather than on the
+ caps. Use GstVideoFrame for buffer mapping and unmapping. Add guards
+ for buffer transformation, since it's only used by Cairo.
+ (webkitVideoSinkDispose): remove glib version guards.
+ (webkitVideoSinkSetCaps): update the value of the private
+ GstVideoInfo.
+
</ins><span class="cx"> 2014-05-06 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> Dragging text from one paragraph to another does not render as expected
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -52,7 +52,8 @@
</span><span class="cx"> {
</span><span class="cx"> GstVideoInfo info;
</span><span class="cx">
</span><del>- if (!gst_caps_is_fixed(caps) || !gst_video_info_from_caps(&info, caps))
</del><ins>+ gst_video_info_init(&info);
+ if (!gst_video_info_from_caps(&info, caps))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> format = GST_VIDEO_INFO_FORMAT(&info);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerImageGStreamerh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include "GRefPtrGStreamer.h"
</span><span class="cx">
</span><span class="cx"> #include <gst/gst.h>
</span><ins>+#include <gst/video/video.h>
</ins><span class="cx">
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -64,8 +65,7 @@
</span><span class="cx"> FloatRect m_cropRect;
</span><span class="cx">
</span><span class="cx"> #if USE(CAIRO)
</span><del>- GRefPtr<GstBuffer> m_buffer;
- GstMapInfo m_mapInfo;
</del><ins>+ GstVideoFrame m_videoFrame;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerImageGStreamerCairocpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -33,24 +33,32 @@
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="cx"> ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
</span><del>- : m_buffer(buffer)
</del><span class="cx"> {
</span><del>- GstVideoFormat format;
- IntSize size;
- int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
- getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
</del><ins>+ GstVideoInfo videoInfo;
+ gst_video_info_init(&videoInfo);
+ if (!gst_video_info_from_caps(&videoInfo, caps))
+ return;
</ins><span class="cx">
</span><del>- gst_buffer_map(buffer, &m_mapInfo, GST_MAP_READ);
- unsigned char* bufferData = reinterpret_cast<unsigned char*>(m_mapInfo.data);
</del><ins>+ // Right now the TextureMapper only supports chromas with one plane
+ ASSERT(GST_VIDEO_INFO_N_PLANES(&videoInfo) == 1);
</ins><span class="cx">
</span><ins>+ if (!gst_video_frame_map(&m_videoFrame, &videoInfo, buffer, GST_MAP_READ))
+ return;
+
+ unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_VIDEO_FRAME_PLANE_DATA(&m_videoFrame, 0));
+
</ins><span class="cx"> cairo_format_t cairoFormat;
</span><span class="cx"> #if G_BYTE_ORDER == G_LITTLE_ENDIAN
</span><del>- cairoFormat = (format == GST_VIDEO_FORMAT_BGRA) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
</del><ins>+ cairoFormat = (GST_VIDEO_FRAME_FORMAT(&m_videoFrame) == GST_VIDEO_FORMAT_BGRA) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
</ins><span class="cx"> #else
</span><del>- cairoFormat = (format == GST_VIDEO_FORMAT_ARGB) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
</del><ins>+ cairoFormat = (GST_VIDEO_FRAME_FORMAT(&m_videoFrame) == GST_VIDEO_FORMAT_ARGB) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(bufferData, cairoFormat, size.width(), size.height(), stride));
</del><ins>+ int stride = GST_VIDEO_FRAME_PLANE_STRIDE(&m_videoFrame, 0);
+ int width = GST_VIDEO_FRAME_WIDTH(&m_videoFrame);
+ int height = GST_VIDEO_FRAME_HEIGHT(&m_videoFrame);
+
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(bufferData, cairoFormat, width, height, stride));
</ins><span class="cx"> ASSERT(cairo_surface_status(surface.get()) == CAIRO_STATUS_SUCCESS);
</span><span class="cx"> m_image = BitmapImage::create(surface.release());
</span><span class="cx">
</span><span class="lines">@@ -67,6 +75,6 @@
</span><span class="cx">
</span><span class="cx"> // We keep the buffer memory mapped until the image is destroyed because the internal
</span><span class="cx"> // cairo_surface_t was created using cairo_image_surface_create_for_data().
</span><del>- gst_buffer_unmap(m_buffer.get(), &m_mapInfo);
</del><ins>+ gst_video_frame_unmap(&m_videoFrame);
</ins><span class="cx"> }
</span><span class="cx"> #endif // USE(GSTREAMER)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="cx"> #include <gst/audio/streamvolume.h>
</span><ins>+#include <gst/video/gstvideometa.h>
</ins><span class="cx">
</span><span class="cx"> #if GST_CHECK_VERSION(1, 1, 0) && USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> #include "TextureMapperGL.h"
</span><span class="lines">@@ -309,23 +310,20 @@
</span><span class="cx"> {
</span><span class="cx"> GMutexLocker lock(m_bufferMutex);
</span><span class="cx"> if (!m_buffer)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><del>- const void* srcData = 0;
</del><span class="cx"> GRefPtr<GstCaps> caps = currentVideoSinkCaps();
</span><span class="cx"> if (!caps)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><del>- IntSize size;
- GstVideoFormat format;
- int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
- if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
- return 0;
</del><ins>+ GstVideoInfo videoInfo;
+ gst_video_info_init(&videoInfo);
+ if (!gst_video_info_from_caps(&videoInfo, caps.get()))
+ return nullptr;
</ins><span class="cx">
</span><del>- const GstVideoFormatInfo* formatInfo = gst_video_format_get_info(format);
</del><ins>+ IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo));
+ RefPtr<BitmapTexture> texture = textureMapper->acquireTextureFromPool(size, GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
</ins><span class="cx">
</span><del>- RefPtr<BitmapTexture> texture = textureMapper->acquireTextureFromPool(size, GST_VIDEO_FORMAT_INFO_HAS_ALPHA(formatInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
-
</del><span class="cx"> #if GST_CHECK_VERSION(1, 1, 0)
</span><span class="cx"> GstVideoGLTextureUploadMeta* meta;
</span><span class="cx"> if ((meta = gst_buffer_get_video_gl_texture_upload_meta(m_buffer))) {
</span><span class="lines">@@ -339,13 +337,18 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- GstMapInfo srcInfo;
- gst_buffer_map(m_buffer, &srcInfo, GST_MAP_READ);
- srcData = srcInfo.data;
</del><ins>+ // Right now the TextureMapper only supports chromas with one plane
+ ASSERT(GST_VIDEO_INFO_N_PLANES(&videoInfo) == 1);
</ins><span class="cx">
</span><ins>+ GstVideoFrame videoFrame;
+ if (!gst_video_frame_map(&videoFrame, &videoInfo, m_buffer, GST_MAP_READ))
+ return nullptr;
+
+ int stride = GST_VIDEO_FRAME_PLANE_STRIDE(&videoFrame, 0);
+ const void* srcData = GST_VIDEO_FRAME_PLANE_DATA(&videoFrame, 0);
</ins><span class="cx"> texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
</span><ins>+ gst_video_frame_unmap(&videoFrame);
</ins><span class="cx">
</span><del>- gst_buffer_unmap(m_buffer, &srcInfo);
</del><span class="cx"> return texture;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -442,7 +445,7 @@
</span><span class="cx"> GRefPtr<GstCaps> MediaPlayerPrivateGStreamerBase::currentVideoSinkCaps() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_webkitVideoSink)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> GRefPtr<GstCaps> currentCaps;
</span><span class="cx"> g_object_get(G_OBJECT(m_webkitVideoSink.get()), "current-caps", &currentCaps.outPtr(), NULL);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreplatformgraphicsgstreamerVideoSinkGStreamercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp (169197 => 169198)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp        2014-05-22 12:01:32 UTC (rev 169197)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp        2014-05-22 12:16:49 UTC (rev 169198)
</span><span class="lines">@@ -147,21 +147,14 @@
</span><span class="cx">
</span><span class="cx"> priv->buffer = gst_buffer_ref(buffer);
</span><span class="cx">
</span><del>- GRefPtr<GstCaps> caps;
</del><span class="cx"> // The video info structure is valid only if the sink handled an allocation query.
</span><del>- if (GST_VIDEO_INFO_FORMAT(&priv->info) != GST_VIDEO_FORMAT_UNKNOWN)
- caps = adoptGRef(gst_video_info_to_caps(&priv->info));
- else
- caps = priv->currentCaps;
-
- GstVideoFormat format;
- WebCore::IntSize size;
- int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
- if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
</del><ins>+ GstVideoFormat format = GST_VIDEO_INFO_FORMAT(&priv->info);
+ if (format == GST_VIDEO_FORMAT_UNKNOWN) {
</ins><span class="cx"> gst_buffer_unref(buffer);
</span><span class="cx"> return GST_FLOW_ERROR;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if !(USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS))
</ins><span class="cx"> // Cairo's ARGB has pre-multiplied alpha while GStreamer's doesn't.
</span><span class="cx"> // Here we convert to Cairo's ARGB.
</span><span class="cx"> if (format == GST_VIDEO_FORMAT_ARGB || format == GST_VIDEO_FORMAT_BGRA) {
</span><span class="lines">@@ -173,22 +166,35 @@
</span><span class="cx"> GstBuffer* newBuffer = WebCore::createGstBuffer(buffer);
</span><span class="cx">
</span><span class="cx"> // Check if allocation failed.
</span><del>- if (UNLIKELY(!newBuffer))
</del><ins>+ if (UNLIKELY(!newBuffer)) {
+ gst_buffer_unref(buffer);
</ins><span class="cx"> return GST_FLOW_ERROR;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // We don't use Color::premultipliedARGBFromColor() here because
</span><span class="cx"> // one function call per video pixel is just too expensive:
</span><span class="cx"> // For 720p/PAL for example this means 1280*720*25=23040000
</span><span class="cx"> // function calls per second!
</span><del>- GstMapInfo sourceInfo;
- GstMapInfo destinationInfo;
- gst_buffer_map(buffer, &sourceInfo, GST_MAP_READ);
- const guint8* source = const_cast<guint8*>(sourceInfo.data);
- gst_buffer_map(newBuffer, &destinationInfo, GST_MAP_WRITE);
- guint8* destination = static_cast<guint8*>(destinationInfo.data);
</del><ins>+ GstVideoFrame sourceFrame;
+ GstVideoFrame destinationFrame;
</ins><span class="cx">
</span><del>- for (int x = 0; x < size.height(); x++) {
- for (int y = 0; y < size.width(); y++) {
</del><ins>+ if (!gst_video_frame_map(&sourceFrame, &priv->info, buffer, GST_MAP_READ)) {
+ gst_buffer_unref(buffer);
+ gst_buffer_unref(newBuffer);
+ return GST_FLOW_ERROR;
+ }
+ if (!gst_video_frame_map(&destinationFrame, &priv->info, newBuffer, GST_MAP_WRITE)) {
+ gst_video_frame_unmap(&sourceFrame);
+ gst_buffer_unref(buffer);
+ gst_buffer_unref(newBuffer);
+ return GST_FLOW_ERROR;
+ }
+
+ const guint8* source = static_cast<guint8*>(GST_VIDEO_FRAME_PLANE_DATA(&sourceFrame, 0));
+ guint8* destination = static_cast<guint8*>(GST_VIDEO_FRAME_PLANE_DATA(&destinationFrame, 0));
+
+ for (int x = 0; x < GST_VIDEO_FRAME_HEIGHT(&sourceFrame); x++) {
+ for (int y = 0; y < GST_VIDEO_FRAME_WIDTH(&sourceFrame); y++) {
</ins><span class="cx"> #if G_BYTE_ORDER == G_LITTLE_ENDIAN
</span><span class="cx"> unsigned short alpha = source[3];
</span><span class="cx"> destination[0] = (source[0] * alpha + 128) / 255;
</span><span class="lines">@@ -207,11 +213,12 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- gst_buffer_unmap(buffer, &sourceInfo);
- gst_buffer_unmap(newBuffer, &destinationInfo);
</del><ins>+ gst_video_frame_unmap(&sourceFrame);
+ gst_video_frame_unmap(&destinationFrame);
</ins><span class="cx"> gst_buffer_unref(buffer);
</span><span class="cx"> buffer = priv->buffer = newBuffer;
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> // This should likely use a lower priority, but glib currently starves
</span><span class="cx"> // lower priority sources.
</span><span class="lines">@@ -335,12 +342,14 @@
</span><span class="cx">
</span><span class="cx"> GST_DEBUG_OBJECT(sink, "Current caps %" GST_PTR_FORMAT ", setting caps %" GST_PTR_FORMAT, priv->currentCaps, caps);
</span><span class="cx">
</span><del>- GstVideoInfo info;
- if (!gst_video_info_from_caps(&info, caps)) {
</del><ins>+ GstVideoInfo videoInfo;
+ gst_video_info_init(&videoInfo);
+ if (!gst_video_info_from_caps(&videoInfo, caps)) {
</ins><span class="cx"> GST_ERROR_OBJECT(sink, "Invalid caps %" GST_PTR_FORMAT, caps);
</span><span class="cx"> return FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ priv->info = videoInfo;
</ins><span class="cx"> gst_caps_replace(&priv->currentCaps, caps);
</span><span class="cx"> return TRUE;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>