Home | History | Annotate | Download | only in video_processing
      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 #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_DEFLICKERING_H_
     12 #define WEBRTC_MODULES_VIDEO_PROCESSING_DEFLICKERING_H_
     13 
     14 #include <string.h>  // NULL
     15 
     16 #include "webrtc/modules/video_processing/include/video_processing.h"
     17 #include "webrtc/typedefs.h"
     18 
     19 namespace webrtc {
     20 
     21 class VPMDeflickering {
     22  public:
     23   VPMDeflickering();
     24   ~VPMDeflickering();
     25 
     26   void Reset();
     27   int32_t ProcessFrame(VideoFrame* frame, VideoProcessing::FrameStats* stats);
     28 
     29  private:
     30   int32_t PreDetection(uint32_t timestamp,
     31                        const VideoProcessing::FrameStats& stats);
     32 
     33   int32_t DetectFlicker();
     34 
     35   enum { kMeanBufferLength = 32 };
     36   enum { kFrameHistory_size = 15 };
     37   enum { kNumProbs = 12 };
     38   enum { kNumQuants = kNumProbs + 2 };
     39   enum { kMaxOnlyLength = 5 };
     40 
     41   uint32_t mean_buffer_length_;
     42   uint8_t detection_state_;  // 0: No flickering
     43                              // 1: Flickering detected
     44                              // 2: In flickering
     45   int32_t mean_buffer_[kMeanBufferLength];
     46   uint32_t timestamp_buffer_[kMeanBufferLength];
     47   uint32_t frame_rate_;
     48   static const uint16_t prob_uw16_[kNumProbs];
     49   static const uint16_t weight_uw16_[kNumQuants - kMaxOnlyLength];
     50   uint8_t quant_hist_uw8_[kFrameHistory_size][kNumQuants];
     51 };
     52 
     53 }  // namespace webrtc
     54 
     55 #endif  // WEBRTC_MODULES_VIDEO_PROCESSING_DEFLICKERING_H_
     56