OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // concurrently processed stream. Similarly, it is recommended to call Reset() | 21 // concurrently processed stream. Similarly, it is recommended to call Reset() |
22 // before switching to a new stream, but this is not absolutely required. | 22 // before switching to a new stream, but this is not absolutely required. |
23 // | 23 // |
24 // The module provides basic thread safety by permitting only a single function | 24 // The module provides basic thread safety by permitting only a single function |
25 // to execute concurrently. | 25 // to execute concurrently. |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 | 28 |
29 class VideoProcessing { | 29 class VideoProcessing { |
30 public: | 30 public: |
31 struct FrameStats { | |
32 uint32_t hist[256]; // Frame histogram. | |
33 uint32_t mean; | |
34 uint32_t sum; | |
35 uint32_t num_pixels; | |
36 uint32_t sub_sampling_factor; // Sub-sampling factor, in powers of 2. | |
37 }; | |
38 | |
39 enum BrightnessWarning { kNoWarning, kDarkWarning, kBrightWarning }; | |
40 | |
41 static VideoProcessing* Create(); | 31 static VideoProcessing* Create(); |
42 virtual ~VideoProcessing() {} | 32 virtual ~VideoProcessing() {} |
43 | 33 |
44 // Retrieves statistics for the input frame. This function must be used to | |
45 // prepare a FrameStats struct for use in certain VPM functions. | |
46 static void GetFrameStats(const VideoFrame& frame, FrameStats* stats); | |
47 | |
48 // Checks the validity of a FrameStats struct. Currently, valid implies only | |
49 // that is had changed from its initialized state. | |
50 static bool ValidFrameStats(const FrameStats& stats); | |
51 | |
52 static void ClearFrameStats(FrameStats* stats); | |
53 | |
54 // Increases/decreases the luminance value. 'delta' can be in the range {} | |
55 static void Brighten(int delta, VideoFrame* frame); | |
56 | |
57 // Detects and removes camera flicker from a video stream. Every frame from | |
58 // the stream must be passed in. A frame will only be altered if flicker has | |
59 // been detected. Has a fixed-point implementation. | |
60 // Frame statistics provided by GetFrameStats(). On return the stats will | |
61 // be reset to zero if the frame was altered. Call GetFrameStats() again | |
62 // if the statistics for the altered frame are required. | |
63 virtual int32_t Deflickering(VideoFrame* frame, FrameStats* stats) = 0; | |
64 | |
65 // Detects if a video frame is excessively bright or dark. Returns a | |
66 // warning if this is the case. Multiple frames should be passed in before | |
67 // expecting a warning. Has a floating-point implementation. | |
68 virtual int32_t BrightnessDetection(const VideoFrame& frame, | |
69 const FrameStats& stats) = 0; | |
70 | |
71 // The following functions refer to the pre-processor unit within VPM. The | 34 // The following functions refer to the pre-processor unit within VPM. The |
72 // pre-processor perfoms spatial/temporal decimation and content analysis on | 35 // pre-processor perfoms spatial/temporal decimation and content analysis on |
73 // the frames prior to encoding. | 36 // the frames prior to encoding. |
74 | 37 |
75 // Enable/disable temporal decimation | 38 // Enable/disable temporal decimation |
76 virtual void EnableTemporalDecimation(bool enable) = 0; | 39 virtual void EnableTemporalDecimation(bool enable) = 0; |
77 | 40 |
78 virtual int32_t SetTargetResolution(uint32_t width, | 41 virtual int32_t SetTargetResolution(uint32_t width, |
79 uint32_t height, | 42 uint32_t height, |
80 uint32_t frame_rate) = 0; | 43 uint32_t frame_rate) = 0; |
81 | 44 |
82 virtual void SetTargetFramerate(int frame_rate) = 0; | 45 virtual void SetTargetFramerate(int frame_rate) = 0; |
83 | 46 |
84 virtual uint32_t GetDecimatedFrameRate() = 0; | 47 virtual uint32_t GetDecimatedFrameRate() = 0; |
85 virtual uint32_t GetDecimatedWidth() const = 0; | 48 virtual uint32_t GetDecimatedWidth() const = 0; |
86 virtual uint32_t GetDecimatedHeight() const = 0; | 49 virtual uint32_t GetDecimatedHeight() const = 0; |
87 | 50 |
88 // Set the spatial resampling settings of the VPM according to | 51 // Set the spatial resampling settings of the VPM according to |
89 // VideoFrameResampling. | 52 // VideoFrameResampling. |
90 virtual void SetInputFrameResampleMode( | 53 virtual void SetInputFrameResampleMode( |
91 VideoFrameResampling resampling_mode) = 0; | 54 VideoFrameResampling resampling_mode) = 0; |
92 | 55 |
93 virtual void EnableDenosing(bool enable) = 0; | 56 virtual void EnableDenoising(bool enable) = 0; |
94 virtual const VideoFrame* PreprocessFrame(const VideoFrame& frame) = 0; | 57 virtual const VideoFrame* PreprocessFrame(const VideoFrame& frame) = 0; |
95 | 58 |
96 virtual VideoContentMetrics* GetContentMetrics() const = 0; | 59 virtual VideoContentMetrics* GetContentMetrics() const = 0; |
97 virtual void EnableContentAnalysis(bool enable) = 0; | 60 virtual void EnableContentAnalysis(bool enable) = 0; |
98 }; | 61 }; |
99 | 62 |
100 } // namespace webrtc | 63 } // namespace webrtc |
101 | 64 |
102 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_INCLUDE_VIDEO_PROCESSING_H_ | 65 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_INCLUDE_VIDEO_PROCESSING_H_ |
OLD | NEW |