2008-12-09 23:07:59 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2008-12-10 21:10:34 +00:00
|
|
|
* $Id$
|
2008-12-09 23:07:59 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Akio Idehara
|
|
|
|
*
|
|
|
|
* This program 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 Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _RESIZE_H_
|
|
|
|
#define _RESIZE_H_
|
|
|
|
#include "config.h"
|
|
|
|
#include "lcd.h"
|
2008-12-26 07:03:22 +00:00
|
|
|
#include "inttypes.h"
|
2008-12-09 23:07:59 +00:00
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
* resize_on_load()
|
|
|
|
*
|
|
|
|
* resize bitmap on load with scaling
|
|
|
|
*
|
|
|
|
* If HAVE_LCD_COLOR then this func use smooth scaling algorithm
|
|
|
|
* - downscaling both way use "Area Sampling"
|
|
|
|
* if IMG_RESIZE_BILINER or IMG_RESIZE_NEAREST is NOT set
|
|
|
|
* - otherwise "Bilinear" or "Nearest Neighbour"
|
|
|
|
*
|
|
|
|
* If !(HAVE_LCD_COLOR) then use simple scaling algorithm "Nearest Neighbour"
|
|
|
|
*
|
|
|
|
* return -1 for error
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
/* nothing needs the on-stack buffer right now */
|
|
|
|
#define MAX_SC_STACK_ALLOC 0
|
|
|
|
#define HAVE_UPSCALER 1
|
|
|
|
|
2009-05-26 20:00:47 +00:00
|
|
|
#define SC_OUT(n, c) (((n) + (1 << 23)) >> 24)
|
|
|
|
#ifndef SC_OUT
|
|
|
|
#define SC_OUT(n, c) (sc_mul_u32_rnd(n, (c)->recip))
|
2009-01-20 17:24:49 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-09 23:07:59 +00:00
|
|
|
struct img_part {
|
|
|
|
int len;
|
2009-01-04 21:22:05 +00:00
|
|
|
#if !defined(HAVE_LCD_COLOR)
|
2008-12-26 07:03:22 +00:00
|
|
|
uint8_t *buf;
|
|
|
|
#else
|
2008-12-09 23:07:59 +00:00
|
|
|
struct uint8_rgb* buf;
|
2008-12-26 07:03:22 +00:00
|
|
|
#endif
|
2008-12-09 23:07:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-12-26 07:03:22 +00:00
|
|
|
/* intermediate type used by the scaler for color output. greyscale version
|
|
|
|
uses uint32_t
|
|
|
|
*/
|
2011-11-08 21:39:23 +00:00
|
|
|
struct uint32_argb {
|
2008-12-26 07:03:22 +00:00
|
|
|
uint32_t r;
|
|
|
|
uint32_t g;
|
|
|
|
uint32_t b;
|
2011-11-08 21:39:23 +00:00
|
|
|
uint32_t a;
|
2008-12-26 07:03:22 +00:00
|
|
|
};
|
2008-12-09 23:07:59 +00:00
|
|
|
#endif
|
2008-12-26 07:03:22 +00:00
|
|
|
|
2008-12-26 07:05:13 +00:00
|
|
|
/* struct which contains various parameters shared between vertical scaler,
|
|
|
|
horizontal scaler, and row output
|
|
|
|
*/
|
|
|
|
struct scaler_context {
|
2009-05-26 20:00:47 +00:00
|
|
|
uint32_t h_i_val;
|
|
|
|
uint32_t h_o_val;
|
|
|
|
uint32_t v_i_val;
|
|
|
|
uint32_t v_o_val;
|
2008-12-26 07:05:13 +00:00
|
|
|
struct bitmap *bm;
|
|
|
|
struct dim *src;
|
|
|
|
unsigned char *buf;
|
|
|
|
bool dither;
|
|
|
|
int len;
|
|
|
|
void *args;
|
|
|
|
struct img_part* (*store_part)(void *);
|
|
|
|
void (*output_row)(uint32_t,void*,struct scaler_context*);
|
|
|
|
bool (*h_scaler)(void*,struct scaler_context*, bool);
|
|
|
|
};
|
|
|
|
|
2009-05-26 20:26:05 +00:00
|
|
|
#if defined(HAVE_LCD_COLOR)
|
2009-05-06 04:53:56 +00:00
|
|
|
#define IF_PIX_FMT(...) __VA_ARGS__
|
|
|
|
#else
|
|
|
|
#define IF_PIX_FMT(...)
|
|
|
|
#endif
|
|
|
|
|
2008-12-26 07:05:13 +00:00
|
|
|
struct custom_format {
|
2009-05-09 07:31:27 +00:00
|
|
|
void (*output_row_8)(uint32_t,void*, struct scaler_context*);
|
2009-05-06 04:53:56 +00:00
|
|
|
#if defined(HAVE_LCD_COLOR)
|
2009-05-09 07:31:27 +00:00
|
|
|
void (*output_row_32[2])(uint32_t,void*, struct scaler_context*);
|
2009-05-06 04:53:56 +00:00
|
|
|
#else
|
2009-05-09 07:31:27 +00:00
|
|
|
void (*output_row_32)(uint32_t,void*, struct scaler_context*);
|
2009-05-06 04:53:56 +00:00
|
|
|
#endif
|
2008-12-26 07:05:13 +00:00
|
|
|
unsigned int (*get_size)(struct bitmap *bm);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rowset;
|
2009-05-04 15:46:41 +00:00
|
|
|
|
|
|
|
extern const struct custom_format format_native;
|
|
|
|
|
2008-12-26 07:03:22 +00:00
|
|
|
int recalc_dimension(struct dim *dst, struct dim *src);
|
|
|
|
|
|
|
|
int resize_on_load(struct bitmap *bm, bool dither,
|
|
|
|
struct dim *src, struct rowset *tmp_row,
|
|
|
|
unsigned char *buf, unsigned int len,
|
2008-12-26 07:05:13 +00:00
|
|
|
const struct custom_format *cformat,
|
2009-05-06 04:53:56 +00:00
|
|
|
IF_PIX_FMT(int format_index,)
|
2008-12-09 23:07:59 +00:00
|
|
|
struct img_part* (*store_part)(void *args),
|
|
|
|
void *args);
|
2009-01-04 21:22:05 +00:00
|
|
|
|
2008-12-09 23:07:59 +00:00
|
|
|
#endif /* _RESIZE_H_ */
|