This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 7989fd973ade991714856c0111b4b11f75e3de9c Author: Niklas Haas <[email protected]> AuthorDate: Fri Mar 27 19:05:10 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Sun Mar 29 12:10:38 2026 +0200 swscale/ops: add min/max to SwsDitherOp This gives more accurate information to the range tracker. Signed-off-by: Niklas Haas <[email protected]> --- libswscale/format.c | 11 +++++++++++ libswscale/ops.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libswscale/format.c b/libswscale/format.c index 17eb405766..6fa279cc18 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -1269,6 +1269,8 @@ static int fmt_dither(SwsContext *ctx, SwsOpList *ops, .op = SWS_OP_DITHER, .type = type, .dither.matrix = bias, + .dither.min = *bias, + .dither.max = *bias, }); } else { return 0; /* No-op */ @@ -1284,6 +1286,15 @@ static int fmt_dither(SwsContext *ctx, SwsOpList *ops, if (!dither.matrix) return AVERROR(ENOMEM); + const int size = 1 << dither.size_log2; + dither.min = dither.max = dither.matrix[0]; + for (int i = 1; i < size * size; i++) { + if (av_cmp_q(dither.min, dither.matrix[i]) > 0) + dither.min = dither.matrix[i]; + if (av_cmp_q(dither.matrix[i], dither.max) > 0) + dither.max = dither.matrix[i]; + } + /* Brute-forced offsets; minimizes quantization error across a 16x16 * bayer dither pattern for standard RGBA and YUVA pixel formats */ const int offsets_16x16[4] = {0, 3, 2, 5}; diff --git a/libswscale/ops.h b/libswscale/ops.h index e3acbd4b18..a9e24ff5a9 100644 --- a/libswscale/ops.h +++ b/libswscale/ops.h @@ -159,6 +159,7 @@ typedef struct SwsConvertOp { typedef struct SwsDitherOp { AVRational *matrix; /* tightly packed dither matrix (refstruct) */ + AVRational min, max; /* minimum/maximum value in `matrix` */ int size_log2; /* size (in bits) of the dither matrix */ int8_t y_offset[4]; /* row offset for each component, or -1 for ignored */ } SwsDitherOp; _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
