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

Commit 12be7037 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "[Exynos4] added support for samsung codec" into ics

parents 084dbcd6 01e4493c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ public:
        USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
        USAGE_HW_COMPOSER       = GRALLOC_USAGE_HW_COMPOSER,
        USAGE_HW_VIDEO_ENCODER  = GRALLOC_USAGE_HW_VIDEO_ENCODER,
#ifdef SAMSUNG_CODEC_SUPPORT
        USAGE_HW_FIMC1          = GRALLOC_USAGE_HW_FIMC1,
#endif
        USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK
    };

+3 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ public:
        USAGE_HW_TEXTURE        = GRALLOC_USAGE_HW_TEXTURE,
        USAGE_HW_RENDER         = GRALLOC_USAGE_HW_RENDER,
        USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
#ifdef SAMSUNG_CODEC_SUPPORT
        USAGE_HW_FIMC1          = GRALLOC_USAGE_HW_FIMC1,
#endif
        USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK
    };

+3 −0
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@ include $(CLEAR_VARS)

include frameworks/base/media/libstagefright/codecs/common/Config.mk

ifeq ($(BOARD_HAVE_CODEC_SUPPORT),SAMSUNG_CODEC_SUPPORT)
LOCAL_CFLAGS     += -DSAMSUNG_CODEC_SUPPORT
endif
LOCAL_SRC_FILES:=                         \
        ACodec.cpp                        \
        AACExtractor.cpp                  \
+132 −3
Original line number Diff line number Diff line
@@ -45,9 +45,19 @@
#include <OMX_Component.h>

#include "include/avc_utils.h"
#ifdef SAMSUNG_CODEC_SUPPORT
#include "include/ColorFormat.h"
#endif

namespace android {

#ifdef SAMSUNG_CODEC_SUPPORT
static const int OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001;
static const int OMX_SEC_COLOR_FormatNV12LPhysicalAddress = 0x7F000002;
static const int OMX_SEC_COLOR_FormatNV12LVirtualAddress = 0x7F000003;
static const int OMX_SEC_COLOR_FormatNV12Tiled = 0x7FC00002;
#endif

// Treat time out as an error if we have not received any output
// buffers after 3 seconds.
const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL;
@@ -875,6 +885,12 @@ status_t OMXCodec::setVideoPortFormatType(
    return err;
}

#ifdef SAMSUNG_CODEC_SUPPORT
#define ALIGN_TO_8KB(x)   ((((x) + (1 << 13) - 1) >> 13) << 13)
#define ALIGN_TO_32B(x)   ((((x) + (1 <<  5) - 1) >>  5) <<  5)
#define ALIGN_TO_128B(x)  ((((x) + (1 <<  7) - 1) >>  7) <<  7)
#define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
#endif
static size_t getFrameSize(
        OMX_COLOR_FORMATTYPE colorFormat, int32_t width, int32_t height) {
    switch (colorFormat) {
@@ -894,8 +910,21 @@ static size_t getFrameSize(
        * this part in the future
        */
        case OMX_COLOR_FormatAndroidOpaque:
#ifdef SAMSUNG_CODEC_SUPPORT
    case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
    case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
#endif
            return (width * height * 3) / 2;

#ifdef SAMSUNG_CODEC_SUPPORT
    case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
        return ALIGN((ALIGN(width, 16) * ALIGN(height, 16)), 2048) + ALIGN((ALIGN(width, 16) * ALIGN(height >> 1, 8)), 2048);

    case OMX_SEC_COLOR_FormatNV12Tiled:
        static unsigned int frameBufferYSise = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height));
        static unsigned int frameBufferUVSise = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height/2));
        return (frameBufferYSise + frameBufferUVSise);
#endif
        default:
            CHECK(!"Should not be here. Unsupported color format.");
            break;
@@ -1403,7 +1432,23 @@ status_t OMXCodec::setVideoOutputFormat(
               || format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar
               || format.eColorFormat == OMX_COLOR_FormatCbYCrY
               || format.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar
               || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar);
               || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar
#ifdef SAMSUNG_CODEC_SUPPORT
               || format.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress
               || format.eColorFormat == OMX_SEC_COLOR_FormatNV12Tiled
#endif
               );
#ifdef SAMSUNG_CODEC_SUPPORT
        if (!strcmp("OMX.SEC.FP.AVC.Decoder", mComponentName) ||
            !strcmp("OMX.SEC.AVC.Decoder", mComponentName) ||
            !strcmp("OMX.SEC.MPEG4.Decoder", mComponentName) ||
            !strcmp("OMX.SEC.H263.Decoder", mComponentName)) {
            if (mNativeWindow == NULL)
                format.eColorFormat = OMX_COLOR_FormatYUV420Planar;
            else
                format.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
        }
#endif

        err = mOMX->setParameter(
                mNode, OMX_IndexParamVideoPortFormat,
@@ -1841,13 +1886,34 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
    if (err != OK) {
        return err;
    }

#ifndef SAMSUNG_CODEC_SUPPORT
    err = native_window_set_buffers_geometry(
            mNativeWindow.get(),
            def.format.video.nFrameWidth,
            def.format.video.nFrameHeight,
            def.format.video.eColorFormat);
#else
    OMX_COLOR_FORMATTYPE eColorFormat;

    switch (def.format.video.eColorFormat) {
    case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
        eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
        break;
    case OMX_COLOR_FormatYUV420SemiPlanar:
        eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_SP;
        break;
    case OMX_COLOR_FormatYUV420Planar:
    default:
        eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_P;
        break;
    }

    err = native_window_set_buffers_geometry(
            mNativeWindow.get(),
            def.format.video.nFrameWidth,
            def.format.video.nFrameHeight,
            eColorFormat);
#endif
    if (err != 0) {
        LOGE("native_window_set_buffers_geometry failed: %s (%d)",
                strerror(-err), -err);
@@ -1891,8 +1957,13 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
    }

    LOGV("native_window_set_usage usage=0x%lx", usage);
#ifndef SAMSUNG_CODEC_SUPPORT
    err = native_window_set_usage(
            mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);
#else
    err = native_window_set_usage(
            mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP | GRALLOC_USAGE_HW_FIMC1 | GRALLOC_USAGE_HWC_HWOVERLAY);
#endif
    if (err != 0) {
        LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
        return err;
@@ -3238,12 +3309,48 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {
                CHECK(info->mMediaBuffer == NULL);
                info->mMediaBuffer = srcBuffer;
            } else {
#ifndef SAMSUNG_CODEC_SUPPORT
                CHECK(srcBuffer->data() != NULL) ;
                memcpy((uint8_t *)info->mData + offset,
                        (const uint8_t *)srcBuffer->data()
                            + srcBuffer->range_offset(),
                        srcBuffer->range_length());
#else
                OMX_PARAM_PORTDEFINITIONTYPE def;
                InitOMXParams(&def);
                def.nPortIndex = kPortIndexInput;

                status_t err = mOMX->getParameter(mNode, OMX_IndexParamPortDefinition,
                                                  &def, sizeof(def));
                CHECK_EQ(err, (status_t)OK);

                if (def.eDomain == OMX_PortDomainVideo) {
                    OMX_VIDEO_PORTDEFINITIONTYPE *videoDef = &def.format.video;
                    switch (videoDef->eColorFormat) {
                    case OMX_SEC_COLOR_FormatNV12LVirtualAddress: {
                        CHECK(srcBuffer->data() != NULL);
                        void *pSharedMem = (void *)(srcBuffer->data());
                        memcpy((uint8_t *)info->mData + offset,
                                (const void *)&pSharedMem, sizeof(void *));
                        break;
                    }
                    default:
                        CHECK(srcBuffer->data() != NULL);
                        memcpy((uint8_t *)info->mData + offset,
                                (const uint8_t *)srcBuffer->data()
                                    + srcBuffer->range_offset(),
                                srcBuffer->range_length());
                        break;
                    }
                } else {
                    CHECK(srcBuffer->data() != NULL);
                    memcpy((uint8_t *)info->mData + offset,
                            (const uint8_t *)srcBuffer->data()
                                + srcBuffer->range_offset(),
                            srcBuffer->range_length());
                }
#endif
            }
        }

        int64_t lastBufferTimeUs;
@@ -4130,7 +4237,22 @@ static const char *colorFormatString(OMX_COLOR_FORMATTYPE type) {

    if (type == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) {
        return "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar";
    } else if (type == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) {
	}
#ifdef SAMSUNG_CODEC_SUPPORT
    if (type == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
        return "OMX_SEC_COLOR_FormatNV12TPhysicalAddress";
    }
    if (type == OMX_SEC_COLOR_FormatNV12LPhysicalAddress) {
        return "OMX_SEC_COLOR_FormatNV12LPhysicalAddress";
    }
    if (type == OMX_SEC_COLOR_FormatNV12LVirtualAddress) {
        return "OMX_SEC_COLOR_FormatNV12LVirtualAddress";
    }
    if (type == OMX_SEC_COLOR_FormatNV12Tiled) {
        return "OMX_SEC_COLOR_FormatNV12Tiled";
    }
#endif
    else if (type == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) {
        return "OMX_QCOM_COLOR_FormatYVU420SemiPlanar";
    } else if (type < 0 || (size_t)type >= numNames) {
        return "UNKNOWN";
@@ -4571,6 +4693,13 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
                        video_def->nFrameWidth, video_def->nFrameHeight);

                if (err == OK) {
#ifdef SAMSUNG_CODEC_SUPPORT
                    /* Hack GetConfig */
                    rect.nLeft = 0;
                    rect.nTop = 0;
                    rect.nWidth = video_def->nFrameWidth;
                    rect.nHeight = video_def->nFrameHeight;
#endif
                    CHECK_GE(rect.nLeft, 0);
                    CHECK_GE(rect.nTop, 0);
                    CHECK_GE(rect.nWidth, 0u);
+30 −0
Original line number Diff line number Diff line
/*************************************************
   Author: Annamalai Lakshmanan
   Added Color formats for Samsung OMX Decode
*************************************************/

enum {
    HAL_PIXEL_FORMAT_YCbCr_422_P         = 0x100,
    HAL_PIXEL_FORMAT_YCbCr_420_P         = 0x101,
    HAL_PIXEL_FORMAT_YCbCr_420_I         = 0x102,
    HAL_PIXEL_FORMAT_CbYCrY_422_I        = 0x103,
    HAL_PIXEL_FORMAT_CbYCrY_420_I        = 0x104,
    HAL_PIXEL_FORMAT_YCbCr_420_SP        = 0x105,
    HAL_PIXEL_FORMAT_YCrCb_422_SP        = 0x106,
    // support custom format for zero copy
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x110,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x111,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED = 0x112,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP = 0x113,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP = 0x114,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x115,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I = 0x116,
    HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117,
    HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I = 0x118,
    HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I  = 0x11B,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_SBS_LR = 0x11C,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_SBS_RL = 0x11D,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_TB_LR = 0x11E,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_TB_RL = 0x11F,
    HAL_PIXEL_FORMAT_CUSTOM_MAX
};
Loading