[FFmpeg-soc] [soc] soc g723.1 6f9d27490f479ce592ccf79df6400c0ab7e9f233

naufal11 at gmail.com naufal11 at gmail.com
Wed Jun 16 16:09:46 CEST 2010



- Log -----------------------------------------------------------------
commit 6f9d27490f479ce592ccf79df6400c0ab7e9f233
Author: Naufal <naufal11 at gmail.com>
Date:   Wed Jun 16 19:37:47 2010 +0530

    Update lsp2lpc, now bit-exact

diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 5b032ef..a70088c 100755
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -253,7 +253,7 @@ static void lsp_interpolate(int16_t *lpc, int16_t *cur_lsp, int16_t *prev_lsp)
             lpc_ptr[j] = av_clipl_int32(((temp1 + temp2) << 1) + (1 << 15)) >> 16;
         }
 
-        ff_acelp_lsp2lpc(lpc_ptr, lpc_ptr, LPC_ORDER >> 1);
+        ff_acelp_lsp2lpc(lpc_ptr, lpc_ptr, LPC_ORDER >> 1, 9, 1 << 9, -1);
         lpc_ptr += LPC_ORDER + 1;
     }
 }

commit b0b092b2392d75711a60c95342c5a5839aef46e5
Author: Naufal <naufal11 at gmail.com>
Date:   Wed Jun 16 19:25:28 2010 +0530

    Make ff_acelp_lsp2lpc generic

diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 003ffbc..f25f846 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -87,7 +87,7 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
     }
 }
 
-void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
+void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order, int shift, int rounder, int sign)
 {
     int i;
     int f1[lp_half_order+1]; // (3.22)
@@ -103,9 +103,10 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
         int ff1 = f1[i] + f1[i-1]; // (3.22)
         int ff2 = f2[i] - f2[i-1]; // (3.22)
 
-        ff1 += 1 << 10; // for rounding
-        lp[i]    = (ff1 + ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
-        lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
+        ff1 += rounder; // for rounding
+        // divide by 2 and scale
+        lp[i]    = av_clip_int16(sign * av_clip_int16((ff1 + ff2) >> (shift + 1)));
+        lp[(lp_half_order << 1) + 1 - i] = av_clip_int16(sign * av_clip_int16((ff1 - ff2) >> (shift + 1)));
     }
 }
 
@@ -122,10 +123,10 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd
         lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1;
 #endif
 
-    ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1);
+    ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1, 10, 1 << 10, 1);
 
     /* LSP values for second subframe (3.2.5 of G.729)*/
-    ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1);
+    ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1, 10, 1 << 10, 1);
 }
 
 void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h
index c3aee7b..822b32d 100644
--- a/libavcodec/lsp.h
+++ b/libavcodec/lsp.h
@@ -67,8 +67,11 @@ void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order);
  * \param lp [out] decoded LP coefficients (-0x8000 <= (3.12) < 0x8000)
  * \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
  * \param lp_half_order LP filter order, divided by 2
+ * \param shift the result will be shifted right by this value
+ * \param rounder this value will be added to the result
+ * \param sign determines if the result is to be negated (-1 or 1)
  */
-void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
+void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order, int shift, int rounder, int sign);
 
 /**
  * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)

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

Summary of changes:
 libavcodec/g723_1.c |    2 +-
 libavcodec/lsp.c    |   13 +++++++------
 libavcodec/lsp.h    |    5 ++++-
 3 files changed, 12 insertions(+), 8 deletions(-)


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


More information about the FFmpeg-soc mailing list