summaryrefslogtreecommitdiff
path: root/src/codecs/include
diff options
context:
space:
mode:
authorayumi <ayumi@noreply.codeberg.org>2025-01-31 19:08:39 +0100
committerayumi <ayumi@noreply.codeberg.org>2025-03-13 03:29:03 +0100
commit885eb1812c15263ad759741ad138cf7188fdf739 (patch)
tree24aff12a5d67f77675281fd70c0857164e913331 /src/codecs/include
parenta3639860761dcdb5ef9c31bb34497f32cadd9ff3 (diff)
downloadtangara-fw-885eb1812c15263ad759741ad138cf7188fdf739.tar.gz
Add WavPack support
Diffstat (limited to 'src/codecs/include')
-rw-r--r--src/codecs/include/types.hpp1
-rw-r--r--src/codecs/include/wavpack.hpp46
2 files changed, 47 insertions, 0 deletions
diff --git a/src/codecs/include/types.hpp b/src/codecs/include/types.hpp
index 2bc63b10..493a177a 100644
--- a/src/codecs/include/types.hpp
+++ b/src/codecs/include/types.hpp
@@ -17,6 +17,7 @@ enum class StreamType {
kOpus,
kWav,
kNative,
+ kWavPack,
};
auto StreamTypeToString(StreamType t) -> std::string;
diff --git a/src/codecs/include/wavpack.hpp b/src/codecs/include/wavpack.hpp
new file mode 100644
index 00000000..4780b6b6
--- /dev/null
+++ b/src/codecs/include/wavpack.hpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2025 ayumi <ayumi@noreply.codeberg.org>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <utility>
+
+#include "wavpack.h"
+#include "sample.hpp"
+
+#include "codec.hpp"
+
+namespace codecs {
+
+class WavPackDecoder : public ICodec {
+ public:
+ WavPackDecoder();
+ ~WavPackDecoder();
+
+ auto OpenStream(std::shared_ptr<IStream> input, uint32_t offset)
+ -> cpp::result<OutputFormat, Error> override;
+
+ auto DecodeTo(std::span<sample::Sample> destination)
+ -> cpp::result<OutputInfo, Error> override;
+
+ WavPackDecoder(const WavPackDecoder&) = delete;
+ WavPackDecoder& operator=(const WavPackDecoder&) = delete;
+
+ private:
+ std::shared_ptr<IStream> input_;
+ WavpackContext wavpack_;
+ int32_t *buf_;
+ uint8_t bitdepth_;
+ uint8_t channels_;
+ size_t size_;
+};
+
+} // namespace codecs