1 /*
2     RawSpeed - RAW file decoder.
3 
4     Copyright (C) 2017 Axel Waggershauser
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 "decompressors/AbstractLJpegDecompressor.h" // for AbstractLJpegDe...
24 #include <cstdint>                                   // for uint32_t
25 
26 namespace rawspeed {
27 
28 class ByteStream;
29 class RawImage;
30 
31 // Decompresses Lossless JPEGs, with 2-4 components
32 
33 class LJpegDecompressor final : public AbstractLJpegDecompressor
34 {
35   void decodeScan() override;
36   template <int N_COMP, bool WeirdWidth = false> void decodeN();
37 
38   uint32_t offX = 0;
39   uint32_t offY = 0;
40   uint32_t w = 0;
41   uint32_t h = 0;
42 
43   uint32_t fullBlocks = 0;
44   uint32_t trailingPixels = 0;
45 
46 public:
47   LJpegDecompressor(const ByteStream& bs, const RawImage& img);
48 
49   void decode(uint32_t offsetX, uint32_t offsetY, uint32_t width,
50               uint32_t height, bool fixDng16Bug_);
51 };
52 
53 } // namespace rawspeed
54