From 337440d4a0f141c036e057ecc4fe4f4b808ff9c0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 15 Sep 2017 19:52:49 -0700 Subject: modules/*: cease dividing stride by 4 Just cast buf to (void *) for the pointer arithmetic, stride is in units of bytes and no assumptions should be made about its value such as divisability by 4. --- src/modules/julia/julia.c | 4 ++-- src/modules/plasma/plasma.c | 4 ++-- src/modules/ray/ray_scene.c | 3 +-- src/modules/roto/roto.c | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index ea97a77..a83fe00 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -133,7 +133,7 @@ static void julia_render_fragment(void *context, fb_fragment_t *fragment) { julia_context_t *ctxt = context; unsigned x, y; - unsigned stride = fragment->stride / 4, width = fragment->width, height = fragment->height; + unsigned width = fragment->width, height = fragment->height; uint32_t *buf = fragment->buf; float real, imag; float realstep = 3.6f / (float)fragment->frame_width, imagstep = 3.6f / (float)fragment->frame_height; @@ -145,7 +145,7 @@ static void julia_render_fragment(void *context, fb_fragment_t *fragment) *buf = colors[julia_iter(real, imag, ctxt->creal, ctxt->cimag, sizeof(colors) / sizeof(*colors))]; } - buf += stride; + buf = ((void *)buf) + fragment->stride; } } diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c index 71c5c13..245cf3c 100644 --- a/src/modules/plasma/plasma.c +++ b/src/modules/plasma/plasma.c @@ -89,7 +89,7 @@ static void plasma_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t * static void plasma_render_fragment(void *context, fb_fragment_t *fragment) { plasma_context_t *ctxt = context; - unsigned stride = fragment->stride / 4, width = fragment->width, height = fragment->height; + unsigned width = fragment->width, height = fragment->height; int fw2 = FIXED_NEW(width / 2), fh2 = FIXED_NEW(height / 2); int x, y, cx, cy, dx2, dy2; uint32_t *buf = fragment->buf; @@ -148,7 +148,7 @@ static void plasma_render_fragment(void *context, fb_fragment_t *fragment) *buf = color2pixel(&c); } - buf += stride; + buf = ((void *)buf) + fragment->stride; } } diff --git a/src/modules/ray/ray_scene.c b/src/modules/ray/ray_scene.c index 91249f3..f78ed3e 100644 --- a/src/modules/ray/ray_scene.c +++ b/src/modules/ray/ray_scene.c @@ -190,7 +190,6 @@ static inline ray_color_t trace_ray(ray_scene_t *scene, ray_ray_t *primary_ray) void ray_scene_render_fragment(ray_scene_t *scene, fb_fragment_t *fb_fragment) { - unsigned stride = fb_fragment->stride / 4; uint32_t *buf = fb_fragment->buf; ray_camera_fragment_t fragment; ray_ray_t ray; @@ -202,7 +201,7 @@ void ray_scene_render_fragment(ray_scene_t *scene, fb_fragment_t *fb_fragment) buf++; } while (ray_camera_fragment_x_step(&fragment)); - buf += stride; + buf = ((void *)buf) + fb_fragment->stride; } while (ray_camera_fragment_y_step(&fragment)); } diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index e859d94..e21b971 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -203,7 +203,7 @@ static void roto32_render_fragment(void *context, fb_fragment_t *fragment) { roto_context_t *ctxt = context; int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; - int x, y, stride = fragment->stride / 4, frame_width = fragment->frame_width, frame_height = fragment->frame_height; + int x, y, frame_width = fragment->frame_width, frame_height = fragment->frame_height; uint32_t *buf = fragment->buf; /* This is all done using fixed-point in the hopes of being faster, and yes assumptions @@ -240,7 +240,7 @@ static void roto32_render_fragment(void *context, fb_fragment_t *fragment) x_sin_r += sin_r; } - buf += stride; + buf = ((void *)buf) + fragment->stride; y_cos_r += cos_r; y_sin_r += sin_r; } @@ -253,7 +253,7 @@ static void roto64_render_fragment(void *context, fb_fragment_t *fragment) { roto_context_t *ctxt = context; int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; - int x, y, stride = fragment->stride / 8, frame_width = fragment->frame_width, frame_height = fragment->frame_height, width = fragment->width; + int x, y, frame_width = fragment->frame_width, frame_height = fragment->frame_height, width = fragment->width; uint64_t *buf = (uint64_t *)fragment->buf; /* This is all done using fixed-point in the hopes of being faster, and yes assumptions @@ -301,7 +301,7 @@ static void roto64_render_fragment(void *context, fb_fragment_t *fragment) x_sin_r += sin_r; } - buf += stride; + buf = ((void *)buf) + fragment->stride; y_cos_r += cos_r; y_sin_r += sin_r; } -- cgit v1.2.1