From 4114f87af993991c7aab55ff86be3003d43244f3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Jan 2023 19:30:25 +0100 Subject: Add render context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libglitter_compose_double.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'libglitter_compose_double.c') diff --git a/libglitter_compose_double.c b/libglitter_compose_double.c index d0fdc3e..5a8d361 100644 --- a/libglitter_compose_double.c +++ b/libglitter_compose_double.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include "libglitter.h" +#include "common.h" static void @@ -60,12 +60,12 @@ hstrips(double **outputs_, const double *restrict input, size_t output_rowsize, static void -generic(double **outputs, const double *restrict input, +generic(double **outputs, size_t noutputs, const double *restrict input, size_t output_rowsize, size_t output_cellsize, size_t input_rowsize, size_t width, size_t height, size_t widthmul, size_t heightmul, - const uint8_t *restrict cellmap, const double *restrict ncellweights) + const uint8_t *restrict cellmap, const double *restrict cellweights) { - size_t y, x, iy, ix, output_y, output_i, input_blanking; + size_t y, x, iy, ix, i, output_y, output_i, input_blanking; uint8_t channel; double value; @@ -75,12 +75,14 @@ generic(double **outputs, const double *restrict input, for (y = 0, output_y = 0; y < height; y++, output_y += output_rowsize) { for (x = 0, output_i = output_y; x < width; x++, output_i += output_cellsize) { + for (i = 0; i < noutputs; i++) + outputs[i][output_i] = 0; for (iy = 0; iy < heightmul; iy++) { for (ix = 0; ix < widthmul; ix++) { channel = cellmap[iy * widthmul + ix]; value = input[iy * input_rowsize + ix]; - value *= ncellweights[channel]; + value *= cellweights[channel]; outputs[channel][output_i] += value; } @@ -93,18 +95,16 @@ generic(double **outputs, const double *restrict input, void -libglitter_compose_double(double **outputs, size_t noutputs, const double *restrict input, - size_t output_rowsize, size_t output_cellsize, size_t input_rowsize, - size_t width, size_t height, size_t widthmul, size_t heightmul, - const uint8_t *restrict cellmap, const double *restrict ncellweights) +libglitter_compose_double(double **outputs, const double *restrict input, size_t output_rowsize, size_t output_cellsize, + size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *render_ctx) { - if (noutputs == 3 && widthmul == 3 && heightmul == 1) { - vstrips(outputs, input, output_rowsize, output_cellsize, input_rowsize, width, height, cellmap); - } else if (noutputs == 3 && widthmul == 1 && heightmul == 3) { - hstrips(outputs, input, output_rowsize, output_cellsize, input_rowsize, width, height, cellmap); + if (render_ctx->render_method == RENDER_METHOD_VSTRIPS) { + vstrips(outputs, input, output_rowsize, output_cellsize, render_ctx->rowsize, width, height, render_ctx->cellmap); + } else if (render_ctx->render_method == RENDER_METHOD_HSTRIPS) { + hstrips(outputs, input, output_rowsize, output_cellsize, render_ctx->rowsize, width, height, render_ctx->cellmap); } else { - generic(outputs, input, output_rowsize, output_cellsize, input_rowsize, - width, height, widthmul, heightmul, cellmap, ncellweights); + generic(outputs, render_ctx->noutputs, input, output_rowsize, output_cellsize, render_ctx->rowsize, width, height, + render_ctx->widthmul, render_ctx->heightmul, render_ctx->cellmap, render_ctx->cellweights_double); } } -- cgit v1.2.3-70-g09d2