equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009, Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
18 */ |
18 */ |
19 |
19 |
20 #include <algorithm> |
20 #include <algorithm> |
21 #include <e32std.h> // For Symbian types used in mmsenginedomaincrkeys.h |
21 #include <e32std.h> // For Symbian types used in mmsenginedomaincrkeys.h |
22 #include <MmsEngineDomainCRKeys.h> |
22 #include <MmsEngineDomainCRKeys.h> |
|
23 #include <imagingconfigmanager.h> |
23 |
24 |
24 #include "cxutils.h" |
25 #include "cxutils.h" |
25 #include "cxenamespace.h" |
26 #include "cxenamespace.h" |
26 #include "cxesettings.h" |
27 #include "cxesettings.h" |
27 #include "cxequalitydetails.h" |
28 #include "cxequalitydetails.h" |
62 */ |
63 */ |
63 CxeQualityPresetsSymbian::CxeQualityPresetsSymbian(CxeSettings &settings) |
64 CxeQualityPresetsSymbian::CxeQualityPresetsSymbian(CxeSettings &settings) |
64 : mSettings(settings) |
65 : mSettings(settings) |
65 { |
66 { |
66 CX_DEBUG_ENTER_FUNCTION(); |
67 CX_DEBUG_ENTER_FUNCTION(); |
|
68 OstTrace0(camerax_performance, CXEQUALITYPRESETSSYMBIAN_1, "msg: e_CX_QUALITYPRESETS_NEW 1"); |
67 |
69 |
68 TRAPD(err, mIcm = CImagingConfigManager::NewL()); |
70 TRAPD(err, mIcm = CImagingConfigManager::NewL()); |
69 |
71 |
70 if (err) { |
72 if (err) { |
71 CX_DEBUG(("Error during ICM initialization error code = %d", err)); |
73 CX_DEBUG(("Error during ICM initialization error code = %d", err)); |
72 mIcm = NULL; |
74 mIcm = NULL; |
73 } |
75 } |
74 |
76 |
75 CX_DEBUG_EXIT_FUNCTION(); |
77 OstTrace0(camerax_performance, CXEQUALITYPRESETSSYMBIAN_2, "msg: e_CX_QUALITYPRESETS_NEW 0"); |
76 |
78 CX_DEBUG_EXIT_FUNCTION(); |
77 } |
79 } |
78 |
80 |
79 /* ! |
81 /* ! |
80 * CxeQualityPresetsSymbian::~CxeQualityPresetsSymbian() |
82 * CxeQualityPresetsSymbian::~CxeQualityPresetsSymbian() |
81 */ |
83 */ |
219 /*! |
221 /*! |
220 * Creates a new image preset based on TImageQualitySet values from ICM. |
222 * Creates a new image preset based on TImageQualitySet values from ICM. |
221 @ param set contains the ICM configuration data |
223 @ param set contains the ICM configuration data |
222 @ returns CxeImageQuality struct |
224 @ returns CxeImageQuality struct |
223 */ |
225 */ |
224 CxeImageDetails CxeQualityPresetsSymbian::createImagePreset(TImageQualitySet set) |
226 CxeImageDetails CxeQualityPresetsSymbian::createImagePreset(const TImageQualitySet &set) |
225 { |
227 { |
226 CxeImageDetails newPreset; |
228 CxeImageDetails newPreset; |
227 // set setting values from quality set |
229 // set setting values from quality set |
228 newPreset.mWidth = set.iImageWidth; |
230 newPreset.mWidth = set.iImageWidth; |
229 newPreset.mHeight = set.iImageHeight; |
231 newPreset.mHeight = set.iImageHeight; |
241 |
243 |
242 |
244 |
243 /*! |
245 /*! |
244 * Creates a new video preset based on TVideoQualitySet values from ICM. |
246 * Creates a new video preset based on TVideoQualitySet values from ICM. |
245 */ |
247 */ |
246 CxeVideoDetails CxeQualityPresetsSymbian::createVideoPreset(TVideoQualitySet set) |
248 CxeVideoDetails CxeQualityPresetsSymbian::createVideoPreset(const TVideoQualitySet &set) |
247 { |
249 { |
248 CX_DEBUG_ENTER_FUNCTION(); |
250 CX_DEBUG_ENTER_FUNCTION(); |
249 CxeVideoDetails newPreset; |
251 CxeVideoDetails newPreset; |
250 // set setting values from quality set |
252 // set setting values from quality set |
251 newPreset.mWidth = set.iVideoWidth; |
253 newPreset.mWidth = set.iVideoWidth; |
309 |
311 |
310 // calculate delta error for the resolution against supported aspect ratio's |
312 // calculate delta error for the resolution against supported aspect ratio's |
311 int delta16by9 = abs((width * ASPECT_RATIO_SIZE_16BY9.height()) - (height * ASPECT_RATIO_SIZE_16BY9.width())); |
313 int delta16by9 = abs((width * ASPECT_RATIO_SIZE_16BY9.height()) - (height * ASPECT_RATIO_SIZE_16BY9.width())); |
312 int delta11by9 = abs((width * ASPECT_RATIO_SIZE_11BY9.height()) - (height * ASPECT_RATIO_SIZE_11BY9.width())); |
314 int delta11by9 = abs((width * ASPECT_RATIO_SIZE_11BY9.height()) - (height * ASPECT_RATIO_SIZE_11BY9.width())); |
313 int delta4by3 = abs((width * ASPECT_RATIO_SIZE_4BY3.height()) - (height * ASPECT_RATIO_SIZE_4BY3.width())); |
315 int delta4by3 = abs((width * ASPECT_RATIO_SIZE_4BY3.height()) - (height * ASPECT_RATIO_SIZE_4BY3.width())); |
314 |
316 |
315 // get the closest aspect ratio |
317 // get the closest aspect ratio |
316 int minValue = qMin(qMin(delta16by9, delta11by9), delta4by3); |
318 int minValue = qMin(qMin(delta16by9, delta11by9), delta4by3); |
317 |
319 |
318 if (minValue == delta16by9) { |
320 if (minValue == delta16by9) { |
319 aspectRatio = Cxe::AspectRatio16to9; |
321 aspectRatio = Cxe::AspectRatio16to9; |
320 } else if (minValue == delta11by9) { |
322 } else if (minValue == delta11by9) { |
321 aspectRatio = Cxe::AspectRatio11to9; |
323 aspectRatio = Cxe::AspectRatio11to9; |
322 } else if (minValue == delta4by3) { |
324 } else if (minValue == delta4by3) { |
381 if (scaler == 0) { |
383 if (scaler == 0) { |
382 // video bit rate scaler is 0, use the constant value |
384 // video bit rate scaler is 0, use the constant value |
383 scaler = VIDEO_AVG_BITRATE_SCALER; |
385 scaler = VIDEO_AVG_BITRATE_SCALER; |
384 } |
386 } |
385 |
387 |
386 int muteSetting = 0; // audio enabled |
388 bool muteSetting = mSettings.get<bool>(CxeSettingIds::VIDEO_MUTE_SETTING, false); // false = audio enabled |
387 mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); |
|
388 |
389 |
389 int avgVideoBitRate = (details.mVideoBitRate * scaler); |
390 int avgVideoBitRate = (details.mVideoBitRate * scaler); |
390 int avgAudioBitRate = (muteSetting == 1) ? 0 : details.mAudioBitRate; |
391 int avgAudioBitRate = muteSetting ? 0 : details.mAudioBitRate; |
391 |
392 |
392 quint32 averageBitRate = (quint32)((avgVideoBitRate + avgAudioBitRate) * VIDEO_METADATA_COEFF); |
393 quint32 averageBitRate = (quint32)((avgVideoBitRate + avgAudioBitRate) * VIDEO_METADATA_COEFF); |
393 quint32 averageByteRate = averageBitRate / 8; |
394 quint32 averageByteRate = averageBitRate / 8; |
394 |
395 |
395 // 0 <= Remaining time <= KCamCMaxClipDurationInSecs |
396 // 0 <= Remaining time <= KCamCMaxClipDurationInSecs |
434 |
435 |
435 /*! |
436 /*! |
436 * Helper method to enable debug prints. |
437 * Helper method to enable debug prints. |
437 @ param Video quality preset values are printed out for debugging |
438 @ param Video quality preset values are printed out for debugging |
438 */ |
439 */ |
439 void CxeQualityPresetsSymbian::debugPrints(CxeVideoDetails preset) |
440 void CxeQualityPresetsSymbian::debugPrints(const CxeVideoDetails &preset) |
440 { |
441 { |
441 CX_DEBUG(("Video quality details")); |
442 CX_DEBUG(("Video quality details")); |
442 CX_DEBUG(("Video resolution (%d,%d)", preset.mWidth, preset.mHeight)); |
443 CX_DEBUG(("Video resolution (%d,%d)", preset.mWidth, preset.mHeight)); |
443 CX_DEBUG(("Audio bitrate = %d)", preset.mAudioBitRate)); |
444 CX_DEBUG(("Audio bitrate = %d)", preset.mAudioBitRate)); |
444 CX_DEBUG(("Video bitrate = %d)", preset.mVideoBitRate)); |
445 CX_DEBUG(("Video bitrate = %d)", preset.mVideoBitRate)); |
459 |
460 |
460 /*! |
461 /*! |
461 * Helper method to enable debug prints. |
462 * Helper method to enable debug prints. |
462 @ param Image quality preset values are printed out for debugging |
463 @ param Image quality preset values are printed out for debugging |
463 */ |
464 */ |
464 void CxeQualityPresetsSymbian::debugPrints(CxeImageDetails newPreset) |
465 void CxeQualityPresetsSymbian::debugPrints(const CxeImageDetails &newPreset) |
465 { |
466 { |
466 CX_DEBUG(("Image quality details")); |
467 CX_DEBUG(("Image quality details")); |
467 CX_DEBUG(("Image resolution (%d,%d)", newPreset.mWidth, newPreset.mHeight)); |
468 CX_DEBUG(("Image resolution (%d,%d)", newPreset.mWidth, newPreset.mHeight)); |
468 CX_DEBUG(("Estimated size in bytes = %d)", newPreset.mEstimatedSize)); |
469 CX_DEBUG(("Estimated size in bytes = %d)", newPreset.mEstimatedSize)); |
469 CX_DEBUG(("Megapixels: %s", newPreset.mMpxCount.toAscii().data())); |
470 CX_DEBUG(("Megapixels: %s", newPreset.mMpxCount.toAscii().data())); |