[FFmpeg-soc] [soc] G.723.1 Decoder 7f3f81e1f58926e24685bde2a97732f216f7e68f

naufal11 at gmail.com naufal11 at gmail.com
Fri Jul 16 15:10:27 CEST 2010



- Log -----------------------------------------------------------------
commit 7f3f81e1f58926e24685bde2a97732f216f7e68f
Author: Naufal <naufal11 at gmail.com>
Date:   Fri Jul 16 18:36:56 2010 +0530

    Synthesize speech

diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 598a4d3..abe60fc 100755
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -2,6 +2,7 @@
 #define ALT_BITSTREAM_READER_LE
 #include "get_bits.h"
 #include "acelp_vectors.h"
+#include "celp_filters.h"
 #include "lsp.h"
 #include "g723_1_data.h"
 
@@ -10,6 +11,7 @@ typedef struct g723_1_context {
     int16_t prev_lsp[LPC_ORDER];
     int16_t pitch_lag[2];
     int16_t prev_excitation[PITCH_MAX];
+    int16_t filter_mem[LPC_ORDER];
     G723_1_Subframe subframe[4];
     FrameType cur_frame_type;
     FrameType past_frame_type;
@@ -778,6 +780,22 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
         }
     }
 
+    vector_ptr = out + LPC_ORDER;
+    for (i = 0; i < SUBFRAMES; i++) {
+
+        // Fill with the last 10 values of the output vector
+        memcpy(vector_ptr - LPC_ORDER, p->filter_mem,
+               LPC_ORDER * sizeof(int16_t));
+        // Perform 10th order LPC synthesis
+        ff_celp_lp_synthesis_filter(vector_ptr, &lpc[i * LPC_ORDER + i + 1],
+                                    vector_ptr, SUBFRAME_LEN, LPC_ORDER,
+                                    0, 1, 1 << 12);
+        // Store the last 10 values of the output vector
+        memcpy(p->filter_mem, vector_ptr + SUBFRAME_LEN - LPC_ORDER,
+               LPC_ORDER * sizeof(int16_t));
+
+        vector_ptr += SUBFRAME_LEN;
+    }
     return frame_size[p->cur_frame_type];
 }
 

commit 5cb58b347cbdedc05ea3afc0118e9bb0b441f773
Author: Naufal <naufal11 at gmail.com>
Date:   Fri Jul 16 18:17:50 2010 +0530

    Make ff_celp_lp_synthesis_filter() usable by G.723.1

diff --git a/libavcodec/celp_filters.c b/libavcodec/celp_filters.c
index 26a62ee..f9e65f4 100644
--- a/libavcodec/celp_filters.c
+++ b/libavcodec/celp_filters.c
@@ -58,7 +58,7 @@ void ff_celp_circ_addf(float *out, const float *in,
 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
                                 const int16_t *in, int buffer_length,
                                 int filter_length, int stop_on_overflow,
-                                int rounder)
+                                int shift, int rounder)
 {
     int i,n;
 
@@ -67,7 +67,7 @@ int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
         for (i = 1; i <= filter_length; i++)
             sum -= filter_coeffs[i-1] * out[n-i];
 
-        sum = (sum >> 12) + in[n];
+        sum = ((sum >> 12) + in[n]) >> shift;
 
         if (sum + 0x8000 > 0xFFFFU) {
             if (stop_on_overflow)
diff --git a/libavcodec/celp_filters.h b/libavcodec/celp_filters.h
index 7b64fc0..aec5c69 100644
--- a/libavcodec/celp_filters.h
+++ b/libavcodec/celp_filters.h
@@ -63,6 +63,7 @@ void ff_celp_circ_addf(float *out, const float *in,
  * @param filter_length filter length (10 for 10th order LP filter)
  * @param stop_on_overflow   1 - return immediately if overflow occurs
  *                           0 - ignore overflows
+ * @param shift result will be shifted right by this value
  * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
  *
  * @return 1 if overflow occurred, 0 - otherwise
@@ -75,7 +76,7 @@ void ff_celp_circ_addf(float *out, const float *in,
 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
                                 const int16_t *in, int buffer_length,
                                 int filter_length, int stop_on_overflow,
-                                int rounder);
+                                int shift, int rounder);
 
 /**
  * LP synthesis filter.
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
index efa62c4..42bfc23 100644
--- a/libavcodec/ra144.c
+++ b/libavcodec/ra144.c
@@ -212,7 +212,7 @@ static void do_output_subblock(RA144Context *ractx, const uint16_t  *lpc_coefs,
            10*sizeof(*ractx->curr_sblock));
 
     if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
-                                    block, BLOCKSIZE, 10, 1, 0xfff))
+                                    block, BLOCKSIZE, 10, 1, 0, 0xfff))
         memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
 }
 

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/celp_filters.c |    4 ++--
 libavcodec/celp_filters.h |    3 ++-
 libavcodec/g723_1.c       |   18 ++++++++++++++++++
 libavcodec/ra144.c        |    2 +-
 4 files changed, 23 insertions(+), 4 deletions(-)


-- 
http://github.com/naufal/ffmpeg-soc


More information about the FFmpeg-soc mailing list