Home | History | Annotate | Download | only in util
      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 = 16 * 16 * 2;
     22 const int kSumDiffThresholdHigh = 600;
     23 
     24 rtc::scoped_ptr<DenoiserFilter> DenoiserFilter::Create(
     25     bool runtime_cpu_detection) {
     26   rtc::scoped_ptr<DenoiserFilter> filter;
     27 
     28   if (runtime_cpu_detection) {
     29 // If we know the minimum architecture at compile time, avoid CPU detection.
     30 #if defined(WEBRTC_ARCH_X86_FAMILY)
     31     // x86 CPU detection required.
     32     if (WebRtc_GetCPUInfo(kSSE2)) {
     33       filter.reset(new DenoiserFilterSSE2());
     34     } else {
     35       filter.reset(new DenoiserFilterC());
     36     }
     37 #elif defined(WEBRTC_DETECT_NEON)
     38     if (WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) {
     39       filter.reset(new DenoiserFilterNEON());
     40     } else {
     41       filter.reset(new DenoiserFilterC());
     42     }
     43 #else
     44     filter.reset(new DenoiserFilterC());
     45 #endif
     46   } else {
     47     filter.reset(new DenoiserFilterC());
     48   }
     49 
     50   RTC_DCHECK(filter.get() != nullptr);
     51   return filter;
     52 }
     53 
     54 }  // namespace webrtc
     55