Add boundary checking to supress gcc 4.8.3 warning.

BUG=2888
Test=try, voe_cmd_test

R=tina.legrand@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/8389004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5526 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turaj@webrtc.org 2014-02-11 16:38:45 +00:00
parent fc320466d1
commit a80be4b23c
3 changed files with 32 additions and 24 deletions

View File

@ -1449,13 +1449,18 @@ void WebRtcIsac_EncodeRc(int16_t* RCQ15, Bitstr* streamdata) {
/* quantize reflection coefficients (add noise feedback?) */
for (k = 0; k < AR_ORDER; k++) {
index[k] = WebRtcIsac_kQArRcInitIndex[k];
// The safe-guards in following while conditions are to suppress gcc 4.8.3
// warnings, Issue 2888. Otherwise, first and last elements of
// |WebRtcIsac_kQArBoundaryLevels| are such that the following search
// *never* cause an out-of-boundary read.
if (RCQ15[k] > WebRtcIsac_kQArBoundaryLevels[index[k]]) {
while (RCQ15[k] > WebRtcIsac_kQArBoundaryLevels[index[k] + 1]) {
while (index[k] + 1 < NUM_AR_RC_QUANT_BAUNDARY &&
RCQ15[k] > WebRtcIsac_kQArBoundaryLevels[index[k] + 1]) {
index[k]++;
}
} else {
while (RCQ15[k] < WebRtcIsac_kQArBoundaryLevels[--index[k]]) ;
while (index[k] > 0 &&
RCQ15[k] < WebRtcIsac_kQArBoundaryLevels[--index[k]]) ;
}
RCQ15[k] = *(WebRtcIsac_kQArRcLevelsPtr[k] + index[k]);
}

View File

@ -13,68 +13,69 @@
/********************* AR Coefficient Tables ************************/
/* cdf for quantized reflection coefficient 1 */
const uint16_t WebRtcIsac_kQArRc1Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc1Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 129, 7707, 57485, 65495, 65527, 65529, 65531,
65533, 65535};
/* cdf for quantized reflection coefficient 2 */
const uint16_t WebRtcIsac_kQArRc2Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc2Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 7, 531, 25298, 64525, 65526, 65529, 65531,
65533, 65535};
/* cdf for quantized reflection coefficient 3 */
const uint16_t WebRtcIsac_kQArRc3Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc3Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 6, 620, 22898, 64843, 65527, 65529, 65531,
65533, 65535};
/* cdf for quantized reflection coefficient 4 */
const uint16_t WebRtcIsac_kQArRc4Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc4Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 6, 35, 10034, 60733, 65506, 65529, 65531,
65533, 65535};
/* cdf for quantized reflection coefficient 5 */
const uint16_t WebRtcIsac_kQArRc5Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc5Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 6, 36, 7567, 56727, 65385, 65529, 65531,
65533, 65535};
/* cdf for quantized reflection coefficient 6 */
const uint16_t WebRtcIsac_kQArRc6Cdf[12] = {
const uint16_t WebRtcIsac_kQArRc6Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
0, 2, 4, 6, 14, 6579, 57360, 65409, 65529, 65531,
65533, 65535};
/* representation levels for quantized reflection coefficient 1 */
const int16_t WebRtcIsac_kQArRc1Levels[11] = {
const int16_t WebRtcIsac_kQArRc1Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29007, -23202, -15496, -9279, -2577, 5934, 17535, 24512, 29503, 32104
};
/* representation levels for quantized reflection coefficient 2 */
const int16_t WebRtcIsac_kQArRc2Levels[11] = {
const int16_t WebRtcIsac_kQArRc2Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29503, -23494, -15261, -7309, -1399, 6158, 16381, 24512, 29503, 32104
};
/* representation levels for quantized reflection coefficient 3 */
const int16_t WebRtcIsac_kQArRc3Levels[11] = {
const int16_t WebRtcIsac_kQArRc3Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29503, -23157, -15186, -7347, -1359, 5829, 17535, 24512, 29503, 32104
};
/* representation levels for quantized reflection coefficient 4 */
const int16_t WebRtcIsac_kQArRc4Levels[11] = {
const int16_t WebRtcIsac_kQArRc4Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29503, -24512, -15362, -6665, -342, 6596, 14585, 24512, 29503, 32104
};
/* representation levels for quantized reflection coefficient 5 */
const int16_t WebRtcIsac_kQArRc5Levels[11] = {
const int16_t WebRtcIsac_kQArRc5Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29503, -24512, -15005, -6564, -106, 7123, 14920, 24512, 29503, 32104
};
/* representation levels for quantized reflection coefficient 6 */
const int16_t WebRtcIsac_kQArRc6Levels[11] = {
const int16_t WebRtcIsac_kQArRc6Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
-32104, -29503, -24512, -15096, -6656, -37, 7036, 14847, 24512, 29503, 32104
};
/* quantization boundary levels for reflection coefficients */
const int16_t WebRtcIsac_kQArBoundaryLevels[12] = {
-32768, -31441, -27566, -21458, -13612, -4663, 4663, 13612, 21458, 27566, 31441, 32767
const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY] = {
-32768, -31441, -27566, -21458, -13612, -4663, 4663, 13612, 21458, 27566, 31441,
32767
};
/* initial index for AR reflection coefficient quantizer and cdf table search */

View File

@ -21,27 +21,29 @@
#include "structs.h"
#define NUM_AR_RC_QUANT_BAUNDARY 12
/********************* AR Coefficient Tables ************************/
/* cdf for quantized reflection coefficient 1 */
extern const uint16_t WebRtcIsac_kQArRc1Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc1Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* cdf for quantized reflection coefficient 2 */
extern const uint16_t WebRtcIsac_kQArRc2Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc2Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* cdf for quantized reflection coefficient 3 */
extern const uint16_t WebRtcIsac_kQArRc3Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc3Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* cdf for quantized reflection coefficient 4 */
extern const uint16_t WebRtcIsac_kQArRc4Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc4Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* cdf for quantized reflection coefficient 5 */
extern const uint16_t WebRtcIsac_kQArRc5Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc5Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* cdf for quantized reflection coefficient 6 */
extern const uint16_t WebRtcIsac_kQArRc6Cdf[12];
extern const uint16_t WebRtcIsac_kQArRc6Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* quantization boundary levels for reflection coefficients */
extern const int16_t WebRtcIsac_kQArBoundaryLevels[12];
extern const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY];
/* initial indices for AR reflection coefficient quantizer and cdf table search */
extern const uint16_t WebRtcIsac_kQArRcInitIndex[AR_ORDER];