Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e9a7908 authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge 0746959b on remote branch

Change-Id: Ie0d243ac4d85a4914686c19a1c6581770b73678c
parents 8eafc8ac 0746959b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ typedef enum OMX_INDEXEXTTYPE {
    OMX_IndexParamVideoHevc,                        /**< reference: OMX_VIDEO_PARAM_HEVCTYPE */
    OMX_IndexParamSliceSegments,                    /**< reference: OMX_VIDEO_SLICESEGMENTSTYPE */
    OMX_IndexConfigAndroidIntraRefresh,             /**< reference: OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE */
    OMX_IndexParamAndroidVideoTemporalLayering,     /**< reference: OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE */
    OMX_IndexConfigAndroidVideoTemporalLayering,    /**< reference: OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE */

    /* Image & Video common configurations */
    OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000,
+90 −1
Original line number Diff line number Diff line
@@ -297,6 +297,95 @@ typedef struct OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE {
    OMX_U32 nRefreshPeriod;
} OMX_VIDEO_CONFIG_ANDROID_INTRAREFRESHTYPE;

/** Maximum number of temporal layers supported by AVC/HEVC */
#define OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS 8

/** temporal layer patterns */
typedef enum OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE {
    OMX_VIDEO_AndroidTemporalLayeringPatternNone = 0,
    // pattern as defined by WebRTC
    OMX_VIDEO_AndroidTemporalLayeringPatternWebRTC = 1 << 0,
    // pattern where frames in any layer other than the base layer only depend on at most the very
    // last frame from each preceding layer (other than the base layer.)
    OMX_VIDEO_AndroidTemporalLayeringPatternAndroid = 1 << 1,
} OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE;

/**
 * Android specific param for configuration of temporal layering.
 * Android only supports temporal layering where successive layers each double the
 * previous layer's framerate.
 * NOTE: Reading this parameter at run-time SHALL return actual run-time values.
 *
 *  nSize                      : Size of the structure in bytes
 *  nVersion                   : OMX specification version information
 *  nPortIndex                 : Port that this structure applies to (output port for encoders)
 *  eSupportedPatterns         : A bitmask of supported layering patterns
 *  nLayerCountMax             : Max number of temporal coding layers supported
 *                               by the encoder (must be at least 1, 1 meaning temporal layering
 *                               is NOT supported)
 *  nBLayerCountMax            : Max number of layers that can contain B frames
 *                               (0) to (nLayerCountMax - 1)
 *  ePattern                   : Layering pattern.
 *  nPLayerCountActual         : Number of temporal layers to be coded with non-B frames,
 *                               starting from and including the base-layer.
 *                               (1 to nLayerCountMax - nBLayerCountActual)
 *                               If nPLayerCountActual is 1 and nBLayerCountActual is 0, temporal
 *                               layering is disabled. Otherwise, it is enabled.
 *  nBLayerCountActual         : Number of temporal layers to be coded with B frames,
 *                               starting after non-B layers.
 *                               (0 to nBLayerCountMax)
 *  bBitrateRatiosSpecified    : Flag to indicate if layer-wise bitrate
 *                               distribution is specified.
 *  nBitrateRatios             : Bitrate ratio (100 based) per layer (index 0 is base layer).
 *                               Honored if bBitrateRatiosSpecified is set.
 *                               i.e for 4 layers with desired distribution (25% 25% 25% 25%),
 *                               nBitrateRatio = {25, 50, 75, 100, ... }
 *                               Values in indices not less than 'the actual number of layers
 *                               minus 1' MAY be ignored and assumed to be 100.
 */
typedef struct OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE {
    OMX_U32 nSize;
    OMX_VERSIONTYPE nVersion;
    OMX_U32 nPortIndex;
    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE eSupportedPatterns;
    OMX_U32 nLayerCountMax;
    OMX_U32 nBLayerCountMax;
    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern;
    OMX_U32 nPLayerCountActual;
    OMX_U32 nBLayerCountActual;
    OMX_BOOL bBitrateRatiosSpecified;
    OMX_U32 nBitrateRatios[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
} OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE;

/**
 * Android specific config for changing the temporal-layer count or
 * bitrate-distribution at run-time.
 *
 *  nSize                      : Size of the structure in bytes
 *  nVersion                   : OMX specification version information
 *  nPortIndex                 : Port that this structure applies to (output port for encoders)
 *  ePattern                   : Layering pattern.
 *  nPLayerCountActual         : Number of temporal layers to be coded with non-B frames.
 *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
 *  nBLayerCountActual         : Number of temporal layers to be coded with B frames.
 *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
 *  bBitrateRatiosSpecified    : Flag to indicate if layer-wise bitrate
 *                               distribution is specified.
 *  nBitrateRatios             : Bitrate ratio (100 based, Q16 values) per layer (0 is base layer).
 *                               Honored if bBitrateRatiosSpecified is set.
 *                               (same OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE limits apply.)
 */
typedef struct OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE {
    OMX_U32 nSize;
    OMX_VERSIONTYPE nVersion;
    OMX_U32 nPortIndex;
    OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern;
    OMX_U32 nPLayerCountActual;
    OMX_U32 nBLayerCountActual;
    OMX_BOOL bBitrateRatiosSpecified;
    OMX_U32 nBitrateRatios[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
} OMX_VIDEO_CONFIG_ANDROID_TEMPORALLAYERINGTYPE;

#ifdef __cplusplus
}
#endif /* __cplusplus */
+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ ifeq ($(TARGET_USES_QCOM_BSP), true)
    LOCAL_C_INCLUDES += hardware/qcom/display/libqdutils
  endif
    LOCAL_SHARED_LIBRARIES += libqdutils
    LOCAL_SHARED_LIBRARIES += libqdMetaData
    LOCAL_CFLAGS += -DQTI_BSP
endif

+168 −3
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -36,10 +36,12 @@
#include <ui/GraphicBuffer.h>
#ifdef QTI_BSP
#include <gralloc_priv.h>
#include <qdMetaData.h>
#include <hardware/display_defs.h>
#endif

#include "ExLayer.h"
#include "RenderEngine/RenderEngine.h"

namespace android {

@@ -70,8 +72,9 @@ static Rect getAspectRatio(const sp<const DisplayDevice>& hw,

ExLayer::ExLayer(SurfaceFlinger* flinger, const sp<Client>& client,
                 const String8& name, uint32_t w, uint32_t h, uint32_t flags)
    : Layer(flinger, client, name, w, h, flags) {

    : Layer(flinger, client, name, w, h, flags),
      mMeshLeftTop(Mesh::TRIANGLE_FAN, 4, 2, 2),
      mMeshRightBottom(Mesh::TRIANGLE_FAN, 4, 2, 2) {
    char property[PROPERTY_VALUE_MAX] = {0};

    mDebugLogs = false;
@@ -204,4 +207,166 @@ bool ExLayer::canAllowGPUForProtected() const {
    }
}

#if (defined QTI_BSP) && (defined QTI_S3D)
uint32_t ExLayer::getS3dFormat(const sp<const DisplayDevice>& hw) const {
    uint32_t s3d_fmt = HWC_S3DMODE_NONE;
    const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);

    if (activeBuffer != 0) {
        ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
        if (buffer) {
            private_handle_t* hnd = static_cast<private_handle_t*>
                    (const_cast<native_handle_t*>(buffer->handle));
            if (hnd != NULL) {
                struct S3DGpuComp_t s3dComp;
                getMetaData(hnd, GET_S3D_COMP, &s3dComp);
                if (s3dComp.displayId == hw->getHwcDisplayId()) {
                    s3d_fmt = s3dComp.s3dMode;
                }
            }
        }
    }
    return s3d_fmt;
}

void ExLayer::clearS3dFormat(const sp<const DisplayDevice>& hw) const {
    const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
    if (activeBuffer != 0) {
        ANativeWindowBuffer* buffer = activeBuffer->getNativeBuffer();
        if (buffer) {
            private_handle_t* hnd = static_cast<private_handle_t*>
                (const_cast<native_handle_t*>(buffer->handle));
            if (hnd != NULL) {
                struct S3DGpuComp_t s3dComp;
                getMetaData(hnd, GET_S3D_COMP, &s3dComp);
                if (s3dComp.displayId == hw->getHwcDisplayId()) {
                    clearMetaData(hnd, SET_S3D_COMP);
                }
            }
        }
    }
}

void ExLayer::computeGeometryS3D(const sp<const DisplayDevice>& hw, Mesh& mesh,
        Mesh& meshLeftTop, Mesh& meshRightBottom, uint32_t s3d_fmt) const
{
    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
    Mesh::VertexArray<vec2> positionLeftTop(meshLeftTop.getPositionArray<vec2>());
    Mesh::VertexArray<vec2> positionRightBottom(meshRightBottom.getPositionArray<vec2>());
    Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>());
    Mesh::VertexArray<vec2> texCoordsLeftTop(meshLeftTop.getTexCoordArray<vec2>());
    Mesh::VertexArray<vec2> texCoordsRightBottom(meshRightBottom.getTexCoordArray<vec2>());

    Rect scissor = hw->getBounds();

    uint32_t count = mesh.getVertexCount();
    while(count--) {
        positionLeftTop[count] = positionRightBottom[count] = position[count];
        texCoordsLeftTop[count] = texCoordsRightBottom[count] = texCoords[count];
    }

    switch (s3d_fmt) {
        case HWC_S3DMODE_LR:
        case HWC_S3DMODE_RL:
        {
            positionLeftTop[0].x  = (position[0].x - scissor.left) / 2.0f + scissor.left;
            positionLeftTop[1].x  = (position[1].x - scissor.left) / 2.0f + scissor.left;
            positionLeftTop[2].x  = (position[2].x - scissor.left) / 2.0f + scissor.left;
            positionLeftTop[3].x  = (position[3].x - scissor.left) / 2.0f + scissor.left;

            positionRightBottom[0].x = positionLeftTop[0].x + scissor.getWidth()/2;
            positionRightBottom[1].x = positionLeftTop[1].x + scissor.getWidth()/2;
            positionRightBottom[2].x = positionLeftTop[2].x + scissor.getWidth()/2;
            positionRightBottom[3].x = positionLeftTop[3].x + scissor.getWidth()/2;

            if(isYuvLayer()) {
                texCoordsLeftTop[0].x  =  texCoords[0].x / 2.0f;
                texCoordsLeftTop[1].x  =  texCoords[1].x / 2.0f;
                texCoordsLeftTop[2].x  =  texCoords[2].x / 2.0f;
                texCoordsLeftTop[3].x  =  texCoords[3].x / 2.0f;

                texCoordsRightBottom[0].x  =  texCoordsLeftTop[0].x + 0.5f;
                texCoordsRightBottom[1].x  =  texCoordsLeftTop[1].x + 0.5f;
                texCoordsRightBottom[2].x  =  texCoordsLeftTop[2].x + 0.5f;
                texCoordsRightBottom[3].x  =  texCoordsLeftTop[3].x + 0.5f;
            }
            break;
        }
        case HWC_S3DMODE_TB:
        {
            positionRightBottom[0].y  = (position[0].y - scissor.top) / 2.0f + scissor.top;
            positionRightBottom[1].y  = (position[1].y - scissor.top) / 2.0f + scissor.top;
            positionRightBottom[2].y  = (position[2].y - scissor.top) / 2.0f + scissor.top;
            positionRightBottom[3].y  = (position[3].y - scissor.top) / 2.0f + scissor.top;

            positionLeftTop[0].y = positionRightBottom[0].y + scissor.getHeight() / 2.0f;
            positionLeftTop[1].y = positionRightBottom[1].y + scissor.getHeight() / 2.0f;
            positionLeftTop[2].y = positionRightBottom[2].y + scissor.getHeight() / 2.0f;
            positionLeftTop[3].y = positionRightBottom[3].y + scissor.getHeight() / 2.0f;

            positionLeftTop[0].x = positionRightBottom[0].x = position[0].x;
            positionLeftTop[1].x = positionRightBottom[1].x = position[1].x;
            positionLeftTop[2].x = positionRightBottom[2].x = position[2].x;
            positionLeftTop[3].x = positionRightBottom[3].x = position[3].x;

            if(isYuvLayer()) {
                texCoordsRightBottom[0].y  =  texCoords[0].y / 2.0f;
                texCoordsRightBottom[1].y  =  texCoords[1].y / 2.0f;
                texCoordsRightBottom[2].y  =  texCoords[2].y / 2.0f;
                texCoordsRightBottom[3].y  =  texCoords[3].y / 2.0f;

                texCoordsLeftTop[0].y  =  texCoordsRightBottom[0].y + 0.5f;
                texCoordsLeftTop[1].y  =  texCoordsRightBottom[1].y + 0.5f;
                texCoordsLeftTop[2].y  =  texCoordsRightBottom[2].y + 0.5f;
                texCoordsLeftTop[3].y  =  texCoordsRightBottom[3].y + 0.5f;
            }
            break;
        }
        default:
            break;
    }
}

void ExLayer::handleOpenGLDraw(const sp<const DisplayDevice>& hw,
    Mesh& mesh) const
{
    const State& s(getDrawingState());
    RenderEngine& engine(mFlinger->getRenderEngine());
    engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), s.alpha);
    uint32_t s3d_fmt = getS3dFormat(hw);
    if (s3d_fmt == HWC_S3DMODE_NONE) {
        engine.drawMesh(mesh);
    } else {
        computeGeometryS3D(hw, mesh, mMeshLeftTop, mMeshRightBottom, s3d_fmt);
        // in non-primary case scissor might be not equal to hw bounds
        engine.setScissor(0, 0, hw->getWidth(), hw->getHeight());
        engine.drawMesh(mMeshLeftTop);
        engine.drawMesh(mMeshRightBottom);
        clearS3dFormat(hw);
    }
    engine.disableBlending();
}
#else
uint32_t ExLayer::getS3dFormat(const sp<const DisplayDevice>&) const {
    return 0;
}

void ExLayer::clearS3dFormat(const sp<const DisplayDevice>&) const {
}

void ExLayer::computeGeometryS3D(const sp<const DisplayDevice>&, Mesh&,
        Mesh&, Mesh&, uint32_t) const {
}

void ExLayer::handleOpenGLDraw(const sp<const DisplayDevice>& /* hw */,
            Mesh& mesh) const {
    const State& s(getDrawingState());
    RenderEngine& engine(mFlinger->getRenderEngine());

    engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), s.alpha);
    engine.drawMesh(mesh);
    engine.disableBlending();
}
#endif

}; // namespace android
+13 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -51,16 +51,28 @@ public:
    virtual bool isIntOnly() const;
    virtual bool isSecureDisplay() const;
    virtual bool isYuvLayer() const;
    virtual uint32_t getS3dFormat(const sp<const DisplayDevice>& hw) const;
    virtual void clearS3dFormat(const sp<const DisplayDevice>& hw) const;
    virtual void setPosition(const sp<const DisplayDevice>& hw,
                             HWComposer::HWCLayerInterface& layer, const State& state);
    virtual void setAcquiredFenceIfBlit(int &fenceFd,
                             HWComposer::HWCLayerInterface& layer);
    virtual bool canAllowGPUForProtected() const;
    virtual void handleOpenGLDraw(const sp<const DisplayDevice>& hw, Mesh& mesh) const;

protected:
    bool mDebugLogs;
    bool isDebug() { return mDebugLogs; }
    bool mIsGPUAllowedForProtected;

private:
    // The mesh used to draw the layer in GLES composition for s3d left/top
    mutable Mesh mMeshLeftTop;
    // The mesh used to draw the layer in GLES composition for s3d right/bottom
    mutable Mesh mMeshRightBottom;
    // split mesh into right/bottom or left/right parts for s3d
    void computeGeometryS3D(const sp<const DisplayDevice>& hw, Mesh& mesh,
        Mesh& meshLeftTop, Mesh &meshRightBottom, uint32_t s3d_fmt) const;
};

}; // namespace android
Loading