[FFmpeg-soc] [soc]: r5024 - in amr: amr-ffmpeg.diff amrnbdec.c

cmcq subversion at mplayerhq.hu
Mon Aug 10 10:24:26 CEST 2009


Author: cmcq
Date: Mon Aug 10 10:24:26 2009
New Revision: 5024

Log:
Replace ff_celp_convolve_circf by a helper function for sparse vectors

Modified:
   amr/amr-ffmpeg.diff
   amr/amrnbdec.c

Modified: amr/amr-ffmpeg.diff
==============================================================================
--- amr/amr-ffmpeg.diff	Mon Aug 10 10:10:05 2009	(r5023)
+++ amr/amr-ffmpeg.diff	Mon Aug 10 10:24:26 2009	(r5024)
@@ -53,30 +53,18 @@ Index: libavcodec/celp_filters.c
 ===================================================================
 --- libavcodec/celp_filters.c	(revision 19613)
 +++ libavcodec/celp_filters.c	(working copy)
-@@ -47,6 +47,28 @@
+@@ -47,6 +47,16 @@
      }
  }
  
-+void ff_celp_convolve_circf(float* fc_out,
-+                            const float* fc_in,
-+                            const float* filter,
-+                            int len)
++void ff_celp_circ_addf(float *out, const float *in,
++                       const float *lagged, int lag, float fac, int n)
 +{
-+    int i, k;
-+
-+    memset(fc_out, 0, len * sizeof(float));
-+
-+    /* Since there are few pulses over an entire subframe (i.e. almost
-+       all fc_in[i] are zero) it is faster to loop over fc_in first. */
-+    for (i = 0; i < len; i++) {
-+        if (fc_in[i]) {
-+            for (k = 0; k < i; k++)
-+                fc_out[k] += fc_in[i] * filter[len + k - i];
-+
-+            for (k = i; k < len; k++)
-+                fc_out[k] += fc_in[i] * filter[      k - i];
-+        }
-+    }
++    int k;
++    for (k = 0; k < lag; k++)
++        out[k] = in[k] + fac * lagged[n + k - lag];
++    for (; k < n; k++)
++        out[k] = in[k] + fac * lagged[    k - lag];
 +}
 +
  int ff_celp_lp_synthesis_filter(int16_t *out,
@@ -86,10 +74,25 @@ Index: libavcodec/celp_filters.h
 ===================================================================
 --- libavcodec/celp_filters.h	(revision 19613)
 +++ libavcodec/celp_filters.h	(working copy)
-@@ -42,6 +42,22 @@
+@@ -42,6 +42,37 @@
                             int len);
  
  /**
++ * Add an array to a rotated array.
++ *
++ * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
++ *
++ * @param out result vector
++ * @param in samples to be added unfiltered
++ * @param lagged samples to be rotated, multiplied and added
++ * @param lag delay from 0 to n
++ * @param fac coefficient to applied to lagged samples
++ * @param n number of samples
++ */
++void ff_celp_circ_addf(float *out, const float *in,
++                       const float *lagged, int lag, float fac, int n);
++
++/**
 + * Circularly convolve fixed vector with a phase dispersion impulse
 + *        response filter (D.6.2 of G.729 and 6.1.5 of AMR).
 + * @param fc_out vector with filter applied

Modified: amr/amrnbdec.c
==============================================================================
--- amr/amrnbdec.c	Mon Aug 10 10:10:05 2009	(r5023)
+++ amr/amrnbdec.c	Mon Aug 10 10:24:26 2009	(r5024)
@@ -860,28 +860,6 @@ static void set_fixed_gain(AMRContext *p
 /// @{
 
 /**
- * Add an array to a rotated array
- *
- * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
- *
- * @param out result vector
- * @param in samples to be added unfiltered
- * @param lagged samples to be rotated, multiplied and added
- * @param lag delay from 0 to n
- * @param fac coefficient to applied to lagged samples
- * @param n number of samples
- */
-static void circ_add(float *out, const float *in, const float *lagged,
-                     int lag, float fac, int n)
-{
-    int k;
-    for (k = 0; k < lag; k++)
-        out[k] = in[k] + fac * lagged[n + k - lag];
-    for (; k < n; k++)
-        out[k] = in[k] + fac * lagged[    k - lag];
-}
-
-/**
  * Circularly convolve a sparse fixed vector with a phase dispersion impulse
  * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
  *
@@ -901,12 +879,12 @@ static void apply_ir_filter(float *out, 
     int i;
 
     if (lag < AMR_SUBFRAME_SIZE) {
-        circ_add(filter1, filter, filter, lag, fac,
-                 AMR_SUBFRAME_SIZE);
+        ff_celp_circ_addf(filter1, filter, filter, lag, fac,
+                          AMR_SUBFRAME_SIZE);
 
         if (lag < AMR_SUBFRAME_SIZE >> 1)
-            circ_add(filter2, filter, filter1, lag, fac,
-                     AMR_SUBFRAME_SIZE);
+            ff_celp_circ_addf(filter2, filter, filter1, lag, fac,
+                              AMR_SUBFRAME_SIZE);
     }
 
     memset(out, 0, sizeof(float) * AMR_SUBFRAME_SIZE);
@@ -922,7 +900,7 @@ static void apply_ir_filter(float *out, 
         } else
             filterp = filter2;
 
-        circ_add(out, out, filterp, x, y, AMR_SUBFRAME_SIZE);
+        ff_celp_circ_addf(out, out, filterp, x, y, AMR_SUBFRAME_SIZE);
     }
 }
 


More information about the FFmpeg-soc mailing list