RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
DummyPrefixCodeDecoder.h
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2022 Roman Lebedev
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#pragma once
22
23#include "adt/Invariant.h"
26#include "codes/HuffmanCode.h"
27#include "codes/PrefixCode.h"
28
29namespace rawspeed {
30class Buffer;
31
32template <typename CodeTag = BaselineCodeTag>
34public:
35 using Tag = CodeTag;
37
40
41private:
42 bool fullDecode = true;
43 bool fixDNGBug16 = false;
44
45public:
46 void setup(bool fullDecode_, bool fixDNGBug16_) {
47 fullDecode = fullDecode_;
48 fixDNGBug16 = fixDNGBug16_;
49 }
50
51 [[nodiscard]] bool isFullDecode() const { return fullDecode; }
52
53 template <typename BIT_STREAM>
54 typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const {
55 static_assert(
57 "This BitStreamer specialization is not marked as usable here");
60 }
61
62 template <typename BIT_STREAM> int decodeDifference(BIT_STREAM& bs) const {
63 static_assert(
65 "This BitStreamer specialization is not marked as usable here");
67 return decode<BIT_STREAM, true>(bs);
68 }
69
70 // The bool template paraeter is to enable two versions:
71 // one returning only the length of the of diff bits (see Hasselblad),
72 // one to return the fully decoded diff.
73 // All ifs depending on this bool will be optimized out by the compiler
74 template <typename BIT_STREAM, bool FULL_DECODE>
75 int decode(BIT_STREAM& bs) const {
76 static_assert(
78 "This BitStreamer specialization is not marked as usable here");
79 invariant(FULL_DECODE == fullDecode);
80
81 (void)bs;
82
83 return 0; // The answer is always the same.
84 }
85};
86
87} // namespace rawspeed
#define invariant(expr)
Definition Invariant.h:27
DummyPrefixCodeDecoder(PrefixCode< CodeTag > code)
int decodeDifference(BIT_STREAM &bs) const
void setup(bool fullDecode_, bool fixDNGBug16_)
DummyPrefixCodeDecoder(HuffmanCode< CodeTag > code)
Traits::CodeValueTy decodeCodeValue(BIT_STREAM &bs) const