This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit aaa898a2d13625afd2c67d27e27ae60575d122cc Author: Niklas Haas <[email protected]> AuthorDate: Thu Jan 8 20:12:26 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Thu Feb 19 19:44:46 2026 +0000 swscale/optimizer: promote component swizzles to plane swizzles In some cases, we can just directly swizzle the order of input/output planes, rather than applying a swizzle operation on the data itself. This can eliminate some such swizzle operations entirely, for example yuv444p -> vuya is now just a read, clear and write. Results in a lot of simplifications like this: rgb24 -> gbrp: [ u8 XXXX -> +++X] SWS_OP_READ : 3 elem(s) packed >> 0 - [ u8 ...X -> +++X] SWS_OP_SWIZZLE : 1203 - [ u8 ...X -> +++X] SWS_OP_WRITE : 3 elem(s) planar >> 0 + [ u8 ...X -> +++X] SWS_OP_WRITE : 3 elem(s) planar >> 0, via {2, 0, 1} rgb24 -> gbrap16le: [ u8 XXXX -> +++X] SWS_OP_READ : 3 elem(s) packed >> 0 [ u8 ...X -> +++X] SWS_OP_CONVERT : u8 -> u16 (expand) - [u16 ...X -> +++X] SWS_OP_SWIZZLE : 1203 [u16 ...X -> ++++] SWS_OP_CLEAR : {_ _ _ 65535} - [u16 .... -> ++++] SWS_OP_WRITE : 4 elem(s) planar >> 0 + [u16 .... -> ++++] SWS_OP_WRITE : 4 elem(s) planar >> 0, via {2, 0, 1, 3} yuv444p -> vuya: - [ u8 XXXX -> +++X] SWS_OP_READ : 3 elem(s) planar >> 0 - [ u8 ...X -> +++X] SWS_OP_SWIZZLE : 2103 + [ u8 XXXX -> +++X] SWS_OP_READ : 3 elem(s) planar >> 0, via {2, 1, 0} [ u8 ...X -> ++++] SWS_OP_CLEAR : {_ _ _ 255} [ u8 .... -> ++++] SWS_OP_WRITE : 4 elem(s) packed >> 0 Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]> --- libswscale/ops_optimizer.c | 28 ++++++++++++++++++++++++++++ tests/ref/fate/sws-ops-list | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c index bcdeb19be5..5319a954df 100644 --- a/libswscale/ops_optimizer.c +++ b/libswscale/ops_optimizer.c @@ -405,6 +405,34 @@ retry: ff_sws_op_list_remove_at(ops, n + 1, 1); goto retry; } + + /* Swizzle planes instead of components, if possible */ + if (prev->op == SWS_OP_READ && !prev->rw.packed) { + for (int dst = 0; dst < prev->rw.elems; dst++) { + const int src = op->swizzle.in[dst]; + if (src > dst && src < prev->rw.elems) { + FFSWAP(int, ops->order_src.in[dst], ops->order_src.in[src]); + for (int i = dst; i < 4; i++) { + if (op->swizzle.in[i] == dst) + op->swizzle.in[i] = src; + else if (op->swizzle.in[i] == src) + op->swizzle.in[i] = dst; + } + goto retry; + } + } + } + + if (next->op == SWS_OP_WRITE && !next->rw.packed) { + for (int dst = 0; dst < next->rw.elems; dst++) { + const int src = op->swizzle.in[dst]; + if (src > dst && src < next->rw.elems) { + FFSWAP(int, ops->order_dst.in[dst], ops->order_dst.in[src]); + FFSWAP(int, op->swizzle.in[dst], op->swizzle.in[src]); + goto retry; + } + } + } break; case SWS_OP_CONVERT: diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list index b69b1ab299..429b46b371 100644 --- a/tests/ref/fate/sws-ops-list +++ b/tests/ref/fate/sws-ops-list @@ -1 +1 @@ -8312bc72ff9e05a8a6ab8d1c394783d6 +30ceeaa73f093642f28c1f17b3ee4e3e _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
