Use backticks not vertical bars to denote variables in comments for /modules/audio_processing
Bug: webrtc:12338 Change-Id: I85bff694dd2ead83c939c4d1945eff82e1296001 No-Presubmit: True Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227161 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34690}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
dc6801c618
commit
0b489303d2
@ -26,7 +26,7 @@ using webrtc::TransientDetector;
|
||||
// Creates a send times array, one for each step.
|
||||
// Each block that contains a transient, has an infinite send time.
|
||||
// The resultant array is written to a DAT file
|
||||
// Returns -1 on error or |lost_packets| otherwise.
|
||||
// Returns -1 on error or `lost_packets` otherwise.
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 5) {
|
||||
printf("\n%s - Application to generate a RTP timing file.\n\n", argv[0]);
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
// Returns the proper length of the output buffer that you should use for the
|
||||
// given |in_length| and decimation |odd_sequence|.
|
||||
// given `in_length` and decimation `odd_sequence`.
|
||||
// Return -1 on error.
|
||||
inline size_t GetOutLengthToDyadicDecimate(size_t in_length,
|
||||
bool odd_sequence) {
|
||||
@ -34,10 +34,10 @@ inline size_t GetOutLengthToDyadicDecimate(size_t in_length,
|
||||
// Performs a dyadic decimation: removes every odd/even member of a sequence
|
||||
// halving its overall length.
|
||||
// Arguments:
|
||||
// in: array of |in_length|.
|
||||
// in: array of `in_length`.
|
||||
// odd_sequence: If false, the odd members will be removed (1, 3, 5, ...);
|
||||
// if true, the even members will be removed (0, 2, 4, ...).
|
||||
// out: array of |out_length|. |out_length| must be large enough to
|
||||
// out: array of `out_length`. `out_length` must be large enough to
|
||||
// hold the decimated output. The necessary length can be provided by
|
||||
// GetOutLengthToDyadicDecimate().
|
||||
// Must be previously allocated.
|
||||
|
||||
@ -42,7 +42,7 @@ TEST(DyadicDecimatorTest, DyadicDecimateErrorValues) {
|
||||
static_cast<int16_t*>(NULL), kOutBufferLength);
|
||||
EXPECT_EQ(0u, out_samples);
|
||||
|
||||
// Less than required |out_length|.
|
||||
// Less than required `out_length`.
|
||||
out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
|
||||
false, // Even sequence.
|
||||
test_buffer_out, 2);
|
||||
|
||||
@ -50,63 +50,63 @@ int ConvertFloatToByteArray(float value, uint8_t out_bytes[4]);
|
||||
// Returns 0 if correct, -1 on error.
|
||||
int ConvertDoubleToByteArray(double value, uint8_t out_bytes[8]);
|
||||
|
||||
// Reads |length| 16-bit integers from |file| to |buffer|.
|
||||
// |file| must be previously opened.
|
||||
// Reads `length` 16-bit integers from `file` to `buffer`.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of 16-bit integers read or -1 on error.
|
||||
size_t ReadInt16BufferFromFile(FileWrapper* file,
|
||||
size_t length,
|
||||
int16_t* buffer);
|
||||
|
||||
// Reads |length| 16-bit integers from |file| and stores those values
|
||||
// (converting them) in |buffer|.
|
||||
// |file| must be previously opened.
|
||||
// Reads `length` 16-bit integers from `file` and stores those values
|
||||
// (converting them) in `buffer`.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of 16-bit integers read or -1 on error.
|
||||
size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file,
|
||||
size_t length,
|
||||
float* buffer);
|
||||
|
||||
// Reads |length| 16-bit integers from |file| and stores those values
|
||||
// (converting them) in |buffer|.
|
||||
// |file| must be previously opened.
|
||||
// Reads `length` 16-bit integers from `file` and stores those values
|
||||
// (converting them) in `buffer`.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of 16-bit integers read or -1 on error.
|
||||
size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file,
|
||||
size_t length,
|
||||
double* buffer);
|
||||
|
||||
// Reads |length| floats in binary representation (4 bytes) from |file| to
|
||||
// |buffer|.
|
||||
// |file| must be previously opened.
|
||||
// Reads `length` floats in binary representation (4 bytes) from `file` to
|
||||
// `buffer`.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of floats read or -1 on error.
|
||||
size_t ReadFloatBufferFromFile(FileWrapper* file, size_t length, float* buffer);
|
||||
|
||||
// Reads |length| doubles in binary representation (8 bytes) from |file| to
|
||||
// |buffer|.
|
||||
// |file| must be previously opened.
|
||||
// Reads `length` doubles in binary representation (8 bytes) from `file` to
|
||||
// `buffer`.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of doubles read or -1 on error.
|
||||
size_t ReadDoubleBufferFromFile(FileWrapper* file,
|
||||
size_t length,
|
||||
double* buffer);
|
||||
|
||||
// Writes |length| 16-bit integers from |buffer| in binary representation (2
|
||||
// bytes) to |file|. It flushes |file|, so after this call there are no
|
||||
// Writes `length` 16-bit integers from `buffer` in binary representation (2
|
||||
// bytes) to `file`. It flushes `file`, so after this call there are no
|
||||
// writings pending.
|
||||
// |file| must be previously opened.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of doubles written or -1 on error.
|
||||
size_t WriteInt16BufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
const int16_t* buffer);
|
||||
|
||||
// Writes |length| floats from |buffer| in binary representation (4 bytes) to
|
||||
// |file|. It flushes |file|, so after this call there are no writtings pending.
|
||||
// |file| must be previously opened.
|
||||
// Writes `length` floats from `buffer` in binary representation (4 bytes) to
|
||||
// `file`. It flushes `file`, so after this call there are no writtings pending.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of doubles written or -1 on error.
|
||||
size_t WriteFloatBufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
const float* buffer);
|
||||
|
||||
// Writes |length| doubles from |buffer| in binary representation (8 bytes) to
|
||||
// |file|. It flushes |file|, so after this call there are no writings pending.
|
||||
// |file| must be previously opened.
|
||||
// Writes `length` doubles from `buffer` in binary representation (8 bytes) to
|
||||
// `file`. It flushes `file`, so after this call there are no writings pending.
|
||||
// `file` must be previously opened.
|
||||
// Returns the number of doubles written or -1 on error.
|
||||
size_t WriteDoubleBufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
|
||||
@ -26,13 +26,13 @@ namespace webrtc {
|
||||
// the last values of the moments. When needed.
|
||||
class MovingMoments {
|
||||
public:
|
||||
// Creates a Moving Moments object, that uses the last |length| values
|
||||
// Creates a Moving Moments object, that uses the last `length` values
|
||||
// (including the new value introduced in every new calculation).
|
||||
explicit MovingMoments(size_t length);
|
||||
~MovingMoments();
|
||||
|
||||
// Calculates the new values using |in|. Results will be in the out buffers.
|
||||
// |first| and |second| must be allocated with at least |in_length|.
|
||||
// Calculates the new values using `in`. Results will be in the out buffers.
|
||||
// `first` and `second` must be allocated with at least `in_length`.
|
||||
void CalculateMoments(const float* in,
|
||||
size_t in_length,
|
||||
float* first,
|
||||
@ -40,7 +40,7 @@ class MovingMoments {
|
||||
|
||||
private:
|
||||
size_t length_;
|
||||
// A queue holding the |length_| latest input values.
|
||||
// A queue holding the `length_` latest input values.
|
||||
std::queue<float> queue_;
|
||||
// Sum of the values of the queue.
|
||||
float sum_;
|
||||
|
||||
@ -43,8 +43,8 @@ TransientDetector::TransientDetector(int sample_rate_hz)
|
||||
sample_rate_hz == ts::kSampleRate48kHz);
|
||||
int samples_per_transient = sample_rate_hz * kTransientLengthMs / 1000;
|
||||
// Adjustment to avoid data loss while downsampling, making
|
||||
// |samples_per_chunk_| and |samples_per_transient| always divisible by
|
||||
// |kLeaves|.
|
||||
// `samples_per_chunk_` and `samples_per_transient` always divisible by
|
||||
// `kLeaves`.
|
||||
samples_per_chunk_ -= samples_per_chunk_ % kLeaves;
|
||||
samples_per_transient -= samples_per_transient % kLeaves;
|
||||
|
||||
@ -137,7 +137,7 @@ float TransientDetector::Detect(const float* data,
|
||||
|
||||
// In the current implementation we return the max of the current result and
|
||||
// the previous results, so the high results have a width equals to
|
||||
// |transient_length|.
|
||||
// `transient_length`.
|
||||
return *std::max_element(previous_results_.begin(), previous_results_.end());
|
||||
}
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ class TransientDetector {
|
||||
|
||||
~TransientDetector();
|
||||
|
||||
// Calculates the log-likelihood of the existence of a transient in |data|.
|
||||
// |data_length| has to be equal to |samples_per_chunk_|.
|
||||
// Calculates the log-likelihood of the existence of a transient in `data`.
|
||||
// `data_length` has to be equal to `samples_per_chunk_`.
|
||||
// Returns a value between 0 and 1, as a non linear representation of this
|
||||
// likelihood.
|
||||
// Returns a negative value on error.
|
||||
@ -71,7 +71,7 @@ class TransientDetector {
|
||||
float last_second_moment_[kLeaves];
|
||||
|
||||
// We keep track of the previous results from the previous chunks, so it can
|
||||
// be used to effectively give results according to the |transient_length|.
|
||||
// be used to effectively give results according to the `transient_length`.
|
||||
std::deque<float> previous_results_;
|
||||
|
||||
// Number of chunks that are going to return only zeros at the beginning of
|
||||
|
||||
@ -27,22 +27,22 @@ class TransientSuppressor {
|
||||
int detector_rate_hz,
|
||||
int num_channels) = 0;
|
||||
|
||||
// Processes a |data| chunk, and returns it with keystrokes suppressed from
|
||||
// Processes a `data` chunk, and returns it with keystrokes suppressed from
|
||||
// it. The float format is assumed to be int16 ranged. If there are more than
|
||||
// one channel, the chunks are concatenated one after the other in |data|.
|
||||
// |data_length| must be equal to |data_length_|.
|
||||
// |num_channels| must be equal to |num_channels_|.
|
||||
// A sub-band, ideally the higher, can be used as |detection_data|. If it is
|
||||
// NULL, |data| is used for the detection too. The |detection_data| is always
|
||||
// one channel, the chunks are concatenated one after the other in `data`.
|
||||
// `data_length` must be equal to `data_length_`.
|
||||
// `num_channels` must be equal to `num_channels_`.
|
||||
// A sub-band, ideally the higher, can be used as `detection_data`. If it is
|
||||
// NULL, `data` is used for the detection too. The `detection_data` is always
|
||||
// assumed mono.
|
||||
// If a reference signal (e.g. keyboard microphone) is available, it can be
|
||||
// passed in as |reference_data|. It is assumed mono and must have the same
|
||||
// length as |data|. NULL is accepted if unavailable.
|
||||
// passed in as `reference_data`. It is assumed mono and must have the same
|
||||
// length as `data`. NULL is accepted if unavailable.
|
||||
// This suppressor performs better if voice information is available.
|
||||
// |voice_probability| is the probability of voice being present in this chunk
|
||||
// of audio. If voice information is not available, |voice_probability| must
|
||||
// `voice_probability` is the probability of voice being present in this chunk
|
||||
// of audio. If voice information is not available, `voice_probability` must
|
||||
// always be set to 1.
|
||||
// |key_pressed| determines if a key was pressed on this audio chunk.
|
||||
// `key_pressed` determines if a key was pressed on this audio chunk.
|
||||
// Returns 0 on success and -1 otherwise.
|
||||
virtual int Suppress(float* data,
|
||||
size_t data_length,
|
||||
|
||||
@ -194,7 +194,7 @@ int TransientSuppressorImpl::Suppress(float* data,
|
||||
|
||||
using_reference_ = detector_->using_reference();
|
||||
|
||||
// |detector_smoothed_| follows the |detector_result| when this last one is
|
||||
// `detector_smoothed_` follows the `detector_result` when this last one is
|
||||
// increasing, but has an exponential decaying tail to be able to suppress
|
||||
// the ringing of keyclicks.
|
||||
float smooth_factor = using_reference_ ? 0.6 : 0.1;
|
||||
@ -223,7 +223,7 @@ int TransientSuppressorImpl::Suppress(float* data,
|
||||
}
|
||||
|
||||
// This should only be called when detection is enabled. UpdateBuffers() must
|
||||
// have been called. At return, |out_buffer_| will be filled with the
|
||||
// have been called. At return, `out_buffer_` will be filled with the
|
||||
// processed output.
|
||||
void TransientSuppressorImpl::Suppress(float* in_ptr,
|
||||
float* spectral_mean,
|
||||
@ -325,7 +325,7 @@ void TransientSuppressorImpl::UpdateRestoration(float voice_probability) {
|
||||
}
|
||||
|
||||
// Shift buffers to make way for new data. Must be called after
|
||||
// |detection_enabled_| is updated by UpdateKeypress().
|
||||
// `detection_enabled_` is updated by UpdateKeypress().
|
||||
void TransientSuppressorImpl::UpdateBuffers(float* data) {
|
||||
// TODO(aluebs): Change to ring buffer.
|
||||
memmove(in_buffer_.get(), &in_buffer_[data_length_],
|
||||
@ -350,9 +350,9 @@ void TransientSuppressorImpl::UpdateBuffers(float* data) {
|
||||
}
|
||||
|
||||
// Restores the unvoiced signal if a click is present.
|
||||
// Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds
|
||||
// the spectral mean. The attenuation depends on |detector_smoothed_|.
|
||||
// If a restoration takes place, the |magnitudes_| are updated to the new value.
|
||||
// Attenuates by a certain factor every peak in the `fft_buffer_` that exceeds
|
||||
// the spectral mean. The attenuation depends on `detector_smoothed_`.
|
||||
// If a restoration takes place, the `magnitudes_` are updated to the new value.
|
||||
void TransientSuppressorImpl::HardRestoration(float* spectral_mean) {
|
||||
const float detector_result =
|
||||
1.f - std::pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f);
|
||||
@ -376,10 +376,10 @@ void TransientSuppressorImpl::HardRestoration(float* spectral_mean) {
|
||||
}
|
||||
|
||||
// Restores the voiced signal if a click is present.
|
||||
// Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds
|
||||
// Attenuates by a certain factor every peak in the `fft_buffer_` that exceeds
|
||||
// the spectral mean and that is lower than some function of the current block
|
||||
// frequency mean. The attenuation depends on |detector_smoothed_|.
|
||||
// If a restoration takes place, the |magnitudes_| are updated to the new value.
|
||||
// frequency mean. The attenuation depends on `detector_smoothed_`.
|
||||
// If a restoration takes place, the `magnitudes_` are updated to the new value.
|
||||
void TransientSuppressorImpl::SoftRestoration(float* spectral_mean) {
|
||||
// Get the spectral magnitude mean of the current block.
|
||||
float block_frequency_mean = 0;
|
||||
|
||||
@ -34,22 +34,22 @@ class TransientSuppressorImpl : public TransientSuppressor {
|
||||
int detector_rate_hz,
|
||||
int num_channels) override;
|
||||
|
||||
// Processes a |data| chunk, and returns it with keystrokes suppressed from
|
||||
// Processes a `data` chunk, and returns it with keystrokes suppressed from
|
||||
// it. The float format is assumed to be int16 ranged. If there are more than
|
||||
// one channel, the chunks are concatenated one after the other in |data|.
|
||||
// |data_length| must be equal to |data_length_|.
|
||||
// |num_channels| must be equal to |num_channels_|.
|
||||
// A sub-band, ideally the higher, can be used as |detection_data|. If it is
|
||||
// NULL, |data| is used for the detection too. The |detection_data| is always
|
||||
// one channel, the chunks are concatenated one after the other in `data`.
|
||||
// `data_length` must be equal to `data_length_`.
|
||||
// `num_channels` must be equal to `num_channels_`.
|
||||
// A sub-band, ideally the higher, can be used as `detection_data`. If it is
|
||||
// NULL, `data` is used for the detection too. The `detection_data` is always
|
||||
// assumed mono.
|
||||
// If a reference signal (e.g. keyboard microphone) is available, it can be
|
||||
// passed in as |reference_data|. It is assumed mono and must have the same
|
||||
// length as |data|. NULL is accepted if unavailable.
|
||||
// passed in as `reference_data`. It is assumed mono and must have the same
|
||||
// length as `data`. NULL is accepted if unavailable.
|
||||
// This suppressor performs better if voice information is available.
|
||||
// |voice_probability| is the probability of voice being present in this chunk
|
||||
// of audio. If voice information is not available, |voice_probability| must
|
||||
// `voice_probability` is the probability of voice being present in this chunk
|
||||
// of audio. If voice information is not available, `voice_probability` must
|
||||
// always be set to 1.
|
||||
// |key_pressed| determines if a key was pressed on this audio chunk.
|
||||
// `key_pressed` determines if a key was pressed on this audio chunk.
|
||||
// Returns 0 on success and -1 otherwise.
|
||||
int Suppress(float* data,
|
||||
size_t data_length,
|
||||
|
||||
@ -25,7 +25,7 @@ class WPDNode {
|
||||
WPDNode(size_t length, const float* coefficients, size_t coefficients_length);
|
||||
~WPDNode();
|
||||
|
||||
// Updates the node data. |parent_data| / 2 must be equals to |length_|.
|
||||
// Updates the node data. `parent_data` / 2 must be equals to `length_`.
|
||||
// Returns 0 if correct, and -1 otherwise.
|
||||
int Update(const float* parent_data, size_t parent_data_length);
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ class WPDTree {
|
||||
// If level or index are out of bounds the function will return NULL.
|
||||
WPDNode* NodeAt(int level, int index);
|
||||
|
||||
// Updates all the nodes of the tree with the new data. |data_length| must be
|
||||
// Updates all the nodes of the tree with the new data. `data_length` must be
|
||||
// teh same that was used for the creation of the tree.
|
||||
// Returns 0 if correct, and -1 otherwise.
|
||||
int Update(const float* data, size_t data_length);
|
||||
|
||||
Reference in New Issue
Block a user