forked from len0rd/rockbox
Added jpeg decoder jpegp.c using RAINBOW lib. Currently enabled only for pictures not supported by old decoder (as old decoder more optimized for low mem targets) Someone TODO: * Old decoder has optimized downscale logic which new decoder doesn't have (it gives big difference in required memory and time for decoding). This logic should be ported/adapted if possible. * Add smooth downscaling. * Grayscale support Change-Id: Ie96bc62848b51cc6a3942f8e069ec6ab02dc1c56
71 lines
1.1 KiB
C
71 lines
1.1 KiB
C
#include "rb_glue.h"
|
|
|
|
static int fd;
|
|
|
|
extern int GETC(void)
|
|
{
|
|
unsigned char x;
|
|
rb->read(fd, &x, 1);
|
|
return x;
|
|
}
|
|
|
|
// multibyte readers: host-endian independent - if evaluated in right order (ie. don't optimize)
|
|
|
|
extern int GETWbi(void) // 16-bit big-endian
|
|
{
|
|
return ( GETC()<<8 ) | GETC();
|
|
}
|
|
|
|
extern int GETDbi(void) // 32-bit big-endian
|
|
{
|
|
return ( GETC()<<24 ) | ( GETC()<<16 ) | ( GETC()<<8 ) | GETC();
|
|
}
|
|
|
|
extern int GETWli(void) // 16-bit little-endian
|
|
{
|
|
return GETC() | ( GETC()<<8 );
|
|
}
|
|
|
|
extern int GETDli(void) // 32-bit little-endian
|
|
{
|
|
return GETC() | ( GETC()<<8 ) | ( GETC()<<16 ) | ( GETC()<<24 );
|
|
}
|
|
|
|
// seek
|
|
|
|
extern void SEEK(int d)
|
|
{
|
|
rb->lseek(fd, d, SEEK_CUR);
|
|
}
|
|
|
|
extern void POS(int d)
|
|
{
|
|
rb->lseek(fd, d, SEEK_SET);
|
|
}
|
|
|
|
extern int TELL(void)
|
|
{
|
|
return rb->lseek(fd, 0, SEEK_CUR);
|
|
}
|
|
|
|
// OPEN/CLOSE file
|
|
|
|
extern void *OPEN(char *f)
|
|
{
|
|
printf("Opening %s\n", f);
|
|
|
|
fd = rb->open(f,O_RDONLY);
|
|
|
|
if ( fd < 0 )
|
|
{
|
|
printf("Error opening %s\n", f);
|
|
return NULL;
|
|
}
|
|
|
|
return &fd;
|
|
}
|
|
|
|
extern int CLOSE(void)
|
|
{
|
|
return rb->close(fd);
|
|
}
|