From 7ebab640d762e3e9509b00dbe7ef829217ed2ae2 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 23 Feb 2023 13:15:14 +0100 Subject: [PATCH] Cleanups/style nits --- audio/drivers/alsa_qsa.c | 7 +- audio/drivers/ctr_csnd_audio.c | 7 +- audio/drivers/ctr_dsp_audio.c | 11 +- audio/drivers/ps3_audio.c | 2 +- audio/drivers/psp_audio.c | 32 +- cores/libretro-ffmpeg/ffmpeg_core.c | 2 +- ctr/gpu_old.c | 16 +- frontend/drivers/platform_ctr.c | 6 +- frontend/drivers/platform_darwin.m | 184 +++++------ frontend/drivers/platform_psp.c | 3 +- frontend/drivers/platform_uwp.c | 43 +-- frontend/drivers/platform_win32.c | 3 +- frontend/frontend_driver.c | 2 +- gfx/common/d3d10_common.c | 2 +- gfx/common/d3d11_common.c | 2 +- gfx/common/d3d8_common.c | 3 +- gfx/common/d3d9_common.c | 12 +- gfx/common/dxgi_common.c | 16 +- gfx/common/metal/menu_pipeline.metal | 20 +- gfx/common/x11_common.c | 2 +- gfx/drivers/d3d8.c | 16 +- gfx/drivers/gl1.c | 4 +- gfx/drivers/gx2_gfx.c | 289 +++++++++--------- gfx/drivers/gx_gfx_vi_encoder.c | 17 +- gfx/drivers/psp1_gfx.c | 6 +- gfx/drivers/rsx_gfx.c | 6 +- gfx/drivers/switch_gfx.c | 12 +- gfx/drivers/vita2d_gfx.c | 8 +- gfx/drivers/vulkan_shaders/hdr.frag | 12 +- .../vulkan_shaders/pipeline_bokeh.frag | 2 +- gfx/drivers_context/qnx_ctx.c | 4 +- gfx/drivers_font/d3d12_font.c | 2 +- gfx/drivers_font/wiiu_font.c | 2 +- gfx/drivers_shader/shader_glsl.c | 8 +- gfx/video_filters/2xsai.c | 95 +++--- gfx/video_filters/blargg_ntsc_snes.c | 58 ++-- gfx/video_filters/darken.c | 62 ++-- gfx/video_filters/dot_matrix_3x.c | 42 ++- gfx/video_filters/dot_matrix_4x.c | 49 ++- gfx/video_filters/epx.c | 68 ++--- gfx/video_filters/gameboy3x.c | 53 ++-- gfx/video_filters/gameboy4x.c | 39 ++- gfx/video_filters/grid2x.c | 54 ++-- gfx/video_filters/grid3x.c | 42 ++- gfx/video_filters/lq2x.c | 61 ++-- gfx/video_filters/normal2x.c | 68 ++--- gfx/video_filters/normal2x_height.c | 46 ++- gfx/video_filters/normal2x_width.c | 48 ++- gfx/video_filters/normal4x.c | 48 ++- gfx/video_filters/phosphor2x.c | 77 ++--- gfx/video_filters/picoscale_256x_320x240.c | 35 ++- gfx/video_filters/scale2x.c | 46 ++- gfx/video_filters/scanline2x.c | 46 ++- gfx/video_filters/super2xsai.c | 66 ++-- gfx/video_filters/supereagle.c | 63 ++-- gfx/video_filters/upscale_1_5x.c | 82 +++-- gfx/video_filters/upscale_240x160_320x240.c | 41 ++- gfx/video_filters/upscale_256x_320x240.c | 41 ++- .../upscale_mix_240x160_320x240.c | 75 ++--- gfx/video_layout/scope.c | 2 +- input/connect/connect_retrode.c | 17 +- input/connect/connect_wii.c | 11 +- input/connect/connect_wiiugca.c | 24 +- input/connect/connect_wiiupro.c | 2 +- input/drivers/android_input.c | 13 +- input/drivers/dinput.c | 2 +- input/drivers/psp_input.c | 8 +- input/drivers/udev_input.c | 6 +- input/drivers/wayland_input.c | 10 +- input/drivers_hid/btstack_hid.c | 2 +- input/drivers_hid/iohidmanager_hid.c | 2 +- input/drivers_hid/libusb_hid.c | 2 +- input/drivers_joypad/gx_joypad.c | 4 +- input/drivers_joypad/mfi_joypad.m | 2 +- input/drivers_joypad/ps2_joypad.c | 3 +- input/drivers_joypad/psp_joypad.c | 2 +- input/drivers_joypad/switch_joypad.c | 2 +- input/input_driver.c | 8 +- intl/msg_hash_el.c | 6 +- intl/msg_hash_pt_br.c | 6 +- intl/msg_hash_tr.c | 6 +- led/drivers/led_rpi.c | 8 +- led/drivers/led_sys_linux.c | 8 +- libretro-common/audio/audio_mixer.c | 2 +- libretro-common/audio/dsp_filters/chorus.c | 63 ++-- .../audio/dsp_filters/crystalizer.c | 9 +- libretro-common/audio/dsp_filters/echo.c | 28 +- libretro-common/audio/dsp_filters/eq.c | 58 ++-- libretro-common/audio/dsp_filters/iir.c | 1 - libretro-common/audio/dsp_filters/panning.c | 1 - libretro-common/audio/dsp_filters/phaser.c | 9 +- libretro-common/audio/dsp_filters/reverb.c | 32 +- libretro-common/audio/dsp_filters/tremolo.c | 55 ++-- libretro-common/audio/dsp_filters/vibrato.c | 114 +++---- libretro-common/audio/dsp_filters/wahwah.c | 54 ++-- libretro-common/encodings/encoding_base64.c | 40 +-- libretro-common/formats/bmp/rbmp_encode.c | 9 +- libretro-common/formats/xml/rxml.c | 2 +- libretro-common/include/gfx/math/vector_2.h | 14 +- libretro-common/libco/aarch64.c | 7 +- libretro-common/libco/amd64.c | 17 +- libretro-common/libco/armeabi.c | 5 +- libretro-common/libco/fiber.c | 4 +- libretro-common/libco/genode.cpp | 10 +- libretro-common/libco/ppc.c | 141 +++++---- libretro-common/libco/ps2.c | 59 ++-- libretro-common/libco/psp1.c | 4 +- libretro-common/libco/psp2.c | 33 +- libretro-common/libco/scefiber.c | 72 +++-- libretro-common/libco/sjlj.c | 38 ++- libretro-common/libco/ucontext.c | 11 +- libretro-common/libco/x86.c | 16 +- libretro-common/net/net_compat.c | 2 +- libretro-common/rthreads/ctr_pthread.h | 2 +- libretro-common/rthreads/psp_pthread.h | 8 +- memory/wii/mem2_manager.c | 4 +- menu/menu_setting.c | 2 +- retroarch.c | 3 +- runloop.c | 4 +- tasks/task_movie.c | 6 +- tasks/task_wifi.c | 3 +- 121 files changed, 1501 insertions(+), 1765 deletions(-) diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index f534a7a7c6..f78c490d6e 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -69,7 +69,7 @@ static void *alsa_qsa_init(const char *device, goto error; } - if((err = snd_pcm_nonblock_mode(alsa->pcm, 1)) < 0) + if ((err = snd_pcm_nonblock_mode(alsa->pcm, 1)) < 0) { RARCH_ERR("[ALSA QSA]: Can't set blocking mode: %s\n", snd_strerror(err)); @@ -313,11 +313,10 @@ static bool alsa_qsa_start(void *data, bool is_shutdown) static void alsa_qsa_set_nonblock_state(void *data, bool state) { + int err; alsa_qsa_t *alsa = (alsa_qsa_t*)data; - int err; - - if((err = snd_pcm_nonblock_mode(alsa->pcm, state)) < 0) + if ((err = snd_pcm_nonblock_mode(alsa->pcm, state)) < 0) { RARCH_ERR("Can't set blocking mode to %d: %s\n", state, snd_strerror(err)); diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index eb7986f90b..e751be3052 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -170,14 +170,9 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) const uint16_t *src = buf; ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data; - (void)data; - (void)buf; - (void)samples_played; - (void)current_tick; - ctr_csnd_audio_update_playpos(ctr); - if((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) || + if ((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) || (((ctr->pos - ctr->playpos ) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4)) || (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (size >> 2))) { diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index e25f0bede4..9cc165be92 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -97,7 +97,7 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size) ctr_dsp_audio_t * ctr = (ctr_dsp_audio_t*)data; uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel); - if((((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 2)) || + if ((((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 2)) || (((ctr->pos - sample_pos ) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 4)) || (((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (size >> 2))) { @@ -105,26 +105,27 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size) ctr->pos = (sample_pos + (CTR_DSP_AUDIO_COUNT >> 1)) & CTR_DSP_AUDIO_COUNT_MASK; else { - do{ + do + { svcSleepThread(100000); /* Run aptMainLoop to update APT state if DSP state * changed, this prevents a hang on sleep. */ - if(!aptMainLoop()) + if (!aptMainLoop()) { command_event(CMD_EVENT_QUIT, NULL); return true; } sample_pos = ndspChnGetSamplePos(ctr->channel); - }while (((sample_pos - (ctr->pos + (size >>2))) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1) + }while ( ((sample_pos - (ctr->pos + (size >>2))) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1) || (((ctr->pos - (CTR_DSP_AUDIO_COUNT >> 4) - sample_pos) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1))); } } pos = ctr->pos << 2; - if((pos + size) > CTR_DSP_AUDIO_SIZE) + if ((pos + size) > CTR_DSP_AUDIO_SIZE) { memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, (CTR_DSP_AUDIO_SIZE - pos)); diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index 1b40ed645f..da7a82345b 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -110,7 +110,7 @@ static void *ps3_audio_init(const char *device, params.param_attrib = 0; #if 0 #ifdef HAVE_HEADSET - if(global->console.sound.mode == SOUND_MODE_HEADSET) + if (global->console.sound.mode == SOUND_MODE_HEADSET) params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY; #endif #endif diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 6e9a394672..abd5ea09cd 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -166,22 +166,23 @@ static void *psp_audio_init(const char *device, static void psp_audio_free(void *data) { psp_audio_t* psp = (psp_audio_t*)data; - if(!psp) + if (!psp) return; - if(psp->running){ + if (psp->running) + { if (psp->worker_thread) { - psp->running = false; - sthread_join(psp->worker_thread); + psp->running = false; + sthread_join(psp->worker_thread); } if (psp->cond) - scond_free(psp->cond); + scond_free(psp->cond); if (psp->fifo_lock) - slock_free(psp->fifo_lock); + slock_free(psp->fifo_lock); if (psp->cond_lock) - slock_free(psp->cond_lock); + slock_free(psp->cond_lock); } free(psp->buffer); psp->worker_thread = NULL; @@ -222,7 +223,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) slock_unlock(psp->cond_lock); slock_lock(psp->fifo_lock); - if((write_pos + sampleCount) > AUDIO_BUFFER_SIZE) + if ((write_pos + sampleCount) > AUDIO_BUFFER_SIZE) { memcpy(psp->buffer + write_pos, buf, (AUDIO_BUFFER_SIZE - write_pos) * sizeof(uint32_t)); @@ -274,13 +275,13 @@ static bool psp_audio_start(void *data, bool is_shutdown) { psp_audio_t* psp = (psp_audio_t*)data; - if(psp && psp->running) - return true; - - if (!psp->worker_thread) + if (psp && !psp->running) { - psp->running = true; - psp->worker_thread = sthread_create(audioMainLoop, psp); + if (!psp->worker_thread) + { + psp->running = true; + psp->worker_thread = sthread_create(audioMainLoop, psp); + } } return true; @@ -295,7 +296,6 @@ static void psp_audio_set_nonblock_state(void *data, bool toggle) static bool psp_audio_use_float(void *data) { - (void)data; return false; } @@ -315,7 +315,7 @@ static size_t psp_write_avail(void *data) static size_t psp_buffer_size(void *data) { - /* TODO */ + /* TODO/FIXME - implement? */ return AUDIO_BUFFER_SIZE /** sizeof(uint32_t)*/; } diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index 79cb59215c..171c2dedaf 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -1675,7 +1675,7 @@ static void decode_thread_seek(double time) decode_last_audio_time = time; - if(avformat_seek_file(fctx, -1, INT64_MIN, seek_to, INT64_MAX, 0) < 0) + if (avformat_seek_file(fctx, -1, INT64_MIN, seek_to, INT64_MAX, 0) < 0) log_cb(RETRO_LOG_ERROR, "[FFMPEG] av_seek_frame() failed.\n"); if (video_stream_index >= 0) diff --git a/ctr/gpu_old.c b/ctr/gpu_old.c index c6688b4a05..f3b92ff863 100644 --- a/ctr/gpu_old.c +++ b/ctr/gpu_old.c @@ -264,17 +264,17 @@ const u8 GPU_TEVID[]={0xC0,0xC8,0xD0,0xD8,0xF0,0xF8}; void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor) { - u32 param[0x5]; - if(id > 6) + u32 param[0x5]; + if (id > 6) return; - param[0x0] = (alphaSources << 16) | (rgbSources); - param[0x1] = (alphaOperands << 12) | (rgbOperands); - param[0x2] = (alphaCombine << 16) | (rgbCombine); - param[0x3] = constantColor; - param[0x4] = 0x00000000; /* ? */ + param[0x0] = (alphaSources << 16) | (rgbSources); + param[0x1] = (alphaOperands << 12) | (rgbOperands); + param[0x2] = (alphaCombine << 16) | (rgbCombine); + param[0x3] = constantColor; + param[0x4] = 0x00000000; /* ? */ - GPUCMD_AddIncrementalWrites(GPUREG_0000|GPU_TEVID[id], param, 0x00000005); + GPUCMD_AddIncrementalWrites(GPUREG_0000|GPU_TEVID[id], param, 0x00000005); } void GPU_DrawArray(GPU_Primitive_t primitive, u32 first, u32 count) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index dede639d12..0c0e40c7ea 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -377,7 +377,7 @@ u8* gfxBottomFramebuffers[2]; void gfxSetFramebufferInfo(gfxScreen_t screen, u8 id) { - if(screen==GFX_TOP) + if (screen==GFX_TOP) { u8 enable3d = 0; u8 bit5=(enable3d != 0); @@ -387,7 +387,9 @@ void gfxSetFramebufferInfo(gfxScreen_t screen, u8 id) enable3d ? (u32*)gfxTopRightFramebuffers[id] : (u32*)gfxTopLeftFramebuffers[id], 240 * 3, ((1)<<8)|((1^bit5)<<6)|((bit5)<<5)|GSP_BGR8_OES); - } else { + } + else + { gspPresentBuffer(GFX_BOTTOM, id, (u32*)gfxBottomFramebuffers[id], diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 9aedfdf99c..ea3ce10abe 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -123,19 +123,17 @@ static void CFSearchPathForDirectoriesInDomains( #else NSSearchPathDirectory dir = NSDocumentDirectory; #endif - CFStringRef array_val; #if __has_feature(objc_arc) - array_val = (__bridge CFStringRef)[ + CFStringRef array_val = (__bridge CFStringRef)[ NSSearchPathForDirectoriesInDomains(dir, NSUserDomainMask, YES) firstObject]; #else - NSArray *arr = NSSearchPathForDirectoriesInDomains(dir, - NSUserDomainMask, YES); - if ([arr count] == 0) { - array_val = nil; - } else{ - array_val = (CFStringRef)[arr objectAtIndex:0]; - } + CFStringRef array_val = nil; + NSArray *arr = + NSSearchPathForDirectoriesInDomains(dir, + NSUserDomainMask, YES); + if ([arr count] != 0) + array_val = (CFStringRef)[arr objectAtIndex:0]; #endif if (array_val) CFStringGetCString(array_val, s, len, kCFStringEncodingUTF8); @@ -160,9 +158,15 @@ void get_ios_version(int *major, int *minor); #define PMGMT_STRMATCH(a,b) (CFStringCompare(a, b, 0) == kCFCompareEqualTo) #define PMGMT_GETVAL(k,v) CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **) v) -/* Note that AC power sources also include a laptop battery it is charging. */ -static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, - bool * charging, int *seconds, int *percent) +/* Note that AC power sources also include a + * laptop battery it is charging. */ +static void darwin_check_power_source( + CFDictionaryRef dict, + bool *have_ac, + bool *have_battery, + bool *charging, + int *seconds, + int *percent) { CFStringRef strval; /* don't CFRelease() this. */ CFBooleanRef bval; @@ -183,7 +187,7 @@ static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, if (PMGMT_STRMATCH(strval, CFSTR(kIOPSACPowerValue))) is_ac = *have_ac = true; else if (!PMGMT_STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) - return; /* not a battery? */ + return; /* Not a battery? */ if ((PMGMT_GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) charge = true; @@ -195,7 +199,7 @@ static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, if (val > 0) { *have_battery = true; - maxpct = (int) val; + maxpct = (int)val; } } @@ -206,7 +210,7 @@ static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, if (val > 0) { *have_battery = true; - maxpct = (int) val; + maxpct = (int)val; } } @@ -216,12 +220,12 @@ static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, CFNumberGetValue(numval, kCFNumberSInt32Type, &val); /* Mac OS X reports 0 minutes until empty if you're plugged in. :( */ - if ((val == 0) && (is_ac)) - val = -1; /* !!! FIXME: calc from timeToFull and capacity? */ + if ((val == 0) && is_ac) + val = -1; /* !!! FIXME: calc from timeToFull and capacity? */ - secs = (int) val; + secs = (int)val; if (secs > 0) - secs *= 60; /* value is in minutes, so convert to seconds. */ + secs *= 60; /* value is in minutes, so convert to seconds. */ } if (PMGMT_GETVAL(kIOPSCurrentCapacityKey, &numval)) @@ -264,11 +268,8 @@ static void frontend_darwin_get_name(char *s, size_t len) { #if defined(IOS) struct utsname buffer; - - if (uname(&buffer) != 0) - return; - - strlcpy(s, buffer.machine, len); + if (uname(&buffer) == 0) + strlcpy(s, buffer.machine, len); #elif defined(OSX) size_t length = 0; sysctlbyname("hw.model", NULL, &length, NULL, 0); @@ -348,10 +349,10 @@ static void frontend_darwin_get_env(int *argc, char *argv[], if (!bundle) return; - bundle_url = CFBundleCopyBundleURL(bundle); - bundle_path = CFURLCopyPath(bundle_url); + bundle_url = CFBundleCopyBundleURL(bundle); + bundle_path = CFURLCopyPath(bundle_url); - resource_url = CFBundleCopyResourcesDirectoryURL(bundle); + resource_url = CFBundleCopyResourcesDirectoryURL(bundle); resource_path = CFURLCopyPath(resource_url); CFRelease(resource_url); @@ -379,8 +380,8 @@ static void frontend_darwin_get_env(int *argc, char *argv[], strlcat(home_dir_buf, "/RetroArch", sizeof(home_dir_buf)); #ifdef HAVE_METAL fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], - home_dir_buf, "shaders_slang", - sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + home_dir_buf, "shaders_slang", + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); #else fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], home_dir_buf, "shaders_glsl", @@ -450,14 +451,18 @@ static void frontend_darwin_get_env(int *argc, char *argv[], int major, minor; get_ios_version(&major, &minor); if (major > 8) - strlcpy(g_defaults.path_buildbot_server_url, "http://buildbot.libretro.com/nightly/apple/ios9/latest/", sizeof(g_defaults.path_buildbot_server_url)); + strlcpy(g_defaults.path_buildbot_server_url, + "http://buildbot.libretro.com/nightly/apple/ios9/latest/", + sizeof(g_defaults.path_buildbot_server_url)); } #endif #if TARGET_OS_IOS - fill_pathname_join_special(assets_zip_path, bundle_path_buf, "assets.zip", sizeof(assets_zip_path)); + fill_pathname_join_special(assets_zip_path, + bundle_path_buf, "assets.zip", sizeof(assets_zip_path)); #else - fill_pathname_join_special(assets_zip_path, full_resource_path_buf, "assets.zip", sizeof(assets_zip_path)); + fill_pathname_join_special(assets_zip_path, + full_resource_path_buf, "assets.zip", sizeof(assets_zip_path)); #endif if (path_is_valid(assets_zip_path)) @@ -616,7 +621,8 @@ static int frontend_darwin_get_rating(void) return -1; } -static enum frontend_powerstate frontend_darwin_get_powerstate(int *seconds, int *percent) +static enum frontend_powerstate frontend_darwin_get_powerstate( + int *seconds, int *percent) { enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; #if defined(OSX) @@ -629,12 +635,13 @@ static enum frontend_powerstate frontend_darwin_get_powerstate(int *seconds, int *percent = -1; if (!blob) - goto end; + return FRONTEND_POWERSTATE_NONE - list = IOPSCopyPowerSourcesList(blob); - - if (!list) - goto end; + if (!(list = IOPSCopyPowerSourcesList(blob))) + { + CFRelease(blob); + return FRONTEND_POWERSTATE_NONE; + } /* don't CFRelease() the list items, or dictionaries! */ have_ac = false; @@ -647,7 +654,7 @@ static enum frontend_powerstate frontend_darwin_get_powerstate(int *seconds, int CFTypeRef ps = (CFTypeRef)CFArrayGetValueAtIndex(list, i); CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps); if (dict) - checkps(dict, &have_ac, &have_battery, &charging, + darwin_check_power_source(dict, &have_ac, &have_battery, &charging, seconds, percent); } @@ -661,38 +668,35 @@ static enum frontend_powerstate frontend_darwin_get_powerstate(int *seconds, int ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; CFRelease(list); -end: - if (blob) - CFRelease(blob); + CFRelease(blob); #elif TARGET_OS_IOS float level; UIDevice *uidev = [UIDevice currentDevice]; - - if (!uidev) - return ret; - - [uidev setBatteryMonitoringEnabled:true]; - - switch (uidev.batteryState) + if (uidev) { - case UIDeviceBatteryStateCharging: - ret = FRONTEND_POWERSTATE_CHARGING; - break; - case UIDeviceBatteryStateFull: - ret = FRONTEND_POWERSTATE_CHARGED; - break; - case UIDeviceBatteryStateUnplugged: - ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - break; - case UIDeviceBatteryStateUnknown: - break; + [uidev setBatteryMonitoringEnabled:true]; + + switch (uidev.batteryState) + { + case UIDeviceBatteryStateCharging: + ret = FRONTEND_POWERSTATE_CHARGING; + break; + case UIDeviceBatteryStateFull: + ret = FRONTEND_POWERSTATE_CHARGED; + break; + case UIDeviceBatteryStateUnplugged: + ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; + break; + case UIDeviceBatteryStateUnknown: + break; + } + + level = uidev.batteryLevel; + + *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); + + [uidev setBatteryMonitoringEnabled:false]; } - - level = uidev.batteryLevel; - - *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); - - [uidev setBatteryMonitoringEnabled:false]; #endif return ret; } @@ -778,26 +782,24 @@ static int frontend_darwin_parse_drive_list(void *data, bool load_content) CFRelease(bundle_url); #endif #endif - return ret; } +/* TODO/FIXME - is adding iOS/tvOS support possible here? */ static uint64_t frontend_darwin_get_total_mem(void) { #if defined(OSX) uint64_t size; int mib[2] = { CTL_HW, HW_MEMSIZE }; - u_int namelen = sizeof(mib) / sizeof(mib[0]); + u_int namelen = ARRAY_SIZE(mib); size_t len = sizeof(size); - - if (sysctl(mib, namelen, &size, &len, NULL, 0) < 0) - return 0; - return size; -#else - return 0; + if (sysctl(mib, namelen, &size, &len, NULL, 0) >= 0) + return size; #endif + return 0; } +/* TODO/FIXME - is adding iOS/tvOS support possible here? */ static uint64_t frontend_darwin_get_free_mem(void) { #if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200)) @@ -808,12 +810,12 @@ static uint64_t frontend_darwin_get_free_mem(void) if (KERN_SUCCESS == host_page_size(mach_port, &page_size) && KERN_SUCCESS == host_statistics64(mach_port, HOST_VM_INFO, - (host_info64_t)&vm_stats, &count)) + (host_info64_t)&vm_stats, &count)) { - - long long used_memory = ((int64_t)vm_stats.active_count + - (int64_t)vm_stats.inactive_count + - (int64_t)vm_stats.wire_count) * (int64_t)page_size; + long long used_memory = ( + (int64_t)vm_stats.active_count + + (int64_t)vm_stats.inactive_count + + (int64_t)vm_stats.wire_count) * (int64_t)page_size; return used_memory; } #endif @@ -822,7 +824,8 @@ static uint64_t frontend_darwin_get_free_mem(void) static const char* frontend_darwin_get_cpu_model_name(void) { - cpu_features_get_model_name(darwin_cpu_model_name, sizeof(darwin_cpu_model_name)); + cpu_features_get_model_name(darwin_cpu_model_name, + sizeof(darwin_cpu_model_name)); return darwin_cpu_model_name; } @@ -851,7 +854,8 @@ static char* accessibility_mac_language_code(const char* language) return "Ioana"; else if (string_is_equal(language,"pt_pt")) return "Joana"; - else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt")) + else if (string_is_equal(language,"pt_bt") + || string_is_equal(language,"pt")) return "Luciana"; else if (string_is_equal(language,"th")) return "Kanya"; @@ -865,7 +869,8 @@ static char* accessibility_mac_language_code(const char* language) return "Maged"; else if (string_is_equal(language,"hu")) return "Mariska"; - else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh")) + else if (string_is_equal(language,"zh_tw") + || string_is_equal(language,"zh")) return "Mei-Jia"; else if (string_is_equal(language,"el")) return "Melina"; @@ -889,8 +894,7 @@ static char* accessibility_mac_language_code(const char* language) return "Zosia"; else if (string_is_equal(language,"cs")) return "Zuzana"; - else - return ""; + return ""; } static bool is_narrator_running_macos(void) @@ -904,12 +908,12 @@ static bool accessibility_speak_macos(int speed, int pid; const char *voice = get_user_language_iso639_1(false); char* language_speaker = accessibility_mac_language_code(voice); - char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; - + char* speeds[10] = {"80", "100", "125", "150", "170", "210", + "260", "310", "380", "450"}; if (speed < 1) - speed = 1; + speed = 1; else if (speed > 10) - speed = 10; + speed = 10; if (priority < 10 && speak_pid > 0) { @@ -952,8 +956,8 @@ static bool accessibility_speak_macos(int speed, else { char* cmd[] = {"say", NULL, "-r", NULL, NULL}; - cmd[1] = (char*) speak_text; - cmd[3] = speeds[speed-1]; + cmd[1] = (char*) speak_text; + cmd[3] = speeds[speed-1]; execvp("say",cmd); } } diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 086227ce18..593a03bda8 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -274,11 +274,10 @@ static void frontend_psp_init(void *data) memset(&appUtilBootParam, 0, sizeof(SceAppUtilBootParam)); sceAppUtilInit(&appUtilParam, &appUtilBootParam); #if defined(HAVE_VITAGLES) - if(pibInit(PIB_SHACCCG|PIB_ENABLE_MSAA|PIB_GET_PROC_ADDR_CORE)) + if (pibInit(PIB_SHACCCG|PIB_ENABLE_MSAA|PIB_GET_PROC_ADDR_CORE)) return; #endif #else - (void)data; /* initialize debug screen */ pspDebugScreenInit(); pspDebugScreenClear(); diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index 9dde3e0341..d989213b81 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -163,29 +163,30 @@ enum frontend_powerstate frontend_uwp_get_powerstate( int *seconds, int *percent) { SYSTEM_POWER_STATUS status; - enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; + enum frontend_powerstate + ret = FRONTEND_POWERSTATE_NONE; - if (!GetSystemPowerStatus(&status)) - return ret; + if (GetSystemPowerStatus(&status)) + { + if (status.BatteryFlag == 0xFF) + ret = FRONTEND_POWERSTATE_NONE; + else if (status.BatteryFlag & (1 << 7)) + ret = FRONTEND_POWERSTATE_NO_SOURCE; + else if (status.BatteryFlag & (1 << 3)) + ret = FRONTEND_POWERSTATE_CHARGING; + else if (status.ACLineStatus == 1) + ret = FRONTEND_POWERSTATE_CHARGED; + else + ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - if (status.BatteryFlag == 0xFF) - ret = FRONTEND_POWERSTATE_NONE; - else if (status.BatteryFlag & (1 << 7)) - ret = FRONTEND_POWERSTATE_NO_SOURCE; - else if (status.BatteryFlag & (1 << 3)) - ret = FRONTEND_POWERSTATE_CHARGING; - else if (status.ACLineStatus == 1) - ret = FRONTEND_POWERSTATE_CHARGED; - else - ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - - *percent = (int)status.BatteryLifePercent; - *seconds = (int)status.BatteryLifeTime; + *percent = (int)status.BatteryLifePercent; + *seconds = (int)status.BatteryLifeTime; #ifdef _WIN32 - if (*percent == 255) - *percent = 0; + if (*percent == 255) + *percent = 0; #endif + } return ret; } @@ -259,8 +260,10 @@ static int frontend_uwp_parse_drive_list(void *data, bool load_content) if (string_is_equal(uwp_device_family, "Windows.Desktop")) { menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILE_BROWSER_OPEN_UWP_PERMISSIONS), - msg_hash_to_str(MENU_ENUM_LABEL_FILE_BROWSER_OPEN_UWP_PERMISSIONS), + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_FILE_BROWSER_OPEN_UWP_PERMISSIONS), + msg_hash_to_str( + MENU_ENUM_LABEL_FILE_BROWSER_OPEN_UWP_PERMISSIONS), MENU_ENUM_LABEL_FILE_BROWSER_OPEN_UWP_PERMISSIONS, MENU_SETTING_ACTION, 0, 0, NULL); } diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 0b232e7b83..119da801f7 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -469,7 +469,8 @@ static void init_nvda(void) /* The above code is executed on each accessibility speak event, so * we should only revert to powershell if nvda_lib wasn't loaded previously, * and we weren't able to load it on this call, or we don't HAVE_DYLIB */ - if ((g_plat_win32_flags & PLAT_WIN32_FLAG_USE_NVDA) && !nvda_lib) { + if ((g_plat_win32_flags & PLAT_WIN32_FLAG_USE_NVDA) && !nvda_lib) + { g_plat_win32_flags &= ~PLAT_WIN32_FLAG_USE_NVDA; g_plat_win32_flags |= PLAT_WIN32_FLAG_USE_POWERSHELL; } diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 98e3f9d5a2..33cc8c3f67 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -582,7 +582,7 @@ void frontend_driver_attach_console(void) For now, we do this hack, but this absolutely should be redesigned as soon as possible. */ - if( frontend_driver_st.current_frontend_ctx + if ( frontend_driver_st.current_frontend_ctx && frontend_driver_st.current_frontend_ctx->attach_console) frontend_driver_st.current_frontend_ctx->attach_console(); } diff --git a/gfx/common/d3d10_common.c b/gfx/common/d3d10_common.c index 569a5922c7..2a9e2d11a3 100644 --- a/gfx/common/d3d10_common.c +++ b/gfx/common/d3d10_common.c @@ -167,7 +167,7 @@ d3d10_get_closest_match(D3D10Device device, DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN}; DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); - if(!format) + if (!format) format = default_list; while (*format != DXGI_FORMAT_UNKNOWN) diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 79056b33aa..43bca23ca3 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -188,7 +188,7 @@ d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT des DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN}; DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); - if(!format) + if (!format) format = default_list; while (*format != DXGI_FORMAT_UNKNOWN) diff --git a/gfx/common/d3d8_common.c b/gfx/common/d3d8_common.c index 11c571c617..245742328e 100644 --- a/gfx/common/d3d8_common.c +++ b/gfx/common/d3d8_common.c @@ -57,8 +57,7 @@ bool d3d8_initialize_symbols(enum gfx_ctx_api api) return true; #if defined(DEBUG) || defined(_DEBUG) - g_d3d8_dll = dylib_load("d3d8d.dll"); - if(!g_d3d8_dll) + if (!(g_d3d8_dll = dylib_load("d3d8d.dll"))) #endif g_d3d8_dll = dylib_load("d3d8.dll"); diff --git a/gfx/common/d3d9_common.c b/gfx/common/d3d9_common.c index 7188183628..5aa9f4af5b 100644 --- a/gfx/common/d3d9_common.c +++ b/gfx/common/d3d9_common.c @@ -592,7 +592,7 @@ static void d3d9_get_video_size(d3d9_video_t *d3d, d3d->resolution_hd_enable = false; - if(video_mode.fIsHiDef) + if (video_mode.fIsHiDef) { *width = 1280; *height = 720; @@ -1196,17 +1196,15 @@ static void d3d9_video_texture_load_d3d( if (!ti) return; - if((info->type == TEXTURE_FILTER_MIPMAP_LINEAR) || - (info->type == TEXTURE_FILTER_MIPMAP_NEAREST)) + if ( (info->type == TEXTURE_FILTER_MIPMAP_LINEAR) + || (info->type == TEXTURE_FILTER_MIPMAP_NEAREST)) want_mipmap = true; - tex = (LPDIRECT3DTEXTURE9)d3d9_texture_new(d3d->dev, + if (!(tex = (LPDIRECT3DTEXTURE9)d3d9_texture_new(d3d->dev, ti->width, ti->height, 0, usage, D3D9_ARGB8888_FORMAT, D3DPOOL_MANAGED, 0, 0, 0, - NULL, NULL, want_mipmap); - - if (!tex) + NULL, NULL, want_mipmap))) return; IDirect3DTexture9_LockRect(tex, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c index 124677e354..3cc77394dd 100644 --- a/gfx/common/dxgi_common.c +++ b/gfx/common/dxgi_common.c @@ -734,14 +734,14 @@ void dxgi_set_hdr_metadata( hdr10_meta_data.MaxFrameAverageLightLevel = (UINT16)(max_fall); - if(g_hdr10_meta_data.RedPrimary != hdr10_meta_data.RedPrimary || - g_hdr10_meta_data.GreenPrimary != hdr10_meta_data.GreenPrimary || - g_hdr10_meta_data.BluePrimary != hdr10_meta_data.BluePrimary || - g_hdr10_meta_data.WhitePoint != hdr10_meta_data.WhitePoint || - g_hdr10_meta_data.MaxContentLightLevel != hdr10_meta_data.MaxContentLightLevel || - g_hdr10_meta_data.MaxMasteringLuminance != hdr10_meta_data.MaxMasteringLuminance || - g_hdr10_meta_data.MinMasteringLuminance != hdr10_meta_data.MinMasteringLuminance || - g_hdr10_meta_data.MaxFrameAverageLightLevel != hdr10_meta_data.MaxFrameAverageLightLevel) + if (g_hdr10_meta_data.RedPrimary != hdr10_meta_data.RedPrimary || + g_hdr10_meta_data.GreenPrimary != hdr10_meta_data.GreenPrimary || + g_hdr10_meta_data.BluePrimary != hdr10_meta_data.BluePrimary || + g_hdr10_meta_data.WhitePoint != hdr10_meta_data.WhitePoint || + g_hdr10_meta_data.MaxContentLightLevel != hdr10_meta_data.MaxContentLightLevel || + g_hdr10_meta_data.MaxMasteringLuminance != hdr10_meta_data.MaxMasteringLuminance || + g_hdr10_meta_data.MinMasteringLuminance != hdr10_meta_data.MinMasteringLuminance || + g_hdr10_meta_data.MaxFrameAverageLightLevel != hdr10_meta_data.MaxFrameAverageLightLevel) { #ifdef __cplusplus if (FAILED(handle->SetHDRMetaData( diff --git a/gfx/common/metal/menu_pipeline.metal b/gfx/common/metal/menu_pipeline.metal index 4cfa884e08..7fa49e8dd0 100644 --- a/gfx/common/metal/menu_pipeline.metal +++ b/gfx/common/metal/menu_pipeline.metal @@ -206,7 +206,7 @@ fragment float4 bokeh_fragment(FontFragmentIn in [[ stage_in ]], float rad = 0.1 + 0.5 * siz + sin(pha + siz) / 4.0; float2 pos = float2(pox + sin(speed / 15. + pha + siz), - 1.0 - rad + (2.0 + 2.0 * rad) * fract(pha + 0.3 * (speed / 7.) * (0.2 + 0.8 * siz))); float dis = length(uv - pos); - if(dis < rad) + if (dis < rad) { float3 col = mix(float3(0.194 * sin(speed / 6.0) + 0.3, 0.2, 0.3 * pha), float3(1.1 * sin(speed / 9.0) + 0.3, 0.2 * pha, 0.4), 0.5 + 0.5 * sin(float(i))); color += col.zyx * (1.0 - smoothstep(rad * 0.15, rad, dis)); @@ -225,22 +225,18 @@ float rand_float(float x) float snow(float3 pos, float2 uv, float o, float atime) { - float2 d = (pos.xy - uv); - float a = atan(d.y / d.x) + sin(atime*1.0 + o) * 10.0; + float2 d = (pos.xy - uv); + float a = atan(d.y / d.x) + sin(atime*1.0 + o) * 10.0; float dist = d.x*d.x + d.y*d.y; - if(dist < pos.z/400.0) + if (dist < pos.z/400.0) { float col = 0.0; - if(sin(a * 8.0) < 0.0) - { - col=1.0; - } - if(dist < pos.z/800.0) - { - col+=1.0; - } + if (sin(a * 8.0) < 0.0) + col = 1.0; + if (dist < pos.z/800.0) + col += 1.0; return col * pos.z; } diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 02f937f9bf..5cc5b17db6 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -660,7 +660,7 @@ bool x11_alive(void *data) * is a key press of the same key combination, * then it's auto-repeat and the key wasn't * actually released. */ - if(XEventsQueued(g_x11_dpy, QueuedAfterReading)) + if (XEventsQueued(g_x11_dpy, QueuedAfterReading)) { XEvent next_event; XPeekEvent(g_x11_dpy, &next_event); diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index f577a159a0..32b4b65450 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -573,14 +573,14 @@ static void d3d8_get_video_size(d3d8_video_t *d3d, /* Only valid in PAL mode, not valid for HDTV modes! */ - if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) + if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) { /* Check for 16:9 mode (PAL REGION) */ - if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN) + if (video_mode & XC_VIDEO_FLAGS_WIDESCREEN) { *width = 720; /* 60 Hz, 720x480i */ - if(video_mode & XC_VIDEO_FLAGS_PAL_60Hz) + if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) *height = 480; else /* 50 Hz, 720x576i */ *height = 576; @@ -590,7 +590,7 @@ static void d3d8_get_video_size(d3d8_video_t *d3d, else { /* Check for 16:9 mode (NTSC REGIONS) */ - if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN) + if (video_mode & XC_VIDEO_FLAGS_WIDESCREEN) { *width = 720; *height = 480; @@ -598,23 +598,23 @@ static void d3d8_get_video_size(d3d8_video_t *d3d, } } - if(XGetAVPack() == XC_AV_PACK_HDTV) + if (XGetAVPack() == XC_AV_PACK_HDTV) { - if(video_mode & XC_VIDEO_FLAGS_HDTV_480p) + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) { *width = 640; *height = 480; d3d->widescreen_mode = false; d3d->resolution_hd_enable = true; } - else if(video_mode & XC_VIDEO_FLAGS_HDTV_720p) + else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) { *width = 1280; *height = 720; d3d->widescreen_mode = true; d3d->resolution_hd_enable = true; } - else if(video_mode & XC_VIDEO_FLAGS_HDTV_1080i) + else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) { *width = 1920; *height = 1080; diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index c48f25966f..728f46cfad 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -924,12 +924,12 @@ static bool gl1_gfx_frame(void *data, const void *frame, #ifdef VITA glUseProgram(0); bool enabled = glIsEnabled(GL_DEPTH_TEST); - if(enabled) + if (enabled) glDisable(GL_DEPTH_TEST); #endif menu_driver_frame(menu_is_alive, video_info); #ifdef VITA - if(enabled) + if (enabled) glEnable(GL_DEPTH_TEST); #endif } diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index 518fc43d1d..eaba52b518 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -690,7 +690,7 @@ static void wiiu_free_shader_preset(wiiu_video_t *wiiu) MEM2_free(wiiu->pass[i].vs_ubos[1]); MEM2_free(wiiu->pass[i].ps_ubos[0]); MEM2_free(wiiu->pass[i].ps_ubos[1]); - if(wiiu->pass[i].mem1) + if (wiiu->pass[i].mem1) MEM1_free(wiiu->pass[i].texture.surface.image); else MEM2_free(wiiu->pass[i].texture.surface.image); @@ -779,7 +779,7 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne { for (i = 0; i < wiiu->shader_preset->passes; i++) { - if(wiiu->pass[i].mem1) + if (wiiu->pass[i].mem1) MEM1_free(wiiu->pass[i].texture.surface.image); else MEM2_free(wiiu->pass[i].texture.surface.image); @@ -932,17 +932,17 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, unsigned i; for (i = 0; i < uniformVarCount; i++) { + int k; + float *dst; + const char *id = NULL; if (uniformVars[i].block != id) continue; - - const char *id = strrchr(uniformVars[i].name, '.'); - - if (!id) + if (!(id = strrchr(uniformVars[i].name, '.'))) continue; id++; - float *dst = ubo + uniformVars[i].offset; + dst = ubo + uniformVars[i].offset; if (string_is_equal(id, "OutputSize")) { @@ -964,7 +964,7 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, if (string_is_equal(id, "FrameCount")) { - *dst = wiiu->shader_preset->pass[pass].frame_count_mod ? + *dst = wiiu->shader_preset->pass[pass].frame_count_mod ? frame_count % wiiu->shader_preset->pass[pass].frame_count_mod : frame_count; *(u32 *)dst = __builtin_bswap32(*(u32 *)dst); @@ -973,7 +973,7 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, if (string_is_equal(id, "FrameDirection")) { - *dst = frame_direction; + *dst = frame_direction; *(u32 *)dst = __builtin_bswap32(*(u32 *)dst); continue; } @@ -989,7 +989,7 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, if (string_is_equal(id, "SourceSize")) { - GX2Surface *source = (pass > 0) ? &wiiu->pass[pass - 1].texture.surface : &wiiu->texture.surface; + GX2Surface *source = (pass > 0) ? &wiiu->pass[pass - 1].texture.surface : &wiiu->texture.surface; ((GX2_vec4 *)dst)->x = source->width; ((GX2_vec4 *)dst)->y = source->height; ((GX2_vec4 *)dst)->z = 1.0f / source->width; @@ -1000,15 +1000,16 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, if (!strncmp(id, "OriginalHistorySize", STRLEN_CONST("OriginalHistorySize"))) { - unsigned index = strtoul(id + STRLEN_CONST("OriginalHistorySize"), + GX2Surface *source; + unsigned index = strtoul(id + STRLEN_CONST("OriginalHistorySize"), NULL, 0); - if(index > pass) - index = 0; + if (index > pass) + index = 0; - if(index) - index = pass - index; + if (index) + index = pass - index; - GX2Surface *source = (index > 0) ? &wiiu->pass[index - 1].texture.surface : &wiiu->texture.surface; + source = (index > 0) ? &wiiu->pass[index - 1].texture.surface : &wiiu->texture.surface; ((GX2_vec4 *)dst)->x = source->width; ((GX2_vec4 *)dst)->y = source->height; ((GX2_vec4 *)dst)->z = 1.0f / source->width; @@ -1019,10 +1020,11 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, if ((pass > 0 ) && !strncmp(id, "PassOutputSize", STRLEN_CONST("PassOutputSize"))) { - unsigned index = strtoul(id + STRLEN_CONST("PassOutputSize"), NULL, 0); - if(index > pass - 1) - index = pass - 1; - GX2Surface *output = &wiiu->pass[index].texture.surface; + GX2Surface *output; + unsigned index = strtoul(id + STRLEN_CONST("PassOutputSize"), NULL, 0); + if (index > pass - 1) + index = pass - 1; + output = &wiiu->pass[index].texture.surface; ((GX2_vec4 *)dst)->x = output->width; ((GX2_vec4 *)dst)->y = output->height; ((GX2_vec4 *)dst)->z = 1.0f / output->width; @@ -1033,10 +1035,11 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, /* feedback not supported yet */ if (!strncmp(id, "PassFeedbackSize", STRLEN_CONST("PassFeedbackSize"))) { - unsigned index = strtoul(id + STRLEN_CONST("PassFeedbackSize"), NULL, 0); - if(index > wiiu->shader_preset->passes - 1) - index = wiiu->shader_preset->passes - 1; - GX2Surface *output = &wiiu->pass[index].texture.surface; + GX2Surface *output; + unsigned index = strtoul(id + STRLEN_CONST("PassFeedbackSize"), NULL, 0); + if (index > wiiu->shader_preset->passes - 1) + index = wiiu->shader_preset->passes - 1; + output = &wiiu->pass[index].texture.surface; ((GX2_vec4 *)dst)->x = output->width; ((GX2_vec4 *)dst)->y = output->height; ((GX2_vec4 *)dst)->z = 1.0f / output->width; @@ -1044,13 +1047,13 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, continue; } - for (int k = 0; k < wiiu->shader_preset->luts; k++) + for (k = 0; k < wiiu->shader_preset->luts; k++) { size_t lut_id_size = strlen(wiiu->shader_preset->lut[k].id); - if (!strncmp(id, wiiu->shader_preset->lut[k].id, lut_id_size) + if ( !strncmp(id, wiiu->shader_preset->lut[k].id, lut_id_size) && !!strcmp(id + lut_id_size, "Size")) { - GX2Surface *surface = &wiiu->luts[k].surface; + GX2Surface *surface = &wiiu->luts[k].surface; ((GX2_vec4 *)dst)->x = surface->width; ((GX2_vec4 *)dst)->y = surface->height; ((GX2_vec4 *)dst)->z = 1.0f / surface->width; @@ -1064,16 +1067,15 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, continue; } - for (int k = 0; k < wiiu->shader_preset->num_parameters; k++) + for (k = 0; k < wiiu->shader_preset->num_parameters; k++) { if (string_is_equal(id, wiiu->shader_preset->parameters[k].id)) { - *dst = wiiu->shader_preset->parameters[k].current; + *dst = wiiu->shader_preset->parameters[k].current; *(u32 *)dst = __builtin_bswap32(*(u32 *)dst); break; } } - } GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, ubo, size); @@ -1122,13 +1124,13 @@ static bool wiiu_gfx_frame(void *data, const void *frame, wiiu_gfx_update_viewport(wiiu); GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f); - /* can't call GX2ClearColor after GX2SetContextState for whatever reason */ + /* Can't call GX2ClearColor after GX2SetContextState for whatever reason */ GX2SetContextState(wiiu->ctx_state); if (frame) { - if ((width != wiiu->texture.surface.width) || - (height != wiiu->texture.surface.height)) + if ( (width != wiiu->texture.surface.width) + || (height != wiiu->texture.surface.height)) wiiu_init_frame_textures(wiiu, width, height); wiiu->width = width; @@ -1221,6 +1223,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame, for (j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++) { + int k; if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Source")) { GX2SetPixelTexture(texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); @@ -1243,14 +1246,14 @@ static bool wiiu_gfx_frame(void *data, const void *frame, if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "OriginalHistory", STRLEN_CONST("OriginalHistory"))) { - unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("OriginalHistory"), NULL, 0); - if(index > i) - index = 0; + GX2Texture *source; + unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("OriginalHistory"), NULL, 0); + if (index > i) + index = 0; + if (index) + index = i - index; - if(index) - index = i - index; - - GX2Texture *source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture; + source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture; GX2SetPixelTexture(source, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ? &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : @@ -1262,8 +1265,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame, if ((i > 0) && !strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassOutput", STRLEN_CONST("PassOutput"))) { unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassOutput"), NULL, 0); - if(index > i - 1) - index = i - 1; + if (index > i - 1) + index = i - 1; GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ? &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : @@ -1276,8 +1279,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame, if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassFeedback", STRLEN_CONST("PassFeedback"))) { unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassFeedback"), NULL, 0); - if(index > wiiu->shader_preset->passes - 1) - index = wiiu->shader_preset->passes - 1; + if (index > wiiu->shader_preset->passes - 1) + index = wiiu->shader_preset->passes - 1; GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ? @@ -1287,7 +1290,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame, continue; } - for (int k = 0; k < wiiu->shader_preset->luts; k++) + for (k = 0; k < wiiu->shader_preset->luts; k++) { if (wiiu->luts[k].surface.image && string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, wiiu->shader_preset->lut[k].id)) @@ -1300,7 +1303,6 @@ static bool wiiu_gfx_frame(void *data, const void *frame, } } - } if (wiiu->pass[i].color_buffer.surface.image) @@ -1440,22 +1442,10 @@ static void wiiu_gfx_set_nonblock_state(void *data, bool toggle, GX2SetSwapInterval(!toggle); /* do we need this ? */ } -static bool wiiu_gfx_alive(void *data) -{ - (void)data; - return true; -} - -static bool wiiu_gfx_focus(void *data) -{ - (void)data; - return true; -} - +static bool wiiu_gfx_alive(void *data) { return true; } +static bool wiiu_gfx_focus(void *data) { return true; } static bool wiiu_gfx_suppress_screensaver(void *data, bool enable) { - (void)data; - (void)enable; return false; } @@ -1471,100 +1461,100 @@ static bool wiiu_gfx_set_shader(void *data, GX2DrawDone(); wiiu_free_shader_preset(wiiu); - if (string_is_empty(path)) - return true; - - if (type != RARCH_SHADER_SLANG) + if (!string_is_empty(path)) { - RARCH_WARN("[GX2] Only Slang shaders are supported. Falling back to stock.\n"); - return false; - } - - wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset)); - - if (!video_shader_load_preset_into_shader(path, wiiu->shader_preset)) - { - free(wiiu->shader_preset); - wiiu->shader_preset = NULL; - return false; - } - - for (i = 0; i < wiiu->shader_preset->passes; i++) - { - unsigned j; - char *ptr; - char gfdpath[PATH_MAX_LENGTH]; - struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; - - strlcpy(gfdpath, pass->source.path, sizeof(gfdpath)); - - if (!(ptr = strrchr(gfdpath, '.'))) - ptr = gfdpath + strlen(gfdpath); - - *ptr++ = '.'; - *ptr++ = 'g'; - *ptr++ = 's'; - *ptr++ = 'h'; - *ptr++ = '\0'; - - wiiu->pass[i].gfd = gfd_open(gfdpath); - - if (!wiiu->pass[i].gfd) + if (type != RARCH_SHADER_SLANG) { - wiiu_free_shader_preset(wiiu); + RARCH_WARN("[GX2] Only Slang shaders are supported. Falling back to stock.\n"); return false; } - for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) + wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset)); + + if (!video_shader_load_preset_into_shader(path, wiiu->shader_preset)) { - wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size, - GX2_UNIFORM_BLOCK_ALIGNMENT); - memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size); - GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j], - wiiu->pass[i].gfd->vs->uniformBlocks[j].size); + free(wiiu->shader_preset); + wiiu->shader_preset = NULL; + return false; } - for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) - { - wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size, - GX2_UNIFORM_BLOCK_ALIGNMENT); - memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size); - GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j], - wiiu->pass[i].gfd->ps->uniformBlocks[j].size); - } - } - - for (i = 0; i < wiiu->shader_preset->luts; i++) - { - struct texture_image image = {}; - - if (image_texture_load(&image, wiiu->shader_preset->lut[i].path)) + for (i = 0; i < wiiu->shader_preset->passes; i++) { unsigned j; + char *ptr; + char gfdpath[PATH_MAX_LENGTH]; + struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; - wiiu->luts[i].surface.width = image.width; - wiiu->luts[i].surface.height = image.height; - wiiu->luts[i].surface.depth = 1; - wiiu->luts[i].surface.dim = GX2_SURFACE_DIM_TEXTURE_2D; - wiiu->luts[i].surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED; - wiiu->luts[i].viewNumSlices = 1; + strlcpy(gfdpath, pass->source.path, sizeof(gfdpath)); - wiiu->luts[i].surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8; - wiiu->luts[i].compMap = GX2_COMP_SEL(_G, _B, _A, _R); + if (!(ptr = strrchr(gfdpath, '.'))) + ptr = gfdpath + strlen(gfdpath); - GX2CalcSurfaceSizeAndAlignment(&wiiu->luts[i].surface); - GX2InitTextureRegs(&wiiu->luts[i]); - wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize, - wiiu->luts[i].surface.alignment); + *ptr++ = '.'; + *ptr++ = 'g'; + *ptr++ = 's'; + *ptr++ = 'h'; + *ptr++ = '\0'; - for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++) - memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch), - image.pixels + (j * image.width), image.width * sizeof(image.pixels)); + wiiu->pass[i].gfd = gfd_open(gfdpath); - GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->luts[i].surface.image, - wiiu->luts[i].surface.imageSize); + if (!wiiu->pass[i].gfd) + { + wiiu_free_shader_preset(wiiu); + return false; + } - image_texture_free(&image); + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) + { + wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size, + GX2_UNIFORM_BLOCK_ALIGNMENT); + memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size); + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j], + wiiu->pass[i].gfd->vs->uniformBlocks[j].size); + } + + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) + { + wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size, + GX2_UNIFORM_BLOCK_ALIGNMENT); + memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size); + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j], + wiiu->pass[i].gfd->ps->uniformBlocks[j].size); + } + } + + for (i = 0; i < wiiu->shader_preset->luts; i++) + { + struct texture_image image = {}; + + if (image_texture_load(&image, wiiu->shader_preset->lut[i].path)) + { + unsigned j; + + wiiu->luts[i].surface.width = image.width; + wiiu->luts[i].surface.height = image.height; + wiiu->luts[i].surface.depth = 1; + wiiu->luts[i].surface.dim = GX2_SURFACE_DIM_TEXTURE_2D; + wiiu->luts[i].surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED; + wiiu->luts[i].viewNumSlices = 1; + + wiiu->luts[i].surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8; + wiiu->luts[i].compMap = GX2_COMP_SEL(_G, _B, _A, _R); + + GX2CalcSurfaceSizeAndAlignment(&wiiu->luts[i].surface); + GX2InitTextureRegs(&wiiu->luts[i]); + wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize, + wiiu->luts[i].surface.alignment); + + for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++) + memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch), + image.pixels + (j * image.width), image.width * sizeof(image.pixels)); + + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->luts[i].surface.image, + wiiu->luts[i].surface.imageSize); + + image_texture_free(&image); + } } } @@ -1712,13 +1702,13 @@ static void wiiu_gfx_set_texture_frame(void *data, GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->menu.texture.surface.image, wiiu->menu.texture.surface.imageSize); - wiiu->menu.v->pos.x = wiiu->vp.x; - wiiu->menu.v->pos.y = wiiu->vp.y; - wiiu->menu.v->pos.width = wiiu->vp.width; - wiiu->menu.v->pos.height = wiiu->vp.height; - wiiu->menu.v->coord.u = 0.0f; - wiiu->menu.v->coord.v = 0.0f; - wiiu->menu.v->coord.width = (float)width / wiiu->menu.texture.surface.width; + wiiu->menu.v->pos.x = wiiu->vp.x; + wiiu->menu.v->pos.y = wiiu->vp.y; + wiiu->menu.v->pos.width = wiiu->vp.width; + wiiu->menu.v->pos.height = wiiu->vp.height; + wiiu->menu.v->coord.u = 0.0f; + wiiu->menu.v->coord.v = 0.0f; + wiiu->menu.v->coord.width = (float)width / wiiu->menu.texture.surface.width; wiiu->menu.v->coord.height = (float)height / wiiu->menu.texture.surface.height; GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, wiiu->menu.v, 4 * sizeof(*wiiu->menu.v)); @@ -1784,18 +1774,13 @@ static const video_poke_interface_t wiiu_poke_interface = { }; static void wiiu_gfx_get_poke_interface(void *data, - const video_poke_interface_t **iface) + const video_poke_interface_t **iface) { - (void)data; *iface = &wiiu_poke_interface; } #ifdef HAVE_GFX_WIDGETS -static bool wiiu_gfx_widgets_enabled(void *data) -{ - (void)data; - return true; -} +static bool wiiu_gfx_widgets_enabled(void *data) { return true; } #endif video_driver_t video_wiiu = diff --git a/gfx/drivers/gx_gfx_vi_encoder.c b/gfx/drivers/gx_gfx_vi_encoder.c index 484bbc7cee..8c31058eee 100644 --- a/gfx/drivers/gx_gfx_vi_encoder.c +++ b/gfx/drivers/gx_gfx_vi_encoder.c @@ -118,13 +118,13 @@ static u32 __VISendI2CData(u8 addr,void *val,u32 len) s32 i,j; u32 level,ret; - if(i2cIdentFirst==0) + if (i2cIdentFirst==0) { __viOpenI2C(0); udelay(4); i2cIdentFlag = 0; - if(__viGetSDA()!=0) + if (__viGetSDA()!=0) i2cIdentFlag = 1; i2cIdentFirst = 1; } @@ -137,9 +137,7 @@ static u32 __VISendI2CData(u8 addr,void *val,u32 len) __viSetSDA(i2cIdentFlag); udelay(4); - ret = __sendSlaveAddress(addr); - - if(ret == 0) + if ((ret = __sendSlaveAddress(addr)) == 0) { _CPU_ISR_Restore(level); return 0; @@ -151,7 +149,7 @@ static u32 __VISendI2CData(u8 addr,void *val,u32 len) c = ((u8*)val)[i]; for(j=0;j<8;j++) { - if(c&0x80) + if (c&0x80) __viSetSDA(i2cIdentFlag); else __viSetSDA(i2cIdentFlag^1); @@ -168,7 +166,7 @@ static u32 __VISendI2CData(u8 addr,void *val,u32 len) __viSetSCL(1); udelay(2); - if(i2cIdentFlag == 1 && __viGetSDA()!=0) + if (i2cIdentFlag == 1 && __viGetSDA()!=0) { _CPU_ISR_Restore(level); return 0; @@ -407,7 +405,8 @@ static const u8 gamma_coeffs[][33] = void VIDEO_SetGamma(int gamma) { - gamma = MAX(0,MIN(30,gamma)); - u8 *data = (u8 *)&gamma_coeffs[gamma][0]; + u8 *data; + gamma = MAX(0,MIN(30,gamma)); + data = (u8 *)&gamma_coeffs[gamma][0]; __VIWriteI2CRegisterBuf(0x10, 0x21, data); } diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index fd8ff73001..f9244f55a1 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -402,7 +402,7 @@ static void *psp_init(const video_info_t *video, psp->vsync = video->vsync; psp->rgb32 = video->rgb32; - if(psp->rgb32) + if (psp->rgb32) { u32 i; uint32_t* LUT_r_local = (uint32_t*)(SCEGU_VRAM_BP32_2); @@ -620,7 +620,7 @@ static bool psp_frame(void *data, const void *frame, menu_driver_frame(menu_is_alive, video_info); #endif - if(psp->menu.active) + if (psp->menu.active) { sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage)); sceGuSync(0, 0); @@ -646,7 +646,7 @@ static void psp_free(void *data) { psp1_video_t *psp = (psp1_video_t*)data; - if(!(psp) || !(psp->main_dList)) + if (!(psp) || !(psp->main_dList)) return; sceDisplayWaitVblankStart(); diff --git a/gfx/drivers/rsx_gfx.c b/gfx/drivers/rsx_gfx.c index f9671ae580..c59e612106 100644 --- a/gfx/drivers/rsx_gfx.c +++ b/gfx/drivers/rsx_gfx.c @@ -777,7 +777,7 @@ static void rsx_unload_texture(void *data, { #if 0 /* TODO fix crash on loading core */ - if(texture->data) + if (texture->data) rsxFree(texture->data); #endif free(texture); @@ -1177,7 +1177,7 @@ static bool rsx_frame(void* data, const void* frame, vp.offset[3] = 0.0f; rsxSetViewport(gcm->context, vp.x, vp.y, vp.w, vp.h, vp.min, vp.max, vp.scale, vp.offset); - if(frame && width && height) + if (frame && width && height) { gcm->tex_index = ((gcm->tex_index + 1) % RSX_MAX_TEXTURES); rsx_load_texture_data(gcm, &gcm->texture[gcm->tex_index], frame, width, height, pitch, gcm->rgb32, false, @@ -1324,7 +1324,7 @@ static void rsx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) { rsx_t* gcm = (rsx_t*)data; - if(!gcm) + if (!gcm) return; gcm->keep_aspect = true; diff --git a/gfx/drivers/switch_gfx.c b/gfx/drivers/switch_gfx.c index d491934eed..cbeb230c8f 100644 --- a/gfx/drivers/switch_gfx.c +++ b/gfx/drivers/switch_gfx.c @@ -174,10 +174,10 @@ static bool switch_frame(void *data, const void *frame, for (x = 0; x < 1280; x++) sw->image[y*1280+x] = 0xFF000000; - if(width > 0 && height > 0) + if (width > 0 && height > 0) { - if(sw->last_width != width || - sw->last_height != height) + if ( (sw->last_width != width) + || (sw->last_height != height)) { scaler_ctx_gen_reset(&sw->scaler); @@ -193,7 +193,7 @@ static bool switch_frame(void *data, const void *frame, sw->scaler.scaler_type = SCALER_TYPE_POINT; - if(!scaler_ctx_gen_filter(&sw->scaler)) + if (!scaler_ctx_gen_filter(&sw->scaler)) { RARCH_ERR("failed to generate scaler for main image\n"); return false; @@ -245,11 +245,11 @@ static bool switch_frame(void *data, const void *frame, #endif r = surface_dequeue_buffer(&sw->surface, &out_buffer); - if(r != RESULT_OK) + if (r != RESULT_OK) return true; /* just skip the frame */ r = surface_wait_buffer(&sw->surface); - if(r != RESULT_OK) + if (r != RESULT_OK) return true; gfx_slow_swizzling_blit(out_buffer, sw->image, 1280, 720, 0, 0); diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 683caff97b..ca2e73a6bb 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -171,7 +171,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, if (frame) { - if(!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame)) + if (!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame)) { unsigned i; unsigned int stride; @@ -252,7 +252,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, menu_driver_frame(menu_is_alive, video_info); #endif - if(vita->menu.texture) + if (vita->menu.texture) { if (vita->fullscreen) vita2d_draw_texture_scale(vita->menu.texture, @@ -297,7 +297,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, gfx_widgets_frame(video_info); #endif - if(!string_is_empty(msg)) + if (!string_is_empty(msg)) font_driver_render_msg(vita, msg, NULL, NULL); vita2d_end_drawing(); @@ -782,7 +782,7 @@ static bool vita_get_current_sw_framebuffer(void *data, if (!vita->texture || vita->width != framebuffer->width || vita->height != framebuffer->height) { - if(vita->texture) + if (vita->texture) { vita2d_wait_rendering_done(); vita2d_free_texture(vita->texture); diff --git a/gfx/drivers/vulkan_shaders/hdr.frag b/gfx/drivers/vulkan_shaders/hdr.frag index 95c9a74aec..72df88b89f 100644 --- a/gfx/drivers/vulkan_shaders/hdr.frag +++ b/gfx/drivers/vulkan_shaders/hdr.frag @@ -24,7 +24,7 @@ vec3 InverseTonemap(vec3 sdr) { vec3 hdr; - if(global.inverse_tonemap > 0.0f) + if (global.inverse_tonemap > 0.0f) { sdr = pow(abs(sdr), vec3(global.contrast / 2.2f)); /* Display Gamma - needs to be determined by calibration screen */ @@ -83,23 +83,19 @@ vec3 Hdr10(vec3 hdr) { vec3 hdr10; - if(global.hdr10 > 0.0f) + if (global.hdr10 > 0.0f) { /* Now convert into HDR10 */ vec3 rec2020 = hdr * k709to2020; - if(global.expand_gamut > 0.0f) - { - rec2020 = hdr * kExpanded709to2020; - } + if (global.expand_gamut > 0.0f) + rec2020 = hdr * kExpanded709to2020; vec3 linearColour = rec2020 * (global.paper_white_nits / kMaxNitsFor2084); hdr10 = LinearToST2084(linearColour); } else - { hdr10 = hdr; - } return hdr10; } diff --git a/gfx/drivers/vulkan_shaders/pipeline_bokeh.frag b/gfx/drivers/vulkan_shaders/pipeline_bokeh.frag index 60fb3db5cb..9344eabd6f 100644 --- a/gfx/drivers/vulkan_shaders/pipeline_bokeh.frag +++ b/gfx/drivers/vulkan_shaders/pipeline_bokeh.frag @@ -28,7 +28,7 @@ for( int i=0; i < 8; i++ ) float rad = 0.1 + 0.5 * siz + sin(pha + siz) / 4.0; vec2 pos = vec2(pox + sin(speed / 15. + pha + siz), - 1.0 - rad + (2.0 + 2.0 * rad) * fract(pha + 0.3 * (speed / 7.) * (0.2 + 0.8 * siz))); float dis = length(uv - pos); - if(dis < rad) + if (dis < rad) { vec3 col = mix(vec3(0.194 * sin(speed / 6.0) + 0.3, 0.2, 0.3 * pha), vec3(1.1 * sin(speed / 9.0) + 0.3, 0.2 * pha, 0.4), 0.5 + 0.5 * sin(float(i))); color += col.zyx * (1.0 - smoothstep(rad * 0.15, rad, dis)); diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 4aeda2b365..ab895617ad 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -132,7 +132,7 @@ static void *gfx_ctx_qnx_init(void *video_driver) goto error; #endif - if(!screen_win) + if (!screen_win) { if (screen_create_window(&screen_win, screen_ctx)) { @@ -308,7 +308,7 @@ static int dpi_get_density(qnx_ctx_data_t *qnx) { int screen_dpi[2]; - if(!qnx) + if (!qnx) return -1; if (screen_get_display_property_iv(qnx->screen_disp, diff --git a/gfx/drivers_font/d3d12_font.c b/gfx/drivers_font/d3d12_font.c index 9cd5a2254e..638c71def5 100644 --- a/gfx/drivers_font/d3d12_font.c +++ b/gfx/drivers_font/d3d12_font.c @@ -216,7 +216,7 @@ static void d3d12_font_render_line( font->atlas->dirty = false; } - if(font->texture.dirty) + if (font->texture.dirty) d3d12_upload_texture(d3d12->queue.cmd, &font->texture, d3d12); diff --git a/gfx/drivers_font/wiiu_font.c b/gfx/drivers_font/wiiu_font.c index 15f02993e2..a6bef75145 100644 --- a/gfx/drivers_font/wiiu_font.c +++ b/gfx/drivers_font/wiiu_font.c @@ -213,7 +213,7 @@ static void wiiu_font_render_line( GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, wiiu->vertex_cache.v + wiiu->vertex_cache.current, count * sizeof(wiiu->vertex_cache.v)); - if(font->atlas->dirty) + if (font->atlas->dirty) { for (i = 0; (i < font->atlas->height) && (i < font->texture.surface.height); i++) memcpy(font->texture.surface.image + (i * font->texture.surface.pitch), diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 81a7b3727d..6395da3652 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -300,11 +300,11 @@ static bool gl_glsl_load_binary_shader(GLuint shader, char *save_path) GLint status; FILE *shader_binary = fopen(save_path, "rb" ); - if(shader_binary) + if (shader_binary) { char *shader_data = NULL; - fseek (shader_binary, 0, SEEK_END); + fseek(shader_binary, 0, SEEK_END); shader_size=ftell (shader_binary); fseek(shader_binary, 0, SEEK_SET); @@ -414,7 +414,7 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, gl_glsl_hash_shader(source, ARRAY_SIZE(source)); snprintf(save_path, sizeof(save_path), "/data/retroarch/temp/%lx.sb", hash); - if(gl_glsl_load_binary_shader(shader, save_path)) + if (gl_glsl_load_binary_shader(shader, save_path)) return true; } #endif @@ -427,7 +427,7 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, #if 0 #if defined(ORBIS) - if(status == GL_TRUE) + if (status == GL_TRUE) gl_glsl_dump_shader(shader, save_path); #endif #endif diff --git a/gfx/video_filters/2xsai.c b/gfx/video_filters/2xsai.c index 7accb0ae6f..9f9d2e1d1a 100644 --- a/gfx/video_filters/2xsai.c +++ b/gfx/video_filters/2xsai.c @@ -68,21 +68,18 @@ static void *twoxsai_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - - (void)simd; - (void)config; - (void)userdata; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) - calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; return filt; } @@ -90,7 +87,7 @@ static void twoxsai_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width * TWOXSAI_SCALE; + *out_width = width * TWOXSAI_SCALE; *out_height = height * TWOXSAI_SCALE; } @@ -143,30 +140,22 @@ static void twoxsai_generic_destroy(void *data) if ((colorA == colorE && colorB == colorL) || (colorA == colorC && colorA == colorF && colorB != colorE && colorB == colorJ)) \ product = colorA; \ else \ - { \ product = interpolate_cb(colorA, colorB); \ - } \ if ((colorA == colorG && colorC == colorO) || (colorA == colorB && colorA == colorH && colorG != colorC && colorC == colorM)) \ product1 = colorA; \ else \ - { \ product1 = interpolate_cb(colorA, colorC); \ - } \ product2 = colorA; \ } else if (colorB == colorC && colorA != colorD) \ { \ if ((colorB == colorF && colorA == colorH) || (colorB == colorE && colorB == colorD && colorA != colorF && colorA == colorI)) \ product = colorB; \ else \ - { \ product = interpolate_cb(colorA, colorB); \ - } \ if ((colorC == colorH && colorA == colorF) || (colorC == colorG && colorC == colorD && colorA != colorH && colorA == colorI)) \ product1 = colorC; \ else \ - { \ product1 = interpolate_cb(colorA, colorC); \ - } \ product2 = colorB; \ } \ else if (colorA == colorD && colorB == colorC) \ @@ -179,21 +168,19 @@ static void twoxsai_generic_destroy(void *data) } \ else \ { \ - int r = 0; \ + int r = 0; \ product1 = interpolate_cb(colorA, colorC); \ product = interpolate_cb(colorA, colorB); \ - r += result_cb(colorA, colorB, colorG, colorE); \ - r += result_cb(colorB, colorA, colorK, colorF); \ - r += result_cb(colorB, colorA, colorH, colorN); \ - r += result_cb(colorA, colorB, colorL, colorO); \ + r += result_cb(colorA, colorB, colorG, colorE); \ + r += result_cb(colorB, colorA, colorK, colorF); \ + r += result_cb(colorB, colorA, colorH, colorN); \ + r += result_cb(colorA, colorB, colorL, colorO); \ if (r > 0) \ product2 = colorA; \ else if (r < 0) \ product2 = colorB; \ else \ - { \ product2 = interpolate2_cb(colorA, colorB, colorC, colorD); \ - } \ } \ } \ else \ @@ -204,21 +191,17 @@ static void twoxsai_generic_destroy(void *data) else if (colorB == colorE && colorB == colorD && colorA != colorF && colorA == colorI) \ product = colorB; \ else \ - { \ product = interpolate_cb(colorA, colorB); \ - } \ if (colorA == colorB && colorA == colorH && colorG != colorC && colorC == colorM) \ product1 = colorA; \ else if (colorC == colorG && colorC == colorD && colorA != colorH && colorA == colorI) \ product1 = colorC; \ else \ - { \ product1 = interpolate_cb(colorA, colorC); \ - } \ } \ - out[0] = colorA; \ - out[1] = product; \ - out[dst_stride] = product1; \ + out[0] = colorA; \ + out[1] = product; \ + out[dst_stride] = product1; \ out[dst_stride + 1] = product2; \ ++in; \ out += 2 @@ -292,11 +275,10 @@ static void twoxsai_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; twoxsai_generic_rgb565(width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), @@ -308,11 +290,10 @@ static void twoxsai_work_cb_xrgb8888(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint32_t *input = (uint32_t*)thr->in_data; - uint32_t *output = (uint32_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint32_t *input = (uint32_t*)thr->in_data; + uint32_t *output = (uint32_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; twoxsai_generic_xrgb8888(width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), @@ -327,37 +308,38 @@ static void twoxsai_generic_packets(void *data, unsigned height, size_t input_stride) { unsigned i; - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; for (i = 0; i < filt->threads; i++) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + + thr->out_data = (uint8_t*)output + y_start * TWOXSAI_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can access pixels * outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = twoxsai_work_cb_rgb565; + packets[i].work = twoxsai_work_cb_rgb565; #if 0 else if (filt->in_fmt == SOFTFILTER_FMT_RGB4444) - packets[i].work = twoxsai_work_cb_rgb4444; + packets[i].work = twoxsai_work_cb_rgb4444; #endif else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = twoxsai_work_cb_xrgb8888; + packets[i].work = twoxsai_work_cb_xrgb8888; packets[i].thread_data = thr; } } @@ -380,7 +362,6 @@ static const struct softfilter_implementation twoxsai_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &twoxsai_generic; } diff --git a/gfx/video_filters/blargg_ntsc_snes.c b/gfx/video_filters/blargg_ntsc_snes.c index b4511e2598..c6b1f683da 100644 --- a/gfx/video_filters/blargg_ntsc_snes.c +++ b/gfx/video_filters/blargg_ntsc_snes.c @@ -46,10 +46,10 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; struct softfilter_thread_data *workers; - unsigned in_fmt; struct snes_ntsc_t *ntsc; + unsigned threads; + unsigned in_fmt; int burst; int burst_toggle; }; @@ -162,18 +162,18 @@ static void *blargg_ntsc_snes_generic_create(const struct softfilter_config *con unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) - calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; blargg_ntsc_snes_initialize(filt, config, userdata); @@ -195,7 +195,7 @@ static void blargg_ntsc_snes_generic_destroy(void *data) if (!filt) return; - if(filt->ntsc) + if (filt->ntsc) free(filt->ntsc); free(filt->workers); @@ -207,7 +207,7 @@ static void blargg_ntsc_snes_render_rgb565(void *data, int width, int height, uint16_t *input, int pitch, uint16_t *output, int outpitch) { struct filter_data *filt = (struct filter_data*)data; - if(width <= 256 || !hires_blit) + if (width <= 256 || !hires_blit) retroarch_snes_ntsc_blit(filt->ntsc, input, pitch, filt->burst, width, height, output, outpitch * 2, first, last); else @@ -225,18 +225,16 @@ static void blargg_ntsc_snes_rgb565(void *data, unsigned width, unsigned height, first, last, src, src_stride, dst, dst_stride); - } static void blargg_ntsc_snes_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; blargg_ntsc_snes_rgb565(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), @@ -249,30 +247,31 @@ static void blargg_ntsc_snes_generic_packets(void *data, void *output, size_t output_stride, const void *input, unsigned width, unsigned height, size_t input_stride) { - struct filter_data *filt = (struct filter_data*)data; unsigned i; + struct filter_data *filt = (struct filter_data*)data; for (i = 0; i < filt->threads; i++) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can * access pixels outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; + /* TODO/FIXME - no XRGB8888 codepath? */ if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = blargg_ntsc_snes_work_cb_rgb565; - packets[i].thread_data = thr; + packets[i].work = blargg_ntsc_snes_work_cb_rgb565; + packets[i].thread_data = thr; } } @@ -294,7 +293,6 @@ static const struct softfilter_implementation blargg_ntsc_snes_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &blargg_ntsc_snes_generic; } diff --git a/gfx/video_filters/darken.c b/gfx/video_filters/darken.c index 17cdce7334..bdb9831b53 100644 --- a/gfx/video_filters/darken.c +++ b/gfx/video_filters/darken.c @@ -40,8 +40,8 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; struct softfilter_thread_data *workers; + unsigned threads; unsigned in_fmt; }; @@ -67,27 +67,23 @@ static void *darken_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) - calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = threads; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + filt->threads = threads; + filt->in_fmt = in_fmt; return filt; } static void darken_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width; + *out_width = width; *out_height = height; } @@ -104,14 +100,13 @@ static void darken_destroy(void *data) static void darken_work_cb_xrgb8888(void *data, void *thread_data) { + unsigned x, y; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - const uint32_t *input = (const uint32_t*)thr->in_data; - uint32_t *output = (uint32_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - - unsigned x, y; + const uint32_t *input = (const uint32_t*)thr->in_data; + uint32_t *output = (uint32_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; for (y = 0; y < height; y++, input += thr->in_pitch >> 2, output += thr->out_pitch >> 2) for (x = 0; x < width; x++) @@ -120,14 +115,13 @@ static void darken_work_cb_xrgb8888(void *data, void *thread_data) static void darken_work_cb_rgb565(void *data, void *thread_data) { + unsigned x, y; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - const uint16_t *input = (const uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - - unsigned x, y; + const uint16_t *input = (const uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; for (y = 0; y < height; y++, input += thr->in_pitch >> 1, output += thr->out_pitch >> 1) for (x = 0; x < width; x++) @@ -145,20 +139,21 @@ static void darken_packets(void *data, { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + + thr->out_data = (uint8_t*)output + y_start * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = darken_work_cb_xrgb8888; + packets[i].work = darken_work_cb_xrgb8888; else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = darken_work_cb_rgb565; - packets[i].thread_data = thr; + packets[i].work = darken_work_cb_rgb565; + packets[i].thread_data = thr; } } @@ -180,7 +175,6 @@ static const struct softfilter_implementation darken = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &darken; } diff --git a/gfx/video_filters/dot_matrix_3x.c b/gfx/video_filters/dot_matrix_3x.c index b4d7e5972b..19153ee0b3 100644 --- a/gfx/video_filters/dot_matrix_3x.c +++ b/gfx/video_filters/dot_matrix_3x.c @@ -87,9 +87,9 @@ static void dot_matrix_3x_initialize(struct filter_data *filt, /* Convert to RGB565 */ filt->grid_color.rgb565 = - (((grid_color >> 19) & 0x1F) << 11) | - (((grid_color >> 11) & 0x1F) << 6) | - ((grid_color >> 3) & 0x1F); + ( ((grid_color >> 19) & 0x1F) << 11) + | (((grid_color >> 11) & 0x1F) << 6) + | ((grid_color >> 3) & 0x1F); } static void *dot_matrix_3x_generic_create(const struct softfilter_config *config, @@ -103,16 +103,16 @@ static void *dot_matrix_3x_generic_create(const struct softfilter_config *config if (!filt) return NULL; - /* Apparently the code is not thread-safe, - * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(1, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; /* Initialise colour lookup tables */ dot_matrix_3x_initialize(filt, config, userdata); @@ -131,9 +131,8 @@ static void dot_matrix_3x_generic_output(void *data, static void dot_matrix_3x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -290,22 +289,22 @@ static void dot_matrix_3x_generic_packets(void *data, /* We are guaranteed single threaded operation * (filt->threads = 1) so we don't need to loop * over threads and can cull some code */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[0].work = dot_matrix_3x_work_cb_rgb565; + packets[0].work = dot_matrix_3x_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[0].work = dot_matrix_3x_work_cb_xrgb8888; + packets[0].work = dot_matrix_3x_work_cb_xrgb8888; - packets[0].thread_data = thr; + packets[0].thread_data = thr; } static const struct softfilter_implementation dot_matrix_3x_generic = { @@ -327,7 +326,6 @@ static const struct softfilter_implementation dot_matrix_3x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &dot_matrix_3x_generic; } diff --git a/gfx/video_filters/dot_matrix_4x.c b/gfx/video_filters/dot_matrix_4x.c index 803529cd9a..4ecc7271e2 100644 --- a/gfx/video_filters/dot_matrix_4x.c +++ b/gfx/video_filters/dot_matrix_4x.c @@ -50,10 +50,10 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; struct softfilter_thread_data *workers; + dot_matrix_4x_grid_color_t grid_color; /* uint32_t alignment */ + unsigned threads; unsigned in_fmt; - dot_matrix_4x_grid_color_t grid_color; }; static unsigned dot_matrix_4x_generic_input_fmts(void) @@ -87,9 +87,9 @@ static void dot_matrix_4x_initialize(struct filter_data *filt, /* Convert to RGB565 */ filt->grid_color.rgb565 = - (((grid_color >> 19) & 0x1F) << 11) | - (((grid_color >> 11) & 0x1F) << 6) | - ((grid_color >> 3) & 0x1F); + (((grid_color >> 19) & 0x1F) << 11) + | (((grid_color >> 11) & 0x1F) << 6) + | ((grid_color >> 3) & 0x1F); } static void *dot_matrix_4x_generic_create(const struct softfilter_config *config, @@ -98,21 +98,18 @@ static void *dot_matrix_4x_generic_create(const struct softfilter_config *config unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - if (!filt) return NULL; - - /* Apparently the code is not thread-safe, - * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(1, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; /* Initialise colour lookup tables */ dot_matrix_4x_initialize(filt, config, userdata); @@ -131,9 +128,8 @@ static void dot_matrix_4x_generic_output(void *data, static void dot_matrix_4x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -330,22 +326,22 @@ static void dot_matrix_4x_generic_packets(void *data, /* We are guaranteed single threaded operation * (filt->threads = 1) so we don't need to loop * over threads and can cull some code */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[0].work = dot_matrix_4x_work_cb_rgb565; + packets[0].work = dot_matrix_4x_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[0].work = dot_matrix_4x_work_cb_xrgb8888; + packets[0].work = dot_matrix_4x_work_cb_xrgb8888; - packets[0].thread_data = thr; + packets[0].thread_data = thr; } static const struct softfilter_implementation dot_matrix_4x_generic = { @@ -367,7 +363,6 @@ static const struct softfilter_implementation dot_matrix_4x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &dot_matrix_4x_generic; } diff --git a/gfx/video_filters/epx.c b/gfx/video_filters/epx.c index a2ddc0b4e2..20c4f3149a 100644 --- a/gfx/video_filters/epx.c +++ b/gfx/video_filters/epx.c @@ -70,20 +70,17 @@ static void *epx_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) + filt->workers = (struct softfilter_thread_data*) calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; if (!filt->workers) { free(filt); return NULL; } + filt->threads = 1; + filt->in_fmt = in_fmt; return filt; } @@ -91,7 +88,7 @@ static void epx_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width * EPX_SCALE; + *out_width = width * EPX_SCALE; *out_height = height * EPX_SCALE; } @@ -110,35 +107,32 @@ static void epx_generic_rgb565 (unsigned width, unsigned height, int first, int lsat, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { - uint16_t colorX, colorA, colorB, colorC, colorD; - uint16_t *sP, *uP, *lP; - uint32_t*dP1, *dP2; + uint16_t colorA; int w; for (; height; height--) { - sP = (uint16_t *) src; - uP = (uint16_t *) (src - src_stride); - lP = (uint16_t *) (src + src_stride); - dP1 = (uint32_t *) dst; - dP2 = (uint32_t *) (dst + dst_stride); + uint16_t *sP = (uint16_t *) src; + uint16_t *uP = (uint16_t *) (src - src_stride); + uint16_t *lP = (uint16_t *) (src + src_stride); + uint32_t *dP1 = (uint32_t *) dst; + uint32_t *dP2 = (uint32_t *) (dst + dst_stride); /* left edge */ - - colorX = *sP; - colorC = *++sP; - colorB = *lP++; - colorD = *uP++; + uint16_t colorX = *sP; + uint16_t colorC = *++sP; + uint16_t colorB = *lP++; + uint16_t colorD = *uP++; if ((colorX != colorC) && (colorB != colorD)) { - #ifdef MSB_FIRST +#ifdef MSB_FIRST *dP1 = (colorX << 16) + ((colorC == colorD) ? colorC : colorX); *dP2 = (colorX << 16) + ((colorB == colorC) ? colorB : colorX); - #else +#else *dP1 = colorX + (((colorC == colorD) ? colorC : colorX) << 16); *dP2 = colorX + (((colorB == colorC) ? colorB : colorX) << 16); - #endif +#endif } else *dP1 = *dP2 = (colorX << 16) + colorX; @@ -172,7 +166,6 @@ static void epx_generic_rgb565 (unsigned width, unsigned height, } /* right edge */ - colorA = colorX; colorX = colorC; colorB = *lP; @@ -200,10 +193,10 @@ static void epx_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; + unsigned width = thr->width; + unsigned height = thr->height; epx_generic_rgb565(width, height, thr->first, thr->last, input, @@ -225,19 +218,19 @@ static void epx_generic_packets(void *data, struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * EPX_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * EPX_SCALE * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can * access pixels outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) packets[i].work = epx_work_cb_rgb565; @@ -263,7 +256,6 @@ static const struct softfilter_implementation epx_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &epx_generic; } diff --git a/gfx/video_filters/gameboy3x.c b/gfx/video_filters/gameboy3x.c index c99ba6771d..d7e53c2f18 100644 --- a/gfx/video_filters/gameboy3x.c +++ b/gfx/video_filters/gameboy3x.c @@ -139,10 +139,10 @@ static void gameboy3x_initialize(struct filter_data *filt, filt->colors.xrgb8888.pixel_lut[i] = palette[i]; /* Populate grid lookup tables */ - grid_color = gameboy3x_get_grid_colour(palette[i], palette_grid); + grid_color = gameboy3x_get_grid_colour(palette[i], palette_grid); - filt->colors.rgb565.grid_lut[i] = GAMEBOY_3X_RGB24_TO_RGB565(grid_color); - filt->colors.xrgb8888.grid_lut[i] = grid_color; + filt->colors.rgb565.grid_lut[i] = GAMEBOY_3X_RGB24_TO_RGB565(grid_color); + filt->colors.xrgb8888.grid_lut[i] = grid_color; } } @@ -152,22 +152,19 @@ static void *gameboy3x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - if (!filt) return NULL; - - /* Apparently the code is not thread-safe, - * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; + /* Initialise colour lookup tables */ gameboy3x_initialize(filt, config, userdata); @@ -185,9 +182,8 @@ static void gameboy3x_generic_output(void *data, static void gameboy3x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -230,8 +226,8 @@ static void gameboy3x_work_cb_rgb565(void *data, void *thread_data) /* Convert to lookup table index * > This can never be greater than 3, * but check anyway... */ - lut_index = in_rgb_mean >> 3; - lut_index = (lut_index > 3) ? 3 : lut_index; + lut_index = in_rgb_mean >> 3; + lut_index = (lut_index > 3) ? 3 : lut_index; /* Get output pixel and grid colours */ out_pixel_color = *(pixel_lut + lut_index); @@ -307,8 +303,8 @@ static void gameboy3x_work_cb_xrgb8888(void *data, void *thread_data) /* Convert to lookup table index * > This can never be greater than 3, * but check anyway... */ - lut_index = in_rgb_mean >> 6; - lut_index = (lut_index > 3) ? 3 : lut_index; + lut_index = in_rgb_mean >> 6; + lut_index = (lut_index > 3) ? 3 : lut_index; /* Get output pixel and grid colours */ out_pixel_color = *(pixel_lut + lut_index); @@ -354,22 +350,22 @@ static void gameboy3x_generic_packets(void *data, /* We are guaranteed single threaded operation * (filt->threads = 1) so we don't need to loop * over threads and can cull some code */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[0].work = gameboy3x_work_cb_rgb565; + packets[0].work = gameboy3x_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[0].work = gameboy3x_work_cb_xrgb8888; + packets[0].work = gameboy3x_work_cb_xrgb8888; - packets[0].thread_data = thr; + packets[0].thread_data = thr; } static const struct softfilter_implementation gameboy3x_generic = { @@ -391,7 +387,6 @@ static const struct softfilter_implementation gameboy3x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &gameboy3x_generic; } diff --git a/gfx/video_filters/gameboy4x.c b/gfx/video_filters/gameboy4x.c index 501f247ebf..f65812f68f 100644 --- a/gfx/video_filters/gameboy4x.c +++ b/gfx/video_filters/gameboy4x.c @@ -170,21 +170,18 @@ static void *gameboy4x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - if (!filt) return NULL; - - /* Apparently the code is not thread-safe, - * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(1, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; /* Initialise colour lookup tables */ gameboy4x_initialize(filt, config, userdata); @@ -203,9 +200,8 @@ static void gameboy4x_generic_output(void *data, static void gameboy4x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -412,22 +408,22 @@ static void gameboy4x_generic_packets(void *data, /* We are guaranteed single threaded operation * (filt->threads = 1) so we don't need to loop * over threads and can cull some code */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[0].work = gameboy4x_work_cb_rgb565; + packets[0].work = gameboy4x_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[0].work = gameboy4x_work_cb_xrgb8888; + packets[0].work = gameboy4x_work_cb_xrgb8888; - packets[0].thread_data = thr; + packets[0].thread_data = thr; } static const struct softfilter_implementation gameboy4x_generic = { @@ -449,7 +445,6 @@ static const struct softfilter_implementation gameboy4x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &gameboy4x_generic; } diff --git a/gfx/video_filters/grid2x.c b/gfx/video_filters/grid2x.c index d065dda773..d155837f10 100644 --- a/gfx/video_filters/grid2x.c +++ b/gfx/video_filters/grid2x.c @@ -68,22 +68,17 @@ static void *grid2x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } + filt->threads = 1; + filt->in_fmt = in_fmt; return filt; } @@ -91,16 +86,15 @@ static void grid2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 1; + *out_width = width << 1; *out_height = height << 1; } static void grid2x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -127,7 +121,7 @@ static void grid2x_work_cb_xrgb8888(void *data, void *thread_data) uint32_t scanline_color = (color + (color & 0x1010101)) >> 1; /* > Second pass: 50:50 mix of color:(color:0) * => Gives ((1 + 0.5) / 2) = 0.75 */ - scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x1010101)) >> 1; + scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x1010101)) >> 1; /* c.f "Mixing Packed RGB Pixels Efficiently" * http://blargg.8bitalley.com/info/rgb_mixing.html */ @@ -171,7 +165,7 @@ static void grid2x_work_cb_rgb565(void *data, void *thread_data) uint16_t scanline_color = (color + (color & 0x821)) >> 1; /* > Second pass: 50:50 mix of color:(color:0) * => Gives ((1 + 0.5) / 2) = 0.75 */ - scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x821)) >> 1; + scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x821)) >> 1; /* c.f "Mixing Packed RGB Pixels Efficiently" * http://blargg.8bitalley.com/info/rgb_mixing.html */ @@ -203,22 +197,21 @@ static void grid2x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = grid2x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = grid2x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = grid2x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = grid2x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation grid2x_generic = { @@ -240,7 +233,6 @@ static const struct softfilter_implementation grid2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &grid2x_generic; } diff --git a/gfx/video_filters/grid3x.c b/gfx/video_filters/grid3x.c index 35246511f7..65fe1404fa 100644 --- a/gfx/video_filters/grid3x.c +++ b/gfx/video_filters/grid3x.c @@ -68,22 +68,17 @@ static void *grid3x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -98,9 +93,8 @@ static void grid3x_generic_output(void *data, static void grid3x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -127,7 +121,7 @@ static void grid3x_work_cb_xrgb8888(void *data, void *thread_data) uint32_t scanline_color = (color + (color & 0x1010101)) >> 1; /* > Second pass: 50:50 mix of color:(color:0) * => Gives ((1 + 0.5) / 2) = 0.75 */ - scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x1010101)) >> 1; + scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x1010101)) >> 1; /* c.f "Mixing Packed RGB Pixels Efficiently" * http://blargg.8bitalley.com/info/rgb_mixing.html */ @@ -179,7 +173,7 @@ static void grid3x_work_cb_rgb565(void *data, void *thread_data) uint16_t scanline_color = (color + (color & 0x821)) >> 1; /* > Second pass: 50:50 mix of color:(color:0) * => Gives ((1 + 0.5) / 2) = 0.75 */ - scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x821)) >> 1; + scanline_color = (color + scanline_color + ((color ^ scanline_color) & 0x821)) >> 1; /* c.f "Mixing Packed RGB Pixels Efficiently" * http://blargg.8bitalley.com/info/rgb_mixing.html */ @@ -219,21 +213,20 @@ static void grid3x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) packets[0].work = grid3x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) packets[0].work = grid3x_work_cb_rgb565; - } packets[0].thread_data = thr; } @@ -256,7 +249,6 @@ static const struct softfilter_implementation grid3x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &grid3x_generic; } diff --git a/gfx/video_filters/lq2x.c b/gfx/video_filters/lq2x.c index f406b3d8ab..8b92df37ff 100644 --- a/gfx/video_filters/lq2x.c +++ b/gfx/video_filters/lq2x.c @@ -67,20 +67,18 @@ static void *lq2x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) - calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; return filt; } @@ -88,7 +86,7 @@ static void lq2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width * LQ2X_SCALE; + *out_width = width * LQ2X_SCALE; *out_height = height * LQ2X_SCALE; } @@ -195,11 +193,10 @@ static void lq2x_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; lq2x_generic_rgb565(width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), @@ -211,13 +208,10 @@ static void lq2x_work_cb_xrgb8888(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint32_t *input = (uint32_t*)thr->in_data; - uint32_t *output = (uint32_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - - (void)data; - + uint32_t *input = (uint32_t*)thr->in_data; + uint32_t *output = (uint32_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; lq2x_generic_xrgb8888(width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), @@ -238,28 +232,28 @@ static void lq2x_generic_packets(void *data, struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * LQ2X_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * LQ2X_SCALE * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can access pixels * outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = lq2x_work_cb_rgb565; + packets[i].work = lq2x_work_cb_rgb565; #if 0 else if (filt->in_fmt == SOFTFILTER_FMT_RGB4444) packets[i].work = lq2x_work_cb_rgb4444; #endif else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = lq2x_work_cb_xrgb8888; + packets[i].work = lq2x_work_cb_xrgb8888; packets[i].thread_data = thr; } } @@ -282,7 +276,6 @@ static const struct softfilter_implementation lq2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &lq2x_generic; } diff --git a/gfx/video_filters/normal2x.c b/gfx/video_filters/normal2x.c index e6f3f77b8a..9f7bf447aa 100644 --- a/gfx/video_filters/normal2x.c +++ b/gfx/video_filters/normal2x.c @@ -68,22 +68,17 @@ static void *normal2x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void normal2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 1; + *out_width = width << 1; *out_height = height << 1; } static void normal2x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -119,16 +113,16 @@ static void normal2x_work_cb_xrgb8888(void *data, void *thread_data) uint32_t *out_ptr = output; for (x = 0; x < thr->width; ++x) { + uint32_t row_color[2]; uint32_t *out_line_ptr = out_ptr; uint32_t color = *(input + x); - uint32_t row_color[2]; - row_color[0] = color; - row_color[1] = color; + row_color[0] = color; + row_color[1] = color; /* Row 1 */ memcpy(out_line_ptr, row_color, sizeof(row_color)); - out_line_ptr += out_stride; + out_line_ptr += out_stride; /* Row 2 */ memcpy(out_line_ptr, row_color, sizeof(row_color)); @@ -155,25 +149,25 @@ static void normal2x_work_cb_rgb565(void *data, void *thread_data) uint16_t *out_ptr = output; for (x = 0; x < thr->width; ++x) { + uint16_t row_color[2]; uint16_t *out_line_ptr = out_ptr; uint16_t color = *(input + x); - uint16_t row_color[2]; - row_color[0] = color; - row_color[1] = color; + row_color[0] = color; + row_color[1] = color; /* Row 1 */ memcpy(out_line_ptr, row_color, sizeof(row_color)); - out_line_ptr += out_stride; + out_line_ptr += out_stride; /* Row 2 */ memcpy(out_line_ptr, row_color, sizeof(row_color)); - out_ptr += 2; + out_ptr += 2; } - input += in_stride; - output += out_stride << 1; + input += in_stride; + output += out_stride << 1; } } @@ -187,22 +181,21 @@ static void normal2x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = normal2x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = normal2x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = normal2x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = normal2x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation normal2x_generic = { @@ -224,7 +217,6 @@ static const struct softfilter_implementation normal2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &normal2x_generic; } diff --git a/gfx/video_filters/normal2x_height.c b/gfx/video_filters/normal2x_height.c index aae59ffe27..e230ab4d1c 100644 --- a/gfx/video_filters/normal2x_height.c +++ b/gfx/video_filters/normal2x_height.c @@ -68,22 +68,17 @@ static void *normal2x_height_generic_create(const struct softfilter_config *conf unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void normal2x_height_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width; + *out_width = width; *out_height = height << 1; } static void normal2x_height_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -171,22 +165,21 @@ static void normal2x_height_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = normal2x_height_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = normal2x_height_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = normal2x_height_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = normal2x_height_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation normal2x_height_generic = { @@ -208,7 +201,6 @@ static const struct softfilter_implementation normal2x_height_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &normal2x_height_generic; } diff --git a/gfx/video_filters/normal2x_width.c b/gfx/video_filters/normal2x_width.c index 7a8a232113..084253d02b 100644 --- a/gfx/video_filters/normal2x_width.c +++ b/gfx/video_filters/normal2x_width.c @@ -41,8 +41,8 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; struct softfilter_thread_data *workers; + unsigned threads; unsigned in_fmt; }; @@ -68,22 +68,17 @@ static void *normal2x_width_generic_create(const struct softfilter_config *confi unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void normal2x_width_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 1; + *out_width = width << 1; *out_height = height; } static void normal2x_width_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -173,22 +167,21 @@ static void normal2x_width_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = normal2x_width_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = normal2x_width_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = normal2x_width_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = normal2x_width_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation normal2x_width_generic = { @@ -210,7 +203,6 @@ static const struct softfilter_implementation normal2x_width_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &normal2x_width_generic; } diff --git a/gfx/video_filters/normal4x.c b/gfx/video_filters/normal4x.c index 63750e5ebc..c0af01478e 100644 --- a/gfx/video_filters/normal4x.c +++ b/gfx/video_filters/normal4x.c @@ -68,22 +68,17 @@ static void *normal4x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void normal4x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 2; + *out_width = width << 2; *out_height = height << 2; } static void normal4x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -165,9 +159,9 @@ static void normal4x_work_cb_rgb565(void *data, void *thread_data) uint16_t *out_ptr = output; for (x = 0; x < thr->width; ++x) { + uint16_t row_color[4]; uint16_t *out_line_ptr = out_ptr; uint16_t color = *(input + x); - uint16_t row_color[4]; row_color[0] = color; row_color[1] = color; @@ -207,22 +201,21 @@ static void normal4x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = normal4x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = normal4x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = normal4x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = normal4x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation normal4x_generic = { @@ -244,7 +237,6 @@ static const struct softfilter_implementation normal4x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &normal4x_generic; } diff --git a/gfx/video_filters/phosphor2x.c b/gfx/video_filters/phosphor2x.c index 3fc84906c3..662ffbe799 100644 --- a/gfx/video_filters/phosphor2x.c +++ b/gfx/video_filters/phosphor2x.c @@ -44,8 +44,8 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; struct softfilter_thread_data *workers; + unsigned threads; unsigned in_fmt; float phosphor_bleed; float scale_add; @@ -234,30 +234,23 @@ static void *phosphor2x_generic_create(const struct softfilter_config *config, { unsigned i; struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - - (void)simd; - (void)out_fmt; - (void)max_width; - (void)max_height; - (void)config; - (void)userdata; - if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*) - calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*) + calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; filt->phosphor_bleed = 0.78; - filt->scale_add = 1.0; - filt->scale_times = 0.8; - filt->scanrange_low = 0.5; + filt->scale_add = 1.0; + filt->scale_times = 0.8; + filt->scanrange_low = 0.5; filt->scanrange_high = 0.65; #if 0 @@ -271,7 +264,7 @@ static void *phosphor2x_generic_create(const struct softfilter_config *config, filt->phosphor_bloom_8888[i] = filt->scale_times * powf((float)i / 255.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_8888[i] = + filt->scan_range_8888[i] = filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 255.0f; } @@ -280,7 +273,7 @@ static void *phosphor2x_generic_create(const struct softfilter_config *config, filt->phosphor_bloom_565[i] = filt->scale_times * powf((float)i / 31.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_565[i] = + filt->scan_range_565[i] = filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 31.0f; } @@ -292,8 +285,7 @@ static void phosphor2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - (void)data; - *out_width = width * PHOSPHOR2X_SCALE; + *out_width = width * PHOSPHOR2X_SCALE; *out_height = height * PHOSPHOR2X_SCALE; } @@ -316,9 +308,6 @@ static void phosphor2x_generic_xrgb8888(void *data, unsigned y; struct filter_data *filt = (struct filter_data*)data; - (void)first; - (void)last; - memset(dst, 0, height * dst_stride); for (y = 0; y < height; y++) @@ -364,9 +353,6 @@ static void phosphor2x_generic_rgb565(void *data, unsigned y; struct filter_data *filt = (struct filter_data*)data; - (void)first; - (void)last; - memset(dst, 0, height * dst_stride); for (y = 0; y < height; y++) @@ -410,7 +396,6 @@ static void phosphor2x_work_cb_xrgb8888(void *data, void *thread_data) uint32_t *output = (uint32_t*)thr->out_data; unsigned width = thr->width; unsigned height = thr->height; - phosphor2x_generic_xrgb8888(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), @@ -422,11 +407,10 @@ static void phosphor2x_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; phosphor2x_generic_rgb565(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), @@ -446,28 +430,28 @@ static void phosphor2x_generic_packets(void *data, struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * PHOSPHOR2X_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * PHOSPHOR2X_SCALE * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can access pixels * outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = phosphor2x_work_cb_rgb565; + packets[i].work = phosphor2x_work_cb_rgb565; #if 0 else if (filt->in_fmt == SOFTFILTER_FMT_RGB4444) - packets[i].work = phosphor2x_work_cb_rgb4444; + packets[i].work = phosphor2x_work_cb_rgb4444; #endif if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = phosphor2x_work_cb_xrgb8888; + packets[i].work = phosphor2x_work_cb_xrgb8888; packets[i].thread_data = thr; } } @@ -490,7 +474,6 @@ static const struct softfilter_implementation phosphor2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &phosphor2x_generic; } diff --git a/gfx/video_filters/picoscale_256x_320x240.c b/gfx/video_filters/picoscale_256x_320x240.c index de16fdc3df..65c0831738 100644 --- a/gfx/video_filters/picoscale_256x_320x240.c +++ b/gfx/video_filters/picoscale_256x_320x240.c @@ -63,10 +63,10 @@ struct softfilter_thread_data struct filter_data { - unsigned threads; - struct softfilter_thread_data *workers; - unsigned in_fmt; picoscale_functions_t functions; + struct softfilter_thread_data *workers; + unsigned threads; + unsigned in_fmt; }; /******************************************************************* @@ -391,16 +391,15 @@ static void *picoscale_256x_320x240_generic_create(const struct softfilter_confi struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); if (!filt) return NULL; - /* Apparently the code is not thread-safe, - * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; /* Assign scaling functions */ picoscale_256x_320x240_initialize(filt, config, userdata); @@ -507,16 +506,17 @@ static void picoscale_256x_320x240_generic_packets(void *data, struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; + /* TODO/FIXME - no XRGB8888 codepath? */ if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[0].work = picoscale_256x_320x240_work_cb_rgb565; - packets[0].thread_data = thr; + packets[0].work = picoscale_256x_320x240_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation picoscale_256x_320x240_generic = { @@ -538,7 +538,6 @@ static const struct softfilter_implementation picoscale_256x_320x240_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &picoscale_256x_320x240_generic; } diff --git a/gfx/video_filters/scale2x.c b/gfx/video_filters/scale2x.c index ecba9d35a8..fdb4fd2778 100644 --- a/gfx/video_filters/scale2x.c +++ b/gfx/video_filters/scale2x.c @@ -68,22 +68,17 @@ static void *scale2x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void scale2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 1; + *out_width = width << 1; *out_height = height << 1; } static void scale2x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -211,22 +205,21 @@ static void scale2x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = scale2x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = scale2x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = scale2x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = scale2x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation scale2x_generic = { @@ -248,7 +241,6 @@ static const struct softfilter_implementation scale2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &scale2x_generic; } diff --git a/gfx/video_filters/scanline2x.c b/gfx/video_filters/scanline2x.c index 675ec68f12..74d4fd716b 100644 --- a/gfx/video_filters/scanline2x.c +++ b/gfx/video_filters/scanline2x.c @@ -68,22 +68,17 @@ static void *scanline2x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -91,16 +86,15 @@ static void scanline2x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width << 1; + *out_width = width << 1; *out_height = height << 1; } static void scanline2x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -203,22 +197,21 @@ static void scanline2x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = scanline2x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = scanline2x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = scanline2x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = scanline2x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation scanline2x_generic = { @@ -240,7 +233,6 @@ static const struct softfilter_implementation scanline2x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &scanline2x_generic; } diff --git a/gfx/video_filters/super2xsai.c b/gfx/video_filters/super2xsai.c index 0b57398259..e05add6103 100644 --- a/gfx/video_filters/super2xsai.c +++ b/gfx/video_filters/super2xsai.c @@ -72,26 +72,23 @@ static void *supertwoxsai_generic_create(const struct softfilter_config *config, if (!filt) return NULL; - (void)simd; - (void)config; - (void)userdata; - - filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + /* Apparently the code is not thread-safe, + * so force single threaded operation... */ + filt->threads = 1; + filt->in_fmt = in_fmt; + return filt; } static void supertwoxsai_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width * SUPERTWOXSAI_SCALE; + *out_width = width * SUPERTWOXSAI_SCALE; *out_height = height * SUPERTWOXSAI_SCALE; } @@ -265,11 +262,10 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, static void supertwoxsai_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; - uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *output = (uint16_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; supertwoxsai_generic_rgb565(width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), @@ -280,16 +276,15 @@ static void supertwoxsai_work_cb_rgb565(void *data, void *thread_data) static void supertwoxsai_work_cb_xrgb8888(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint32_t *input = (uint32_t*)thr->in_data; - uint32_t *output = (uint32_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; - + uint32_t *input = (uint32_t*)thr->in_data; + uint32_t *output = (uint32_t*)thr->out_data; + unsigned width = thr->width; + unsigned height = thr->height; supertwoxsai_generic_xrgb8888(width, height, thr->first, thr->last, input, - (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), - output, - (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); + (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), + output, + (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); } static void supertwoxsai_generic_packets(void *data, @@ -304,24 +299,24 @@ static void supertwoxsai_generic_packets(void *data, { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * SUPERTWOXSAI_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * SUPERTWOXSAI_SCALE * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can access pixels * outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = supertwoxsai_work_cb_rgb565; + packets[i].work = supertwoxsai_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = supertwoxsai_work_cb_xrgb8888; + packets[i].work = supertwoxsai_work_cb_xrgb8888; packets[i].thread_data = thr; } } @@ -343,7 +338,6 @@ static const struct softfilter_implementation supertwoxsai_generic = { const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd) { - (void)simd; return &supertwoxsai_generic; } diff --git a/gfx/video_filters/supereagle.c b/gfx/video_filters/supereagle.c index a191d104c3..a33830b9cc 100644 --- a/gfx/video_filters/supereagle.c +++ b/gfx/video_filters/supereagle.c @@ -69,26 +69,22 @@ static void *supereagle_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; if (!filt) return NULL; - filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)); - filt->threads = 1; - filt->in_fmt = in_fmt; - if (!filt->workers) + if (!(filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)))) { free(filt); return NULL; } + filt->threads = 1; + filt->in_fmt = in_fmt; return filt; } static void supereagle_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - *out_width = width * SUPEREAGLE_SCALE; + *out_width = width * SUPEREAGLE_SCALE; *out_height = height * SUPEREAGLE_SCALE; } @@ -229,7 +225,6 @@ static void supereagle_generic_xrgb8888(unsigned width, unsigned height, for (finish = width; finish; finish -= 1) { supereagle_declare_variables(uint32_t, in, nextline); - supereagle_function(supereagle_result, supereagle_interpolate_xrgb8888, supereagle_interpolate2_xrgb8888); } @@ -253,7 +248,6 @@ static void supereagle_generic_rgb565(unsigned width, unsigned height, for (finish = width; finish; finish -= 1) { supereagle_declare_variables(uint16_t, in, nextline); - supereagle_function(supereagle_result, supereagle_interpolate_rgb565, supereagle_interpolate2_rgb565); } @@ -265,31 +259,31 @@ static void supereagle_generic_rgb565(unsigned width, unsigned height, static void supereagle_work_cb_rgb565(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint16_t *input = (uint16_t*)thr->in_data; + uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; + unsigned width = thr->width; + unsigned height = thr->height; supereagle_generic_rgb565(width, height, thr->first, thr->last, input, - (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), - output, - (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); + (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), + output, + (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); } static void supereagle_work_cb_xrgb8888(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; - uint32_t *input = (uint32_t*)thr->in_data; + uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; - unsigned width = thr->width; - unsigned height = thr->height; + unsigned width = thr->width; + unsigned height = thr->height; supereagle_generic_xrgb8888(width, height, thr->first, thr->last, input, - (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), - output, - (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); + (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), + output, + (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); } static void supereagle_generic_packets(void *data, @@ -304,23 +298,23 @@ static void supereagle_generic_packets(void *data, { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - unsigned y_start = (height * i) / filt->threads; - unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * SUPEREAGLE_SCALE * output_stride; - thr->in_data = (const uint8_t*)input + y_start * input_stride; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = y_end - y_start; + unsigned y_start = (height * i) / filt->threads; + unsigned y_end = (height * (i + 1)) / filt->threads; + thr->out_data = (uint8_t*)output + y_start * SUPEREAGLE_SCALE * output_stride; + thr->in_data = (const uint8_t*)input + y_start * input_stride; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = y_end - y_start; /* Workers need to know if they can access pixels outside their given buffer. */ - thr->first = y_start; - thr->last = y_end == height; + thr->first = y_start; + thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = supereagle_work_cb_rgb565; + packets[i].work = supereagle_work_cb_rgb565; else if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = supereagle_work_cb_xrgb8888; + packets[i].work = supereagle_work_cb_xrgb8888; packets[i].thread_data = thr; } } @@ -342,7 +336,6 @@ static const struct softfilter_implementation supereagle_generic = { const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd) { - (void)simd; return &supereagle_generic; } diff --git a/gfx/video_filters/upscale_1_5x.c b/gfx/video_filters/upscale_1_5x.c index 3527e5176f..aac9d4d88a 100644 --- a/gfx/video_filters/upscale_1_5x.c +++ b/gfx/video_filters/upscale_1_5x.c @@ -68,22 +68,17 @@ static void *upscale_1_5x_generic_create(const struct softfilter_config *config, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -98,9 +93,8 @@ static void upscale_1_5x_generic_output(void *data, static void upscale_1_5x_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -139,34 +133,34 @@ static void upscale_1_5x_work_cb_xrgb8888(void *data, void *thread_data) const uint32_t *in_line_ptr = input + (x << 1); uint32_t *out_line_ptr = out_ptr; - color_a = *in_line_ptr; - color_b = *(in_line_ptr + 1); - in_line_ptr += in_stride; + color_a = *in_line_ptr; + color_b = *(in_line_ptr + 1); + in_line_ptr += in_stride; - color_c = *in_line_ptr; - color_d = *(in_line_ptr + 1); + color_c = *in_line_ptr; + color_d = *(in_line_ptr + 1); - color_ab = (color_a + color_b + ((color_a ^ color_b) & 0x1010101)) >> 1; - color_cd = (color_c + color_d + ((color_c ^ color_d) & 0x1010101)) >> 1; + color_ab = (color_a + color_b + ((color_a ^ color_b) & 0x1010101)) >> 1; + color_cd = (color_c + color_d + ((color_c ^ color_d) & 0x1010101)) >> 1; /* Row 1 */ - *out_line_ptr = color_a; - *(out_line_ptr + 1) = color_ab; - *(out_line_ptr + 2) = color_b; - out_line_ptr += out_stride; + *out_line_ptr = color_a; + *(out_line_ptr + 1) = color_ab; + *(out_line_ptr + 2) = color_b; + out_line_ptr += out_stride; /* Row 2 */ - *out_line_ptr = (color_a + color_c + ((color_a ^ color_c) & 0x1010101)) >> 1; - *(out_line_ptr + 1) = (color_ab + color_cd + ((color_ab ^ color_cd) & 0x1010101)) >> 1; - *(out_line_ptr + 2) = (color_b + color_d + ((color_b ^ color_d) & 0x1010101)) >> 1; - out_line_ptr += out_stride; + *out_line_ptr = (color_a + color_c + ((color_a ^ color_c) & 0x1010101)) >> 1; + *(out_line_ptr + 1) = (color_ab + color_cd + ((color_ab ^ color_cd) & 0x1010101)) >> 1; + *(out_line_ptr + 2) = (color_b + color_d + ((color_b ^ color_d) & 0x1010101)) >> 1; + out_line_ptr += out_stride; /* Row 3 */ - *out_line_ptr = color_c; - *(out_line_ptr + 1) = color_cd; - *(out_line_ptr + 2) = color_d; + *out_line_ptr = color_c; + *(out_line_ptr + 1) = color_cd; + *(out_line_ptr + 2) = color_d; - out_ptr += 3; + out_ptr += 3; } input += in_stride << 1; @@ -253,22 +247,21 @@ static void upscale_1_5x_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) { - packets[0].work = upscale_1_5x_work_cb_xrgb8888; - } else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = upscale_1_5x_work_cb_rgb565; - } - packets[0].thread_data = thr; + if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) + packets[0].work = upscale_1_5x_work_cb_xrgb8888; + else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = upscale_1_5x_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation upscale_1_5x_generic = { @@ -290,7 +283,6 @@ static const struct softfilter_implementation upscale_1_5x_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &upscale_1_5x_generic; } diff --git a/gfx/video_filters/upscale_240x160_320x240.c b/gfx/video_filters/upscale_240x160_320x240.c index 57f8c05fa4..633803005a 100644 --- a/gfx/video_filters/upscale_240x160_320x240.c +++ b/gfx/video_filters/upscale_240x160_320x240.c @@ -333,22 +333,17 @@ static void *upscale_240x160_320x240_generic_create(const struct softfilter_conf unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } /* Assign scaling functions */ upscale_240x160_320x240_initialize(filt, config, userdata); @@ -375,9 +370,8 @@ static void upscale_240x160_320x240_generic_output(void *data, static void upscale_240x160_320x240_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -429,20 +423,20 @@ static void upscale_240x160_320x240_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = upscale_240x160_320x240_work_cb_rgb565; - } - packets[0].thread_data = thr; + /* TODO/FIXME - no XRGB8888 codepath? */ + if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = upscale_240x160_320x240_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation upscale_240x160_320x240_generic = { @@ -464,7 +458,6 @@ static const struct softfilter_implementation upscale_240x160_320x240_generic = const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &upscale_240x160_320x240_generic; } diff --git a/gfx/video_filters/upscale_256x_320x240.c b/gfx/video_filters/upscale_256x_320x240.c index 49ce86932f..7dfcd14af7 100644 --- a/gfx/video_filters/upscale_256x_320x240.c +++ b/gfx/video_filters/upscale_256x_320x240.c @@ -574,22 +574,17 @@ static void *upscale_256x_320x240_generic_create(const struct softfilter_config unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } return filt; } @@ -613,9 +608,8 @@ static void upscale_256x_320x240_generic_output(void *data, static void upscale_256x_320x240_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -679,20 +673,20 @@ static void upscale_256x_320x240_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = upscale_256x_320x240_work_cb_rgb565; - } - packets[0].thread_data = thr; + /* TODO/FIXME - no XRGB8888 codepath? */ + if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = upscale_256x_320x240_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation upscale_256x_320x240_generic = { @@ -714,7 +708,6 @@ static const struct softfilter_implementation upscale_256x_320x240_generic = { const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &upscale_256x_320x240_generic; } diff --git a/gfx/video_filters/upscale_mix_240x160_320x240.c b/gfx/video_filters/upscale_mix_240x160_320x240.c index a0a584262b..0c95c926d6 100644 --- a/gfx/video_filters/upscale_mix_240x160_320x240.c +++ b/gfx/video_filters/upscale_mix_240x160_320x240.c @@ -89,18 +89,14 @@ void upscale_mix_240x160_to_320x240(uint16_t *dst, const uint16_t *src, for (block_x = 0; block_x < 80; block_x++) { - const uint16_t *block_src_ptr = block_src; - uint16_t *block_dst_ptr = block_dst; - - uint16_t _1, _2, _3, - _4, _5, _6; - + uint16_t _4, _5, _6; uint16_t _1_2_weight_1_3; uint16_t _2_3_weight_1_1; uint16_t _4_5_weight_1_3; uint16_t _5_6_weight_1_1; - uint16_t tmp; + const uint16_t *block_src_ptr = block_src; + uint16_t *block_dst_ptr = block_dst; /* Horizontally: * Before(3): @@ -116,9 +112,9 @@ void upscale_mix_240x160_to_320x240(uint16_t *dst, const uint16_t *src, */ /* -- Row 1 -- */ - _1 = *(block_src_ptr ); - _2 = *(block_src_ptr + 1); - _3 = *(block_src_ptr + 2); + uint16_t _1 = *(block_src_ptr ); + uint16_t _2 = *(block_src_ptr + 1); + uint16_t _3 = *(block_src_ptr + 2); *(block_dst_ptr ) = _1; UPSCALE_240__WEIGHT_1_3(_1, _2, block_dst_ptr + 1, tmp); @@ -277,12 +273,10 @@ void upscale_mix_240x160_to_320x240_aspect(uint16_t *dst, const uint16_t *src, for (block_x = 0; block_x < 80; block_x++) { + uint16_t tmp; const uint16_t *block_src_ptr = block_src; uint16_t *block_dst_ptr = block_dst; - uint16_t _1, _2, _3; - uint16_t tmp; - /* Horizontally: * Before(3): * (a)(b)(c) @@ -291,17 +285,17 @@ void upscale_mix_240x160_to_320x240_aspect(uint16_t *dst, const uint16_t *src, */ /* -- Row 1 -- */ - _1 = *(block_src_ptr ); - _2 = *(block_src_ptr + 1); - _3 = *(block_src_ptr + 2); + uint16_t _1 = *(block_src_ptr ); + uint16_t _2 = *(block_src_ptr + 1); + uint16_t _3 = *(block_src_ptr + 2); *(block_dst_ptr ) = _1; UPSCALE_240__WEIGHT_1_3(_1, _2, block_dst_ptr + 1, tmp); UPSCALE_240__WEIGHT_1_1(_2, _3, block_dst_ptr + 2, tmp); *(block_dst_ptr + 3) = _3; - block_src += 3; - block_dst += 4; + block_src += 3; + block_dst += 4; } /* Letterboxing - zero out last 14 rows */ @@ -337,8 +331,7 @@ static void upscale_mix_240x160_320x240_initialize(struct filter_data *filt, filt->function.upscale_mix_240x160_320x240 = upscale_mix_240x160_to_320x240_aspect; /* Read aspect ratio correction setting */ - if (config->get_int(userdata, "keep_aspect", &keep_aspect, 1) && - !keep_aspect) + if (config->get_int(userdata, "keep_aspect", &keep_aspect, 1) && !keep_aspect) filt->function.upscale_mix_240x160_320x240 = upscale_mix_240x160_to_320x240; } @@ -348,23 +341,17 @@ static void *upscale_mix_240x160_320x240_generic_create(const struct softfilter_ unsigned threads, softfilter_simd_mask_t simd, void *userdata) { struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - (void)simd; - (void)config; - (void)userdata; - - if (!filt) { + if (!filt) + return NULL; + if (!(filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)))) + { + free(filt); return NULL; } /* Apparently the code is not thread-safe, * so force single threaded operation... */ - filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; - if (!filt->workers) { - free(filt); - return NULL; - } - /* Assign scaling functions */ upscale_mix_240x160_320x240_initialize(filt, config, userdata); @@ -390,9 +377,8 @@ static void upscale_mix_240x160_320x240_generic_output(void *data, static void upscale_mix_240x160_320x240_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if (!filt) { + if (!filt) return; - } free(filt->workers); free(filt); } @@ -444,20 +430,20 @@ static void upscale_mix_240x160_320x240_generic_packets(void *data, * over threads and can cull some code. This only * makes the tiniest performance difference, but * every little helps when running on an o3DS... */ - struct filter_data *filt = (struct filter_data*)data; + struct filter_data *filt = (struct filter_data*)data; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0]; - thr->out_data = (uint8_t*)output; - thr->in_data = (const uint8_t*)input; - thr->out_pitch = output_stride; - thr->in_pitch = input_stride; - thr->width = width; - thr->height = height; + thr->out_data = (uint8_t*)output; + thr->in_data = (const uint8_t*)input; + thr->out_pitch = output_stride; + thr->in_pitch = input_stride; + thr->width = width; + thr->height = height; - if (filt->in_fmt == SOFTFILTER_FMT_RGB565) { - packets[0].work = upscale_mix_240x160_320x240_work_cb_rgb565; - } - packets[0].thread_data = thr; + /* TODO/FIXME - no XRGB8888 codepath? */ + if (filt->in_fmt == SOFTFILTER_FMT_RGB565) + packets[0].work = upscale_mix_240x160_320x240_work_cb_rgb565; + packets[0].thread_data = thr; } static const struct softfilter_implementation upscale_mix_240x160_320x240_generic = { @@ -479,7 +465,6 @@ static const struct softfilter_implementation upscale_mix_240x160_320x240_generi const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { - (void)simd; return &upscale_mix_240x160_320x240_generic; } diff --git a/gfx/video_layout/scope.c b/gfx/video_layout/scope.c index a37fa5f88b..bb1b19c0ff 100644 --- a/gfx/video_layout/scope.c +++ b/gfx/video_layout/scope.c @@ -134,7 +134,7 @@ void scope_repeat(scope_t *scope) else { gen->value.val_int += gen->increment.val_int; - if(gen->shift > 0) + if (gen->shift > 0) gen->value.val_int <<= gen->shift; else if (gen->shift < 0) gen->value.val_int >>= -gen->shift; diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index d56e7ee455..b9e201e4fe 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -92,7 +92,7 @@ static void hidpad_retrode_get_buttons(void *pad_data, input_bits_t *state) retrode_pad_data_t *pad = (retrode_pad_data_t *)pad_data; if (pad) { - if(pad->datatype == RETRODE_TYPE_PAD) + if (pad->datatype == RETRODE_TYPE_PAD) { BITS_COPY16_PTR(state, pad->buttons); } @@ -117,7 +117,7 @@ static int16_t hidpad_retrode_get_axis(void *pad_data, unsigned axis) if (!pad || axis >= 2) return 0; - if(pad->datatype == RETRODE_TYPE_PAD) + if (pad->datatype == RETRODE_TYPE_PAD) val = pad->data[2 + axis]; else val = device->pad_data[0].data[2 + axis]; @@ -228,7 +228,7 @@ static void *hidpad_retrode_pad_init(void *device_data, int pad_index, joypad_co { retrode_device_data_t *device = (retrode_device_data_t *)device_data; - if(!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD || !joypad || device->pad_data[pad_index].joypad) + if (!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD || !joypad || device->pad_data[pad_index].joypad) return NULL; device->pad_data[pad_index].joypad = joypad; @@ -238,11 +238,8 @@ static void *hidpad_retrode_pad_init(void *device_data, int pad_index, joypad_co static void hidpad_retrode_pad_deinit(void *pad_data) { retrode_pad_data_t *pad = (retrode_pad_data_t *)pad_data; - - if(!pad) - return; - - pad->joypad = NULL; + if (pad) + pad->joypad = NULL; } static int8_t hidpad_retrode_status(void *device_data, int pad_index) @@ -250,7 +247,7 @@ static int8_t hidpad_retrode_status(void *device_data, int pad_index) retrode_device_data_t *device = (retrode_device_data_t *)device_data; int8_t result = 0; - if(!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD) + if (!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD) return 0; result |= PAD_CONNECT_READY; @@ -265,7 +262,7 @@ static joypad_connection_t *hidpad_retrode_joypad(void *device_data, int pad_ind { retrode_device_data_t *device = (retrode_device_data_t *)device_data; - if(!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD) + if (!device || pad_index < 0 || pad_index >= RETRODE_MAX_PAD) return 0; return device->pad_data[pad_index].joypad; } diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index d91d7054bb..1de05ab535 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -420,8 +420,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, /* estamos haciendo handshake o bien se necesita iniciar un * nuevo handshake ya que se inserta(quita una expansion. */ int attachment = 0; - - if(event != WM_RPT_CTRL_STATUS) + if (event != WM_RPT_CTRL_STATUS) return 0; /* Is an attachment connected to @@ -440,7 +439,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, /* Send the initialization code for the attachment */ - if(WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE_COMPLETE)) + if (WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE_COMPLETE)) { /* Rehandshake. */ @@ -481,7 +480,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP); wm->exp.type = EXP_NONE; - if(WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE_COMPLETE)) + if (WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE_COMPLETE)) { WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE); /* forzamos un handshake por si venimos @@ -490,7 +489,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, } } - if(!attachment && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE)) + if (!attachment && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE)) { wm->handshake_state = 2; continue; @@ -536,7 +535,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, } return 0; case 5: - if(event != WM_RPT_READ) + if (event != WM_RPT_READ) return 0; wiimote_classic_ctrl_handshake(wm, &wm->exp.cc.classic, data,len); diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index a5c48e72f7..f65f4c93ca 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -108,7 +108,7 @@ static void hidpad_wiiugca_get_buttons(void *pad_data, input_bits_t *state) gca_pad_data_t *pad = (gca_pad_data_t *)pad_data; if (pad) { - if(pad->datatype == GCA_TYPE_PAD) + if (pad->datatype == GCA_TYPE_PAD) { BITS_COPY16_PTR(state, pad->buttons); } @@ -134,10 +134,8 @@ static int16_t hidpad_wiiugca_get_axis(void *pad_data, unsigned axis) if (!pad || axis_data.axis >= 4) return 0; - - if(pad->datatype == GCA_TYPE_PAD) + if (pad->datatype == GCA_TYPE_PAD) return gamepad_get_axis_value(pad->analog, &axis_data); - return gamepad_get_axis_value(device->pad_data[0].analog, &axis_data); } @@ -244,7 +242,7 @@ static void hidpad_wiiugca_set_rumble(void *data, const char *hidpad_wiiugca_get_name(void *pad_data) { gca_pad_data_t *pad = (gca_pad_data_t *)pad_data; - if(!pad || pad->datatype != GCA_TYPE_PAD) + if (!pad || pad->datatype != GCA_TYPE_PAD) return DEVICE_NAME; switch(pad->device_data->connected[pad->pad_index]) @@ -284,7 +282,7 @@ static void *hidpad_wiiugca_pad_init(void *device_data, int pad_index, joypad_co { gca_device_data_t *device = (gca_device_data_t *)device_data; - if(!device || pad_index < 0 || pad_index >= GCA_MAX_PAD || !joypad || device->pad_data[pad_index].joypad || !device->connected[pad_index]) + if (!device || pad_index < 0 || pad_index >= GCA_MAX_PAD || !joypad || device->pad_data[pad_index].joypad || !device->connected[pad_index]) return NULL; device->pad_data[pad_index].joypad = joypad; @@ -295,18 +293,16 @@ static void hidpad_wiiugca_pad_deinit(void *pad_data) { gca_pad_data_t *pad = (gca_pad_data_t *)pad_data; - if(!pad) - return; - - pad->joypad = NULL; + if (pad) + pad->joypad = NULL; } static int8_t hidpad_wiiugca_status(void *device_data, int pad_index) { - gca_device_data_t *device = (gca_device_data_t *)device_data; int8_t result = 0; + gca_device_data_t *device = (gca_device_data_t *)device_data; - if(!device || pad_index < 0 || pad_index >= GCA_MAX_PAD) + if (!device || pad_index < 0 || pad_index >= GCA_MAX_PAD) return 0; if (device->connected[pad_index]) @@ -321,10 +317,8 @@ static int8_t hidpad_wiiugca_status(void *device_data, int pad_index) static joypad_connection_t *hidpad_wiiugca_joypad(void *device_data, int pad_index) { gca_device_data_t *device = (gca_device_data_t *)device_data; - - if(!device || pad_index < 0 || pad_index >= GCA_MAX_PAD) + if (!device || pad_index < 0 || pad_index >= GCA_MAX_PAD) return 0; - return device->pad_data[pad_index].joypad; } diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 87c4dd3d0d..182ae53eb5 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -219,7 +219,7 @@ static void hidpad_wiiupro_packet_handler(void *data, device->data.btn.home = (packet[0x0C] & 0x8) ? 1 : 0; - if(device->calib.calib_round < 5) + if (device->calib.calib_round < 5) { device->calib.hatvalue_calib[0] = (packet[4] | (packet[4 + 1] << 8)); device->calib.hatvalue_calib[1] = (packet[8] | (packet[8 + 1] << 8)); diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 26bb88ed8a..99f118da41 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1132,7 +1132,7 @@ static void handle_hotplug(android_input_t *android, * This device is composed of two hid devices * We make it look like one device */ - else if( + else if ( ( string_starts_with_size(device_model, "R800", STRLEN_CONST("R800")) || strstr(device_model, "Xperia Play") || @@ -1326,17 +1326,17 @@ static void engine_handle_touchpad( int action = AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction(event); int raw_action = AMotionEvent_getAction(event); - if( action == AMOTION_EVENT_ACTION_POINTER_DOWN + if ( action == AMOTION_EVENT_ACTION_POINTER_DOWN || action == AMOTION_EVENT_ACTION_POINTER_UP ) { int pointer_index = (AMotionEvent_getAction( event ) & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; pointer_id = AMotionEvent_getPointerId( event, pointer_index); } - if( action == AMOTION_EVENT_ACTION_DOWN + if ( action == AMOTION_EVENT_ACTION_DOWN || action == AMOTION_EVENT_ACTION_POINTER_DOWN ) touchstate[pointer_id].down = 1; - else if( action == AMOTION_EVENT_ACTION_UP + else if (action == AMOTION_EVENT_ACTION_UP || action == AMOTION_EVENT_ACTION_POINTER_UP || action == AMOTION_EVENT_ACTION_CANCEL ) touchstate[pointer_id].down = 0; @@ -1669,8 +1669,9 @@ static int16_t android_input_state( case RETRO_DEVICE_MOUSE: { int val = 0; - if(port > 0) + if (port > 0) break; /* TODO: implement mouse for additional ports/players */ + switch (id) { case RETRO_DEVICE_ID_MOUSE_LEFT: @@ -1703,7 +1704,7 @@ static int16_t android_input_state( case RETRO_DEVICE_LIGHTGUN: { int val = 0; - if(port > 0) + if (port > 0) break; /* TODO: implement lightgun for additional ports/players */ switch (id) { diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 9c9650be8d..8aa8d4b651 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -1004,7 +1004,7 @@ bool dinput_handle_message(void *data, wParam == DBT_DEVICEREMOVECOMPLETE) { PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam; - if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + if (pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { #if 0 PDEV_BROADCAST_DEVICEINTERFACE pDevInf = diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index 2a68652fe7..fcbd1987e9 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -325,7 +325,7 @@ static bool psp_input_set_sensor_state(void *data, unsigned port, return true; case RETRO_SENSOR_ACCELEROMETER_DISABLE: case RETRO_SENSOR_GYROSCOPE_DISABLE: - if(psp->sensors_enabled) + if (psp->sensors_enabled) { psp->sensors_enabled = false; sceMotionMagnetometerOff(); @@ -334,7 +334,7 @@ static bool psp_input_set_sensor_state(void *data, unsigned port, return true; case RETRO_SENSOR_ACCELEROMETER_ENABLE: case RETRO_SENSOR_GYROSCOPE_ENABLE: - if(!psp->sensors_enabled) + if (!psp->sensors_enabled) { psp->sensors_enabled = true; sceMotionStartSampling(); @@ -357,10 +357,10 @@ static float psp_input_get_sensor_input(void *data, psp_input_t *psp = (psp_input_t*)data; - if(!psp || !psp->sensors_enabled) + if (!psp || !psp->sensors_enabled) return 0.0f; - if(id >= RETRO_SENSOR_ACCELEROMETER_X && id <= RETRO_SENSOR_GYROSCOPE_Z) + if (id >= RETRO_SENSOR_ACCELEROMETER_X && id <= RETRO_SENSOR_GYROSCOPE_Z) { sceMotionGetSensorState(&sixaxis, port); diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 222afaed4c..d4cd109885 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -412,7 +412,7 @@ static int16_t udev_mouse_get_pointer_x(const udev_input_mouse_t *mouse, bool sc if (x < -0x7fff) return -0x7fff; - else if(x > 0x7fff) + else if (x > 0x7fff) return 0x7fff; return x; @@ -457,7 +457,7 @@ static int16_t udev_mouse_get_pointer_y(const udev_input_mouse_t *mouse, bool sc if (y < -0x7fff) return -0x7fff; - else if(y > 0x7fff) + else if (y > 0x7fff) return 0x7fff; return y; @@ -1064,7 +1064,7 @@ static int16_t udev_pointer_state(udev_input_t *udev, case RETRO_DEVICE_ID_POINTER_Y: return udev_mouse_get_pointer_y(mouse, screen); case RETRO_DEVICE_ID_POINTER_PRESSED: - if(mouse->abs == 1) + if (mouse->abs == 1) return mouse->pp; return mouse->l; } diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index d022334d2b..b9ea351877 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -174,7 +174,7 @@ static int16_t input_wl_state( } } - if(!keyboard_mapping_blocked) + if (!keyboard_mapping_blocked) { for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -194,14 +194,14 @@ static int16_t input_wl_state( { if (binds[port][id].valid && binds[port][id].key < RETROK_LAST) { - if(id != RARCH_GAME_FOCUS_TOGGLE && !keyboard_mapping_blocked) + if (id != RARCH_GAME_FOCUS_TOGGLE && !keyboard_mapping_blocked) { - if(BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key])) + if (BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key])) return 1; } - else if(id == RARCH_GAME_FOCUS_TOGGLE) + else if (id == RARCH_GAME_FOCUS_TOGGLE) { - if(BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key])) + if (BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key])) return 1; } diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 55f3fad37b..c52154e01a 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1390,7 +1390,7 @@ static int16_t btstack_hid_joypad_axis(void *data, if (val < 0) return val; } - else if(AXIS_POS_GET(joyaxis) < 4) + else if (AXIS_POS_GET(joyaxis) < 4) { int16_t val = pad_connection_get_axis( &slots[port], port, AXIS_POS_GET(joyaxis)); diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 0870d0d243..0492a68b82 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -340,7 +340,7 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result, if (range == 3) val *= 2; - if(min == 1) + if (min == 1) val--; switch(val) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index d943b6944c..b0ab24bc2a 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -493,7 +493,7 @@ static int16_t libusb_hid_joypad_axis(void *data, if (val < 0) return val; } - else if(AXIS_POS_GET(joyaxis) < 4) + else if (AXIS_POS_GET(joyaxis) < 4) { int16_t val = pad_connection_get_axis(&hid->slots[port], port, AXIS_POS_GET(joyaxis)); diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index dfce0e0cd9..8a3dfef8d2 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -227,7 +227,7 @@ static void check_port0_active(uint8_t pad_count) settings_t *settings = config_get_ptr(); int idx = settings->uints.input_joypad_index[0]; - if(pad_count < 2 && idx != 0) + if (pad_count < 2 && idx != 0) { #ifdef HW_RVL pad_type[0] = WPAD_EXP_NONE; @@ -588,7 +588,7 @@ static void gx_joypad_poll(void) #endif /* Count active controllers */ - if(gx_joypad_query_pad(port)) + if (gx_joypad_query_pad(port)) pad_count++; /* Always enable 1 pad in port 0 if there's only 1 controller connected. diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index cf377c6a26..6ecb028396 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -535,7 +535,7 @@ static int16_t apple_gamecontroller_joypad_axis( if (val < 0) return val; } - else if(AXIS_POS_GET(joyaxis) < 4) + else if (AXIS_POS_GET(joyaxis) < 4) { int16_t axis = AXIS_POS_GET(joyaxis); int16_t val = mfi_axes[port][axis]; diff --git a/input/drivers_joypad/ps2_joypad.c b/input/drivers_joypad/ps2_joypad.c index 1d70bc01c1..0698843f8d 100644 --- a/input/drivers_joypad/ps2_joypad.c +++ b/input/drivers_joypad/ps2_joypad.c @@ -80,8 +80,7 @@ static void *ps2_joypad_init(void *data) Port 0,3 -> Connector 7 Port 1,3 -> Connector 8 */ - - if((ret = padPortOpen(port, slot, padBuf[port][slot])) == 0) + if ((ret = padPortOpen(port, slot, padBuf[port][slot])) == 0) return NULL; } } diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 52139dd3b6..ab35c188d8 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -368,7 +368,7 @@ static bool psp_joypad_rumble(unsigned pad, #ifdef VITA if (psp2_model != SCE_KERNEL_MODEL_VITATV) return false; - if(pad >= DEFAULT_MAX_PADS) + if (pad >= DEFAULT_MAX_PADS) return false; switch (effect) { diff --git a/input/drivers_joypad/switch_joypad.c b/input/drivers_joypad/switch_joypad.c index 3095c8870f..c06cc13a7d 100644 --- a/input/drivers_joypad/switch_joypad.c +++ b/input/drivers_joypad/switch_joypad.c @@ -68,7 +68,7 @@ static void *switch_joypad_init(void *data) for (i = 0; i < DEFAULT_MAX_PADS; i++) { - if(i == 0) + if (i == 0) padInitializeDefault(&pad_states[0]); else padInitialize(&pad_states[i], i); diff --git a/input/input_driver.c b/input/input_driver.c index 351cc3bc0f..26c8f63343 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -4776,7 +4776,7 @@ void bsv_movie_handle_push_key_event(bsv_movie_t *movie, uint8_t down, uint16_t void bsv_movie_finish_rewind(input_driver_state_t *input_st) { bsv_movie_t *handle = input_st->bsv_movie_state_handle; - if(!handle) + if (!handle) return; handle->frame_ptr = (handle->frame_ptr + 1) & handle->frame_mask; handle->first_rewind = !handle->did_rewind; @@ -4803,7 +4803,7 @@ void bsv_movie_next_frame(input_driver_state_t *input_st) if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_PLAYBACK) { /* read next key events, a frame happened for sure? but don't apply them yet */ - if(handle->key_event_count != 0) + if (handle->key_event_count != 0) { RARCH_ERR("[Movie] BSV keyboard replay reading next frame while some unused keys still in queue\n"); } @@ -5289,7 +5289,7 @@ void input_driver_poll(void) runloop_state_t *runloop_st = runloop_state_get_ptr(); retro_keyboard_event_t *key_event = &runloop_st->key_event; - if(*key_event && *key_event == runloop_st->frontend_key_event) + if (*key_event && *key_event == runloop_st->frontend_key_event) { int i; bsv_key_data_t k; @@ -6301,7 +6301,7 @@ void input_keyboard_event(bool down, unsigned code, if (*key_event) { - if(*key_event == runloop_st->frontend_key_event) + if (*key_event == runloop_st->frontend_key_event) { #ifdef HAVE_BSV_MOVIE /* Save input to BSV record, if recording */ diff --git a/intl/msg_hash_el.c b/intl/msg_hash_el.c index 1a37184466..a268c59848 100644 --- a/intl/msg_hash_el.c +++ b/intl/msg_hash_el.c @@ -403,7 +403,8 @@ static const char *menu_hash_to_str_el_label_enum(enum msg_hash_enums msg) } #endif -const char *msg_hash_to_str_el(enum msg_hash_enums msg) { +const char *msg_hash_to_str_el(enum msg_hash_enums msg) +{ #ifdef HAVE_MENU const char *ret = menu_hash_to_str_el_label_enum(msg); @@ -411,7 +412,8 @@ const char *msg_hash_to_str_el(enum msg_hash_enums msg) { return ret; #endif - switch (msg) { + switch (msg) + { #include "msg_hash_el.h" default: #if 0 diff --git a/intl/msg_hash_pt_br.c b/intl/msg_hash_pt_br.c index 07855a266c..5fdc102f84 100644 --- a/intl/msg_hash_pt_br.c +++ b/intl/msg_hash_pt_br.c @@ -2373,7 +2373,8 @@ static const char *menu_hash_to_str_pt_br_label_enum(enum msg_hash_enums msg) } #endif -const char *msg_hash_to_str_pt_br(enum msg_hash_enums msg) { +const char *msg_hash_to_str_pt_br(enum msg_hash_enums msg) +{ #ifdef HAVE_MENU const char *ret = menu_hash_to_str_pt_br_label_enum(msg); @@ -2381,7 +2382,8 @@ const char *msg_hash_to_str_pt_br(enum msg_hash_enums msg) { return ret; #endif - switch (msg) { + switch (msg) + { #include "msg_hash_pt_br.h" default: #if 0 diff --git a/intl/msg_hash_tr.c b/intl/msg_hash_tr.c index fe1ca7e672..5ac0029bf0 100644 --- a/intl/msg_hash_tr.c +++ b/intl/msg_hash_tr.c @@ -1911,7 +1911,8 @@ static const char *menu_hash_to_str_tr_label_enum(enum msg_hash_enums msg) } #endif -const char *msg_hash_to_str_tr(enum msg_hash_enums msg) { +const char *msg_hash_to_str_tr(enum msg_hash_enums msg) +{ #ifdef HAVE_MENU const char *ret = menu_hash_to_str_tr_label_enum(msg); @@ -1919,7 +1920,8 @@ const char *msg_hash_to_str_tr(enum msg_hash_enums msg) { return ret; #endif - switch (msg) { + switch (msg) + { #include "msg_hash_tr.h" default: #if 0 diff --git a/led/drivers/led_rpi.c b/led/drivers/led_rpi.c index 0c296044f5..bd3593734c 100644 --- a/led/drivers/led_rpi.c +++ b/led/drivers/led_rpi.c @@ -106,16 +106,16 @@ static void rpi_set(int led, int state) int gpio = 0; /* Invalid LED? */ - if((led < 0) || (led >= MAX_LEDS)) + if ((led < 0) || (led >= MAX_LEDS)) return; gpio = rpi_cur->map[led]; - if(gpio <= 0) + if (gpio <= 0) return; - if(rpi_cur->setup[led] == 0) + if (rpi_cur->setup[led] == 0) rpi_cur->setup[led] = setup_gpio(gpio); - if(rpi_cur->setup[led] > 0) + if (rpi_cur->setup[led] > 0) set_gpio(gpio, state); } diff --git a/led/drivers/led_sys_linux.c b/led/drivers/led_sys_linux.c index 4562e34337..cbfe191c49 100644 --- a/led/drivers/led_sys_linux.c +++ b/led/drivers/led_sys_linux.c @@ -93,16 +93,16 @@ static void sys_led_set(int led, int state) int sysled = 0; /* Invalid LED? */ - if((led < 0) || (led >= MAX_LEDS)) + if ((led < 0) || (led >= MAX_LEDS)) return; sysled = sys_cur->map[led]; - if(sysled < 0) + if (sysled < 0) return; - if(sys_cur->setup[led] == 0) + if (sys_cur->setup[led] == 0) sys_cur->setup[led] = setup_sysled(sysled); - if(sys_cur->setup[led] > 0) + if (sys_cur->setup[led] > 0) set_sysled(sysled, state); } diff --git a/libretro-common/audio/audio_mixer.c b/libretro-common/audio/audio_mixer.c index 9638906b73..a274989be4 100644 --- a/libretro-common/audio/audio_mixer.c +++ b/libretro-common/audio/audio_mixer.c @@ -923,7 +923,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, } else { - if(i < AUDIO_MIXER_MAX_VOICES) + if (i < AUDIO_MIXER_MAX_VOICES) { audio_mixer_release(voice); AUDIO_MIXER_UNLOCK(voice); diff --git a/libretro-common/audio/dsp_filters/chorus.c b/libretro-common/audio/dsp_filters/chorus.c index bbae0d0552..c6dae1192b 100644 --- a/libretro-common/audio/dsp_filters/chorus.c +++ b/libretro-common/audio/dsp_filters/chorus.c @@ -33,13 +33,12 @@ struct chorus_data { float old[2][CHORUS_MAX_DELAY]; - unsigned old_ptr; - float delay; float depth; float input_rate; float mix_dry; float mix_wet; + unsigned old_ptr; unsigned lfo_ptr; unsigned lfo_period; }; @@ -66,37 +65,37 @@ static void chorus_process(void *data, struct dspfilter_output *output, unsigned delay_int; float delay_frac, l_a, l_b, r_a, r_b; float chorus_l, chorus_r; - float in[2] = { out[0], out[1] }; - float delay = ch->delay + ch->depth * sin((2.0 * M_PI * ch->lfo_ptr++) / ch->lfo_period); + float in[2] = { out[0], out[1] }; + float delay = ch->delay + ch->depth * sin((2.0 * M_PI * ch->lfo_ptr++) / ch->lfo_period); - delay *= ch->input_rate; + delay *= ch->input_rate; if (ch->lfo_ptr >= ch->lfo_period) - ch->lfo_ptr = 0; + ch->lfo_ptr = 0; - delay_int = (unsigned)delay; + delay_int = (unsigned)delay; if (delay_int >= CHORUS_MAX_DELAY - 1) - delay_int = CHORUS_MAX_DELAY - 2; + delay_int = CHORUS_MAX_DELAY - 2; - delay_frac = delay - delay_int; + delay_frac = delay - delay_int; ch->old[0][ch->old_ptr] = in[0]; ch->old[1][ch->old_ptr] = in[1]; - l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; - l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; - r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; - r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; + l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; + l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; + r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; + r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; /* Lerp introduces aliasing of the chorus component, * but doing full polyphase here is probably overkill. */ - chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; - chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; + chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; + chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; - out[0] = ch->mix_dry * in[0] + ch->mix_wet * chorus_l; - out[1] = ch->mix_dry * in[1] + ch->mix_wet * chorus_r; + out[0] = ch->mix_dry * in[0] + ch->mix_wet * chorus_l; + out[1] = ch->mix_dry * in[1] + ch->mix_wet * chorus_r; - ch->old_ptr = (ch->old_ptr + 1) & CHORUS_DELAY_MASK; + ch->old_ptr = (ch->old_ptr + 1) & CHORUS_DELAY_MASK; } } @@ -113,24 +112,24 @@ static void *chorus_init(const struct dspfilter_info *info, config->get_float(userdata, "lfo_freq", &lfo_freq, 0.5f); config->get_float(userdata, "drywet", &drywet, 0.8f); - delay /= 1000.0f; - depth /= 1000.0f; + delay /= 1000.0f; + depth /= 1000.0f; if (depth > delay) - depth = delay; + depth = delay; if (drywet < 0.0f) - drywet = 0.0f; + drywet = 0.0f; else if (drywet > 1.0f) - drywet = 1.0f; + drywet = 1.0f; - ch->mix_dry = 1.0f - 0.5f * drywet; - ch->mix_wet = 0.5f * drywet; + ch->mix_dry = 1.0f - 0.5f * drywet; + ch->mix_wet = 0.5f * drywet; - ch->delay = delay; - ch->depth = depth; - ch->lfo_period = (1.0f / lfo_freq) * info->input_rate; - ch->input_rate = info->input_rate; + ch->delay = delay; + ch->depth = depth; + ch->lfo_period = (1.0f / lfo_freq) * info->input_rate; + ch->input_rate = info->input_rate; if (!ch->lfo_period) ch->lfo_period = 1; return ch; @@ -151,10 +150,6 @@ static const struct dspfilter_implementation chorus_plug = { #endif const struct dspfilter_implementation * -dspfilter_get_implementation(dspfilter_simd_mask_t mask) -{ - (void)mask; - return &chorus_plug; -} +dspfilter_get_implementation(dspfilter_simd_mask_t mask) { return &chorus_plug; } #undef dspfilter_get_implementation diff --git a/libretro-common/audio/dsp_filters/crystalizer.c b/libretro-common/audio/dsp_filters/crystalizer.c index 0bd6c50491..8ccecd8377 100644 --- a/libretro-common/audio/dsp_filters/crystalizer.c +++ b/libretro-common/audio/dsp_filters/crystalizer.c @@ -42,7 +42,7 @@ static void delta_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { unsigned i, c; - struct delta_data *d = (struct delta_data*)data; + struct delta_data *d = (struct delta_data*)data; float *out = output->samples; output->samples = input->samples; output->frames = input->frames; @@ -51,9 +51,9 @@ static void delta_process(void *data, struct dspfilter_output *output, { for (c = 0; c < 2; c++) { - float current = *out; - *out++ = current + (current - d->old[c]) * d->intensity; - d->old[c] = current; + float current = *out; + *out++ = current + (current - d->old[c]) * d->intensity; + d->old[c] = current; } } } @@ -83,7 +83,6 @@ static const struct dspfilter_implementation delta_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &delta_plug; } diff --git a/libretro-common/audio/dsp_filters/echo.c b/libretro-common/audio/dsp_filters/echo.c index d0f27eb8fe..27df905231 100644 --- a/libretro-common/audio/dsp_filters/echo.c +++ b/libretro-common/audio/dsp_filters/echo.c @@ -75,11 +75,11 @@ static void echo_process(void *data, struct dspfilter_output *output, echo_right += echo->channels[c].buffer[(echo->channels[c].ptr << 1) + 1]; } - echo_left *= echo->amp; - echo_right *= echo->amp; + echo_left *= echo->amp; + echo_right *= echo->amp; - left = out[0] + echo_left; - right = out[1] + echo_right; + left = out[0] + echo_left; + right = out[1] + echo_right; for (c = 0; c < echo->num_channels; c++) { @@ -121,28 +121,25 @@ static void *echo_init(const struct dspfilter_info *info, &num_feedback, default_feedback, 1); config->get_float(userdata, "amp", &echo->amp, 0.2f); - channels = num_feedback = num_delay = MIN(num_delay, num_feedback); + channels = num_feedback = num_delay = MIN(num_delay, num_feedback); - echo_channels = (struct echo_channel*)calloc(channels, - sizeof(*echo_channels)); - - if (!echo_channels) + if (!(echo_channels = (struct echo_channel*)calloc(channels, + sizeof(*echo_channels)))) goto error; - echo->channels = echo_channels; - echo->num_channels = channels; + echo->channels = echo_channels; + echo->num_channels = channels; for (i = 0; i < channels; i++) { - unsigned frames = (unsigned)(delay[i] * info->input_rate / 1000.0f + 0.5f); + unsigned frames = (unsigned)(delay[i] * info->input_rate / 1000.0f + 0.5f); if (!frames) goto error; - echo->channels[i].buffer = (float*)calloc(frames, 2 * sizeof(float)); - if (!echo->channels[i].buffer) + if (!(echo->channels[i].buffer = (float*)calloc(frames, 2 * sizeof(float)))) goto error; - echo->channels[i].frames = frames; + echo->channels[i].frames = frames; echo->channels[i].feedback = feedback[i]; } @@ -173,7 +170,6 @@ static const struct dspfilter_implementation echo_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &echo_plug; } diff --git a/libretro-common/audio/dsp_filters/eq.c b/libretro-common/audio/dsp_filters/eq.c index e5cddd5c3f..a7578d9281 100644 --- a/libretro-common/audio/dsp_filters/eq.c +++ b/libretro-common/audio/dsp_filters/eq.c @@ -34,12 +34,11 @@ struct eq_data { fft_t *fft; - float buffer[8 * 1024]; - float *save; float *block; fft_complex_t *filter; fft_complex_t *fftblock; + float buffer[8 * 1024]; unsigned block_size; unsigned block_ptr; }; @@ -88,11 +87,11 @@ static void eq_process(void *data, struct dspfilter_output *output, memcpy(eq->block + eq->block_ptr * 2, in, write_avail * 2 * sizeof(float)); - in += write_avail * 2; - input_frames -= write_avail; + in += write_avail * 2; + input_frames -= write_avail; eq->block_ptr += write_avail; - // Convolve a new block. + /* Convolve a new block. */ if (eq->block_ptr == eq->block_size) { unsigned i, c; @@ -105,16 +104,16 @@ static void eq_process(void *data, struct dspfilter_output *output, fft_process_inverse(eq->fft, out + c, eq->fftblock, 2); } - // Overlap add method, so add in saved block now. + /* Overlap add method, so add in saved block now. */ for (i = 0; i < 2 * eq->block_size; i++) - out[i] += eq->save[i]; + out[i] += eq->save[i]; - // Save block for later. + /* Save block for later. */ memcpy(eq->save, out + 2 * eq->block_size, 2 * eq->block_size * sizeof(float)); - out += eq->block_size * 2; + out += eq->block_size * 2; output->frames += eq->block_size; - eq->block_ptr = 0; + eq->block_ptr = 0; } } } @@ -184,8 +183,8 @@ static void generate_response(fft_complex_t *response, lerp = (freq - start_freq) / (end_freq - start_freq); gain = (1.0f - lerp) * start_gain + lerp * end_gain; - response[i].real = gain; - response[i].imag = 0.0f; + response[i].real = gain; + response[i].imag = 0.0f; response[2 * samples - i].real = gain; response[2 * samples - i].imag = 0.0f; } @@ -196,10 +195,9 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, { int i; int half_block_size = eq->block_size >> 1; - double window_mod = 1.0 / kaiser_window_function(0.0, beta); - - fft_t *fft = fft_new(size_log2); - float *time_filter = (float*)calloc(eq->block_size * 2 + 1, sizeof(*time_filter)); + double window_mod = 1.0 / kaiser_window_function(0.0, beta); + fft_t *fft = fft_new(size_log2); + float *time_filter = (float*)calloc(eq->block_size * 2 + 1, sizeof(*time_filter)); if (!fft || !time_filter) goto end; @@ -228,8 +226,8 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, for (i = 0; i < (int)eq->block_size; i++) { /* Kaiser window. */ - double phase = (double)i / eq->block_size; - phase = 2.0 * (phase - 0.5); + double phase = (double)i / eq->block_size; + phase = 2.0 * (phase - 0.5); time_filter[i] *= window_mod * kaiser_window_function(phase, beta); } @@ -261,15 +259,15 @@ end: static void *eq_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { - float *frequencies, *gain; - unsigned num_freq, num_gain, i, size; int size_log2; float beta; - struct eq_gain *gains = NULL; - char *filter_path = NULL; + float *frequencies, *gain; + unsigned num_freq, num_gain, i, size; + struct eq_gain *gains = NULL; + char *filter_path = NULL; const float default_freq[] = { 0.0f, info->input_rate }; const float default_gain[] = { 0.0f, 0.0f }; - struct eq_data *eq = (struct eq_data*)calloc(1, sizeof(*eq)); + struct eq_data *eq = (struct eq_data*)calloc(1, sizeof(*eq)); if (!eq) return NULL; @@ -289,8 +287,7 @@ static void *eq_init(const struct dspfilter_info *info, num_gain = num_freq = MIN(num_gain, num_freq); - gains = (struct eq_gain*)calloc(num_gain, sizeof(*gains)); - if (!gains) + if (!(gains = (struct eq_gain*)calloc(num_gain, sizeof(*gains)))) goto error; for (i = 0; i < num_gain; i++) @@ -303,15 +300,15 @@ static void *eq_init(const struct dspfilter_info *info, eq->block_size = size; - eq->save = (float*)calloc( size, 2 * sizeof(*eq->save)); - eq->block = (float*)calloc(2 * size, 2 * sizeof(*eq->block)); - eq->fftblock = (fft_complex_t*)calloc(2 * size, sizeof(*eq->fftblock)); - eq->filter = (fft_complex_t*)calloc(2 * size, sizeof(*eq->filter)); + eq->save = (float*)calloc( size, 2 * sizeof(*eq->save)); + eq->block = (float*)calloc(2 * size, 2 * sizeof(*eq->block)); + eq->fftblock = (fft_complex_t*)calloc(2 * size, sizeof(*eq->fftblock)); + eq->filter = (fft_complex_t*)calloc(2 * size, sizeof(*eq->filter)); /* Use an FFT which is twice the block size with zero-padding * to make circular convolution => proper convolution. */ - eq->fft = fft_new(size_log2 + 1); + eq->fft = fft_new(size_log2 + 1); if (!eq->fft || !eq->fftblock || !eq->save || !eq->block || !eq->filter) goto error; @@ -345,7 +342,6 @@ static const struct dspfilter_implementation eq_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &eq_plug; } diff --git a/libretro-common/audio/dsp_filters/iir.c b/libretro-common/audio/dsp_filters/iir.c index 956f01651e..232edc15d7 100644 --- a/libretro-common/audio/dsp_filters/iir.c +++ b/libretro-common/audio/dsp_filters/iir.c @@ -364,7 +364,6 @@ static const struct dspfilter_implementation iir_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &iir_plug; } diff --git a/libretro-common/audio/dsp_filters/panning.c b/libretro-common/audio/dsp_filters/panning.c index e89b9ce1d3..87216edf0b 100644 --- a/libretro-common/audio/dsp_filters/panning.c +++ b/libretro-common/audio/dsp_filters/panning.c @@ -104,7 +104,6 @@ static const struct dspfilter_implementation panning = { const struct dspfilter_implementation * dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &panning; } diff --git a/libretro-common/audio/dsp_filters/phaser.c b/libretro-common/audio/dsp_filters/phaser.c index e470e30c43..4c5d206df8 100644 --- a/libretro-common/audio/dsp_filters/phaser.c +++ b/libretro-common/audio/dsp_filters/phaser.c @@ -27,8 +27,8 @@ #include #include -#define phaserlfoshape 4.0 -#define phaserlfoskipsamples 20 +#define PHASER_LFO_SHAPE 4.0 +#define PHASER_LFO_SKIP_SAMPLES 20 struct phaser_data { @@ -71,10 +71,10 @@ static void phaser_process(void *data, struct dspfilter_output *output, for (c = 0; c < 2; c++) m[c] = in[c] + ph->fbout[c] * ph->fb * 0.01f; - if ((ph->skipcount++ % phaserlfoskipsamples) == 0) + if ((ph->skipcount++ % PHASER_LFO_SKIP_SAMPLES) == 0) { ph->gain = 0.5 * (1.0 + cos(ph->skipcount * ph->lfoskip + ph->phase)); - ph->gain = (exp(ph->gain * phaserlfoshape) - 1.0) / (exp(phaserlfoshape) - 1); + ph->gain = (exp(ph->gain * PHASER_LFO_SHAPE) - 1.0) / (exp(PHASER_LFO_SHAPE) - 1); ph->gain = 1.0 - ph->gain * ph->depth; } @@ -138,7 +138,6 @@ static const struct dspfilter_implementation phaser_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &phaser_plug; } diff --git a/libretro-common/audio/dsp_filters/reverb.c b/libretro-common/audio/dsp_filters/reverb.c index f92352db70..22060bb789 100644 --- a/libretro-common/audio/dsp_filters/reverb.c +++ b/libretro-common/audio/dsp_filters/reverb.c @@ -127,7 +127,7 @@ static float revmodel_process(struct revmodel *rev, float in) static void revmodel_update(struct revmodel *rev) { int i; - rev->wet1 = rev->wet * (rev->width / 2.0f + 0.5f); + rev->wet1 = rev->wet * (rev->width / 2.0f + 0.5f); if (rev->mode >= freezemode) { @@ -138,15 +138,15 @@ static void revmodel_update(struct revmodel *rev) else { rev->roomsize1 = rev->roomsize; - rev->damp1 = rev->damp; - rev->gain = fixedgain; + rev->damp1 = rev->damp; + rev->gain = fixedgain; } for (i = 0; i < NUMCOMBS; i++) { rev->combL[i].feedback = rev->roomsize1; - rev->combL[i].damp1 = rev->damp1; - rev->combL[i].damp2 = 1.0f - rev->damp1; + rev->combL[i].damp1 = rev->damp1; + rev->combL[i].damp2 = 1.0f - rev->damp1; } } @@ -186,7 +186,7 @@ static void revmodel_setmode(struct revmodel *rev, float value) revmodel_update(rev); } -static void revmodel_init(struct revmodel *rev,int srate, bool right) +static void revmodel_init(struct revmodel *rev, int srate, bool right) { unsigned c; static const int comb_lengths[8] = { 1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 }; @@ -196,19 +196,19 @@ static void revmodel_init(struct revmodel *rev,int srate, bool right) for (c = 0; c < NUMCOMBS; ++c) { - rev->bufcomb[c] = malloc(r*comb_lengths[c]+stereosep*sizeof(float)); - rev->combL[c].buffer = rev->bufcomb[c]; - memset(rev->combL[c].buffer,0,r*comb_lengths[c]+stereosep*sizeof(float)); - rev->combL[c].bufsize=r*comb_lengths[c]+stereosep; + rev->bufcomb[c] = malloc(r * comb_lengths[c] + stereosep * sizeof(float)); + rev->combL[c].buffer = rev->bufcomb[c]; + memset(rev->combL[c].buffer, 0, r * comb_lengths[c] + stereosep * sizeof(float)); + rev->combL[c].bufsize = r * comb_lengths[c] + stereosep; } for (c = 0; c < NUMALLPASSES; ++c) { - rev->bufallpass[c] = malloc(r*allpass_lengths[c]+stereosep*sizeof(float)); - rev->allpassL[c].buffer = rev->bufallpass[c]; - memset(rev->allpassL[c].buffer,0,r*allpass_lengths[c]+stereosep*sizeof(float)); - rev->allpassL[c].bufsize=r*allpass_lengths[c]+stereosep; - rev->allpassL[c].feedback = 0.5f; + rev->bufallpass[c] = malloc(r * allpass_lengths[c] + stereosep * sizeof(float)); + rev->allpassL[c].buffer = rev->bufallpass[c]; + memset(rev->allpassL[c].buffer, 0, r * allpass_lengths[c] + stereosep * sizeof(float)); + rev->allpassL[c].bufsize = r * allpass_lengths[c] + stereosep; + rev->allpassL[c].feedback = 0.5f; } revmodel_setwet(rev, initialwet); @@ -226,8 +226,8 @@ struct reverb_data static void reverb_free(void *data) { - struct reverb_data *rev = (struct reverb_data*)data; unsigned i; + struct reverb_data *rev = (struct reverb_data*)data; for (i = 0; i < NUMCOMBS; i++) { diff --git a/libretro-common/audio/dsp_filters/tremolo.c b/libretro-common/audio/dsp_filters/tremolo.c index bf07ca30ee..5bdf52ed32 100644 --- a/libretro-common/audio/dsp_filters/tremolo.c +++ b/libretro-common/audio/dsp_filters/tremolo.c @@ -32,11 +32,11 @@ struct tremolo_core { - float freq; - float depth; - float* wavetable; - int index; - int maxindex; + float *wavetable; + float freq; + float depth; + int index; + int maxindex; }; struct tremolo @@ -54,24 +54,25 @@ static void tremolo_free(void *data) static void tremolocore_init(struct tremolo_core *core,float depth,int samplerate,float freq) { - const double offset = 1. - depth / 2.; - unsigned i; - double env; - core->index = 0; - core->maxindex = samplerate/freq; - core->wavetable = malloc(core->maxindex*sizeof(float)); - memset(core->wavetable, 0, core->maxindex * sizeof(float)); - for (i = 0; i < core->maxindex; i++) { - env = freq * i / samplerate; - env = sin((M_PI*2) * fmod(env + 0.25, 1.0)); - core->wavetable[i] = env * (1 - fabs(offset)) + offset; - } + double env; + unsigned i; + const double offset = 1. - depth / 2.; + core->index = 0; + core->maxindex = samplerate / freq; + core->wavetable = malloc(core->maxindex * sizeof(float)); + memset(core->wavetable, 0, core->maxindex * sizeof(float)); + for (i = 0; i < core->maxindex; i++) + { + env = freq * i / samplerate; + env = sin((M_PI*2) * fmod(env + 0.25, 1.0)); + core->wavetable[i] = env * (1 - fabs(offset)) + offset; + } } float tremolocore_core(struct tremolo_core *core,float in) { - core->index = core->index % core->maxindex; - return in * core->wavetable[core->index++]; + core->index = core->index % core->maxindex; + return in * core->wavetable[core->index++]; } static void tremolo_process(void *data, struct dspfilter_output *output, @@ -81,16 +82,15 @@ static void tremolo_process(void *data, struct dspfilter_output *output, float *out; struct tremolo *tre = (struct tremolo*)data; - output->samples = input->samples; - output->frames = input->frames; - out = output->samples; + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { - float in[2] = { out[0], out[1] }; - - out[0] = tremolocore_core(&tre->left, in[0]); - out[1] = tremolocore_core(&tre->right, in[1]); + float in[2] = { out[0], out[1] }; + out[0] = tremolocore_core(&tre->left, in[0]); + out[1] = tremolocore_core(&tre->right, in[1]); } } @@ -98,7 +98,7 @@ static void *tremolo_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { float freq, depth; - struct tremolo *tre = (struct tremolo*)calloc(1, sizeof(*tre)); + struct tremolo *tre = (struct tremolo*)calloc(1, sizeof(*tre)); if (!tre) return NULL; @@ -125,7 +125,6 @@ static const struct dspfilter_implementation tremolo_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &tremolo_plug; } diff --git a/libretro-common/audio/dsp_filters/vibrato.c b/libretro-common/audio/dsp_filters/vibrato.c index 673554c873..d5efacd626 100644 --- a/libretro-common/audio/dsp_filters/vibrato.c +++ b/libretro-common/audio/dsp_filters/vibrato.c @@ -30,31 +30,30 @@ #define sqr(a) ((a) * (a)) -const float BASE_DELAY_SEC = 0.002; // 2 ms -const float VIBRATO_FREQUENCY_DEFAULT_HZ = 2; -const float VIBRATO_FREQUENCY_MAX_HZ = 14; -const float VIBRATO_DEPTH_DEFAULT_PERCENT = 50; -const int add_delay = 3; +static const float BASE_DELAY_SEC = 0.002; /* 2 ms */ +static const float VIBRATO_FREQUENCY_DEFAULT_HZ = 2; +static const float VIBRATO_FREQUENCY_MAX_HZ = 14; +static const float VIBRATO_DEPTH_DEFAULT_PERCENT = 50; +static const int add_delay = 3; -float hermite_interp(float x, float *y) +static float hermite_interp(float x, float *y) { - float c0, c1, c2, c3; - c0 = y[1]; - c1 = (1.0 / 2.0)*(y[2] - y[0]); - c2 = (y[0] - (5.0 / 2.0)*y[1]) + (2.0*y[2] - (1.0 / 2.0)*y[3]); - c3 = (1.0 / 2.0)*(y[3] - y[0]) + (3.0 / 2.0)*(y[1] - y[2]); - return ((c3*x + c2)*x + c1)*x + c0; + float c0 = y[1]; + float c1 = (1.0f / 2.0f) * (y[2] - y[0]); + float c2 = (y[0] - (5.0f / 2.0f) * y[1]) + (2.0f * y[2] - (1.0f / 2.0f) * y[3]); + float c3 = (1.0f / 2.0f) * (y[3] - y[0]) + (3.0f / 2.0f) * (y[1] - y[2]); + return ((c3 * x + c2) * x + c1) * x + c0; } struct vibrato_core { - float freq; - float samplerate; - int phase; - float depth; - float* buffer; - int writeindex; - int size; + float* buffer; + float freq; + float samplerate; + float depth; + int phase; + int writeindex; + int size; }; struct vibrato @@ -72,60 +71,62 @@ static void vibrato_free(void *data) static void vibratocore_init(struct vibrato_core *core,float depth,int samplerate,float freq) { - core->size = BASE_DELAY_SEC * samplerate * 2; - core->buffer = malloc((core->size + add_delay)*sizeof(float)); - memset(core->buffer, 0, (core->size + add_delay) * sizeof(float)); + core->size = BASE_DELAY_SEC * samplerate * 2; + core->buffer = malloc((core->size + add_delay) * sizeof(float)); + memset(core->buffer, 0, (core->size + add_delay) * sizeof(float)); core->samplerate = samplerate; - core->freq = freq; - core->depth = depth; - core->phase = 0; + core->freq = freq; + core->depth = depth; + core->phase = 0; core->writeindex = 0; } float vibratocore_core(struct vibrato_core *core,float in) { - float M = core->freq / core->samplerate; - int maxphase = core->samplerate / core->freq; - float lfo = sin(M * 2. * M_PI * core->phase++); - core->phase = core->phase % maxphase; - lfo = (lfo + 1) * 1.; // transform from [-1; 1] to [0; 1] - int maxdelay = BASE_DELAY_SEC * core->samplerate; - float delay = lfo * core->depth * maxdelay; - delay += add_delay; - float readindex = core->writeindex - 1 - delay; - while (readindex < 0)readindex += core->size; - while (readindex >= core->size)readindex -= core->size; - int ipart = (int)readindex; // integer part of the delay - float fpart = readindex - ipart; // fractional part of the delay - float value = hermite_interp(fpart, &(core->buffer[ipart])); - core->buffer[core->writeindex] = in; - if (core->writeindex < add_delay){ - core->buffer[core->size + core->writeindex] = in; - } - core->writeindex++; - if (core->writeindex == core->size) { - core->writeindex = 0; - } - return value; + int ipart; + float delay, readindex, fpart, value; + float M = core->freq / core->samplerate; + int maxphase = core->samplerate / core->freq; + float lfo = sin(M * 2. * M_PI * core->phase++); + int maxdelay = BASE_DELAY_SEC * core->samplerate; + core->phase = core->phase % maxphase; + lfo = (lfo + 1) * 1.; // transform from [-1; 1] to [0; 1] + delay = lfo * core->depth * maxdelay; + delay += add_delay; + readindex = core->writeindex - 1 - delay; + while (readindex < 0) + readindex += core->size; + while (readindex >= core->size) + readindex -= core->size; + ipart = (int)readindex; /* Integer part of the delay */ + fpart = readindex - ipart; /* fractional part of the delay */ + value = hermite_interp(fpart, &(core->buffer[ipart])); + core->buffer[core->writeindex] = in; + if (core->writeindex < add_delay) + core->buffer[core->size + core->writeindex] = in; + core->writeindex++; + if (core->writeindex == core->size) + core->writeindex = 0; + return value; } -static void vibrato_process(void *data, struct dspfilter_output *output, +static void vibrato_process(void *data, + struct dspfilter_output *output, const struct dspfilter_input *input) { unsigned i; float *out; struct vibrato *vib = (struct vibrato*)data; - output->samples = input->samples; - output->frames = input->frames; - out = output->samples; + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { float in[2] = { out[0], out[1] }; - - out[0] = vibratocore_core(&vib->left, in[0]); - out[1] = vibratocore_core(&vib->right, in[1]); + out[0] = vibratocore_core(&vib->left, in[0]); + out[1] = vibratocore_core(&vib->right, in[1]); } } @@ -133,7 +134,7 @@ static void *vibrato_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { float freq, depth; - struct vibrato *vib = (struct vibrato*)calloc(1, sizeof(*vib)); + struct vibrato *vib = (struct vibrato*)calloc(1, sizeof(*vib)); if (!vib) return NULL; @@ -160,7 +161,6 @@ static const struct dspfilter_implementation vibrato_plug = { const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) { - (void)mask; return &vibrato_plug; } diff --git a/libretro-common/audio/dsp_filters/wahwah.c b/libretro-common/audio/dsp_filters/wahwah.c index 3d85b50c6c..fff8be7e2e 100644 --- a/libretro-common/audio/dsp_filters/wahwah.c +++ b/libretro-common/audio/dsp_filters/wahwah.c @@ -68,39 +68,39 @@ static void wahwah_process(void *data, struct dspfilter_output *output, if ((wah->skipcount++ % WAHWAH_LFO_SKIP_SAMPLES) == 0) { float omega, sn, cs, alpha; - float frequency = (1.0 + cos(wah->skipcount * wah->lfoskip + wah->phase)) / 2.0; + float frequency = (1.0f + cos(wah->skipcount * wah->lfoskip + wah->phase)) / 2.0f; - frequency = frequency * wah->depth * (1.0 - wah->freqofs) + wah->freqofs; - frequency = exp((frequency - 1.0) * 6.0); + frequency = frequency * wah->depth * (1.0f - wah->freqofs) + wah->freqofs; + frequency = exp((frequency - 1.0f) * 6.0f); - omega = M_PI * frequency; - sn = sin(omega); - cs = cos(omega); - alpha = sn / (2.0 * wah->res); + omega = M_PI * frequency; + sn = sin(omega); + cs = cos(omega); + alpha = sn / (2.0f * wah->res); - wah->b0 = (1.0 - cs) / 2.0; - wah->b1 = 1.0 - cs; - wah->b2 = (1.0 - cs) / 2.0; - wah->a0 = 1.0 + alpha; - wah->a1 = -2.0 * cs; - wah->a2 = 1.0 - alpha; + wah->b0 = (1.0f - cs) / 2.0f; + wah->b1 = 1.0f - cs; + wah->b2 = (1.0f - cs) / 2.0f; + wah->a0 = 1.0f + alpha; + wah->a1 = -2.0f * cs; + wah->a2 = 1.0f - alpha; } - out_l = (wah->b0 * in[0] + wah->b1 * wah->l.xn1 + wah->b2 * wah->l.xn2 - wah->a1 * wah->l.yn1 - wah->a2 * wah->l.yn2) / wah->a0; - out_r = (wah->b0 * in[1] + wah->b1 * wah->r.xn1 + wah->b2 * wah->r.xn2 - wah->a1 * wah->r.yn1 - wah->a2 * wah->r.yn2) / wah->a0; + out_l = (wah->b0 * in[0] + wah->b1 * wah->l.xn1 + wah->b2 * wah->l.xn2 - wah->a1 * wah->l.yn1 - wah->a2 * wah->l.yn2) / wah->a0; + out_r = (wah->b0 * in[1] + wah->b1 * wah->r.xn1 + wah->b2 * wah->r.xn2 - wah->a1 * wah->r.yn1 - wah->a2 * wah->r.yn2) / wah->a0; - wah->l.xn2 = wah->l.xn1; - wah->l.xn1 = in[0]; - wah->l.yn2 = wah->l.yn1; - wah->l.yn1 = out_l; + wah->l.xn2 = wah->l.xn1; + wah->l.xn1 = in[0]; + wah->l.yn2 = wah->l.yn1; + wah->l.yn1 = out_l; - wah->r.xn2 = wah->r.xn1; - wah->r.xn1 = in[1]; - wah->r.yn2 = wah->r.yn1; - wah->r.yn1 = out_r; + wah->r.xn2 = wah->r.xn1; + wah->r.xn1 = in[1]; + wah->r.yn2 = wah->r.yn1; + wah->r.yn1 = out_r; - out[0] = out_l; - out[1] = out_r; + out[0] = out_l; + out[1] = out_r; } } @@ -117,8 +117,8 @@ static void *wahwah_init(const struct dspfilter_info *info, config->get_float(userdata, "depth", &wah->depth, 0.7f); config->get_float(userdata, "resonance", &wah->res, 2.5f); - wah->lfoskip = wah->freq * 2.0 * M_PI / info->input_rate; - wah->phase = wah->startphase * M_PI / 180.0; + wah->lfoskip = wah->freq * 2.0f * M_PI / info->input_rate; + wah->phase = wah->startphase * M_PI / 180.0f; return wah; } diff --git a/libretro-common/encodings/encoding_base64.c b/libretro-common/encodings/encoding_base64.c index fcadf284c3..eb4224367a 100644 --- a/libretro-common/encodings/encoding_base64.c +++ b/libretro-common/encodings/encoding_base64.c @@ -68,24 +68,17 @@ const static unsigned char unb64[]={ */ char* base64(const void* binaryData, int len, int *flen) { - const unsigned char* bin = (const unsigned char*) binaryData; char* res; - - int rc = 0; /* result counter */ int byteNo; /* I need this after the loop */ - - int modulusLen = len % 3 ; - + const unsigned char* bin = (const unsigned char*) binaryData; + int rc = 0; /* result counter */ + int modulusLen = len % 3 ; /* 2 gives 1 and 1 gives 2, but 0 gives 0. */ - int pad = ((modulusLen&1)<<1) + ((modulusLen&2)>>1); + int pad = ((modulusLen&1)<<1) + ((modulusLen&2)>>1); - *flen = 4*(len + pad)/3; - res = (char*) malloc(*flen + 1); /* and one for the null */ - if (!res) - { - /* ERROR: base64 could not allocate enough memory. */ + *flen = 4*(len + pad)/3; + if (!(res = (char*) malloc(*flen + 1))) /* and one for the NULL */ return 0; - } for (byteNo=0; byteNo <= len-3; byteNo+=3) { @@ -120,34 +113,29 @@ char* base64(const void* binaryData, int len, int *flen) unsigned char* unbase64(const char* ascii, int len, int *flen) { - const unsigned char *safeAsciiPtr = (const unsigned char*) ascii; - unsigned char *bin; - int cb = 0; int charNo; + unsigned char *bin; + const unsigned char *safeAsciiPtr = (const unsigned char*) ascii; + int cb = 0; int pad = 0; - if (len < 2) { /* 2 accesses below would be OOB. */ + if (len < 2) /* 2 accesses below would be OOB (Out Of Bounds). */ + { /* catch empty string, return NULL as result. */ - /* ERROR: You passed an invalid base64 string (too short). * You get NULL back. */ *flen = 0; return 0; } - if(safeAsciiPtr[len-1]=='=') + if (safeAsciiPtr[len-1]=='=') ++pad; - if(safeAsciiPtr[len-2]=='=') + if (safeAsciiPtr[len-2]=='=') ++pad; *flen = 3*len/4 - pad; - bin = (unsigned char*)malloc(*flen); - - if (!bin) - { - /* ERROR: unbase64 could not allocate enough memory. */ + if (!(bin = (unsigned char*)malloc(*flen))) return 0; - } for (charNo=0; charNo <= len-4-pad; charNo+=4) { diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 83d2001bd8..0cf619d311 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -165,12 +165,12 @@ static void dump_content(RFILE *file, const void *frame, { /* BGR24 byte order input matches output. Can directly copy, but... need to make sure we pad it. */ uint32_t zeros = 0; - int pad = (int)(line_size-pitch); + int padding = (int)(line_size-pitch); for (j = 0; j < height; j++, u.u8 += pitch) { filestream_write(file, u.u8, pitch); - if(pad != 0) - filestream_write(file, &zeros, pad); + if (padding != 0) + filestream_write(file, &zeros, padding); } } break; @@ -184,8 +184,7 @@ static void dump_content(RFILE *file, const void *frame, } /* allocate line buffer, and initialize the final four bytes to zero, for deterministic padding */ - line = (uint8_t*)malloc(line_size); - if (!line) + if (!(line = (uint8_t*)malloc(line_size))) return; *(uint32_t*)(line + line_size - 4) = 0; diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index 1c2caeabba..eea41caf70 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -118,7 +118,7 @@ rxml_document_t *rxml_load_document(const char *path) error: free(memory_buffer); - if(file) + if (file) filestream_close(file); return NULL; } diff --git a/libretro-common/include/gfx/math/vector_2.h b/libretro-common/include/gfx/math/vector_2.h index 6efbf2818e..7a989fc004 100644 --- a/libretro-common/include/gfx/math/vector_2.h +++ b/libretro-common/include/gfx/math/vector_2.h @@ -75,22 +75,22 @@ static INLINE int16_t tofloat16(float f) e = ((i >> 23) & 0x000000ff) - (127 - 15); m = i & 0x007fffff; - if(e <= 0) + if (e <= 0) { - if(e < -10) + if (e < -10) return (int16_t)(s); m = (m | 0x00800000) >> (1 - e); - if(m & 0x00001000) + if (m & 0x00001000) m += 0x00002000; return (int16_t)(s | (m >> 13)); } - if(e == 0xff - (127 - 15)) + if (e == 0xff - (127 - 15)) { - if(m == 0) + if (m == 0) return (int16_t)(s | 0x7c00); m >>= 13; @@ -98,11 +98,11 @@ static INLINE int16_t tofloat16(float f) return (int16_t)(s | 0x7c00 | m | (m == 0)); } - if(m & 0x00001000) + if (m & 0x00001000) { m += 0x00002000; - if(m & 0x00800000) + if (m & 0x00800000) { m = 0; e += 1; diff --git a/libretro-common/libco/aarch64.c b/libretro-common/libco/aarch64.c index eef31a3f6e..516443fd03 100644 --- a/libretro-common/libco/aarch64.c +++ b/libretro-common/libco/aarch64.c @@ -66,19 +66,20 @@ static void crash(void) cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { - size = (size + 1023) & ~1023; + uint64_t *ptr = NULL; cothread_t handle = 0; + size = (size + 1023) & ~1023; #if HAVE_POSIX_MEMALIGN >= 1 if (posix_memalign(&handle, 1024, size + 512) < 0) return 0; #else - handle = memalign(1024, size + 512); + handle = memalign(1024, size + 512); #endif if (!handle) return handle; - uint64_t *ptr = (uint64_t*)handle; + ptr = (uint64_t*)handle; /* Non-volatiles. */ ptr[0] = 0; /* x8 */ ptr[1] = 0; /* x9 */ diff --git a/libretro-common/libco/amd64.c b/libretro-common/libco/amd64.c index 124c319761..54b1abf6d8 100644 --- a/libretro-common/libco/amd64.c +++ b/libretro-common/libco/amd64.c @@ -20,7 +20,7 @@ extern "C" { static thread_local long long co_active_buffer[64]; static thread_local cothread_t co_active_handle = 0; #ifndef CO_USE_INLINE_ASM -static void (*co_swap)(cothread_t, cothread_t) = 0; +static void (*co_swap)(cothread_t, cothread_t) = 0; #endif #ifdef _WIN32 @@ -137,9 +137,8 @@ cothread_t co_active(void) cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { cothread_t handle; - #ifndef CO_USE_INLINE_ASM - if(!co_swap) + if (!co_swap) { co_init(); co_swap = (void (*)(cothread_t, cothread_t))co_swap_function; @@ -152,15 +151,15 @@ cothread_t co_create(unsigned int size, void (*entrypoint)(void)) size &= ~15; /* align stack to 16-byte boundary */ #ifdef __GENODE__ - if((handle = (cothread_t)genode_alloc_secondary_stack(size))) + if ((handle = (cothread_t)genode_alloc_secondary_stack(size))) { - long long *p = (long long*)((char*)handle); /* OS returns top of stack */ - *--p = (long long)crash; /* crash if entrypoint returns */ - *--p = (long long)entrypoint; /* start of function */ - *(long long*)handle = (long long)p; /* stack pointer */ + long long *p = (long long*)((char*)handle); /* OS returns top of stack */ + *--p = (long long)crash; /* crash if entrypoint returns */ + *--p = (long long)entrypoint; /* start of function */ + *(long long*)handle = (long long)p; /* stack pointer */ } #else - if((handle = (cothread_t)malloc(size))) + if ((handle = (cothread_t)malloc(size))) { long long *p = (long long*)((char*)handle + size); /* seek to top of stack */ *--p = (long long)crash; /* crash if entrypoint returns */ diff --git a/libretro-common/libco/armeabi.c b/libretro-common/libco/armeabi.c index 3f0ea1a30c..d3efd40f08 100644 --- a/libretro-common/libco/armeabi.c +++ b/libretro-common/libco/armeabi.c @@ -58,8 +58,9 @@ void co_switch_arm(cothread_t handle, cothread_t current); cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { - size = (size + 1023) & ~1023; + uint32_t *ptr = NULL; cothread_t handle = 0; + size = (size + 1023) & ~1023; #if defined(__APPLE__) || HAVE_POSIX_MEMALIGN >= 1 if (posix_memalign(&handle, 1024, size + 256) < 0) return 0; @@ -70,7 +71,7 @@ cothread_t co_create(unsigned int size, void (*entrypoint)(void)) if (!handle) return handle; - uint32_t *ptr = (uint32_t*)handle; + ptr = (uint32_t*)handle; /* Non-volatiles. */ ptr[0] = 0; /* r4 */ ptr[1] = 0; /* r5 */ diff --git a/libretro-common/libco/fiber.c b/libretro-common/libco/fiber.c index 9e630894fa..d745926066 100644 --- a/libretro-common/libco/fiber.c +++ b/libretro-common/libco/fiber.c @@ -24,7 +24,7 @@ static void __stdcall co_thunk(void *coentry) cothread_t co_active(void) { - if(!co_active_) + if (!co_active_) { #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) ConvertThreadToFiberEx(0, FIBER_FLAG_FLOAT_SWITCH); @@ -38,7 +38,7 @@ cothread_t co_active(void) cothread_t co_create(unsigned int heapsize, void (*coentry)(void)) { - if(!co_active_) + if (!co_active_) { #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) ConvertThreadToFiberEx(0, FIBER_FLAG_FLOAT_SWITCH); diff --git a/libretro-common/libco/genode.cpp b/libretro-common/libco/genode.cpp index 2f2bdac52a..f1d671ad41 100644 --- a/libretro-common/libco/genode.cpp +++ b/libretro-common/libco/genode.cpp @@ -13,13 +13,15 @@ extern "C" void *genode_alloc_secondary_stack(unsigned long stack_size) { - try { - return Genode::Thread::myself()->alloc_secondary_stack("libco", stack_size); } - catch (...) { + try + { + return Genode::Thread::myself()->alloc_secondary_stack("libco", stack_size); + } + catch (...) + { Genode::error("libco: failed to allocate ", stack_size, " byte secondary stack"); return nullptr; } - } extern "C" diff --git a/libretro-common/libco/ppc.c b/libretro-common/libco/ppc.c index 391f7218e8..88faed611b 100644 --- a/libretro-common/libco/ppc.c +++ b/libretro-common/libco/ppc.c @@ -16,8 +16,8 @@ floating-point and AltiVec save/restore */ #define LIBCO_MPROTECT (__unix__ && !LIBCO_PPC_ASM) #if LIBCO_MPROTECT - #include - #include +#include +#include #endif /* State format (offsets in 32-bit words) @@ -58,8 +58,8 @@ or are directly to function */ #endif /* Swap code is in ppc.S */ - void co_swap_asm( cothread_t, cothread_t ); - #define CO_SWAP_ASM( x, y ) co_swap_asm( x, y ) + void co_swap_asm(cothread_t, cothread_t); + #define CO_SWAP_ASM(x, y) co_swap_asm(x, y) #else @@ -272,122 +272,118 @@ static const uint32_t libco_ppc_code [] = { #if LIBCO_PPCDESC /* Function call goes through indirect descriptor */ - #define CO_SWAP_ASM( x, y ) \ - ((void (*)( cothread_t, cothread_t )) (uintptr_t) x)( x, y ) + #define CO_SWAP_ASM(x, y) \ + ((void (*)(cothread_t, cothread_t)) (uintptr_t) x)(x, y) #else /* Function call goes directly to code */ - #define CO_SWAP_ASM( x, y ) \ - ((void (*)( cothread_t, cothread_t )) (uintptr_t) libco_ppc_code)( x, y ) + #define CO_SWAP_ASM(x, y) \ + ((void (*)(cothread_t, cothread_t)) (uintptr_t) libco_ppc_code)(x, y) #endif #endif -static uint32_t* co_create_( unsigned size, uintptr_t entry ) +static uint32_t* co_create_( unsigned size, uintptr_t entry) { - uint32_t* t = (uint32_t*) malloc( size ); + uint32_t *t = (uint32_t*)malloc(size); - (void) entry; +#if LIBCO_PPCDESC + if (t) + { + /* Copy entry's descriptor */ + memcpy(t, (void*)entry, sizeof(void*) * 3); - #if LIBCO_PPCDESC - if ( t ) - { - /* Copy entry's descriptor */ - memcpy( t, (void*) entry, sizeof (void*) * 3 ); - - /* Set function pointer to swap routine */ - #ifdef LIBCO_PPC_ASM - *(const void**) t = *(void**) &co_swap_asm; - #else - *(const void**) t = libco_ppc_code; - #endif - } + /* Set function pointer to swap routine */ +#ifdef LIBCO_PPC_ASM + *(const void**) t = *(void**) &co_swap_asm; +#else + *(const void**) t = libco_ppc_code; +#endif + } #endif return t; } -cothread_t co_create( unsigned int size, void (*entry_)( void ) ) +cothread_t co_create(unsigned int size, void (*entry_)(void)) { uintptr_t entry = (uintptr_t) entry_; - uint32_t* t = NULL; + uint32_t *t = NULL; /* Be sure main thread was successfully allocated */ - if ( co_active() ) + if (co_active()) { size += state_size + above_stack + stack_align; - t = co_create_( size, entry ); + t = co_create_(size, entry); } - if ( t ) - { - uintptr_t sp; - int shift; + if (t) + { + uintptr_t sp; +#if LIBCO_PPC64 + int shift = 16; +#else + int shift = 0; +#endif + /* Save current registers into new thread, so that any special ones will + have proper values when thread is begun */ + CO_SWAP_ASM(t, t); - /* Save current registers into new thread, so that any special ones will - have proper values when thread is begun */ - CO_SWAP_ASM( t, t ); +#if LIBCO_PPCDESC + /* Get real address */ + entry = (uintptr_t) *(void**)entry; +#endif - #if LIBCO_PPCDESC - /* Get real address */ - entry = (uintptr_t) *(void**) entry; - #endif + /* Put stack near end of block, and align */ + sp = (uintptr_t) t + size - above_stack; + sp -= sp % stack_align; - /* Put stack near end of block, and align */ - sp = (uintptr_t) t + size - above_stack; - sp -= sp % stack_align; + /* On PPC32, we save and restore GPRs as 32 bits. For PPC64, we + save and restore them as 64 bits, regardless of the size the ABI + uses. So, we manually write pointers at the proper size. We always + save and restore at the same address, and since PPC is big-endian, + we must put the low byte first on PPC32. */ - /* On PPC32, we save and restore GPRs as 32 bits. For PPC64, we - save and restore them as 64 bits, regardless of the size the ABI - uses. So, we manually write pointers at the proper size. We always - save and restore at the same address, and since PPC is big-endian, - we must put the low byte first on PPC32. */ + /* If uintptr_t is 32 bits, >>32 is undefined behavior, so we do two shifts + and don't have to care how many bits uintptr_t is. */ - /* If uintptr_t is 32 bits, >>32 is undefined behavior, so we do two shifts - and don't have to care how many bits uintptr_t is. */ - #if LIBCO_PPC64 - shift = 16; - #else - shift = 0; - #endif + /* Set up so entry will be called on next swap */ + t [8] = (uint32_t) (entry >> shift >> shift); + t [9] = (uint32_t) entry; - /* Set up so entry will be called on next swap */ - t [8] = (uint32_t) (entry >> shift >> shift); - t [9] = (uint32_t) entry; - - t [10] = (uint32_t) (sp >> shift >> shift); - t [11] = (uint32_t) sp; - } + t [10] = (uint32_t) (sp >> shift >> shift); + t [11] = (uint32_t) sp; + } return t; } -void co_delete( cothread_t t ) +void co_delete(cothread_t t) { free(t); } -static void co_init_( void ) +static void co_init_(void) { #if LIBCO_MPROTECT /* TODO: pre- and post-pad PPC code so that this doesn't make other data executable and writable */ - long page_size = sysconf( _SC_PAGESIZE ); - if ( page_size > 0 ) + long page_size = sysconf(_SC_PAGESIZE); + if (page_size > 0) { uintptr_t align = page_size; uintptr_t begin = (uintptr_t) libco_ppc_code; uintptr_t end = begin + sizeof libco_ppc_code; /* Align beginning and end */ - end += align - 1; - end -= end % align; - begin -= begin % align; + end += align - 1; + end -= end % align; + begin -= begin % align; - mprotect( (void*) begin, end - begin, PROT_READ | PROT_WRITE | PROT_EXEC ); + mprotect((void*)begin, end - begin, PROT_READ | PROT_WRITE | PROT_EXEC); } #endif - co_active_handle = co_create_( state_size, (uintptr_t) &co_switch ); + co_active_handle = co_create_(state_size, (uintptr_t) &co_switch); } cothread_t co_active(void) @@ -400,8 +396,7 @@ cothread_t co_active(void) void co_switch(cothread_t t) { - cothread_t old = co_active_handle; + cothread_t old = co_active_handle; co_active_handle = t; - - CO_SWAP_ASM( t, old ); + CO_SWAP_ASM(t, old); } diff --git a/libretro-common/libco/ps2.c b/libretro-common/libco/ps2.c index 65a9c09864..78bc91516a 100644 --- a/libretro-common/libco/ps2.c +++ b/libretro-common/libco/ps2.c @@ -19,48 +19,41 @@ cothread_t co_active() cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { - /* Similar scenario as with active_thread_id except there will only be one active_thread_id while there could be many - * new threads each with their own handle, so we create them on the heap instead and delete them manually when they're - * no longer needed in co_delete(). - */ - cothread_t handle = malloc(sizeof(cothread_t)); - ee_thread_t thread; + /* Similar scenario as with active_thread_id except there will only be one active_thread_id while there could be many + * new threads each with their own handle, so we create them on the heap instead and delete them manually when they're + * no longer needed in co_delete(). + */ + ee_thread_t thread; + int32_t new_thread_id; + cothread_t handle = malloc(sizeof(cothread_t)); + void *threadStack = (void *)malloc(size); - // u8 threadStack[size/8] __attribute__ ((aligned(16))); - void *threadStack = (void *)malloc(size); + if (!threadStack) + return -1; - if ( threadStack== NULL) - { - printf("libco: ERROR: creating threadStack\n"); - return(-1); - } + thread.stack_size = size; + thread.gp_reg = &_gp; + thread.func = (void *)entrypoint; + thread.stack = threadStack; + thread.option = 0; + thread.initial_priority = 1; - thread.stack_size = size; - thread.gp_reg = &_gp; - thread.func = (void *)entrypoint; - thread.stack = threadStack; - thread.option = 0; - thread.initial_priority = 1; - - int32_t new_thread_id = CreateThread(&thread); - if (new_thread_id < 0) - printf("libco: ERROR: creating thread\n"); - - StartThread(new_thread_id, NULL); - *(uint32_t *)handle = new_thread_id; - return handle; + new_thread_id = CreateThread(&thread); + StartThread(new_thread_id, NULL); + *(uint32_t *)handle = new_thread_id; + return handle; } void co_delete(cothread_t handle) { - TerminateThread(*(uint32_t *)handle); - DeleteThread(*(uint32_t *)handle); - free(handle); + TerminateThread(*(uint32_t *)handle); + DeleteThread(*(uint32_t *)handle); + free(handle); } void co_switch(cothread_t handle) { - WakeupThread(*(uint32_t *)handle); - /* Sleep the currently active thread so the new thread can start */ - SleepThread(); + WakeupThread(*(uint32_t *)handle); + /* Sleep the currently active thread so the new thread can start */ + SleepThread(); } diff --git a/libretro-common/libco/psp1.c b/libretro-common/libco/psp1.c index 75a71c22e7..18914a2168 100644 --- a/libretro-common/libco/psp1.c +++ b/libretro-common/libco/psp1.c @@ -6,9 +6,9 @@ typedef void (*entrypoint_t)(void); -cothread_t co_active() +cothread_t co_active(void) { - return (void *) sceKernelGetThreadId(); + return (void *)sceKernelGetThreadId(); } static int thread_wrap(unsigned int argc, void *argp) diff --git a/libretro-common/libco/psp2.c b/libretro-common/libco/psp2.c index d45568992d..82271bdf43 100644 --- a/libretro-common/libco/psp2.c +++ b/libretro-common/libco/psp2.c @@ -45,24 +45,21 @@ extern "C" { if (block < 0) return; - /* get base address */ - ret = sceKernelGetMemBlockBase(block, &base); - if (ret < 0) + /* Get base address */ + if ((ret = sceKernelGetMemBlockBase(block, &base)) < 0) return; - /* set domain to be writable by user */ - ret = sceKernelOpenVMDomain(); - if (ret < 0) + /* Set domain to be writable by user */ + if ((ret = sceKernelOpenVMDomain()) < 0) return; memcpy(base, co_swap_function, sizeof co_swap_function); - /* set domain back to read-only */ - ret = sceKernelCloseVMDomain(); - if (ret < 0) + /* Set domain back to read-only */ + if ((ret = sceKernelCloseVMDomain()) < 0) return; - /* flush icache */ + /* Flush icache */ ret = sceKernelSyncVMDomain(block, base, MB_ALIGN(FOUR_KB_ALIGN(sizeof co_swap_function))); if (ret < 0) @@ -73,7 +70,8 @@ extern "C" { cothread_t co_active(void) { - if (!co_active_handle) co_active_handle = &co_active_buffer; + if (!co_active_handle) + co_active_handle = &co_active_buffer; return co_active_handle; } @@ -82,15 +80,16 @@ extern "C" { unsigned long* handle = 0; if (!co_swap) co_init(); - if (!co_active_handle) co_active_handle = &co_active_buffer; - size += 256; - size &= ~15; + if (!co_active_handle) + co_active_handle = &co_active_buffer; + size += 256; + size &= ~15; if ((handle = (unsigned long*)malloc(size))) { - unsigned long* p = (unsigned long*)((unsigned char*)handle + size); - handle[8] = (unsigned long)p; - handle[9] = (unsigned long)entrypoint; + unsigned long *p = (unsigned long*)((unsigned char*)handle + size); + handle[8] = (unsigned long)p; + handle[9] = (unsigned long)entrypoint; } return handle; diff --git a/libretro-common/libco/scefiber.c b/libretro-common/libco/scefiber.c index 11f521d607..0a2407301b 100644 --- a/libretro-common/libco/scefiber.c +++ b/libretro-common/libco/scefiber.c @@ -15,18 +15,17 @@ extern "C" { static thread_local cothread_t co_active_ = 0; -typedef struct SceFiber { +typedef struct SceFiber +{ char reserved[128]; } SceFiber __attribute__( ( aligned ( 8 ) ) ) ; -int32_t _sceFiberInitializeImpl(SceFiber* fiber, char* name, void* entry, uint32_t argOnInitialize, void* addrContext, int32_t sizeContext, void* params); - +/* Forward declarations */ +int32_t _sceFiberInitializeImpl(SceFiber *fiber, char *name, void *entry, uint32_t argOnInitialize, + void* addrContext, int32_t sizeContext, void* params); int32_t sceFiberFinalize(SceFiber* fiber); - int32_t sceFiberRun(SceFiber* fiber, uint32_t argOnRunTo, uint32_t* argOnRun); - int32_t sceFiberSwitch(SceFiber* fiber, uint32_t argOnRunTo, uint32_t* argOnRun); - int32_t sceFiberReturnToThread(uint32_t argOnReturn, uint32_t* argOnRun); static void co_thunk(uint32_t argOnInitialize, uint32_t argOnRun) @@ -36,9 +35,9 @@ static void co_thunk(uint32_t argOnInitialize, uint32_t argOnRun) cothread_t co_active(void) { - if(!co_active_) + if (!co_active_) { - sceSysmoduleLoadModule(SCE_SYSMODULE_FIBER); + sceSysmoduleLoadModule(SCE_SYSMODULE_FIBER); co_active_ = (cothread_t)1; } return co_active_; @@ -46,48 +45,45 @@ cothread_t co_active(void) cothread_t co_create(unsigned int heapsize, void (*coentry)(void)) { - SceFiber* tailFiber = malloc(sizeof(SceFiber)); - char * m_contextBuffer = malloc(sizeof(char)*heapsize); - if(!co_active_) + int ret; + SceFiber* tail_fiber = malloc(sizeof(SceFiber)); + char * m_ctxbuf = malloc(sizeof(char)*heapsize); + if (!co_active_) { sceSysmoduleLoadModule(SCE_SYSMODULE_FIBER); - co_active_ = (cothread_t)1; - } - - //_sceFiberInitializeImpl - int ret = _sceFiberInitializeImpl(tailFiber, "tailFiber", co_thunk, (uint32_t)coentry, (void*) m_contextBuffer, heapsize, NULL); - if(ret==0){ - return (cothread_t)tailFiber; - }else{ - return (cothread_t)ret; + co_active_ = (cothread_t)1; } + /* _sceFiberInitializeImpl */ + if ((ret = _sceFiberInitializeImpl( + tail_fiber, "tailFiber", co_thunk, + (uint32_t)coentry, (void*)m_ctxbuf, heapsize, NULL)) == 0) + return (cothread_t)tail_fiber; + return (cothread_t)ret; } void co_delete(cothread_t cothread) { - if(cothread == (cothread_t)1){ - return; - } - sceFiberFinalize((SceFiber*)cothread); + if (cothread != (cothread_t)1) + sceFiberFinalize((SceFiber*)cothread); } void co_switch(cothread_t cothread) { - - uint32_t argOnReturn = 0; - if(cothread == (cothread_t)1){ - co_active_ = cothread; - sceFiberReturnToThread(0, NULL); - }else{ - SceFiber* theFiber = (SceFiber*)cothread; - if(co_active_ == (cothread_t)1){ - co_active_ = cothread; - sceFiberRun(theFiber, 0, &argOnReturn); - }else{ - co_active_ = cothread; - sceFiberSwitch(theFiber, 0, &argOnReturn); - } + uint32_t argOnReturn = 0; + if (cothread == (cothread_t)1) + { + co_active_ = cothread; + sceFiberReturnToThread(0, NULL); + } + else + { + SceFiber* theFiber = (SceFiber*)cothread; + co_active_ = cothread; + if (co_active_ == (cothread_t)1) + sceFiberRun(theFiber, 0, &argOnReturn); + else + sceFiberSwitch(theFiber, 0, &argOnReturn); } } diff --git a/libretro-common/libco/sjlj.c b/libretro-common/libco/sjlj.c index bb6513675b..c661d15016 100644 --- a/libretro-common/libco/sjlj.c +++ b/libretro-common/libco/sjlj.c @@ -33,7 +33,7 @@ static thread_local cothread_struct *creating, *co_running = 0; static void springboard(int ignored) { - if(sigsetjmp(creating->context, 0)) + if (sigsetjmp(creating->context, 0)) co_running->coentry(); } @@ -46,42 +46,40 @@ cothread_t co_active(void) cothread_t co_create(unsigned int size, void (*coentry)(void)) { - if(!co_running) + cothread_struct *thread; + if (!co_running) co_running = &co_primary; - cothread_struct *thread = (cothread_struct*)malloc(sizeof(cothread_struct)); - - if(thread) + if ((thread = (cothread_struct*)malloc(sizeof(cothread_struct)))) { stack_t stack; stack_t old_stack; - struct sigaction handler = {{0}}; - struct sigaction old_handler = {{0}}; - thread->coentry = thread->stack = 0; - stack.ss_flags = 0; - stack.ss_size = size; - thread->stack = stack.ss_sp = malloc(size); + stack.ss_flags = 0; + stack.ss_size = size; + thread->stack = stack.ss_sp = malloc(size); - if(stack.ss_sp && !sigaltstack(&stack, &old_stack)) + if (stack.ss_sp && !sigaltstack(&stack, &old_stack)) { - handler.sa_handler = springboard; - handler.sa_flags = SA_ONSTACK; + struct sigaction old_handler = {{0}}; + struct sigaction handler = {{0}}; + handler.sa_handler = springboard; + handler.sa_flags = SA_ONSTACK; sigemptyset(&handler.sa_mask); - creating = thread; + creating = thread; - if(!sigaction(SIGUSR1, &handler, &old_handler)) + if (!sigaction(SIGUSR1, &handler, &old_handler)) { - if(!raise(SIGUSR1)) - thread->coentry = coentry; + if (!raise(SIGUSR1)) + thread->coentry = coentry; sigaltstack(&old_stack, 0); sigaction(SIGUSR1, &old_handler, 0); } } - if(thread->coentry != coentry) + if (thread->coentry != coentry) { co_delete(thread); thread = 0; @@ -95,7 +93,7 @@ void co_delete(cothread_t cothread) { if (cothread) { - if(((cothread_struct*)cothread)->stack) + if (((cothread_struct*)cothread)->stack) free(((cothread_struct*)cothread)->stack); free(cothread); } diff --git a/libretro-common/libco/ucontext.c b/libretro-common/libco/ucontext.c index 3e21816023..949273d506 100644 --- a/libretro-common/libco/ucontext.c +++ b/libretro-common/libco/ucontext.c @@ -37,13 +37,13 @@ cothread_t co_active(void) cothread_t co_create(unsigned int heapsize, void (*coentry)(void)) { + ucontext_t *thread; if (!co_running) co_running = &co_primary; - ucontext_t *thread = (ucontext_t*)malloc(sizeof(ucontext_t)); - if(thread) + if ((thread = (ucontext_t*)malloc(sizeof(ucontext_t)))) { - if((!getcontext(thread) && !(thread->uc_stack.ss_sp = 0)) && (thread->uc_stack.ss_sp = malloc(heapsize))) + if ((!getcontext(thread) && !(thread->uc_stack.ss_sp = 0)) && (thread->uc_stack.ss_sp = malloc(heapsize))) { thread->uc_link = co_running; thread->uc_stack.ss_size = heapsize; @@ -63,7 +63,7 @@ void co_delete(cothread_t cothread) if (!cothread) return; - if(((ucontext_t*)cothread)->uc_stack.ss_sp) + if (((ucontext_t*)cothread)->uc_stack.ss_sp) free(((ucontext_t*)cothread)->uc_stack.ss_sp); free(cothread); } @@ -71,8 +71,7 @@ void co_delete(cothread_t cothread) void co_switch(cothread_t cothread) { ucontext_t *old_thread = co_running; - - co_running = (ucontext_t*)cothread; + co_running = (ucontext_t*)cothread; swapcontext(old_thread, co_running); } diff --git a/libretro-common/libco/x86.c b/libretro-common/libco/x86.c index 1a1d01d0d8..24e5aa6ce2 100644 --- a/libretro-common/libco/x86.c +++ b/libretro-common/libco/x86.c @@ -70,7 +70,7 @@ static void crash(void) cothread_t co_active(void) { - if(!co_active_handle) + if (!co_active_handle) co_active_handle = &co_active_buffer; return co_active_handle; } @@ -78,24 +78,24 @@ cothread_t co_active(void) cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { cothread_t handle; - if(!co_swap) + if (!co_swap) { co_init(); co_swap = (void (fastcall*)(cothread_t, cothread_t))co_swap_function; } - if(!co_active_handle) + if (!co_active_handle) co_active_handle = &co_active_buffer; size += 256; /* allocate additional space for storage */ size &= ~15; /* align stack to 16-byte boundary */ - if((handle = (cothread_t)malloc(size))) + if ((handle = (cothread_t)malloc(size))) { - long *p = (long*)((char*)handle + size); /* seek to top of stack */ - *--p = (long)crash; /* crash if entrypoint returns */ - *--p = (long)entrypoint; /* start of function */ - *(long*)handle = (long)p; /* stack pointer */ + long *p = (long*)((char*)handle + size); /* seek to top of stack */ + *--p = (long)crash; /* crash if entrypoint returns */ + *--p = (long)entrypoint; /* start of function */ + *(long*)handle = (long)p; /* stack pointer */ } return handle; diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 0bf5a6557d..e291bbee90 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -189,7 +189,7 @@ struct hostent *gethostbyname(const char *name) return NULL; rid = sceNetResolverCreate("resolver", NULL, 0); - if(rid < 0) + if (rid < 0) return NULL; if (sceNetResolverStartNtoa(rid, name, &addr, 0, 0, 0) < 0) diff --git a/libretro-common/rthreads/ctr_pthread.h b/libretro-common/rthreads/ctr_pthread.h index 88b359d4e9..5582af1a9d 100644 --- a/libretro-common/rthreads/ctr_pthread.h +++ b/libretro-common/rthreads/ctr_pthread.h @@ -242,7 +242,7 @@ static INLINE int pthread_detach(pthread_t thread) static INLINE int pthread_join(pthread_t thread, void **retval) { /*retval is ignored*/ - if(threadJoin((Thread)thread, INT64_MAX)) + if (threadJoin((Thread)thread, INT64_MAX)) return -1; threadFree((Thread)thread); diff --git a/libretro-common/rthreads/psp_pthread.h b/libretro-common/rthreads/psp_pthread.h index a1571863fd..f320969db2 100644 --- a/libretro-common/rthreads/psp_pthread.h +++ b/libretro-common/rthreads/psp_pthread.h @@ -96,7 +96,7 @@ static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, #ifdef VITA *mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0); - if(*mutex<0) + if (*mutex<0) return *mutex; return 0; #else @@ -220,13 +220,13 @@ static INLINE int pthread_cond_init(pthread_cond_t *cond, pthread_mutex_init(&cond->mutex,NULL); - if(cond->mutex<0) + if (cond->mutex<0) return cond->mutex; snprintf(name_buffer, sizeof(name_buffer), "0x%08X", (unsigned int) cond); cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0); - if(cond->sema < 0) + if (cond->sema < 0) { pthread_mutex_destroy(&cond->mutex); return cond->sema; @@ -269,7 +269,7 @@ static INLINE int pthread_cond_destroy(pthread_cond_t *cond) { #ifdef VITA int ret = sceKernelDeleteSema(cond->sema); - if(ret < 0) + if (ret < 0) return ret; return sceKernelDeleteMutex(cond->mutex); diff --git a/memory/wii/mem2_manager.c b/memory/wii/mem2_manager.c index f142c79769..9361e863fc 100644 --- a/memory/wii/mem2_manager.c +++ b/memory/wii/mem2_manager.c @@ -53,7 +53,7 @@ static uint32_t __lwp_heap_block_size(heap_cntrl *theheap, void *ptr) _CPU_ISR_Disable(level); block = __lwp_heap_usrblockat(ptr); - if(!__lwp_heap_blockin(theheap, block) || __lwp_heap_blockfree(block)) + if (!__lwp_heap_blockin(theheap, block) || __lwp_heap_blockfree(block)) { _CPU_ISR_Restore(level); return 0; @@ -101,7 +101,7 @@ bool gx_init_mem2(void) void *_mem2_memalign(uint8_t align, uint32_t size) { - if(size == 0) + if (size == 0) return NULL; return __lwp_heap_allocate(&gx_mem2_heap, size); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 29fa9962eb..8bc2e42c7c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -12795,7 +12795,7 @@ static bool setting_append_list( END_SUB_GROUP(list, list_info, parent_group); - if(video_driver_supports_hdr()) + if (video_driver_supports_hdr()) { START_SUB_GROUP(list, list_info, "HDR", &group_info, &subgroup_info, parent_group); diff --git a/retroarch.c b/retroarch.c index 2f94951c0a..5f18c27ab1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5910,7 +5910,8 @@ static bool retroarch_parse_input_and_config( if (runloop_st->entry_state_slot) { input_driver_state_t *input_st = input_state_get_ptr(); - if(input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_PLAYBACK) { + if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_PLAYBACK) + { runloop_st->entry_state_slot = 0; RARCH_WARN("Trying to load entry state while BSV playback is active. Ignoring entry state.\n"); } diff --git a/runloop.c b/runloop.c index c89c2baccd..60d1f08a14 100644 --- a/runloop.c +++ b/runloop.c @@ -4108,12 +4108,12 @@ static bool event_init_content( #ifdef HAVE_BSV_MOVIE movie_stop(input_st); - if(input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_RECORDING) + if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_RECORDING) { configuration_set_uint(settings, settings->uints.rewind_granularity, 1); movie_start_record(input_st, input_st->bsv_movie_state.movie_start_path); } - else if(input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_PLAYBACK) + else if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_START_PLAYBACK) { configuration_set_uint(settings, settings->uints.rewind_granularity, 1); movie_start_playback(input_st, input_st->bsv_movie_state.movie_start_path); diff --git a/tasks/task_movie.c b/tasks/task_movie.c index 68dd4c5849..de71353f19 100644 --- a/tasks/task_movie.c +++ b/tasks/task_movie.c @@ -322,7 +322,7 @@ static void moviectl_start_playback_cb(retro_task_t *task, static void task_moviectl_record_handler(retro_task_t *task) { /* Hang on until the state is loaded */ - if(content_load_state_in_progress(NULL)) + if (content_load_state_in_progress(NULL)) return; /* trivial handler */ @@ -385,7 +385,7 @@ bool movie_stop_playback(input_driver_state_t *input_st) bool movie_stop_record(input_driver_state_t *input_st) { const char *movie_rec_stopped_str = msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED); - if(!(input_st->bsv_movie_state_handle)) + if (!(input_st->bsv_movie_state_handle)) return false; runloop_msg_queue_push(movie_rec_stopped_str, 2, 180, true, @@ -400,7 +400,7 @@ bool movie_stop(input_driver_state_t *input_st) { if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_PLAYBACK) return movie_stop_playback(input_st); - else if(input_st->bsv_movie_state_handle) + else if (input_st->bsv_movie_state_handle) return movie_stop_record(input_st); return true; } diff --git a/tasks/task_wifi.c b/tasks/task_wifi.c index ad5a8e5be9..0279499f2f 100644 --- a/tasks/task_wifi.c +++ b/tasks/task_wifi.c @@ -100,7 +100,8 @@ static void task_wifi_connect_handler(retro_task_t *task) task_set_finished(task, true); } -bool task_push_wifi_connect(retro_task_callback_t cb, void *netptr) { +bool task_push_wifi_connect(retro_task_callback_t cb, void *netptr) +{ char msg[128]; retro_task_t *task = task_init(); wifi_network_info_t *netinfo = (wifi_network_info_t*)netptr;