aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac/at3p/at3p_bitstream.cpp
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-06-18 23:01:36 +0000
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-06-26 20:14:13 +0000
commit1d99ba9937d6588f4b00dc3766e165e9e3ff834d (patch)
tree931a13e03da012f856b42677f87a7c5b5568c714 /src/atrac/at3p/at3p_bitstream.cpp
parent23a4e5f1dd7ce24f65a2af0598d1f92af4b5c424 (diff)
downloadatracdenc-1d99ba9937d6588f4b00dc3766e165e9e3ff834d.tar.gz
[AT3P] Introduce at3p development branch
- Simpe code just to produce correct at3p zero frame
Diffstat (limited to 'src/atrac/at3p/at3p_bitstream.cpp')
-rw-r--r--src/atrac/at3p/at3p_bitstream.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/atrac/at3p/at3p_bitstream.cpp b/src/atrac/at3p/at3p_bitstream.cpp
new file mode 100644
index 0000000..7bf5829
--- /dev/null
+++ b/src/atrac/at3p/at3p_bitstream.cpp
@@ -0,0 +1,61 @@
+/*
+ * This file is part of AtracDEnc.
+ *
+ * AtracDEnc is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * AtracDEnc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with AtracDEnc; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "at3p_bitstream.h"
+#include <lib/bitstream/bitstream.h>
+#include <env.h>
+#include <iostream>
+
+namespace NAtracDEnc {
+
+TAt3PBitStream::TAt3PBitStream(ICompressedOutput* container, uint16_t frameSz)
+ : Container(container)
+ , FrameSz(frameSz)
+{
+ NEnv::SetRoundFloat();
+}
+
+void TAt3PBitStream::WriteFrame(int channels)
+{
+ NBitStream::TBitStream bitStream;
+ // First bit must be zero
+ bitStream.Write(0, 1);
+ // Channel block type
+ // 0 - MONO block
+ // 1 - STEREO block
+ // 2 - Nobody know
+ bitStream.Write(channels - 1, 2);
+
+ // Skip some bits to produce correct zero bitstream
+ bitStream.Write(0, 10);
+ if (channels == 2) {
+ bitStream.Write(0, 14);
+ } else {
+ bitStream.Write(0, 5);
+ }
+ // Terminator
+ bitStream.Write(3, 2);
+
+ std::vector<char> buf = bitStream.GetBytes();
+
+ buf.resize(FrameSz);
+ Container->WriteFrame(buf);
+}
+
+}