Clean the code for external denoiser.
BUG=webrtc:5255 Review URL: https://codereview.webrtc.org/1578373003 Cr-Commit-Position: refs/heads/master@{#11235}
This commit is contained in:
@ -34,12 +34,9 @@ bool EqualPlane(const uint8_t* data1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ExpectedSize(int plane_stride, int image_height, PlaneType type) {
|
int ExpectedSize(int plane_stride, int image_height, PlaneType type) {
|
||||||
if (type == kYPlane) {
|
if (type == kYPlane)
|
||||||
return (plane_stride * image_height);
|
return plane_stride * image_height;
|
||||||
} else {
|
return plane_stride * ((image_height + 1) / 2);
|
||||||
int half_height = (image_height + 1) / 2;
|
|
||||||
return (plane_stride * half_height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoFrame::VideoFrame() {
|
VideoFrame::VideoFrame() {
|
||||||
@ -226,23 +223,23 @@ VideoFrame VideoFrame::ConvertNativeToI420Frame() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VideoFrame::EqualsFrame(const VideoFrame& frame) const {
|
bool VideoFrame::EqualsFrame(const VideoFrame& frame) const {
|
||||||
if ((this->width() != frame.width()) || (this->height() != frame.height()) ||
|
if (width() != frame.width() || height() != frame.height() ||
|
||||||
(this->stride(kYPlane) != frame.stride(kYPlane)) ||
|
stride(kYPlane) != frame.stride(kYPlane) ||
|
||||||
(this->stride(kUPlane) != frame.stride(kUPlane)) ||
|
stride(kUPlane) != frame.stride(kUPlane) ||
|
||||||
(this->stride(kVPlane) != frame.stride(kVPlane)) ||
|
stride(kVPlane) != frame.stride(kVPlane) ||
|
||||||
(this->timestamp() != frame.timestamp()) ||
|
timestamp() != frame.timestamp() ||
|
||||||
(this->ntp_time_ms() != frame.ntp_time_ms()) ||
|
ntp_time_ms() != frame.ntp_time_ms() ||
|
||||||
(this->render_time_ms() != frame.render_time_ms())) {
|
render_time_ms() != frame.render_time_ms()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const int half_width = (this->width() + 1) / 2;
|
const int half_width = (width() + 1) / 2;
|
||||||
const int half_height = (this->height() + 1) / 2;
|
const int half_height = (height() + 1) / 2;
|
||||||
return EqualPlane(this->buffer(kYPlane), frame.buffer(kYPlane),
|
return EqualPlane(buffer(kYPlane), frame.buffer(kYPlane),
|
||||||
this->stride(kYPlane), this->width(), this->height()) &&
|
stride(kYPlane), width(), height()) &&
|
||||||
EqualPlane(this->buffer(kUPlane), frame.buffer(kUPlane),
|
EqualPlane(buffer(kUPlane), frame.buffer(kUPlane),
|
||||||
this->stride(kUPlane), half_width, half_height) &&
|
stride(kUPlane), half_width, half_height) &&
|
||||||
EqualPlane(this->buffer(kVPlane), frame.buffer(kVPlane),
|
EqualPlane(buffer(kVPlane), frame.buffer(kVPlane),
|
||||||
this->stride(kVPlane), half_width, half_height);
|
stride(kVPlane), half_width, half_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/modules/video_processing/util/denoiser_filter.h"
|
#include "webrtc/modules/video_processing/util/denoiser_filter.h"
|
||||||
#include "webrtc/modules/video_processing/util/denoiser_filter_c.h"
|
#include "webrtc/modules/video_processing/util/denoiser_filter_c.h"
|
||||||
#include "webrtc/modules/video_processing/util/denoiser_filter_neon.h"
|
#include "webrtc/modules/video_processing/util/denoiser_filter_neon.h"
|
||||||
@ -20,31 +21,33 @@ const int kMotionMagnitudeThreshold = 8 * 3;
|
|||||||
const int kSumDiffThreshold = 16 * 16 * 2;
|
const int kSumDiffThreshold = 16 * 16 * 2;
|
||||||
const int kSumDiffThresholdHigh = 600;
|
const int kSumDiffThresholdHigh = 600;
|
||||||
|
|
||||||
DenoiserFilter* DenoiserFilter::Create(bool runtime_cpu_detection) {
|
rtc::scoped_ptr<DenoiserFilter> DenoiserFilter::Create(
|
||||||
DenoiserFilter* filter = NULL;
|
bool runtime_cpu_detection) {
|
||||||
|
rtc::scoped_ptr<DenoiserFilter> filter;
|
||||||
|
|
||||||
if (runtime_cpu_detection) {
|
if (runtime_cpu_detection) {
|
||||||
// If we know the minimum architecture at compile time, avoid CPU detection.
|
// If we know the minimum architecture at compile time, avoid CPU detection.
|
||||||
#if defined(WEBRTC_ARCH_X86_FAMILY)
|
#if defined(WEBRTC_ARCH_X86_FAMILY)
|
||||||
// x86 CPU detection required.
|
// x86 CPU detection required.
|
||||||
if (WebRtc_GetCPUInfo(kSSE2)) {
|
if (WebRtc_GetCPUInfo(kSSE2)) {
|
||||||
filter = new DenoiserFilterSSE2();
|
filter.reset(new DenoiserFilterSSE2());
|
||||||
} else {
|
} else {
|
||||||
filter = new DenoiserFilterC();
|
filter.reset(new DenoiserFilterC());
|
||||||
}
|
}
|
||||||
#elif defined(WEBRTC_DETECT_NEON)
|
#elif defined(WEBRTC_DETECT_NEON)
|
||||||
if (WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) {
|
if (WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) {
|
||||||
filter = new DenoiserFilterNEON();
|
filter.reset(new DenoiserFilterNEON());
|
||||||
} else {
|
} else {
|
||||||
filter = new DenoiserFilterC();
|
filter.reset(new DenoiserFilterC());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
filter = new DenoiserFilterC();
|
filter.reset(new DenoiserFilterC());
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
filter = new DenoiserFilterC();
|
filter.reset(new DenoiserFilterC());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RTC_DCHECK(filter.get() != nullptr);
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_DENOISER_FILTER_H_
|
#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_DENOISER_FILTER_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_DENOISER_FILTER_H_
|
#define WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_DENOISER_FILTER_H_
|
||||||
|
|
||||||
|
#include "webrtc/base/scoped_ptr.h"
|
||||||
#include "webrtc/modules/include/module_common_types.h"
|
#include "webrtc/modules/include/module_common_types.h"
|
||||||
#include "webrtc/modules/video_processing/include/video_processing_defines.h"
|
#include "webrtc/modules/video_processing/include/video_processing_defines.h"
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ struct DenoiseMetrics {
|
|||||||
|
|
||||||
class DenoiserFilter {
|
class DenoiserFilter {
|
||||||
public:
|
public:
|
||||||
static DenoiserFilter* Create(bool runtime_cpu_detection);
|
static rtc::scoped_ptr<DenoiserFilter> Create(bool runtime_cpu_detection);
|
||||||
|
|
||||||
virtual ~DenoiserFilter() {}
|
virtual ~DenoiserFilter() {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user