X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fscale.c;h=2695696fffba5d3073ce7b1b62d9d07055f640d1;hb=90311a1fce1d63452a4bba074b396bd0cac07dcb;hp=925733a192e78f99e87a46e04dd27b0c83e71f9f;hpb=94742eb40ed0dc1608f8e163fa3f9933f2c2bd18;p=libucw.git diff --git a/images/scale.c b/images/scale.c index 925733a1..2695696f 100644 --- a/images/scale.c +++ b/images/scale.c @@ -9,10 +9,10 @@ #undef LOCAL_DEBUG -#include "lib/lib.h" -#include "images/images.h" -#include "images/error.h" -#include "images/math.h" +#include +#include +#include +#include #include @@ -26,19 +26,19 @@ #define IMAGE_SCALE_PREFIX(x) image_scale_1_##x #define IMAGE_SCALE_PIXEL_SIZE 1 -#include "images/scale-gen.h" +#include #define IMAGE_SCALE_PREFIX(x) image_scale_2_##x #define IMAGE_SCALE_PIXEL_SIZE 2 -#include "images/scale-gen.h" +#include #define IMAGE_SCALE_PREFIX(x) image_scale_3_##x #define IMAGE_SCALE_PIXEL_SIZE 3 -#include "images/scale-gen.h" +#include #define IMAGE_SCALE_PREFIX(x) image_scale_4_##x #define IMAGE_SCALE_PIXEL_SIZE 4 -#include "images/scale-gen.h" +#include /* Simple "nearest neighbour" algorithm */ @@ -73,10 +73,10 @@ image_scale_nearest_x(struct image *dest, struct image *src) static void image_scale_nearest_y(struct image *dest, struct image *src) { - uns y_inc = (src->rows << 16) / dest->rows; - uns y_pos = y_inc >> 1; + uint y_inc = (src->rows << 16) / dest->rows; + uint y_pos = y_inc >> 1; byte *dest_pos = dest->pixels; - for (uns row_counter = dest->rows; row_counter--; ) + for (uint row_counter = dest->rows; row_counter--; ) { byte *src_pos = src->pixels + (y_pos >> 16) * src->row_size; y_pos += y_inc; @@ -94,22 +94,22 @@ image_scale_linear_y(struct image *dest, struct image *src) /* Handle problematic special case */ if (src->rows == 1) { - for (uns y_counter = dest->rows; y_counter--; dest_row += dest->row_size) + for (uint y_counter = dest->rows; y_counter--; dest_row += dest->row_size) memcpy(dest_row, src->pixels, src->row_pixels_size); return; } /* Initialize the main loop */ - uns y_inc = ((src->rows - 1) << 16) / (dest->rows - 1), y_pos = 0; + uint y_inc = ((src->rows - 1) << 16) / (dest->rows - 1), y_pos = 0; #ifdef __SSE2__ __m128i zero = _mm_setzero_si128(); #endif /* Main loop */ - for (uns y_counter = dest->rows; --y_counter; ) + for (uint y_counter = dest->rows; --y_counter; ) { - uns coef = y_pos & 0xffff; + uint coef = y_pos & 0xffff; byte *src_row_1 = src->pixels + (y_pos >> 16) * src->row_size; byte *src_row_2 = src_row_1 + src->row_size; - uns i = 0; + uint i = 0; #ifdef __SSE2__ /* SSE2 */ __m128i sse_coef = _mm_set1_epi16(coef >> 9); @@ -226,7 +226,7 @@ image_scale(struct image_context *ctx, struct image *dest, struct image *src) } else { - if (dest->cols <= src->cols && src->cols <= dest->cols) + if (dest->cols <= src->cols && dest->rows <= src->rows) { /* Downscale in both dimensions */ image_scale_downsample_xy(dest, src); @@ -241,7 +241,7 @@ image_scale(struct image_context *ctx, struct image *dest, struct image *src) } void -image_dimensions_fit_to_box(u32 *cols, u32 *rows, u32 max_cols, u32 max_rows, uns upsample) +image_dimensions_fit_to_box(uint *cols, uint *rows, uint max_cols, uint max_rows, uint upsample) { ASSERT(image_dimensions_valid(*cols, *rows)); ASSERT(image_dimensions_valid(max_cols, max_rows));