|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <mmf/devvideo/devvideobase.h> |
|
17 #include "rendererutil.h" |
|
18 |
|
19 /** Convert TVideoRendererPixelFormat pixel format from resource file to uncompressed video format */ |
|
20 TUncompressedVideoFormat VideoRendererUtil::ConvertPixelFormatToUncompressedVideoFormatL(TVideoRendererPixelFormat aPixelFormat) |
|
21 { |
|
22 TUncompressedVideoFormat ret; |
|
23 |
|
24 switch (aPixelFormat) |
|
25 { |
|
26 case EVideoRendererPixelFormatXRGB_8888: |
|
27 ret.iDataFormat = ERgbRawData; |
|
28 ret.iRgbFormat = ERgb32bit888; |
|
29 break; |
|
30 case EVideoRendererPixelFormatRGB_565: |
|
31 ret.iDataFormat = ERgbRawData; |
|
32 ret.iRgbFormat = ERgb16bit565; |
|
33 break; |
|
34 case EVideoRendererPixelFormatXRGB_4444: |
|
35 ret.iDataFormat = ERgbRawData; |
|
36 ret.iRgbFormat = ERgb16bit444; |
|
37 break; |
|
38 default: |
|
39 DEBUGPRINT2(_L("VideoRendererUtil::ConvertPixelFormatToUncompressedVideoFormatL aPixelFormat=%d"), aPixelFormat); |
|
40 User::Leave(KErrNotSupported); |
|
41 } |
|
42 |
|
43 return ret; |
|
44 } |
|
45 |
|
46 /** Convert TUidPixelFormat pixel format to uncompressed video format */ |
|
47 TUncompressedVideoFormat VideoRendererUtil::ConvertUidPixelFormatToUncompressedVideoFormatL(TUidPixelFormat aUidPixelFormat) |
|
48 { |
|
49 return ConvertPixelFormatToUncompressedVideoFormatL(static_cast<TVideoRendererPixelFormat>(aUidPixelFormat)); |
|
50 } |
|
51 |
|
52 /** Convert uncompressed video format to TUidPixelFormat pixel format */ |
|
53 TUidPixelFormat VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormatL(const TUncompressedVideoFormat& aFormat) |
|
54 { |
|
55 TUidPixelFormat ret = EUidPixelFormatUnknown; |
|
56 |
|
57 if (aFormat.iDataFormat != ERgbRawData) |
|
58 { |
|
59 DEBUGPRINT2(_L("VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormat iDataFormat=%d"), aFormat.iDataFormat); |
|
60 User::Leave(KErrNotSupported); |
|
61 } |
|
62 |
|
63 switch (aFormat.iRgbFormat) |
|
64 { |
|
65 case ERgb32bit888: |
|
66 ret = EUidPixelFormatXRGB_8888; |
|
67 break; |
|
68 case ERgb16bit565: |
|
69 ret = EUidPixelFormatRGB_565; |
|
70 break; |
|
71 case ERgb16bit444: |
|
72 ret = EUidPixelFormatXRGB_4444; |
|
73 break; |
|
74 default: |
|
75 DEBUGPRINT2(_L("VideoRendererUtil::ConvertUncompressedVideoFormatToUidPixelFormatL iRgbFormat=%d"), aFormat.iRgbFormat); |
|
76 User::Leave(KErrNotSupported); |
|
77 } |
|
78 |
|
79 return ret; |
|
80 } |
|
81 |
|
82 /** return the bytes per pixel for a uid pixel format */ |
|
83 TInt VideoRendererUtil::BytesPerPixelL(TUidPixelFormat aPixelFormat) |
|
84 { |
|
85 switch (aPixelFormat) |
|
86 { |
|
87 case EUidPixelFormatXRGB_4444: |
|
88 case EUidPixelFormatRGB_565: |
|
89 return 2; |
|
90 case EUidPixelFormatXRGB_8888: |
|
91 return 4; |
|
92 default: |
|
93 DEBUGPRINT2(_L("VideoRendererUtil::BytesPerPixelL aPixelFormat=%d"), aPixelFormat); |
|
94 User::Leave(KErrNotSupported); |
|
95 } |
|
96 |
|
97 return 0; // to remove compile warning |
|
98 } |