68 ThrowIOE(
"Not enough data to decode a single line. Image file truncated.");
70 ThrowIOE(
"Image truncated, only %u of %u lines found", fullRows, *h);
82 const auto bpl = bpp * w;
91 if ((12 * w) % 8 != 0)
95 auto perline = (12 * w) / 8;
101 perline += ((w + 2) / 10);
108 int inputPitchBytes_,
int bitPerPixel_,
BitOrder order_)
109 :
input(input_.getStream(crop.
dim.
y, inputPitchBytes_)),
113 if (!
size.hasPositiveArea())
117 ThrowRDE(
"Input pitch is non-positive");
126 ThrowRDE(
"JPEG bit order not supported.");
135 if (cpp < 1 || cpp > 3)
136 ThrowRDE(
"Unsupported number of components per pixel: %u", cpp);
145 if (outPixelBits % 8 != 0) {
146 ThrowRDE(
"Bad combination of cpp (%u), bps (%d) and width (%u), the "
147 "pitch is %" PRIu64
" bits, which is not a multiple of 8 (1 byte)",
151 const auto outPixelBytes = outPixelBits / 8;
156 ThrowRDE(
"Specified pitch is smaller than minimally-required pitch");
171template <
typename Pump,
typename NarrowFpType>
174 Pump bits(
input.peekRemainingBuffer().getAsArray1DRef());
177 for (; row < rows; row++) {
178 for (
int col = 0; col < cols; col++) {
179 uint32_t b = bits.getBits(NarrowFpType::StorageWidth);
182 out(row,
offset.x + col) = std::bit_cast<float>(f);
188template <
typename Pump>
191 Pump bits(
input.peekRemainingBuffer().getAsArray1DRef());
194 for (; row < rows; row++) {
195 for (
int x = 0;
x < cols;
x++) {
216 reinterpret_cast<std::byte*
>(
219 reinterpret_cast<const std::byte*
>(
input.getData(
244 ThrowRDE(
"Unsupported floating-point input bitwidth/bit packing: %d / %u",
258 reinterpret_cast<std::byte*
>(
261 reinterpret_cast<const std::byte*
>(
input.getData(
270template <
bool uncorrectedRawValues>
280 for (
uint32_t row = 0; row < h; row++) {
281 for (
uint32_t col = 0; col < w; col++) {
282 if constexpr (uncorrectedRawValues)
283 out(row, col) = in(row, col);
285 mRaw->setWithLookUp(in(row, col),
286 reinterpret_cast<std::byte*
>(&out(row, col)),
296template <Endianness e>
300 static constexpr const auto bits = 12;
303 "unknown endianness");
305 static constexpr const auto shift = 16 - bits;
306 static constexpr const auto pack = 8 - shift;
307 static constexpr const auto mask = (1 << pack) - 1;
309 static_assert(bits == 12 && pack == 4,
"wrong pack");
311 static_assert(bits == 12 && mask == 0x0f,
"wrong mask");
320 for (
uint32_t row = 0; row < h; row++) {
336 process(
x,
false, g1, g2);
338 g1 = in(row, col + 2);
340 process(
x + 1,
true, g1, g2);
356template <Endianness e>
365 for (
int row = 0; row < static_cast<int>(h); row++) {
366 for (
int col = 0; col < static_cast<int>(w); ++col) {
367 uint32_t g1 = in(row, (2 * col) + 0);
368 uint32_t g2 = in(row, (2 * col) + 1);
375 out(row, col) = pix >> 4;
iPoint2D dim(rawspeed::implicit_cast< int >(ceil(sqSide *sqARatio)), rawspeed::implicit_cast< int >(ceil(sqSide/sqARatio)))
void decodePackedInt(int rows, int row) const
void decodePackedFP(int rows, int row) const
void readUncompressedRaw()
void sanityCheck(const uint32_t *h, int bytesPerLine) const
void decode12BitRawWithControl()
void decode12BitRawUnpackedLeftAligned()
static int bytesPerLine(int w, bool skips)
UncompressedDecompressor(ByteStream input, RawImage img, const iRectangle2D &crop, int inputPitchBytes, int bitPerPixel, BitOrder order)
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
void copyPixels(std::byte *destPtr, int dstPitch, const std::byte *srcPtr, int srcPitch, int rowSize, int height)
Array2DRef(Array1DRef< T > data, int width, int height, int pitch) -> Array2DRef< T >
Endianness getHostEndianness()
uint32_t extendBinaryFloatingPoint(uint32_t narrow)