[FFmpeg-soc] [soc]: r1103 - in qcelp: qcelpdata.h qcelpdec.c

reynaldo subversion at mplayerhq.hu
Mon Aug 20 23:30:07 CEST 2007


Author: reynaldo
Date: Mon Aug 20 23:30:06 2007
New Revision: 1103

Log:
Fix spec omission at codebook vector computation formula

Modified:
   qcelp/qcelpdata.h
   qcelp/qcelpdec.c

Modified: qcelp/qcelpdata.h
==============================================================================
--- qcelp/qcelpdata.h	(original)
+++ qcelp/qcelpdata.h	Mon Aug 20 23:30:06 2007
@@ -36,6 +36,22 @@
 
 #define FIX_SPEC_PREDICTOR(p) (p-6)
 
+/**
+ * TIA/EIA/IS-733 Spec has an omission on the codebook index determination
+ * formula for RATE_FULL and RATE_HALF frames at section 2.4.8.1.1. It says
+ * you have to subtract the decoded index parameter to the given scaled
+ * codebook vector index 'n' to get the desired circular codebook index but
+ * It doesn't tell you have to clamp 'n' to [0-9] in order to get RI complaint
+ * results.
+ *
+ * The reason for this mistake seems to be the fact they forget to tell you
+ * have to do this calculations per codebook subframe and adjust given equation
+ * values accordingly -- If not were by the obvious 'counting till 10' detail,
+ * the given formula is simply not clear enough without this missing info.
+ */
+
+#define FIX_SPEC_MISSING_CLAMP(n) ((n<9)? n+1:0)
+
 typedef enum
 {
     RATE_FULL   = 0,

Modified: qcelp/qcelpdec.c
==============================================================================
--- qcelp/qcelpdec.c	(original)
+++ qcelp/qcelpdec.c	Mon Aug 20 23:30:06 2007
@@ -270,20 +270,39 @@ static int qcelp_compute_svector(qcelp_p
     float    rnd[160];
 
 
+    /**
+     * TIA/EIA/IS-733 Has some missing info on the scaled codebook vector
+     * computation formula. Briefly:
+     *
+     * 'j' should go from 0 to 9 emulating a per codebook-subframe computation.
+     * For a longer explanation see FIX_SPEC_MISSING_CLAMP macro definition
+     * at the qcelpdata.h header in this software distribution.
+     */
+
+    j=0;
+
     switch(rate)
     {
         case RATE_FULL:
-             for(i=0; i<160; i++)
-             {
+
+            for(i=0; i<160; i++)
+            {
                 cdn_vector[i]=
-                gain[i/10]*qcelp_fullrate_ccodebook[(i-index[i/10]) & 127];
-             }
-             break;
+                gain[i/10]*qcelp_fullrate_ccodebook[(j-index[i/10]) & 127];
+
+                j=FIX_SPEC_MISSING_CLAMP(j);
+            }
+            break;
         case RATE_HALF:
-             for(i=0; i<160; i++)
+
+            for(i=0; i<160; i++)
+            {
                 cdn_vector[i]=
-                gain[i/40]*qcelp_halfrate_ccodebook[(i-index[i/40]) & 127];
-             break;
+                gain[i/40]*qcelp_halfrate_ccodebook[(j-index[i/40]) & 127];
+
+                j=FIX_SPEC_MISSING_CLAMP(j);
+            }
+            break;
         case RATE_QUARTER:
             for(i=0; i<160; i++)
             {



More information about the FFmpeg-soc mailing list