From 52320b83c0e9fb3c3f6c463f8bd61de35f03b235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Mon, 12 Jan 2009 21:56:46 +0000 Subject: Added missing dependencies for codeclib and pluginlib. This required renaming some files that have twins in other places. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19756 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/codecs.make | 1 + apps/codecs/lib/codeclib_misc.h | 291 +++++++++++++++++++++++++++++++ apps/codecs/lib/mdct2.h | 2 +- apps/codecs/lib/misc.h | 291 ------------------------------- apps/plugins/lib/SOURCES | 4 +- apps/plugins/lib/bmp.c | 138 --------------- apps/plugins/lib/bmp.h | 56 ------ apps/plugins/lib/bmp_smooth_scale.c | 2 +- apps/plugins/lib/pluginlib_bmp.c | 138 +++++++++++++++ apps/plugins/lib/pluginlib_bmp.h | 56 ++++++ apps/plugins/lib/pluginlib_resize.c | 34 ++++ apps/plugins/lib/pluginlib_resize.h | 29 +++ apps/plugins/lib/resize.c | 34 ---- apps/plugins/lib/resize.h | 29 --- apps/plugins/plugins.make | 2 +- apps/plugins/ppmviewer.c | 2 +- apps/plugins/rockpaint.c | 2 +- apps/plugins/test_greylib_bitmap_scale.c | 4 +- apps/plugins/test_resize.c | 2 +- 19 files changed, 559 insertions(+), 558 deletions(-) create mode 100644 apps/codecs/lib/codeclib_misc.h delete mode 100644 apps/codecs/lib/misc.h delete mode 100644 apps/plugins/lib/bmp.c delete mode 100644 apps/plugins/lib/bmp.h create mode 100644 apps/plugins/lib/pluginlib_bmp.c create mode 100644 apps/plugins/lib/pluginlib_bmp.h create mode 100644 apps/plugins/lib/pluginlib_resize.c create mode 100644 apps/plugins/lib/pluginlib_resize.h delete mode 100644 apps/plugins/lib/resize.c delete mode 100644 apps/plugins/lib/resize.h diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make index 2ba73af..8bfa53c 100644 --- a/apps/codecs/codecs.make +++ b/apps/codecs/codecs.make @@ -16,6 +16,7 @@ CODECS := $(subst $(ROOTDIR),$(BUILDDIR),$(CODECS)) # the codec helper library include $(APPSDIR)/codecs/lib/libcodec.make +OTHER_INC += -I$(APPSDIR)/codecs/lib # the codec libraries include $(APPSDIR)/codecs/demac/libdemac.make diff --git a/apps/codecs/lib/codeclib_misc.h b/apps/codecs/lib/codeclib_misc.h new file mode 100644 index 0000000..5ab78d6 --- /dev/null +++ b/apps/codecs/lib/codeclib_misc.h @@ -0,0 +1,291 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: miscellaneous math and prototypes + + ********************************************************************/ + +//#include "config-tremor.h" + +#ifndef _V_RANDOM_H_ +#define _V_RANDOM_H_ +//#include "ivorbiscodec.h" +//#include "os_types.h" + +//#include "asm_arm.h" +//#include "asm_mcf5249.h" + + +/* Some prototypes that were not defined elsewhere */ +//void *_vorbis_block_alloc(vorbis_block *vb,long bytes); +//void _vorbis_block_ripcord(vorbis_block *vb); +//extern int _ilog(unsigned int v); + +#ifndef _V_WIDE_MATH +#define _V_WIDE_MATH + +#ifndef _LOW_ACCURACY_ +/* 64 bit multiply */ +/* #include */ + +#if BYTE_ORDER==LITTLE_ENDIAN +union magic { + struct { + int32_t lo; + int32_t hi; + } halves; + int64_t whole; +}; +#elif BYTE_ORDER==BIG_ENDIAN +union magic { + struct { + int32_t hi; + int32_t lo; + } halves; + int64_t whole; +}; +#endif + +static inline int32_t MULT32(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return magic.halves.hi; +} +static inline int32_t MULT31(int32_t x, int32_t y) { + return MULT32(x,y)<<1; +} + +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); +} + +#else +/* 32 bit multiply, more portable but less accurate */ + +/* + * Note: Precision is biased towards the first argument therefore ordering + * is important. Shift values were chosen for the best sound quality after + * many listening tests. + */ + +/* + * For MULT32 and MULT31: The second argument is always a lookup table + * value already preshifted from 31 to 8 bits. We therefore take the + * opportunity to save on text space and use unsigned char for those + * tables in this case. + */ + +static inline int32_t MULT32(int32_t x, int32_t y) { + return (x >> 9) * y; /* y preshifted >>23 */ +} + +static inline int32_t MULT31(int32_t x, int32_t y) { + return (x >> 8) * y; /* y preshifted >>23 */ +} + +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + return (x >> 6) * y; /* y preshifted >>9 */ +} +#endif + +/* + * This should be used as a memory barrier, forcing all cached values in + * registers to wr writen back to memory. Might or might not be beneficial + * depending on the architecture and compiler. + */ +#define MB() + +/* + * The XPROD functions are meant to optimize the cross products found all + * over the place in mdct.c by forcing memory operation ordering to avoid + * unnecessary register reloads as soon as memory is being written to. + * However this is only beneficial on CPUs with a sane number of general + * purpose registers which exclude the Intel x86. On Intel, better let the + * compiler actually reload registers directly from original memory by using + * macros. + */ + +/* replaced XPROD32 with a macro to avoid memory reference + _x, _y are the results (must be l-values) */ +#define XPROD32(_a, _b, _t, _v, _x, _y) \ + { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ + (_y)=MULT32(_b,_t)-MULT32(_a,_v); } + + +#ifdef __i386__ + +#define XPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } +#define XNPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } + +#else + +static inline void XPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + *x = MULT31(a, t) + MULT31(b, v); + *y = MULT31(b, t) - MULT31(a, v); +} + +static inline void XNPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + *x = MULT31(a, t) - MULT31(b, v); + *y = MULT31(b, t) + MULT31(a, v); +} +#endif + +#ifndef _V_VECT_OPS +#define _V_VECT_OPS + +static inline +void vect_add(int32_t *x, int32_t *y, int n) +{ + while (n>0) { + *x++ += *y++; + n--; + } +} + +static inline +void vect_copy(int32_t *x, int32_t *y, int n) +{ + while (n>0) { + *x++ = *y++; + n--; + } +} + +static inline +void vect_mult_fw(int32_t *data, int32_t *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window++; + n--; + } +} + +static inline +void vect_mult_bw(int32_t *data, int32_t *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window--; + n--; + } +} +#endif + +#endif + +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +static inline int32_t CLIP_TO_15(int32_t x) { + int ret=x; + ret-= ((x<=32767)-1)&(x-32767); + ret-= ((x>=-32768)-1)&(x+32768); + return(ret); +} + +#endif + +static inline int32_t VFLOAT_MULT(int32_t a,int32_t ap, + int32_t b,int32_t bp, + int32_t *p){ + if(a && b){ +#ifndef _LOW_ACCURACY_ + *p=ap+bp+32; + return MULT32(a,b); +#else + *p=ap+bp+31; + return (a>>15)*(b>>16); +#endif + }else + return 0; +} + +/*static inline int32_t VFLOAT_MULTI(int32_t a,int32_t ap, + int32_t i, + int32_t *p){ + + int ip=_ilog(abs(i))-31; + return VFLOAT_MULT(a,ap,i<<-ip,ip,p); +} +*/ +static inline int32_t VFLOAT_ADD(int32_t a,int32_t ap, + int32_t b,int32_t bp, + int32_t *p){ + + if(!a){ + *p=bp; + return b; + }else if(!b){ + *p=ap; + return a; + } + + /* yes, this can leak a bit. */ + if(ap>bp){ + int shift=ap-bp+1; + *p=ap+1; + a>>=1; + if(shift<32){ + b=(b+(1<<(shift-1)))>>shift; + }else{ + b=0; + } + }else{ + int shift=bp-ap+1; + *p=bp+1; + b>>=1; + if(shift<32){ + a=(a+(1<<(shift-1)))>>shift; + }else{ + a=0; + } + } + + a+=b; + if((a&0xc0000000)==0xc0000000 || + (a&0xc0000000)==0){ + a<<=1; + (*p)--; + } + return(a); +} + +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define EXPECT(a, b) __builtin_expect((a), (b)) +#else +#define EXPECT(a, b) (a) +#endif +#else +#define EXPECT(a, b) (a) +#endif + +#endif + + + diff --git a/apps/codecs/lib/mdct2.h b/apps/codecs/lib/mdct2.h index b03430b..ba0f129 100644 --- a/apps/codecs/lib/mdct2.h +++ b/apps/codecs/lib/mdct2.h @@ -31,7 +31,7 @@ #include #include "asm_arm.h" #include "asm_mcf5249.h" -#include "misc.h" +#include "codeclib_misc.h" #ifndef ICONST_ATTR_TREMOR_WINDOW #define ICONST_ATTR_TREMOR_WINDOW ICONST_ATTR diff --git a/apps/codecs/lib/misc.h b/apps/codecs/lib/misc.h deleted file mode 100644 index 5ab78d6..0000000 --- a/apps/codecs/lib/misc.h +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: miscellaneous math and prototypes - - ********************************************************************/ - -//#include "config-tremor.h" - -#ifndef _V_RANDOM_H_ -#define _V_RANDOM_H_ -//#include "ivorbiscodec.h" -//#include "os_types.h" - -//#include "asm_arm.h" -//#include "asm_mcf5249.h" - - -/* Some prototypes that were not defined elsewhere */ -//void *_vorbis_block_alloc(vorbis_block *vb,long bytes); -//void _vorbis_block_ripcord(vorbis_block *vb); -//extern int _ilog(unsigned int v); - -#ifndef _V_WIDE_MATH -#define _V_WIDE_MATH - -#ifndef _LOW_ACCURACY_ -/* 64 bit multiply */ -/* #include */ - -#if BYTE_ORDER==LITTLE_ENDIAN -union magic { - struct { - int32_t lo; - int32_t hi; - } halves; - int64_t whole; -}; -#elif BYTE_ORDER==BIG_ENDIAN -union magic { - struct { - int32_t hi; - int32_t lo; - } halves; - int64_t whole; -}; -#endif - -static inline int32_t MULT32(int32_t x, int32_t y) { - union magic magic; - magic.whole = (int64_t)x * y; - return magic.halves.hi; -} -static inline int32_t MULT31(int32_t x, int32_t y) { - return MULT32(x,y)<<1; -} - -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - union magic magic; - magic.whole = (int64_t)x * y; - return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); -} - -#else -/* 32 bit multiply, more portable but less accurate */ - -/* - * Note: Precision is biased towards the first argument therefore ordering - * is important. Shift values were chosen for the best sound quality after - * many listening tests. - */ - -/* - * For MULT32 and MULT31: The second argument is always a lookup table - * value already preshifted from 31 to 8 bits. We therefore take the - * opportunity to save on text space and use unsigned char for those - * tables in this case. - */ - -static inline int32_t MULT32(int32_t x, int32_t y) { - return (x >> 9) * y; /* y preshifted >>23 */ -} - -static inline int32_t MULT31(int32_t x, int32_t y) { - return (x >> 8) * y; /* y preshifted >>23 */ -} - -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - return (x >> 6) * y; /* y preshifted >>9 */ -} -#endif - -/* - * This should be used as a memory barrier, forcing all cached values in - * registers to wr writen back to memory. Might or might not be beneficial - * depending on the architecture and compiler. - */ -#define MB() - -/* - * The XPROD functions are meant to optimize the cross products found all - * over the place in mdct.c by forcing memory operation ordering to avoid - * unnecessary register reloads as soon as memory is being written to. - * However this is only beneficial on CPUs with a sane number of general - * purpose registers which exclude the Intel x86. On Intel, better let the - * compiler actually reload registers directly from original memory by using - * macros. - */ - -/* replaced XPROD32 with a macro to avoid memory reference - _x, _y are the results (must be l-values) */ -#define XPROD32(_a, _b, _t, _v, _x, _y) \ - { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ - (_y)=MULT32(_b,_t)-MULT32(_a,_v); } - - -#ifdef __i386__ - -#define XPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } -#define XNPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } - -#else - -static inline void XPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - *x = MULT31(a, t) + MULT31(b, v); - *y = MULT31(b, t) - MULT31(a, v); -} - -static inline void XNPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - *x = MULT31(a, t) - MULT31(b, v); - *y = MULT31(b, t) + MULT31(a, v); -} -#endif - -#ifndef _V_VECT_OPS -#define _V_VECT_OPS - -static inline -void vect_add(int32_t *x, int32_t *y, int n) -{ - while (n>0) { - *x++ += *y++; - n--; - } -} - -static inline -void vect_copy(int32_t *x, int32_t *y, int n) -{ - while (n>0) { - *x++ = *y++; - n--; - } -} - -static inline -void vect_mult_fw(int32_t *data, int32_t *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window++; - n--; - } -} - -static inline -void vect_mult_bw(int32_t *data, int32_t *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window--; - n--; - } -} -#endif - -#endif - -#ifndef _V_CLIP_MATH -#define _V_CLIP_MATH - -static inline int32_t CLIP_TO_15(int32_t x) { - int ret=x; - ret-= ((x<=32767)-1)&(x-32767); - ret-= ((x>=-32768)-1)&(x+32768); - return(ret); -} - -#endif - -static inline int32_t VFLOAT_MULT(int32_t a,int32_t ap, - int32_t b,int32_t bp, - int32_t *p){ - if(a && b){ -#ifndef _LOW_ACCURACY_ - *p=ap+bp+32; - return MULT32(a,b); -#else - *p=ap+bp+31; - return (a>>15)*(b>>16); -#endif - }else - return 0; -} - -/*static inline int32_t VFLOAT_MULTI(int32_t a,int32_t ap, - int32_t i, - int32_t *p){ - - int ip=_ilog(abs(i))-31; - return VFLOAT_MULT(a,ap,i<<-ip,ip,p); -} -*/ -static inline int32_t VFLOAT_ADD(int32_t a,int32_t ap, - int32_t b,int32_t bp, - int32_t *p){ - - if(!a){ - *p=bp; - return b; - }else if(!b){ - *p=ap; - return a; - } - - /* yes, this can leak a bit. */ - if(ap>bp){ - int shift=ap-bp+1; - *p=ap+1; - a>>=1; - if(shift<32){ - b=(b+(1<<(shift-1)))>>shift; - }else{ - b=0; - } - }else{ - int shift=bp-ap+1; - *p=bp+1; - b>>=1; - if(shift<32){ - a=(a+(1<<(shift-1)))>>shift; - }else{ - a=0; - } - } - - a+=b; - if((a&0xc0000000)==0xc0000000 || - (a&0xc0000000)==0){ - a<<=1; - (*p)--; - } - return(a); -} - -#ifdef __GNUC__ -#if __GNUC__ >= 3 -#define EXPECT(a, b) __builtin_expect((a), (b)) -#else -#define EXPECT(a, b) (a) -#endif -#else -#define EXPECT(a, b) (a) -#endif - -#endif - - - diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index b55fea0..bb7da12 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -9,7 +9,7 @@ rgb_hsv.c pluginlib for use with greylib overlay output */ #if LCD_DEPTH == 1 -resize.c +pluginlib_resize.c #endif grey_core.c grey_draw.c @@ -37,7 +37,7 @@ picture.c xlcd_core.c xlcd_draw.c xlcd_scroll.c -bmp.c +pluginlib_bmp.c #ifdef HAVE_LCD_COLOR bmp_smooth_scale.c #endif diff --git a/apps/plugins/lib/bmp.c b/apps/plugins/lib/bmp.c deleted file mode 100644 index 1cb24d3..0000000 --- a/apps/plugins/lib/bmp.c +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by Antoine Cellerier - * Copyright (C) 2009 by Andrew Mahone - * - * 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. - * - ****************************************************************************/ - -#include "bmp.h" - -#include "lcd.h" -#include "file.h" -#include "lcd.h" -#include "system.h" - -#if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ -#ifdef HAVE_LCD_COLOR -#define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff -#define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff -/** - * Save to 24 bit bitmap. - */ -int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ) -{ - /* I'm not really sure about this one :) */ - int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); - - const unsigned char header[] = - { - 0x42, 0x4d, /* signature - 'BM' */ - LE32( bm->height*line_width + 54 + 4*0 ), /* file size in bytes */ - 0x00, 0x00, 0x00, 0x00, /* 0, 0 */ - LE32( 54 + 4*0 ), /* offset to bitmap */ - 0x28, 0x00, 0x00, 0x00, /* size of this struct (40) */ - LE32( bm->width ), /* bmap width in pixels */ - LE32( bm->height ), /* bmap height in pixels */ - 0x01, 0x00, /* num planes - always 1 */ - LE16( 24 ), /* bits per pixel */ - LE32( 0 ), /* compression flag */ - LE32( bm->height*line_width ), /* image size in bytes */ - 0xc4, 0x0e, 0x00, 0x00, /* horz resolution */ - 0xc4, 0x0e, 0x00, 0x00, /* vert resolution */ - LE32( 0 ), /* 0 -> color table size */ - LE32( 0 ) /* important color count */ - }; - - int fh; - int x,y; - if( bm->format != FORMAT_NATIVE ) return -1; - fh = rb->creat( filename ); - if( fh < 0 ) return -1; - - rb->write( fh, header, sizeof( header ) ); - for( y = bm->height-1; y >= 0; y-- ) - { - for( x = 0; x < bm->width; x++ ) - { - fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width); - unsigned char c[] = - { - RGB_UNPACK_BLUE( *d ), - RGB_UNPACK_GREEN( *d ), - RGB_UNPACK_RED( *d ) - }; - rb->write( fh, c, 3 ); - } - for( x = 0; x < 3*bm->width - line_width; x++ ) - { - unsigned char c = 0; - rb->write( fh, &c, 1 ); - } - } - rb->close( fh ); - return 1; -} -#endif - -/** - Very simple image scale from src to dst (nearest neighbour). - Source and destination dimensions are read from the struct bitmap. -*/ -void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) -{ - const int srcw = src->width; - const int srch = src->height; - const int dstw = dst->width; - const int dsth = dst->height; - const fb_data *srcd = (fb_data*)(src->data); - const fb_data *dstd = (fb_data*)(dst->data); - - const long xrstep = ((srcw-1) << 8) / (dstw-1); - const long yrstep = ((srch-1) << 8) / (dsth-1); - fb_data *src_row, *dst_row; - long xr, yr = 0; - int src_x, src_y, dst_x, dst_y; - for (dst_y=0; dst_y < dsth; dst_y++) - { - src_y = (yr >> 8); - src_row = (fb_data*)&srcd[src_y * srcw]; - dst_row = (fb_data*)&dstd[dst_y * dstw]; - for (xr=0,dst_x=0; dst_x < dstw; dst_x++) - { - src_x = (xr >> 8); - dst_row[dst_x] = src_row[src_x]; - xr += xrstep; - } - yr += yrstep; - } -} - -#else /* LCD_DEPTH == 1 */ -#include "wrappers.h" - -static const struct plugin_api *rb; - -/* import the core bmp loader */ -#include "../../recorder/bmp.c" - -/* initialize rb for use by the bmp loader */ -void bmp_init(const struct plugin_api *api) -{ - rb = api; -} -#endif diff --git a/apps/plugins/lib/bmp.h b/apps/plugins/lib/bmp.h deleted file mode 100644 index 0e7a0a4..0000000 --- a/apps/plugins/lib/bmp.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by Antoine Cellerier - * - * 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 _LIB_BMP_H_ -#define _LIB_BMP_H_ - -#include "lcd.h" -#include "plugin.h" - -#if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ -#ifdef HAVE_LCD_COLOR -/** - * Save bitmap to file - */ -int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ); -#endif - -/** - Very simple image scale from src to dst (nearest neighbour). - Source and destination dimensions are read from the struct bitmap. -*/ -void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); - -/** - Advanced image scale from src to dst (bilinear) based on imlib2. - Source and destination dimensions are read from the struct bitmap. - */ -void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); - -#else -/* - BMP loader is built with scaling support in pluginlib on 1bpp targets, as - these do not provide scaling support in the core BMP loader. bmp_init is - needed to copy the plugin API pointer for the pluginlib loader's use. -*/ -void bmp_init(const struct plugin_api *api); -#endif - -#endif diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c index 860a20e..4d5eab0 100644 --- a/apps/plugins/lib/bmp_smooth_scale.c +++ b/apps/plugins/lib/bmp_smooth_scale.c @@ -70,7 +70,7 @@ * (C) Daniel M. Duley. */ -#include "bmp.h" +#include "pluginlib_bmp.h" #include "lcd.h" void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c new file mode 100644 index 0000000..b1dd53b --- /dev/null +++ b/apps/plugins/lib/pluginlib_bmp.c @@ -0,0 +1,138 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Antoine Cellerier + * Copyright (C) 2009 by Andrew Mahone + * + * 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. + * + ****************************************************************************/ + +#include "pluginlib_bmp.h" + +#include "lcd.h" +#include "file.h" +#include "lcd.h" +#include "system.h" + +#if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ +#ifdef HAVE_LCD_COLOR +#define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff +#define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff +/** + * Save to 24 bit bitmap. + */ +int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ) +{ + /* I'm not really sure about this one :) */ + int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); + + const unsigned char header[] = + { + 0x42, 0x4d, /* signature - 'BM' */ + LE32( bm->height*line_width + 54 + 4*0 ), /* file size in bytes */ + 0x00, 0x00, 0x00, 0x00, /* 0, 0 */ + LE32( 54 + 4*0 ), /* offset to bitmap */ + 0x28, 0x00, 0x00, 0x00, /* size of this struct (40) */ + LE32( bm->width ), /* bmap width in pixels */ + LE32( bm->height ), /* bmap height in pixels */ + 0x01, 0x00, /* num planes - always 1 */ + LE16( 24 ), /* bits per pixel */ + LE32( 0 ), /* compression flag */ + LE32( bm->height*line_width ), /* image size in bytes */ + 0xc4, 0x0e, 0x00, 0x00, /* horz resolution */ + 0xc4, 0x0e, 0x00, 0x00, /* vert resolution */ + LE32( 0 ), /* 0 -> color table size */ + LE32( 0 ) /* important color count */ + }; + + int fh; + int x,y; + if( bm->format != FORMAT_NATIVE ) return -1; + fh = rb->creat( filename ); + if( fh < 0 ) return -1; + + rb->write( fh, header, sizeof( header ) ); + for( y = bm->height-1; y >= 0; y-- ) + { + for( x = 0; x < bm->width; x++ ) + { + fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width); + unsigned char c[] = + { + RGB_UNPACK_BLUE( *d ), + RGB_UNPACK_GREEN( *d ), + RGB_UNPACK_RED( *d ) + }; + rb->write( fh, c, 3 ); + } + for( x = 0; x < 3*bm->width - line_width; x++ ) + { + unsigned char c = 0; + rb->write( fh, &c, 1 ); + } + } + rb->close( fh ); + return 1; +} +#endif + +/** + Very simple image scale from src to dst (nearest neighbour). + Source and destination dimensions are read from the struct bitmap. +*/ +void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) +{ + const int srcw = src->width; + const int srch = src->height; + const int dstw = dst->width; + const int dsth = dst->height; + const fb_data *srcd = (fb_data*)(src->data); + const fb_data *dstd = (fb_data*)(dst->data); + + const long xrstep = ((srcw-1) << 8) / (dstw-1); + const long yrstep = ((srch-1) << 8) / (dsth-1); + fb_data *src_row, *dst_row; + long xr, yr = 0; + int src_x, src_y, dst_x, dst_y; + for (dst_y=0; dst_y < dsth; dst_y++) + { + src_y = (yr >> 8); + src_row = (fb_data*)&srcd[src_y * srcw]; + dst_row = (fb_data*)&dstd[dst_y * dstw]; + for (xr=0,dst_x=0; dst_x < dstw; dst_x++) + { + src_x = (xr >> 8); + dst_row[dst_x] = src_row[src_x]; + xr += xrstep; + } + yr += yrstep; + } +} + +#else /* LCD_DEPTH == 1 */ +#include "wrappers.h" + +static const struct plugin_api *rb; + +/* import the core bmp loader */ +#include "../../recorder/bmp.c" + +/* initialize rb for use by the bmp loader */ +void bmp_init(const struct plugin_api *api) +{ + rb = api; +} +#endif diff --git a/apps/plugins/lib/pluginlib_bmp.h b/apps/plugins/lib/pluginlib_bmp.h new file mode 100644 index 0000000..0e7a0a4 --- /dev/null +++ b/apps/plugins/lib/pluginlib_bmp.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Antoine Cellerier + * + * 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 _LIB_BMP_H_ +#define _LIB_BMP_H_ + +#include "lcd.h" +#include "plugin.h" + +#if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ +#ifdef HAVE_LCD_COLOR +/** + * Save bitmap to file + */ +int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ); +#endif + +/** + Very simple image scale from src to dst (nearest neighbour). + Source and destination dimensions are read from the struct bitmap. +*/ +void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); + +/** + Advanced image scale from src to dst (bilinear) based on imlib2. + Source and destination dimensions are read from the struct bitmap. + */ +void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); + +#else +/* + BMP loader is built with scaling support in pluginlib on 1bpp targets, as + these do not provide scaling support in the core BMP loader. bmp_init is + needed to copy the plugin API pointer for the pluginlib loader's use. +*/ +void bmp_init(const struct plugin_api *api); +#endif + +#endif diff --git a/apps/plugins/lib/pluginlib_resize.c b/apps/plugins/lib/pluginlib_resize.c new file mode 100644 index 0000000..28446e7 --- /dev/null +++ b/apps/plugins/lib/pluginlib_resize.c @@ -0,0 +1,34 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a wrapper for the core resize.c +* +* 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. +* +****************************************************************************/ + +#include +#include "wrappers.h" + +static const struct plugin_api *rb; + +#include "../../recorder/resize.c" + +void resize_init(const struct plugin_api *api) +{ + rb = api; +} diff --git a/apps/plugins/lib/pluginlib_resize.h b/apps/plugins/lib/pluginlib_resize.h new file mode 100644 index 0000000..46a8977 --- /dev/null +++ b/apps/plugins/lib/pluginlib_resize.h @@ -0,0 +1,29 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a header for the pluginlib extensions to the core resize.c file +* +* 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 _LIB_RESIZE_H_ +#define _LIB_RESIZE_H_ + +void resize_init(const struct plugin_api *api); + +#endif diff --git a/apps/plugins/lib/resize.c b/apps/plugins/lib/resize.c deleted file mode 100644 index 28446e7..0000000 --- a/apps/plugins/lib/resize.c +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** -* __________ __ ___. -* Open \______ \ ____ ____ | | _\_ |__ _______ ___ -* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -* \/ \/ \/ \/ \/ -* $Id$ -* -* Copyright (C) 2009 by Andrew Mahone -* -* This is a wrapper for the core resize.c -* -* 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. -* -****************************************************************************/ - -#include -#include "wrappers.h" - -static const struct plugin_api *rb; - -#include "../../recorder/resize.c" - -void resize_init(const struct plugin_api *api) -{ - rb = api; -} diff --git a/apps/plugins/lib/resize.h b/apps/plugins/lib/resize.h deleted file mode 100644 index 46a8977..0000000 --- a/apps/plugins/lib/resize.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** -* __________ __ ___. -* Open \______ \ ____ ____ | | _\_ |__ _______ ___ -* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -* \/ \/ \/ \/ \/ -* $Id$ -* -* Copyright (C) 2009 by Andrew Mahone -* -* This is a header for the pluginlib extensions to the core resize.c file -* -* 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 _LIB_RESIZE_H_ -#define _LIB_RESIZE_H_ - -void resize_init(const struct plugin_api *api); - -#endif diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make index 0921c0b..c6c399d 100644 --- a/apps/plugins/plugins.make +++ b/apps/plugins/plugins.make @@ -32,7 +32,7 @@ $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link -OTHER_INC += -I$(APPSDIR)/plugins +OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib # special compile flags for plugins: PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) diff --git a/apps/plugins/ppmviewer.c b/apps/plugins/ppmviewer.c index 97f085a..6db24ff 100644 --- a/apps/plugins/ppmviewer.c +++ b/apps/plugins/ppmviewer.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include "plugin.h" -#include "lib/bmp.h" +#include "lib/pluginlib_bmp.h" #if defined(HAVE_LCD_COLOR) diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index b66324c..96ae7c5 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c @@ -29,7 +29,7 @@ */ #include "plugin.h" -#include "lib/bmp.h" +#include "lib/pluginlib_bmp.h" #include "lib/rgb_hsv.h" PLUGIN_HEADER diff --git a/apps/plugins/test_greylib_bitmap_scale.c b/apps/plugins/test_greylib_bitmap_scale.c index a3de006..1e45130 100644 --- a/apps/plugins/test_greylib_bitmap_scale.c +++ b/apps/plugins/test_greylib_bitmap_scale.c @@ -21,8 +21,8 @@ #include "plugin.h" #include "lib/grey.h" -#include "lib/resize.h" -#include "lib/bmp.h" +#include "lib/pluginlib_resize.h" +#include "lib/pluginlib_bmp.h" #if LCD_DEPTH == 1 #define BMP_LOAD read_bmp_file diff --git a/apps/plugins/test_resize.c b/apps/plugins/test_resize.c index a608005..e98fa80 100644 --- a/apps/plugins/test_resize.c +++ b/apps/plugins/test_resize.c @@ -26,7 +26,7 @@ #include "plugin.h" #include "lib/pluginlib_actions.h" -#include "lib/bmp.h" +#include "lib/pluginlib_bmp.h" PLUGIN_HEADER -- cgit v1.1