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:
pkasting
2015-07-22 15:17:22 -07:00
committed by Commit bot
parent 7c5304c791
commit b297c5a01f
29 changed files with 105 additions and 83 deletions

View File

@ -28,7 +28,7 @@ void WebRtcIlbcfix_CbMemEnergy(
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
int16_t base_size /* (i) Index to where the energy values should be stored */
int16_t base_size /* (i) Index to where energy values should be stored */
);
#endif

View File

@ -70,7 +70,8 @@ void WebRtcIlbcfix_DoThePlc(
/* Maximum 60 samples are correlated, preserve as high accuracy
as possible without getting overflow */
max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual, (int16_t)iLBCdec_inst->blockl);
max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual,
(int16_t)iLBCdec_inst->blockl);
scale3 = (WebRtcSpl_GetSizeInBits(max)<<1) - 25;
if (scale3 < 0) {
scale3 = 0;

View File

@ -27,9 +27,9 @@
int WebRtcIsacfix_DecodeImpl(int16_t *signal_out16,
IsacFixDecoderInstance *ISACdec_obj,
int16_t *current_framesamples)
int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
IsacFixDecoderInstance* ISACdec_obj,
int16_t* current_framesamples)
{
int k;
int err;

View File

@ -777,7 +777,7 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
ISACFIX_SubStruct *ISAC_inst;
/* number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples;
int16_t number_of_samples;
int declen = 0;
/* typecast pointer to real structure */
@ -807,8 +807,8 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples);
declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen < 0) {
/* Some error inside the decoder */
ISAC_inst->errorcode = -(int16_t)declen;
@ -818,14 +818,18 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
/* error check */
if (declen & 0x0001) {
if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) {
if (declen & 1) {
if (len != declen &&
len != declen +
((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
memset(decoded, 0, sizeof(int16_t) * number_of_samples);
return -1;
}
} else {
if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) {
if (len != declen &&
len != declen +
((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) {
ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
memset(decoded, 0, sizeof(int16_t) * number_of_samples);
return -1;
@ -870,7 +874,7 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
ISACFIX_SubStruct *ISAC_inst;
/* twice the number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples;
int16_t number_of_samples;
int declen = 0;
int16_t dummy[FRAMESAMPLES/2];
@ -901,8 +905,8 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples);
declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen < 0) {
/* Some error inside the decoder */
ISAC_inst->errorcode = -(int16_t)declen;
@ -912,14 +916,18 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
/* error check */
if (declen & 0x0001) {
if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) {
if (declen & 1) {
if (len != declen &&
len != declen +
((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
memset(decoded, 0, sizeof(int16_t) * number_of_samples);
return -1;
}
} else {
if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) {
if (len != declen &&
len != declen +
((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) {
ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
memset(decoded, 0, sizeof(int16_t) * number_of_samples);
return -1;
@ -1319,7 +1327,8 @@ int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
/* decode frame length, needed to get to the rateIndex in the bitstream */
err = WebRtcIsacfix_DecodeFrameLen(&streamdata, rateIndex);
int16_t frameLength;
err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength);
if (err<0) // error check
return err;

View File

@ -218,7 +218,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
int16_t lo_hi,
int16_t *lat_outQ0)
{
int ii,n,k,i,u;
int ii, n, k, i, u;
int16_t sthQ15[MAX_AR_MODEL_ORDER];
int16_t cthQ15[MAX_AR_MODEL_ORDER];
int32_t tmp32;

View File

@ -38,7 +38,7 @@ DEFINE_FUNCTION WebRtcIsacfix_FilterArLoop
mov r4, #HALF_SUBFRAMELEN
sub r4, #1 @ Outer loop counter = HALF_SUBFRAMELEN - 1
HALF_SUBFRAME_LOOP: @ for(n = 0; n < HALF_SUBFRAMELEN - 1; n++)
HALF_SUBFRAME_LOOP: @ for (n = 0; n < HALF_SUBFRAMELEN - 1; n++)
ldr r9, [sp, #32] @ Restore the inner loop counter to order_coef
ldrh r5, [r1] @ tmpAR = ar_f_Q0[n+1]
@ -46,7 +46,7 @@ HALF_SUBFRAME_LOOP: @ for(n = 0; n < HALF_SUBFRAMELEN - 1; n++)
add r2, r9, asl #1 @ Restore r2 to &cth_Q15[order_coef]
add r3, r9, asl #1 @ Restore r3 to &sth_Q15[order_coef]
ORDER_COEF_LOOP: @ for(k = order_coef ; k > 0; k--)
ORDER_COEF_LOOP: @ for (k = order_coef; k > 0; k--)
ldrh r7, [r3, #-2]! @ sth_Q15[k - 1]
ldrh r6, [r2, #-2]! @ cth_Q15[k - 1]

View File

@ -624,8 +624,8 @@ int main(int argc, char* argv[])
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in encoder: %d.\n", errtype);
} else {
if (fwrite(streamdata, sizeof(char),
stream_len, outbits) != (size_t)stream_len) {
if (fwrite(streamdata, sizeof(char), stream_len, outbits) !=
(size_t)stream_len) {
return -1;
}
}
@ -731,12 +731,12 @@ int main(int argc, char* argv[])
/* iSAC decoding */
if( lostFrame && framecnt > 0) {
if (nbTest !=2) {
declen = WebRtcIsacfix_DecodePlc(ISAC_main_inst,
decoded, prevFrameSize );
declen =
WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize);
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
declen = WebRtcIsacfix_DecodePlcNb(ISAC_main_inst, decoded,
prevFrameSize );
declen = WebRtcIsacfix_DecodePlcNb(
ISAC_main_inst, decoded, prevFrameSize);
#else
declen = -1;
#endif
@ -755,7 +755,7 @@ int main(int argc, char* argv[])
decoded,
speechType);
/* Error check */
if (err<0 || declen<0 || FL!=declen) {
if (err < 0 || declen < 0 || FL != declen) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decode_B/or getFrameLen: %d.\n", errtype);
}

View File

@ -556,12 +556,13 @@ int main(int argc, char* argv[]) {
else
declen = WebRtcIsacfix_DecodePlcNb(ISACFIX_main_inst, decoded, 1);
} else {
if (nbTest != 2)
if (nbTest != 2) {
declen = WebRtcIsacfix_Decode(ISACFIX_main_inst, streamdata,
stream_len, decoded, speechType);
else
} else {
declen = WebRtcIsacfix_DecodeNb(ISACFIX_main_inst, streamdata,
stream_len, decoded, speechType);
}
}
if (declen <= 0) {
/* exit if returned with error */
@ -582,7 +583,7 @@ int main(int argc, char* argv[]) {
totalsmpls += declen;
totalbits += 8 * stream_len;
kbps = ((double)FS) / ((double)cur_framesmpls) * 8.0 * stream_len / 1000.0;
kbps = (double)FS / (double)cur_framesmpls * 8.0 * stream_len / 1000.0;
fy = fopen("bit_rate.dat", "a");
fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps);
fclose(fy);

View File

@ -750,7 +750,8 @@ int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
streamLenUB + garbageLen, &crc);
#ifndef WEBRTC_ARCH_BIG_ENDIAN
for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) {
encoded[streamLen - LEN_CHECK_SUM_WORD8 + k] = crc >> (24 - k * 8);
encoded[streamLen - LEN_CHECK_SUM_WORD8 + k] =
(uint8_t)(crc >> (24 - k * 8));
}
#else
memcpy(&encoded[streamLenLB + streamLenUB + 1], &crc, LEN_CHECK_SUM_WORD8);

View File

@ -662,8 +662,9 @@ int main(int argc, char* argv[]) {
if (stream_len < 0) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\nError in encoder: %d.\n\n", errtype);
fprintf(stderr, "Error in encoder: %d.\n", errtype);
cout << flush;
exit(0);
}
cur_framesmpls += samplesIn10Ms;
/* exit encoder loop if the encoder returned a bitstream */

View File

@ -350,6 +350,11 @@ int main(int argc, char* argv[]) {
}
rcuStreamLen = WebRtcIsac_GetRedPayload(ISAC_main_inst, payloadRCU);
if (rcuStreamLen < 0) {
fprintf(stderr, "\nError getting RED payload\n");
getc(stdin);
exit(EXIT_FAILURE);
}
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData,
sampFreqKHz * 1000, sampFreqKHz * 1000);

View File

@ -115,7 +115,7 @@ size_t AudioEncoderOpus::MaxEncodedBytes() const {
// Calculate the number of bytes we expect the encoder to produce,
// then multiply by two to give a wide margin for error.
size_t bytes_per_millisecond =
static_cast<size_t>(bitrate_bps_ / (1000 * 8) + 1);
static_cast<size_t>(bitrate_bps_ / (1000 * 8) + 1);
size_t approx_encoded_bytes =
num_10ms_frames_per_packet_ * 10 * bytes_per_millisecond;
return 2 * approx_encoded_bytes;

View File

@ -150,8 +150,7 @@ void PCMFile::Write10MsData(AudioFrame& audio_frame) {
}
} else {
int16_t* stereo_audio = new int16_t[2 * audio_frame.samples_per_channel_];
int k;
for (k = 0; k < audio_frame.samples_per_channel_; k++) {
for (int k = 0; k < audio_frame.samples_per_channel_; k++) {
stereo_audio[k << 1] = audio_frame.data_[k];
stereo_audio[(k << 1) + 1] = audio_frame.data_[k];
}

View File

@ -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);

View File

@ -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;

View File

@ -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|.

View File

@ -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.
}

View File

@ -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;
}
}