summaryrefslogtreecommitdiff
path: root/src/codecs/include/wavpack.hpp
blob: 4780b6b6f6ffb095bcff16553b90d81715432021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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