aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2020-12-07 00:51:46 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2020-12-07 00:51:46 +0300
commit62ced878b526d49e5ef6ad42ca2eb7efc874867a (patch)
tree768c03f4870d1a8f67104e36d8055c385a526aed
parent40d971c988fd9ccfb82cc6aaacc57ca1ad477d52 (diff)
downloadatracdenc-62ced878b526d49e5ef6ad42ca2eb7efc874867a.tar.gz
Fix range to search proper bit allocation
In some cases we have quite small target number of bits so we unable to fit without reducing BFU number. But current algorithm starts reduce BFU only after succeful (from bit numbet perspctive) allocation. Which mean we must create zero allocation and only after that we restart allocation with reduced bfu number. The issue was the range to shift SNR was not enough to create zerro allocation in some cases.
-rw-r--r--src/atrac/atrac3_bitstream.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/atrac/atrac3_bitstream.cpp b/src/atrac/atrac3_bitstream.cpp
index df0130c..5343579 100644
--- a/src/atrac/atrac3_bitstream.cpp
+++ b/src/atrac/atrac3_bitstream.cpp
@@ -191,15 +191,15 @@ std::pair<uint8_t, vector<uint32_t>> TAtrac3BitStreamWriter::CreateAllocation(co
bool cont = true;
while (cont) {
precisionPerEachBlocks.resize(numBfu);
- TFloat maxShift = 15;
- TFloat minShift = -3;
+ TFloat maxShift = 20;
+ TFloat minShift = -8;
for (;;) {
TFloat shift = (maxShift + minShift) / 2;
const vector<uint32_t>& tmpAlloc = CalcBitsAllocation(scaledBlocks, numBfu, spread, shift);
auto consumption = CalcSpecsBitsConsumption(sce, tmpAlloc, mt);
auto bitsUsedByTonal = EncodeTonalComponents(sce, tmpAlloc, nullptr);
- //std::cerr << consumption.second << " |tonal: " << bitsUsedByTonal << " target: " << targetBits << " shift " << shift << " max | min " << maxShift << " " << minShift << std::endl;
+// std::cerr << consumption.second << " |tonal: " << bitsUsedByTonal << " target: " << targetBits << " shift " << shift << " max | min " << maxShift << " " << minShift << " numBfu: " << numBfu << std::endl;
consumption.second += bitsUsedByTonal;
if (consumption.second < targetBits) {