@@ -1325,9 +1325,44 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
1325
1325
compute_band_energies (st -> mode , freq , bandE , effEnd , C , M );
1326
1326
1327
1327
amp2Log2 (st -> mode , effEnd , st -> end , bandE , bandLogE , C );
1328
- /*for (i=0;i<17 ;i++)
1328
+ /*for (i=0;i<21 ;i++)
1329
1329
printf("%f ", bandLogE[i]);
1330
1330
printf("\n");*/
1331
+
1332
+ ALLOC (bandLogE2 , C * st -> mode -> nbEBands , opus_val16 );
1333
+ if (shortBlocks )
1334
+ {
1335
+ ALLOC (freq2 , C * N , celt_sig );
1336
+ compute_mdcts (st -> mode , 0 , in , freq2 , CC , LM );
1337
+ if (CC == 2 && C == 1 )
1338
+ {
1339
+ for (i = 0 ;i < N ;i ++ )
1340
+ freq2 [i ] = ADD32 (HALF32 (freq2 [i ]), HALF32 (freq2 [N + i ]));
1341
+ }
1342
+ if (st -> upsample != 1 )
1343
+ {
1344
+ c = 0 ; do
1345
+ {
1346
+ int bound = N /st -> upsample ;
1347
+ for (i = 0 ;i < bound ;i ++ )
1348
+ freq2 [c * N + i ] *= st -> upsample ;
1349
+ for (;i < N ;i ++ )
1350
+ freq2 [c * N + i ] = 0 ;
1351
+ } while (++ c < C );
1352
+ }
1353
+ ALLOC (bandE2 , C * st -> mode -> nbEBands , opus_val32 );
1354
+ compute_band_energies (st -> mode , freq2 , bandE2 , effEnd , C , M );
1355
+ amp2Log2 (st -> mode , effEnd , st -> end , bandE2 , bandLogE2 , C );
1356
+ for (i = 0 ;i < C * st -> mode -> nbEBands ;i ++ )
1357
+ bandLogE2 [i ] += LM /2. ;
1358
+ } else {
1359
+ for (i = 0 ;i < C * st -> mode -> nbEBands ;i ++ )
1360
+ bandLogE2 [i ] = bandLogE [i ];
1361
+ }
1362
+ /*for (i=0;i<C*st->mode->nbEBands;i++)
1363
+ printf("%f ", MAX16(0,bandLogE[i]-bandLogE2[i]-LM/2.));
1364
+ printf("\n");*/
1365
+
1331
1366
{
1332
1367
opus_val16 follower [42 ]= {0 };
1333
1368
c = 0 ;do
@@ -1403,11 +1438,11 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
1403
1438
opus_val16 follower [42 ]= {0 };
1404
1439
c = 0 ;do
1405
1440
{
1406
- follower [c * st -> mode -> nbEBands ] = bandLogE [c * st -> mode -> nbEBands ];
1441
+ follower [c * st -> mode -> nbEBands ] = bandLogE2 [c * st -> mode -> nbEBands ];
1407
1442
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 ]);
1443
+ follower [c * st -> mode -> nbEBands + i ] = MIN16 (follower [c * st -> mode -> nbEBands + i - 1 ]+ 2 , bandLogE2 [c * st -> mode -> nbEBands + i ]);
1409
1444
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 ]));
1445
+ follower [c * st -> mode -> nbEBands + i ] = MIN16 (follower [c * st -> mode -> nbEBands + i ], MIN16 (follower [c * st -> mode -> nbEBands + i + 1 ]+ 2 , bandLogE2 [c * st -> mode -> nbEBands + i ]));
1411
1446
} while (++ c < 2 );
1412
1447
if (C == 2 )
1413
1448
{
@@ -1423,13 +1458,13 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
1423
1458
follower [i ] = MAX16 (0 , bandLogE [i ]- follower [i ]);
1424
1459
}
1425
1460
}
1426
- opus_val32 tot_boost = effectiveBytes * 8 / 6 ;
1461
+ opus_val32 tot_boost = ( effectiveBytes * 8 - 20 - 40 * C )/ 5 ;
1427
1462
for (i = st -> start ;i < st -> end - 1 ;i ++ )
1428
1463
{
1429
1464
int width ;
1430
1465
int boost ;
1431
1466
1432
- follower [i ] = MIN16 (follower [i ], QCONST16 (2 , DB_SHIFT ));
1467
+ follower [i ] = MIN16 (2 * follower [i ], i < 10 ? QCONST16 ( 4 , DB_SHIFT ) : QCONST16 (2 , DB_SHIFT ));
1433
1468
width = C * (st -> mode -> eBands [i + 1 ]- st -> mode -> eBands [i ])<<LM ;
1434
1469
if (width < 6 )
1435
1470
{
@@ -1446,43 +1481,10 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
1446
1481
offsets [i ] = boost ;
1447
1482
}
1448
1483
/*for (i=st->start;i<st->end-1;i++)
1449
- printf("%f ", follower[i]);*/
1450
- //printf("%f\n", tot_boost);
1451
- #if 0
1452
- if (LM <= 1 )
1453
- {
1454
- t1 = 3 ;
1455
- t2 = 5 ;
1456
- } else {
1457
- t1 = 2 ;
1458
- t2 = 4 ;
1459
- }
1460
- for (i = st -> start + 1 ;i < st -> end - 1 ;i ++ )
1461
- {
1462
- opus_val32 d2 ;
1463
- d2 = 2 * bandLogE [i ]- bandLogE [i - 1 ]- bandLogE [i + 1 ];
1464
- if (C == 2 )
1465
- d2 = HALF32 (d2 + 2 * bandLogE [i + st -> mode -> nbEBands ]-
1466
- bandLogE [i - 1 + st -> mode -> nbEBands ]- bandLogE [i + 1 + st -> mode -> nbEBands ]);
1467
- #ifdef FUZZING
1468
- if ((rand ()& 0xF )== 0 )
1469
- {
1470
- offsets [i ] += 1 ;
1471
- if ((rand ()& 0x3 )== 0 )
1472
- offsets [i ] += 1 + (rand ()& 0x3 );
1473
- }
1474
- #else
1475
- if (d2 > SHL16 (t1 ,DB_SHIFT ))
1476
- offsets [i ] += 1 ;
1477
- if (d2 > SHL16 (t2 ,DB_SHIFT ))
1478
- offsets [i ] += 1 ;
1479
- #endif
1480
- }
1481
- #endif
1484
+ printf("%f ", follower[i]);
1485
+ printf("%f\n", tot_boost);*/
1482
1486
}
1483
1487
#ifndef FIXED_POINT
1484
- //offsets[4] += 12;
1485
- //offsets[10] += 12;
1486
1488
if (0 && st -> analysis .valid )
1487
1489
{
1488
1490
if (st -> analysis .boost_amount [0 ]> .2 )
0 commit comments