shithub: opus

Download patch

ref: bb5288174da23ec5961a6d86725387509ff69079
parent: 31b189b419766b1429281910e4c39ebd8449c943
author: Jean-Marc Valin <[email protected]>
date: Wed Aug 25 18:12:18 EDT 2010

coarse probability model in static modes too

--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -99,6 +99,15 @@
       fprintf(file, "#endif\n");
       fprintf(file, "\n");
 
+      fprintf(file, "#ifndef DEF_PROB%d\n", mode->nbEBands);
+      fprintf(file, "#define DEF_PROB%d\n", mode->nbEBands);
+      fprintf (file, "static const celt_int16 prob%d[%d] = {\n", mode->nbEBands, 4*mode->nbEBands);
+      for (j=0;j<4*mode->nbEBands;j++)
+         fprintf (file, "%d, ", mode->prob[j]);
+      fprintf (file, "};\n");
+      fprintf(file, "#endif\n");
+      fprintf(file, "\n");
+
       fprintf(file, "#ifndef DEF_LOGN%d_%d\n", mode->Fs, mdctSize);
       fprintf(file, "#define DEF_LOGN%d_%d\n", mode->Fs, mdctSize);
       fprintf (file, "static const celt_int16 logN%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands);
@@ -210,7 +219,7 @@
       fprintf(file, "%d,\t/* maxLM */\n", mode->maxLM);
       fprintf(file, "%d,\t/* nbShortMdcts */\n", mode->nbShortMdcts);
       fprintf(file, "%d,\t/* shortMdctSize */\n", mode->shortMdctSize);
-      fprintf(file, "0,\t/* prob */\n");
+      fprintf(file, "prob%d,\t/* prob */\n", mode->nbEBands);
       fprintf(file, "logN%d_%d,\t/* logN */\n", mode->Fs, mdctSize);
       fprintf(file, "{%d, cache_index%d_%d, cache_bits%d_%d},\t/* cache */\n",
             mode->cache.size, mode->Fs, mdctSize, mode->Fs, mdctSize);
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -85,7 +85,7 @@
    /* We have enough points that sine isn't necessary */
 #if defined(FIXED_POINT)
    for (i=0;i<=N4;i++)
-      l->trig[i] = TRIG_UPSCALE*celt_cos_norm(DIV32(ADD32(SHL32(EXTEND32(i),17),N2),N));
+      trig[i] = TRIG_UPSCALE*celt_cos_norm(DIV32(ADD32(SHL32(EXTEND32(i),17),N2),N));
 #else
    for (i=0;i<=N4;i++)
       trig[i] = cos(2*M_PI*i/N);
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -430,12 +430,12 @@
    )
       goto failure;
 
-#endif /* !STATIC_MODES */
-
    mode->prob = quant_prob_alloc(mode);
    if (mode->prob==NULL)
      goto failure;
 
+#endif /* !STATIC_MODES */
+
    mode->marker_start = MODEVALID;
    mode->marker_end   = MODEVALID;
    if (error)
@@ -479,9 +479,9 @@
    celt_free((celt_int16*)mode->cache.index);
    celt_free((unsigned char*)mode->cache.bits);
    clt_mdct_clear(&mode->mdct);
+   quant_prob_free(mode->prob);
 #endif
 
-   quant_prob_free(mode->prob);
    mode->marker_end = MODEFREED;
    celt_free((CELTMode *)mode);
 }
--- a/libcelt/modes.h
+++ b/libcelt/modes.h
@@ -98,7 +98,7 @@
    int         nbShortMdcts;
    int         shortMdctSize;
 
-   int *prob;
+   const celt_int16 *prob;
    const celt_int16 *logN;
 
    PulseCache cache;
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -81,11 +81,11 @@
    return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start);
 }
 
-int *quant_prob_alloc(const CELTMode *m)
+celt_int16 *quant_prob_alloc(const CELTMode *m)
 {
    int i;
-   int *prob;
-   prob = celt_alloc(4*m->nbEBands*sizeof(int));
+   celt_int16 *prob;
+   prob = celt_alloc(4*m->nbEBands*sizeof(celt_int16));
    if (prob==NULL)
      return NULL;
    for (i=0;i<m->nbEBands;i++)
@@ -101,14 +101,14 @@
    return prob;
 }
 
-void quant_prob_free(int *freq)
+void quant_prob_free(const celt_int16 *freq)
 {
-   celt_free(freq);
+   celt_free((celt_int16*)freq);
 }
 
 static void quant_coarse_energy_impl(const CELTMode *m, int start, int end,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
-      int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
+      const celt_int16 *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
       int intra, celt_word16 max_decay)
 {
    const int C = CHANNELS(_C);
@@ -179,7 +179,7 @@
 
 void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
-      int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
+      const celt_int16 *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
       int nbAvailableBytes, int force_intra, int *delayedIntra)
 {
    const int C = CHANNELS(_C);
@@ -322,7 +322,7 @@
    }
 }
 
-void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, int *prob, ec_dec *dec, int _C, int LM)
+void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, const celt_int16 *prob, ec_dec *dec, int _C, int LM)
 {
    int i, c;
    celt_word32 prev[2] = {0, 0};
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -45,12 +45,12 @@
 void log2Amp(const CELTMode *m, int start, int end,
       celt_ener *eBands, celt_word16 *oldEBands, int _C);
 
-int *quant_prob_alloc(const CELTMode *m);
-void quant_prob_free(int *freq);
+celt_int16 *quant_prob_alloc(const CELTMode *m);
+void quant_prob_free(const celt_int16 *freq);
 
 void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
-      int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
+      const celt_int16 *prob, celt_word16 *error, ec_enc *enc, int _C, int LM,
       int nbAvailableBytes, int force_intra, int *delayedIntra);
 
 void quant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C);
@@ -57,7 +57,7 @@
 
 void quant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C);
 
-void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, int *prob, ec_dec *dec, int _C, int LM);
+void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int intra, const celt_int16 *prob, ec_dec *dec, int _C, int LM);
 
 void unquant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, ec_dec *dec, int _C);