Skip to content

Commit 96d7a07

Browse files
committed
Dynalloc based on a bands that stand out of the "noise floor"
1 parent 2a9fdbc commit 96d7a07

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

celt/celt.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,25 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
13281328
/*for (i=0;i<17;i++)
13291329
printf("%f ", bandLogE[i]);
13301330
printf("\n");*/
1331+
{
1332+
opus_val16 follower[42]={0};
1333+
c=0;do
1334+
{
1335+
follower[c*st->mode->nbEBands] = bandLogE[c*st->mode->nbEBands];
1336+
for (i=1;i<st->mode->nbEBands;i++)
1337+
follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i-1]+2, bandLogE[c*st->mode->nbEBands+i]);
1338+
for (i=st->mode->nbEBands-2;i>=0;i--)
1339+
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]));
1340+
} while (++c<2);
1341+
for (i=st->start;i<st->end-1;i++)
1342+
{
1343+
follower[i] = MAX16(0, bandLogE[i]-follower[i]);
1344+
}
1345+
/*for (i=st->start;i<st->end-1;i++)
1346+
printf("%f ", follower[i]);
1347+
printf("\n");*/
13311348

1349+
}
13321350
/* Band normalisation */
13331351
normalise_bands(st->mode, freq, X, bandE, effEnd, C, M);
13341352

@@ -1382,6 +1400,55 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
13821400
if (effectiveBytes > 50 && LM>=1)
13831401
{
13841402
int t1, t2;
1403+
opus_val16 follower[42]={0};
1404+
c=0;do
1405+
{
1406+
follower[c*st->mode->nbEBands] = bandLogE[c*st->mode->nbEBands];
1407+
for (i=1;i<st->mode->nbEBands;i++)
1408+
follower[c*st->mode->nbEBands+i] = MIN16(follower[c*st->mode->nbEBands+i-1]+2, bandLogE[c*st->mode->nbEBands+i]);
1409+
for (i=st->mode->nbEBands-2;i>=0;i--)
1410+
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]));
1411+
} while (++c<2);
1412+
if (C==2)
1413+
{
1414+
for (i=st->start;i<st->end-1;i++)
1415+
{
1416+
follower[st->mode->nbEBands+i] = MAX16(follower[st->mode->nbEBands+i], follower[ i]-4);
1417+
follower[ i] = MAX16(follower[ i], follower[st->mode->nbEBands+i]-4);
1418+
follower[i] = HALF16(MAX16(0, bandLogE[i]-follower[i]) + MAX16(0, bandLogE[st->mode->nbEBands+i]-follower[st->mode->nbEBands+i]));
1419+
}
1420+
} else {
1421+
for (i=st->start;i<st->end-1;i++)
1422+
{
1423+
follower[i] = MAX16(0, bandLogE[i]-follower[i]);
1424+
}
1425+
}
1426+
opus_val32 tot_boost=effectiveBytes*8/6;
1427+
for (i=st->start;i<st->end-1;i++)
1428+
{
1429+
int width;
1430+
int boost;
1431+
1432+
follower[i] = MIN16(follower[i], QCONST16(2, DB_SHIFT));
1433+
width = C*(st->mode->eBands[i+1]-st->mode->eBands[i])<<LM;
1434+
if (width<6)
1435+
{
1436+
boost = IMIN(tot_boost/width, EXTEND32(follower[i]));
1437+
tot_boost -= boost*width;
1438+
} else if (width > 48) {
1439+
boost = IMIN(8*tot_boost/width, EXTEND32(follower[i])*8);
1440+
tot_boost -= boost*width/8;
1441+
} else {
1442+
boost = IMIN(tot_boost/6, EXTEND32(follower[i])*width/6);
1443+
tot_boost -= boost*6;
1444+
}
1445+
//printf("%d ", boost);
1446+
offsets[i] = boost;
1447+
}
1448+
/*for (i=st->start;i<st->end-1;i++)
1449+
printf("%f ", follower[i]);*/
1450+
//printf("%f\n", tot_boost);
1451+
#if 0
13851452
if (LM <= 1)
13861453
{
13871454
t1 = 3;
@@ -1411,8 +1478,11 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
14111478
offsets[i] += 1;
14121479
#endif
14131480
}
1481+
#endif
14141482
}
14151483
#ifndef FIXED_POINT
1484+
//offsets[4] += 12;
1485+
//offsets[10] += 12;
14161486
if (0 && st->analysis.valid)
14171487
{
14181488
if (st->analysis.boost_amount[0]>.2)

0 commit comments

Comments
 (0)