[FFmpeg-soc] [soc]: r4816 - in amr: amr-ffmpeg.diff amrnbfloatdata.h amrnbfloatdec.c

cmcq subversion at mplayerhq.hu
Tue Jul 28 17:52:32 CEST 2009


Author: cmcq
Date: Tue Jul 28 17:52:32 2009
New Revision: 4816

Log:
Add a floating-point high-pass filter to acelp_filters and use it

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

Modified: amr/amr-ffmpeg.diff
==============================================================================
--- amr/amr-ffmpeg.diff	Tue Jul 28 17:43:39 2009	(r4815)
+++ amr/amr-ffmpeg.diff	Tue Jul 28 17:52:32 2009	(r4816)
@@ -6,7 +6,7 @@ Index: libavcodec/Makefile
  OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
  OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
  OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o lpc.o
-+OBJS-$(CONFIG_AMRNB_DECODER)           += amrnbfloatdec.o qcelp_lsp.o celp_filters.o celp_math.o
++OBJS-$(CONFIG_AMRNB_DECODER)           += amrnbfloatdec.o qcelp_lsp.o celp_filters.o celp_math.o acelp_filters.o
  OBJS-$(CONFIG_AMV_DECODER)             += sp5xdec.o mjpegdec.o mjpeg.o
  OBJS-$(CONFIG_APE_DECODER)             += apedec.o
  OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o mpeg12data.o
@@ -160,3 +160,42 @@ Index: libavcodec/celp_filters.h
   * Routine applies A(z) filter to given speech data.
   */
  void ff_celp_lp_zero_synthesis_filterf(
+Index: libavcodec/acelp_filters.c
+===================================================================
+--- libavcodec/acelp_filters.c	(revision 19401)
++++ libavcodec/acelp_filters.c	(working copy)
+@@ -93,3 +93,17 @@
+         hpf_f[0] = tmp;
+     }
+ }
++
++void ff_acelp_high_pass_filterf(float *buf, float *mem, int length)
++{
++    int i;
++    float tmp;
++
++    for (i = 0; i < length; i++) {
++         tmp = buf[i] + 1.933105469 * mem[0] - 0.935913085 * mem[1];
++         buf[i] = 0.939819335 * (tmp - 2 * mem[0] + mem[1]);
++
++         mem[1] = mem[0];
++         mem[0] = tmp;
++    }
++}
+Index: libavcodec/acelp_filters.h
+===================================================================
+--- libavcodec/acelp_filters.h	(revision 19401)
++++ libavcodec/acelp_filters.h	(working copy)
+@@ -81,4 +81,12 @@
+ void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
+                                const int16_t* in, int length);
+ 
++/**
++ * high-pass filtering (6.2.2 of 3GPP TS 26.090)
++ * @param samples [in/out]·
++ * @param mem intermediate values used by filter (should be 0 initially)
++ * @param length input data size
++ */
++void ff_acelp_high_pass_filterf(float *samples, float mem[2], int length);
++
+ #endif /* AVCODEC_ACELP_FILTERS_H */

Modified: amr/amrnbfloatdata.h
==============================================================================
--- amr/amrnbfloatdata.h	Tue Jul 28 17:43:39 2009	(r4815)
+++ amr/amrnbfloatdata.h	Tue Jul 28 17:52:32 2009	(r4816)
@@ -2360,10 +2360,6 @@ static const float *formant_low_d = form
 // Adaptive gain control factor used in post-filter
 #define AMR_AGC_ALPHA 0.9
 
-// High-pass filter coefficients (section 6.2.2)
-static const float high_pass_n[] = {0.939819335, -1.879638672, 0.939819335};
-static const float high_pass_d[] = {             -1.933105469, 0.935913085};
-
 /**************************** end of tables *****************************/
 
 #endif /* AVCODEC_AMRNBFLOATDATA_H */

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	Tue Jul 28 17:43:39 2009	(r4815)
+++ amr/amrnbfloatdec.c	Tue Jul 28 17:52:32 2009	(r4816)
@@ -37,6 +37,7 @@
 #include "internal.h"
 #include "celp_math.h"
 #include "celp_filters.h"
+#include "acelp_filters.h"
 #include "amrnbfloatdata.h"
 
 void ff_celp_lspf2lpc(const double *lspf, float *lpc);
@@ -1129,24 +1130,6 @@ static void postfilter(AMRContext *p, fl
     }
 }
 
-/**
- * High-pass filtering and up-scaling
- *
- * @param high_pass_mem Pointer to two floats for the filter state
- * @param samples AMR_SUBFRAME_SIZE buffer where the filter is applied
- */
-static void high_pass_filter(float *high_pass_mem, float *samples)
-{
-    float tmp[AMR_BLOCK_SIZE + 2];
-
-    memcpy(tmp, high_pass_mem, sizeof(float) * 2);
-    ff_celp_lp_synthesis_filterf(tmp + 2, high_pass_d, samples,
-                                 AMR_BLOCK_SIZE, 2);
-    memcpy(high_pass_mem, tmp + AMR_BLOCK_SIZE, sizeof(float) * 2);
-    ff_celp_lp_zero_synthesis_filterf(samples, high_pass_n, tmp + 2,
-                                      AMR_BLOCK_SIZE, 3);
-}
-
 /// @}
 
 static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
@@ -1248,7 +1231,7 @@ static int amrnb_decode_frame(AVCodecCon
         update_state(p);
     }
 
-    high_pass_filter(p->high_pass_mem, buf_out);
+    ff_acelp_high_pass_filterf(buf_out, p->high_pass_mem, 160);
 
     for (i = 0; i < AMR_BLOCK_SIZE; i++)
         // Post-processing up-scales by 2. It's convenient to


More information about the FFmpeg-soc mailing list