diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-25 13:15:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-25 13:15:58 +0200 |
commit | aa604e8e33ae06f3a106e44fff798fdd70d77230 (patch) | |
tree | de1f5670244e74d90e97b8dc69f054768c363959 /libavutil/mem.c | |
parent | d312ffdd79bd22b5a051790c993eda6b1366cdfc (diff) | |
parent | 2a91ada8282f18d2807abee5188225bba1b19bda (diff) | |
download | ffmpeg-aa604e8e33ae06f3a106e44fff798fdd70d77230.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
avutil: Make LZO decoder code configure-time selectable
avutil: Move memcpy_backptr() to mem.c
configure: detect parisc64 automatically
configure: detect ppc64 automatically
configure: detect mips64 automatically
configure: generalise 64-bit test
smoothstreamingenc: Don't assume streams start from timestamp 0
Conflicts:
configure
libavutil/Makefile
libavutil/lzo.c
libavutil/lzo.h
libavutil/mem.c
libavutil/mem.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r-- | libavutil/mem.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c index 0c1c4b25a0..f3853b0827 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -29,6 +29,7 @@ #include "config.h" #include <limits.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #if HAVE_MALLOC_H @@ -36,6 +37,7 @@ #endif #include "avutil.h" +#include "intreadwrite.h" #include "mem.h" /* here we can use OS-dependent allocation functions */ @@ -244,3 +246,38 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem) *nb_ptr = nb; } +void av_memcpy_backptr(uint8_t *dst, int back, int cnt) +{ + const uint8_t *src = &dst[-back]; + if (back <= 1) { + memset(dst, *src, cnt); + } else { + if (cnt >= 4) { + AV_COPY16U(dst, src); + AV_COPY16U(dst + 2, src + 2); + src += 4; + dst += 4; + cnt -= 4; + } + if (cnt >= 8) { + AV_COPY16U(dst, src); + AV_COPY16U(dst + 2, src + 2); + AV_COPY16U(dst + 4, src + 4); + AV_COPY16U(dst + 6, src + 6); + src += 8; + dst += 8; + cnt -= 8; + } + if (cnt > 0) { + int blocklen = back; + while (cnt > blocklen) { + memcpy(dst, src, blocklen); + dst += blocklen; + cnt -= blocklen; + blocklen <<= 1; + } + memcpy(dst, src, cnt); + } + } +} + |