blob: c5313b406680b6768d374ce849909ed9830028df [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +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 */
10
11/*
12 * frame_preprocessor.h
13 */
Henrik Kjellander0f59a882015-11-18 22:31:24 +010014#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
15#define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000016
Henrik Kjellander0f59a882015-11-18 22:31:24 +010017#include "webrtc/modules/video_processing/include/video_processing.h"
18#include "webrtc/modules/video_processing/content_analysis.h"
19#include "webrtc/modules/video_processing/spatial_resampler.h"
20#include "webrtc/modules/video_processing/video_decimator.h"
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000021#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
24
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000025class VPMFramePreprocessor {
26 public:
27 VPMFramePreprocessor();
28 ~VPMFramePreprocessor();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000030 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000031
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000032 // Enable temporal decimation.
33 void EnableTemporalDecimation(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000035 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000037 // Enable content analysis.
38 void EnableContentAnalysis(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000040 // Set target resolution: frame rate and dimension.
41 int32_t SetTargetResolution(uint32_t width, uint32_t height,
42 uint32_t frame_rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
jackychen6e2ce6e2015-07-13 16:26:33 -070044 // Set target frame rate.
45 void SetTargetFramerate(int frame_rate);
46
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000047 // Update incoming frame rate/dimension.
48 void UpdateIncomingframe_rate();
niklase@google.com470e71d2011-07-07 08:21:25 +000049
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000050 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000051
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000052 // Set decimated values: frame rate/dimension.
53 uint32_t Decimatedframe_rate();
54 uint32_t DecimatedWidth() const;
55 uint32_t DecimatedHeight() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000057 // Preprocess output:
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070058 int32_t PreprocessFrame(const VideoFrame& frame,
59 VideoFrame** processed_frame);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000060 VideoContentMetrics* ContentMetrics() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000061
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000062 private:
63 // The content does not change so much every frame, so to reduce complexity
64 // we can compute new content metrics every |kSkipFrameCA| frames.
65 enum { kSkipFrameCA = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000066
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000067 VideoContentMetrics* content_metrics_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070068 VideoFrame resampled_frame_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000069 VPMSpatialResampler* spatial_resampler_;
70 VPMContentAnalysis* ca_;
71 VPMVideoDecimator* vd_;
72 bool enable_ca_;
73 int frame_cnt_;
niklase@google.com470e71d2011-07-07 08:21:25 +000074
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000075};
niklase@google.com470e71d2011-07-07 08:21:25 +000076
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000077} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000078
Henrik Kjellander0f59a882015-11-18 22:31:24 +010079#endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_