Miscellaneous changes split from https://codereview.webrtc.org/1230503003 .
These are mostly trivial changes and are separated out just to reduce the diff on that change to the minimum possible. Note explanatory comments on patch set 1. BUG=none TEST=none Review URL: https://codereview.webrtc.org/1235643003 Cr-Commit-Position: refs/heads/master@{#9617}
This commit is contained in:
@ -256,16 +256,14 @@ int AudioDecoderG722Stereo::DecodeInternal(const uint8_t* encoded,
|
||||
static_cast<int16_t>(encoded_len / 2),
|
||||
&decoded[decoded_len], &temp_type);
|
||||
if (ret == decoded_len) {
|
||||
decoded_len += ret;
|
||||
ret += decoded_len; // Return total number of samples.
|
||||
// Interleave output.
|
||||
for (int k = decoded_len / 2; k < decoded_len; k++) {
|
||||
for (int k = ret / 2; k < ret; k++) {
|
||||
int16_t temp = decoded[k];
|
||||
memmove(&decoded[2 * k - decoded_len + 2],
|
||||
&decoded[2 * k - decoded_len + 1],
|
||||
(decoded_len - k - 1) * sizeof(int16_t));
|
||||
decoded[2 * k - decoded_len + 1] = temp;
|
||||
memmove(&decoded[2 * k - ret + 2], &decoded[2 * k - ret + 1],
|
||||
(ret - k - 1) * sizeof(int16_t));
|
||||
decoded[2 * k - ret + 1] = temp;
|
||||
}
|
||||
ret = decoded_len; // Return total number of samples.
|
||||
}
|
||||
}
|
||||
*speech_type = ConvertSpeechType(temp_type);
|
||||
|
||||
@ -117,7 +117,7 @@ void DspHelper::PeakDetection(int16_t* data, int data_length,
|
||||
peak_index[i] = WebRtcSpl_MaxIndexW16(data, data_length - 1);
|
||||
|
||||
if (i != num_peaks - 1) {
|
||||
min_index = std::max(0, peak_index[i] - 2);
|
||||
min_index = (peak_index[i] > 2) ? (peak_index[i] - 2) : 0;
|
||||
max_index = std::min(data_length - 1, peak_index[i] + 2);
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult,
|
||||
int DspHelper::MinDistortion(const int16_t* signal, int min_lag,
|
||||
int max_lag, int length,
|
||||
int32_t* distortion_value) {
|
||||
int best_index = -1;
|
||||
int best_index = 0;
|
||||
int32_t min_distortion = WEBRTC_SPL_WORD32_MAX;
|
||||
for (int i = min_lag; i <= max_lag; i++) {
|
||||
int32_t sum_diff = 0;
|
||||
|
||||
@ -441,8 +441,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
|
||||
&audio_history[signal_length - correlation_length - start_index
|
||||
- correlation_lags],
|
||||
correlation_length + start_index + correlation_lags - 1);
|
||||
correlation_scale = ((31 - WebRtcSpl_NormW32(signal_max * signal_max))
|
||||
+ (31 - WebRtcSpl_NormW32(correlation_length))) - 31;
|
||||
correlation_scale = (31 - WebRtcSpl_NormW32(signal_max * signal_max)) +
|
||||
(31 - WebRtcSpl_NormW32(correlation_length)) - 31;
|
||||
correlation_scale = std::max(0, correlation_scale);
|
||||
|
||||
// Calculate the correlation, store in |correlation_vector2|.
|
||||
|
||||
@ -255,7 +255,7 @@ int PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database,
|
||||
continue;
|
||||
}
|
||||
int duration =
|
||||
decoder->PacketDuration(packet->payload, packet->payload_length);
|
||||
decoder->PacketDuration(packet->payload, packet->payload_length);
|
||||
if (duration >= 0) {
|
||||
last_duration = duration; // Save the most up-to-date (valid) duration.
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ int main(int argc, char* argv[]) {
|
||||
printf("Packet size %d must be positive", packet_size);
|
||||
return -1;
|
||||
}
|
||||
printf("Packet size: %i\n", packet_size);
|
||||
printf("Packet size: %d\n", packet_size);
|
||||
|
||||
// check for stereo
|
||||
if (argv[4][strlen(argv[4]) - 1] == '*') {
|
||||
@ -1572,29 +1572,31 @@ int NetEQTest_encode(int coder,
|
||||
if (useVAD) {
|
||||
*vad = 0;
|
||||
|
||||
int sampleRate_10 = 10 * sampleRate / 1000;
|
||||
int sampleRate_20 = 20 * sampleRate / 1000;
|
||||
int sampleRate_30 = 30 * sampleRate / 1000;
|
||||
for (int k = 0; k < numChannels; k++) {
|
||||
tempLen = frameLen;
|
||||
tempdata = &indata[k * frameLen];
|
||||
int localVad = 0;
|
||||
/* Partition the signal and test each chunk for VAD.
|
||||
All chunks must be VAD=0 to produce a total VAD=0. */
|
||||
while (tempLen >= 10 * sampleRate / 1000) {
|
||||
if ((tempLen % 30 * sampleRate / 1000) ==
|
||||
0) { // tempLen is multiple of 30ms
|
||||
while (tempLen >= sampleRate_10) {
|
||||
if ((tempLen % sampleRate_30) == 0) { // tempLen is multiple of 30ms
|
||||
localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata,
|
||||
30 * sampleRate / 1000);
|
||||
tempdata += 30 * sampleRate / 1000;
|
||||
tempLen -= 30 * sampleRate / 1000;
|
||||
} else if (tempLen >= 20 * sampleRate / 1000) { // tempLen >= 20ms
|
||||
sampleRate_30);
|
||||
tempdata += sampleRate_30;
|
||||
tempLen -= sampleRate_30;
|
||||
} else if (tempLen >= sampleRate_20) { // tempLen >= 20ms
|
||||
localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata,
|
||||
20 * sampleRate / 1000);
|
||||
tempdata += 20 * sampleRate / 1000;
|
||||
tempLen -= 20 * sampleRate / 1000;
|
||||
sampleRate_20);
|
||||
tempdata += sampleRate_20;
|
||||
tempLen -= sampleRate_20;
|
||||
} else { // use 10ms
|
||||
localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata,
|
||||
10 * sampleRate / 1000);
|
||||
tempdata += 10 * sampleRate / 1000;
|
||||
tempLen -= 10 * sampleRate / 1000;
|
||||
sampleRate_10);
|
||||
tempdata += sampleRate_10;
|
||||
tempLen -= sampleRate_10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user