Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: media/video/capture/win/video_capture_device_win.cc

Issue 220193006: Win DirectShow: connect antibanding/anti-flicker where supported. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tommi@s nits Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/win/video_capture_device_win.cc
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index 2afb96860177ea648017597a2ce05ee34c0a5316..f56646b3264b595905da6ca8717a4302574d87d4 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -4,6 +4,9 @@
#include "media/video/capture/win/video_capture_device_win.h"
+#include <ks.h>
+#include <ksmedia.h>
+
#include <algorithm>
#include <list>
@@ -591,6 +594,8 @@ void VideoCaptureDeviceWin::AllocateAndStart(
}
}
+ SetAntiFlickerInCaptureFilter();
+
if (format.pixel_format == PIXEL_FORMAT_MJPEG && mjpg_filter_.get()) {
// Connect the camera to the MJPEG decoder.
hr = graph_builder_->ConnectDirect(output_capture_pin_, input_mjpg_pin_,
@@ -749,6 +754,36 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() {
return !capabilities_.empty();
}
+// Set the power line frequency removal in |capture_filter_| if available.
+void VideoCaptureDeviceWin::SetAntiFlickerInCaptureFilter() {
+ const int power_line_frequency = GetPowerLineFrequencyForLocation();
+ if (power_line_frequency != kPowerLine50Hz &&
+ power_line_frequency != kPowerLine60Hz) {
+ return;
+ }
+ ScopedComPtr<IKsPropertySet> ks_propset;
+ DWORD type_support = 0;
+ HRESULT hr;
+ if (SUCCEEDED(hr = ks_propset.QueryFrom(capture_filter_)) &&
+ SUCCEEDED(hr = ks_propset->QuerySupported(PROPSETID_VIDCAP_VIDEOPROCAMP,
+ KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY, &type_support)) &&
+ (type_support & KSPROPERTY_SUPPORT_SET)) {
+ KSPROPERTY_VIDEOPROCAMP_S data = {};
+ data.Property.Set = PROPSETID_VIDCAP_VIDEOPROCAMP;
+ data.Property.Id = KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY;
+ data.Property.Flags = KSPROPERTY_TYPE_SET;
+ data.Value = (power_line_frequency == kPowerLine50Hz) ? 1 : 2;
+ data.Flags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
+ hr = ks_propset->Set(PROPSETID_VIDCAP_VIDEOPROCAMP,
+ KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY,
+ &data, sizeof(data), &data, sizeof(data));
+ DVLOG_IF(ERROR, FAILED(hr)) << "Anti-flicker setting failed.";
+ DVLOG_IF(2, SUCCEEDED(hr)) << "Anti-flicker set correctly.";
+ } else {
+ DVLOG(2) << "Anti-flicker setting not supported.";
+ }
+}
+
void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) {
DCHECK(CalledOnValidThread());
DVLOG(1) << reason;
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698