niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
xians@webrtc.org | 9a798d3 | 2012-02-20 09:00:35 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 10 | |
Henrik Kjellander | 0f59a88 | 2015-11-18 22:31:24 +0100 | [diff] [blame] | 11 | #include "webrtc/modules/video_processing/video_processing_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 13 | #include <assert.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 15 | #include "webrtc/base/checks.h" |
| 16 | #include "webrtc/base/logging.h" |
| 17 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 18 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | namespace webrtc { |
| 20 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 21 | VideoProcessing* VideoProcessing::Create() { |
| 22 | return new VideoProcessingImpl(); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 23 | } |
| 24 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 25 | VideoProcessingImpl::VideoProcessingImpl() {} |
| 26 | VideoProcessingImpl::~VideoProcessingImpl() {} |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 27 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 28 | void VideoProcessingImpl::EnableTemporalDecimation(bool enable) { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 29 | rtc::CritScope mutex(&mutex_); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 30 | frame_pre_processor_.EnableTemporalDecimation(enable); |
| 31 | } |
| 32 | |
mflodman | 99ab944 | 2015-12-07 22:54:50 -0800 | [diff] [blame] | 33 | void VideoProcessingImpl::SetInputFrameResampleMode( |
| 34 | VideoFrameResampling resampling_mode) { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 35 | rtc::CritScope cs(&mutex_); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 36 | frame_pre_processor_.SetInputFrameResampleMode(resampling_mode); |
| 37 | } |
| 38 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 39 | int32_t VideoProcessingImpl::SetTargetResolution(uint32_t width, |
| 40 | uint32_t height, |
| 41 | uint32_t frame_rate) { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 42 | rtc::CritScope cs(&mutex_); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 43 | return frame_pre_processor_.SetTargetResolution(width, height, frame_rate); |
| 44 | } |
| 45 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 46 | uint32_t VideoProcessingImpl::GetDecimatedFrameRate() { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 47 | rtc::CritScope cs(&mutex_); |
mflodman | 99ab944 | 2015-12-07 22:54:50 -0800 | [diff] [blame] | 48 | return frame_pre_processor_.GetDecimatedFrameRate(); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 49 | } |
| 50 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 51 | uint32_t VideoProcessingImpl::GetDecimatedWidth() const { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 52 | rtc::CritScope cs(&mutex_); |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 53 | return frame_pre_processor_.GetDecimatedWidth(); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 54 | } |
| 55 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 56 | uint32_t VideoProcessingImpl::GetDecimatedHeight() const { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 57 | rtc::CritScope cs(&mutex_); |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 58 | return frame_pre_processor_.GetDecimatedHeight(); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 59 | } |
| 60 | |
nisse | 90c335a | 2016-04-27 00:59:22 -0700 | [diff] [blame] | 61 | void VideoProcessingImpl::EnableDenoising(bool enable) { |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 62 | rtc::CritScope cs(&mutex_); |
nisse | 90c335a | 2016-04-27 00:59:22 -0700 | [diff] [blame] | 63 | frame_pre_processor_.EnableDenoising(enable); |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | const VideoFrame* VideoProcessingImpl::PreprocessFrame( |
| 67 | const VideoFrame& frame) { |
Peter Boström | f4aa4c2 | 2015-09-18 12:24:25 +0200 | [diff] [blame] | 68 | rtc::CritScope mutex(&mutex_); |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 69 | return frame_pre_processor_.PreprocessFrame(frame); |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 70 | } |
| 71 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 72 | } // namespace webrtc |