ref: 47ad4a093876af2f19216dae2dd121c2205231f0
parent: ffe5061a75f8ba09b009d21b43382fdd1515bd4f
author: Jean-Marc Valin <[email protected]>
date: Fri Jun 4 21:18:40 EDT 2010
Doing the log2Amp() just in one place
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -177,8 +177,6 @@
/*printf ("%f ", error[i] - offset);*/
} while (++c < C);
}
- for (i=start;i<C*m->nbEBands;i++)
- eBands[i] = log2Amp(oldEBands[i]);
}
void quant_energy_finalise(const CELTMode *m, int start, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C)
@@ -205,16 +203,19 @@
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384);
#endif
oldEBands[i+c*m->nbEBands] += offset;
- eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
bits_left--;
} while (++c < C);
}
}
- for (i=start;i<C*m->nbEBands;i++)
- {
- if (oldEBands[i] < -QCONST16(7.f,DB_SHIFT))
- oldEBands[i] = -QCONST16(7.f,DB_SHIFT);
- }
+ c=0;
+ do {
+ for (i=start;i<m->nbEBands;i++)
+ {
+ eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
+ if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
+ oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
+ }
+ } while (++c < C);
}
void unquant_coarse_energy(const CELTMode *m, int start, celt_ener *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C)
@@ -277,8 +278,6 @@
oldEBands[i+c*m->nbEBands] += offset;
} while (++c < C);
}
- for (i=start;i<C*m->nbEBands;i++)
- eBands[i] = log2Amp(oldEBands[i]);
}
void unquant_energy_finalise(const CELTMode *m, int start, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C)
@@ -304,14 +303,17 @@
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384);
#endif
oldEBands[i+c*m->nbEBands] += offset;
- eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
bits_left--;
} while (++c < C);
}
}
- for (i=start;i<C*m->nbEBands;i++)
- {
- if (oldEBands[i] < -QCONST16(7.f,DB_SHIFT))
- oldEBands[i] = -QCONST16(7.f,DB_SHIFT);
- }
+ c=0;
+ do {
+ for (i=start;i<m->nbEBands;i++)
+ {
+ eBands[i+c*m->nbEBands] = log2Amp(oldEBands[i+c*m->nbEBands]);
+ if (oldEBands[i+c*m->nbEBands] < -QCONST16(7.f,DB_SHIFT))
+ oldEBands[i+c*m->nbEBands] = -QCONST16(7.f,DB_SHIFT);
+ }
+ } while (++c < C);
}