Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c

Issue 2255203002: iLBC: Handle a case of bad input data (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: bool test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c b/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
index b8a067e0f3d5d4dfcea879e1efdd5b9d83dfb35b..dd5c353cb53e420d7b421c0edea7b7da3dbcf384 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
@@ -16,6 +16,8 @@
******************************************************************/
+#include "decode_residual.h"
+
#include <string.h>
#include "defines.h"
@@ -32,7 +34,7 @@
* frame residual decoder function (subrutine to iLBC_decode)
*---------------------------------------------------------------*/
-void WebRtcIlbcfix_DecodeResidual(
+bool WebRtcIlbcfix_DecodeResidual(
IlbcDecoder *iLBCdec_inst,
/* (i/o) the decoder state structure */
iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used
@@ -72,11 +74,11 @@ void WebRtcIlbcfix_DecodeResidual(
/* construct decoded vector */
- WebRtcIlbcfix_CbConstruct(
- &decresidual[start_pos+iLBCdec_inst->state_short_len],
- iLBC_encbits->cb_index, iLBC_encbits->gain_index,
- mem+CB_MEML-ST_MEM_L_TBL,
- ST_MEM_L_TBL, diff);
+ if (!WebRtcIlbcfix_CbConstruct(
+ &decresidual[start_pos + iLBCdec_inst->state_short_len],
+ iLBC_encbits->cb_index, iLBC_encbits->gain_index,
+ mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, diff))
+ return false; // Error.
}
else {/* put adaptive part in the beginning */
@@ -90,12 +92,11 @@ void WebRtcIlbcfix_DecodeResidual(
/* construct decoded vector */
- WebRtcIlbcfix_CbConstruct(
- reverseDecresidual,
- iLBC_encbits->cb_index, iLBC_encbits->gain_index,
- mem+CB_MEML-ST_MEM_L_TBL,
- ST_MEM_L_TBL, diff
- );
+ if (!WebRtcIlbcfix_CbConstruct(reverseDecresidual, iLBC_encbits->cb_index,
+ iLBC_encbits->gain_index,
+ mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL,
+ diff))
+ return false; // Error.
/* get decoded residual from reversed vector */
@@ -122,12 +123,12 @@ void WebRtcIlbcfix_DecodeResidual(
for (subframe=0; subframe<Nfor; subframe++) {
/* construct decoded vector */
- WebRtcIlbcfix_CbConstruct(
- &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL],
- iLBC_encbits->cb_index+subcount*CB_NSTAGES,
- iLBC_encbits->gain_index+subcount*CB_NSTAGES,
- mem, MEM_LF_TBL, SUBL
- );
+ if (!WebRtcIlbcfix_CbConstruct(
+ &decresidual[(iLBC_encbits->startIdx + 1 + subframe) * SUBL],
+ iLBC_encbits->cb_index + subcount * CB_NSTAGES,
+ iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL,
+ SUBL))
+ return false; // Error;
/* update memory */
memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem));
@@ -160,12 +161,12 @@ void WebRtcIlbcfix_DecodeResidual(
for (subframe=0; subframe<Nback; subframe++) {
/* construct decoded vector */
- WebRtcIlbcfix_CbConstruct(
- &reverseDecresidual[subframe*SUBL],
- iLBC_encbits->cb_index+subcount*CB_NSTAGES,
- iLBC_encbits->gain_index+subcount*CB_NSTAGES,
- mem, MEM_LF_TBL, SUBL
- );
+ if (!WebRtcIlbcfix_CbConstruct(
+ &reverseDecresidual[subframe * SUBL],
+ iLBC_encbits->cb_index + subcount * CB_NSTAGES,
+ iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL,
+ SUBL))
+ return false; // Error.
/* update memory */
memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem));
@@ -179,4 +180,6 @@ void WebRtcIlbcfix_DecodeResidual(
WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1,
reverseDecresidual, SUBL*Nback);
}
+
+ return true; // Success.
}
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/decode_residual.h ('k') | webrtc/modules/audio_coding/codecs/ilbc/encode.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698