Skip to content

Commit

Permalink
samsung: set proper native color format if using samsung codecs
Browse files Browse the repository at this point in the history
Change-Id: Ifd76d88f9f7a1947a1583322f0a675dec6d12edf

Conflicts:

	media/libstagefright/ACodec.cpp
  • Loading branch information
Faryaab committed Apr 7, 2012
1 parent 0075195 commit 199de01
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/media/stagefright/ACodec.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions media/libstagefright/ACodec.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

#include <OMX_Component.h>

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

namespace android {

template<class T>
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 199de01

Please sign in to comment.