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

reynaldo subversion at mplayerhq.hu
Mon Aug 20 07:57:16 CEST 2007


Author: reynaldo
Date: Mon Aug 20 07:57:16 2007
New Revision: 1037

Log:
Fix codebook subrame gain and index params computation -- spec had errors

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

Modified: qcelp/qcelpdata.h
==============================================================================
--- qcelp/qcelpdata.h	(original)
+++ qcelp/qcelpdata.h	Mon Aug 20 07:57:16 2007
@@ -26,6 +26,16 @@
 
 #define FXQ(v)  (roundf(16384.0*v)/16384.0)
 
+/**
+ * TIA/EIA/IS-733 Spec has errors on the predictor determination formula
+ * at equation 2.4.6.1-4 -- The predictor there needs 6 to be sustracted
+ * from it to give RI compliants results. The problem is it ignores the
+ * fact that codebook subframes 4,8,12 and 16 on a FULL_RATE frame use a
+ * different quantizer table.
+ */
+
+#define FIX_SPEC_PREDICTOR(p) (p-6)
+
 typedef enum
 {
     RATE_FULL   = 0,

Modified: qcelp/qcelpdec.c
==============================================================================
--- qcelp/qcelpdec.c	(original)
+++ qcelp/qcelpdec.c	Mon Aug 20 07:57:16 2007
@@ -183,24 +183,20 @@ void qcelp_decode_params(AVCodecContext 
                 gs[i]=QCELP_CBSIGN2GS(cbsign[i]);
                 g0[i]=QCELP_CBGAIN2G0(cbgain[i]);
 
-                /* FIXME this needs to be further examinated */
+                /**
+                 * Spec has errors on the predictor determination formula
+                 * it needs 6 to be sustracted from it to give RI results.
+                 */
+
                 if(frame->rate == RATE_FULL && i > 0 && !((i+1) & 3))
-                    predictor=av_clip(floor((g1[i-1]+g1[i-2]+g1[i-3])/3), 6,
-                                      38);
+                    predictor=FIX_SPEC_PREDICTOR
+                              (av_clip(floor((g1[i-1]+g1[i-2]+g1[i-3])/3.0), 6,
+                              38));
                 else
                     predictor=0;
 
                 g1[i]=g0[i]+predictor;
 
-                /**
-                 * FIXME
-                 *
-                 * This shouldn't but does happen quite a few
-                 * times during decoding, my guess is I have an
-                 * error at predictor computation somewhere but
-                 * can't find it yet.
-                 */
-
                 if(g1[i]<0 || g1[i]>60)
                 {
                     av_log(avctx, AV_LOG_WARNING,
@@ -281,9 +277,7 @@ static int qcelp_compute_svector(qcelp_p
              {
                 cdn_vector[i]=
                 gain[i/10]*qcelp_fullrate_ccodebook[(i+1-index[i/10]) & 127];
-                av_log(NULL, AV_LOG_ERROR, " %f", cdn_vector[i]);
              }
-             av_log(NULL, AV_LOG_ERROR, "\n");
              break;
         case RATE_HALF:
              for(i=0; i<160; i++)



More information about the FFmpeg-soc mailing list