blob: d3f8139bef79c801e78c76e4bb8882fff5f4fb56 [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
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000018#include <string.h> // NULL
19
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000020#include "webrtc/modules/video_processing/main/interface/video_processing.h"
21#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
niklase@google.com470e71d2011-07-07 08:21:25 +000023namespace webrtc {
24
25class VPMDeflickering
26{
27public:
28 VPMDeflickering();
29 ~VPMDeflickering();
30
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000031 int32_t ChangeUniqueId(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
33 void Reset();
34
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000035 int32_t ProcessFrame(I420VideoFrame* frame,
36 VideoProcessingModule::FrameStats* stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000037private:
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000038 int32_t PreDetection(uint32_t timestamp,
39 const VideoProcessingModule::FrameStats& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000041 int32_t DetectFlicker();
niklase@google.com470e71d2011-07-07 08:21:25 +000042
43 enum { kMeanBufferLength = 32 };
44 enum { kFrameHistorySize = 15 };
45 enum { kNumProbs = 12 };
46 enum { kNumQuants = kNumProbs + 2 };
47 enum { kMaxOnlyLength = 5 };
48
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000049 int32_t _id;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000051 uint32_t _meanBufferLength;
52 uint8_t _detectionState; // 0: No flickering
niklase@google.com470e71d2011-07-07 08:21:25 +000053 // 1: Flickering detected
54 // 2: In flickering
pbos@webrtc.org1ab45f62013-04-09 13:38:10 +000055 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.com470e71d2011-07-07 08:21:25 +000061};
62
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000063} // namespace
niklase@google.com470e71d2011-07-07 08:21:25 +000064
65#endif // VPM_DEFLICKERING_H