blob: 86f75bf239d9254722b5b67862922157ec9c472c [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
xians@webrtc.org9a798d32012-02-20 09:00:35 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 */
mflodmana8565422015-12-07 01:09:52 -080010
Henrik Kjellander0f59a882015-11-18 22:31:24 +010011#include "webrtc/modules/video_processing/video_processing_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000013#include <assert.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000014
mflodmana8565422015-12-07 01:09:52 -080015#include "webrtc/base/checks.h"
16#include "webrtc/base/logging.h"
17#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
18
niklase@google.com470e71d2011-07-07 08:21:25 +000019namespace webrtc {
20
mflodmana8565422015-12-07 01:09:52 -080021VideoProcessing* VideoProcessing::Create() {
22 return new VideoProcessingImpl();
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000023}
24
mflodmana8565422015-12-07 01:09:52 -080025VideoProcessingImpl::VideoProcessingImpl() {}
26VideoProcessingImpl::~VideoProcessingImpl() {}
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000027
mflodmana8565422015-12-07 01:09:52 -080028void VideoProcessingImpl::EnableTemporalDecimation(bool enable) {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020029 rtc::CritScope mutex(&mutex_);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000030 frame_pre_processor_.EnableTemporalDecimation(enable);
31}
32
mflodman99ab9442015-12-07 22:54:50 -080033void VideoProcessingImpl::SetInputFrameResampleMode(
34 VideoFrameResampling resampling_mode) {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020035 rtc::CritScope cs(&mutex_);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000036 frame_pre_processor_.SetInputFrameResampleMode(resampling_mode);
37}
38
mflodmana8565422015-12-07 01:09:52 -080039int32_t VideoProcessingImpl::SetTargetResolution(uint32_t width,
40 uint32_t height,
41 uint32_t frame_rate) {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020042 rtc::CritScope cs(&mutex_);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000043 return frame_pre_processor_.SetTargetResolution(width, height, frame_rate);
44}
45
mflodmana8565422015-12-07 01:09:52 -080046uint32_t VideoProcessingImpl::GetDecimatedFrameRate() {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020047 rtc::CritScope cs(&mutex_);
mflodman99ab9442015-12-07 22:54:50 -080048 return frame_pre_processor_.GetDecimatedFrameRate();
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000049}
50
mflodmana8565422015-12-07 01:09:52 -080051uint32_t VideoProcessingImpl::GetDecimatedWidth() const {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020052 rtc::CritScope cs(&mutex_);
mflodmana8565422015-12-07 01:09:52 -080053 return frame_pre_processor_.GetDecimatedWidth();
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000054}
55
mflodmana8565422015-12-07 01:09:52 -080056uint32_t VideoProcessingImpl::GetDecimatedHeight() const {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020057 rtc::CritScope cs(&mutex_);
mflodmana8565422015-12-07 01:09:52 -080058 return frame_pre_processor_.GetDecimatedHeight();
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000059}
60
nisse90c335a2016-04-27 00:59:22 -070061void VideoProcessingImpl::EnableDenoising(bool enable) {
mflodmana8565422015-12-07 01:09:52 -080062 rtc::CritScope cs(&mutex_);
nisse90c335a2016-04-27 00:59:22 -070063 frame_pre_processor_.EnableDenoising(enable);
mflodmana8565422015-12-07 01:09:52 -080064}
65
66const VideoFrame* VideoProcessingImpl::PreprocessFrame(
67 const VideoFrame& frame) {
Peter Boströmf4aa4c22015-09-18 12:24:25 +020068 rtc::CritScope mutex(&mutex_);
mflodmana8565422015-12-07 01:09:52 -080069 return frame_pre_processor_.PreprocessFrame(frame);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000070}
71
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000072} // namespace webrtc