Revert 7266 "WebRtcIsac_Encode and WebRtcIsacfix_Encode: Type en..."
This was causing apparently legitimate failures on the following bots: http://chromegw/i/client.webrtc/builders/Linux64%20Release%20%5Blarge%20tests%5D/builds/2599 http://chromegw/i/client.webrtc/builders/Android%20Tests%20%28KK%20Nexus5%29%28dbg%29/builds/2023 http://chromegw/i/client.webrtc/builders/Android%20Tests%20%28JB%20Nexus7.2%29%28dbg%29/builds/1825 http://chromegw/i/client.webrtc/builders/Android%20Tests%20%28KK%20Nexus5%29/builds/2013 http://chromegw/i/client.webrtc/builders/Android%20Tests%20%28JB%20Nexus7.2%29/builds/1795 > WebRtcIsac_Encode and WebRtcIsacfix_Encode: Type encoded stream as uint8_t > > We have to fix both at once, since there's a macro that calls one of > them or the other. > > BUG=909 > R=andrew@webrtc.org, bjornv@webrtc.org, henrik.lundin@webrtc.org, minyue@webrtc.org > > Review URL: https://webrtc-codereview.appspot.com/19229004 TBR=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/30519004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7267 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -496,7 +496,7 @@ int16_t WebRtcIsac_EncoderInit(ISACStruct* ISAC_main_inst,
|
||||
*/
|
||||
int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
const int16_t* speechIn,
|
||||
uint8_t* encoded) {
|
||||
int16_t* encoded) {
|
||||
float inFrame[FRAMESAMPLES_10ms];
|
||||
int16_t speechInLB[FRAMESAMPLES_10ms];
|
||||
int16_t speechInUB[FRAMESAMPLES_10ms];
|
||||
@ -504,6 +504,7 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
int16_t streamLenUB = 0;
|
||||
int16_t streamLen = 0;
|
||||
int16_t k = 0;
|
||||
uint8_t* ptrEncodedUW8 = (uint8_t*)encoded;
|
||||
int garbageLen = 0;
|
||||
int32_t bottleneck = 0;
|
||||
int16_t bottleneckIdx = 0;
|
||||
@ -642,22 +643,23 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
streamLenUB = 0;
|
||||
}
|
||||
|
||||
memcpy(encoded, instLB->ISACencLB_obj.bitstr_obj.stream, streamLenLB);
|
||||
memcpy(ptrEncodedUW8, instLB->ISACencLB_obj.bitstr_obj.stream, streamLenLB);
|
||||
streamLen = streamLenLB;
|
||||
if (streamLenUB > 0) {
|
||||
encoded[streamLenLB] = streamLenUB + 1 + LEN_CHECK_SUM_WORD8;
|
||||
memcpy(&encoded[streamLenLB + 1],
|
||||
instUB->ISACencUB_obj.bitstr_obj.stream,
|
||||
streamLenUB);
|
||||
streamLen += encoded[streamLenLB];
|
||||
ptrEncodedUW8[streamLenLB] = (uint8_t)(streamLenUB + 1 +
|
||||
LEN_CHECK_SUM_WORD8);
|
||||
memcpy(&ptrEncodedUW8[streamLenLB + 1],
|
||||
instUB->ISACencUB_obj.bitstr_obj.stream, streamLenUB);
|
||||
streamLen += ptrEncodedUW8[streamLenLB];
|
||||
} else {
|
||||
encoded[streamLenLB] = 0;
|
||||
ptrEncodedUW8[streamLenLB] = 0;
|
||||
}
|
||||
} else {
|
||||
if (streamLenLB == 0) {
|
||||
return 0;
|
||||
}
|
||||
memcpy(encoded, instLB->ISACencLB_obj.bitstr_obj.stream, streamLenLB);
|
||||
memcpy(ptrEncodedUW8, instLB->ISACencLB_obj.bitstr_obj.stream,
|
||||
streamLenLB);
|
||||
streamLenUB = 0;
|
||||
streamLen = streamLenLB;
|
||||
}
|
||||
@ -695,11 +697,11 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
* 255 is the max garbage length we can signal using 8 bits. */
|
||||
if ((instISAC->bandwidthKHz == isac8kHz) ||
|
||||
(streamLenUB == 0)) {
|
||||
ptrGarbage = &encoded[streamLenLB];
|
||||
ptrGarbage = &ptrEncodedUW8[streamLenLB];
|
||||
limit = streamLen + 255;
|
||||
} else {
|
||||
ptrGarbage = &encoded[streamLenLB + 1 + streamLenUB];
|
||||
limit = streamLen + (255 - encoded[streamLenLB]);
|
||||
ptrGarbage = &ptrEncodedUW8[streamLenLB + 1 + streamLenUB];
|
||||
limit = streamLen + (255 - ptrEncodedUW8[streamLenLB]);
|
||||
}
|
||||
minBytes = (minBytes > limit) ? limit : minBytes;
|
||||
|
||||
@ -716,12 +718,13 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
* That is the only way to preserve backward compatibility. */
|
||||
if ((instISAC->bandwidthKHz == isac8kHz) ||
|
||||
(streamLenUB == 0)) {
|
||||
encoded[streamLenLB] = garbageLen;
|
||||
ptrEncodedUW8[streamLenLB] = (uint8_t)garbageLen;
|
||||
} else {
|
||||
encoded[streamLenLB] += garbageLen;
|
||||
ptrEncodedUW8[streamLenLB] += (uint8_t)garbageLen;
|
||||
/* Write the length of the garbage at the end of the upper-band
|
||||
* bit-stream, if exists. This helps for sanity check. */
|
||||
encoded[streamLenLB + 1 + streamLenUB] = garbageLen;
|
||||
ptrEncodedUW8[streamLenLB + 1 + streamLenUB] =
|
||||
(uint8_t)garbageLen;
|
||||
|
||||
}
|
||||
streamLen += garbageLen;
|
||||
@ -738,14 +741,16 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
|
||||
if ((instISAC->bandwidthKHz != isac8kHz) && (streamLenUB > 0)) {
|
||||
uint32_t crc;
|
||||
|
||||
WebRtcIsac_GetCrc((int16_t*)(&(encoded[streamLenLB + 1])),
|
||||
WebRtcIsac_GetCrc((int16_t*)(&(ptrEncodedUW8[streamLenLB + 1])),
|
||||
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);
|
||||
ptrEncodedUW8[streamLen - LEN_CHECK_SUM_WORD8 + k] =
|
||||
(uint8_t)((crc >> (24 - k * 8)) & 0xFF);
|
||||
}
|
||||
#else
|
||||
memcpy(&encoded[streamLenLB + streamLenUB + 1], &crc, LEN_CHECK_SUM_WORD8);
|
||||
memcpy(&ptrEncodedUW8[streamLenLB + streamLenUB + 1], &crc,
|
||||
LEN_CHECK_SUM_WORD8);
|
||||
#endif
|
||||
}
|
||||
return streamLen;
|
||||
|
||||
@ -31,7 +31,7 @@ class IsacTest : public ::testing::Test {
|
||||
|
||||
int16_t speech_data_[kIsacNumberOfSamples];
|
||||
int16_t output_data_[kIsacNumberOfSamples];
|
||||
uint8_t bitstream_[kMaxBytes];
|
||||
int16_t bitstream_[kMaxBytes / 2];
|
||||
uint8_t bitstream_small_[7]; // Simulate sync packets.
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user