[FFmpeg-soc] [soc]: r4126 - in amr: amr-ffmpeg.diff amrnbfloatdec.c

kmalaussene subversion at mplayerhq.hu
Sun Feb 22 23:33:13 CET 2009


Author: kmalaussene
Date: Sun Feb 22 23:33:12 2009
New Revision: 4126

Log:
Use ff_celp_convolve_circf in celp_filtes.[ch] instead of convolve_circ.

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

Modified: amr/amr-ffmpeg.diff
==============================================================================
--- amr/amr-ffmpeg.diff	Sun Feb 22 22:41:33 2009	(r4125)
+++ amr/amr-ffmpeg.diff	Sun Feb 22 23:33:12 2009	(r4126)
@@ -136,3 +136,67 @@ Index: libavcodec/qcelp_lsp.c
      {
          lpc[i] *= bandwith_expansion_coeff;
          bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
+Index: libavcodec/celp_filters.c
+===================================================================
+--- libavcodec/celp_filters.c	(revision 17468)
++++ libavcodec/celp_filters.c	(working copy)
+@@ -85,6 +85,31 @@
+     return 0;
+ }
+ 
++void ff_celp_convolve_circf(
++        float* fc_out,
++        const float* fc_in,
++        const float* filter,
++        int len)
++{
++    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];
++        }
++    }
++}
++
+ void ff_celp_lp_synthesis_filterf(
+         float *out,
+         const float* filter_coeffs,
+Index: libavcodec/celp_filters.h
+===================================================================
+--- libavcodec/celp_filters.h	(revision 17468)
++++ libavcodec/celp_filters.h	(working copy)
+@@ -70,6 +70,23 @@
+         int rounder);
+ 
+ /**
++ * 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
++ * @param fc_in source vector
++ * @param filter phase filter coefficients
++ *
++ *  fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
++ *
++ * \note fc_in and fc_out should not overlap!
++ */
++void ff_celp_convolve_circf(
++        float* fc_out,
++        const float* fc_in,
++        const float* filter,
++        int len);
++
++/**
+  * LP synthesis filter.
+  * @param out [out] pointer to output buffer
+  *        - the array out[-filter_length, -1] must

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	Sun Feb 22 22:41:33 2009	(r4125)
+++ amr/amrnbfloatdec.c	Sun Feb 22 23:33:12 2009	(r4126)
@@ -36,6 +36,7 @@
 #include "libavutil/common.h"
 #include "internal.h"
 #include "celp_math.h"
+#include "celp_filters.h"
 #include "amrnbfloatdata.h"
 
 void ff_celp_lspf2lpc(const double *lspf, float *lpc);
@@ -690,42 +691,6 @@ static float fixed_gain_prediction(float
 /// @defgroup amr_pre_processing pre-processing functions
 /// @{
 
-/**
- * Circularly convolve the fixed vector with a phase dispersion impulse response
- * filter.
- *
- * @param fixed_vector  pointer to the fixed vector
- * @param ir_filter     pointer to the impulse response filter
- */
-
-static void convolve_circ(float *fixed_vector, const float *ir_filter)
-{
-    int i, j, k;
-    int npulses = 0, pulse_positions[AMR_SUBFRAME_SIZE];
-    float fixed_vector_temp[AMR_SUBFRAME_SIZE];
-
-    memcpy(fixed_vector_temp, fixed_vector, AMR_SUBFRAME_SIZE*sizeof(float));
-    memset(fixed_vector, 0, AMR_SUBFRAME_SIZE*sizeof(float));
-
-    // Find non-zero pulses (most are zero)
-    for(i=0; i<AMR_SUBFRAME_SIZE; i++) {
-        if(fixed_vector_temp[i]) {
-            pulse_positions[npulses] = i;
-            npulses++;
-        }
-    }
-
-    for(i=0; i<npulses; i++) {
-        k = 0;
-        for(j=pulse_positions[i]; j<AMR_SUBFRAME_SIZE; j++) {
-            fixed_vector[j] += fixed_vector_temp[pulse_positions[i]]*ir_filter[k++];
-        }
-        for(j=0; j<pulse_positions[i]; j++) {
-            fixed_vector[j] += fixed_vector_temp[pulse_positions[i]]*ir_filter[k++];
-        }
-    }
-}
-
 /// @}
 
 /**
@@ -777,7 +742,12 @@ void do_phase_dispersion(AMRContext *p)
         const float **filters = p->cur_frame_mode == MODE_795 ? ir_filters_lookup_MODE_795
                                                               : ir_filters_lookup;
         // circularly convolve the fixed vector with the impulse response
-        convolve_circ(p->fixed_vector, filters[ir_filter_strength]);
+        // FIXME: extra memcpy (ff_celp_convolve_circf needs in and out not to overlap)
+        float fixed_vector_temp[AMR_SUBFRAME_SIZE];
+
+        memcpy(fixed_vector_temp, p->fixed_vector, sizeof(fixed_vector_temp));
+        ff_celp_convolve_circf(p->fixed_vector, fixed_vector_temp,
+                               filters[ir_filter_strength], AMR_SUBFRAME_SIZE);
     }
 
     // update ir filter strength history



More information about the FFmpeg-soc mailing list