swscale/unscaled: fix rgbToRgbWrapper for non-native-endian formats

The fix from 5fa2a65c11 introduced a regression for non-native-endian
formats (such as rgb565be on a little-endian system).

Reproducible with:
$ ./libswscale/tests/swscale -unscaled 1 -src rgb565be -dst rgb24

Also:
$ ./ffmpeg_g -i /opt/samples/jpegls/128.jls -vf "scale=size=512x512,format=rgb24,scale=flags=neighbor,format=rgb565be" -f rawvideo -vframes 1 -y rgb565be.raw
$ magick -size 512x512 -endian MSB RGB565:rgb565be.raw output.png
$ ./ffplay_g output.png

(note: don't use ffmpeg to convert from rgb565be.raw to output for the
test above since it will perform the same bug and cancel out the error)
This commit is contained in:
Ramiro Polla
2026-05-12 15:03:11 +02:00
parent d812c8b0eb
commit d0a84c660a
+2 -3
View File
@@ -1847,9 +1847,8 @@ static rgbConvFn findRgbConvFn(SwsInternal *c)
const int dstId = c->dstFormatBpp;
rgbConvFn conv = NULL;
#define IS_NOT_NE(bpp, desc) \
(((bpp + 7) >> 3) == 2 && \
(!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
#define IS_NOT_NE(Bpp, desc) \
(Bpp == 2 && (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
#define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)