blob: 53ffebed5fe03efb00443158e720dd5f8adab0be [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
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000011#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCEdeflickering__H
12#define WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCEdeflickering__H
niklase@google.com470e71d2011-07-07 08:21:25 +000013
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000014#include <string.h> // NULL
15
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000016#include "webrtc/modules/video_processing/main/interface/video_processing.h"
17#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
niklase@google.com470e71d2011-07-07 08:21:25 +000019namespace webrtc {
20
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000021class VPMDeflickering {
22 public:
23 VPMDeflickering();
24 ~VPMDeflickering();
niklase@google.com470e71d2011-07-07 08:21:25 +000025
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000026 int32_t ChangeUniqueId(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +000027
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000028 void Reset();
29 int32_t ProcessFrame(I420VideoFrame* frame,
30 VideoProcessingModule::FrameStats* stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000032 private:
33 int32_t PreDetection(uint32_t timestamp,
34 const VideoProcessingModule::FrameStats& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000036 int32_t DetectFlicker();
niklase@google.com470e71d2011-07-07 08:21:25 +000037
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000038 enum { kMeanBufferLength = 32 };
39 enum { kFrameHistory_size = 15 };
40 enum { kNumProbs = 12 };
41 enum { kNumQuants = kNumProbs + 2 };
42 enum { kMaxOnlyLength = 5 };
niklase@google.com470e71d2011-07-07 08:21:25 +000043
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000044 int32_t id_;
niklase@google.com470e71d2011-07-07 08:21:25 +000045
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000046 uint32_t mean_buffer_length_;
47 uint8_t detection_state_; // 0: No flickering
48 // 1: Flickering detected
49 // 2: In flickering
50 int32_t mean_buffer_[kMeanBufferLength];
51 uint32_t timestamp_buffer_[kMeanBufferLength];
52 uint32_t frame_rate_;
53 static const uint16_t prob_uw16_[kNumProbs];
54 static const uint16_t weight_uw16_[kNumQuants - kMaxOnlyLength];
55 uint8_t quant_hist_uw8_[kFrameHistory_size][kNumQuants];
niklase@google.com470e71d2011-07-07 08:21:25 +000056};
57
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000058} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000059
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000060#endif // WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_SOURCEdeflickering__H