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

Commit 2a6d0570 authored by codeworkx's avatar codeworkx
Browse files

samsung: set proper native color format if using samsung codecs

Change-Id: Ifd76d88f9f7a1947a1583322f0a675dec6d12edf
parent 40c519ed
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -137,6 +137,10 @@ private:
    status_t freeOutputBuffersNotOwnedByComponent();
    BufferInfo *dequeueBufferFromNativeWindow();

#ifdef SAMSUNG_CODEC_SUPPORT
    void setNativeWindowColorFormat(OMX_COLOR_FORMATTYPE &eNativeColorFormat);
#endif

    BufferInfo *findBufferByID(
            uint32_t portIndex, IOMX::buffer_id bufferID,
            ssize_t *index = NULL);
+33 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
#define MIN_HEIGHT 320;
#endif

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

namespace android {

template<class T>
@@ -533,6 +537,15 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
        format = HAL_PIXEL_FORMAT_YCrCb_420_SP;
#endif

#ifdef SAMSUNG_CODEC_SUPPORT
    OMX_COLOR_FORMATTYPE eNativeColorFormat = def.format.video.eColorFormat;
    setNativeWindowColorFormat(eNativeColorFormat);
    err = native_window_set_buffers_geometry(
            mNativeWindow.get(),
            def.format.video.nFrameWidth,
            def.format.video.nFrameHeight,
           eNativeColorFormat);
#else
    err = native_window_set_buffers_geometry(
            mNativeWindow.get(),
            def.format.video.nFrameWidth,
@@ -542,6 +555,7 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
#else
            def.format.video.eColorFormat);
#endif
#endif


    if (err != 0) {
@@ -690,6 +704,25 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
    return err;
}

#ifdef SAMSUNG_CODEC_SUPPORT
void ACodec::setNativeWindowColorFormat(OMX_COLOR_FORMATTYPE &eNativeColorFormat)
{
    // In case of Samsung decoders, we set proper native color format for the Native Window
    if (!strcasecmp(mComponentName.c_str(), "OMX.SEC.AVC.Decoder")
        || !strcasecmp(mComponentName.c_str(), "OMX.SEC.FP.AVC.Decoder")) {
        switch (eNativeColorFormat) {
            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

status_t ACodec::cancelBufferToNativeWindow(BufferInfo *info) {
    CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_US);