RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
PanasonicV4Decompressor.h
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017-2018 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/Point.h"
24#include "common/RawImage.h"
26#include "io/ByteStream.h"
27#include <cstdint>
28#include <vector>
29
30namespace rawspeed {
31
33 static constexpr uint32_t BlockSize = 0x4000;
34
35 static constexpr int PixelsPerPacket = 14;
36
37 static constexpr uint32_t BytesPerPacket = 16;
38
40
42
43 class ProxyStream;
44
48
49 // The RW2 raw image buffer is split into sections of BufSize bytes.
50 // If section_split_offset is 0, then the last section is not necessarily
51 // full. If section_split_offset is not 0, then each section has two parts:
52 // bytes: [0..section_split_offset-1][section_split_offset..BufSize-1]
53 // pixels: [a..b][0..a-1]
54 // I.e. these two parts need to be swapped around.
56
57 struct Block final {
60 // The rectangle is an incorrect representation. All the rows
61 // between the first and last one span the entire width of the image.
63
64 Block() = default;
65 Block(ByteStream bs_, iPoint2D beginCoord_, iPoint2D endCoord_)
66 : bs(bs_), beginCoord(beginCoord_), endCoord(endCoord_) {}
67 };
68
69 // If really wanted, this vector could be avoided,
70 // and each Block computed on-the-fly
71 std::vector<Block> blocks;
72
74
75 inline void
76 processPixelPacket(ProxyStream& bits, int row, int col,
77 std::vector<uint32_t>* zero_pos) const noexcept;
78
79 void processBlock(const Block& block,
80 std::vector<uint32_t>* zero_pos) const noexcept;
81
82 void decompressThread() const noexcept;
83
84public:
85 PanasonicV4Decompressor(RawImage img, ByteStream input_, bool zero_is_not_bad,
86 uint32_t section_split_offset_);
87
88 void decompress() const noexcept;
89};
90
91} // namespace rawspeed
static constexpr uint32_t PacketsPerBlock
void processPixelPacket(ProxyStream &bits, int row, int col, std::vector< uint32_t > *zero_pos) const noexcept
void processBlock(const Block &block, std::vector< uint32_t > *zero_pos) const noexcept
PanasonicV4Decompressor(RawImage img, ByteStream input_, bool zero_is_not_bad, uint32_t section_split_offset_)
Block(ByteStream bs_, iPoint2D beginCoord_, iPoint2D endCoord_)