ClippingPredictor/Evaluator/LevelBuffer and GainMap: Move to agc2
Bug: webrtc:7494 Change-Id: If88795fe34a73faa267a9c0bd5250e36455d4d81 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277741 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Hanna Silen <silen@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38296}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
d9b9c29143
commit
cfbda697ec
@ -418,6 +418,7 @@ if (rtc_include_tests) {
|
|||||||
"agc2:adaptive_digital_unittests",
|
"agc2:adaptive_digital_unittests",
|
||||||
"agc2:biquad_filter_unittests",
|
"agc2:biquad_filter_unittests",
|
||||||
"agc2:fixed_digital_unittests",
|
"agc2:fixed_digital_unittests",
|
||||||
|
"agc2:input_volume_controller_unittests",
|
||||||
"agc2:noise_estimator_unittests",
|
"agc2:noise_estimator_unittests",
|
||||||
"agc2:test_utils",
|
"agc2:test_utils",
|
||||||
"agc2:vad_wrapper_unittests",
|
"agc2:vad_wrapper_unittests",
|
||||||
@ -525,7 +526,7 @@ if (rtc_include_tests) {
|
|||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
"../../rtc_base:safe_conversions",
|
"../../rtc_base:safe_conversions",
|
||||||
"../../rtc_base:safe_minmax",
|
"../../rtc_base:safe_minmax",
|
||||||
"agc:gain_map",
|
"agc2:gain_map",
|
||||||
]
|
]
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,7 @@ rtc_library("agc") {
|
|||||||
]
|
]
|
||||||
configs += [ "..:apm_debug_dump" ]
|
configs += [ "..:apm_debug_dump" ]
|
||||||
deps = [
|
deps = [
|
||||||
":clipping_predictor",
|
|
||||||
":clipping_predictor_evaluator",
|
|
||||||
":gain_control_interface",
|
":gain_control_interface",
|
||||||
":gain_map",
|
|
||||||
":level_estimation",
|
":level_estimation",
|
||||||
"..:api",
|
"..:api",
|
||||||
"..:apm_logging",
|
"..:apm_logging",
|
||||||
@ -37,6 +34,9 @@ rtc_library("agc") {
|
|||||||
"../../../rtc_base:safe_minmax",
|
"../../../rtc_base:safe_minmax",
|
||||||
"../../../system_wrappers:field_trial",
|
"../../../system_wrappers:field_trial",
|
||||||
"../../../system_wrappers:metrics",
|
"../../../system_wrappers:metrics",
|
||||||
|
"../agc2:clipping_predictor",
|
||||||
|
"../agc2:clipping_predictor_evaluator",
|
||||||
|
"../agc2:gain_map",
|
||||||
"../vad",
|
"../vad",
|
||||||
]
|
]
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
@ -56,48 +56,6 @@ rtc_library("analog_gain_stats_reporter") {
|
|||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("clipping_predictor") {
|
|
||||||
sources = [
|
|
||||||
"clipping_predictor.cc",
|
|
||||||
"clipping_predictor.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":clipping_predictor_level_buffer",
|
|
||||||
":gain_map",
|
|
||||||
"..:api",
|
|
||||||
"..:audio_frame_view",
|
|
||||||
"../../../common_audio",
|
|
||||||
"../../../rtc_base:checks",
|
|
||||||
"../../../rtc_base:logging",
|
|
||||||
"../../../rtc_base:safe_minmax",
|
|
||||||
]
|
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_library("clipping_predictor_evaluator") {
|
|
||||||
sources = [
|
|
||||||
"clipping_predictor_evaluator.cc",
|
|
||||||
"clipping_predictor_evaluator.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
"../../../rtc_base:checks",
|
|
||||||
"../../../rtc_base:logging",
|
|
||||||
]
|
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_library("clipping_predictor_level_buffer") {
|
|
||||||
sources = [
|
|
||||||
"clipping_predictor_level_buffer.cc",
|
|
||||||
"clipping_predictor_level_buffer.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
"../../../rtc_base:checks",
|
|
||||||
"../../../rtc_base:logging",
|
|
||||||
]
|
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_library("level_estimation") {
|
rtc_library("level_estimation") {
|
||||||
sources = [
|
sources = [
|
||||||
"agc.cc",
|
"agc.cc",
|
||||||
@ -147,19 +105,12 @@ rtc_library("legacy_agc") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_source_set("gain_map") {
|
|
||||||
sources = [ "gain_map_internal.h" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtc_include_tests) {
|
if (rtc_include_tests) {
|
||||||
rtc_library("agc_unittests") {
|
rtc_library("agc_unittests") {
|
||||||
testonly = true
|
testonly = true
|
||||||
sources = [
|
sources = [
|
||||||
"agc_manager_direct_unittest.cc",
|
"agc_manager_direct_unittest.cc",
|
||||||
"analog_gain_stats_reporter_unittest.cc",
|
"analog_gain_stats_reporter_unittest.cc",
|
||||||
"clipping_predictor_evaluator_unittest.cc",
|
|
||||||
"clipping_predictor_level_buffer_unittest.cc",
|
|
||||||
"clipping_predictor_unittest.cc",
|
|
||||||
"loudness_histogram_unittest.cc",
|
"loudness_histogram_unittest.cc",
|
||||||
"mock_agc.h",
|
"mock_agc.h",
|
||||||
]
|
]
|
||||||
@ -168,9 +119,6 @@ if (rtc_include_tests) {
|
|||||||
deps = [
|
deps = [
|
||||||
":agc",
|
":agc",
|
||||||
":analog_gain_stats_reporter",
|
":analog_gain_stats_reporter",
|
||||||
":clipping_predictor",
|
|
||||||
":clipping_predictor_evaluator",
|
|
||||||
":clipping_predictor_level_buffer",
|
|
||||||
":gain_control_interface",
|
":gain_control_interface",
|
||||||
":level_estimation",
|
":level_estimation",
|
||||||
"..:mocks",
|
"..:mocks",
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "common_audio/include/audio_util.h"
|
#include "common_audio/include/audio_util.h"
|
||||||
#include "modules/audio_processing/agc/gain_control.h"
|
#include "modules/audio_processing/agc/gain_control.h"
|
||||||
#include "modules/audio_processing/agc/gain_map_internal.h"
|
#include "modules/audio_processing/agc2/gain_map_internal.h"
|
||||||
#include "modules/audio_processing/include/audio_frame_view.h"
|
#include "modules/audio_processing/include/audio_frame_view.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "modules/audio_processing/agc/agc.h"
|
#include "modules/audio_processing/agc/agc.h"
|
||||||
#include "modules/audio_processing/agc/clipping_predictor.h"
|
#include "modules/audio_processing/agc2/clipping_predictor.h"
|
||||||
#include "modules/audio_processing/agc/clipping_predictor_evaluator.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_evaluator.h"
|
||||||
#include "modules/audio_processing/audio_buffer.h"
|
#include "modules/audio_processing/audio_buffer.h"
|
||||||
#include "modules/audio_processing/include/audio_processing.h"
|
#include "modules/audio_processing/include/audio_processing.h"
|
||||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||||
|
|||||||
@ -69,6 +69,51 @@ rtc_library("biquad_filter") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_library("clipping_predictor") {
|
||||||
|
visibility = [
|
||||||
|
"../agc:agc",
|
||||||
|
"./*",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"clipping_predictor.cc",
|
||||||
|
"clipping_predictor.h",
|
||||||
|
"clipping_predictor_level_buffer.cc",
|
||||||
|
"clipping_predictor_level_buffer.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":gain_map",
|
||||||
|
"..:api",
|
||||||
|
"..:audio_frame_view",
|
||||||
|
"../../../common_audio",
|
||||||
|
"../../../rtc_base:checks",
|
||||||
|
"../../../rtc_base:logging",
|
||||||
|
"../../../rtc_base:safe_minmax",
|
||||||
|
]
|
||||||
|
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_library("clipping_predictor_evaluator") {
|
||||||
|
visibility = [
|
||||||
|
"../agc:agc",
|
||||||
|
"./*",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"clipping_predictor_evaluator.cc",
|
||||||
|
"clipping_predictor_evaluator.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"../../../rtc_base:checks",
|
||||||
|
"../../../rtc_base:logging",
|
||||||
|
]
|
||||||
|
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
|
}
|
||||||
|
|
||||||
rtc_source_set("common") {
|
rtc_source_set("common") {
|
||||||
sources = [ "agc2_common.h" ]
|
sources = [ "agc2_common.h" ]
|
||||||
}
|
}
|
||||||
@ -126,6 +171,16 @@ rtc_library("gain_applier") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_source_set("gain_map") {
|
||||||
|
visibility = [
|
||||||
|
"..:analog_mic_simulation",
|
||||||
|
"../agc:agc",
|
||||||
|
"./*",
|
||||||
|
]
|
||||||
|
|
||||||
|
sources = [ "gain_map_internal.h" ]
|
||||||
|
}
|
||||||
|
|
||||||
rtc_library("noise_level_estimator") {
|
rtc_library("noise_level_estimator") {
|
||||||
sources = [
|
sources = [
|
||||||
"noise_level_estimator.cc",
|
"noise_level_estimator.cc",
|
||||||
@ -256,6 +311,29 @@ rtc_library("fixed_digital_unittests") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_library("input_volume_controller_unittests") {
|
||||||
|
testonly = true
|
||||||
|
sources = [
|
||||||
|
"clipping_predictor_evaluator_unittest.cc",
|
||||||
|
"clipping_predictor_level_buffer_unittest.cc",
|
||||||
|
"clipping_predictor_unittest.cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
configs += [ "..:apm_debug_dump" ]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":clipping_predictor",
|
||||||
|
":clipping_predictor_evaluator",
|
||||||
|
":gain_map",
|
||||||
|
"../../../rtc_base:checks",
|
||||||
|
"../../../rtc_base:random",
|
||||||
|
"../../../rtc_base:safe_conversions",
|
||||||
|
"../../../test:test_support",
|
||||||
|
]
|
||||||
|
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
|
}
|
||||||
|
|
||||||
rtc_library("noise_estimator_unittests") {
|
rtc_library("noise_estimator_unittests") {
|
||||||
testonly = true
|
testonly = true
|
||||||
configs += [ "..:apm_debug_dump" ]
|
configs += [ "..:apm_debug_dump" ]
|
||||||
|
|||||||
@ -8,14 +8,14 @@
|
|||||||
* 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 "modules/audio_processing/agc/clipping_predictor.h"
|
#include "modules/audio_processing/agc2/clipping_predictor.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "common_audio/include/audio_util.h"
|
#include "common_audio/include/audio_util.h"
|
||||||
#include "modules/audio_processing/agc/clipping_predictor_level_buffer.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_level_buffer.h"
|
||||||
#include "modules/audio_processing/agc/gain_map_internal.h"
|
#include "modules/audio_processing/agc2/gain_map_internal.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/numerics/safe_minmax.h"
|
#include "rtc_base/numerics/safe_minmax.h"
|
||||||
@ -8,8 +8,8 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_H_
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_H_
|
||||||
#define MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_H_
|
#define MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -46,7 +46,6 @@ class ClippingPredictor {
|
|||||||
int default_step,
|
int default_step,
|
||||||
int min_mic_level,
|
int min_mic_level,
|
||||||
int max_mic_level) const = 0;
|
int max_mic_level) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates a ClippingPredictor based on the provided `config`. When enabled,
|
// Creates a ClippingPredictor based on the provided `config`. When enabled,
|
||||||
@ -60,4 +59,4 @@ std::unique_ptr<ClippingPredictor> CreateClippingPredictor(
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_H_
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_H_
|
||||||
@ -8,7 +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 "modules/audio_processing/agc/clipping_predictor_evaluator.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_evaluator.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -8,8 +8,8 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_EVALUATOR_H_
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_EVALUATOR_H_
|
||||||
#define MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_EVALUATOR_H_
|
#define MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_EVALUATOR_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -119,4 +119,4 @@ absl::optional<ClippingPredictionMetrics> ComputeClippingPredictionMetrics(
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_EVALUATOR_H_
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_EVALUATOR_H_
|
||||||
@ -8,7 +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 "modules/audio_processing/agc/clipping_predictor_evaluator.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_evaluator.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -8,7 +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 "modules/audio_processing/agc/clipping_predictor_level_buffer.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_level_buffer.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -8,8 +8,8 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
||||||
#define MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
#define MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -68,4 +68,4 @@ class ClippingPredictorLevelBuffer {
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // MODULES_AUDIO_PROCESSING_AGC_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_
|
||||||
@ -8,7 +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 "modules/audio_processing/agc/clipping_predictor_level_buffer.h"
|
#include "modules/audio_processing/agc2/clipping_predictor_level_buffer.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -8,7 +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 "modules/audio_processing/agc/clipping_predictor.h"
|
#include "modules/audio_processing/agc2/clipping_predictor.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -8,8 +8,8 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MODULES_AUDIO_PROCESSING_AGC_GAIN_MAP_INTERNAL_H_
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_GAIN_MAP_INTERNAL_H_
|
||||||
#define MODULES_AUDIO_PROCESSING_AGC_GAIN_MAP_INTERNAL_H_
|
#define MODULES_AUDIO_PROCESSING_AGC2_GAIN_MAP_INTERNAL_H_
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -37,4 +37,4 @@ static const int kGainMap[kGainMapSize] = {
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // MODULES_AUDIO_PROCESSING_AGC_GAIN_MAP_INTERNAL_H_
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_GAIN_MAP_INTERNAL_H_
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "modules/audio_processing/agc/gain_map_internal.h"
|
#include "modules/audio_processing/agc2/gain_map_internal.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/numerics/safe_conversions.h"
|
#include "rtc_base/numerics/safe_conversions.h"
|
||||||
#include "rtc_base/numerics/safe_minmax.h"
|
#include "rtc_base/numerics/safe_minmax.h"
|
||||||
@ -94,8 +94,8 @@ class FakeRecordingDeviceLinear final : public FakeRecordingDeviceWorker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
float ComputeAgc1LinearFactor(const absl::optional<int>& undo_mic_level,
|
float ComputeAgcLinearFactor(const absl::optional<int>& undo_mic_level,
|
||||||
int mic_level) {
|
int mic_level) {
|
||||||
// If an undo level is specified, virtually restore the unmodified
|
// If an undo level is specified, virtually restore the unmodified
|
||||||
// microphone level; otherwise simulate the mic gain only.
|
// microphone level; otherwise simulate the mic gain only.
|
||||||
const int undo_level =
|
const int undo_level =
|
||||||
@ -105,14 +105,14 @@ float ComputeAgc1LinearFactor(const absl::optional<int>& undo_mic_level,
|
|||||||
|
|
||||||
// Roughly dB-scale fake recording device. Valid levels are [0, 255]. The mic
|
// Roughly dB-scale fake recording device. Valid levels are [0, 255]. The mic
|
||||||
// applies a gain from kGainMap in agc/gain_map_internal.h.
|
// applies a gain from kGainMap in agc/gain_map_internal.h.
|
||||||
class FakeRecordingDeviceAgc1 final : public FakeRecordingDeviceWorker {
|
class FakeRecordingDeviceAgc final : public FakeRecordingDeviceWorker {
|
||||||
public:
|
public:
|
||||||
explicit FakeRecordingDeviceAgc1(const int initial_mic_level)
|
explicit FakeRecordingDeviceAgc(const int initial_mic_level)
|
||||||
: FakeRecordingDeviceWorker(initial_mic_level) {}
|
: FakeRecordingDeviceWorker(initial_mic_level) {}
|
||||||
~FakeRecordingDeviceAgc1() override = default;
|
~FakeRecordingDeviceAgc() override = default;
|
||||||
void ModifyBufferInt16(rtc::ArrayView<int16_t> buffer) override {
|
void ModifyBufferInt16(rtc::ArrayView<int16_t> buffer) override {
|
||||||
const float scaling_factor =
|
const float scaling_factor =
|
||||||
ComputeAgc1LinearFactor(undo_mic_level_, mic_level_);
|
ComputeAgcLinearFactor(undo_mic_level_, mic_level_);
|
||||||
const size_t number_of_samples = buffer.size();
|
const size_t number_of_samples = buffer.size();
|
||||||
int16_t* data = buffer.data();
|
int16_t* data = buffer.data();
|
||||||
for (size_t i = 0; i < number_of_samples; ++i) {
|
for (size_t i = 0; i < number_of_samples; ++i) {
|
||||||
@ -121,7 +121,7 @@ class FakeRecordingDeviceAgc1 final : public FakeRecordingDeviceWorker {
|
|||||||
}
|
}
|
||||||
void ModifyBufferFloat(ChannelBuffer<float>* buffer) override {
|
void ModifyBufferFloat(ChannelBuffer<float>* buffer) override {
|
||||||
const float scaling_factor =
|
const float scaling_factor =
|
||||||
ComputeAgc1LinearFactor(undo_mic_level_, mic_level_);
|
ComputeAgcLinearFactor(undo_mic_level_, mic_level_);
|
||||||
for (size_t c = 0; c < buffer->num_channels(); ++c) {
|
for (size_t c = 0; c < buffer->num_channels(); ++c) {
|
||||||
for (size_t i = 0; i < buffer->num_frames(); ++i) {
|
for (size_t i = 0; i < buffer->num_frames(); ++i) {
|
||||||
buffer->channels()[c][i] =
|
buffer->channels()[c][i] =
|
||||||
@ -145,7 +145,7 @@ FakeRecordingDevice::FakeRecordingDevice(int initial_mic_level,
|
|||||||
worker_ = std::make_unique<FakeRecordingDeviceLinear>(initial_mic_level);
|
worker_ = std::make_unique<FakeRecordingDeviceLinear>(initial_mic_level);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
worker_ = std::make_unique<FakeRecordingDeviceAgc1>(initial_mic_level);
|
worker_ = std::make_unique<FakeRecordingDeviceAgc>(initial_mic_level);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RTC_DCHECK_NOTREACHED();
|
RTC_DCHECK_NOTREACHED();
|
||||||
|
|||||||
Reference in New Issue
Block a user