From 8ad26356f5e92bd396e58290217da55858345a4e Mon Sep 17 00:00:00 2001 From: neonloop Date: Sat, 7 Aug 2021 20:28:34 +0000 Subject: Adds generic nearest and smooth scalers Smooth is slower (10-15%) than a scaler built for a specific resolution. Works well for downscaling and for odd screen ratios until a custom scaler is built. Replaces the snes smooth scaler (outperforms it) and the gba smooth scaler (looks better) --- plat_sdl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plat_sdl.c') diff --git a/plat_sdl.c b/plat_sdl.c index 7223a0d..9467f5d 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -9,9 +9,9 @@ static SDL_Surface* screen; struct audio_state { - int buf_w; - int max_buf_w; - int buf_r; + unsigned buf_w; + unsigned max_buf_w; + unsigned buf_r; size_t buf_len; struct audio_frame *buf; int freq; @@ -37,14 +37,14 @@ static int audio_resample_nearest(struct audio_frame data) { static int diff = 0; int consumed = 0; - if (diff <= 0) { + if (diff < audio.out_sample_rate) { audio.buf[audio.buf_w++] = data; if (audio.buf_w >= audio.buf_len) audio.buf_w = 0; diff += audio.in_sample_rate; } - if (diff > 0) { + if (diff >= audio.out_sample_rate) { consumed++; diff -= audio.out_sample_rate; } -- cgit v1.2.3