diff options
author | Peter Ross <pross@xvid.org> | 2008-08-06 08:17:03 +0000 |
---|---|---|
committer | Peter Ross <pross@xvid.org> | 2008-08-06 08:17:03 +0000 |
commit | 6ba10f338ae8fe06faa1ed830ce07ce036cc2fdc (patch) | |
tree | dd250ac1c3e5c2c7c25acafbc217186346694790 | |
parent | c0f0b34bba397e6413e746514054f6fa2439adba (diff) | |
download | ffmpeg-6ba10f338ae8fe06faa1ed830ce07ce036cc2fdc.tar.gz |
Add av_memcpy_backptr(): deliberately overlapping memcpy variant.
Originally committed as revision 14641 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavutil/lzo.c | 24 | ||||
-rw-r--r-- | libavutil/lzo.h | 2 |
2 files changed, 23 insertions, 3 deletions
diff --git a/libavutil/lzo.c b/libavutil/lzo.c index d5d11867f8..12d3b894b5 100644 --- a/libavutil/lzo.c +++ b/libavutil/lzo.c @@ -106,6 +106,8 @@ static inline void copy(LZOContext *c, int cnt) { c->out = dst + cnt; } +static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); + /** * \brief copy previously decoded bytes to current position * \param back how many bytes back we start @@ -125,9 +127,14 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) { cnt = FFMAX(c->out_end - dst, 0); c->error |= LZO_OUTPUT_FULL; } + memcpy_backptr(dst, back, cnt); + c->out = dst + cnt; +} + +static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { + const uint8_t *src = &dst[-back]; if (back == 1) { memset(dst, *src, cnt); - dst += cnt; } else { #ifdef OUTBUF_PADDED COPY2(dst, src); @@ -155,9 +162,20 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) { } memcpy(dst, src, cnt); } - dst += cnt; } - c->out = dst; +} + +/** + * \brief deliberately overlapping memcpy implementation + * \param dst destination buffer; must be padded with 12 additional bytes + * \param back how many bytes back we start (the initial size of the overlapping window) + * \param cnt number of bytes to copy, must be >= 0 + * + * cnt > back is valid, this will copy the bytes we just copied, + * thus creating a repeating pattern with a period length of back. + */ +void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { + memcpy_backptr(dst, back, cnt); } /** diff --git a/libavutil/lzo.h b/libavutil/lzo.h index e7795f7718..6c5e5a31bc 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -32,4 +32,6 @@ int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); +void av_memcpy_backptr(uint8_t *dst, int back, int cnt); + #endif /* FFMPEG_LZO_H */ |