1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "VedVideoClipGenerator.h" |
|
22 #include "VedMovieImp.h" |
|
23 #include "VedVideoClip.h" |
|
24 #include <e32std.h> |
|
25 |
|
26 EXPORT_C CVedVideoClipGenerator::CVedVideoClipGenerator() |
|
27 : iVideoClip(0), iIsOwnedByVideoClip(EFalse), iMaximumFramerate(KVEdMaxFrameRate) |
|
28 { |
|
29 } |
|
30 |
|
31 |
|
32 EXPORT_C CVedVideoClipGenerator::~CVedVideoClipGenerator() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 EXPORT_C TBool CVedVideoClipGenerator::IsInserted() const |
|
38 { |
|
39 return (iVideoClip != 0); |
|
40 } |
|
41 |
|
42 |
|
43 EXPORT_C CVedMovie* CVedVideoClipGenerator::Movie() const |
|
44 { |
|
45 __ASSERT_ALWAYS(iVideoClip != 0, |
|
46 TVedPanic::Panic(TVedPanic::EVideoClipGeneratorNotInserted)); |
|
47 |
|
48 return iVideoClip->Movie(); |
|
49 } |
|
50 |
|
51 |
|
52 EXPORT_C TInt CVedVideoClipGenerator::VideoClipIndex() const |
|
53 { |
|
54 __ASSERT_ALWAYS(iVideoClip != 0, |
|
55 TVedPanic::Panic(TVedPanic::EVideoClipGeneratorNotInserted)); |
|
56 |
|
57 return iVideoClip->Index(); |
|
58 } |
|
59 |
|
60 |
|
61 EXPORT_C TBool CVedVideoClipGenerator::IsOwnedByVideoClip() const |
|
62 { |
|
63 __ASSERT_ALWAYS(iVideoClip != 0, |
|
64 TVedPanic::Panic(TVedPanic::EVideoClipGeneratorNotInserted)); |
|
65 |
|
66 return iIsOwnedByVideoClip; |
|
67 } |
|
68 |
|
69 |
|
70 void CVedVideoClipGenerator::SetVideoClip(CVedVideoClip& aVideoClip, |
|
71 TBool aIsOwnedByVideoClip) |
|
72 { |
|
73 __ASSERT_ALWAYS(iVideoClip == 0, |
|
74 TVedPanic::Panic(TVedPanic::EVideoClipGeneratorAlreadyInserted)); |
|
75 |
|
76 iVideoClip = &aVideoClip; |
|
77 iIsOwnedByVideoClip = aIsOwnedByVideoClip; |
|
78 } |
|
79 |
|
80 |
|
81 EXPORT_C void CVedVideoClipGenerator::ReportDurationChanged() const |
|
82 { |
|
83 if (iVideoClip != 0) |
|
84 { |
|
85 iVideoClip->Movie()->RecalculateVideoClipTimings(iVideoClip); |
|
86 iVideoClip->Movie()->FireVideoClipTimingsChanged(iVideoClip->Movie(), iVideoClip); |
|
87 } |
|
88 } |
|
89 |
|
90 |
|
91 EXPORT_C void CVedVideoClipGenerator::ReportSettingsChanged() const |
|
92 { |
|
93 if (iVideoClip != 0) |
|
94 { |
|
95 iVideoClip->Movie()->FireVideoClipGeneratorSettingsChanged(iVideoClip->Movie(), iVideoClip); |
|
96 } |
|
97 } |
|
98 |
|
99 EXPORT_C void CVedVideoClipGenerator::ReportDescriptiveNameChanged() const |
|
100 { |
|
101 if (iVideoClip != 0) |
|
102 { |
|
103 iVideoClip->Movie()->FireVideoClipDescriptiveNameChanged(iVideoClip->Movie(), iVideoClip); |
|
104 } |
|
105 } |
|
106 |
|
107 EXPORT_C TInt CVedVideoClipGenerator::CalculateFrameComplexityFactor(CFbsBitmap* /*aFrame*/) const |
|
108 { |
|
109 RDebug::Print(_L("CVedVideoClipGenerator::CalculateFrameComplexityFactor IN")); |
|
110 |
|
111 return 10; |
|
112 |
|
113 // Disabled since the calculation takes too long and is not very accurate |
|
114 /*if ( !aFrame ) |
|
115 { |
|
116 return 0; |
|
117 } |
|
118 |
|
119 TInt height = aFrame->SizeInPixels().iHeight; |
|
120 TInt width = aFrame->SizeInPixels().iWidth; |
|
121 TInt numberOfPixels = height * width; |
|
122 |
|
123 TInt mean = 0; |
|
124 |
|
125 TInt y; |
|
126 TInt x; |
|
127 |
|
128 for (y = 0; y < height; y++) |
|
129 { |
|
130 for (x = 0; x < width; x++) |
|
131 { |
|
132 TRgb color; |
|
133 TPoint point(x, y); |
|
134 aFrame->GetPixel(color, point); |
|
135 mean += color.Green(); |
|
136 } |
|
137 } |
|
138 mean = (TInt)((TReal)mean/(TReal)numberOfPixels + 0.5); |
|
139 |
|
140 TInt moment = 0; |
|
141 TInt tmp; |
|
142 for (y = 0; y < height; y++) |
|
143 { |
|
144 for (x = 0; x < width; x++) |
|
145 { |
|
146 TRgb color; |
|
147 TPoint point(x, y); |
|
148 aFrame->GetPixel(color, point); |
|
149 tmp = color.Green() - mean; |
|
150 if (tmp<0) |
|
151 tmp = -tmp; |
|
152 moment += tmp; |
|
153 } |
|
154 } |
|
155 moment = (TInt)((TReal)moment/(TReal)numberOfPixels + 0.5); |
|
156 moment *= 10; |
|
157 |
|
158 RDebug::Print(_L("CVedVideoClipGenerator::CalculateFrameComplexityFactor returning moment: %d"), moment); |
|
159 return moment;*/ |
|
160 } |
|
161 |
|
162 // End of file |
|