[FFmpeg-soc] [soc]: r1540 - in amr: amrnbfloatdata.h amrnbfloatdec.c

superdump subversion at mplayerhq.hu
Sun Dec 9 23:25:25 CET 2007


Author: superdump
Date: Sun Dec  9 23:25:24 2007
New Revision: 1540

Log:
Initialise values used for prediction. Values taken from ref source and
converted as per the comments


Modified:
   amr/amrnbfloatdata.h
   amr/amrnbfloatdec.c

Modified: amr/amrnbfloatdata.h
==============================================================================
--- amr/amrnbfloatdata.h	(original)
+++ amr/amrnbfloatdata.h	Sun Dec  9 23:25:24 2007
@@ -1812,6 +1812,8 @@ static const uint8_t gray_decode[8] = { 
 
 // gain tables
 
+#define MIN_ENERGY -0.875
+
 // scalar quantised pitch gain table for 7.95 and 12.2 kbps modes
 static const float qua_gain_pit[16] = {
 0.0             , 0.20001220703125, 0.400146484375  , 0.5             ,

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	(original)
+++ amr/amrnbfloatdec.c	Sun Dec  9 23:25:24 2007
@@ -88,6 +88,41 @@ typedef struct AMRContext {
 } AMRContext;
 
 
+static void reset_state(AMRContext *p) {
+    int i;
+
+    // initialise values for the lsp vector from the 4th subframe of the
+    // previous subframe values
+    // taken from Decoder_amr_reset using (val<<10)/16777216.0
+    p->prev_lsp_sub4[0] = 1.8310546875;
+    p->prev_lsp_sub4[1] = 1.5869140625;
+    p->prev_lsp_sub4[2] = 1.28173828125;
+    p->prev_lsp_sub4[3] = 0.91552734375;
+    p->prev_lsp_sub4[4] = 0.48828125;
+    p->prev_lsp_sub4[5] = 0;
+    p->prev_lsp_sub4[6] = -0.48828125;
+    p->prev_lsp_sub4[7] = -0.91552734375;
+    p->prev_lsp_sub4[8] = -1.28173828125;
+    p->prev_lsp_sub4[9] = -1.5869140625;
+
+    // initialise mean lsp values
+    // taken from Decoder_amr_reset using (val<<10)/16777216.0
+    p->lsp_avg[0] = 0.08447265625;
+    p->lsp_avg[1] = 0.12677001953125;
+    p->lsp_avg[2] = 0.208740234375;
+    p->lsp_avg[3] = 0.311767578125;
+    p->lsp_avg[4] = 0.4114990234375;
+    p->lsp_avg[5] = 0.4957275390625;
+    p->lsp_avg[6] = 0.60198974609375;
+    p->lsp_avg[7] = 0.677001953125;
+    p->lsp_avg[8] = 0.7760009765625;
+    p->lsp_avg[9] = 0.83624267578125;
+
+    for(i=0; i<4; i++) {
+        p->prediction_error[i] = MIN_ENERGY;
+    }
+}
+
 static int amrnb_decode_init(AVCodecContext *avctx) {
     AMRContext *p = avctx->priv_data;
 
@@ -112,6 +147,8 @@ static int amrnb_decode_init(AVCodecCont
     // p->excitation always points to the same position in p->excitation_buf
     p->excitation = &p->excitation_buf[PITCH_LAG_MAX + LP_FILTER_ORDER + 1];
 
+    reset_state(p);
+
     /* return 0 for a successful init, -1 for failure */
     return 0;
 }



More information about the FFmpeg-soc mailing list