[FFmpeg-soc] [soc]: r1591 - amr/amrnbfloatdec.c
superdump
subversion at mplayerhq.hu
Sat Dec 15 22:23:37 CET 2007
Author: superdump
Date: Sat Dec 15 22:23:37 2007
New Revision: 1591
Log:
Conduct overflow detection as in the reference source
Modified:
amr/amrnbfloatdec.c
Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c (original)
+++ amr/amrnbfloatdec.c Sat Dec 15 22:23:37 2007
@@ -958,8 +958,8 @@ static void convolve_circ(float *fixed_v
* @param overflow 16-bit overflow flag
*/
-static void synthesis(AMRContext *p, float *excitation, float *lpc, float *samples, uint8_t overflow) {
- int i, j;
+static int synthesis(AMRContext *p, float *excitation, float *lpc, float *samples, uint8_t overflow) {
+ int i, j, overflow_temp = 0;
// if an overflow has been detected, the pitch vector is scaled down by a
// factor of 4
@@ -1002,7 +1002,14 @@ static void synthesis(AMRContext *p, flo
sample_temp -= lpc[j]*samples[i-j-1];
}
samples[i] = excitation[i] + sample_temp;
+ // Detect overflow
+ if(fabsf(samples[i])>1.0) {
+ overflow_temp = 1;
+ samples[i] = av_clipf(samples[i], -1.0, 1.0);
+ }
}
+
+ return overflow_temp;
}
/*** end of synthesis functions ***/
@@ -1272,15 +1279,13 @@ static int amrnb_decode_frame(AVCodecCon
/*** synthesis ***/
- synthesis(p, p->excitation, p->lpc[subframe], &p->samples_in[LP_FILTER_ORDER], 0);
-
- // Check for overflows
- for(i=0; i<AMR_SUBFRAME_SIZE; i++) {
- if(fabsf(samples[i])>1.0)
- synthesis(p, excitation, lpc, samples, 1);
+ if(synthesis(p, p->excitation, p->lpc[subframe], &p->samples_in[LP_FILTER_ORDER], 0)) {
+ // overflow detected -> rerun synthesis scaling pitch vector down by
+ // a factor of 4, skipping pitch vector contribution emphasis and
+ // adaptive gain control
+ synthesis(p, p->excitation, p->lpc[subframe], &p->samples_in[LP_FILTER_ORDER], 1);
}
-
/*** end of synthesis ***/
// convert float samples to 16-bit integer
More information about the FFmpeg-soc
mailing list