1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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 */
10
11/*
12 * frame_preprocessor.h
13 */
14#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCE_FRAME_PREPROCESSOR_H
15#define WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCE_FRAME_PREPROCESSOR_H
16
17#include "webrtc/modules/video_processing/main/interface/video_processing.h"
18#include "webrtc/modules/video_processing/main/source/content_analysis.h"
19#include "webrtc/modules/video_processing/main/source/spatial_resampler.h"
20#include "webrtc/modules/video_processing/main/source/video_decimator.h"
21#include "webrtc/typedefs.h"
22
23namespace webrtc {
24
25class VPMFramePreprocessor {
26 public:
27  VPMFramePreprocessor();
28  ~VPMFramePreprocessor();
29
30  int32_t ChangeUniqueId(const int32_t id);
31
32  void Reset();
33
34  // Enable temporal decimation.
35  void EnableTemporalDecimation(bool enable);
36
37  void SetInputFrameResampleMode(VideoFrameResampling resampling_mode);
38
39  // Enable content analysis.
40  void EnableContentAnalysis(bool enable);
41
42  // Set target resolution: frame rate and dimension.
43  int32_t SetTargetResolution(uint32_t width, uint32_t height,
44                              uint32_t frame_rate);
45
46  // Update incoming frame rate/dimension.
47  void UpdateIncomingframe_rate();
48
49  int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
50
51  // Set decimated values: frame rate/dimension.
52  uint32_t Decimatedframe_rate();
53  uint32_t DecimatedWidth() const;
54  uint32_t DecimatedHeight() const;
55
56  // Preprocess output:
57  int32_t PreprocessFrame(const I420VideoFrame& frame,
58                          I420VideoFrame** processed_frame);
59  VideoContentMetrics* ContentMetrics() const;
60
61 private:
62  // The content does not change so much every frame, so to reduce complexity
63  // we can compute new content metrics every |kSkipFrameCA| frames.
64  enum { kSkipFrameCA = 2 };
65
66  int32_t id_;
67  VideoContentMetrics* content_metrics_;
68  I420VideoFrame resampled_frame_;
69  VPMSpatialResampler* spatial_resampler_;
70  VPMContentAnalysis* ca_;
71  VPMVideoDecimator* vd_;
72  bool enable_ca_;
73  int frame_cnt_;
74
75};
76
77}  // namespace webrtc
78
79#endif // WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCE_FRAME_PREPROCESSOR_H
80