This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 0744260ff0e9e3a8832754c51c5515a0a0ce2793 Author: Niklas Haas <[email protected]> AuthorDate: Wed Dec 3 18:39:58 2025 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Mon Dec 15 14:31:58 2025 +0000 swscale/x86/ops: over-allocate dither matrix I want to change the way offsets are calculated inside the dither asm; and the cleanest way to solve that problem is to just over-allocate the entire dither matrix based on the maximum offset range we expected. --- libswscale/x86/ops.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c index ecbd79564e..1d8a2e77da 100644 --- a/libswscale/x86/ops.c +++ b/libswscale/x86/ops.c @@ -194,13 +194,27 @@ static int setup_dither(const SwsOp *op, SwsOpPriv *out) } const int size = 1 << op->dither.size_log2; - float *matrix = out->ptr = av_mallocz(size * size * sizeof(*matrix)); + int max_offset = 0; + for (int i = 0; i < 4; i++) { + const int offset = op->dither.y_offset[i] & (size - 1); + max_offset = FFMAX(max_offset, offset); + } + + /* Allocate extra rows to allow over-reading for row offsets. Note that + * max_offset is currently never larger than 5, so the extra space needed + * for this over-allocation is bounded by 5 * size * sizeof(float), + * typically 320 bytes for a 16x16 dither matrix. */ + const int stride = size * sizeof(float); + const int num_rows = size + max_offset; + float *matrix = out->ptr = av_mallocz(num_rows * stride); if (!matrix) return AVERROR(ENOMEM); for (int i = 0; i < size * size; i++) matrix[i] = (float) op->dither.matrix[i].num / op->dither.matrix[i].den; + memcpy(&matrix[size * size], matrix, max_offset * stride); + return 0; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
