sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "rendererutil.h" sl@0: sl@0: /** Convert TVideoRendererPixelFormat pixel format from resource file to uncompressed video format */ sl@0: TUncompressedVideoFormat VideoRendererUtil::ConvertPixelFormatToUncompressedVideoFormatL(TVideoRendererPixelFormat aPixelFormat) sl@0: { sl@0: TUncompressedVideoFormat ret; sl@0: sl@0: switch (aPixelFormat) sl@0: { sl@0: case EVideoRendererPixelFormatXRGB_8888: sl@0: ret.iDataFormat = ERgbRawData; sl@0: ret.iRgbFormat = ERgb32bit888; sl@0: break; sl@0: case EVideoRendererPixelFormatRGB_565: sl@0: ret.iDataFormat = ERgbRawData; sl@0: ret.iRgbFormat = ERgb16bit565; sl@0: break; sl@0: case EVideoRendererPixelFormatXRGB_4444: sl@0: ret.iDataFormat = ERgbRawData; sl@0: ret.iRgbFormat = ERgb16bit444; sl@0: break; sl@0: default: sl@0: DEBUGPRINT2(_L("VideoRendererUtil::ConvertPixelFormatToUncompressedVideoFormatL aPixelFormat=%d"), aPixelFormat); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: /** Convert TUidPixelFormat pixel format to uncompressed video format */ sl@0: TUncompressedVideoFormat VideoRendererUtil::ConvertUidPixelFormatToUncompressedVideoFormatL(TUidPixelFormat aUidPixelFormat) sl@0: { sl@0: return ConvertPixelFormatToUncompressedVideoFormatL(static_cast(aUidPixelFormat)); sl@0: } sl@0: sl@0: /** Convert uncompressed video format to TUidPixelFormat pixel format */ sl@0: TUidPixelFormat VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormatL(const TUncompressedVideoFormat& aFormat) sl@0: { sl@0: TUidPixelFormat ret = EUidPixelFormatUnknown; sl@0: sl@0: if (aFormat.iDataFormat != ERgbRawData) sl@0: { sl@0: DEBUGPRINT2(_L("VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormat iDataFormat=%d"), aFormat.iDataFormat); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: switch (aFormat.iRgbFormat) sl@0: { sl@0: case ERgb32bit888: sl@0: ret = EUidPixelFormatXRGB_8888; sl@0: break; sl@0: case ERgb16bit565: sl@0: ret = EUidPixelFormatRGB_565; sl@0: break; sl@0: case ERgb16bit444: sl@0: ret = EUidPixelFormatXRGB_4444; sl@0: break; sl@0: default: sl@0: DEBUGPRINT2(_L("VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormatL iRgbFormat=%d"), aFormat.iRgbFormat); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: /** return the bytes per pixel for a uid pixel format */ sl@0: TInt VideoRendererUtil::BytesPerPixelL(TUidPixelFormat aPixelFormat) sl@0: { sl@0: switch (aPixelFormat) sl@0: { sl@0: case EUidPixelFormatXRGB_4444: sl@0: case EUidPixelFormatRGB_565: sl@0: return 2; sl@0: case EUidPixelFormatXRGB_8888: sl@0: return 4; sl@0: default: sl@0: DEBUGPRINT2(_L("VideoRendererUtil::BytesPerPixelL aPixelFormat=%d"), aPixelFormat); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return 0; // to remove compile warning sl@0: }