1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Akio Idehara
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 /****************************************************************
30 * resize bitmap on load with scaling
32 * If HAVE_LCD_COLOR then this func use smooth scaling algorithm
33 * - downscaling both way use "Area Sampling"
34 * if IMG_RESIZE_BILINER or IMG_RESIZE_NEAREST is NOT set
35 * - otherwise "Bilinear" or "Nearest Neighbour"
37 * If !(HAVE_LCD_COLOR) then use simple scaling algorithm "Nearest Neighbour"
40 ****************************************************************/
42 /* nothing needs the on-stack buffer right now */
43 #define MAX_SC_STACK_ALLOC 0
44 #define HAVE_UPSCALER 1
46 #if defined(CPU_COLDFIRE)
47 #define SC_NUM 0x80000000U
49 unsigned long macsr_st = coldfire_get_macsr(); \
50 coldfire_set_macsr(EMAC_UNSIGNED);
51 #define SC_MUL_END coldfire_set_macsr(macsr_st);
52 #define SC_MUL(x, y) \
55 asm ("mac.l %[a], %[b], %%acc0\n\t" \
56 "move.l %%accext01, %[t]\n\t" \
57 "move.l #0, %%acc0\n\t" \
58 : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
61 #elif (CONFIG_CPU == SH7034)
70 #define SC_NUM 0x1000000U
74 #define SC_MUL(x, y) ((x) * (y) >> 24)
79 #else /* SC_SHIFT == 32 */
80 #define SC_NUM 0x80000000U
84 #define SC_MUL(x, y) ((x) * (uint64_t)(y) >> 32)
93 #if !defined(HAVE_LCD_COLOR)
96 struct uint8_rgb
* buf
;
100 #ifdef HAVE_LCD_COLOR
101 /* intermediate type used by the scaler for color output. greyscale version
111 /* struct which contains various parameters shared between vertical scaler,
112 horizontal scaler, and row output
114 struct scaler_context
{
123 struct img_part
* (*store_part
)(void *);
124 void (*output_row
)(uint32_t,void*,struct scaler_context
*);
125 bool (*h_scaler
)(void*,struct scaler_context
*, bool);
128 struct custom_format
{
129 void (*output_row
)(uint32_t,void*,struct scaler_context
*);
130 unsigned int (*get_size
)(struct bitmap
*bm
);
134 int recalc_dimension(struct dim
*dst
, struct dim
*src
);
136 int resize_on_load(struct bitmap
*bm
, bool dither
,
137 struct dim
*src
, struct rowset
*tmp_row
,
138 unsigned char *buf
, unsigned int len
,
139 const struct custom_format
*cformat
,
140 struct img_part
* (*store_part
)(void *args
),
143 #endif /* _RESIZE_H_ */