diff --git a/gfx/scaler/filter.c b/gfx/scaler/filter.c index 9c7e5516f0..d6f58113e8 100644 --- a/gfx/scaler/filter.c +++ b/gfx/scaler/filter.c @@ -1,3 +1,19 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + + #include "filter.h" #include #include diff --git a/gfx/scaler/filter.h b/gfx/scaler/filter.h index 0614c6d31a..2b0b1b3949 100644 --- a/gfx/scaler/filter.h +++ b/gfx/scaler/filter.h @@ -1,3 +1,19 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + + #ifndef FILTER_H__ #define FILTER_H__ diff --git a/gfx/scaler/main.c b/gfx/scaler/main.c deleted file mode 100644 index 2edf1226a6..0000000000 --- a/gfx/scaler/main.c +++ /dev/null @@ -1,171 +0,0 @@ -#include "scaler.h" -#include -#include -#include -#include -#include -#include -#include - -static float g_horiz_scale = 1.0f; -static float g_vert_scale = 1.0f; - -static enum scaler_type g_scaler_type = SCALER_TYPE_SINC; - -static char *g_in_path; -static char *g_out_path; - -static void print_help(void) -{ - fprintf(stderr, "Usage: scale [...options...]\n"); - fprintf(stderr, "\t-i/--input: Input file\n"); - fprintf(stderr, "\t-o/--output: Output file\n"); - fprintf(stderr, "\t-x/--xscale: Relative scale in X\n"); - fprintf(stderr, "\t-y/--yscale: Relative scale in Y\n"); - fprintf(stderr, "\t-s/--scale: Relative scale in both X/Y\n"); - fprintf(stderr, "\t-t/--type: Filter type. Valid ones are:\n"); - fprintf(stderr, "\t\tsinc, point, bilinear\n"); - fprintf(stderr, "\t-h/--help: Prints this help\n"); -} - -static bool parse_args(int argc, char *argv[]) -{ - const struct option opts[] = { - { "xscale", 1, NULL, 'x' }, - { "yscale", 1, NULL, 'y' }, - { "scale", 1, NULL, 's' }, - { "input", 1, NULL, 'i' }, - { "output", 1, NULL, 'o' }, - { "type", 1, NULL, 't' }, - { "help", 0, NULL, 'h' }, - { NULL, 0, NULL, 0 }, - }; - - const char *optstring = "x:y:i:o:t:s:h"; - - for (;;) - { - int c = getopt_long(argc, argv, optstring, opts, NULL); - if (c == -1) - break; - - switch (c) - { - case 'h': - print_help(); - exit(EXIT_SUCCESS); - - case 's': - g_horiz_scale = strtof(optarg, NULL); - g_vert_scale = g_horiz_scale; - break; - - case 'x': - g_horiz_scale = strtof(optarg, NULL); - break; - - case 'y': - g_vert_scale = strtof(optarg, NULL); - break; - - case 'i': - g_in_path = strdup(optarg); - break; - - case 'o': - g_out_path = strdup(optarg); - break; - - case '?': - print_help(); - return false; - - case 't': - if (strcmp(optarg, "sinc") == 0) - g_scaler_type = SCALER_TYPE_SINC; - else if (strcmp(optarg, "bilinear") == 0) - g_scaler_type = SCALER_TYPE_BILINEAR; - else if (strcmp(optarg, "point") == 0) - g_scaler_type = SCALER_TYPE_POINT; - else - { - print_help(); - return false; - } - break; - } - } - - if (!g_in_path || !g_out_path) - { - print_help(); - return false; - } - - if (optind < argc) - { - print_help(); - return false; - } - - return true; -} - -int main(int argc, char *argv[]) -{ - if (!parse_args(argc, argv)) - return EXIT_FAILURE; - - Imlib_Image img = imlib_load_image(g_in_path); - if (!img) - return EXIT_FAILURE; - - imlib_context_set_image(img); - - struct scaler_ctx ctx = {0}; - ctx.in_width = imlib_image_get_width(); - ctx.in_height = imlib_image_get_height(); - ctx.out_width = (int)(imlib_image_get_width() * g_horiz_scale); - ctx.out_height = (int)(imlib_image_get_height() * g_vert_scale); - ctx.in_stride = imlib_image_get_width() * sizeof(uint32_t); - ctx.out_stride = (int)(imlib_image_get_width() * g_horiz_scale) * sizeof(uint32_t); - ctx.in_fmt = SCALER_FMT_ARGB8888; - ctx.out_fmt = SCALER_FMT_ARGB8888; - ctx.scaler_type = g_scaler_type; - - assert(scaler_ctx_gen_filter(&ctx)); - - uint32_t *scale_buf = (uint32_t*)calloc(sizeof(uint32_t), ctx.out_width * ctx.out_height); - - //struct timespec tv[2]; - //clock_gettime(CLOCK_MONOTONIC, &tv[0]); - scaler_ctx_scale(&ctx, scale_buf, imlib_image_get_data_for_reading_only()); - //clock_gettime(CLOCK_MONOTONIC, &tv[1]); - - //double time_ms = (tv[1].tv_sec - tv[0].tv_sec) * 1000.0 + (tv[1].tv_nsec - tv[0].tv_nsec) / 1000000.0; - //double ns_per_pix = (1000000.0 * time_ms) / (ctx.out_width * ctx.out_height); - //printf("Time: %.3lf ms, %.3lf ns / pixel\n", time_ms, ns_per_pix); - - Imlib_Image new_img = imlib_create_image_using_data(ctx.out_width, ctx.out_height, - scale_buf); - - imlib_free_image(); - imlib_context_set_image(new_img); - - const char *fmt = strrchr(g_out_path, '.'); - if (fmt) - fmt++; - else - fmt = "png"; - - imlib_image_set_format(fmt); - imlib_save_image(g_out_path); - imlib_free_image(); - - free(scale_buf); - free(g_in_path); - free(g_out_path); - - scaler_ctx_gen_reset(&ctx); -} - diff --git a/gfx/scaler/pixconv.c b/gfx/scaler/pixconv.c index 791c9ca13f..73f94a9891 100644 --- a/gfx/scaler/pixconv.c +++ b/gfx/scaler/pixconv.c @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #include "pixconv.h" #include #include diff --git a/gfx/scaler/pixconv.h b/gfx/scaler/pixconv.h index 8af7240713..d27608704d 100644 --- a/gfx/scaler/pixconv.h +++ b/gfx/scaler/pixconv.h @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #ifndef PIXCONV_H__ #define PIXCONV_H__ diff --git a/gfx/scaler/scaler.c b/gfx/scaler/scaler.c index 8dc886daca..bc876744f4 100644 --- a/gfx/scaler/scaler.c +++ b/gfx/scaler/scaler.c @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #include "scaler.h" #include "scaler_int.h" #include "filter.h" diff --git a/gfx/scaler/scaler.h b/gfx/scaler/scaler.h index f5091621df..2a23240629 100644 --- a/gfx/scaler/scaler.h +++ b/gfx/scaler/scaler.h @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #ifndef SCALER_H__ #define SCALER_H__ diff --git a/gfx/scaler/scaler_int.c b/gfx/scaler/scaler_int.c index a6e1390a44..7b338a659b 100644 --- a/gfx/scaler/scaler_int.c +++ b/gfx/scaler/scaler_int.c @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #include "scaler_int.h" #if defined(__SSE2__) diff --git a/gfx/scaler/scaler_int.h b/gfx/scaler/scaler_int.h index 1d20616edf..99762f72d9 100644 --- a/gfx/scaler/scaler_int.h +++ b/gfx/scaler/scaler_int.h @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #ifndef SCALER_INT_H__ #define SCALER_INT_H__