From 199de01f60a1ed5fc375161dd8680af2fae5ae2c Mon Sep 17 00:00:00 2001 From: Faryaab Sheikh Date: Sat, 7 Apr 2012 18:47:40 +0100 Subject: [PATCH] samsung: set proper native color format if using samsung codecs Change-Id: Ifd76d88f9f7a1947a1583322f0a675dec6d12edf Conflicts: media/libstagefright/ACodec.cpp --- include/media/stagefright/ACodec.h | 4 +++ media/libstagefright/ACodec.cpp | 42 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) mode change 100644 => 100755 include/media/stagefright/ACodec.h mode change 100644 => 100755 media/libstagefright/ACodec.cpp diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h old mode 100644 new mode 100755 index 3963d9cf5909b..fff0ebe717385 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -128,6 +128,10 @@ struct ACodec : public AHierarchicalStateMachine { 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); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp old mode 100644 new mode 100755 index dbc9b7ecb5df1..f794fb05f0870 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -36,6 +36,10 @@ #include +#ifdef SAMSUNG_CODEC_SUPPORT +#include "include/ColorFormat.h" +#endif + namespace android { template @@ -438,11 +442,30 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() { return err; } +#ifdef QCOM_HARDWARE + int format = (def.format.video.eColorFormat == (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka)? + HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED : def.format.video.eColorFormat; + if(def.format.video.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) + 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, def.format.video.nFrameHeight, def.format.video.eColorFormat); +#endif +#endif + if (err != 0) { LOGE("native_window_set_buffers_geometry failed: %s (%d)", @@ -562,6 +585,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);