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

Commit 23faa62e authored by codeworkx's avatar codeworkx Committed by Ricardo Cerqueira
Browse files

omx: exynos4: bring inline with jellybean

Change-Id: Ic275fd30a721f8161dcc44c2706b86ab5ea213ba
parent 4fb1c3e8
Loading
Loading
Loading
Loading
+20 −42
Original line number Diff line number Diff line
@@ -726,6 +726,9 @@ status_t OMXCodec::setVideoPortFormatType(
}

#ifdef USE_SAMSUNG_COLORFORMAT
#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

@@ -754,12 +757,11 @@ static size_t getFrameSize(
#endif
            return (width * height * 3) / 2;
#ifdef USE_SAMSUNG_COLORFORMAT

        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 = calc_plane(width, height);
            static unsigned int frameBufferUVSise = calc_plane(width, height >> 1);
            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:
@@ -1283,7 +1285,7 @@ status_t OMXCodec::setVideoOutputFormat(
            if (mNativeWindow == NULL)
                format.eColorFormat = OMX_COLOR_FormatYUV420Planar;
            else
                format.eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled;
                format.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
        }
#endif

@@ -1793,14 +1795,20 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
            def.format.video.nFrameHeight,
            def.format.video.eColorFormat);
#else
    OMX_COLOR_FORMATTYPE eNativeColorFormat = def.format.video.eColorFormat;
    setNativeWindowColorFormat(eNativeColorFormat);
    OMX_COLOR_FORMATTYPE eColorFormat;

    err = native_window_set_buffers_geometry(
    mNativeWindow.get(),
    def.format.video.nFrameWidth,
    def.format.video.nFrameHeight,
    eNativeColorFormat);
    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;
    }
#endif

    if (err != 0) {
@@ -1847,14 +1855,8 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {

    ALOGV("native_window_set_usage usage=0x%lx", usage);

#ifdef EXYNOS4_ENHANCEMENTS
    err = native_window_set_usage(
            mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP
            | GRALLOC_USAGE_HW_FIMC1 | GRALLOC_USAGE_HWC_HWOVERLAY);
#else
    err = native_window_set_usage(
            mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);
#endif

    if (err != 0) {
        ALOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
@@ -1951,30 +1953,6 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
    return err;
}

#ifdef USE_SAMSUNG_COLORFORMAT
void OMXCodec::setNativeWindowColorFormat(OMX_COLOR_FORMATTYPE &eNativeColorFormat)
{
    // Convert OpenMAX color format to native color format
    switch (eNativeColorFormat) {
        // In case of SAMSUNG color format
        case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
            eNativeColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
            break;
        case OMX_SEC_COLOR_FormatNV12Tiled:
            eNativeColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
            break;
        // In case of OpenMAX color formats
        case OMX_COLOR_FormatYUV420SemiPlanar:
            eNativeColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_SP;
            break;
        case OMX_COLOR_FormatYUV420Planar:
            default:
            eNativeColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_P;
            break;
    }
}
#endif // USE_SAMSUNG_COLORFORMAT

status_t OMXCodec::cancelBufferToNativeWindow(BufferInfo *info) {
    CHECK_EQ((int)info->mStatus, (int)OWNED_BY_US);
    CODEC_LOGV("Calling cancelBuffer on buffer %p", info->mBuffer);