This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 5f1be98f62c1fb692e19c4c13ca342fa6606d733 Author: Niklas Haas <[email protected]> AuthorDate: Tue Dec 23 14:36:42 2025 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Wed Dec 24 16:37:22 2025 +0000 swscale/ops: add SWS_COMP_SWAPPED This flag keeps track of whether a pixel is currently byte-swapped or not. Not needed by current backends, but informative and useful for catching potential endianness errors. Updates a lot of FATE tests with a cosmetic diff like this: rgb24 -> gray16be: [ u8 XXXX -> +++X] SWS_OP_READ : 3 elem(s) packed >> 0 [ u8 ...X -> +++X] SWS_OP_CONVERT : u8 -> f32 [f32 ...X -> .++X] SWS_OP_LINEAR : dot3 [...] [f32 .XXX -> +++X] SWS_OP_CONVERT : f32 -> u16 - [u16 .XXX -> +++X] SWS_OP_SWAP_BYTES - [u16 .XXX -> +++X] SWS_OP_WRITE : 1 elem(s) planar >> 0 - (X = unused, + = exact, 0 = zero) + [u16 .XXX -> zzzX] SWS_OP_SWAP_BYTES + [u16 .XXX -> zzzX] SWS_OP_WRITE : 1 elem(s) planar >> 0 + (X = unused, z = byteswapped, + = exact, 0 = zero) (The choice of `z` to represent swapped integers is arbitrary, but I think it's visually evocative and distinct from the other symbols) --- libswscale/format.c | 9 ++++++--- libswscale/ops.c | 9 +++++++-- libswscale/ops.h | 1 + tests/ref/fate/sws-ops-list | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libswscale/format.c b/libswscale/format.c index 6b88fa4c5d..ea7b5b5ebe 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -906,8 +906,11 @@ 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); - for (int i = 0; i < rw_op.elems; i++) - comps.flags[i] = (integer ? SWS_COMP_EXACT : 0); + const int swapped = (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); + } /* Generate value range information for simple unpacked formats */ if (integer && !unpack.pattern[0]) { @@ -931,7 +934,7 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, enum AVPixelFormat fmt) .comps = comps, })); - if ((desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG) { + if (swapped) { RET(ff_sws_op_list_append(ops, &(SwsOp) { .op = SWS_OP_SWAP_BYTES, .type = raw_type, diff --git a/libswscale/ops.c b/libswscale/ops.c index 3fd6f678f5..0b07b21158 100644 --- a/libswscale/ops.c +++ b/libswscale/ops.c @@ -274,11 +274,14 @@ void ff_sws_op_list_update_comps(SwsOpList *ops) op->comps.max[i] = prev.max[i]; } break; + case SWS_OP_SWAP_BYTES: + for (int i = 0; i < 4; i++) + op->comps.flags[i] = prev.flags[i] ^ SWS_COMP_SWAPPED; + break; case SWS_OP_WRITE: for (int i = 0; i < op->rw.elems; i++) av_assert1(!(prev.flags[i] & SWS_COMP_GARBAGE)); /* fall through */ - case SWS_OP_SWAP_BYTES: case SWS_OP_LSHIFT: case SWS_OP_RSHIFT: case SWS_OP_MIN: @@ -620,6 +623,8 @@ static char describe_comp_flags(unsigned flags) return 'X'; else if (flags & SWS_COMP_ZERO) return '0'; + else if (flags & SWS_COMP_SWAPPED) + return 'z'; else if (flags & SWS_COMP_EXACT) return '+'; else @@ -763,7 +768,7 @@ void ff_sws_op_list_print(void *log, int lev, const SwsOpList *ops) } - av_log(log, lev, " (X = unused, + = exact, 0 = zero)\n"); + av_log(log, lev, " (X = unused, z = byteswapped, + = exact, 0 = zero)\n"); } int ff_sws_ops_compile_backend(SwsContext *ctx, const SwsOpBackend *backend, diff --git a/libswscale/ops.h b/libswscale/ops.h index a91b63e63a..d3d06b30e9 100644 --- a/libswscale/ops.h +++ b/libswscale/ops.h @@ -73,6 +73,7 @@ enum SwsCompFlags { SWS_COMP_GARBAGE = 1 << 0, /* contents are undefined / garbage data */ SWS_COMP_EXACT = 1 << 1, /* value is an exact integer */ SWS_COMP_ZERO = 1 << 2, /* known to be a constant zero */ + SWS_COMP_SWAPPED = 1 << 3, /* byte order is swapped */ }; typedef union SwsConst { diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list index a7d6149d8b..0458a25df4 100644 --- a/tests/ref/fate/sws-ops-list +++ b/tests/ref/fate/sws-ops-list @@ -1 +1 @@ -ef1dd10af970984495f6008e43d0fe1b +6b2360c6fa99f5d0e428a97dfeff7189 _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
