[Ffmpeg-devel] [PATCH] simple internal lzo decoder
Michael Niedermayer
michaelni
Sat Jan 14 16:03:18 CET 2006
Hi
On Sat, Jan 14, 2006 at 02:07:30PM +0100, Reimar D?ffinger wrote:
[...]
> static inline void copy(LZOContext *c, int cnt) {
> - if (c->in + cnt > c->in_end) {
> - cnt = c->in_end - c->in;
> + register uint8_t *in_ptr = c->in;
> + register uint8_t *out_ptr = c->out;
> + if (in_ptr + cnt > c->in_end) {
> + cnt = c->in_end - in_ptr;
> c->error |= LZO_INPUT_DEPLETED;
> }
> - if (c->out + cnt > c->out_end) {
> - cnt = c->out_end - c->out;
> + if (out_ptr + cnt > c->out_end) {
> + cnt = c->out_end - out_ptr;
> c->error |= LZO_OUTPUT_FULL;
> }
> do {
> - *c->out++ = *c->in++;
> + *out_ptr++ = *in_ptr++;
> } while (--cnt);
> + c->in = in_ptr;
> + c->out = out_ptr;
what about:
static inline void copy(LZOContext *c, int cnt) {
register uint8_t *in_ptr = c->in;
register uint8_t *out_ptr = c->out;
out_ptr += cnt;
in_ptr += cnt;
if (in_ptr > c->in_end) {
cnt -= in_ptr - c->in_end;
out_ptr -= in_ptr - c->in_end;
in_ptr= c->in_end;
c->error |= LZO_INPUT_DEPLETED;
}
if (out_ptr > c->out_end) {
cnt -= out_ptr - c->out_end;
in_ptr -= out_ptr - c->out_end;
out_ptr= c->out_end;
c->error |= LZO_OUTPUT_FULL;
}
c->in = in_ptr;
c->out = out_ptr;
cnt= -cnt;
do {
out_ptr[cnt] = in_ptr[cnt];
} while (++cnt);
}
or something like
c->in = in_ptr + cnt;
c->out = out_ptr + cnt;
cnt= (cnt+3)>>2;
do {
out_ptr[0] = in_ptr[0];
out_ptr[1] = in_ptr[1];
out_ptr[2] = in_ptr[2];
out_ptr[3] = in_ptr[3];
out_ptr += 4;
in_ptr += 4;
} while(cnt --)
note, the idea here is that a few more bytes wont matter as long as they dont
go over the end of th buffer
[...]
--
Michael
More information about the ffmpeg-devel
mailing list