Hi,
this is actually a brown paper bag patch, as my last patch managed to break the build of nrv2b. It's basically some reordering and an additional preprocessor define on the command line.
I'm sorry that this issue slipped through (I didn't notice that my build didn't cover nrv2b anymore)
Regards, Patrick Georgi
Signed-off-by: Patrick Georgi patrick@georgi-clan.de
Index: util/nrv2b/nrv2b.c =================================================================== --- util/nrv2b/nrv2b.c (revision 367) +++ util/nrv2b/nrv2b.c (working copy) @@ -1309,9 +1309,47 @@ out = malloc(*out_len); ucl_nrv2b_99_compress(in, in_len, out, out_len, 0 ); } +#endif
+#ifdef DECODE + +#define GETBIT_8(bb, src, ilen) \ + (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) + +#define GETBIT_LE16(bb, src, ilen) \ + (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1)) + +#define GETBIT_LE32(bb, src, ilen) \ + (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\ + bb=*(const uint32_t *)((src)+ilen),ilen+=4,(bb>>31)&1)) + +#if ENDIAN == 0 && BITSIZE == 8 +#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 16 +#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 32 +#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen) +#endif + +#ifndef GETBIT +#error "Bad Combination of ENDIAN and BITSIZE values specified" +#endif + +#undef SAFE + +#ifdef SAFE +#define FAIL(x,r) if (x) { Error(r); } +#else +#define FAIL(x,r) +#endif + +#ifdef COMPACT void do_nrv2b_uncompress(char* dst, char* src, unsigned long len) { unsigned long ilen = 0, olen = 0, last_m_off = 1; + uint32_t bb = 0; + unsigned bc = 0; for (;;) { unsigned int m_off, m_len; while (GETBIT(bb, src, ilen)) { @@ -1359,42 +1397,7 @@ } FAIL(ilen < src_len, "input not consumed"); } -#endif - -#ifdef DECODE - -#define GETBIT_8(bb, src, ilen) \ - (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) - -#define GETBIT_LE16(bb, src, ilen) \ - (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1)) - -#define GETBIT_LE32(bb, src, ilen) \ - (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\ - bb=*(const uint32_t *)((src)+ilen),ilen+=4,(bb>>31)&1)) - -#if ENDIAN == 0 && BITSIZE == 8 -#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen) -#endif -#if ENDIAN == 0 && BITSIZE == 16 -#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen) -#endif -#if ENDIAN == 0 && BITSIZE == 32 -#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen) -#endif - -#ifndef GETBIT -#error "Bad Combination of ENDIAN and BITSIZE values specified" -#endif - -#undef SAFE - -#ifdef SAFE -#define FAIL(x,r) if (x) { Error(r); } #else -#define FAIL(x,r) -#endif - void Decode(void) /* recover */ { uint32_t tw; @@ -1494,6 +1497,7 @@ free(dst); } #endif +#endif
#ifdef MAIN int main(int argc, char *argv[]) Index: util/nrv2b/Makefile =================================================================== --- util/nrv2b/Makefile (revision 367) +++ util/nrv2b/Makefile (working copy) @@ -25,7 +25,7 @@
$(obj)/util/nrv2b/nrv2b-compress.o: nrv2bdir $(src)/util/nrv2b/nrv2b.c $(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n" - $(Q)$(HOSTCC) $(HOSTCFLAGS) -DENCODE -DVERBOSE -DCOMPACT -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -c -o $@ $(src)/util/nrv2b/nrv2b.c + $(Q)$(HOSTCC) $(HOSTCFLAGS) -DENCODE -DDECODE -DVERBOSE -DCOMPACT -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -c -o $@ $(src)/util/nrv2b/nrv2b.c
nrv2bdir: $(Q)printf " BUILD NRV2B\n"