Commit bb528817 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

coarse probability model in static modes too

parent 31b189b4
......@@ -99,6 +99,15 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
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 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
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);
......
......@@ -85,7 +85,7 @@ void clt_mdct_init(mdct_lookup *l,int N, int maxshift)
/* 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);
......
......@@ -430,12 +430,12 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
)
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 @@ void celt_mode_destroy(CELTMode *mode)
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);
}
......
......@@ -98,7 +98,7 @@ struct CELTMode {
int nbShortMdcts;
int shortMdctSize;
int *prob;
const celt_int16 *prob;
const celt_int16 *logN;
PulseCache cache;
......
......@@ -81,11 +81,11 @@ static int intra_decision(const celt_word16 *eBands, celt_word16 *oldEBands, int
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 @@ int *quant_prob_alloc(const CELTMode *m)
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 @@ static void quant_coarse_energy_impl(const CELTMode *m, int start, int end,
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 quant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *eBa
}
}
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};
......
......@@ -45,19 +45,19 @@ void amp2Log2(const CELTMode *m, int effEnd, int end,
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);
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment