libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
imagedatadecoder.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <cstddef>
14#include <cstdint>
15#include <promeki/namespace.h>
16#include <promeki/error.h>
17#include <promeki/result.h>
18#include <promeki/list.h>
19#include <promeki/imagedesc.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
24class Image;
25class UncompressedVideoPayload;
26
101class ImageDataDecoder {
102 public:
104 static constexpr uint32_t SyncBits = ImageDataEncoder::SyncBits;
106 static constexpr uint32_t PayloadBits = ImageDataEncoder::PayloadBits;
108 static constexpr uint32_t CrcBits = ImageDataEncoder::CrcBits;
110 static constexpr uint32_t BitsPerRow = ImageDataEncoder::BitsPerRow;
112 static constexpr uint8_t SyncNibble = ImageDataEncoder::SyncNibble;
113
117 enum class SampleMode {
122 AverageBand,
126 MiddleLine,
127 };
128
136 struct Band {
137 uint32_t firstLine;
138 uint32_t lineCount;
139 };
140
151 struct DecodedItem {
152 uint64_t payload = 0;
153 double bitWidth =
154 0;
155 uint32_t syncStartCol = 0;
156 uint8_t decodedSync =
157 0;
158 uint8_t decodedCrc = 0;
159 uint8_t expectedCrc = 0;
160 Error error = Error::Ok;
161 };
162
164 using DecodedList = ::promeki::List<DecodedItem>;
165
167 ImageDataDecoder() = default;
168
179 explicit ImageDataDecoder(const ImageDesc &desc);
180
182 bool isValid() const { return _valid; }
183
185 const ImageDesc &desc() const { return _desc; }
186
188 uint32_t expectedBitWidth() const { return _expectedBitWidth; }
189
191 uint32_t bitWidthMin() const { return _bitWidthMin; }
192
194 uint32_t bitWidthMax() const { return _bitWidthMax; }
195
197 SampleMode sampleMode() const { return _sampleMode; }
198
200 void setSampleMode(SampleMode mode) { _sampleMode = mode; }
201
221 Error decode(const UncompressedVideoPayload &payload, const List<Band> &bands, DecodedList &out) const;
222
227 DecodedItem decode(const UncompressedVideoPayload &payload, const Band &band) const;
228
229 private:
230 ImageDesc _desc;
231 uint32_t _expectedBitWidth = 0;
232 uint32_t _bitWidthMin = 0;
233 uint32_t _bitWidthMax = 0;
234 size_t _maxVSubsampling = 1;
235 SampleMode _sampleMode = SampleMode::AverageBand;
236 bool _valid = false;
237
238 DecodedItem decodeOne(const UncompressedVideoPayload &payload, const Band &band) const;
239};
240
241PROMEKI_NAMESPACE_END
242
243#endif // PROMEKI_ENABLE_PROAV