Initial VideoProcessing refactoring.

This CL is the first in a series of CLs to refactor
VideoProcessing(Module) to follow Google C++ style guide and make the
code more readable.

This CL removed inheritance from Module, renames variables and makes
VideoProcessingImpl::PreprocessFrame return a frame pointer if there
is a frame to send, nullptr otherwise. The affected CLs also passes git
cl lint.

BUG=webrtc:5259

Review URL: https://codereview.webrtc.org/1482913003

Cr-Commit-Position: refs/heads/master@{#10907}
This commit is contained in:
mflodman
2015-12-07 01:09:52 -08:00
committed by Commit bot
parent 2512f44397
commit a8565425bc
22 changed files with 362 additions and 642 deletions

View File

@ -8,11 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/video_processing/include/video_processing.h"
#include "webrtc/modules/video_processing/brightness_detection.h"
#include <math.h>
#include "webrtc/modules/video_processing/include/video_processing.h"
namespace webrtc {
VPMBrightnessDetection::VPMBrightnessDetection() {
@ -28,14 +29,14 @@ void VPMBrightnessDetection::Reset() {
int32_t VPMBrightnessDetection::ProcessFrame(
const VideoFrame& frame,
const VideoProcessingModule::FrameStats& stats) {
const VideoProcessing::FrameStats& stats) {
if (frame.IsZeroSize()) {
return VPM_PARAMETER_ERROR;
}
int width = frame.width();
int height = frame.height();
if (!VideoProcessingModule::ValidFrameStats(stats)) {
if (!VideoProcessing::ValidFrameStats(stats)) {
return VPM_PARAMETER_ERROR;
}
@ -62,9 +63,9 @@ int32_t VPMBrightnessDetection::ProcessFrame(
// Standard deviation of Y
const uint8_t* buffer = frame.buffer(kYPlane);
float std_y = 0;
for (int h = 0; h < height; h += (1 << stats.subSamplHeight)) {
for (int h = 0; h < height; h += (1 << stats.sub_sampling_factor)) {
int row = h*width;
for (int w = 0; w < width; w += (1 << stats.subSamplWidth)) {
for (int w = 0; w < width; w += (1 << stats.sub_sampling_factor)) {
std_y += (buffer[w + row] - stats.mean) * (buffer[w + row] -
stats.mean);
}
@ -122,11 +123,11 @@ int32_t VPMBrightnessDetection::ProcessFrame(
}
if (frame_cnt_dark_ > frame_cnt_alarm) {
return VideoProcessingModule::kDarkWarning;
return VideoProcessing::kDarkWarning;
} else if (frame_cnt_bright_ > frame_cnt_alarm) {
return VideoProcessingModule::kBrightWarning;
return VideoProcessing::kBrightWarning;
} else {
return VideoProcessingModule::kNoWarning;
return VideoProcessing::kNoWarning;
}
}