C89 cleanups part 2

This commit is contained in:
Alcaro 2015-06-26 17:46:13 +02:00
parent 7961d82e3c
commit febcbc5ce4
20 changed files with 181 additions and 158 deletions

View File

@ -128,7 +128,7 @@ enum
MENU_XMB,
RECORD_FFMPEG,
RECORD_NULL,
RECORD_NULL
};
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__)

View File

@ -852,6 +852,9 @@ static config_file_t *open_default_config_file(void)
(void)conf_path;
(void)app_path;
(void)saved;
const char *xdg; (void)xdg;
const char *home; (void)home;
#if defined(_WIN32) && !defined(_XBOX)
fill_pathname_application_path(app_path, sizeof(app_path));
@ -899,7 +902,7 @@ static config_file_t *open_default_config_file(void)
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
}
#elif defined(OSX)
const char *home = getenv("HOME");
home = getenv("HOME");
if (!home)
return NULL;
@ -935,8 +938,8 @@ static config_file_t *open_default_config_file(void)
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
}
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
const char *xdg = getenv("XDG_CONFIG_HOME");
const char *home = getenv("HOME");
xdg = getenv("XDG_CONFIG_HOME");
home = getenv("HOME");
/* XDG_CONFIG_HOME falls back to $HOME/.config. */
if (xdg)
@ -1518,9 +1521,12 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL_BASE(conf, settings, rewind_enable, "rewind_enable");
int buffer_size = 0;
if (config_get_int(conf, "rewind_buffer_size", &buffer_size))
settings->rewind_buffer_size = buffer_size * UINT64_C(1000000);
{
/* ugly hack around C89 not allowing mixing declarations and code */
int buffer_size = 0;
if (config_get_int(conf, "rewind_buffer_size", &buffer_size))
settings->rewind_buffer_size = buffer_size * UINT64_C(1000000);
}
CONFIG_GET_INT_BASE(conf, settings, rewind_granularity, "rewind_granularity");
CONFIG_GET_FLOAT_BASE(conf, settings, slowmotion_ratio, "slowmotion_ratio");
@ -1821,12 +1827,10 @@ bool config_load_override(void)
else
RARCH_LOG("No core-specific overrides found at %s.\n", core_path);
new_conf = NULL;
// Create a new config file from game_path
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
// If a game override exists, add it's location to append_config_path
/* If a game override exists, add it's location to append_config_path */
if (new_conf)
{
RARCH_LOG("Game-specific overrides found at %s. Appending.\n", game_path);

View File

@ -159,12 +159,13 @@ static dylib_t libretro_get_system_info_lib(const char *path,
struct retro_system_info *info, bool *load_no_content)
{
dylib_t lib = dylib_load(path);
void (*proc)(struct retro_system_info*);
if (!lib)
return NULL;
void (*proc)(struct retro_system_info*) =
(void (*)(struct retro_system_info*))dylib_proc(lib,
"retro_get_system_info");
proc = (void (*)(struct retro_system_info*))
dylib_proc(lib, "retro_get_system_info");
if (!proc)
{
@ -176,10 +177,10 @@ static dylib_t libretro_get_system_info_lib(const char *path,
if (load_no_content)
{
void (*set_environ)(retro_environment_t);
*load_no_content = false;
void (*set_environ)(retro_environment_t) =
(void (*)(retro_environment_t))dylib_proc(lib,
"retro_set_environment");
set_environ = (void (*)(retro_environment_t))
dylib_proc(lib, "retro_set_environment");
if (!set_environ)
return lib;
@ -735,6 +736,13 @@ bool rarch_environment_cb(unsigned cmd, void *data)
unsigned retro_id, retro_port;
const struct retro_input_descriptor *desc = NULL;
static const char *libretro_btn_desc[] = {
"B (bottom)", "Y (left)", "Select", "Start",
"D-Pad Up", "D-Pad Down", "D-Pad Left", "D-Pad Right",
"A (right)", "X (up)",
"L", "R", "L2", "R2", "L3", "R3",
};
memset(system->input_desc_btn, 0,
sizeof(system->input_desc_btn));
@ -792,13 +800,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
system->input_desc_btn[retro_port][retro_id] = desc->description;
}
static const char *libretro_btn_desc[] = {
"B (bottom)", "Y (left)", "Select", "Start",
"D-Pad Up", "D-Pad Down", "D-Pad Left", "D-Pad Right",
"A (right)", "X (up)",
"L", "R", "L2", "R2", "L3", "R3",
};
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
for (p = 0; p < settings->input.max_users; p++)
{
@ -933,11 +934,11 @@ bool rarch_environment_cb(unsigned cmd, void *data)
#if defined(HAVE_THREADS) && !defined(__CELLOS_LV2__)
case RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK:
{
RARCH_LOG("Environ SET_AUDIO_CALLBACK.\n");
const struct retro_audio_callback *info =
(const struct retro_audio_callback*)data;
RARCH_LOG("Environ SET_AUDIO_CALLBACK.\n");
if (driver->recording_data) // A/V sync is a must.
if (driver->recording_data) /* A/V sync is a must. */
return false;
#ifdef HAVE_NETPLAY

View File

@ -122,16 +122,16 @@ void fill_pathname_abbreviate_special(char *out_path,
char application_dir[PATH_MAX_LENGTH] = {0};
const char *home = getenv("HOME");
fill_pathname_application_path(application_dir, sizeof(application_dir));
path_basedir(application_dir);
/* application_dir could be zero-string. Safeguard against this.
*
* Keep application dir in front of home, moving app dir to a
* new location inside home would break otherwise. */
const char *candidates[3] = { application_dir, home, NULL };
const char *candidates[3] = { application_dir, home, NULL }; /* ugly hack - use application_dir before filling it in. C89 reasons */
const char *notations[3] = { ":", "~", NULL };
fill_pathname_application_path(application_dir, sizeof(application_dir));
path_basedir(application_dir);
for (i = 0; candidates[i]; i++)
{
@ -197,24 +197,27 @@ void fill_pathname_application_path(char *buf, size_t size)
}
}
#else
*buf = '\0';
pid_t pid = getpid();
char link_path[PATH_MAX_LENGTH] = {0};
/* Linux, BSD and Solaris paths. Not standardized. */
static const char *exts[] = { "exe", "file", "path/a.out" };
for (i = 0; i < ARRAY_SIZE(exts); i++)
{
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
(unsigned)pid, exts[i]);
ssize_t ret = readlink(link_path, buf, size - 1);
if (ret >= 0)
*buf = '\0';
pid_t pid = getpid();
char link_path[PATH_MAX_LENGTH] = {0};
/* Linux, BSD and Solaris paths. Not standardized. */
static const char *exts[] = { "exe", "file", "path/a.out" };
for (i = 0; i < ARRAY_SIZE(exts); i++)
{
buf[ret] = '\0';
return;
ssize_t ret;
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
(unsigned)pid, exts[i]);
ret = readlink(link_path, buf, size - 1);
if (ret >= 0)
{
buf[ret] = '\0';
return;
}
}
}
/* Cannot resolve application path! This should not happen. */
RARCH_ERR("Cannot resolve application path! This should not happen.");
#endif
}
#endif

View File

@ -348,13 +348,10 @@ bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state,
else
*state = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
const int pct = battery_percent;
const int secs = battery_time;
if (pct >= 0) /* -1 == unknown */
*percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
if (secs >= 0) /* -1 == unknown */
*seconds = secs;
if (battery_percent >= 0) /* -1 == unknown */
*percent = (battery_percent > 100) ? 100 : battery_percent; /* clamp between 0%, 100% */
if (battery_time >= 0) /* -1 == unknown */
*seconds = battery_time;
return true;
}
@ -464,7 +461,7 @@ static void frontend_linux_get_os(char *s, size_t len, int *major, int *minor)
if (uname(&buffer) != 0)
return;
sscanf(buffer.release, "%u.%u.%u", major, minor, &krel);
sscanf(buffer.release, "%d.%d.%d", major, minor, &krel);
strlcpy(s, "Linux", len);
}

View File

@ -66,11 +66,11 @@ static Atom XA_NET_MOVERESIZE_WINDOW;
void x11_windowed_fullscreen(Display *dpy, Window win)
{
XEvent xev = {0};
XA_INIT(_NET_WM_STATE);
XA_INIT(_NET_WM_STATE_FULLSCREEN);
XEvent xev = {0};
xev.xclient.type = ClientMessage;
xev.xclient.send_event = True;
xev.xclient.message_type = XA_NET_WM_STATE;

View File

@ -1370,37 +1370,41 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
}
}
#elif defined(HAVE_PSGL)
unsigned h;
size_t buffer_addr = gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size;
size_t buffer_stride = gl->tex_w * gl->base_size;
const uint8_t *frame_copy = frame;
size_t frame_copy_size = width * gl->base_size;
uint8_t *buffer = (uint8_t*)glMapBuffer(
GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE) + buffer_addr;
for (h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch)
memcpy(buffer, frame_copy, frame_copy_size);
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE);
#else
const GLvoid *data_buf = frame;
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(pitch));
if (gl->base_size == 2 && !gl->have_es2_compat)
{
/* Convert to 32-bit textures on desktop GL. */
gl_convert_frame_rgb16_32(gl, gl->conv_buffer,
frame, width, height, pitch);
data_buf = gl->conv_buffer;
unsigned h;
size_t buffer_addr = gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size;
size_t buffer_stride = gl->tex_w * gl->base_size;
const uint8_t *frame_copy = frame;
size_t frame_copy_size = width * gl->base_size;
uint8_t *buffer = (uint8_t*)glMapBuffer(
GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE) + buffer_addr;
for (h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch)
memcpy(buffer, frame_copy, frame_copy_size);
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE);
}
else
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / gl->base_size);
#else
{
const GLvoid *data_buf = frame;
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(pitch));
glTexSubImage2D(GL_TEXTURE_2D,
0, 0, 0, width, height, gl->texture_type,
gl->texture_fmt, data_buf);
if (gl->base_size == 2 && !gl->have_es2_compat)
{
/* Convert to 32-bit textures on desktop GL. */
gl_convert_frame_rgb16_32(gl, gl->conv_buffer,
frame, width, height, pitch);
data_buf = gl->conv_buffer;
}
else
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / gl->base_size);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexSubImage2D(GL_TEXTURE_2D,
0, 0, 0, width, height, gl->texture_type,
gl->texture_fmt, data_buf);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
#endif
RARCH_PERFORMANCE_STOP(copy_frame);
}
@ -2639,7 +2643,7 @@ static bool gl_set_shader(void *data,
{
unsigned textures = gl->shader->get_prev_textures() + 1;
if (textures > gl->textures) // Have to reinit a bit.
if (textures > gl->textures) /* Have to reinit a bit. */
{
#if defined(HAVE_FBO)
gl_deinit_hw_render(gl);

View File

@ -186,20 +186,22 @@ static void sdl2_render_msg(sdl2_video_t *vid, const char *msg)
tex_x = gly->atlas_offset_x;
tex_y = gly->atlas_offset_y;
SDL_Rect srcrect = {
tex_x, tex_y,
(int)gly->width, (int)gly->height
};
{
SDL_Rect srcrect = {
tex_x, tex_y,
(int)gly->width, (int)gly->height
};
SDL_Rect dstrect = {
x + delta_x + off_x, y + delta_y + off_y,
(int)gly->width, (int)gly->height
};
SDL_Rect dstrect = {
x + delta_x + off_x, y + delta_y + off_y,
(int)gly->width, (int)gly->height
};
SDL_RenderCopyEx(vid->renderer, vid->font.tex, &srcrect, &dstrect, 0, NULL, SDL_FLIP_NONE);
delta_x += gly->advance_x;
delta_y -= gly->advance_y;
SDL_RenderCopyEx(vid->renderer, vid->font.tex, &srcrect, &dstrect, 0, NULL, SDL_FLIP_NONE);
delta_x += gly->advance_x;
delta_y -= gly->advance_y;
}
}
}
@ -250,8 +252,9 @@ static void sdl2_init_renderer(sdl2_video_t *vid)
static void sdl_refresh_renderer(sdl2_video_t *vid)
{
SDL_Rect r;
SDL_RenderClear(vid->renderer);
SDL_Rect r = { vid->vp.x, vid->vp.y, (int)vid->vp.width, (int)vid->vp.height };
r = (SDL_Rect){ vid->vp.x, vid->vp.y, (int)vid->vp.width, (int)vid->vp.height };
SDL_RenderSetViewport(vid->renderer, &r);
/* breaks int scaling */
@ -370,6 +373,7 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp
int i;
unsigned flags;
settings_t *settings = config_get_ptr();
sdl2_video_t *vid;
#ifdef HAVE_X11
XInitThreads();
@ -383,7 +387,7 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp
else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
sdl2_video_t *vid = (sdl2_video_t*)calloc(1, sizeof(*vid));
vid = (sdl2_video_t*)calloc(1, sizeof(*vid));
if (!vid)
return NULL;

View File

@ -14,7 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
// Null context.
/* Null context. */
#include "../../driver.h"
#include "../video_context_driver.h"

View File

@ -285,18 +285,20 @@ static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
/* Save last used monitor for later. */
#ifdef HAVE_XINERAMA
XWindowAttributes target;
Window child;
{
XWindowAttributes target;
Window child;
int x = 0, y = 0;
XGetWindowAttributes(glx->g_dpy, glx->g_win, &target);
XTranslateCoordinates(glx->g_dpy, glx->g_win, DefaultRootWindow(glx->g_dpy),
target.x, target.y, &x, &y, &child);
int x = 0, y = 0;
XGetWindowAttributes(glx->g_dpy, glx->g_win, &target);
XTranslateCoordinates(glx->g_dpy, glx->g_win, DefaultRootWindow(glx->g_dpy),
target.x, target.y, &x, &y, &child);
glx->g_screen = x11_get_xinerama_monitor(glx->g_dpy, x, y,
target.width, target.height);
glx->g_screen = x11_get_xinerama_monitor(glx->g_dpy, x, y,
target.width, target.height);
RARCH_LOG("[GLX]: Saved monitor #%u.\n", glx->g_screen);
RARCH_LOG("[GLX]: Saved monitor #%u.\n", glx->g_screen);
}
#endif
XUnmapWindow(glx->g_dpy, glx->g_win);
@ -524,9 +526,9 @@ static bool gfx_ctx_glx_set_video_mode(void *data,
else
{
XMapWindow(glx->g_dpy, glx->g_win);
// If we want to map the window on a different screen, we'll have to do it by force.
// Otherwise, we should try to let the window manager sort it out.
// x_off and y_off usually get ignored in XCreateWindow().
/* If we want to map the window on a different screen, we'll have to do it by force.
* Otherwise, we should try to let the window manager sort it out.
* x_off and y_off usually get ignored in XCreateWindow(). */
if (glx->g_screen)
x11_move_window(glx->g_dpy, glx->g_win, x_off, y_off, width, height);
}

View File

@ -371,8 +371,6 @@ static bool sdl_ctx_has_focus(void *data)
unsigned flags;
driver_t *driver = driver_get_ptr();
(void)data;
#ifdef HAVE_SDL2
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;
flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS);
@ -381,6 +379,8 @@ static bool sdl_ctx_has_focus(void *data)
flags = (SDL_APPINPUTFOCUS | SDL_APPACTIVE);
return (SDL_GetAppState() & flags) == flags;
#endif
(void)data;
}
static bool sdl_ctx_suppress_screensaver(void *data, bool enable)

View File

@ -21,6 +21,7 @@
#include "../drivers/gl_common.h"
#include <wayland-client.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h>
#include <EGL/egl.h>
@ -600,14 +601,15 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
driver->video_context_data;
struct sigaction sa = {{0}};
EGLint egl_attribs[16];
EGLint *attr;
sa.sa_handler = sighandler;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
EGLint egl_attribs[16];
EGLint *attr = egl_attribs;
attr = egl_fill_attribs(attr);
wl->g_width = width ? width : DEFAULT_WINDOWED_WIDTH;
@ -667,9 +669,9 @@ static void gfx_ctx_wl_input_driver(void *data,
{
(void)data;
#if 0
//void *wl = input_wayland.init();
//*input = wl ? &input_wayland : NULL;
//*input_data = wl;
void *wl = input_wayland.init();
*input = wl ? &input_wayland : NULL;
*input_data = wl;
#endif
*input = NULL;
*input_data = NULL;

View File

@ -301,6 +301,9 @@ static bool gfx_ctx_xegl_init(void *data)
const EGLint *attrib_ptr;
EGLint egl_major, egl_minor;
EGLint num_configs;
if (g_inited)
return false;
@ -345,7 +348,6 @@ static bool gfx_ctx_xegl_init(void *data)
goto error;
}
EGLint egl_major, egl_minor;
if (!eglInitialize(g_egl_dpy, &egl_major, &egl_minor))
{
RARCH_ERR("[X/EGL]: Unable to initialize EGL.\n");
@ -355,7 +357,6 @@ static bool gfx_ctx_xegl_init(void *data)
RARCH_LOG("[X/EGL]: EGL version: %d.%d\n", egl_major, egl_minor);
EGLint num_configs;
if (!eglChooseConfig(g_egl_dpy, attrib_ptr, &g_egl_config, 1, &num_configs))
{
RARCH_ERR("[X/EGL]: eglChooseConfig failed with 0x%x.\n", eglGetError());
@ -459,6 +460,10 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
int (*old_handler)(Display*, XErrorEvent*) = NULL;
XEvent event;
sa.sa_handler = egl_sighandler;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
@ -468,8 +473,6 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
windowed_full = settings->video.windowed_fullscreen;
true_full = false;
int (*old_handler)(Display*, XErrorEvent*) = NULL;
attr = egl_attribs;
attr = xegl_fill_attribs(attr);
@ -594,7 +597,6 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
x11_move_window(g_dpy, g_win, x_off, y_off, width, height);
}
XEvent event;
XIfEvent(g_dpy, &event, egl_wait_notify, NULL);
g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False);

View File

@ -131,13 +131,14 @@ static void gl_raster_font_free_font(void *data)
static int gl_get_message_width(void *data, const char *msg, unsigned msg_len_full, float scale)
{
gl_raster_t *font = (gl_raster_t*)data;
if (!font)
return 0;
unsigned i;
unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
int delta_x = 0;
if (!font)
return 0;
while (msg_len_full)
{
for (i = 0; i < msg_len; i++)
@ -265,24 +266,26 @@ static void gl_raster_font_render_message(
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
unsigned text_align)
{
int lines = 0;
float line_height;
if (!msg || !*msg || !font->gl)
return;
//If the font height is not supported just draw as usual
/* If the font height is not supported just draw as usual */
if (!font->font_driver->get_line_height)
{
gl_raster_font_render_line(font, msg, strlen(msg), scale, color, pos_x, pos_y, text_align);
return;
}
int lines = 0;
float line_height = scale * 1/(float)font->font_driver->get_line_height(font->font_data);
line_height = scale * 1/(float)font->font_driver->get_line_height(font->font_data);
for (;;)
{
const char *delim = strchr(msg, '\n');
//Draw the line
/* Draw the line */
if (delim)
{
unsigned msg_len = delim - msg;

View File

@ -83,6 +83,7 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle)
for (i = 0; i < FT_ATLAS_SIZE; i++)
{
struct font_glyph *glyph = &handle->glyphs[i];
FT_GlyphSlot slot;
if (!glyph)
continue;
@ -94,7 +95,7 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle)
}
FT_Render_Glyph(handle->face->glyph, FT_RENDER_MODE_NORMAL);
FT_GlyphSlot slot = handle->face->glyph;
slot = handle->face->glyph;
/* Some glyphs can be blank. */
buffer[i] = (uint8_t*)calloc(slot->bitmap.rows * slot->bitmap.pitch, 1);

View File

@ -341,9 +341,11 @@ static bool compile_shader(glsl_shader_data_t *glsl,
RARCH_LOG("[GL]: Using GLSL version %u.\n", version_no);
}
const char *source[] = { version, define, glsl->glsl_alias_define, program };
glShaderSource(shader, ARRAY_SIZE(source), source, NULL);
glCompileShader(shader);
{
const char *source[] = { version, define, glsl->glsl_alias_define, program };
glShaderSource(shader, ARRAY_SIZE(source), source, NULL);
glCompileShader(shader);
}
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
print_shader_log(shader);
@ -353,9 +355,10 @@ static bool compile_shader(glsl_shader_data_t *glsl,
static bool link_program(GLuint prog)
{
GLint status;
glLinkProgram(prog);
GLint status;
glGetProgramiv(prog, GL_LINK_STATUS, &status);
print_linker_log(prog);
@ -421,8 +424,7 @@ static GLuint compile_program(glsl_shader_data_t *glsl,
glDeleteShader(frag);
glUseProgram(prog);
GLint location = get_uniform(glsl, prog, "Texture");
glUniform1i(location, 0);
glUniform1i(get_uniform(glsl, prog, "Texture"), 0);
glUseProgram(0);
}

View File

@ -46,7 +46,7 @@ enum display_metric_types
DISPLAY_METRIC_NONE = 0,
DISPLAY_METRIC_MM_WIDTH,
DISPLAY_METRIC_MM_HEIGHT,
DISPLAY_METRIC_DPI,
DISPLAY_METRIC_DPI
};
typedef void (*gfx_ctx_proc_t)(void);

View File

@ -127,17 +127,14 @@ static void gen_filter_sinc_sub(struct scaler_filter *filter,
{
filter->filter_pos[i] = pos >> 16;
//int16_t sinc_sum = 0;
for (j = 0; j < sinc_size; j++)
{
double sinc_phase = M_PI * ((double)((sinc_size << 15) + (pos & 0xffff)) / 0x10000 - j);
double lanczos_phase = sinc_phase / ((sinc_size >> 1));
int16_t sinc_val = FILTER_UNITY * filter_sinc(sinc_phase * phase_mul) * filter_sinc(lanczos_phase) * phase_mul;
//sinc_sum += sinc_val;
filter->filter[i * sinc_size + j] = sinc_val;
}
//fprintf(stderr, "Sinc sum = %.3lf\n", (double)sinc_sum / FILTER_UNITY);
}
}

View File

@ -34,22 +34,23 @@
#endif
#endif
// ARGB8888 scaler is split in two:
//
// First, horizontal scaler is applied.
// Here, all 8-bit channels are expanded to 16-bit. Values are then shifted 7 to left to occupy 15 bits.
// The sign bit is kept empty as we have to do signed multiplication for the filter.
// A mulhi [(a * b) >> 16] is applied which loses some precision, but is very efficient for SIMD.
// It is accurate enough for 8-bit purposes.
//
// The fixed point 1.0 for filter is (1 << 14). After horizontal scale, the output is kept
// with 16-bit channels, and will now have 13 bits of precision as [(a * (1 << 14)) >> 16] is effectively a right shift by 2.
//
// Vertical scaler takes the 13 bit channels, and performs the same mulhi steps.
// Another 2 bits of precision is lost, which ends up as 11 bits.
// Scaling is now complete. Channels are shifted right by 3, and saturated into 8-bit values.
//
// The C version of scalers perform the exact same operations as the SIMD code for testing purposes.
/* ARGB8888 scaler is split in two:
*
* First, horizontal scaler is applied.
* Here, all 8-bit channels are expanded to 16-bit. Values are then shifted 7 to left to occupy 15 bits.
* The sign bit is kept empty as we have to do signed multiplication for the filter.
* A mulhi [(a * b) >> 16] is applied which loses some precision, but is very efficient for SIMD.
* It is accurate enough for 8-bit purposes.
*
* The fixed point 1.0 for filter is (1 << 14). After horizontal scale, the output is kept
* with 16-bit channels, and will now have 13 bits of precision as [(a * (1 << 14)) >> 16] is effectively a right shift by 2.
*
* Vertical scaler takes the 13 bit channels, and performs the same mulhi steps.
* Another 2 bits of precision is lost, which ends up as 11 bits.
* Scaling is now complete. Channels are shifted right by 3, and saturated into 8-bit values.
*
* The C version of scalers perform the exact same operations as the SIMD code for testing purposes.
*/
#if defined(__SSE2__)
void scaler_argb8888_vert(const struct scaler_ctx *ctx, void *output_, int stride)
@ -185,7 +186,7 @@ void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int
#ifdef __x86_64__
output[w] = _mm_cvtsi128_si64(res);
#else // 32-bit doesn't have si64. Do it in two steps.
#else /* 32-bit doesn't have si64. Do it in two steps. */
union
{
uint32_t *u32;

View File

@ -24,20 +24,20 @@ struct rmsgpack_dom_value {
union {
uint64_t uint_;
int64_t int_;
struct {
struct string_t {
uint32_t len;
char * buff;
} string;
struct {
struct binary_t {
uint32_t len;
char * buff;
} binary;
int bool_;
struct {
struct map_t {
uint32_t len;
struct rmsgpack_dom_pair * items;
} map;
struct {
struct array_t {
uint32_t len;
struct rmsgpack_dom_value * items;
} array;