Changeset 243644 in webkit


Ignore:
Timestamp:
Mar 29, 2019 3:43:30 AM (5 years ago)
Author:
Philippe Normand
Message:

[GStreamer] imxvpudecoder detection and handling
https://bugs.webkit.org/show_bug.cgi?id=196346

Reviewed by Xabier Rodriguez-Calvar.

When the imxvpudecoder is used, the texture sampling of the
directviv-uploaded texture returns an RGB value, so there's no need
to convert it. This patch also includes a refactoring of the
ImageRotation flag handling. The flag is now computed once only
and stored in an instance variable.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:

(WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
(WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer):
(WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
(WebCore::MediaPlayerPrivateGStreamerBase::setVideoSourceOrientation):
(WebCore::MediaPlayerPrivateGStreamerBase::updateTextureMapperFlags):
(WebCore::texMapFlagFromOrientation): Deleted.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243643 r243644  
     12019-03-29  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] imxvpudecoder detection and handling
     4        https://bugs.webkit.org/show_bug.cgi?id=196346
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        When the imxvpudecoder is used, the texture sampling of the
     9        directviv-uploaded texture returns an RGB value, so there's no need
     10        to convert it. This patch also includes a refactoring of the
     11        ImageRotation flag handling. The flag is now computed once only
     12        and stored in an instance variable.
     13
     14        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     15        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
     16        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     17        (WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
     18        (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
     19        (WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
     20        (WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer):
     21        (WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
     22        (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
     23        (WebCore::MediaPlayerPrivateGStreamerBase::setVideoSourceOrientation):
     24        (WebCore::MediaPlayerPrivateGStreamerBase::updateTextureMapperFlags):
     25        (WebCore::texMapFlagFromOrientation): Deleted.
     26        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     27
    1282019-03-29  Cathie Chen  <cathiechen@igalia.com>
    229
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r243610 r243644  
    23932393
    23942394        GUniquePtr<char> elementName(gst_element_get_name(element));
    2395         player->m_isVideoDecoderVideo4Linux = g_str_has_prefix(elementName.get(), "v4l2");
     2395        if (g_str_has_prefix(elementName.get(), "v4l2"))
     2396            player->m_videoDecoderPlatform = WebKitGstVideoDecoderPlatform::Video4Linux;
     2397        else if (g_str_has_prefix(elementName.get(), "imxvpudecoder"))
     2398            player->m_videoDecoderPlatform = WebKitGstVideoDecoderPlatform::ImxVPU;
     2399
     2400        player->updateTextureMapperFlags();
    23962401    }), this);
    23972402
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r243538 r243644  
    120120#include "GraphicsContext3D.h"
    121121#include "TextureMapperContextAttributes.h"
    122 #include "TextureMapperGL.h"
    123122#include "TextureMapperPlatformLayerBuffer.h"
    124123#include "TextureMapperPlatformLayerProxy.h"
     
    149148    return ABS(a);
    150149}
    151 
    152 #if USE(TEXTURE_MAPPER_GL)
    153 static inline TextureMapperGL::Flags texMapFlagFromOrientation(const ImageOrientation& orientation)
    154 {
    155     switch (orientation) {
    156     case DefaultImageOrientation:
    157         return 0;
    158     case OriginRightTop:
    159         return TextureMapperGL::ShouldRotateTexture90;
    160     case OriginBottomRight:
    161         return TextureMapperGL::ShouldRotateTexture180;
    162     case OriginLeftBottom:
    163         return TextureMapperGL::ShouldRotateTexture270;
    164     default:
    165         ASSERT_NOT_REACHED();
    166     }
    167 
    168     return 0;
    169 }
    170 #endif
    171150
    172151#if USE(TEXTURE_MAPPER_GL)
     
    186165
    187166#if USE(GSTREAMER_GL)
    188         m_flags = flags | (m_hasAlphaChannel ? TextureMapperGL::ShouldBlend : 0) | TEXTURE_MAPPER_COLOR_CONVERT_FLAG;
     167        m_flags = flags | (m_hasAlphaChannel ? TextureMapperGL::ShouldBlend : 0);
    189168
    190169        if (gstGLEnabled) {
     
    275254{
    276255#if USE(GSTREAMER_GL)
    277     if (m_isVideoDecoderVideo4Linux)
     256    if (m_videoDecoderPlatform == WebKitGstVideoDecoderPlatform::Video4Linux)
    278257        flushCurrentBuffer();
    279258#endif
     
    734713                return;
    735714
    736             std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink);
     715            std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), m_textureMapperFlags, !m_usingFallbackVideoSink);
    737716
    738717            GLuint textureID = frameHolder->textureID();
     
    749728                }
    750729                frameHolder->updateTexture(layerBuffer->textureGL());
    751                 layerBuffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0));
     730                layerBuffer->setExtraFlags(m_textureMapperFlags | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0));
    752731            }
    753732            proxy.pushNextBuffer(WTFMove(layerBuffer));
     
    875854    }
    876855
    877     auto proxyOperation =
    878         [shouldWait = m_isVideoDecoderVideo4Linux, pipeline = pipeline()](TextureMapperPlatformLayerProxy& proxy)
    879         {
    880             GST_DEBUG_OBJECT(pipeline, "Flushing video sample %s", shouldWait ? "synchronously" : "");
    881             LockHolder locker(!shouldWait ? &proxy.lock() : nullptr);
    882 
    883             if (proxy.isActive())
    884                 proxy.dropCurrentBufferWhilePreservingTexture(shouldWait);
    885         };
     856    bool shouldWait = m_videoDecoderPlatform == WebKitGstVideoDecoderPlatform::Video4Linux;
     857    auto proxyOperation = [shouldWait, pipeline = pipeline()](TextureMapperPlatformLayerProxy& proxy) {
     858        GST_DEBUG_OBJECT(pipeline, "Flushing video sample %s", shouldWait ? "synchronously" : "");
     859        LockHolder locker(!shouldWait ? &proxy.lock() : nullptr);
     860
     861        if (proxy.isActive())
     862            proxy.dropCurrentBufferWhilePreservingTexture(shouldWait);
     863    };
    886864
    887865#if USE(NICOSIA)
     
    937915        return false;
    938916
    939     std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), true);
     917    std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), m_textureMapperFlags, true);
    940918
    941919    auto textureID = frameHolder->textureID();
     
    964942        return nullptr;
    965943
    966     std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), true);
     944    std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), m_textureMapperFlags, true);
    967945
    968946    auto textureID = frameHolder->textureID();
     
    996974
    997975    m_videoSourceOrientation = orientation;
    998 }
     976#if USE(TEXTURE_MAPPER_GL)
     977    updateTextureMapperFlags();
     978#endif
     979}
     980
     981#if USE(TEXTURE_MAPPER_GL)
     982void MediaPlayerPrivateGStreamerBase::updateTextureMapperFlags()
     983{
     984    switch (m_videoSourceOrientation) {
     985    case DefaultImageOrientation:
     986        m_textureMapperFlags = 0;
     987        break;
     988    case OriginRightTop:
     989        m_textureMapperFlags = TextureMapperGL::ShouldRotateTexture90;
     990        break;
     991    case OriginBottomRight:
     992        m_textureMapperFlags = TextureMapperGL::ShouldRotateTexture180;
     993        break;
     994    case OriginLeftBottom:
     995        m_textureMapperFlags = TextureMapperGL::ShouldRotateTexture270;
     996        break;
     997    default:
     998        // FIXME: Handle OriginTopRight, OriginBottomLeft, OriginLeftTop and OriginRightBottom?
     999        m_textureMapperFlags = 0;
     1000        break;
     1001    }
     1002
     1003    // When the imxvpudecoder is used, the texture sampling of the
     1004    // directviv-uploaded texture returns an RGB value, so there's no need to
     1005    // convert it.
     1006    if (m_videoDecoderPlatform != WebKitGstVideoDecoderPlatform::ImxVPU)
     1007        m_textureMapperFlags |= TEXTURE_MAPPER_COLOR_CONVERT_FLAG;
     1008}
     1009#endif
    9991010
    10001011bool MediaPlayerPrivateGStreamerBase::supportsFullscreen() const
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r242793 r243644  
    3939
    4040#if USE(TEXTURE_MAPPER_GL)
     41#include "TextureMapperGL.h"
    4142#if USE(NICOSIA)
    4243#include "NicosiaContentLayerTextureMapperImpl.h"
     
    222223    static void muteChangedCallback(MediaPlayerPrivateGStreamerBase*);
    223224
     225#if USE(TEXTURE_MAPPER_GL)
     226    void updateTextureMapperFlags();
     227    TextureMapperGL::Flags m_textureMapperFlags;
     228#endif
     229
    224230    enum MainThreadNotification {
    225231        VideoChanged = 1 << 0,
     
    284290#endif
    285291
    286     mutable bool m_isVideoDecoderVideo4Linux { false };
     292    enum class WebKitGstVideoDecoderPlatform { ImxVPU, Video4Linux };
     293
     294    WebKitGstVideoDecoderPlatform m_videoDecoderPlatform;
    287295};
    288296
Note: See TracChangeset for help on using the changeset viewer.