diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-06-19 02:58:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-06-19 03:31:55 +0300 |
commit | 1151d5831f19a9f24dd0c545a4968606712a62d2 (patch) | |
tree | c978c1b9a3fc86fef531dd412fe6b7668b7c0567 /src/atrac/atrac1.h | |
parent | 8d65a0bd0774e03b3d10354e15f2f3361a2ce26a (diff) | |
download | atracdenc-1151d5831f19a9f24dd0c545a4968606712a62d2.tar.gz |
some improvements of ATRAC3 implementation:atrac3
- simple (ATRAC1 like) psychoacoustic added
- possibility to encode tonal components
- simple tonal component extractor
- refactoring
Diffstat (limited to 'src/atrac/atrac1.h')
-rw-r--r-- | src/atrac/atrac1.h | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/src/atrac/atrac1.h b/src/atrac/atrac1.h index cb0df1f..9736ea7 100644 --- a/src/atrac/atrac1.h +++ b/src/atrac/atrac1.h @@ -4,23 +4,52 @@ #include <map> #include <math.h> #include "../bitstream/bitstream.h" -const int QMF_BANDS = 3; -const int MAX_BFUS = 52; +namespace NAtracDEnc { +namespace NAtrac1 { + +class TAtrac1EncodeSettings { +public: + enum class EWindowMode { + EWM_NOTRANSIENT, + EWM_AUTO + }; +private: + const uint32_t BfuIdxConst = 0; + const bool FastBfuNumSearch = false; + EWindowMode WindowMode = EWindowMode::EWM_AUTO; + const uint32_t WindowMask = 0; +public: + TAtrac1EncodeSettings() + {} + TAtrac1EncodeSettings(uint32_t bfuIdxConst, bool fastBfuNumSearch, EWindowMode windowMode, uint32_t windowMask) + : BfuIdxConst(bfuIdxConst) + , FastBfuNumSearch(fastBfuNumSearch) + , WindowMode(windowMode) + , WindowMask(windowMask) + {} + uint32_t GetBfuIdxConst() const { return BfuIdxConst; } + bool GetFastBfuNumSearch() const { return FastBfuNumSearch; } + EWindowMode GetWindowMode() const {return WindowMode; } + uint32_t GetWindowMask() const {return WindowMask; } +}; class TAtrac1Data { +public: + static constexpr uint8_t MaxBfus = 52; + static constexpr uint8_t NumQMF = 3; protected: - static constexpr uint32_t SpecsPerBlock[MAX_BFUS] = { + static constexpr uint32_t SpecsPerBlock[MaxBfus] = { 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, // low band 6, 6, 6, 6, 7, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, // middle band 12, 12, 12, 12, 12, 12, 12, 12, 20, 20, 20, 20, 20, 20, 20, 20 // high band }; - static constexpr uint32_t BlocksPerBand[QMF_BANDS + 1] = {0, 20, 36, 52}; - static constexpr uint32_t SpecsStartLong[MAX_BFUS] = { + static constexpr uint32_t BlocksPerBand[NumQMF + 1] = {0, 20, 36, 52}; + static constexpr uint32_t SpecsStartLong[MaxBfus] = { 0, 8, 16, 24, 32, 36, 40, 44, 48, 56, 64, 72, 80, 86, 92, 98, 104, 110, 116, 122, 128, 134, 140, 146, 152, 159, 166, 173, 180, 189, 198, 207, 216, 226, 236, 246, 256, 268, 280, 292, 304, 316, 328, 340, 352, 372, 392, 412, 432, 452, 472, 492, }; - static constexpr uint32_t SpecsStartShort[MAX_BFUS] = { + static constexpr uint32_t SpecsStartShort[MaxBfus] = { 0, 32, 64, 96, 8, 40, 72, 104, 12, 44, 76, 108, 20, 52, 84, 116, 26, 58, 90, 122, 128, 160, 192, 224, 134, 166, 198, 230, 141, 173, 205, 237, 150, 182, 214, 246, 256, 288, 320, 352, 384, 416, 448, 480, 268, 300, 332, 364, 396, 428, 460, 492 @@ -30,8 +59,6 @@ protected: static const uint32_t BitsPerBfuAmountTabIdx = 3; static const uint32_t BitsPerIDWL = 4; static const uint32_t BitsPerIDSF = 6; - static const uint32_t NumSamples = 512; - static const uint8_t NumQMF = QMF_BANDS; static double ScaleTable[64]; static double SineWindow[32]; @@ -43,6 +70,7 @@ protected: return 2; } public: + static const uint32_t NumSamples = 512; TAtrac1Data() { if (ScaleTable[0] == 0) { for (uint32_t i = 0; i < 64; i++) { @@ -57,30 +85,5 @@ public: } }; -class TBlockSize { - static std::array<int, QMF_BANDS> Parse(NBitStream::TBitStream* stream) { - std::array<int,QMF_BANDS> tmp; - tmp[0] = 2 - stream->Read(2); - tmp[1] = 2 - stream->Read(2); - tmp[2] = 3 - stream->Read(2); - stream->Read(2); //skip unused 2 bits - return tmp; - } - static std::array<int,QMF_BANDS> Create(bool lowShort, bool midShort, bool hiShort) { - std::array<int,QMF_BANDS> tmp; - tmp[0] = lowShort ? 2 : 0; - tmp[1] = midShort ? 2 : 0; - tmp[2] = hiShort ? 3 : 0; - return tmp; - } -public: - TBlockSize(NBitStream::TBitStream* stream) - : LogCount(Parse(stream)) - {} - TBlockSize(bool lowShort, bool midShort, bool hiShort) - : LogCount(Create(lowShort, midShort, hiShort)) - {} - const std::array<int,QMF_BANDS> LogCount; -}; - - +} //namespace NAtrac1 +} //namespace NAtracDEnc |