Line data Source code
1 : /*
2 : * Copyright (c) 2015 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 : #include "webrtc/base/checks.h"
12 : #include "webrtc/modules/video_processing/util/denoiser_filter.h"
13 : #include "webrtc/modules/video_processing/util/denoiser_filter_c.h"
14 : #include "webrtc/modules/video_processing/util/denoiser_filter_neon.h"
15 : #include "webrtc/modules/video_processing/util/denoiser_filter_sse2.h"
16 : #include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
17 :
18 : namespace webrtc {
19 :
20 : const int kMotionMagnitudeThreshold = 8 * 3;
21 : const int kSumDiffThreshold = 96;
22 : const int kSumDiffThresholdHigh = 448;
23 :
24 0 : std::unique_ptr<DenoiserFilter> DenoiserFilter::Create(
25 : bool runtime_cpu_detection,
26 : CpuType* cpu_type) {
27 0 : std::unique_ptr<DenoiserFilter> filter;
28 :
29 0 : if (cpu_type != nullptr)
30 0 : *cpu_type = CPU_NOT_NEON;
31 0 : if (runtime_cpu_detection) {
32 : // If we know the minimum architecture at compile time, avoid CPU detection.
33 : #if defined(WEBRTC_ARCH_X86_FAMILY)
34 : #if defined(__SSE2__)
35 0 : filter.reset(new DenoiserFilterSSE2());
36 : #else
37 : // x86 CPU detection required.
38 : if (WebRtc_GetCPUInfo(kSSE2)) {
39 : filter.reset(new DenoiserFilterSSE2());
40 : } else {
41 : filter.reset(new DenoiserFilterC());
42 : }
43 : #endif
44 : #elif defined(WEBRTC_HAS_NEON)
45 : filter.reset(new DenoiserFilterNEON());
46 : if (cpu_type != nullptr)
47 : *cpu_type = CPU_NEON;
48 : #else
49 : filter.reset(new DenoiserFilterC());
50 : #endif
51 : } else {
52 0 : filter.reset(new DenoiserFilterC());
53 : }
54 :
55 0 : RTC_DCHECK(filter.get() != nullptr);
56 0 : return filter;
57 : }
58 :
59 : } // namespace webrtc
|