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:
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user