treewide: fix various build warnings; ignore vendored headers in formatting job
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I7af033c8d3f437e5574b050223cbc16a6a6a6964
This commit is contained in:
parent
b311a0a969
commit
3719dbccd5
10 changed files with 95 additions and 81 deletions
34
src/config.c
34
src/config.c
|
|
@ -262,7 +262,7 @@ static int add_output_mapping(chroma_config_t *config, const char *output_name,
|
|||
"Added mapping: %s -> %s (scale: %s, filter: %s, anchor: %s @ %.1f,%.1f)",
|
||||
output_name, image_path, scale_mode_to_string(scale_mode),
|
||||
filter_quality_to_string(filter_quality), anchor_to_string(anchor),
|
||||
anchor_x, anchor_y);
|
||||
(double)anchor_x, (double)anchor_y);
|
||||
chroma_log("TRACE", "Output mapping %d: '%s' -> '%s' (path length: %zu)",
|
||||
config->mapping_count, output_name, image_path, path_len);
|
||||
return CHROMA_OK;
|
||||
|
|
@ -403,7 +403,7 @@ static int parse_config_line(chroma_config_t *config, char *line,
|
|||
config->default_anchor_x = 50.0f;
|
||||
} else {
|
||||
config->default_anchor_x = ax;
|
||||
chroma_log("DEBUG", "Set default anchor_x: %.1f", ax);
|
||||
chroma_log("DEBUG", "Set default anchor_x: %.1f", (double)ax);
|
||||
}
|
||||
} else if (strcasecmp(key, "anchor_y") == 0) {
|
||||
char *endptr = NULL;
|
||||
|
|
@ -417,7 +417,7 @@ static int parse_config_line(chroma_config_t *config, char *line,
|
|||
config->default_anchor_y = 50.0f;
|
||||
} else {
|
||||
config->default_anchor_y = ay;
|
||||
chroma_log("DEBUG", "Set default anchor_y: %.1f", ay);
|
||||
chroma_log("DEBUG", "Set default anchor_y: %.1f", (double)ay);
|
||||
}
|
||||
} else if (strcasecmp(key, "max_output_width") == 0) {
|
||||
int width = atoi(value);
|
||||
|
|
@ -436,10 +436,10 @@ static int parse_config_line(chroma_config_t *config, char *line,
|
|||
chroma_log("WARN", "Invalid max_output_height: %s (using 2160)", value);
|
||||
}
|
||||
} else if (strcasecmp(key, "min_scale_factor") == 0) {
|
||||
float factor = atof(value);
|
||||
if (factor > 0.0f && factor <= 1.0f) { // Valid range
|
||||
float factor = (float)atof(value);
|
||||
if (factor > 0.0f && factor <= 1.0f) {
|
||||
config->min_scale_factor = factor;
|
||||
chroma_log("DEBUG", "Set minimum scale factor: %.2f", factor);
|
||||
chroma_log("DEBUG", "Set minimum scale factor: %.2f", (double)factor);
|
||||
} else {
|
||||
chroma_log("WARN", "Invalid min_scale_factor: %s (using 0.25)", value);
|
||||
}
|
||||
|
|
@ -527,24 +527,24 @@ static int parse_config_line(chroma_config_t *config, char *line,
|
|||
}
|
||||
chroma_log("DEBUG", "Set anchor for output %s: %s (x=%.1f, y=%.1f)",
|
||||
output_name, anchor_to_string(mapping->anchor),
|
||||
mapping->anchor_x, mapping->anchor_y);
|
||||
(double)mapping->anchor_x, (double)mapping->anchor_y);
|
||||
} else if (strcasecmp(property, "anchor_x") == 0) {
|
||||
float ax = atof(value);
|
||||
float ax = (float)atof(value);
|
||||
if (ax >= 0.0f && ax <= 100.0f) {
|
||||
mapping->anchor_x = ax;
|
||||
chroma_log("DEBUG", "Set anchor_x for output %s: %.1f", output_name,
|
||||
ax);
|
||||
(double)ax);
|
||||
} else {
|
||||
mapping->anchor_x = 50.0f;
|
||||
chroma_log("WARN", "Invalid anchor_x: %s (range 0-100, using 50)",
|
||||
value);
|
||||
}
|
||||
} else if (strcasecmp(property, "anchor_y") == 0) {
|
||||
float ay = atof(value);
|
||||
float ay = (float)atof(value);
|
||||
if (ay >= 0.0f && ay <= 100.0f) {
|
||||
mapping->anchor_y = ay;
|
||||
chroma_log("DEBUG", "Set anchor_y for output %s: %.1f", output_name,
|
||||
ay);
|
||||
(double)ay);
|
||||
} else {
|
||||
mapping->anchor_y = 50.0f;
|
||||
chroma_log("WARN", "Invalid anchor_y: %s (range 0-100, using 50)",
|
||||
|
|
@ -660,7 +660,7 @@ int chroma_config_load(chroma_config_t *config, const char *config_file) {
|
|||
// Log configuration memory usage
|
||||
size_t config_size =
|
||||
sizeof(chroma_config_t) +
|
||||
(config->mapping_count * sizeof(chroma_config_mapping_t));
|
||||
((size_t)config->mapping_count * sizeof(chroma_config_mapping_t));
|
||||
chroma_log_resource_allocation("config_data", config_size,
|
||||
"configuration structure");
|
||||
chroma_log_memory_stats("post-config-load");
|
||||
|
|
@ -677,7 +677,7 @@ void chroma_config_free(chroma_config_t *config) {
|
|||
// Log configuration deallocation
|
||||
size_t config_size =
|
||||
sizeof(chroma_config_t) +
|
||||
(config->mapping_count * sizeof(chroma_config_mapping_t));
|
||||
((size_t)config->mapping_count * sizeof(chroma_config_mapping_t));
|
||||
chroma_log_resource_deallocation("config_data", config_size,
|
||||
"configuration structure");
|
||||
|
||||
|
|
@ -748,7 +748,8 @@ int chroma_config_get_mapping_for_output(
|
|||
output_name, output_description ? output_description : "none",
|
||||
scale_mode_to_string(*scale_mode),
|
||||
filter_quality_to_string(*filter_quality),
|
||||
anchor_to_string(*anchor), *anchor_x, *anchor_y);
|
||||
anchor_to_string(*anchor), (double)*anchor_x,
|
||||
(double)*anchor_y);
|
||||
return CHROMA_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -764,7 +765,7 @@ int chroma_config_get_mapping_for_output(
|
|||
"%.1f,%.1f",
|
||||
output_name, scale_mode_to_string(*scale_mode),
|
||||
filter_quality_to_string(*filter_quality),
|
||||
anchor_to_string(*anchor), *anchor_x, *anchor_y);
|
||||
anchor_to_string(*anchor), (double)*anchor_x, (double)*anchor_y);
|
||||
return CHROMA_OK;
|
||||
}
|
||||
|
||||
|
|
@ -786,7 +787,8 @@ void chroma_config_print(const chroma_config_t *config) {
|
|||
if (config->enable_downsampling) {
|
||||
chroma_log("INFO", "Max output size: %dx%d", config->max_output_width,
|
||||
config->max_output_height);
|
||||
chroma_log("INFO", "Min scale factor: %.2f", config->min_scale_factor);
|
||||
chroma_log("INFO", "Min scale factor: %.2f",
|
||||
(double)config->min_scale_factor);
|
||||
}
|
||||
chroma_log("INFO", "Output mappings: %d", config->mapping_count);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,8 @@ static int assign_wallpaper_to_output(chroma_state_t *state,
|
|||
"Loaded config for output %u: scale=%d, filter=%d, anchor=%d @ "
|
||||
"%.1f,%.1f",
|
||||
output->id, output->scale_mode, output->filter_quality,
|
||||
output->anchor, output->anchor_x, output->anchor_y);
|
||||
output->anchor, (double)output->anchor_x,
|
||||
(double)output->anchor_y);
|
||||
|
||||
// Check if configuration changed and invalidate texture if needed
|
||||
if (had_config &&
|
||||
|
|
|
|||
39
src/image.c
39
src/image.c
|
|
@ -1,5 +1,5 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "../include/stb_image.h"
|
||||
#include "../include/vendor/stb_image.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -37,16 +37,16 @@ static void calculate_optimal_size(int original_width, int original_height,
|
|||
}
|
||||
|
||||
// Calculate scale factor to fit within max output dimensions
|
||||
float scale_x = (float)max_output_width / original_width;
|
||||
float scale_y = (float)max_output_height / original_height;
|
||||
float scale_x = (float)max_output_width / (float)original_width;
|
||||
float scale_y = (float)max_output_height / (float)original_height;
|
||||
float scale = (scale_x < scale_y) ? scale_x : scale_y;
|
||||
|
||||
// Apply scale factor with minimum size to avoid too small images
|
||||
scale = (scale > 1.0f) ? 1.0f : scale;
|
||||
scale = (scale < 0.25f) ? 0.25f : scale; // XXX: don't scale below 25%
|
||||
|
||||
*optimal_width = (int)(original_width * scale);
|
||||
*optimal_height = (int)(original_height * scale);
|
||||
*optimal_width = (int)((float)original_width * scale);
|
||||
*optimal_height = (int)((float)original_height * scale);
|
||||
|
||||
// Ensure even dimensions for better GPU alignment
|
||||
*optimal_width = (*optimal_width / 2) * 2;
|
||||
|
|
@ -64,14 +64,14 @@ static int downsample_image(unsigned char *src_data, int src_width,
|
|||
return -1;
|
||||
}
|
||||
|
||||
float x_ratio = (float)src_width / dst_width;
|
||||
float y_ratio = (float)src_height / dst_height;
|
||||
float x_ratio = (float)src_width / (float)dst_width;
|
||||
float y_ratio = (float)src_height / (float)dst_height;
|
||||
|
||||
for (int y = 0; y < dst_height; y++) {
|
||||
for (int x = 0; x < dst_width; x++) {
|
||||
// Calculate corresponding source pixel
|
||||
int src_x = (int)(x * x_ratio);
|
||||
int src_y = (int)(y * y_ratio);
|
||||
int src_x = (int)((float)x * x_ratio);
|
||||
int src_y = (int)((float)y * y_ratio);
|
||||
|
||||
// Ensure we're within bounds
|
||||
src_x = (src_x >= src_width) ? src_width - 1 : src_x;
|
||||
|
|
@ -160,14 +160,14 @@ int chroma_image_load(chroma_image_t *image, const char *path,
|
|||
&optimal_width, &optimal_height);
|
||||
|
||||
// Apply minimum scale factor constraint
|
||||
float scale_x = (float)optimal_width / original_width;
|
||||
float scale_y = (float)optimal_height / original_height;
|
||||
float scale_x = (float)optimal_width / (float)original_width;
|
||||
float scale_y = (float)optimal_height / (float)original_height;
|
||||
float scale = (scale_x < scale_y) ? scale_x : scale_y;
|
||||
|
||||
if (scale < config->min_scale_factor) {
|
||||
scale = config->min_scale_factor;
|
||||
optimal_width = (int)(original_width * scale);
|
||||
optimal_height = (int)(original_height * scale);
|
||||
optimal_width = (int)((float)original_width * scale);
|
||||
optimal_height = (int)((float)original_height * scale);
|
||||
|
||||
// Ensure even dimensions
|
||||
optimal_width = (optimal_width / 2) * 2;
|
||||
|
|
@ -180,13 +180,14 @@ int chroma_image_load(chroma_image_t *image, const char *path,
|
|||
|
||||
// Downsamp if needed and enabled
|
||||
if (should_downsample) {
|
||||
double reduction_ratio = (double)(optimal_width * optimal_height) /
|
||||
(double)(original_width * original_height) * 100.0;
|
||||
chroma_log("INFO",
|
||||
"Downsampling image from %dx%d to %dx%d (%.1f%% of original)",
|
||||
original_width, original_height, optimal_width, optimal_height,
|
||||
(float)(optimal_width * optimal_height) /
|
||||
(original_width * original_height) * 100.0f);
|
||||
reduction_ratio);
|
||||
|
||||
size_t optimal_size = (size_t)optimal_width * optimal_height * 4;
|
||||
size_t optimal_size = (size_t)optimal_width * (size_t)optimal_height * 4;
|
||||
unsigned char *downsampled_data = malloc(optimal_size);
|
||||
if (!downsampled_data) {
|
||||
chroma_log("ERROR", "Failed to allocate memory for downsampled image");
|
||||
|
|
@ -219,7 +220,8 @@ int chroma_image_load(chroma_image_t *image, const char *path,
|
|||
image->loaded = true;
|
||||
|
||||
// Calculate and log memory allocation
|
||||
size_t image_size = (size_t)image->width * image->height * image->channels;
|
||||
size_t image_size =
|
||||
(size_t)image->width * (size_t)image->height * (size_t)image->channels;
|
||||
chroma_log_resource_allocation("image_data", image_size, path);
|
||||
|
||||
chroma_log("INFO", "Loaded image: %s (%dx%d, %d channels, %.2f MB)%s", path,
|
||||
|
|
@ -238,7 +240,8 @@ void chroma_image_free(chroma_image_t *image) {
|
|||
|
||||
if (image->data) {
|
||||
// Log memory deallocation before freeing
|
||||
size_t image_size = (size_t)image->width * image->height * image->channels;
|
||||
size_t image_size =
|
||||
(size_t)image->width * (size_t)image->height * (size_t)image->channels;
|
||||
|
||||
if (strlen(image->path) > 0) {
|
||||
chroma_log("DEBUG", "Freed image: %s", image->path);
|
||||
|
|
|
|||
70
src/render.c
70
src/render.c
|
|
@ -6,7 +6,7 @@
|
|||
#include <GLES2/gl2.h>
|
||||
|
||||
#include "../include/chroma.h"
|
||||
#include "../include/stb_image.h"
|
||||
#include "../include/vendor/stb_image.h"
|
||||
|
||||
// Convert filter quality enum to OpenGL parameters
|
||||
static void get_gl_filter_params(chroma_filter_quality_t quality,
|
||||
|
|
@ -64,14 +64,14 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
|
|||
// Center image at original size
|
||||
// Calculate how much of the texture to show
|
||||
{
|
||||
float image_aspect = (float)image_width / image_height;
|
||||
float output_aspect = (float)output_width / output_height;
|
||||
float image_aspect = (float)image_width / (float)image_height;
|
||||
float output_aspect = (float)output_width / (float)output_height;
|
||||
|
||||
if (image_aspect > output_aspect) {
|
||||
// Image is wider - fit width, show center portion vertically
|
||||
float visible_height = (float)image_width / output_aspect;
|
||||
float v_offset =
|
||||
(image_height - visible_height) / (2.0f * image_height);
|
||||
float v_offset = ((float)image_height - visible_height) /
|
||||
(2.0f * (float)image_height);
|
||||
u1 = 0.0f;
|
||||
v1 = v_offset;
|
||||
u2 = 1.0f;
|
||||
|
|
@ -79,7 +79,8 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
|
|||
} else {
|
||||
// Image is taller - fit height, show center portion horizontally
|
||||
float visible_width = (float)image_height * output_aspect;
|
||||
float u_offset = (image_width - visible_width) / (2.0f * image_width);
|
||||
float u_offset =
|
||||
((float)image_width - visible_width) / (2.0f * (float)image_width);
|
||||
u1 = u_offset;
|
||||
v1 = 0.0f;
|
||||
u2 = 1.0f - u_offset;
|
||||
|
|
@ -91,14 +92,14 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
|
|||
case CHROMA_SCALE_FIT:
|
||||
// Fit image within output, maintaining aspect ratio
|
||||
{
|
||||
float image_aspect = (float)image_width / image_height;
|
||||
float output_aspect = (float)output_width / output_height;
|
||||
float image_aspect = (float)image_width / (float)image_height;
|
||||
float output_aspect = (float)output_width / (float)output_height;
|
||||
|
||||
if (image_aspect > output_aspect) {
|
||||
// Image is wider - fit width, add borders top/bottom
|
||||
float scaled_height = (float)output_width / image_aspect;
|
||||
float v_border =
|
||||
(output_height - scaled_height) / (2.0f * output_height);
|
||||
float v_border = ((float)output_height - scaled_height) /
|
||||
(2.0f * (float)output_height);
|
||||
u1 = 0.0f;
|
||||
v1 = v_border;
|
||||
u2 = 1.0f;
|
||||
|
|
@ -106,7 +107,8 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
|
|||
} else {
|
||||
// Image is taller - fit height, add borders left/right
|
||||
float scaled_width = (float)output_height * image_aspect;
|
||||
float u_border = (output_width - scaled_width) / (2.0f * output_width);
|
||||
float u_border =
|
||||
((float)output_width - scaled_width) / (2.0f * (float)output_width);
|
||||
u1 = u_border;
|
||||
v1 = 0.0f;
|
||||
u2 = 1.0f - u_border;
|
||||
|
|
@ -119,21 +121,23 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
|
|||
default:
|
||||
// Fill entire output, crop if necessary
|
||||
{
|
||||
float image_aspect = (float)image_width / image_height;
|
||||
float output_aspect = (float)output_width / output_height;
|
||||
float image_aspect = (float)image_width / (float)image_height;
|
||||
float output_aspect = (float)output_width / (float)output_height;
|
||||
|
||||
if (image_aspect > output_aspect) {
|
||||
// Image is wider - crop left/right
|
||||
float crop_width = image_height * output_aspect;
|
||||
float u_crop = (image_width - crop_width) / (2.0f * image_width);
|
||||
float crop_width = (float)image_height * output_aspect;
|
||||
float u_crop =
|
||||
((float)image_width - crop_width) / (2.0f * (float)image_width);
|
||||
u1 = u_crop;
|
||||
v1 = 0.0f;
|
||||
u2 = 1.0f - u_crop;
|
||||
v2 = 1.0f;
|
||||
} else {
|
||||
// Image is taller - crop top/bottom
|
||||
float crop_height = image_width / output_aspect;
|
||||
float v_crop = (image_height - crop_height) / (2.0f * image_height);
|
||||
float crop_height = (float)image_width / output_aspect;
|
||||
float v_crop =
|
||||
((float)image_height - crop_height) / (2.0f * (float)image_height);
|
||||
u1 = 0.0f;
|
||||
v1 = v_crop;
|
||||
u2 = 1.0f;
|
||||
|
|
@ -336,7 +340,8 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
// Could this b made more accurate?
|
||||
if (output->image && output->image->loaded) {
|
||||
size_t texture_size = (size_t)output->image->width *
|
||||
output->image->height * output->image->channels;
|
||||
(size_t)output->image->height *
|
||||
(size_t)output->image->channels;
|
||||
chroma_log_resource_deallocation("gpu_texture", texture_size,
|
||||
"texture replacement");
|
||||
}
|
||||
|
|
@ -349,7 +354,8 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
glBindTexture(GL_TEXTURE_2D, output->texture_id);
|
||||
|
||||
// Log GPU texture allocation
|
||||
size_t texture_size = (size_t)image->width * image->height * image->channels;
|
||||
size_t texture_size =
|
||||
(size_t)image->width * (size_t)image->height * (size_t)image->channels;
|
||||
chroma_log_resource_allocation("gpu_texture", texture_size, image->path);
|
||||
|
||||
// Set texture parameters
|
||||
|
|
@ -398,8 +404,8 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
|
||||
// Only free image data when ALL outputs using it have uploaded
|
||||
if (total_using > 0 && uploaded_count >= total_using) {
|
||||
size_t freed_bytes =
|
||||
(size_t)image->width * image->height * image->channels;
|
||||
size_t freed_bytes = (size_t)image->width * (size_t)image->height *
|
||||
(size_t)image->channels;
|
||||
stbi_image_free(image->data);
|
||||
image->data = NULL;
|
||||
chroma_log("INFO",
|
||||
|
|
@ -580,8 +586,8 @@ int chroma_surface_create(chroma_state_t *state, chroma_output_t *output) {
|
|||
}
|
||||
|
||||
// Configure layer surface
|
||||
zwlr_layer_surface_v1_set_size(output->layer_surface, output->width,
|
||||
output->height);
|
||||
zwlr_layer_surface_v1_set_size(output->layer_surface, (uint32_t)output->width,
|
||||
(uint32_t)output->height);
|
||||
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
||||
|
|
@ -626,8 +632,7 @@ int chroma_surface_create(chroma_state_t *state, chroma_output_t *output) {
|
|||
output->width, output->height);
|
||||
|
||||
// Log surface creation resource allocation
|
||||
size_t surface_size =
|
||||
(size_t)output->width * output->height * 4; // estimate RGBA surface
|
||||
size_t surface_size = (size_t)output->width * (size_t)output->height * 4;
|
||||
chroma_log_resource_allocation("egl_surface", surface_size, "output surface");
|
||||
|
||||
return CHROMA_OK;
|
||||
|
|
@ -663,8 +668,7 @@ void chroma_surface_destroy(chroma_output_t *output) {
|
|||
}
|
||||
|
||||
// Log surface destruction
|
||||
size_t surface_size =
|
||||
(size_t)output->width * output->height * 4; // estimate RGBA surface
|
||||
size_t surface_size = (size_t)output->width * (size_t)output->height * 4;
|
||||
chroma_log_resource_deallocation("egl_surface", surface_size,
|
||||
"output surface cleanup");
|
||||
|
||||
|
|
@ -749,13 +753,13 @@ int chroma_render_wallpaper(chroma_state_t *state, chroma_output_t *output) {
|
|||
GLint position_attr = glGetAttribLocation(output->shader_program, "position");
|
||||
GLint texcoord_attr = glGetAttribLocation(output->shader_program, "texcoord");
|
||||
|
||||
glEnableVertexAttribArray(position_attr);
|
||||
glVertexAttribPointer(position_attr, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
|
||||
(void *)0);
|
||||
glEnableVertexAttribArray((GLuint)position_attr);
|
||||
glVertexAttribPointer((GLuint)position_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
4 * sizeof(float), (void *)0);
|
||||
|
||||
glEnableVertexAttribArray(texcoord_attr);
|
||||
glVertexAttribPointer(texcoord_attr, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
|
||||
(void *)(2 * sizeof(float)));
|
||||
glEnableVertexAttribArray((GLuint)texcoord_attr);
|
||||
glVertexAttribPointer((GLuint)texcoord_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
4 * sizeof(float), (void *)(2 * sizeof(float)));
|
||||
|
||||
// Draw
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ static char *expand_env_vars(const char *str) {
|
|||
break;
|
||||
}
|
||||
|
||||
size_t var_len = end - p;
|
||||
size_t var_len = (size_t)(end - p);
|
||||
char *var_name = malloc(var_len + 1);
|
||||
if (!var_name) {
|
||||
free(result);
|
||||
|
|
@ -165,7 +165,7 @@ static char *expand_env_vars(const char *str) {
|
|||
result = tmp;
|
||||
strcat(result, "$");
|
||||
} else {
|
||||
size_t var_len = p - start;
|
||||
size_t var_len = (size_t)(p - start);
|
||||
char *var_name = malloc(var_len + 1);
|
||||
if (!var_name) {
|
||||
free(result);
|
||||
|
|
|
|||
|
|
@ -397,13 +397,14 @@ void chroma_output_remove(chroma_state_t *state, uint32_t id) {
|
|||
free(output->description);
|
||||
|
||||
// Remove from array by shifting remaining elements
|
||||
int index = output - state->outputs;
|
||||
int remaining = state->output_count - index - 1;
|
||||
chroma_log("TRACE", "Removing output %u from array: index=%d, remaining=%d",
|
||||
ptrdiff_t index = output - state->outputs;
|
||||
size_t remaining = (size_t)(state->output_count - index - 1);
|
||||
chroma_log("TRACE", "Removing output %u from array: index=%td, remaining=%zu",
|
||||
id, index, remaining);
|
||||
if (remaining > 0) {
|
||||
memmove(output, output + 1, remaining * sizeof(chroma_output_t));
|
||||
chroma_log("TRACE", "Shifted %d outputs in array after removal", remaining);
|
||||
chroma_log("TRACE", "Shifted %zu outputs in array after removal",
|
||||
remaining);
|
||||
}
|
||||
|
||||
state->output_count--;
|
||||
|
|
|
|||
|
|
@ -201,14 +201,14 @@ int main(int argc, char **argv) {
|
|||
for (int r = 0; r < 6; r++) {
|
||||
int w = widths[r];
|
||||
int h = heights[r];
|
||||
size_t original_bytes = (size_t)w * h * 4;
|
||||
double original_mb = original_bytes / (1024.0 * 1024.0);
|
||||
size_t original_bytes = (size_t)w * (size_t)h * 4u;
|
||||
double original_mb = (double)original_bytes / (1024.0 * 1024.0);
|
||||
|
||||
int dw, dh;
|
||||
uint8_t *src = create_noise_image(w, h, 42);
|
||||
uint8_t *dst = downsample_image(src, w, h, 4, &dw, &dh, scales[s]);
|
||||
size_t downsampled_bytes = (size_t)dw * dh * 4;
|
||||
double downsampled_mb = downsampled_bytes / (1024.0 * 1024.0);
|
||||
size_t downsampled_bytes = (size_t)dw * (size_t)dh * 4u;
|
||||
double downsampled_mb = (double)downsampled_bytes / (1024.0 * 1024.0);
|
||||
|
||||
double savings = 0.0;
|
||||
if (original_mb > 0) {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,12 @@ extern int test_total;
|
|||
} while (0)
|
||||
|
||||
#define TEST_ASSERT_FTZ(actual, expected, tol, msg) do { \
|
||||
double _diff = fabs((actual) - (expected)); \
|
||||
if (_diff > (tol)) { \
|
||||
fprintf(stderr, " [FAIL] %s: expected %.6f, got %.6f (diff %.6f)\n", msg, (expected), (actual), _diff); \
|
||||
double _actual = (double)(actual); \
|
||||
double _expected = (double)(expected); \
|
||||
double _tol = (double)(tol); \
|
||||
double _diff = fabs(_actual - _expected); \
|
||||
if (_diff > _tol) { \
|
||||
fprintf(stderr, " [FAIL] %s: expected %.6f, got %.6f (diff %.6f)\n", msg, _expected, _actual, _diff); \
|
||||
test_failures++; \
|
||||
return TEST_FAILED; \
|
||||
} \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue