aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_compose_double.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-21 19:30:25 +0100
committerMattias Andrée <maandree@kth.se>2023-01-21 19:32:34 +0100
commit4114f87af993991c7aab55ff86be3003d43244f3 (patch)
treeb5841672b4a48c02a9015ddc273f7b64ad9bec3a /libglitter_compose_double.c
parentAdd integer versions of libglitter_compose_* (diff)
downloadlibglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.gz
libglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.bz2
libglitter-4114f87af993991c7aab55ff86be3003d43244f3.tar.xz
Add render context
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libglitter_compose_double.c')
-rw-r--r--libglitter_compose_double.c30
1 files changed, 15 insertions, 15 deletions
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);
}
}