This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 6321b5380939a4e676854d67fe41085d5f0c4ad8 Author: Niklas Haas <[email protected]> AuthorDate: Thu Jun 25 18:36:44 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Mon Aug 3 09:32:30 2026 +0000 swscale/ops: solve for component dependencies Needed to determine reverse dependencies of different input planes, for appropriately splitting op lists involving subsampled planes. Generates benign diffs that just reflect the new addition, e.g.: yuva444p 16x16 -> rgb24 16x16: [ u8 ===X] SWS_OP_READ : 3 elem(s) planar >> 0 min: {0 0 0 _}, max: {255 255 255 _} + inputs: {x y z _}, outputs: {xyz yz xy _} [ u8 ===X] SWS_OP_CONVERT : u8 -> f32 min: {0 0 0 _}, max: {255 255 255 _} + inputs: {x y z _}, outputs: {xyz yz xy _} [f32 ...X] SWS_OP_LINEAR : matrix3+off3 [[85/73 0 1.596027 0 -222.921566] [85/73 -0.391762 -0.812968 0 135.575295] [85/73 2.017232 0 0 -276.835851] [0 0 0 1 0]] min: {-222.921566 -171.630839 -276.835851 _}, max: {480.983073 432.493103 534.476153 _} + inputs: {xz xyz xy _}, outputs: {x y z _} [f32 ...X] SWS_OP_DITHER : 16x16 matrix + {0 3 2 -1} min: {-222.919612 -171.628886 -276.833898 _}, max: {481.981120 433.491150 535.474200 _} + inputs: {xz xyz xy _}, outputs: {x y z _} [f32 ...X] SWS_OP_MAX : {0 0 0 _} <= x min: {0 0 0 _}, max: {481.981120 433.491150 535.474200 _} + inputs: {xz xyz xy _}, outputs: {x y z _} [f32 ...X] SWS_OP_MIN : x <= {255 255 255 _} min: {0 0 0 _}, max: {255 255 255 _} + inputs: {xz xyz xy _}, outputs: {x y z _} [f32 +++X] SWS_OP_CONVERT : f32 -> u8 min: {0 0 0 _}, max: {255 255 255 _} + inputs: {xz xyz xy _}, outputs: {x y z _} [ u8 XXXX] SWS_OP_WRITE : 3 elem(s) packed >> 0 ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero) Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]> --- libswscale/ops.c | 46 ++++++++++++++++++++++++++++++++++++++------- libswscale/ops.h | 3 +++ tests/ref/fate/sws-ops-list | 2 +- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/libswscale/ops.c b/libswscale/ops.c index be3e9853a9..21462df386 100644 --- a/libswscale/ops.c +++ b/libswscale/ops.c @@ -292,7 +292,8 @@ static void apply_filter_weights(SwsComps *comps, const SwsComps *prev, const AVRational64 posw = { weights->sum_positive, SWS_FILTER_SCALE }; const AVRational64 negw = { weights->sum_negative, SWS_FILTER_SCALE }; for (int i = 0; i < 4; i++) { - comps->flags[i] = prev->flags[i] & SWS_COMP_DIRTY; + comps->flags[i] = prev->flags[i] & SWS_COMP_DIRTY; + comps->dep_in[i] = prev->dep_in[i]; /* Only point sampling preserves exactness */ if (weights->filter_size != 1) comps->flags[i] &= ~SWS_COMP_EXACT; @@ -331,17 +332,21 @@ void ff_sws_op_list_update_comps(SwsOpList *ops) break; } - for (int i = 0; i < 4; i++) - op->comps.flags[i] = SWS_COMP_IDENTITY; + for (int i = 0; i < 4; i++) { + op->comps.flags[i] = SWS_COMP_IDENTITY; + op->comps.dep_in[i] = SWS_COMP_NONE; + } #define FORWARD(I, J, EXPR) do { \ SwsCompFlags flags = prev.flags[J]; \ op->comps.flags[I] = merge_comp_flags(op->comps.flags[I], (EXPR)); \ + op->comps.dep_in[I] |= prev.dep_in[J]; \ } while (0) #define RESET(I) do { \ op->comps.flags[I] = SWS_COMP_GARBAGE; \ op->comps.min[I] = op->comps.max[I] = (AVRational64) {0}; \ + op->comps.dep_in[I] = SWS_COMP_NONE; \ } while (0) switch (op->op) { @@ -360,6 +365,7 @@ void ff_sws_op_list_update_comps(SwsOpList *ops) op->comps.flags[i] = ops->comps_src.flags[idx] & SWS_COMP_DIRTY; op->comps.min[i] = ops->comps_src.min[idx]; op->comps.max[i] = ops->comps_src.max[idx]; + op->comps.dep_in[i] = SWS_COMP(idx); /** * Don't mark packed or fractional reads as a copy, because the @@ -521,13 +527,15 @@ void ff_sws_op_list_update_comps(SwsOpList *ops) prev = op->comps; } - /* Backwards pass, solves for component dependencies */ - bool need_out[4] = { false, false, false, false }; + /* Backwards pass, solves for output component dependencies */ + SwsCompMask need_out[4] = {0}; + for (int n = ops->num_ops - 1; n >= 0; n--) { SwsOp *op = &ops->ops[n]; - bool need_in[4] = { false, false, false, false }; + SwsCompMask need_in[4] = {0}; for (int i = 0; i < 4; i++) { + op->comps.dep_out[i] = need_out[i]; if (!need_out[i]) RESET(i); } @@ -536,7 +544,7 @@ void ff_sws_op_list_update_comps(SwsOpList *ops) case SWS_OP_READ: case SWS_OP_WRITE: for (int i = 0; i < op->rw.elems; i++) - need_in[i] = op->op == SWS_OP_WRITE; + need_in[i] = (op->op == SWS_OP_WRITE) ? SWS_COMP(i) : 0; for (int i = op->rw.elems; i < 4; i++) need_in[i] = need_out[i]; break; @@ -789,6 +797,17 @@ static char describe_comp_flags(SwsCompFlags flags) return '.'; } +static void print_deps(AVBPrint *bp, const SwsCompMask *deps) +{ + av_bprintf(bp, "{"); + for (int i = 0; i < 4; i++) { + if (i) + av_bprintf(bp, " "); + av_bprintf(bp, "%s", deps[i] ? ff_sws_comp_mask_str(deps[i]) : "_"); + } + av_bprintf(bp, "}"); +} + static void print_q(AVBPrint *bp, const AVRational64 q) { if (!q.den) { @@ -976,6 +995,19 @@ void ff_sws_op_list_print(void *log, int lev, int lev_extra, av_log(log, lev_extra, "%s\n", bp.str); } + bool has_deps = false; + for (int i = 0; i < 4; i++) + has_deps |= op->comps.dep_in[i] || op->comps.dep_out[i]; + if (has_deps) { + av_bprint_clear(&bp); + av_bprintf(&bp, " inputs: "); + print_deps(&bp, op->comps.dep_in); + av_bprintf(&bp, ", outputs: "); + print_deps(&bp, op->comps.dep_out); + av_assert0(av_bprint_is_complete(&bp)); + av_log(log, lev_extra, "%s\n", bp.str); + } + } av_log(log, lev, " ('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)\n"); diff --git a/libswscale/ops.h b/libswscale/ops.h index 67dd04d227..02c122655a 100644 --- a/libswscale/ops.h +++ b/libswscale/ops.h @@ -85,6 +85,9 @@ typedef struct SwsComps { /* Keeps track of the known possible value range, or {0, 0} for undefined * or (unknown range) floating point inputs */ AVRational64 min[4], max[4]; + + /* Keeps track of input (forward) and output (reverse) dependencies */ + SwsCompMask dep_in[4], dep_out[4]; } SwsComps; typedef enum SwsReadWriteMode { diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list index 0fb88d65da..8b92ff60b6 100644 --- a/tests/ref/fate/sws-ops-list +++ b/tests/ref/fate/sws-ops-list @@ -1 +1 @@ -3a8f3bccd7c1f8407ee7c40fd26d86cc +63448a9d7345ac61bedcb479045358f3 _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
