Moving the neural residual echo estimator code to its own folder.

Bug: webrtc:442444736
Change-Id: I9caf03d059e4ed018979a632135867ea22c8f8ea
No-Iwyu: Not changing the tflite includes.
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/414961
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45861}
diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn
index 049ed11..a5e6ce5 100644
--- a/api/audio/BUILD.gn
+++ b/api/audio/BUILD.gn
@@ -192,7 +192,7 @@
     ]
     deps = [
       ":neural_residual_echo_estimator_api",
-      "../../modules/audio_processing/aec3:neural_residual_echo_estimator_impl",
+      "../../modules/audio_processing/aec3/neural_residual_echo_estimator:neural_residual_echo_estimator_impl",
       "../../rtc_base:checks",
       "../../rtc_base/system:rtc_export",
       "//third_party/abseil-cpp/absl/base:nullability",
diff --git a/api/audio/neural_residual_echo_estimator_creator.cc b/api/audio/neural_residual_echo_estimator_creator.cc
index e5e02c5..7583c70 100644
--- a/api/audio/neural_residual_echo_estimator_creator.cc
+++ b/api/audio/neural_residual_echo_estimator_creator.cc
@@ -11,12 +11,11 @@
 #include "api/audio/neural_residual_echo_estimator_creator.h"
 
 #include <memory>
-#include <utility>
 
 #include "absl/base/nullability.h"
 #include "absl/strings/string_view.h"
 #include "api/audio/neural_residual_echo_estimator.h"
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h"
 #include "rtc_base/checks.h"
 #include "third_party/tflite/src/tensorflow/lite/op_resolver.h"
 
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 2264302..c4f5f6b 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -101,6 +101,9 @@
       "video_coding/timing:timing_unittests",
     ]
 
+    if (rtc_enable_protobuf) {
+      deps += [ "audio_processing/aec3/neural_residual_echo_estimator:neural_residual_echo_estimator_unittest" ]
+    }
     if (rtc_desktop_capture_supported) {
       deps += [ "desktop_capture:desktop_capture_unittests" ]
     }
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index b9cd84f..9d17d51 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -290,46 +290,6 @@
   }
 }
 
-if (rtc_enable_protobuf) {
-  proto_library("neural_residual_echo_estimator_proto") {
-    sources = [ "neural_residual_echo_estimator.proto" ]
-    proto_out_dir = "modules/audio_processing/aec3"
-  }
-
-  rtc_library("neural_residual_echo_estimator_impl") {
-    visibility = [ "*" ]
-    poisonous = [ "default_neural_residual_echo_estimator" ]
-    configs += [ "..:apm_debug_dump" ]
-    public_configs = [ "//third_party/tflite:tflite_config_no_undef" ]
-    sources = [
-      "neural_feature_extractor.cc",
-      "neural_feature_extractor.h",
-      "neural_residual_echo_estimator_impl.cc",
-      "neural_residual_echo_estimator_impl.h",
-    ]
-    deps = [
-      ":aec3_common",
-      ":neural_residual_echo_estimator_proto",
-      "..:apm_logging",
-      "../../../api:array_view",
-      "../../../api/audio:aec3_config",
-      "../../../api/audio:neural_residual_echo_estimator_api",
-      "../../../common_audio",
-      "../../../rtc_base:checks",
-      "../../../rtc_base:logging",
-      "//third_party/abseil-cpp/absl/base:nullability",
-      "//third_party/abseil-cpp/absl/strings:string_view",
-      "//third_party/flatbuffers",
-      "//third_party/pffft",
-    ]
-    if (build_with_chromium) {
-      deps += [ "//third_party/tflite" ]
-    } else {
-      deps += [ "//third_party/tflite:tflite_standalone" ]
-    }
-  }
-}
-
 if (rtc_include_tests) {
   rtc_library("aec3_unittests") {
     testonly = true
@@ -415,8 +375,6 @@
         "matched_filter_unittest.cc",
         "moving_average_unittest.cc",
         "multi_channel_content_detector_unittest.cc",
-        "neural_feature_extractor_unittest.cc",
-        "neural_residual_echo_estimator_impl_unittest.cc",
         "refined_filter_update_gain_unittest.cc",
         "render_buffer_unittest.cc",
         "render_delay_buffer_unittest.cc",
@@ -431,19 +389,7 @@
         "suppression_gain_unittest.cc",
         "vector_math_unittest.cc",
       ]
-      deps += [
-        ":neural_residual_echo_estimator_impl",
-        ":neural_residual_echo_estimator_proto",
-        "../../../test:test_support",
-        "//third_party/flatbuffers",
-      ]
-      if (build_with_chromium) {
-        deps += [ "//third_party/tflite:tflite_builtin_op_resolver" ]
-      } else {
-        deps += [ "//third_party/tflite:tflite_builtin_op_resolver_standalone" ]
-      }
     }
-
     if (!build_with_chromium) {
       deps += [ "..:audio_processing_unittests" ]
     }
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn b/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn
new file mode 100644
index 0000000..4089904
--- /dev/null
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn
@@ -0,0 +1,88 @@
+# Copyright (c) 2025 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+import("../../../../webrtc.gni")
+if (rtc_enable_protobuf) {
+  import("//third_party/protobuf/proto_library.gni")
+}
+
+if (rtc_enable_protobuf) {
+  proto_library("neural_residual_echo_estimator_proto") {
+    sources = [ "neural_residual_echo_estimator.proto" ]
+    proto_out_dir =
+        "modules/audio_processing/aec3/neural_residual_echo_estimator"
+  }
+
+  rtc_library("neural_residual_echo_estimator_impl") {
+    visibility = [ "*" ]
+    poisonous = [ "default_neural_residual_echo_estimator" ]
+    configs += [ "../..:apm_debug_dump" ]
+    public_configs = [ "//third_party/tflite:tflite_config_no_undef" ]
+    sources = [
+      "neural_feature_extractor.cc",
+      "neural_feature_extractor.h",
+      "neural_residual_echo_estimator_impl.cc",
+      "neural_residual_echo_estimator_impl.h",
+    ]
+    deps = [
+      ":neural_residual_echo_estimator_proto",
+      "..:aec3_common",
+      "../..:apm_logging",
+      "../../../../api:array_view",
+      "../../../../api/audio:aec3_config",
+      "../../../../api/audio:neural_residual_echo_estimator_api",
+      "../../../../common_audio",
+      "../../../../rtc_base:checks",
+      "../../../../rtc_base:logging",
+      "//third_party/abseil-cpp/absl/base:nullability",
+      "//third_party/abseil-cpp/absl/strings:string_view",
+      "//third_party/flatbuffers",
+      "//third_party/pffft",
+    ]
+    if (build_with_chromium) {
+      deps += [ "//third_party/tflite" ]
+    } else {
+      deps += [ "//third_party/tflite:tflite_standalone" ]
+    }
+  }
+}
+
+if (rtc_include_tests) {
+  if (rtc_enable_protobuf) {
+    rtc_library("neural_residual_echo_estimator_unittest") {
+      testonly = true
+      configs += [
+        "../..:apm_debug_dump",
+        "//third_party/tflite:tflite_config_no_undef",
+      ]
+      sources = [
+        "neural_feature_extractor_unittest.cc",
+        "neural_residual_echo_estimator_impl_unittest.cc",
+      ]
+      deps = [
+        ":neural_residual_echo_estimator_impl",
+        ":neural_residual_echo_estimator_proto",
+        "..:aec3_common",
+        "../../../../api:array_view",
+        "../../../../rtc_base:checks",
+        "../../../../rtc_base:random",
+        "../../../../test:fileutils",
+        "../../../../test:test_support",
+        "//third_party/flatbuffers",
+      ]
+      if (build_with_chromium) {
+        deps += [ "//third_party/tflite:tflite_builtin_op_resolver" ]
+      } else {
+        deps += [
+          "../..:audio_processing_unittests",
+          "//third_party/tflite:tflite_builtin_op_resolver_standalone",
+        ]
+      }
+    }
+  }
+}
diff --git a/modules/audio_processing/aec3/DEPS b/modules/audio_processing/aec3/neural_residual_echo_estimator/DEPS
similarity index 100%
rename from modules/audio_processing/aec3/DEPS
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/DEPS
diff --git a/modules/audio_processing/aec3/neural_feature_extractor.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc
similarity index 97%
rename from modules/audio_processing/aec3/neural_feature_extractor.cc
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc
index df053b5..b6f071e 100644
--- a/modules/audio_processing/aec3/neural_feature_extractor.cc
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "modules/audio_processing/aec3/neural_feature_extractor.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h"
 
 #include <algorithm>
 #include <array>
diff --git a/modules/audio_processing/aec3/neural_feature_extractor.h b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h
similarity index 86%
rename from modules/audio_processing/aec3/neural_feature_extractor.h
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h
index 79dc56b..641093c 100644
--- a/modules/audio_processing/aec3/neural_feature_extractor.h
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef MODULES_AUDIO_PROCESSING_AEC3_NEURAL_FEATURE_EXTRACTOR_H_
-#define MODULES_AUDIO_PROCESSING_AEC3_NEURAL_FEATURE_EXTRACTOR_H_
+#ifndef MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_FEATURE_EXTRACTOR_H_
+#define MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_FEATURE_EXTRACTOR_H_
 
 #include <cstring>
 #include <memory>
@@ -58,7 +58,7 @@
  private:
   class PffftState {
    public:
-    PffftState(int frame_size)
+    explicit PffftState(int frame_size)
         : data_(static_cast<float*>(
               pffft_aligned_malloc(frame_size * sizeof(float)))) {
       std::memset(data_, 0, sizeof(float) * frame_size);
@@ -78,4 +78,4 @@
 };
 
 }  // namespace webrtc
-#endif  // MODULES_AUDIO_PROCESSING_AEC3_NEURAL_FEATURE_EXTRACTOR_H_
+#endif  // MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_FEATURE_EXTRACTOR_H_
diff --git a/modules/audio_processing/aec3/neural_feature_extractor_unittest.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc
similarity index 98%
rename from modules/audio_processing/aec3/neural_feature_extractor_unittest.cc
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc
index 642a93e..024f5df 100644
--- a/modules/audio_processing/aec3/neural_feature_extractor_unittest.cc
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc
@@ -49,7 +49,7 @@
 print(format_as_cpp_array(expected_output2, "expected_output2"))
 */
 
-#include "modules/audio_processing/aec3/neural_feature_extractor.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h"
 
 #include <vector>
 
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator.proto b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.proto
similarity index 100%
rename from modules/audio_processing/aec3/neural_residual_echo_estimator.proto
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.proto
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc
similarity index 98%
rename from modules/audio_processing/aec3/neural_residual_echo_estimator_impl.cc
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc
index bc19c4d..4d4cac9 100644
--- a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl.cc
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h"
 
 #include <algorithm>
 #include <array>
@@ -28,12 +28,12 @@
 #include "api/audio/echo_canceller3_config.h"
 #include "api/audio/neural_residual_echo_estimator.h"
 #include "modules/audio_processing/aec3/aec3_common.h"
-#include "modules/audio_processing/aec3/neural_feature_extractor.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h"
 #include "third_party/tflite/src/tensorflow/lite/c/c_api_types.h"
 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #else
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #endif
 #include "modules/audio_processing/logging/apm_data_dumper.h"
 #include "rtc_base/checks.h"
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h
similarity index 92%
rename from modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h
index bc4ba66..885c40e 100644
--- a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
-#define MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
+#ifndef MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
+#define MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
 
 #include <array>
 #include <memory>
@@ -21,13 +21,13 @@
 #include "api/audio/echo_canceller3_config.h"
 #include "api/audio/neural_residual_echo_estimator.h"
 #include "modules/audio_processing/aec3/aec3_common.h"
-#include "modules/audio_processing/aec3/neural_feature_extractor.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h"
 #include "modules/audio_processing/logging/apm_data_dumper.h"
 #include "third_party/tflite/src/tensorflow/lite/op_resolver.h"
 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #else
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #endif
 
 namespace webrtc {
@@ -39,7 +39,6 @@
 // that the AEC3 suppressor needs for computing the suppression gains.
 class NeuralResidualEchoEstimatorImpl : public NeuralResidualEchoEstimator {
  public:
-
   // Executes a residual echo estimation model on given inputs.
   class ModelRunner {
    public:
@@ -104,4 +103,4 @@
 
 }  // namespace webrtc
 
-#endif  // MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
+#endif  // MODULES_AUDIO_PROCESSING_AEC3_NEURAL_RESIDUAL_ECHO_ESTIMATOR_NEURAL_RESIDUAL_ECHO_ESTIMATOR_IMPL_H_
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl_unittest.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc
similarity index 97%
rename from modules/audio_processing/aec3/neural_residual_echo_estimator_impl_unittest.cc
rename to modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc
index bcf1576..a162321 100644
--- a/modules/audio_processing/aec3/neural_residual_echo_estimator_impl_unittest.cc
+++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator_impl.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h"
 
 #include <algorithm>
 #include <array>
@@ -20,7 +20,7 @@
 
 #include "api/array_view.h"
 #include "modules/audio_processing/aec3/aec3_common.h"
-#include "modules/audio_processing/aec3/neural_feature_extractor.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h"
 #include "modules/audio_processing/test/echo_canceller_test_tools.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/random.h"
@@ -29,9 +29,9 @@
 #include "test/testsupport/file_utils.h"
 #include "third_party/tflite/src/tensorflow/lite/kernels/register.h"
 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "external/webrtc/webrtc/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #else
-#include "modules/audio_processing/aec3/neural_residual_echo_estimator.pb.h"
+#include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator.pb.h"
 #endif
 
 namespace webrtc {