shithub: opus

Download patch

ref: eafbdd55312151ae8ad142e2a0be099787765b22
parent: 433820954fb2e38d951dffaa77dc2ca3e3d288c8
author: Jean-Marc Valin <[email protected]>
date: Mon Apr 27 15:35:09 EDT 2009

Making it easier to Torben to develop his new PLC code

--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,7 @@
 AC_CANONICAL_HOST
 AM_PROG_LIBTOOL
 
+AC_PROG_CC_C99
 AC_C_BIGENDIAN
 AC_C_CONST
 AC_C_INLINE
@@ -113,6 +114,11 @@
 AC_ARG_ENABLE(assertions, [  --enable-assertions],
 [if test "$enableval" = yes; then
   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
+fi])
+
+AC_ARG_ENABLE(new-plc, [  --enable-new-plc],
+[if test "$enableval" = yes; then
+  AC_DEFINE([NEW_PLC], , [Use new PLC code])
 fi])
 
 saved_CFLAGS="$CFLAGS"
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -788,8 +788,12 @@
 /*                                DECODER                                   */
 /*                                                                          */
 /****************************************************************************/
+#ifdef NEW_PLC
+#define DECODE_BUFFER_SIZE 2048
+#else
+#define DECODE_BUFFER_SIZE MAX_PERIOD
+#endif
 
-
 /** Decoder state 
  @brief Decoder state
  */
@@ -805,6 +809,7 @@
    celt_sig_t * restrict preemph_memD;
 
    celt_sig_t *out_mem;
+   celt_sig_t *decode_mem;
 
    celt_word16_t *oldBandE;
    
@@ -828,7 +833,8 @@
    st->block_size = N;
    st->overlap = mode->overlap;
 
-   st->out_mem = celt_alloc((MAX_PERIOD+st->overlap)*C*sizeof(celt_sig_t));
+   st->decode_mem = celt_alloc((DECODE_BUFFER_SIZE+st->overlap)*C*sizeof(celt_sig_t));
+   st->out_mem = st->decode_mem+DECODE_BUFFER_SIZE-MAX_PERIOD;
    
    st->oldBandE = (celt_word16_t*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16_t));
 
@@ -849,7 +855,7 @@
       return;
 
 
-   celt_free(st->out_mem);
+   celt_free(st->decode_mem);
    
    celt_free(st->oldBandE);
    
@@ -860,6 +866,9 @@
 
 /** Handles lost packets by just copying past data with the same offset as the last
     pitch period */
+#ifdef NEW_PLC
+#include "plc.c"
+#else
 static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict pcm)
 {
    int c, N;
@@ -909,6 +918,7 @@
    }
    RESTORE_STACK;
 }
+#endif
 
 #ifdef FIXED_POINT
 int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16_t * restrict pcm)
@@ -1051,7 +1061,7 @@
    denormalise_bands(st->mode, X, freq, bandE);
 
 
-   CELT_MOVE(st->out_mem, st->out_mem+C*N, C*(MAX_PERIOD+st->overlap-N));
+   CELT_MOVE(st->decode_mem, st->decode_mem+C*N, C*(DECODE_BUFFER_SIZE+st->overlap-N));
    /* Compute inverse MDCTs */
    compute_inv_mdcts(st->mode, shortBlocks, freq, transient_time, transient_shift, st->out_mem);