diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2008-10-28 21:07:53 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2008-10-28 21:07:53 +0000 |
| commit | 2c52dee83f5c796fe471e6fab15dea17a2f508ff (patch) | |
| tree | 4f90ccd3c1d5785385fea9144e5011b1943acfcd /firmware/decompressor/decompressor.c | |
| parent | afd2f681d18e574442f8569f1a722d5d39d79b78 (diff) | |
| download | rockbox-2c52dee83f5c796fe471e6fab15dea17a2f508ff.zip rockbox-2c52dee83f5c796fe471e6fab15dea17a2f508ff.tar.gz rockbox-2c52dee83f5c796fe471e6fab15dea17a2f508ff.tar.bz2 rockbox-2c52dee83f5c796fe471e6fab15dea17a2f508ff.tar.xz | |
Self-extractor for on-disk firmware image: UCL decompressor in SH1 assembler - less than half the size of the compiled C function, and ~45% faster.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18904 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/decompressor/decompressor.c')
| -rw-r--r-- | firmware/decompressor/decompressor.c | 69 |
1 files changed, 2 insertions, 67 deletions
diff --git a/firmware/decompressor/decompressor.c b/firmware/decompressor/decompressor.c index cec82b8..11888ef 100644 --- a/firmware/decompressor/decompressor.c +++ b/firmware/decompressor/decompressor.c @@ -36,8 +36,8 @@ extern char loadaddress[], dramend[]; extern void start(void); void main(void) ICODE_ATTR; -static int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst, - unsigned long *dst_len) ICODE_ATTR; +int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst, + unsigned long *dst_len) ICODE_ATTR; /* Vector table */ void (*vbr[]) (void) __attribute__ ((section (".vectors"))) = @@ -50,71 +50,6 @@ void (*vbr[]) (void) __attribute__ ((section (".vectors"))) = /** All subsequent functions are executed from IRAM **/ -/* Thinned out version of the UCL 2e decompression sourcecode - * Original (C) Markus F.X.J Oberhumer under GNU GPL license */ -#define GETBIT(bb, src, ilen) \ - (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) - -static int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst, - unsigned long *dst_len) -{ - unsigned long bb = 0; - unsigned ilen = 0, olen = 0, last_m_off = 1; - - for (;;) - { - unsigned m_off, m_len; - - while (GETBIT(bb,src,ilen)) - dst[olen++] = src[ilen++]; - - m_off = 1; - for (;;) - { - m_off = m_off*2 + GETBIT(bb,src,ilen); - if (GETBIT(bb,src,ilen)) - break; - m_off = (m_off-1)*2 + GETBIT(bb,src,ilen); - } - if (m_off == 2) - { - m_off = last_m_off; - m_len = GETBIT(bb,src,ilen); - } - else - { - m_off = (m_off-3)*256 + src[ilen++]; - if (m_off == 0xffffffff) - break; - m_len = (m_off ^ 0xffffffff) & 1; - m_off >>= 1; - last_m_off = ++m_off; - } - if (m_len) - m_len = 1 + GETBIT(bb,src,ilen); - else if (GETBIT(bb,src,ilen)) - m_len = 3 + GETBIT(bb,src,ilen); - else - { - m_len++; - do { - m_len = m_len*2 + GETBIT(bb,src,ilen); - } while (!GETBIT(bb,src,ilen)); - m_len += 3; - } - m_len += (m_off > 0x500); - { - const unsigned char *m_pos; - m_pos = dst + olen - m_off; - dst[olen++] = *m_pos++; - do dst[olen++] = *m_pos++; while (--m_len > 0); - } - } - *dst_len = olen; - - return ilen; -} - #define ALIGNED_IMG_SIZE ((sizeof(image) + 3) & ~3) /* This will never return */ void main(void) |