aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac/at3p/at3p_gha.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-07-31 22:07:21 +0000
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-07-31 22:07:21 +0000
commit61c74a7dab606653ae82153786031b6a0260ec16 (patch)
tree8663519b21a95f3e7821b53832d2199b6698da74 /src/atrac/at3p/at3p_gha.h
parentf1c9056c40e22b6aea21da5281e469b93a334778 (diff)
downloadatracdenc-61c74a7dab606653ae82153786031b6a0260ec16.tar.gz
[AT3P] Add GHA related bitstream code
* borrow Huffman table from FFmpeg * code (with ut) to pack frequency part of GHA block * some related data structures * bitstrem modification to write correct GHA block * switch compile flag to use float data type
Diffstat (limited to 'src/atrac/at3p/at3p_gha.h')
-rw-r--r--src/atrac/at3p/at3p_gha.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/atrac/at3p/at3p_gha.h b/src/atrac/at3p/at3p_gha.h
new file mode 100644
index 0000000..4625ac3
--- /dev/null
+++ b/src/atrac/at3p/at3p_gha.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <config.h>
+#include <libgha/include/libgha.h>
+
+#include <vector>
+
+static_assert(sizeof(TFloat) == sizeof(float), "TFloat must be float32");
+namespace NAtracDEnc {
+
+struct TAt3PGhaData {
+ struct TWaveParam {
+ uint32_t FreqIndex;
+ uint32_t AmpSf;
+ uint32_t AmpIndex;
+ uint32_t PhaseIndex;
+ struct gha_info orig_gha_info;
+ };
+ struct TWaveSbInfo {
+ size_t WaveIndex;
+ size_t WaveNums;
+ };
+ struct TWavesChannel {
+ std::vector<TWaveSbInfo> WaveSbInfos;
+ std::vector<TWaveParam> WaveParams;
+ };
+ std::array<TWavesChannel, 2> Waves;
+
+ uint8_t NumToneBands;
+ uint8_t SecondChBands[16];
+
+ size_t GetNumWaves(size_t ch, size_t sb) const {
+ return Waves[ch].WaveSbInfos.at(sb).WaveNums;
+ }
+
+ std::pair<const TWaveParam*, size_t> GetWaves(size_t ch, size_t sb) const {
+ const auto& sbInfo = Waves[ch].WaveSbInfos.at(sb);
+ return { &Waves[ch].WaveParams[sbInfo.WaveIndex], sbInfo.WaveNums };
+ }
+};
+
+} // namespace NAtracDEnc
+