Changeset 249429 in webkit


Ignore:
Timestamp:
Sep 3, 2019 7:58:38 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[GStreamer] Add support to copy YUV video textures into images
https://bugs.webkit.org/show_bug.cgi?id=200922

Patch by Chris Lord <Chris Lord> on 2019-09-03
Reviewed by Philippe Normand and Xabier Rodriguez-Calvar.

Use gst_gl_color_convert to convert to RGB before using ImageGStreamer
with gstreamer-gl.

No new tests, not changing behavior.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:

(WebCore::MediaPlayerPrivateGStreamerBase::paint):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249428 r249429  
     12019-09-03  Chris Lord  <clord@igalia.com>
     2
     3        [GStreamer] Add support to copy YUV video textures into images
     4        https://bugs.webkit.org/show_bug.cgi?id=200922
     5
     6        Reviewed by Philippe Normand and Xabier Rodriguez-Calvar.
     7
     8        Use gst_gl_color_convert to convert to RGB before using ImageGStreamer
     9        with gstreamer-gl.
     10
     11        No new tests, not changing behavior.
     12
     13        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     14        (WebCore::MediaPlayerPrivateGStreamerBase::paint):
     15        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     16
    1172019-09-03  Chris Lord  <clord@igalia.com>
    218
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r249428 r249429  
    970970        return;
    971971
     972#if USE(GSTREAMER_GL)
     973    // Ensure the input is RGBA. We handle YUV video natively, so we need to do
     974    // this conversion on-demand here.
     975    GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
     976    if (UNLIKELY(!GST_IS_BUFFER(buffer)))
     977        return;
     978
     979    GstCaps* caps = gst_sample_get_caps(m_sample.get());
     980
     981    GstVideoInfo videoInfo;
     982    gst_video_info_init(&videoInfo);
     983    if (!gst_video_info_from_caps(&videoInfo, caps))
     984        return;
     985
     986    if (!GST_VIDEO_INFO_IS_RGB(&videoInfo)) {
     987        if (!m_colorConvert) {
     988            GstMemory* mem = gst_buffer_peek_memory(buffer, 0);
     989            GstGLContext* context = ((GstGLBaseMemory*)mem)->context;
     990            m_colorConvert = adoptGRef(gst_gl_color_convert_new(context));
     991        }
     992
     993        if (!m_colorConvertInputCaps || !gst_caps_is_equal(m_colorConvertInputCaps.get(), caps)) {
     994            m_colorConvertInputCaps = caps;
     995            m_colorConvertOutputCaps = adoptGRef(gst_caps_copy(caps));
     996#if G_BYTE_ORDER == G_LITTLE_ENDIAN
     997            const gchar* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "BGRx";
     998#else
     999            const gchar* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "RGBx";
     1000#endif
     1001            gst_caps_set_simple(m_colorConvertOutputCaps.get(), "format", G_TYPE_STRING, formatString, nullptr);
     1002            if (!gst_gl_color_convert_set_caps(m_colorConvert.get(), caps, m_colorConvertOutputCaps.get()))
     1003                return;
     1004        }
     1005
     1006        GRefPtr<GstBuffer> rgbBuffer = adoptGRef(gst_gl_color_convert_perform(m_colorConvert.get(), buffer));
     1007        if (UNLIKELY(!GST_IS_BUFFER(rgbBuffer.get())))
     1008            return;
     1009
     1010        const GstStructure* info = gst_sample_get_info(m_sample.get());
     1011        m_sample = adoptGRef(gst_sample_new(rgbBuffer.get(), m_colorConvertOutputCaps.get(),
     1012            gst_sample_get_segment(m_sample.get()), info ? gst_structure_copy(info) : nullptr));
     1013    }
     1014#endif
     1015
    9721016    auto gstImage = ImageGStreamer::createImage(m_sample.get());
    9731017    if (!gstImage)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r249321 r249429  
    297297    GRefPtr<GstContext> m_glAppElementContext;
    298298    std::unique_ptr<VideoTextureCopierGStreamer> m_videoTextureCopier;
     299
     300    GRefPtr<GstGLColorConvert> m_colorConvert;
     301    GRefPtr<GstCaps> m_colorConvertInputCaps;
     302    GRefPtr<GstCaps> m_colorConvertOutputCaps;
    299303#endif
    300304
Note: See TracChangeset for help on using the changeset viewer.