AGC2 NoiseLevelEstimator: DCHECK pointer
Bug: webrtc:7494 Change-Id: Iaac36bade3da4cfa55e8de99cfd3836df75dffa3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286423 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Hanna Silen <silen@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38828}
This commit is contained in:
parent
ce79f873e7
commit
0524319a9d
@ -72,6 +72,7 @@ class NoiseFloorEstimator : public NoiseLevelEstimator {
|
|||||||
"noise levels.");
|
"noise levels.");
|
||||||
|
|
||||||
NoiseFloorEstimator(ApmDataDumper* data_dumper) : data_dumper_(data_dumper) {
|
NoiseFloorEstimator(ApmDataDumper* data_dumper) : data_dumper_(data_dumper) {
|
||||||
|
RTC_DCHECK(data_dumper_);
|
||||||
// Initially assume that 48 kHz will be used. `Analyze()` will detect the
|
// Initially assume that 48 kHz will be used. `Analyze()` will detect the
|
||||||
// used sample rate and call `Initialize()` again if needed.
|
// used sample rate and call `Initialize()` again if needed.
|
||||||
Initialize(/*sample_rate_hz=*/48000);
|
Initialize(/*sample_rate_hz=*/48000);
|
||||||
@ -91,8 +92,9 @@ class NoiseFloorEstimator : public NoiseLevelEstimator {
|
|||||||
const float frame_energy = FrameEnergy(frame);
|
const float frame_energy = FrameEnergy(frame);
|
||||||
if (frame_energy <= min_noise_energy_) {
|
if (frame_energy <= min_noise_energy_) {
|
||||||
// Ignore frames when muted or below the minimum measurable energy.
|
// Ignore frames when muted or below the minimum measurable energy.
|
||||||
data_dumper_->DumpRaw("agc2_noise_floor_estimator_preliminary_level",
|
if (data_dumper_)
|
||||||
noise_energy_);
|
data_dumper_->DumpRaw("agc2_noise_floor_estimator_preliminary_level",
|
||||||
|
noise_energy_);
|
||||||
return EnergyToDbfs(noise_energy_,
|
return EnergyToDbfs(noise_energy_,
|
||||||
static_cast<int>(frame.samples_per_channel()));
|
static_cast<int>(frame.samples_per_channel()));
|
||||||
}
|
}
|
||||||
@ -104,8 +106,9 @@ class NoiseFloorEstimator : public NoiseLevelEstimator {
|
|||||||
preliminary_noise_energy_ = frame_energy;
|
preliminary_noise_energy_ = frame_energy;
|
||||||
preliminary_noise_energy_set_ = true;
|
preliminary_noise_energy_set_ = true;
|
||||||
}
|
}
|
||||||
data_dumper_->DumpRaw("agc2_noise_floor_estimator_preliminary_level",
|
if (data_dumper_)
|
||||||
preliminary_noise_energy_);
|
data_dumper_->DumpRaw("agc2_noise_floor_estimator_preliminary_level",
|
||||||
|
preliminary_noise_energy_);
|
||||||
|
|
||||||
if (counter_ == 0) {
|
if (counter_ == 0) {
|
||||||
// Full period observed.
|
// Full period observed.
|
||||||
@ -128,8 +131,13 @@ class NoiseFloorEstimator : public NoiseLevelEstimator {
|
|||||||
noise_energy_ = std::min(noise_energy_, preliminary_noise_energy_);
|
noise_energy_ = std::min(noise_energy_, preliminary_noise_energy_);
|
||||||
counter_--;
|
counter_--;
|
||||||
}
|
}
|
||||||
return EnergyToDbfs(noise_energy_,
|
|
||||||
static_cast<int>(frame.samples_per_channel()));
|
float noise_rms_dbfs = EnergyToDbfs(
|
||||||
|
noise_energy_, static_cast<int>(frame.samples_per_channel()));
|
||||||
|
if (data_dumper_)
|
||||||
|
data_dumper_->DumpRaw("agc2_noise_rms_dbfs", noise_rms_dbfs);
|
||||||
|
|
||||||
|
return noise_rms_dbfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user