summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/camera/dscamerasession.cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-12-08 21:58:16 +0300
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-12-10 13:12:55 +0000
commitfcb511b6d6985820e0c049e6bd0f25e8715e9e3f (patch)
treefae5e7f4123a276eac90a5ce322636bfd5b66460 /src/plugins/directshow/camera/dscamerasession.cpp
parent5becd7c1a9786acd80f0cb7d4a7b837442cd8836 (diff)
DirectShow: Get current image processing parameter from the cache
We can simplify a code, do not need to call pVideoProcAmp->Get() each time when we want to get current parameter value. It is better to do this once from updateImageProcessingParametersInfos(). In this case we will return desired parameter from the local cache. Change-Id: If33c3882230c9ae817071ace5b792dfe31685a7f Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/plugins/directshow/camera/dscamerasession.cpp')
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp56
1 files changed, 17 insertions, 39 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index e0261e035..2e92cb37d 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -231,16 +231,16 @@ void DSCameraSession::setViewfinderSettings(const QCameraViewfinderSettings &set
}
qreal DSCameraSession::scaledImageProcessingParameterValue(
- qint32 sourceValue, const ImageProcessingParameterInfo &sourceValueInfo)
+ const ImageProcessingParameterInfo &sourceValueInfo)
{
- if (sourceValue == sourceValueInfo.defaultValue) {
+ if (sourceValueInfo.currentValue == sourceValueInfo.defaultValue) {
return 0.0f;
- } else if (sourceValue < sourceValueInfo.defaultValue) {
- return ((sourceValue - sourceValueInfo.minimumValue)
+ } else if (sourceValueInfo.currentValue < sourceValueInfo.defaultValue) {
+ return ((sourceValueInfo.currentValue - sourceValueInfo.minimumValue)
/ qreal(sourceValueInfo.defaultValue - sourceValueInfo.minimumValue))
+ (-1.0f);
} else {
- return ((sourceValue - sourceValueInfo.defaultValue)
+ return ((sourceValueInfo.currentValue - sourceValueInfo.defaultValue)
/ qreal(sourceValueInfo.maximumValue - sourceValueInfo.defaultValue));
}
}
@@ -349,52 +349,22 @@ QVariant DSCameraSession::imageProcessingParameter(
if (sourceValueInfo == m_imageProcessingParametersInfos.constEnd())
return QVariant();
- IAMVideoProcAmp *pVideoProcAmp = NULL;
- HRESULT hr = m_graphBuilder->FindInterface(
- NULL,
- NULL,
- m_sourceFilter,
- IID_IAMVideoProcAmp,
- reinterpret_cast<void**>(&pVideoProcAmp)
- );
-
- if (FAILED(hr) || !pVideoProcAmp) {
- qWarning() << "failed to find the video proc amp";
- return QVariant();
- }
-
- LONG sourceValue = 0;
- LONG capsFlags = 0;
-
- hr = pVideoProcAmp->Get(
- (*sourceValueInfo).videoProcAmpProperty,
- &sourceValue,
- &capsFlags);
-
- pVideoProcAmp->Release();
-
- if (FAILED(hr)) {
- qWarning() << "failed to get the parameter value";
- return QVariant();
- }
-
switch (parameter) {
case QCameraImageProcessingControl::WhiteBalancePreset:
return QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(
- capsFlags == VideoProcAmp_Flags_Auto
+ (*sourceValueInfo).capsFlags == VideoProcAmp_Flags_Auto
? QCameraImageProcessing::WhiteBalanceAuto
: QCameraImageProcessing::WhiteBalanceManual);
case QCameraImageProcessingControl::ColorTemperature:
- return QVariant::fromValue<qint32>(sourceValue);
+ return QVariant::fromValue<qint32>((*sourceValueInfo).currentValue);
case QCameraImageProcessingControl::ContrastAdjustment: // falling back
case QCameraImageProcessingControl::SaturationAdjustment: // falling back
case QCameraImageProcessingControl::BrightnessAdjustment: // falling back
case QCameraImageProcessingControl::SharpeningAdjustment:
- return scaledImageProcessingParameterValue(
- sourceValue, (*sourceValueInfo));
+ return scaledImageProcessingParameterValue((*sourceValueInfo));
default:
return QVariant();
@@ -1032,7 +1002,7 @@ void DSCameraSession::updateImageProcessingParametersInfos()
ImageProcessingParameterInfo sourceValueInfo;
LONG steppingDelta = 0;
- const HRESULT hr = pVideoProcAmp->GetRange(
+ HRESULT hr = pVideoProcAmp->GetRange(
property,
&sourceValueInfo.minimumValue,
&sourceValueInfo.maximumValue,
@@ -1043,6 +1013,14 @@ void DSCameraSession::updateImageProcessingParametersInfos()
if (FAILED(hr))
continue;
+ hr = pVideoProcAmp->Get(
+ property,
+ &sourceValueInfo.currentValue,
+ &sourceValueInfo.capsFlags);
+
+ if (FAILED(hr))
+ continue;
+
sourceValueInfo.videoProcAmpProperty = static_cast<VideoProcAmpProperty>(property);
m_imageProcessingParametersInfos.insert(processingParameter, sourceValueInfo);