diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-03-13 09:49:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-09-02 21:21:28 +0300 |
commit | cfaa2cd39b7256a868a4f5cd83aac207df6bd1b3 (patch) | |
tree | 75efff26584e046566d17cd308d45b6b0fd5abfc /src/bitstream/bitstream.cpp | |
parent | b4df8a7c2dd12eea27c8cc52bd52a1bb8c00943f (diff) | |
download | atracdenc-cfaa2cd39b7256a868a4f5cd83aac207df6bd1b3.tar.gz |
Dirty implementation of atrac3 encoder:
- no JS mode
- constant quantiser for tonal components
- gain controll implemented but produces some artifacts with real signals.
- etc...
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(); |