ref: 96d7a079425d39712f0214a868beb415c46b8061
parent: 2a9fdbc93dd048bb8fe5d992c1d4502fe3510666
author: Jean-Marc Valin <[email protected]>
date: Thu Dec 15 18:01:46 EST 2011
Dynalloc based on a bands that stand out of the "noise floor"
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -1328,7 +1328,25 @@
/*for (i=0;i<17;i++)
printf("%f ", bandLogE[i]);
printf("\n");*/
+ {
+ opus_val16 follower[42]={0};
+ c=0;do
+ {
+ follower[c*st->mode->nbEBands] = bandLogE[c*st->mode->nbEBands];
+ for (i=1;i<st->mode->nbEBands;i++)
+ follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i-1]+2, bandLogE[c*st->mode->nbEBands+i]);
+ for (i=st->mode->nbEBands-2;i>=0;i--)
+ follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i], MIN16(follower[c*st->mode->nbEBands+i+1]+2, bandLogE[c*st->mode->nbEBands+i]));
+ } while (++c<2);
+ for (i=st->start;i<st->end-1;i++)
+ {
+ follower[i] = MAX16(0, bandLogE[i]-follower[i]);
+ }
+ /*for (i=st->start;i<st->end-1;i++)
+ printf("%f ", follower[i]);
+ printf("\n");*/
+ }
/* Band normalisation */
normalise_bands(st->mode, freq, X, bandE, effEnd, C, M);
@@ -1382,6 +1400,55 @@
if (effectiveBytes > 50 && LM>=1)
{
int t1, t2;
+ opus_val16 follower[42]={0};
+ c=0;do
+ {
+ follower[c*st->mode->nbEBands] = bandLogE[c*st->mode->nbEBands];
+ for (i=1;i<st->mode->nbEBands;i++)
+ follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i-1]+2, bandLogE[c*st->mode->nbEBands+i]);
+ for (i=st->mode->nbEBands-2;i>=0;i--)
+ follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i], MIN16(follower[c*st->mode->nbEBands+i+1]+2, bandLogE[c*st->mode->nbEBands+i]));
+ } while (++c<2);
+ if (C==2)
+ {
+ for (i=st->start;i<st->end-1;i++)
+ {
+ follower[st->mode->nbEBands+i] = MAX16(follower[st->mode->nbEBands+i], follower[ i]-4);
+ follower[ i] = MAX16(follower[ i], follower[st->mode->nbEBands+i]-4);
+ follower[i] = HALF16(MAX16(0, bandLogE[i]-follower[i]) + MAX16(0, bandLogE[st->mode->nbEBands+i]-follower[st->mode->nbEBands+i]));
+ }
+ } else {
+ for (i=st->start;i<st->end-1;i++)
+ {
+ follower[i] = MAX16(0, bandLogE[i]-follower[i]);
+ }
+ }
+ opus_val32 tot_boost=effectiveBytes*8/6;
+ for (i=st->start;i<st->end-1;i++)
+ {
+ int width;
+ int boost;
+
+ follower[i] = MIN16(follower[i], QCONST16(2, DB_SHIFT));
+ width = C*(st->mode->eBands[i+1]-st->mode->eBands[i])<<LM;
+ if (width<6)
+ {
+ boost = IMIN(tot_boost/width, EXTEND32(follower[i]));
+ tot_boost -= boost*width;
+ } else if (width > 48) {
+ boost = IMIN(8*tot_boost/width, EXTEND32(follower[i])*8);
+ tot_boost -= boost*width/8;
+ } else {
+ boost = IMIN(tot_boost/6, EXTEND32(follower[i])*width/6);
+ tot_boost -= boost*6;
+ }
+ //printf("%d ", boost);
+ offsets[i] = boost;
+ }
+ /*for (i=st->start;i<st->end-1;i++)
+ printf("%f ", follower[i]);*/
+ //printf("%f\n", tot_boost);
+#if 0
if (LM <= 1)
{
t1 = 3;
@@ -1411,8 +1478,11 @@
offsets[i] += 1;
#endif
}
+#endif
}
#ifndef FIXED_POINT
+ //offsets[4] += 12;
+ //offsets[10] += 12;
if (0 && st->analysis.valid)
{
if (st->analysis.boost_amount[0]>.2)