niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | * deflickering.h |
| 13 | */ |
| 14 | |
| 15 | #ifndef VPM_DEFLICKERING_H |
| 16 | #define VPM_DEFLICKERING_H |
| 17 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame^] | 18 | #include <string.h> // NULL |
| 19 | |
pbos@webrtc.org | 6f3d8fc | 2013-05-27 14:12:16 +0000 | [diff] [blame] | 20 | #include "webrtc/modules/video_processing/main/interface/video_processing.h" |
| 21 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | namespace webrtc { |
| 24 | |
| 25 | class VPMDeflickering |
| 26 | { |
| 27 | public: |
| 28 | VPMDeflickering(); |
| 29 | ~VPMDeflickering(); |
| 30 | |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 31 | int32_t ChangeUniqueId(int32_t id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
| 33 | void Reset(); |
| 34 | |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 35 | int32_t ProcessFrame(I420VideoFrame* frame, |
| 36 | VideoProcessingModule::FrameStats* stats); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | private: |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 38 | int32_t PreDetection(uint32_t timestamp, |
| 39 | const VideoProcessingModule::FrameStats& stats); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 41 | int32_t DetectFlicker(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
| 43 | enum { kMeanBufferLength = 32 }; |
| 44 | enum { kFrameHistorySize = 15 }; |
| 45 | enum { kNumProbs = 12 }; |
| 46 | enum { kNumQuants = kNumProbs + 2 }; |
| 47 | enum { kMaxOnlyLength = 5 }; |
| 48 | |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 49 | int32_t _id; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 51 | uint32_t _meanBufferLength; |
| 52 | uint8_t _detectionState; // 0: No flickering |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | // 1: Flickering detected |
| 54 | // 2: In flickering |
pbos@webrtc.org | 1ab45f6 | 2013-04-09 13:38:10 +0000 | [diff] [blame] | 55 | int32_t _meanBuffer[kMeanBufferLength]; |
| 56 | uint32_t _timestampBuffer[kMeanBufferLength]; |
| 57 | uint32_t _frameRate; |
| 58 | static const uint16_t _probUW16[kNumProbs]; |
| 59 | static const uint16_t _weightUW16[kNumQuants - kMaxOnlyLength]; |
| 60 | uint8_t _quantHistUW8[kFrameHistorySize][kNumQuants]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 63 | } // namespace |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
| 65 | #endif // VPM_DEFLICKERING_H |