Skip to content

Commit

Permalink
mb_shuffle big endian
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Jun 1, 2024
1 parent ed15ed9 commit fb7702f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,33 @@ shuffle_mb_unavail(UINT8 *dst, const UINT8 *src, int pixels) {

static void
mb_shuffle(UINT8 *dst, const UINT8 *src, Imaging im, ImagingCodecState state) {
memcpy(dst, src, state->xsize * im->pixelsize);
int size = state->xsize * im->pixelsize;
#ifdef WORDS_BIGENDIAN
switch (im->depth) {
default:
abort();
return;
case 4 * CHAR_BIT: {
for (int i = 0; i < size; i += 4) {
dst[i] = src[i + 3];
dst[i + 1] = src[i + 2];
dst[i + 2] = src[i + 1];
dst[i + 3] = src[i];
}
return;
}
case 2 * CHAR_BIT: {
for (int i = 0; i < size; i += 2) {
dst[i] = src[i + 1];
dst[i + 1] = src[i];
}
return;
case CHAR_BIT:
// fallthrough
}
}
#endif
memcpy(dst, src, size);
}

static int
Expand Down

0 comments on commit fb7702f

Please sign in to comment.