Commit be6f02ca authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns
Browse files

unfilter speedup by Moritz

parent 16cc61df
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
#define FLUSH(KIND) \ #define FLUSH(KIND) \
static void flush_##KIND(struct aec_stream *strm) \ static void flush_##KIND(struct aec_stream *strm) \
{ \ { \
int64_t x, d, th, lower, m; \ uint32_t *bp, *flush_end; \
int64_t data; \ int64_t d, m, th2; \
uint32_t *bp, *bend, *flush_end; \ int64_t data, med; \
struct internal_state *state = strm->state; \ struct internal_state *state = strm->state; \
\ \
flush_end = state->bufp; \ flush_end = state->bufp; \
...@@ -93,26 +93,28 @@ ...@@ -93,26 +93,28 @@
state->flush_start++; \ state->flush_start++; \
} \ } \
\ \
data = state->last_out; \
if (strm->flags & AEC_DATA_SIGNED) \
med = 0; \
else \
med = (state->xmax - state->xmin) / 2 + 1; \
\
for (bp = state->flush_start; bp < flush_end; bp++) { \ for (bp = state->flush_start; bp < flush_end; bp++) { \
d = *bp; \ d = *bp; \
x = state->last_out; \ th2 = (data < med ? \
lower = x - state->xmin; \ data - state->xmin : \
th = MIN(lower, state->xmax - x); \ state->xmax - data) << 1; \
\ if (d <= th2) { \
if (d <= 2 * th) { \ data += ((d + 1) / 2 ^ -(d & 1)) + (d & 1); \
if (d & 1) \
data = x - (d + 1) / 2; \
else \
data = x + d / 2; \
} else { \ } else { \
if (th == lower) \ if (data < med) \
data = x + d - th; \ data = d + state->xmin; \
else \ else \
data = x + th - d; \ data = state->xmax - d; \
} \ } \
put_##KIND(strm, data); \ put_##KIND(strm, data); \
state->last_out = data; \
} \ } \
state->last_out = data; \
} else { \ } else { \
for (bp = state->flush_start; bp < flush_end; bp++) \ for (bp = state->flush_start; bp < flush_end; bp++) \
put_##KIND(strm, *bp); \ put_##KIND(strm, *bp); \
......
Supports Markdown
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