# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1272381142 -10800 # Node ID cd271b19d82401164b7f5fda75a3d70f0426e188 # Parent b74061f7f3d2e7178a3fbbab56615eef2d733173 Revision: 201015 Kit: 201017 diff -r b74061f7f3d2 -r cd271b19d824 devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/group/ciextnserverplugin.mmp --- a/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/group/ciextnserverplugin.mmp Wed Apr 14 17:32:53 2010 +0300 +++ b/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/group/ciextnserverplugin.mmp Tue Apr 27 18:12:22 2010 +0300 @@ -28,7 +28,6 @@ SOURCEPATH ../src SOURCE ciextnserverplugin.cpp -SOURCE ciextnserverpluginwrapper.cpp SOURCE main.cpp USERINCLUDE . diff -r b74061f7f3d2 -r cd271b19d824 devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.cpp --- a/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -59,11 +59,7 @@ { DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::Setup")); TInt status(KErrNone); - TRAPD(err, iCiExtnServerPluginWrapper = CIExtnServerPluginWrapper::NewL(aInterface)); - if (err == KErrNone) - { - iMCustomInterface = iCiExtnServerPluginWrapper->GetInterface(); - } + iMCustomInterface = &aInterface; TRAP_IGNORE(InitializeMsgHndlrPluginsL()); return status; } @@ -111,7 +107,6 @@ iMCIMsgHndlrIntfcList.Reset(); iMCIMsgHndlrIntfcList.Close(); - iCiExtnServerPluginWrapper->Release(); REComSession::DestroyedImplementation(iDestructorKey); diff -r b74061f7f3d2 -r cd271b19d824 devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.h --- a/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.h Wed Apr 14 17:32:53 2010 +0300 +++ b/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverplugin.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,6 @@ // Include files #include #include -#include "ciextnserverpluginwrapper.h" // Forward declarations class MCustomInterface; @@ -99,12 +98,6 @@ MCustomInterface* iMCustomInterface; /** - * Reference to MCustomInterface interface - * Not own. - */ - CIExtnServerPluginWrapper* iCiExtnServerPluginWrapper; - - /** * Uid of the plugin object passed by the framework via PassDestructorKey() */ TUid iDestructorKey; diff -r b74061f7f3d2 -r cd271b19d824 devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.cpp --- a/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.cpp Wed Apr 14 17:32:53 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: Class definition of server plugin wrapper implementing S60 custom interface. - * - */ - -#include "ciextnserverpluginwrapper.h" -#include "citraces.h" -#include -#include - -#define KMuxTempBufferSize 20 - -#ifdef __WINSCW__ -class MyMCustomInterface - { -public: - virtual TAny* CustomInterface(TUid aCustomeInterface) = 0; - virtual void Release() = 0; - virtual void PassDestructionKey(TUid aUid) = 0; - }; -#endif - -CIExtnServerPluginWrapper* CIExtnServerPluginWrapper::NewL( - MCustomInterface& aInterfaceRef) - { - DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL Begin")); - CIExtnServerPluginWrapper* self = new (ELeave) CIExtnServerPluginWrapper( - aInterfaceRef); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL End")); - return self; - } - -CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper() - { - DEB_TRACE0(_L("CIExtnServerPluginWrappers::~CIExtnServerPluginWrapper Begin")); - DEB_TRACE0(_L("CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper End")); - } - -CIExtnServerPluginWrapper::CIExtnServerPluginWrapper( - MCustomInterface& aInterfaceRef) : - iCustomInterfaceRef(&aInterfaceRef) - { - } - -void CIExtnServerPluginWrapper::ConstructL() - { -#ifdef __WINSCW__ - DEB_TRACE0(_L("Try Loading CI Stub Plugin")); - TUid interfaceUid = - { - 0x10207C71 - }; - TAny* pluginRef; - TRAPD(error, pluginRef = REComSession::CreateImplementationL( interfaceUid, iDtor_ID_Key )); - if (pluginRef) - { - DEB_TRACE1(_L("CreateImplementationL Uid [0x%x]"), iDtor_ID_Key.iUid); - iCustomInterfaceStub = (MyMCustomInterface*) pluginRef; - iCustomInterfaceStub->PassDestructionKey(iDtor_ID_Key); - DEB_TRACE0(_L("CI Stub Loaded")); - } -#endif - - } - -MCustomInterface* CIExtnServerPluginWrapper::GetInterface() - { - DEB_TRACE0(_L("CIExtnServerPluginWrappers::GetInterface")); - return (MCustomInterface*) this; - } - -TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId) - { - DEB_TRACE0(_L("*CI* CIExtnServerPluginWrapper::CustomInterface")); - TAny* pluginRef = NULL; - pluginRef = iCustomInterfaceRef->CustomInterface(aInterfaceId); -#ifdef __WINSCW__ - if (!pluginRef) - { - DEB_TRACE0(_L("*CI* Try Loading CI Stub if present")); - pluginRef = iCustomInterfaceStub->CustomInterface(aInterfaceId); - if (pluginRef) - { - DEB_TRACE0(_L("*CI* CI Stub Loaded")); - } - } -#endif - return pluginRef; - } - -void CIExtnServerPluginWrapper::Release() - { - DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> ENTER")); -#ifdef __WINSCW__ - iCustomInterfaceStub->Release(); -#endif - DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> EXIT")); - delete this; - } - -/* - TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId) - { - DEB_TRACE0(_L("CIExtnServerPluginWrappers::CustomInterface")); - TUid interfaceUid = - { - 0x10207C49 - }; - TEComResolverParams resolverParams; - DEB_TRACE1(_L("Findig CustomInterface with Uid [0x%x]"),aInterfaceId.iUid); - TInt uidAsInteger = aInterfaceId.iUid; - TBuf8 tempBuffer; - tempBuffer.Num(uidAsInteger, EHex); - resolverParams.SetDataType(tempBuffer); - - TAny* ptr = NULL; - TRAPD(err, ptr=REComSession::CreateImplementationL( - interfaceUid, - _FOFF(CIExtnServerPluginWrapper, iDtor_ID_Key),resolverParams)); - if (err != KErrNone) - { - DEB_TRACE1(_L("No Custom Interface found: Error [%d]"),err); - } - if (ptr) - { - DEB_TRACE1(_L("Stub Present for Uid [0x%x]"),interfaceUid); - return ptr; - } - else - { - return iCustomInterfaceRef->CustomInterface(aInterfaceId); - } - } - */ diff -r b74061f7f3d2 -r cd271b19d824 devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.h --- a/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.h Wed Apr 14 17:32:53 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* -* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Header definition of server plugin wrapper class implementig S60 custom interface. -* -*/ - - -#ifndef CIEXTNSERVERPLUGINWRAPPER_H -#define CIEXTNSERVERPLUGINWRAPPER_H - -#include -#include - -// Forward declarations -class MCustomInterface; -class MyMCustomInterface; - -class CIExtnServerPluginWrapper : public CBase, - public MCustomInterface - { - public: // Constructors and destructor - - /** - * Constructs, and returns a pointer to, a new CIExtnCustomInterfaceS60 object. - * Leaves on failure.. - * @param MCustomInterface& aInterfaceRef A reference to MCustomInterface. - * @return CIExtnCustomInterfaceS60* A pointer to newly created object. - */ - static CIExtnServerPluginWrapper* NewL(MCustomInterface& aInterfaceRef); - - /** - * Destructor. - */ - ~CIExtnServerPluginWrapper(); - - public: - /** - Obtain a custom interface - @param aInterfaceId The UID of the required custom interface - @return a pointer to the custom interface - */ - TAny* CustomInterface(TUid aInterfaceId); - - public: - MCustomInterface* GetInterface(); - void Release(); - private: - - /** - * Default Constructor - */ - CIExtnServerPluginWrapper(MCustomInterface& aInterfaceRef); - - /** - * Second phase constructor. - */ - void ConstructL(); - - private: - MCustomInterface* iCustomInterfaceRef; - MyMCustomInterface* iCustomInterfaceStub; - - private: - TUid iDtor_ID_Key; - }; - -#endif // CIEXTNSERVERPLUGINWRAPPER_H diff -r b74061f7f3d2 -r cd271b19d824 imagingandcamerafws/imagingfws/GifScaler/src/NQColorQuantizer.cpp --- a/imagingandcamerafws/imagingfws/GifScaler/src/NQColorQuantizer.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/imagingandcamerafws/imagingfws/GifScaler/src/NQColorQuantizer.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -458,7 +458,7 @@ // For frequently chosen neurons, freq[i] is high and bias[i] is negative // bias[i] = gamma*((1/netsize)-freq[i]) - TInt bestd = ~(1<<31); + TInt bestd = ~((TUint32)1<<31); TInt bestbiasd = bestd; TInt bestpos = -1; TInt bestbiaspos = bestpos; diff -r b74061f7f3d2 -r cd271b19d824 imagingandcamerafws/imagingfws/ImageProcessor/inc/imageprocessorinputinfo.h --- a/imagingandcamerafws/imagingfws/ImageProcessor/inc/imageprocessorinputinfo.h Wed Apr 14 17:32:53 2010 +0300 +++ b/imagingandcamerafws/imagingfws/ImageProcessor/inc/imageprocessorinputinfo.h Tue Apr 27 18:12:22 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,6 +23,7 @@ #define __IMAGE_PROCESSOR_INPUT_INFO_H__ #include +#include namespace ImageProcessor { @@ -35,7 +36,9 @@ } /** -This class provides functions to read image input details. +This class provides functions to read input image details. These details can be used for display in a file browser +or to verify the correct capabilities. Prior to use this API, a pointer to ImageProcessor::InputInfoL() interface must be +obtained from the active CImgProcessor instance. @publishedAll @released diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/group/NGAPostProcHwDevice.mmp --- a/mdfdevvideoextensions/nga_mdf_postprocessor/group/NGAPostProcHwDevice.mmp Wed Apr 14 17:32:53 2010 +0300 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/group/NGAPostProcHwDevice.mmp Tue Apr 27 18:12:22 2010 +0300 @@ -39,7 +39,8 @@ SOURCEPATH ../src -SOURCE Colorspace_conv_yuv.c +SOURCE Colorspace_conv_yuv.c +SOURCE colorconversion.c SOURCE NGAPostProcHwDevice.cpp SOURCE ImplementationProxy.cpp SOURCE NGAPostProcSessionManager.cpp diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/inc/Colorconversion.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/inc/Colorconversion.h Tue Apr 27 18:12:22 2010 +0300 @@ -0,0 +1,774 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "common.h" + +#define CONST_19075 19075 +#define CONST_26748 26748 +#define CONST_6563 6563 +#define CONST_13621 13621 +#define CONST_33802 33802 +#define CONST_29374 29374 +#define CONST_8731 8731 +#define CONST_1747 1747 +#define CONST_34603 34603 +#define CONST_22973 22973 +#define CONST_5637 5637 +#define CONST_11699 11699 +#define CONST_29032 29032 +#define CONST_25801 25801 +#define CONST_3835 3835 +#define CONST_30397 30397 + + +/************* Start of Chroma2 format ******************************************/ + +/* For YUV420 Chroma2 input */ +// For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV420Chr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV420Chr2toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr2toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/* End of YUV420 input */ + + + + +/* Start of YUV422 Chroma2 BE (U1 Y1 V1 Y2) input */ +// For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV422BEChr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV422BEChr2toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr2toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/* End of YUV422 Chroma2 BE (U1 Y1 V1 Y2) input */ + + +/* Start of YUV422 Chr2 LE (Y2 V1 Y1 U1) input */ +// For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV422LEChr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV422LEChr2toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr2toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/* End of YUV422 Chr2 LE (Y2 V1 Y1 U1) input */ + + +void sDiffuse(int32 i, int32 j, int32 diff, int32 actWidth, int32 actHeight, + uint8 *lLumPtr, int32 lLumWidth, uint8 skip); + +/************* End of Chroma2 format ********************************************/ + + +/************* Start of Chroma1 format ******************************************/ + +/* For YUV420 Chroma1 input */ +//For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV420Chr1toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +//For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV420Chr1toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr1toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/* For YUV422 BE Chroma1 input */ +//For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV422BEChr1toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV422BEChr1toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422BEChr1toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/* For YUV422 LE Chroma1 input */ +//For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV422LEChr1toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV422LEChr1toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV422LEChr1toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/************* End of Chroma1 format ********************************************/ + + + +/************* Start of Chroma3 format ******************************************/ + +/* For YUV420 Chroma3 input */ +// For RGB 5:6:5 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 4:4:4:4 Ordered and Error Diffusion +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For RGB 8:8:8 +void sEmz_VDec_YUV420Chr3toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +// For XRGB 8:8:8:8 +void sEmz_VDec_YUV420Chr3toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +void sEmz_VDec_YUV420Chr3toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow); + +/************* End of Chroma3 format ******************************************/ + diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/inc/NGAPostProcHwDevice.h --- a/mdfdevvideoextensions/nga_mdf_postprocessor/inc/NGAPostProcHwDevice.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/inc/NGAPostProcHwDevice.h Tue Apr 27 18:12:22 2010 +0300 @@ -41,9 +41,11 @@ #include #include +#include "fetchframecustominterface.h" #include "MdfRDebug.h" #include "NGAPostProcHwDevice_UID.hrh" #include "NGAPostProcSessionManagerObserver.h" +#include "common.h" class CNGAPostProcSessionManager; class CNGAPostProcSurfaceHandler; @@ -528,8 +530,8 @@ plug-in does not support snapshots." @pre "This method can only be called after the hwdevice has been initialized with Initialize()." */ -// TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat) {return EFalse;}; - TBool GetSnapshotL(TPictureData&, const TUncompressedVideoFormat& ) {return EFalse;}; +// TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat) {return EFalse;}; + TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat); /** When the snapshot is available, it will be returned to the client using the TimedSnapshotComplete() @@ -1008,6 +1010,10 @@ #ifdef _DUMP_YUV_FRAMES void captureYuv(TVideoPicture* aPicture); #endif + + TInt SetSourceFormat(); + TInt SetSourceRange(); + TInt ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow); private: @@ -1091,6 +1097,13 @@ TUint8 iSkippedFramesCountingBuffer[64]; TUint8 iSkippedFramesInLast64Frames; TUint8 iCurrentPosInFramesCountingBuffer; + TUncompressedVideoFormat iVideoFormat; + //---------- utility variables ------- + // Image source format + TUint8 iSourceFormat; + + //Image range + TUint8 iSourceRange; }; /** diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/inc/common.h --- a/mdfdevvideoextensions/nga_mdf_postprocessor/inc/common.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/inc/common.h Tue Apr 27 18:12:22 2010 +0300 @@ -55,6 +55,31 @@ #define mIsSuccess(code) ((code)>=0) #define mIsFailure(code) ((code)<0) +/* These define the srcImageFormats */ +#define EYuv420Chroma1_Planar 0x01 +#define EYuv420Chroma2_Planar 0x02 +#define EYuv420Chroma3_Planar 0x03 +#define EYuv422Chroma1_LE 0x04 +#define EYuv422Chroma2_LE 0x05 +#define EYuv422Chroma1_BE 0x06 +#define EYuv422Chroma2_BE 0x07 + +/* These define the dstImageFormats */ +#define EBitmapColor4k_DitherOrdered 0x01 +#define EBitmapColor4k_DitherErrDiff 0x02 +#define EBitmapColor64k_DitherOrdered 0x03 +#define EBitmapColor64k_DitherErrDiff 0x04 +#define EBitmapColor16M 0x05 +#define EBitmapColor16MU 0x06 + +/* These define the various color conversion schemes */ +#define EITU601_5_FULLRANGE 0X01 +#define EITU601_5_REDUCEDRANGE 0X02 +#define EB709_FULLRANGE 0X03 +#define EB709_REDUCEDRANGE 0X04 + +#define COLOR_CONV_PRECISION 14 +#define COLOR_CONV_ROUND 8192 /* This is the data structure for the output video frame buffer */ typedef struct BaseVideoFrame { @@ -69,4 +94,13 @@ typedef enum {YUV422INT_LE, YUV422INT_BE} EBufferLayout422; +/* Crop window structure */ +typedef struct WndParam +{ + uint16 xOffset; + uint16 yOffset; + uint32 wndWidth; + uint32 wndHeight; +}tWndParam; + #endif /* INCLUDE_COMMON */ diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/inc/fetchframecustominterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/inc/fetchframecustominterface.h Tue Apr 27 18:12:22 2010 +0300 @@ -0,0 +1,51 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef FETCHFRAMECUSTOMINTERFACE_H +#define FETCHFRAMECUSTOMINTERFACE_H + +/** +FetchFrame Custom Interface UID. + +@publishedPartner +@prototype +*/ +const TUid KUidMMFVideoFetchFrame = { 0x20024343 }; + +/** +This interface can be used to fetch the frame data using the buffer id. +This interface can be used by a H/W device which needs to send the frame +data back to application. + +@publishedPartner +@prototype +*/ +class MMmfVideoFetchFrame + { + public: + + /** + Set the handle for the surface + + @param aBufId Buffer id whose frame data needs to be returned. + + returns pointer to a frame data. memory is allocated by the Custom interface + implementor to hold the frame data on the host side. ownership of the memory + would be transfered to the caller of this method. + */ + virtual TUint8* MmvffGetFrame(TInt aBufId) = 0; + }; + +#endif // FETCHFRAMECUSTOMINTERFACE_H diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp --- a/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -19,7 +19,6 @@ #include "NGAPostProcHwDevice.h" #include "NGAPostProcSessionManager.h" #include "NGAPostProcSurfaceHandler.h" -#include "common.h" // post-processor info const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid}; @@ -47,6 +46,11 @@ int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame, uint8 outClrFmt, int16 stride); +int32 Emz_VDec_gColorConv_YUVtoRGB ( + tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow, + tWndParam *dstWindow, uint8 srcImageFormat, uint8 dstImageFormat, + uint8 colorConvScheme); + #ifdef __cplusplus } #endif @@ -175,10 +179,7 @@ if(!iSurfaceId.IsNull()) { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this); - for(TInt i=0;i < iWsSession.NumberOfScreens();i++) - { - iWsSession.UnregisterSurface(i, iSurfaceId); - } + iWsSession.UnregisterSurface(0, iSurfaceId); iSurfaceHandler->DestroySurface(iSurfaceId); } delete iSurfaceHandler; @@ -206,11 +207,15 @@ User::Leave(KErrNotReady); } - - if( ((aFormat.iYuvFormat.iPattern == EYuv420Chroma1) || - (aFormat.iYuvFormat.iPattern == EYuv420Chroma2) || - (aFormat.iYuvFormat.iPattern == EYuv420Chroma3) )) + iVideoFormat = aFormat; + if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) || + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) || + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) )) { + iVideoFormat.iYuvFormat.iCoefficients = EYuvBt709Range1; + iVideoFormat.iYuvFormat.iPattern = EYuv422Chroma1; + iVideoFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; + #if defined __WINSCW__ iIsColorConversionNeeded = ETrue; #else @@ -359,7 +364,7 @@ void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) { - PP_DEBUG(_L("CNGAPostProcHwDevice:WritePicture ++")); + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture)); TVideoPicture* pic; if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded) { @@ -373,15 +378,18 @@ User::Leave(KErrArgument); } pic = aPicture; - if (iInputQ.Count() > 0) - { - AddToQ(pic); - AttemptToPost(); - } - else - { - PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(pic)); - iPictureCounters.iTotalPictures++; + iPictureCounters.iTotalPictures++; + if((iPPState != EPlaying) && (iFirstPictureUpdated)) + { + AddToQ(pic); + } + else if( iInputQ.Count() > 0 ) + { + AddToQ(pic); + AttemptToPost(); + } + else + { TInt64 delta = 0; TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta); if(!IsGceReady()) @@ -397,7 +405,10 @@ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); iTimeToPost = ESkipIt; } - + if(!iFirstPictureUpdated) + { + iTimeToPost = EPostIt; + } switch(iTimeToPost) { case EDelayIt: @@ -870,6 +881,7 @@ { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this); iPPState = EPlaying; + AttemptToPost(); PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this); } @@ -981,6 +993,107 @@ //not required for direct rendering } +TBool CNGAPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& /*aFormat*/) +{ + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL %d %d ++"), this, iVBMEnabled, iProcessQ.Count()); + TVideoPicture* pic = NULL; + TInt err = KErrNone; + TBool frameAvailable =EFalse; + tWndParam inputCropWindow; + tWndParam outputCropWindow; + tBaseVideoFrame inputFrame; + inputFrame.lum = NULL; + + if(aPictureData.iDataFormat == ERgbFbsBitmap) + { + if(iProcessQ.Count()) + { + pic = iProcessQ[0]; //frame already submitted for display + } + else if(iInputQ.Count()) + { + pic = iInputQ[0]; //frame yet to be displayed + } + if(pic) + { + if (iVBMEnabled) + { + inputFrame.lum = (TUint8*)pic->iData.iRawData->Ptr(); + } + else + { + if (iInputDecoderDevice) + { + MMmfVideoFetchFrame* VFHandler = NULL; + VFHandler = (MMmfVideoFetchFrame*)iInputDecoderDevice->CustomInterface(KUidMMFVideoFetchFrame); + if (VFHandler) + { + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() fetch frame"), this); + inputFrame.lum = (TUint8*)VFHandler->MmvffGetFrame(GetID(pic)); + } + else + { + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() decoder yet to implement MMmfVideoFetchFrame CI"), this); + } + } + } + } + if(inputFrame.lum) + { + inputFrame.cb = inputFrame.lum + iPicSize.iWidth * iPicSize.iHeight; + + if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) || + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) || + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) )) + { + inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*5)/4; + } + else + { + inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*3)/2; + } + + inputFrame.width = (unsigned short)iPicSize.iWidth; + inputFrame.height = (unsigned short)iPicSize.iHeight; + + outputCropWindow.wndHeight = iPicSize.iHeight; + outputCropWindow.wndWidth = iPicSize.iWidth; + outputCropWindow.xOffset = 0; + outputCropWindow.yOffset = 0; + + inputCropWindow.wndHeight = iPicSize.iHeight; + inputCropWindow.wndWidth = iPicSize.iWidth; + inputCropWindow.xOffset = 0; + inputCropWindow.yOffset = 0; + + RFbsSession fbs; + fbs.Connect(); + CFbsBitmap* iOutBitmap = aPictureData.iRgbBitmap; + TInt status = iOutBitmap->Resize(iPicSize); + if (status == KErrNone) + { + // Lock the heap to prevent the FBS server from invalidating the address + iOutBitmap->LockHeap(); + TUint8* dataAddress = (TUint8*)iOutBitmap->DataAddress(); + err = ColorConvert(&inputFrame, dataAddress, &inputCropWindow, &outputCropWindow); + iOutBitmap->UnlockHeap(); + frameAvailable = ETrue; + } + fbs.Disconnect(); + } + } + else + { + err = KErrNotSupported; + } + if(err != KErrNone) + { + User::Leave(err); + } + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL --"), this); + return(frameAvailable); +} + void CNGAPostProcHwDevice::InputEnd() { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this); @@ -1218,12 +1331,13 @@ if(iVBMBufferReferenceQ.Count() == 0) { - err = SetupSurface(aSize); - if(err) - { - PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err); - User::Leave(err); - } + iPicSize = aSize; + err = SetupSurface(aSize); + if(err) + { + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err); + User::Leave(err); + } } if(!iVBMBufferQ.Count()) @@ -1302,10 +1416,7 @@ if(!aSurfaceId.IsNull()) { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId ); - for(TInt i=0;i < iWsSession.NumberOfScreens();i++) - { - iWsSession.UnregisterSurface(i, aSurfaceId); - } + iWsSession.UnregisterSurface(0, iSurfaceId); iSurfaceHandler->DestroySurface(aSurfaceId); } @@ -1701,12 +1812,12 @@ TInt64 uPresTime = frame->iTimestamp.Int64(); // Check if this is an out of order frame in case of forward playback - if((iCurrentPlaybackPosition.Int64() >= uPresTime) && (iPlayRate > 0)) + if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0)) { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime); resp = ESkipIt; //drop } // Check if this is an out of order frame in case of backward playback - else if((iCurrentPlaybackPosition.Int64() <= uPresTime) && (iPlayRate < 0)) + else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0)) { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime); resp = ESkipIt; //drop @@ -1729,7 +1840,7 @@ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta); } - PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d"), this, resp); + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame)); return resp; } @@ -1914,12 +2025,7 @@ TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId) { PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId); - TInt err = KErrNone; - for(TInt i=0; (i < iWsSession.NumberOfScreens() && err == KErrNone); i++) - { - err = iWsSession.RegisterSurface(i, aSurfaceId); - } - return(err); + return(iWsSession.RegisterSurface(0, aSurfaceId)); } TInt CNGAPostProcHwDevice::IsGceReady() @@ -2153,6 +2259,110 @@ return err; } +TInt CNGAPostProcHwDevice::ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow) +{ + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert ++"), this); + __ASSERT_ALWAYS(aDestPtr, User::Invariant()); + TInt lError = E_SUCCESS; + TInt err = KErrNone; + + err = SetSourceFormat(); + if(err == KErrNone) + { + err = SetSourceRange(); + if(err == KErrNone) + { + + lError = Emz_VDec_gColorConv_YUVtoRGB(aInputFrame,aDestPtr, + aInputCropWindow, aOutputCropWindow, iSourceFormat, + EBitmapColor16MU, iSourceRange); + + if(lError) + { + if(lError == E_OUT_OF_MEMORY) + { + err = KErrNoMemory; + } + else if(lError == E_FAILURE) + { + err = KErrNotSupported; + } + else + { + err = KErrGeneral; + } + } + } + } + + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert --"), this); + return err; +} + +TInt CNGAPostProcHwDevice::SetSourceFormat() +{ + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL ++"), this); + TInt err = KErrNone; + switch (iVideoFormat.iYuvFormat.iPattern) + { + case EYuv420Chroma1: + iSourceFormat = EYuv420Chroma1_Planar; + break; + case EYuv420Chroma2: + iSourceFormat = EYuv420Chroma2_Planar; + break; + case EYuv420Chroma3: + iSourceFormat = EYuv420Chroma3_Planar; + break; + case EYuv422Chroma1: + if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE) + iSourceFormat = EYuv422Chroma1_LE; + else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE ) + iSourceFormat = EYuv422Chroma1_BE; + else + err = KErrArgument; + break; + case EYuv422Chroma2: + if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE) + iSourceFormat = EYuv422Chroma2_LE; + else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE ) + iSourceFormat = EYuv422Chroma2_BE; + else + err = KErrArgument; + break; + default: + err = KErrNotSupported; + } + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL --"), this); + return err; +} + + +TInt CNGAPostProcHwDevice::SetSourceRange() +{ + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL ++"), this); + TInt err = KErrNone; + switch (iVideoFormat.iYuvFormat.iCoefficients) + { + case EYuvBt601Range0: + iSourceRange = EITU601_5_REDUCEDRANGE; + break; + case EYuvBt601Range1: + iSourceRange = EITU601_5_FULLRANGE; + break; + case EYuvBt709Range0: + iSourceRange = EB709_REDUCEDRANGE; + break; + case EYuvBt709Range1: + iSourceRange = EB709_FULLRANGE; + break; + default: + err = KErrNotSupported; + } + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL --"), this); + return err; +} + CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent ) :CTimer(EPriorityHigh),iParent(aParent) { diff -r b74061f7f3d2 -r cd271b19d824 mdfdevvideoextensions/nga_mdf_postprocessor/src/colorconversion.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdfdevvideoextensions/nga_mdf_postprocessor/src/colorconversion.c Tue Apr 27 18:12:22 2010 +0300 @@ -0,0 +1,63648 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include "Colorconversion.h" + +/* +****************************************************************************** +Name : Emz_VDec_gColorConv_YUVtoRGB +Description : Converts YUV picture data to RGB data. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) + uint8 srcImageFmt : Specifies the color format of src data (i/p, o/p). + uint8 dstImageFmt : Specifies the color format of dst data (i/p, o/p). + uint8 colorConvScheme : Specifies the color conversion standard.(i/p) +Return Value : int32 +****************************************************************************** +*/ +int32 Emz_VDec_gColorConv_YUVtoRGB + (tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow, + tWndParam *dstWindow, uint8 srcImageFmt, uint8 dstImageFmt, + uint8 colorConvScheme) +{ + tWndParam lSrcWindow, lDstWindow; + + if( (NULL == srcImage) || (NULL == srcImage->lum) || + (NULL == dstImage) || (srcWindow == NULL)|| (dstWindow == NULL) ) + + { + return E_OUT_OF_MEMORY; + } + + if( (EYuv422Chroma2_BE != srcImageFmt) && (EYuv422Chroma2_LE != srcImageFmt) + && (EYuv422Chroma1_BE != srcImageFmt) && (EYuv422Chroma1_LE != srcImageFmt)) + { + if( (NULL == srcImage->cb) || (NULL == srcImage->cr) ) + { + return E_OUT_OF_MEMORY; + } + } + + lSrcWindow.xOffset = srcWindow->xOffset; + lSrcWindow.yOffset = srcWindow->yOffset; + lSrcWindow.wndWidth = srcWindow->wndWidth; + lSrcWindow.wndHeight = srcWindow->wndHeight; + + lDstWindow.xOffset = dstWindow->xOffset; + lDstWindow.yOffset = dstWindow->yOffset; + lDstWindow.wndWidth = dstWindow->wndWidth; + lDstWindow.wndHeight = dstWindow->wndHeight; + + lSrcWindow.xOffset = (uint16) ((lSrcWindow.xOffset >> 1) << 1); + lSrcWindow.yOffset = (uint16) ((lSrcWindow.yOffset >> 1) << 1); + lDstWindow.wndWidth = (lDstWindow.wndWidth >> 1) << 1; + lDstWindow.wndHeight = (lDstWindow.wndHeight >> 1) << 1; + + switch (srcImageFmt) + { + + case EYuv420Chroma1_Planar : + + switch (dstImageFmt) + { + + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr1toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr1toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv420Chroma2_Planar : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr2toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr2toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv420Chroma3_Planar : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV420Chr3toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV420Chr3toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv422Chroma1_BE : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr1toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr1toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv422Chroma2_BE : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422BEChr2toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422BEChr2toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv422Chroma1_LE : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr1toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr1toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + case EYuv422Chroma2_LE : + + switch (dstImageFmt) + { + case EBitmapColor4k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor4k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherOrdered : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor64k_DitherErrDiff : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16M : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor16M_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor16M_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor16M_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor16M_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + case EBitmapColor16MU : + + switch (colorConvScheme) + { + case EB709_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor16MU_709_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_FULLRANGE : + sEmz_VDec_YUV422LEChr2toColor16MU_601_5_FR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EB709_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor16MU_709_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + case EITU601_5_REDUCEDRANGE : + sEmz_VDec_YUV422LEChr2toColor16MU_601_5_RR + (srcImage, dstImage, &lSrcWindow, &lDstWindow); + break; + + default : + return E_FAILURE; + } + break; + + default : + return E_FAILURE; + } + + break; + + default : + return E_FAILURE; + } + + return E_SUCCESS; +} + + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** Start of Chroma2 format *******************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + + + +/****** Functions for YUV420 input *******/ +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_FR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_FR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_RR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_RR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16M_709_FR +Description : Converts YUV420 Chroma2 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16M_601_5_FR +Description : Converts YUV420 Chroma2 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16M_709_RR +Description : Converts YUV420 Chroma2 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16M_601_5_RR +Description : Converts YUV420 Chroma2 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16MU_709_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16MU_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16MU_601_5_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16MU_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16MU_709_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16MU_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor16MU_601_5_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor16MU_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCr = lCrPtr[j >> 1]; + lCb = lCbPtr[j >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/**** End of YUV420 input *****/ + + + +/**** Start of YUV422BE input *****/ +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16M_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16M_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16M_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16M_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16MU_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16MU_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16MU_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor16MU_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/***** End of YUV422BE input ****/ + + + +/**** Start of YUV422LE input *****/ +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16M_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16M_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16M_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16M_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16MU_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16MU_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16MU_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor16MU_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < lWidth; j += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/***** End of YUV422LE input ****/ + + + + + + + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_FR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_RR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma2 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCr = lCrPtr[k >> 1]; + lCb = lCbPtr[k >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr = lCrPtr[(k + lLumWidth) >> 1]; + lCb = lCbPtr[(k + lLumWidth) >> 1]; + + lCr -= 128; + lCb -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr2toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[0]; + lCr = lYuyvPtr[2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth]; + lCr = lYuyvPtr[lLumWidth + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1)]; + lCr = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (25801 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb) + (7670 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (22973 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb) + (11699 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (29374 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb) + (8731 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr2toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr, lCb; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < lWidth; k += 2) + { + lCb = lYuyvPtr[3]; + lCr = lYuyvPtr[1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[lLumWidth + 3]; + lCr = lYuyvPtr[lLumWidth + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lCb = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb -= 128; + lCr -= 128; + + lTemp1 = (26748 * lCr) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb) + (13621 * lCr)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** End of Chroma2 format *********************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + + + + + + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** Start of Chroma1 format *******************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_FR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_FR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_RR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_RR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16M_709_FR +Description : Converts YUV420 Chroma1 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16M_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16M_601_5_FR +Description : Converts YUV420 Chroma1 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16M_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16M_709_RR +Description : Converts YUV420 Chroma1 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16M_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16M_601_5_RR +Description : Converts YUV420 Chroma1 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16M_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_FR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_FR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_RR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_RR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16MU_709_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16MU_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16MU_601_5_FR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16MU_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16MU_709_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16MU_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor16MU_601_5_RR +Description : Converts YUV420 Chroma2 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor16MU_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + + +/************** End of YUV420 input *************/ + +/************** Start of YUV422BE input ********/ + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16M_709_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16M_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16M_709_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16M_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16MU_709_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16MU_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16MU_709_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor16MU_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/************** End of YUV422BE input *******************/ + + + + + +/************** Start of YUV422LE input ********/ + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16M_709_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16M_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16M_709_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16M_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to RGB888 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1 ; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = (lY1 + lTemp1); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = (lY1 - lTemp2); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[4] = (uint8) lTemp; + + /*B component*/ + lTemp = (lY1 + lTemp3); + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr[5] = (uint8) lTemp; + + lYuyvPtr += 4; + lRGBFramePtr += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_Ordered_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Third Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)lTemp4; + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)lTemp4; + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16MU_709_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16MU_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16MU_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16MU_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16MU_709_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16MU_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor16MU_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma1 Interleaved to XRGB (8:8:8:8) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor16MU_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lYuyvPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + + for(i = 0; i < lHeight; i++) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)lTemp4; + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)lTemp4; + + lYuyvPtr += 4; + lRGBFramePtr += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + lRGBFramePtr += (wndWidth - lTempWidth); + } + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/************** End of YUV422LE input *******************/ + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_FR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_RR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma1 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_FR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_RR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma1 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 4); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[(k + lLumWidth) >> 1 + 1]; + lCb2 = lCbPtr[(k + lLumWidth) >> 1 + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Seventh Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1)) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Eighth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 2) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + (lSrcWidth << 1) + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + (lSrcWidth << 1) + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + (lSrcWidth << 1) + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_FR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_RR +Description : Converts YUV422 BE (UYVY) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422BEChr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb2 = lYuyvPtr[4]; + lCr2 = lYuyvPtr[6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb2 = lYuyvPtr[lLumWidth + 4]; + lCr2 = lYuyvPtr[lLumWidth + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 4]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 6]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[0]; + lCr1 = lYuyvPtr[2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth]; + lCr1 = lYuyvPtr[lLumWidth + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth << 1]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to RGB565 Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + + + + + + + + + + + + + + + + + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_FR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_RR +Description : Converts YUV422 LE (YVYU) Chroma2 Interleaved to XRGB (4:4:4:4) Interleaved format. +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV422LEChr1toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lYuyvPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 diff1, diff2, diff3; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, k, extraCol, extraRow; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lYuyvPtr = srcImage->lum + (srcYOffset * (lLumWidth << 1)) + (srcXOffset << 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + lLumWidth <<= 1; + + for(i = 0; i < lHeight; i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb2 = lYuyvPtr[7]; + lCr2 = lYuyvPtr[5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*First Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb2 = lYuyvPtr[lLumWidth + 7]; + lCr2 = lYuyvPtr[lLumWidth + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + /*Third Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb2 = lYuyvPtr[(lLumWidth << 1) + 7]; + lCr2 = lYuyvPtr[(lLumWidth << 1) + 5]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCb2 -= 128; + lCr2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + } + + lCb1 = lYuyvPtr[3]; + lCr1 = lYuyvPtr[1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lYuyvPtr[2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lYuyvPtr[0]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[lLumWidth + 3]; + lCr1 = lYuyvPtr[lLumWidth + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lYuyvPtr[lLumWidth + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lYuyvPtr[lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCb1 = lYuyvPtr[(lLumWidth << 1) + 3]; + lCr1 = lYuyvPtr[(lLumWidth << 1) + 1]; + + lCb1 -= 128; + lCr1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1) + 2]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lYuyvPtr[(lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lYuyvPtr += 4; + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lYuyvPtr += ((lLumWidth - lWidth) << 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** End of Chroma1 format *********************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + + + + + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** Start of Chroma3 format *******************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_FR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_FR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_RR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_RR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 16-bit + {5,6,5} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,3,2} {4,0,6} | + | {6,1,4} {2,2,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 6; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1 + 4; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 3); + + /*G component*/ + lTemp = lY1 - lTemp2 + 2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 2) << 5; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 3) << 11; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_Ordered_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + /* This function performs YUV to RGB conversion with dithering for 12-bit + {4,4,4} RGB. The 2x2 dither pattern used for {R,G,B} colors is as follows: + + | {0,15,5} {10,0,15} | + | {15,5,10} {5,10,0} | */ + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + /*First Pixel*/ + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[0] = (uint16)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr[1] = (uint16)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 15; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[0] = (uint16)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3 + 5; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (lTemp >> 4); + + /*G component*/ + lTemp = lY1 - lTemp2 + 10; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 4; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= (lTemp >> 4) << 8; + + lRGBFramePtr1[1] = (uint16)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16M_709_FR +Description : Converts YUV420 Chroma3 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16M_709_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16M_601_5_FR +Description : Converts YUV420 Chroma3 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16M_601_5_FR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16M_709_RR +Description : Converts YUV420 Chroma3 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16M_709_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16M_601_5_RR +Description : Converts YUV420 Chroma3 Planar to RGB888 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16M_601_5_RR + (tBaseVideoFrame *srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint8 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth * 3; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + dstXOffset *= 3; + wndWidth *= 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = dstImage + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[2] = (uint8) lTemp; + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[4] = (uint8) lTemp; + + + /*B component*/ + lTemp = lY1 + lTemp3; + + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr[5] = (uint8) lTemp; + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[0] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[1] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[2] = (uint8) lTemp; + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[3] = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lRGBFramePtr1[4] = (uint8) lTemp; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + + lRGBFramePtr1[5] = (uint8) lTemp; + + lRGBFramePtr += 6; + lRGBFramePtr1 += 6; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr = lRGBFramePtr[-3]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + *lRGBFramePtr1 = lRGBFramePtr1[-3]; + lRGBFramePtr1++; + + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth * 3; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + } + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16MU_709_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16MU_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16MU_601_5_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16MU_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16MU_709_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16MU_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor16MU_601_5_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (8:8:8:8) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor16MU_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint32 *lRGBFramePtr, *lRGBFramePtr1; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + int32 lLumWidth, lWidth, lHeight, lTempWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3, lTemp4; + int32 i, j, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + lRGBFramePtr = (uint32*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + lRGBFramePtr1 = lRGBFramePtr + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + for(j = 0; j < (lWidth - 2); j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr2 = lCrPtr[(j >> 1) + 1]; + lCb2 = lCbPtr[(j >> 1) + 1]; + + lCr3 = lCrPtr[(j >> 1) + (lLumWidth >> 1)]; + lCb3 = lCbPtr[(j >> 1) + (lLumWidth >> 1)]; + + lCr4 = lCrPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + lCb4 = lCbPtr[(j >> 1) + (lLumWidth >> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + } + + + for(j = 0; j < lWidth; j += 2) + { + lCr1 = lCrPtr[j >> 1]; + lCb1 = lCbPtr[j >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[j]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[0] = (uint32)(lTemp4); + + /*Second Pixel*/ + lY1 = lLumPtr[j + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr[1] = (uint32)(lTemp4); + + + /*Third Pixel*/ + lY1 = lLumPtr[j + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[0] = (uint32)(lTemp4); + + /*Fourth Pixel*/ + lY1 = lLumPtr[j + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + /*B component*/ + lTemp = lY1 + lTemp3; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 = (uint8) lTemp; + + /*G component*/ + lTemp = lY1 - lTemp2; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 8; + + /*R component*/ + lTemp = lY1 + lTemp1; + if (lTemp < 0) + lTemp = 0; + if (lTemp > 255) + lTemp = 255; + lTemp4 |= lTemp << 16; + + lRGBFramePtr1[1] = (uint32)(lTemp4); + + lRGBFramePtr += 2; + lRGBFramePtr1 += 2; + } + + if(extraCol) + { + *lRGBFramePtr = lRGBFramePtr[-1]; + lRGBFramePtr++; + *lRGBFramePtr1 = lRGBFramePtr1[-1]; + lRGBFramePtr1++; + } + + lRGBFramePtr += ((wndWidth << 1) - lTempWidth); + lRGBFramePtr1 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + lRGBFramePtr1 = lRGBFramePtr - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *lRGBFramePtr++ = *lRGBFramePtr1++; + *lRGBFramePtr++ = *lRGBFramePtr1++; + } + if(extraCol) + { + *lRGBFramePtr = *lRGBFramePtr1; + } + } + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_FR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_RR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma3 Planar to RGB565 Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor64k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 3 | (*(src1 + 1) >> 2) << 5 | (*src1 >> 3) << 11); + diff1 = *src1 & 0x7; + diff2 = *(src1 + 1) & 0x3; + diff3 = *(src1 + 2) & 0x7; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 3 | (*(src1 + 4) >> 2) << 5 | (*(src1 + 3) >> 3) << 11); + diff1 = *(src1 + 3) & 0x7; + diff2 = *(src1 + 4) & 0x3; + diff3 = *(src1 + 5) & 0x7; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 3 | (*(src2 + 1) >> 2) << 5 | (*src2 >> 3) << 11); + diff1 = *src2 & 0x7; + diff2 = *(src2 + 1) & 0x3; + diff3 = *(src2 + 2) & 0x7; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 3 | (*(src2 + 4) >> 2) << 5 | (*(src2 + 3) >> 3) << 11); + diff1 = *(src2 + 3) & 0x7; + diff2 = *(src2 + 4) & 0x3; + diff3 = *(src2 + 5) & 0x7; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (25801 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb4) + (7670 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (25801 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb3) + (7670 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (25801 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb2) + (7670 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (25801 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3072 * lCb1) + (7670 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (30397 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_FR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_FR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (22973 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb4) + (11699 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (22973 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb3) + (11699 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (22973 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb2) + (11699 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (22973 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((5637 * lCb1) + (11699 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (29032 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 255) ? 255 : ((lTemp < 0) ? 0 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_709_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (29374 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb4) + (8731 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (29374 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb3) + (8731 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (29374 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb2) + (8731 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (29374 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((3494 * lCb1) + (8731 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (34603 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_RR +Description : Converts YUV420 Chroma3 Planar to XRGB (4:4:4:4) Interleaved format +Parameter : tBaseVideoFrame *srcImage : Pointer to the source frame (i/p), + uint8 *dstImage : Pointer to rgb data (o/p). + tWndParam *srcWindow : Pointer to structure containing source window + parameters like xOffset,yOffset,cropWidth, + cropHeight. (i/p) + tWndParam *dstWindow : Pointer to structure containing destination window + parameters like xOffset,yOffset,windWidth, + windHeight. (i/p) +Return Value : void +****************************************************************************** +*/ + +void sEmz_VDec_YUV420Chr3toColor4k_ErrDiff_601_5_RR + (tBaseVideoFrame* srcImage, uint8* dstImage, + tWndParam* srcWindow, tWndParam* dstWindow) +{ + uint16 *dest1, *dest2; + uint8 *lLumPtr, *lCrPtr, *lCbPtr; + uint8 *lBuffer; + uint8 *src1, *src2; + uint8 *lPtr1, *lPtr2; + int32 lLumWidth, lWidth, lHeight, lTempWidth, lSrcWidth; + int32 lY1, lCr1, lCb1, lCr2, lCb2, lCr3, lCb3, lCr4, lCb4; + int32 lTemp, lTemp1, lTemp2, lTemp3; + int32 diff1, diff2, diff3; + int32 i, j, k, extraRow, extraCol; + int32 srcXOffset,srcYOffset,dstXOffset,dstYOffset, + cropWidth,cropHeight,wndWidth,wndHeight; + + srcXOffset = srcWindow->xOffset; + srcYOffset = srcWindow->yOffset; + cropWidth = srcWindow->wndWidth; + cropHeight = srcWindow->wndHeight; + + dstXOffset = dstWindow->xOffset; + dstYOffset = dstWindow->yOffset; + wndWidth = dstWindow->wndWidth; + wndHeight = dstWindow->wndHeight; + + if ((srcImage->width - srcXOffset) >= cropWidth) + { + lWidth = cropWidth; + } + else + { + lWidth = srcImage->width - srcXOffset; + } + + if ((srcImage->height - srcYOffset) >= cropHeight) + { + lHeight = cropHeight; + } + else + { + lHeight = srcImage->height - srcYOffset; + } + + if (lWidth > (wndWidth - dstXOffset)) + { + lWidth = wndWidth - dstXOffset; + } + + if (lHeight > (wndHeight - dstYOffset)) + { + lHeight = wndHeight - dstYOffset; + } + + extraCol = lWidth & 0x01; + extraRow = lHeight & 0x01; + + lTempWidth = lWidth; + lWidth = (lWidth >> 1) << 1; + lHeight = (lHeight >> 1) << 1; + + lBuffer = (uint8*) malloc(lWidth * 3 * 3); + + lSrcWidth = lWidth * 3; + + lLumWidth = (srcImage->width >> 1) << 1; + lLumPtr = srcImage->lum + (srcYOffset * lLumWidth) + srcXOffset; + lCbPtr = srcImage->cb + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + lCrPtr = srcImage->cr + (((srcYOffset * (lLumWidth >> 1)) + srcXOffset) >> 1); + + dest1 = (uint16*)(dstImage) + (dstYOffset * wndWidth) + dstXOffset; + dest2 = dest1 + wndWidth; + + for(i = 0; i < (lHeight - 2); i += 2) + { + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = lCrPtr[((k + lLumWidth)>> 1) + 1]; + lCb4 = lCbPtr[((k + lLumWidth)>> 1) + 1]; + + lCr4 = (lCr1 + lCr2 + lCr3 + lCr4) >> 2; + lCb4 = (lCb1 + lCb2 + lCb3 + lCb4) >> 2; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + lCr3 = (lCr1 + lCr3) >> 1; + lCb3 = (lCb1 + lCb3) >> 1; + + /*First Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + /*Third Pixel*/ + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr1 = lCrPtr[(k + lLumWidth) >> 1]; + lCb1 = lCbPtr[(k + lLumWidth) >> 1]; + + lCr2 = lCrPtr[((k + lLumWidth) >> 1) + 1]; + lCb2 = lCbPtr[((k + lLumWidth) >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + /*Fifth Pixel*/ + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr3 = lCrPtr[(k + lLumWidth)>> 1]; + lCb3 = lCbPtr[(k + lLumWidth)>> 1]; + + lCr4 = (lCr1 + lCr3) >> 1; + lCb4 = (lCb1 + lCb3) >> 1; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr4 -= 128; + lCb4 -= 128; + + lTemp1 = (26748 * lCr4) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb4) + (13621 * lCr4)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb4) >> COLOR_CONV_PRECISION; + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr3 -= 128; + lCb3 -= 128; + + lTemp1 = (26748 * lCr3) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb3) + (13621 * lCr3)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb3) >> COLOR_CONV_PRECISION; + + /*Fifth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1)]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Sixth Pixel*/ + lY1 = lLumPtr[k + (lLumWidth << 1) + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + lSrcWidth + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + lSrcWidth + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + lSrcWidth + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + lLumPtr += (lLumWidth << 1); + lCrPtr += (lLumWidth >> 1); + lCbPtr += (lLumWidth >> 1); + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + } + + + lPtr1 = src1 = lBuffer; + lPtr2 = src2 = src1 + lSrcWidth; + + for(k = 0; k < (lWidth - 2); k += 2) + { + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr2 = lCrPtr[(k >> 1) + 1]; + lCb2 = lCbPtr[(k >> 1) + 1]; + + lCr2 = (lCr1 + lCr2) >> 1; + lCb2 = (lCb1 + lCb2) >> 1; + + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + + lCr2 -= 128; + lCb2 -= 128; + + lTemp1 = (26748 * lCr2) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb2) + (13621 * lCr2)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb2) >> COLOR_CONV_PRECISION; + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + } + + lCr1 = lCrPtr[k >> 1]; + lCb1 = lCbPtr[k >> 1]; + + lCr1 -= 128; + lCb1 -= 128; + + lTemp1 = (26748 * lCr1) >> COLOR_CONV_PRECISION; + lTemp2 = ((6563 * lCb1) + (13621 * lCr1)) >> COLOR_CONV_PRECISION; + lTemp3 = (33802 * lCb1) >> COLOR_CONV_PRECISION; + + /*First Pixel*/ + lY1 = lLumPtr[k]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src1 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Second Pixel*/ + lY1 = lLumPtr[k + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src1 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src1 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src1 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Third Pixel*/ + lY1 = lLumPtr[k + lLumWidth]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *src2 = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 1) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 2) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + /*Fourth Pixel*/ + lY1 = lLumPtr[k + lLumWidth + 1]; + lY1 -= 16; + lY1 = (lY1 * 19075) >> COLOR_CONV_PRECISION; + + lTemp = lY1 + lTemp1; + *(src2 + 3) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 - lTemp2; + *(src2 + 4) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + lTemp = lY1 + lTemp3; + *(src2 + 5) = (uint8)((lTemp > 235) ? 235 : ((lTemp < 16) ? 16 : lTemp)); + + src1 += 6; + src2 += 6; + + + src1 = lPtr1; + src2 = lPtr2; + + for(j = 0; j < lWidth; j += 2) + { + /* First Pixel */ + *dest1 = (uint16) (*(src1 + 2) >> 4 | (*(src1 + 1) >> 4) << 4 | (*src1 >> 4) << 8); + diff1 = *src1 & 0xf; + diff2 = *(src1 + 1) & 0xf; + diff3 = *(src1 + 2) & 0xf; + + // diffuse the error + sDiffuse(i,j,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + /* Second Pixel */ + *(dest1 + 1) = (uint16) (*(src1 + 5) >> 4 | (*(src1 + 4) >> 4) << 4 | (*(src1 + 3) >> 4) << 8); + diff1 = *(src1 + 3) & 0xf; + diff2 = *(src1 + 4) & 0xf; + diff3 = *(src1 + 5) & 0xf; + // diffuse the error + sDiffuse(i,j+1,diff1,lWidth,lHeight,lPtr1,lSrcWidth, 3); //r + sDiffuse(i,j+1,diff2,lWidth,lHeight,lPtr1 + 1,lSrcWidth, 3); //g + sDiffuse(i,j+1,diff3,lWidth,lHeight,lPtr1 + 2,lSrcWidth, 3); //b + + src1 += 6; + dest1 += 2; + + /* Third Pixel */ + *dest2 = (uint16) (*(src2 + 2) >> 4 | (*(src2 + 1) >> 4) << 4 | (*src2 >> 4) << 8); + diff1 = *src2 & 0xf; + diff2 = *(src2 + 1) & 0xf; + diff3 = *(src2 + 2) & 0xf; + //diffuse the error + sDiffuse(i+1,j,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + /* Fourth Pixel */ + *(dest2 + 1) = (uint16) (*(src2 + 5) >> 4 | (*(src2 + 4) >> 4) << 4 | (*(src2 + 3) >> 4) << 8); + diff1 = *(src2 + 3) & 0xf; + diff2 = *(src2 + 4) & 0xf; + diff3 = *(src2 + 5) & 0xf; + //diffuse the error + sDiffuse(i+1,j+1,diff1,lWidth,lHeight,lPtr2,lSrcWidth, 3); //r + sDiffuse(i+1,j+1,diff2,lWidth,lHeight,lPtr2 + 1,lSrcWidth, 3); //g + sDiffuse(i+1,j+1,diff3,lWidth,lHeight,lPtr2 + 2,lSrcWidth, 3); //b + + src2 += 6; + dest2 += 2; + } + + if(extraCol) + { + *dest1 = dest1[-1]; + dest1++; + *dest2 = dest2[-1]; + dest2++; + } + + dest1 += ((wndWidth << 1) - lTempWidth); + dest2 += ((wndWidth << 1) - lTempWidth); + + if(extraRow) + { + dest2 = dest1 - wndWidth; + for(j = 0; j < lWidth; j += 2) + { + *dest1++ = *dest2++; + *dest1++ = *dest2++; + } + if(extraCol) + { + *dest1 = *dest2; + } + } + + free(lBuffer); + return; +} + +/* +****************************************************************************** +Name : sDiffuse +Description : Diffuses the quantization error to the neighbouring pixels. +Parameter : int32 i : x position of the current pixel. + int32 j : y position of the current pixel. + int32 diff : error to be diffused. + int32 actWidth : Source Width + int32 actHeight : Source Height + uint8 *lLumPtr : + int32 lLumWidth : + uint8 skip : + +Return Value : void +****************************************************************************** +*/ + +void sDiffuse(int32 i, int32 j, int32 diff, int32 actWidth, int32 actHeight, uint8 *lLumPtr, + int32 lLumWidth, uint8 skip) +{ + int32 tmp; + + if(i < actHeight - 2) + { + if(j < actWidth - 2) + { + if(j > 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else if(j > 0) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + } + else if(j < actWidth - 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + } + else if(i < actHeight - 1) + { + if(j < actWidth - 2) + { + if(j > 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else if(j > 0) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + } + else if(j < actWidth - 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[(j + 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j + 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + tmp = lLumPtr[(j - 1) * skip + lLumWidth] + ((diff << 3) >> 6); + lLumPtr[(j - 1) * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + tmp = lLumPtr[j * skip + lLumWidth] + ((diff << 4) >> 6); + lLumPtr[j * skip + lLumWidth] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + } + else + { + if(j < actWidth - 2) + { + if(j > 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else if(j > 0) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + } + else if(j < actWidth - 1) + { + tmp = lLumPtr[(j + 1) * skip] + ((diff * 24) >> 6); + lLumPtr[(j + 1) * skip] = (uint8)((tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp)); + + } + else + { + return; + } + } + + return; +} + +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ +/**************** End of Chroma3 format *********************/ +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ + + diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/audio_routing_api/inc/AudioOutput.h --- a/mm_plat/audio_routing_api/inc/AudioOutput.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/audio_routing_api/inc/AudioOutput.h Tue Apr 27 18:12:22 2010 +0300 @@ -25,7 +25,7 @@ #include #include #include -#include +#include // FORWARD DECLARATIONS class MAudioOutputObserver; diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/audio_routing_proxy_api/inc/AudioInputProxy.h --- a/mm_plat/audio_routing_proxy_api/inc/AudioInputProxy.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/audio_routing_proxy_api/inc/AudioInputProxy.h Tue Apr 27 18:12:22 2010 +0300 @@ -22,7 +22,7 @@ // INCLUDES #include "AudioInput.h" #include -#include +#include // FORWARD DECLARATIONS class CCustomCommandUtility; class CCustomInterfaceUtility; diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/audio_routing_proxy_api/inc/AudioOutputProxy.h --- a/mm_plat/audio_routing_proxy_api/inc/AudioOutputProxy.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/audio_routing_proxy_api/inc/AudioOutputProxy.h Tue Apr 27 18:12:22 2010 +0300 @@ -22,7 +22,7 @@ // INCLUDES #include "AudioOutput.h" #include -#include +#include // FORWARD DECLARATIONS class CCustomCommandUtility; diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/custom_interface_proxy_factory_api/inc/CustomInterfaceProxyFactory.h --- a/mm_plat/custom_interface_proxy_factory_api/inc/CustomInterfaceProxyFactory.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/custom_interface_proxy_factory_api/inc/CustomInterfaceProxyFactory.h Tue Apr 27 18:12:22 2010 +0300 @@ -19,7 +19,7 @@ #define __CUSTOMINTERFACEPROXYFACTORY_H #include -#include +#include #include class CCustomInterfaceProxyFactory diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/custom_interface_utility_api/inc/CustomCommandUtility.h --- a/mm_plat/custom_interface_utility_api/inc/CustomCommandUtility.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/custom_interface_utility_api/inc/CustomCommandUtility.h Tue Apr 27 18:12:22 2010 +0300 @@ -20,7 +20,7 @@ #define __CUSTOMCOMMANDUTILITY_H #include -#include +#include //#include "CustomCommandTypes.h" diff -r b74061f7f3d2 -r cd271b19d824 mm_plat/custom_interface_utility_api/inc/CustomInterfaceUtility.h --- a/mm_plat/custom_interface_utility_api/inc/CustomInterfaceUtility.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_plat/custom_interface_utility_api/inc/CustomInterfaceUtility.h Tue Apr 27 18:12:22 2010 +0300 @@ -19,7 +19,7 @@ #define __CUSTOMINTERFACEUTILITY_H #include -#include +#include //#include "CustomCommandTypes.h" #include class CProxyCustomInterfaceUtility; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/AudioEqualizerBase.h --- a/mm_pub/audio_effects_api/inc/AudioEqualizerBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/AudioEqualizerBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidAudioEqualizerEffect = {0x1020382A}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/BassBoostBase.h --- a/mm_pub/audio_effects_api/inc/BassBoostBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/BassBoostBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidBassBoostEffect = {0x10203827}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/DistanceAttenuationBase.h --- a/mm_pub/audio_effects_api/inc/DistanceAttenuationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/DistanceAttenuationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidDistanceAttenuationEffect = {0x1020382C}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/DopplerBase.h --- a/mm_pub/audio_effects_api/inc/DopplerBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/DopplerBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -25,7 +25,7 @@ #include #include #include -#include +#include // CLASS DECLARATION diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/EnvironmentalReverbBase.h --- a/mm_pub/audio_effects_api/inc/EnvironmentalReverbBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/EnvironmentalReverbBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidEnvironmentalReverbEffect = {0x10203837}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/ListenerDopplerBase.h --- a/mm_pub/audio_effects_api/inc/ListenerDopplerBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/ListenerDopplerBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidListenerDopplerEffect = {0x10207B16}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/ListenerLocationBase.h --- a/mm_pub/audio_effects_api/inc/ListenerLocationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/ListenerLocationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidListenerLocationEffect = {0x1020382D}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/ListenerOrientationBase.h --- a/mm_pub/audio_effects_api/inc/ListenerOrientationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/ListenerOrientationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidListenerOrientationEffect = {0x1020382E}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/LoudnessBase.h --- a/mm_pub/audio_effects_api/inc/LoudnessBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/LoudnessBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidLoudnessEffect = {0x10207AA8}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/OrientationBase.h --- a/mm_pub/audio_effects_api/inc/OrientationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/OrientationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -25,7 +25,7 @@ #include #include #include -#include +#include // CLASS DECLARATION diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/RoomLevelBase.h --- a/mm_pub/audio_effects_api/inc/RoomLevelBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/RoomLevelBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidRoomLevelEffect = {0x10207B3C}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/SourceDopplerBase.h --- a/mm_pub/audio_effects_api/inc/SourceDopplerBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/SourceDopplerBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidSourceDopplerEffect = {0x10207B15}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/SourceLocationBase.h --- a/mm_pub/audio_effects_api/inc/SourceLocationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/SourceLocationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidSourceLocationEffect = {0x10203835}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/SourceOrientationBase.h --- a/mm_pub/audio_effects_api/inc/SourceOrientationBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/SourceOrientationBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -23,7 +23,7 @@ #include #include -#include +#include const TUid KUidSourceOrientationEffect = {0x10203834}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/audio_effects_api/inc/StereoWideningBase.h --- a/mm_pub/audio_effects_api/inc/StereoWideningBase.h Wed Apr 14 17:32:53 2010 +0300 +++ b/mm_pub/audio_effects_api/inc/StereoWideningBase.h Tue Apr 27 18:12:22 2010 +0300 @@ -24,7 +24,7 @@ #include #include #include -#include +#include const TUid KUidStereoWideningEffect = {0x10203836}; diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/drm_audio_player_api/tsrc/data/mmc/drm/test3gp.dcf diff -r b74061f7f3d2 -r cd271b19d824 mm_pub/drm_audio_player_api/tsrc/data/mmc/drm/testmp3.dcf diff -r b74061f7f3d2 -r cd271b19d824 mmplugins/imagingplugins/codecs/JPEGCodec/JPEGCodec.cpp --- a/mmplugins/imagingplugins/codecs/JPEGCodec/JPEGCodec.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/mmplugins/imagingplugins/codecs/JPEGCodec/JPEGCodec.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -1467,7 +1467,7 @@ do { index = (index << 1) + 1; - index +=((look & TUint(1<<31)) != 0); + index +=((look & ((TUint32)1<<31)) != 0); look<<=1; } while (++bitCount < nb); diff -r b74061f7f3d2 -r cd271b19d824 mmplugins/imagingplugins/codecs/JPEGCodec/JPGQUANT.CPP --- a/mmplugins/imagingplugins/codecs/JPEGCodec/JPGQUANT.CPP Wed Apr 14 17:32:53 2010 +0300 +++ b/mmplugins/imagingplugins/codecs/JPEGCodec/JPGQUANT.CPP Tue Apr 27 18:12:22 2010 +0300 @@ -226,6 +226,7 @@ register TAligned64Value dstValue; register TAligned64Value qValue; register TAligned64Value zValue; + dstValue.iAligment = 0; //to remove possible RVCT warning zValue.iAligment = *reinterpret_cast(zigZagPtr); qValue.iAligment = *qPtr++; diff -r b74061f7f3d2 -r cd271b19d824 mmplugins/imagingplugins/codecs/PNGCodec/PngScanlineDecoder.cpp --- a/mmplugins/imagingplugins/codecs/PNGCodec/PngScanlineDecoder.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/mmplugins/imagingplugins/codecs/PNGCodec/PngScanlineDecoder.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -327,7 +327,7 @@ while (aDataPtr < aDataPtrLimit) { - *scanLinePtr++ = (0xFF << 24) | (aDataPtr[0] << 16) | (aDataPtr[1] << 8) | aDataPtr[2]; + *scanLinePtr++ = ((TUint32)0xFF << 24) | ((TUint32)aDataPtr[0] << 16) | ((TUint32)aDataPtr[1] << 8) | aDataPtr[2]; aDataPtr += KPngDepth3BytesPerPixel; } diff -r b74061f7f3d2 -r cd271b19d824 mmplugins/imagingplugins/codecs/TIFFCodec/TIFFFax.cpp --- a/mmplugins/imagingplugins/codecs/TIFFCodec/TIFFFax.cpp Wed Apr 14 17:32:53 2010 +0300 +++ b/mmplugins/imagingplugins/codecs/TIFFCodec/TIFFFax.cpp Tue Apr 27 18:12:22 2010 +0300 @@ -1154,7 +1154,7 @@ if(!iBitCacheLength) return(ETiffFaxUnderflow); - if(iBitCache&(1<<31)) + if(iBitCache&((TUint32)1<<31)) iState = E1d; else iState = E2d;