[FFmpeg-soc] [soc]: r1532 - amr/amrnbfloatdec.c

superdump subversion at mplayerhq.hu
Tue Dec 4 18:28:28 CET 2007


Author: superdump
Date: Tue Dec  4 18:28:27 2007
New Revision: 1532

Log:
Update buffers and history etc at the end of decoding a subframe


Modified:
   amr/amrnbfloatdec.c

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	(original)
+++ amr/amrnbfloatdec.c	Tue Dec  4 18:28:27 2007
@@ -982,6 +982,41 @@ static void synthesis(AMRContext *p, flo
 /*** end of synthesis functions ***/
 
 
+/*** update functions ***/
+
+/**
+ * Update buffers and history at the end of decoding a subframe
+ *
+ * @param p             pointer to the AMRContext
+ */
+
+static void update_state(AMRContext *p) {
+    // update the excitation buffer moving the current values into the buffer
+    // pushing out those no longer needed
+    memmove(&p->excitation_buf[0], &p->excitation_buf[AMR_SUBFRAME_SIZE],
+        (PITCH_LAG_MAX + LP_FILTER_ORDER + 1)*sizeof(float));
+
+    // update quantified prediction error energy history
+    p->prediction_error[0] = p->prediction_error[1];
+    p->prediction_error[1] = p->prediction_error[2];
+    p->prediction_error[2] = p->prediction_error[3];
+    p->prediction_error[3] = 20.0*log10f(p->fixed_gain_factor);
+
+    // update gain history
+    memmove(&p->pitch_gain[0], &p->pitch_gain[1], 4*sizeof(float));
+    memmove(&p->fixed_gain[0], &p->fixed_gain[1], 4*sizeof(float));
+
+    // update ir filter strength history
+    p->ir_filter_strength[0] = p->ir_filter_strength[1];
+
+    // update speech sample history
+    memmove(&p->samples_in[0], &p->samples_in[LP_FILTER_ORDER],
+        AMR_SUBFRAME_SIZE*sizeof(float));
+}
+
+/*** end of update functions ***/
+
+
 static int amrnb_decode_frame(AVCodecContext *avctx,
         void *data, int *data_size, uint8_t *buf, int buf_size) {
 
@@ -1216,6 +1251,9 @@ static int amrnb_decode_frame(AVCodecCon
         p->dsp.float_to_int16(p->samples_out, p->samples_in, AMR_SUBFRAME_SIZE);
         memcpy(buf_out, p->samples_out, AMR_SUBFRAME_SIZE*sizeof(int16_t));
 
+        // update buffers and history
+        update_state(p);
+
     }
 
     /* Report how many samples we got */



More information about the FFmpeg-soc mailing list