diff options
| author | Daniil Cherednik <[email protected]> | 2016-06-19 02:58:23 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2016-06-19 03:31:55 +0300 |
| commit | 1151d5831f19a9f24dd0c545a4968606712a62d2 (patch) | |
| tree | c978c1b9a3fc86fef531dd412fe6b7668b7c0567 /src/bitstream/bitstream.cpp | |
| parent | 8d65a0bd0774e03b3d10354e15f2f3361a2ce26a (diff) | |
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/bitstream/bitstream.cpp')
| -rw-r--r-- | src/bitstream/bitstream.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bitstream/bitstream.cpp b/src/bitstream/bitstream.cpp index d916f52..e8f1857 100644 --- a/src/bitstream/bitstream.cpp +++ b/src/bitstream/bitstream.cpp @@ -11,7 +11,6 @@ TBitStream::TBitStream(const char* buf, int size) {} TBitStream::TBitStream() {} - void TBitStream::Write(unsigned long long val, int n) { if (n > 23 || n < 0) abort(); @@ -29,10 +28,30 @@ void TBitStream::Write(unsigned long long val, int n) { for (int i = 0; i < n/8 + (overlap ? 2 : 1); ++i) { Buf[bytesPos+i] |= t.bytes[7-i]; + + // std::cout << "bufPos: "<< bytesPos+i << " buf: " << (int)Buf[bytesPos+i] << std::endl; } BitsUsed += n; } +/* +void TBitStream::Write(unsigned long long val, int n) { + if (n > 23 || n < 0) + abort(); + const int bitsLeft = Buf.size() * 8 - BitsUsed; + const int bitsReq = n - bitsLeft; + const int bytesPos = BitsUsed / 8; + const int overlap = BitsUsed % 8; + + if (overlap || bitsReq >= 0) { + Buf.resize(Buf.size() + (bitsReq / 8 + (overlap ? 2 : 1 )), 0); + } + TMix t; + t.ull = (val << (64 - n)) >> overlap; + *(unsigned long long*)&Buf[bytesPos-8] |= t.ull; + BitsUsed += n; +} +*/ unsigned long long TBitStream::Read(int n) { if (n >23 || n < 0) abort(); |
