This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 327319bb7b34d91a50b479f30055770f7ea603dd Author: Niklas Haas <[email protected]> AuthorDate: Fri Jul 17 12:41:43 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Mon Aug 3 09:32:30 2026 +0000 swscale/ops: remove SwsLinearOp.mask This was originally introduced to make matching linear ops against implementations faster. However, since this is now handled on the uops level, there is no more reason to carry this metadata on the ops level. Simplifies a lot of places in the code. It will simplify even more, once the linear optimizations are moved to the uops level. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]> --- libswscale/aarch64/ops_impl_conv.c | 3 ++- libswscale/format.c | 7 +------ libswscale/ops.h | 8 +------- libswscale/ops_optimizer.c | 17 +++++++---------- libswscale/uops.c | 3 ++- 5 files changed, 13 insertions(+), 25 deletions(-) diff --git a/libswscale/aarch64/ops_impl_conv.c b/libswscale/aarch64/ops_impl_conv.c index 21360e51c7..daebac9f09 100644 --- a/libswscale/aarch64/ops_impl_conv.c +++ b/libswscale/aarch64/ops_impl_conv.c @@ -268,8 +268,9 @@ static int convert_to_aarch64_impl(SwsContext *ctx, const SwsOpList *ops, int n, case SWS_UOP_LINEAR: case SWS_UOP_LINEAR_FMA: out->mask = 0; + const uint32_t lin_mask = ff_sws_linear_mask(&op->lin); for (int i = 0; i < 4; i++) { - if (!SWS_OP_NEEDED(op, i) || !(op->lin.mask & SWS_MASK_ROW(i))) { + if (!SWS_OP_NEEDED(op, i) || !(lin_mask & SWS_MASK_ROW(i))) { for (int j = 0; j < 5; j++) out->par.lin.zero |= SWS_MASK(i, j); continue; diff --git a/libswscale/format.c b/libswscale/format.c index 70cc813dd7..2531435dae 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -1283,7 +1283,6 @@ static SwsLinearOp fmt_encode_range(const SwsFormat *fmt, bool *incomplete) c.m[0][0] = av_neg_q64(c.m[0][0]); } - c.mask = ff_sws_linear_mask(&c); return c; } @@ -1302,7 +1301,6 @@ static SwsLinearOp fmt_decode_range(const SwsFormat *fmt, bool *incomplete) if (!(fmt->desc->flags & AV_PIX_FMT_FLAG_ALPHA)) c.m[3][4] = Q(1); - c.mask = ff_sws_linear_mask(&c); return c; } @@ -1464,15 +1462,12 @@ linear_mat3(const AVRational m00, const AVRational m01, const AVRational m02, const AVRational m10, const AVRational m11, const AVRational m12, const AVRational m20, const AVRational m21, const AVRational m22) { - SwsLinearOp c = {{ + return (SwsLinearOp) {{ { Q64(m00), Q64(m01), Q64(m02), Q(0), Q(0) }, { Q64(m10), Q64(m11), Q64(m12), Q(0), Q(0) }, { Q64(m20), Q64(m21), Q64(m22), Q(0), Q(0) }, { Q(0), Q(0), Q(0), Q(1), Q(0) }, }}; - - c.mask = ff_sws_linear_mask(&c); - return c; } int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type, diff --git a/libswscale/ops.h b/libswscale/ops.h index 02c122655a..83ef2b49df 100644 --- a/libswscale/ops.h +++ b/libswscale/ops.h @@ -192,17 +192,11 @@ typedef struct SwsLinearOp { * [ Out.y ] = [ F G H I J ] * [ x y z w 1 ] * [ Out.z ] = [ K L M N O ] * [ Out.w ] = [ P Q R S T ] - * - * The mask keeps track of which components differ from an identity matrix. - * There may be more efficient implementations of particular subsets, for - * example the common subset of {A, E, G, J, M, O} can be implemented with - * just three fused multiply-add operations. */ AVRational64 m[4][5]; - uint32_t mask; /* m[i][j] <-> 1 << (5 * i + j) */ } SwsLinearOp; -/* Helper function to compute the correct mask */ +/* m[i][j] <-> 1 << (5 * i + j) */ uint32_t ff_sws_linear_mask(const SwsLinearOp *c); typedef struct SwsFilterOp { diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c index 5b22f3b387..3546d8bc9e 100644 --- a/libswscale/ops_optimizer.c +++ b/libswscale/ops_optimizer.c @@ -238,7 +238,7 @@ static bool extract_scalar(const SwsLinearOp *c, SwsScaleOp scale = {0}; /* There are components not on the main diagonal */ - if (c->mask & ~SWS_MASK_DIAG4) + if (ff_sws_linear_mask(c) & ~SWS_MASK_DIAG4) return false; for (int i = 0; i < 4; i++) { @@ -260,6 +260,7 @@ static bool extract_scalar(const SwsLinearOp *c, static bool extract_constant_rows(SwsLinearOp *c, const SwsComps *prev, SwsClearOp *out_clear) { + const uint32_t mask = ff_sws_linear_mask(c); SwsClearOp clear = {0}; bool ret = false; @@ -269,12 +270,11 @@ static bool extract_constant_rows(SwsLinearOp *c, const SwsComps *prev, const_row &= c->m[i][j].num == 0 || /* scalar is zero */ (prev->flags[j] & SWS_COMP_ZERO); /* input is zero */ } - if (const_row && (c->mask & SWS_MASK_ROW(i))) { + if (const_row && (mask & SWS_MASK_ROW(i))) { clear.mask |= SWS_COMP(i); clear.value[i] = c->m[i][4]; for (int j = 0; j < 5; j++) c->m[i][j] = Q(i == j); - c->mask &= ~SWS_MASK_ROW(i); ret = true; } } @@ -321,7 +321,6 @@ static bool extract_swizzle(SwsLinearOp *op, const SwsComps *prev, if (swiz.mask == SWS_SWIZZLE(0, 1, 2, 3).mask) return false; /* no swizzle was identified */ - c.mask = ff_sws_linear_mask(&c); *out_swiz = swiz; *op = c; return true; @@ -622,12 +621,13 @@ retry: break; case SWS_OP_LINEAR: { + const uint32_t mask = ff_sws_linear_mask(&op->lin); SwsSwizzleOp swizzle; SwsClearOp clear; SwsScaleOp scale; /* No-op (identity) linear operation */ - if (!op->lin.mask) { + if (!mask) { ff_sws_op_list_remove_at(ops, n, 1); goto retry; } @@ -646,7 +646,6 @@ retry: op->lin.m[i][j] = sum; } } - op->lin.mask = ff_sws_linear_mask(&op->lin); ff_sws_op_list_remove_at(ops, n + 1, 1); goto retry; } @@ -654,22 +653,20 @@ retry: /* Optimize away zero columns */ for (int j = 0; j < 4; j++) { const uint32_t col = SWS_MASK_COL(j); - if (!(prev->comps.flags[j] & SWS_COMP_ZERO) || !(op->lin.mask & col)) + if (!(prev->comps.flags[j] & SWS_COMP_ZERO) || !(mask & col)) continue; for (int i = 0; i < 4; i++) op->lin.m[i][j] = Q(i == j); - op->lin.mask &= ~col; goto retry; } /* Optimize away unused rows */ for (int i = 0; i < 4; i++) { const uint32_t row = SWS_MASK_ROW(i); - if (SWS_OP_NEEDED(op, i) || !(op->lin.mask & row)) + if (SWS_OP_NEEDED(op, i) || !(mask & row)) continue; for (int j = 0; j < 5; j++) op->lin.m[i][j] = Q(i == j); - op->lin.mask &= ~row; goto retry; } diff --git a/libswscale/uops.c b/libswscale/uops.c index 44000b35f1..fc9d609636 100644 --- a/libswscale/uops.c +++ b/libswscale/uops.c @@ -506,11 +506,12 @@ static int translate_linear_op(SwsContext *ctx, SwsUOpList *ops, .uop = SWS_UOP_LINEAR, }; + const uint32_t mask = ff_sws_linear_mask(&op->lin); const bool bitexact = ctx->flags & SWS_BITEXACT; uint32_t exact = 0; for (int i = 0; i < 4; i++) { - if (!SWS_OP_NEEDED(op, i) || !(op->lin.mask & SWS_MASK_ROW(i))) { + if (!SWS_OP_NEEDED(op, i) || !(mask & SWS_MASK_ROW(i))) { uop.par.lin.zero |= SWS_MASK_ROW(i); continue; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
