From 4e36265deadfb6e5ae951578bc69a7ac11aded16 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 20 Feb 2026 16:59:07 +0100 Subject: [PATCH] swscale/format: don't mark single byte formats as byte swapped Fixes a bug where all format lists contained redundant byte swapped annotations on big-endian platforms, even for single-byte formats. --- libswscale/format.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libswscale/format.c b/libswscale/format.c index eb56994beb..017df9f69a 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -936,7 +936,8 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, enum AVPixelFormat fmt) /* Set baseline pixel content flags */ const int integer = ff_sws_pixel_type_is_int(raw_type); - const int swapped = (desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG; + const int swapped = ff_sws_pixel_type_size(raw_type) > 1 && + (desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG; for (int i = 0; i < rw_op.elems; i++) { comps->flags[i] = (integer ? SWS_COMP_EXACT : 0) | (swapped ? SWS_COMP_SWAPPED : 0); @@ -1057,7 +1058,8 @@ int ff_sws_encode_pixfmt(SwsOpList *ops, enum AVPixelFormat fmt) })); } - if ((desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG) { + if (ff_sws_pixel_type_size(raw_type) > 1 && + (desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG) { RET(ff_sws_op_list_append(ops, &(SwsOp) { .op = SWS_OP_SWAP_BYTES, .type = raw_type,