2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* video_processing.h
|
|
|
|
|
* This header file contains the API required for the video
|
|
|
|
|
* processing module class.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2015-11-18 22:31:24 +01:00
|
|
|
#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_INCLUDE_VIDEO_PROCESSING_H_
|
|
|
|
|
#define WEBRTC_MODULES_VIDEO_PROCESSING_INCLUDE_VIDEO_PROCESSING_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/include/module_common_types.h"
|
2015-11-18 22:31:24 +01:00
|
|
|
#include "webrtc/modules/video_processing/include/video_processing_defines.h"
|
2015-04-10 12:52:13 +02:00
|
|
|
#include "webrtc/video_frame.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// The module is largely intended to process video streams, except functionality
|
|
|
|
|
// provided by static functions which operate independent of previous frames. It
|
|
|
|
|
// is recommended, but not required that a unique instance be used for each
|
|
|
|
|
// concurrently processed stream. Similarly, it is recommended to call Reset()
|
|
|
|
|
// before switching to a new stream, but this is not absolutely required.
|
|
|
|
|
//
|
|
|
|
|
// The module provides basic thread safety by permitting only a single function
|
|
|
|
|
// to execute concurrently.
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
class VideoProcessing {
|
2013-10-03 16:42:41 +00:00
|
|
|
public:
|
|
|
|
|
struct FrameStats {
|
2015-12-07 01:09:52 -08:00
|
|
|
uint32_t hist[256]; // Frame histogram.
|
|
|
|
|
uint32_t mean;
|
|
|
|
|
uint32_t sum;
|
|
|
|
|
uint32_t num_pixels;
|
|
|
|
|
uint32_t sub_sampling_factor; // Sub-sampling factor, in powers of 2.
|
|
|
|
|
};
|
2013-10-03 16:42:41 +00:00
|
|
|
|
|
|
|
|
enum BrightnessWarning {
|
2015-12-07 01:09:52 -08:00
|
|
|
kNoWarning,
|
|
|
|
|
kDarkWarning,
|
|
|
|
|
kBrightWarning
|
2013-10-03 16:42:41 +00:00
|
|
|
};
|
|
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
static VideoProcessing* Create();
|
|
|
|
|
virtual ~VideoProcessing() {}
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Retrieves statistics for the input frame. This function must be used to
|
|
|
|
|
// prepare a FrameStats struct for use in certain VPM functions.
|
|
|
|
|
static void GetFrameStats(const VideoFrame& frame, FrameStats* stats);
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Checks the validity of a FrameStats struct. Currently, valid implies only
|
|
|
|
|
// that is had changed from its initialized state.
|
2013-10-03 16:42:41 +00:00
|
|
|
static bool ValidFrameStats(const FrameStats& stats);
|
|
|
|
|
|
|
|
|
|
static void ClearFrameStats(FrameStats* stats);
|
|
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Increases/decreases the luminance value. 'delta' can be in the range {}
|
|
|
|
|
static void Brighten(int delta, VideoFrame* frame);
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Detects and removes camera flicker from a video stream. Every frame from
|
|
|
|
|
// the stream must be passed in. A frame will only be altered if flicker has
|
|
|
|
|
// been detected. Has a fixed-point implementation.
|
|
|
|
|
// Frame statistics provided by GetFrameStats(). On return the stats will
|
|
|
|
|
// be reset to zero if the frame was altered. Call GetFrameStats() again
|
|
|
|
|
// if the statistics for the altered frame are required.
|
2015-05-29 17:21:40 -07:00
|
|
|
virtual int32_t Deflickering(VideoFrame* frame, FrameStats* stats) = 0;
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Detects if a video frame is excessively bright or dark. Returns a
|
|
|
|
|
// warning if this is the case. Multiple frames should be passed in before
|
|
|
|
|
// expecting a warning. Has a floating-point implementation.
|
2015-05-29 17:21:40 -07:00
|
|
|
virtual int32_t BrightnessDetection(const VideoFrame& frame,
|
2013-10-03 16:42:41 +00:00
|
|
|
const FrameStats& stats) = 0;
|
|
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// The following functions refer to the pre-processor unit within VPM. The
|
|
|
|
|
// pre-processor perfoms spatial/temporal decimation and content analysis on
|
|
|
|
|
// the frames prior to encoding.
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Enable/disable temporal decimation
|
2013-10-03 16:42:41 +00:00
|
|
|
virtual void EnableTemporalDecimation(bool enable) = 0;
|
|
|
|
|
|
|
|
|
|
virtual int32_t SetTargetResolution(uint32_t width,
|
|
|
|
|
uint32_t height,
|
|
|
|
|
uint32_t frame_rate) = 0;
|
|
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
virtual void SetTargetFramerate(int frame_rate) = 0;
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
virtual uint32_t GetDecimatedFrameRate() = 0;
|
|
|
|
|
virtual uint32_t GetDecimatedWidth() const = 0;
|
|
|
|
|
virtual uint32_t GetDecimatedHeight() const = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
// Set the spatial resampling settings of the VPM according to
|
|
|
|
|
// VideoFrameResampling.
|
|
|
|
|
virtual void SetInputFrameResampleMode(
|
|
|
|
|
VideoFrameResampling resampling_mode) = 0;
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
virtual void EnableDenosing(bool enable) = 0;
|
|
|
|
|
virtual const VideoFrame* PreprocessFrame(const VideoFrame& frame) = 0;
|
2013-10-03 16:42:41 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
virtual VideoContentMetrics* GetContentMetrics() const = 0;
|
2013-10-03 16:42:41 +00:00
|
|
|
virtual void EnableContentAnalysis(bool enable) = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-10-03 16:42:41 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-11-18 22:31:24 +01:00
|
|
|
#endif // WEBRTC_MODULES_VIDEO_PROCESSING_INCLUDE_VIDEO_PROCESSING_H_
|