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

reynaldo subversion at mplayerhq.hu
Sat Jul 14 04:46:26 CEST 2007


Author: reynaldo
Date: Sat Jul 14 04:46:26 2007
New Revision: 398

Log:
- Scaled codebook vector generation for rate 1/4 and 1/8 frames (WIP)
- Some modulus ops got replaced with &, following Michael's suggestions


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

Modified: qcelp/qcelpdata.h
==============================================================================
--- qcelp/qcelpdata.h	(original)
+++ qcelp/qcelpdata.h	Sat Jul 14 04:46:26 2007
@@ -371,3 +371,15 @@ static const float qcelp_halfrate_ccodeb
     1.5, -1.5,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
     0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0
 };
+
+#define QCELP_SQRT1887 1.373681186
+
+static const double qcelp_rnd_fir_coefs[]=
+{
+            0,-1.344519e-1, 1.735384e-2,-6.905826e-2,
+  2.434368e-2,-8.210701e-2, 3.041388e-2,-9.251384e-2,
+  3.501983e-2,-9.918777e-2, 3.749518e-2, 8.985137e-1,
+  3.749518e-2,-9.918777e-2, 3.501983e-2,-9.251384e-2,
+  3.041388e-2,-8.210701e-2, 2.434368e-2,-6.905826e-2,
+  1.735384e-2,-1.344519e-1
+}; /*!< start reading from [1] */

Modified: qcelp/qcelpdec.c
==============================================================================
--- qcelp/qcelpdec.c	(original)
+++ qcelp/qcelpdec.c	Sat Jul 14 04:46:26 2007
@@ -150,7 +150,7 @@ void qcelp_ctc2GI(const QCELPFrame *fram
                 g0[i]=QCELP_CBGAIN2G0(cbgain[i]);
 
                 /* FIXME this needs to be further examinated */
-                if(frame->rate == RATE_FULL && i > 0 && !((i+1)%4))
+                if(frame->rate == RATE_FULL && i > 0 && !(i+1 & 3))
                     predictor=av_clip(6, 38, (g1[i-1]+g1[i-2]+g1[i-3])/3);
                 else
                     predictor=0;
@@ -159,7 +159,7 @@ void qcelp_ctc2GI(const QCELPFrame *fram
                 ga[i]=qcelp_g12ga[g1[i]];
 
                 gain[i]=ga[i]*gs[i];
-                index[i]=(gs[i] > 0)? cindex[i]:(cindex[i]-89)%128; /* FIXME */
+                index[i]=(gs[i] > 0)? cindex[i]:cindex[i]-89 & 127; /* FIXME */
             }
 
             break;
@@ -212,13 +212,41 @@ void qcelp_ctc2GI(const QCELPFrame *fram
 static int qcelp_compute_cdn(qcelp_packet_rate rate, const float *gain,
            const int *index, uint16_t cbseed, float *cdn_vector)
 {
+    int      i,j;
+    uint16_t new_cbseed;
+    float    rnd[160];
+
     switch(rate)
     {
         case RATE_FULL:
         case RATE_HALF:
+             break;
         case RATE_QUARTER:
+            for(i=0; i<160; i++)
+            {
+                new_cbseed=521*cbseed+259 & 65535;
+                cbseed=rnd[i]=
+                QCELP_SQRT1887*((new_cbseed+32768 & 65535)-32768)/32768.0;
+
+                /* FIR filter */
+                cdn_vector[i]=qcelp_rnd_fir_coefs[1]*rnd[i];
+                for(j=1; j<22 && !(i-j+1); j++)
+                {
+                    cdn_vector[i]+=qcelp_rnd_fir_coefs[j]*rnd[i-j];
+                }
+                /* final scaling */
+                cdn_vector[i]*=gain[i/20];
+            }
+            break;
         case RATE_OCTAVE:
-        break;
+            for(i=0; i<160; i++)
+            {
+                new_cbseed=521*cbseed+259 & 65535;
+                cbseed=rnd[i]=
+                QCELP_SQRT1887*((new_cbseed+32768 & 65535)-32768)/32768.0;
+
+                cdn_vector[i]=gain[0]*rnd[i];
+            }
     }
 
     return 1;



More information about the FFmpeg-soc mailing list