blob: dfe7d9d19c5538d7bf671fda8bd0dcd8e26a0120 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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
18#include "typedefs.h"
19#include "video_processing.h"
20
21#include <cstring> // NULL
22
23namespace webrtc {
24
25class VPMDeflickering
26{
27public:
28 VPMDeflickering();
29 ~VPMDeflickering();
30
31 WebRtc_Word32 ChangeUniqueId(WebRtc_Word32 id);
32
33 void Reset();
34
mikhal@webrtc.org0e196e12012-10-19 15:43:31 +000035 WebRtc_Word32 ProcessFrame(VideoFrame* frame,
36 VideoProcessingModule::FrameStats* stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000037private:
38 WebRtc_Word32 PreDetection(WebRtc_UWord32 timestamp,
mikhal@webrtc.org0e196e12012-10-19 15:43:31 +000039 const VideoProcessingModule::FrameStats& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 WebRtc_Word32 DetectFlicker();
42
43 enum { kMeanBufferLength = 32 };
44 enum { kFrameHistorySize = 15 };
45 enum { kNumProbs = 12 };
46 enum { kNumQuants = kNumProbs + 2 };
47 enum { kMaxOnlyLength = 5 };
48
49 WebRtc_Word32 _id;
50
51 WebRtc_UWord32 _meanBufferLength;
52 WebRtc_UWord8 _detectionState; // 0: No flickering
53 // 1: Flickering detected
54 // 2: In flickering
55 WebRtc_Word32 _meanBuffer[kMeanBufferLength];
56 WebRtc_UWord32 _timestampBuffer[kMeanBufferLength];
57 WebRtc_UWord32 _frameRate;
58 static const WebRtc_UWord16 _probUW16[kNumProbs];
59 static const WebRtc_UWord16 _weightUW16[kNumQuants - kMaxOnlyLength];
60 WebRtc_UWord8 _quantHistUW8[kFrameHistorySize][kNumQuants];
61};
62
63} //namespace
64
65#endif // VPM_DEFLICKERING_H
66