From 58c70bc3e59ac241aa25cb28d17fbd03fc814a4f Mon Sep 17 00:00:00 2001 From: Saurabh Shah Date: Fri, 20 May 2011 13:57:35 -0700 Subject: [PATCH] Fix positioning of small videos. Small videos (width < 128) have their stride as 128. For HDMI destination position was set only once, before the actual width was supplied through crop. Now the position is set during a setPosition API call. Change-Id: If49ac23b9294951aaf4ad9d5432653082b4a7802 CRs-fixed: 286953 --- liboverlay/overlay.cpp | 2 +- liboverlay/overlayLib.cpp | 15 ++++++++++----- liboverlay/overlayLib.h | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp index db8468b..9f9075f 100644 --- a/liboverlay/overlay.cpp +++ b/liboverlay/overlay.cpp @@ -198,7 +198,7 @@ public: if (!mHandle.pobjControlChannel[channel]) return false; return mHandle.pobjControlChannel[channel]->getAspectRatioPosition(mHandle.w, - mHandle.h, mHandle.format, rect); + mHandle.h, rect); } bool setParameter(int param, int value, int channel) { diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index 1f5b816..ce79f6e 100644 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -217,7 +217,7 @@ bool Overlay::startChannelHDMI(int w, int h, int format, bool norot) { if(ret) { ret = startChannel(w, h, format, FRAMEBUFFER_1, true, 0, 0, VG1_PIPE); overlay_rect rect; - if(ret && objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition(w, h, format, &rect)) { + if(ret && objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition(w, h, &rect)) { if(!setChannelPosition(rect.x, rect.y, rect.w, rect.h, VG1_PIPE)) { LOGE("Failed to upscale for framebuffer 1"); return false; @@ -275,9 +275,13 @@ bool Overlay::getOrientation(int& orientation, int channel) const { bool Overlay::setPosition(int x, int y, uint32_t w, uint32_t h) { if(mS3DFormat && mHDMIConnected) { return setPositionS3D(x, y, w, h); - } else { - return setChannelPosition(x, y, w, h, VG0_PIPE); } + if(mHDMIConnected) { + overlay_rect rect; + objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition(w, h, &rect); + setChannelPosition(rect.x, rect.y, rect.w, rect.h, VG1_PIPE); + } + return setChannelPosition(x, y, w, h, VG0_PIPE); } bool Overlay::setChannelPosition(int x, int y, uint32_t w, uint32_t h, int channel) { @@ -521,7 +525,7 @@ OverlayControlChannel::~OverlayControlChannel() { closeControlChannel(); } -bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int format, overlay_rect *rect) +bool OverlayControlChannel::getAspectRatioPosition(int w, int h, overlay_rect *rect) { int width = w, height = h, x, y; int fbWidth = getFBWidth(); @@ -529,7 +533,7 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int format, ove // width and height for YUV TILE format int tempWidth = w, tempHeight = h; /* Calculate the width and height if it is YUV TILE format*/ - if(format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) { + if(getFormat() == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) { tempWidth = w - ( (((w-1)/64 +1)*64) - w); tempHeight = h - ((((h-1)/32 +1)*32) - h); } @@ -779,6 +783,7 @@ bool OverlayControlChannel::startControlChannel(int w, int h, unsigned int format3D, int zorder, bool ignoreFB) { mNoRot = norot; + mFormat = format; mUIChannel = uichannel; fb_fix_screeninfo finfo; fb_var_screeninfo vinfo; diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index 3636b20..be87445 100644 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -117,7 +117,7 @@ class OverlayControlChannel { int mFBHeight; int mFBbpp; int mFBystride; - + int mFormat; int mFD; int mRotFD; int mSize; @@ -155,9 +155,10 @@ public: bool getOrientation(int& orientation) const; bool setSource(uint32_t w, uint32_t h, int format, int orientation, bool ignoreFB); - bool getAspectRatioPosition(int w, int h, int format, overlay_rect *rect); + bool getAspectRatioPosition(int w, int h, overlay_rect *rect); bool getPositionS3D(int channel, int format, overlay_rect *rect); bool updateOverlaySource(uint32_t w, uint32_t h, int format, int orientation); + bool getFormat() const { return mFormat; } }; class OverlayDataChannel {