Home | History | Annotate | Download | only in audio_processing
      1 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
      2 #
      3 # Use of this source code is governed by a BSD-style license
      4 # that can be found in the LICENSE file in the root of the source
      5 # tree. An additional intellectual property rights grant can be found
      6 # in the file PATENTS.  All contributing project authors may
      7 # be found in the AUTHORS file in the root of the source tree.
      8 
      9 import("//build/config/arm.gni")
     10 import("//third_party/protobuf/proto_library.gni")
     11 import("../../build/webrtc.gni")
     12 
     13 declare_args() {
     14   # Outputs some low-level debug files.
     15   aec_debug_dump = false
     16 
     17   # Disables the usual mode where we trust the reported system delay
     18   # values the AEC receives. The corresponding define is set appropriately
     19   # in the code, but it can be force-enabled here for testing.
     20   aec_untrusted_delay_for_testing = false
     21 }
     22 
     23 source_set("audio_processing") {
     24   sources = [
     25     "aec/include/echo_cancellation.h",
     26     "aec/echo_cancellation.c",
     27     "aec/echo_cancellation_internal.h",
     28     "aec/aec_core.h",
     29     "aec/aec_core.c",
     30     "aec/aec_core_internal.h",
     31     "aec/aec_rdft.h",
     32     "aec/aec_rdft.c",
     33     "aec/aec_resampler.h",
     34     "aec/aec_resampler.c",
     35     "aecm/include/echo_control_mobile.h",
     36     "aecm/echo_control_mobile.c",
     37     "aecm/aecm_core.c",
     38     "aecm/aecm_core.h",
     39     "agc/include/gain_control.h",
     40     "agc/analog_agc.c",
     41     "agc/analog_agc.h",
     42     "agc/digital_agc.c",
     43     "agc/digital_agc.h",
     44     "audio_buffer.cc",
     45     "audio_buffer.h",
     46     "audio_processing_impl.cc",
     47     "audio_processing_impl.h",
     48     "common.h",
     49     "echo_cancellation_impl.cc",
     50     "echo_cancellation_impl.h",
     51     "echo_control_mobile_impl.cc",
     52     "echo_control_mobile_impl.h",
     53     "gain_control_impl.cc",
     54     "gain_control_impl.h",
     55     "high_pass_filter_impl.cc",
     56     "high_pass_filter_impl.h",
     57     "include/audio_processing.h",
     58     "level_estimator_impl.cc",
     59     "level_estimator_impl.h",
     60     "noise_suppression_impl.cc",
     61     "noise_suppression_impl.h",
     62     "processing_component.cc",
     63     "processing_component.h",
     64     "rms_level.cc",
     65     "rms_level.h",
     66     "typing_detection.cc",
     67     "typing_detection.h",
     68     "utility/delay_estimator.c",
     69     "utility/delay_estimator.h",
     70     "utility/delay_estimator_internal.h",
     71     "utility/delay_estimator_wrapper.c",
     72     "utility/delay_estimator_wrapper.h",
     73     "utility/fft4g.c",
     74     "utility/fft4g.h",
     75     "utility/ring_buffer.c",
     76     "utility/ring_buffer.h",
     77     "voice_detection_impl.cc",
     78     "voice_detection_impl.h",
     79   ]
     80 
     81   configs += [ "../..:common_config" ]
     82   direct_dependent_configs = [ "../..:common_inherited_config" ]
     83 
     84   defines = []
     85   deps = []
     86 
     87   if (aec_debug_dump) {
     88     defines += [ "WEBRTC_AEC_DEBUG_DUMP" ]
     89   }
     90 
     91   if (aec_untrusted_delay_for_testing) {
     92     defines += [ "WEBRTC_UNTRUSTED_DELAY" ]
     93   }
     94 
     95   if (rtc_enable_protobuf) {
     96     defines += [ "WEBRTC_AUDIOPROC_DEBUG_DUMP" ]
     97     deps += [ ":audioproc_debug_proto" ]
     98   }
     99 
    100   if (rtc_prefer_fixed_point) {
    101     defines += [ "WEBRTC_NS_FIXED" ]
    102     sources += [
    103       "ns/include/noise_suppression_x.h",
    104       "ns/noise_suppression_x.c",
    105       "ns/nsx_core.c",
    106       "ns/nsx_core.h",
    107       "ns/nsx_defines.h",
    108     ]
    109     if (cpu_arch == "mipsel") {
    110       sources += [ "ns/nsx_core_mips.c" ]
    111     } else {
    112       sources += [ "ns/nsx_core_c.c" ]
    113     }
    114   } else {
    115     defines += [ "WEBRTC_NS_FLOAT" ]
    116     sources += [
    117       "ns/defines.h",
    118       "ns/include/noise_suppression.h",
    119       "ns/noise_suppression.c",
    120       "ns/ns_core.c",
    121       "ns/ns_core.h",
    122       "ns/windows_private.h",
    123     ]
    124   }
    125 
    126   if (cpu_arch == "x86" || cpu_arch == "x64") {
    127     deps += [ ":audio_processing_sse2" ]
    128   }
    129 
    130   if (rtc_build_armv7_neon) {
    131     deps += [ ":audio_processing_neon" ]
    132   }
    133 
    134   if (cpu_arch == "mipsel") {
    135     sources += [ "aecm/aecm_core_mips.c" ]
    136     if (mips_fpu)  {
    137       sources += [
    138         "aec/aec_core_mips.c",
    139         "aec/aec_rdft_mips.c",
    140       ]
    141     }
    142   } else {
    143     sources += [ "aecm/aecm_core_c.c" ]
    144   }
    145 
    146   if (is_win) {
    147     cflags = [
    148       # TODO(jschuh): Bug 1348: fix this warning.
    149       "/wd4267",  # size_t to int truncations
    150     ]
    151   }
    152 
    153   if (is_clang) {
    154     # Suppress warnings from Chrome's Clang plugins.
    155     # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
    156     configs -= [ "//build/config/clang:find_bad_constructs" ]
    157   }
    158 
    159   deps += [
    160     "../../base:rtc_base_approved",
    161     "../../common_audio",
    162     "../../system_wrappers",
    163   ]
    164 }
    165 
    166 if (rtc_enable_protobuf) {
    167   proto_library("audioproc_debug_proto") {
    168     sources = [ "debug.proto" ]
    169 
    170     proto_out_dir = "webrtc/audio_processing"
    171   }
    172 }
    173 
    174 if (cpu_arch == "x86" || cpu_arch == "x64") {
    175   source_set("audio_processing_sse2") {
    176     sources = [
    177       "aec/aec_core_sse2.c",
    178       "aec/aec_rdft_sse2.c",
    179     ]
    180 
    181     cflags = [ "-msse2" ]
    182 
    183     configs += [ "../..:common_inherited_config" ]
    184   }
    185 }
    186 
    187 if (rtc_build_armv7_neon) {
    188   source_set("audio_processing_neon") {
    189     sources = [
    190       "aec/aec_core_neon.c",
    191       "aec/aec_rdft_neon.c",
    192     ]
    193 
    194     deps = [ "../../common_audio" ]
    195 
    196     if (is_android || is_ios) {
    197       sources += [
    198         # TODO(andrew): Re-enable these once webrtc:3580 is resolved.
    199         #"aecm/aecm_core_neon.S",
    200         #"ns/nsx_core_neon.S",
    201       ]
    202 
    203       include_dirs = [ target_out_dir ]
    204     } else {
    205       sources += [
    206         "aecm/aecm_core_neon.c",
    207         "ns/nsx_core_neon.c",
    208       ]
    209     }
    210 
    211     # Enable compilation for the ARM v7 Neon instruction set. This is needed
    212     # since //build/config/arm.gni only enables Neon for iOS, not Android.
    213     # This provides the same functionality as webrtc/build/arm_neon.gypi.
    214     # TODO(kjellander): Investigate if this can be moved into webrtc.gni or
    215     # //build/config/arm.gni instead, to reduce code duplication.
    216     # Remove the -mfpu=vfpv3-d16 cflag.
    217     configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
    218     cflags = [
    219       "-flax-vector-conversions",
    220       "-mfpu=neon",
    221     ]
    222 
    223     # Disable LTO in audio_processing_neon target due to compiler bug.
    224     if (rtc_use_lto) {
    225       cflags -= [
    226         "-flto",
    227         "-ffat-lto-objects",
    228       ]
    229     }
    230   }
    231 }
    232