RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
LJpegDecompressor.h
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017 Axel Waggershauser
5 Copyright (C) 2023 Roman Lebedev
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#pragma once
23
24#include "adt/Array1DRef.h"
25#include "adt/Array2DRef.h"
26#include "adt/Point.h"
29#include "common/RawImage.h"
30#include "io/ByteStream.h"
31#include <array>
32#include <cstddef>
33#include <cstdint>
34#include <functional>
35#include <utility>
36#include <vector>
37
38namespace rawspeed {
39
40// Decompresses Lossless JPEGs, with 2-4 components
41
42class LJpegDecompressor final {
43public:
44 struct Frame final {
47 };
52
53private:
56
58
59 const Frame frame;
60 const std::vector<PerComponentRecipe> rec;
62
63 int numFullMCUs = 0;
65
66 template <int N_COMP, size_t... I>
67 [[nodiscard]] std::array<std::reference_wrapper<const PrefixCodeDecoder<>>,
68 N_COMP>
69 getPrefixCodeDecodersImpl(std::index_sequence<I...> /*unused*/) const;
70
71 template <int N_COMP>
72 [[nodiscard]] std::array<std::reference_wrapper<const PrefixCodeDecoder<>>,
73 N_COMP>
75
76 template <int N_COMP>
77 [[nodiscard]] std::array<uint16_t, N_COMP> getInitialPreds() const;
78
79 template <const iPoint2D& MCUSize, int N_COMP>
80 __attribute__((always_inline)) inline void decodeRowN(
82 std::array<std::reference_wrapper<const PrefixCodeDecoder<>>, N_COMP> ht,
83 BitStreamerJPEG& bs) const;
84
85 template <const iPoint2D& MCUSize>
86 [[nodiscard]] __attribute__((noinline)) ByteStream::size_type decodeN() const;
87
88public:
90 std::vector<PerComponentRecipe> rec,
91 int numLJpegRowsPerRestartInterval_,
93
94 [[nodiscard]] ByteStream::size_type decode() const;
95};
96
97} // namespace rawspeed
uint32_t size_type
Definition Buffer.h:49
const std::vector< PerComponentRecipe > rec
LJpegDecompressor(RawImage img, iRectangle2D imgFrame, Frame frame, std::vector< PerComponentRecipe > rec, int numLJpegRowsPerRestartInterval_, Array1DRef< const uint8_t > input)
const Array1DRef< const uint8_t > input
Array2DRef< const uint16_t > pred
std::array< std::reference_wrapper< const PrefixCodeDecoder<> >, N_COMP > getPrefixCodeDecoders() const
Array2DRef< const uint16_t > std::array< std::reference_wrapper< const PrefixCodeDecoder<> >, N_COMP > ht
std::array< uint16_t, N_COMP > getInitialPreds() const
ByteStream::size_type decode() const
std::array< std::reference_wrapper< const PrefixCodeDecoder<> >, N_COMP > getPrefixCodeDecodersImpl(std::index_sequence< I... >) const
__attribute__((always_inline)) inline void decodeRowN(Array2DRef< uint16_t > outStripe
PrefixCodeLUTDecoder< CodeTag, PrefixCodeLookupDecoder< CodeTag > > PrefixCodeDecoder