PR #23084 opened by Ramiro Polla (ramiro)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23084
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23084.patch

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)


>From cfa4cbe04567a7a9efdd74533281dd13eb35a5bc Mon Sep 17 00:00:00 2001
From: Ramiro Polla <[email protected]>
Date: Tue, 12 May 2026 15:03:11 +0200
Subject: [PATCH] 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)
---
 libswscale/swscale_unscaled.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index f1245811bd..0ecef7d44a 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -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)
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to