Skip to content

Commit

Permalink
Fix decoding of piz when y sampling is not the same for all channels (#…
Browse files Browse the repository at this point in the history
…1183)

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd authored Oct 19, 2021
1 parent decd533 commit f44097e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/lib/OpenEXRCore/internal_piz.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,10 @@ internal_exr_apply_piz (exr_encode_pipeline_t* encode)
if (nBytes == 0) continue;

tmp = scratch;
scratch += nBytes;
if (curc->y_samples > 1)
{
if ((cury % curc->y_samples) != 0)
{
scratch += nBytes;
continue;
}
if ((cury % curc->y_samples) != 0) continue;
tmp += ((uint64_t) (y / curc->y_samples)) * bpl;
}
else
Expand All @@ -475,7 +472,6 @@ internal_exr_apply_piz (exr_encode_pipeline_t* encode)
memcpy (tmp, packed, bpl);
priv_to_native16 (tmp, nx * (curc->bytes_per_element / 2));
packed += bpl;
scratch += nBytes;
}
}

Expand Down Expand Up @@ -628,7 +624,7 @@ internal_exr_undo_piz (
if (nBytes + hufbytes > packsz) return EXR_ERR_CORRUPT_CHUNK;

wavbuf = decode->scratch_buffer_1;
rv = internal_huf_decompress (
rv = internal_huf_decompress (
packed + nBytes, hufbytes, wavbuf, outsz / 2, hufspare, hufSpareBytes);
if (rv != EXR_ERR_SUCCESS) return rv;

Expand Down Expand Up @@ -679,6 +675,8 @@ internal_exr_undo_piz (
if (nBytes == 0) continue;

tmp = scratch;
scratch += ((uint64_t) ny) * nBytes;

if (curc->y_samples > 1)
{
if ((cury % curc->y_samples) != 0) continue;
Expand All @@ -691,7 +689,6 @@ internal_exr_undo_piz (
priv_from_native16 (out, nx * (curc->bytes_per_element / 2));
out += nBytes;
nOut += nBytes;
scratch += ((uint64_t) ny) * nBytes;
}
}

Expand Down

0 comments on commit f44097e

Please sign in to comment.