Commit 86776dfd authored by michael's avatar michael

simpify state and make code 2% faster

reimar, dont hesitate to flame me for not sending patches and feel free to revert any or all of my changes to lzo.c if you dont like them


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@7778 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 753861a1
...@@ -168,7 +168,7 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) { ...@@ -168,7 +168,7 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) {
* LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes
*/ */
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) { int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
enum {COPY, BACKPTR} state = COPY; int state= 0;
int x; int x;
LZOContext c; LZOContext c;
c.in = in; c.in = in;
...@@ -205,9 +205,7 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) { ...@@ -205,9 +205,7 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
break; break;
} }
} }
} else } else if(!state){
switch (state) {
case COPY:
cnt = get_len(&c, x, 15); cnt = get_len(&c, x, 15);
copy(&c, cnt + 3); copy(&c, cnt + 3);
x = GETB(c); x = GETB(c);
...@@ -219,15 +217,13 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) { ...@@ -219,15 +217,13 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
continue; continue;
cnt = 1; cnt = 1;
back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
break; } else {
case BACKPTR:
cnt = 0; cnt = 0;
back = (GETB(c) << 2) + (x >> 2) + 1; back = (GETB(c) << 2) + (x >> 2) + 1;
break;
} }
copy_backptr(&c, back, cnt + 2); copy_backptr(&c, back, cnt + 2);
state=
cnt = x & 3; cnt = x & 3;
state = cnt ? BACKPTR : COPY;
if (cnt) if (cnt)
copy(&c, cnt); copy(&c, cnt);
x = GETB(c); x = GETB(c);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment