From 95c3e58ff95605dc3db8b17ad39f7ffeebe181c0 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 7 Apr 2015 11:33:11 -0700 Subject: [PATCH] split decimate, interpolate --- include/os2piir_stereo.h | 58 ++++++++++++++++++++----------------- include/process_nonlinear.h | 10 +++---- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/include/os2piir_stereo.h b/include/os2piir_stereo.h index 5710154..f2a70a6 100644 --- a/include/os2piir_stereo.h +++ b/include/os2piir_stereo.h @@ -14,7 +14,6 @@ typedef struct { v2df ao[8], bo[8]; v2df at[8], bt[8]; v2df x1, x2, x3; - int i; } halfband_t; INNER void @@ -60,39 +59,46 @@ halfband(halfband_t *h, v2df x0) } INNER v2df -decimate(halfband_t *h, v2df x0) +decimate_a(halfband_t *h, v2df x0) { v2df c[8]; - if ((h->i = !h->i)) { - halfband_b(c, h->bo, x0, h->x2); - copy(h->bo, c); - h->x2 = h->x1; - h->x1 = x0; - return V(0); - } else { - halfband_a(c, h->ao, x0, h->x2); - copy(h->ao, c); - h->x2 = h->x1; - h->x1 = x0; - return (c[7] + h->bo[7])*V(0.5); - } + halfband_b(c, h->bo, x0, h->x2); + copy(h->bo, c); + h->x2 = h->x1; + h->x1 = x0; + return V(0); +} + +INNER v2df +decimate_b(halfband_t *h, v2df x0) +{ + v2df c[8]; + halfband_a(c, h->ao, x0, h->x2); + copy(h->ao, c); + h->x2 = h->x1; + h->x1 = x0; + return (c[7] + h->bo[7])*V(0.5); } // note: do not zero-stuff! send the input each time. INNER v2df -interpolate(halfband_t *h, v2df x0) +interpolate_a(halfband_t *h, v2df x0) { v2df c[8]; - if ((h->i = !h->i)) { - halfband_a(c, h->ao, x0, h->x1); - copy(h->ao, c); - return c[7]; - } else { - halfband_b(c, h->bo, x0, h->x1); - copy(h->bo, c); - h->x1 = x0; - return c[7]; - } + halfband_a(c, h->ao, x0, h->x1); + copy(h->ao, c); + return c[7]; +} + +// note: do not zero-stuff! send the input each time. +INNER v2df +interpolate_b(halfband_t *h, v2df x0) +{ + v2df c[8]; + halfband_b(c, h->bo, x0, h->x1); + copy(h->bo, c); + h->x1 = x0; + return c[7]; } #undef copy diff --git a/include/process_nonlinear.h b/include/process_nonlinear.h index 603e489..5146662 100644 --- a/include/process_nonlinear.h +++ b/include/process_nonlinear.h @@ -30,9 +30,8 @@ } for (ulong i = 0; i < rem; i++) { - hb_up->i = 0; // so compiler can optimize - over[i*2+0] = interpolate(hb_up, buf[i]); - over[i*2+1] = interpolate(hb_up, buf[i]); + over[i*2+0] = interpolate_a(hb_up, buf[i]); + over[i*2+1] = interpolate_b(hb_up, buf[i]); } for (ulong i = 0; i < rem2; i++) { @@ -40,9 +39,8 @@ } for (ulong i = 0; i < rem; i++) { - hb_down->i = 0; // so compiler can optimize - decimate(hb_down, over[i*2+0]); - buf[i] = decimate(hb_down, over[i*2+1]); + decimate_a(hb_down, over[i*2+0]); + buf[i] = decimate_b(hb_down, over[i*2+1]); } for (ulong i = 0; i < rem; i++) {