summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-25 13:15:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-25 13:15:58 +0200
commitaa604e8e33ae06f3a106e44fff798fdd70d77230 (patch)
treede1f5670244e74d90e97b8dc69f054768c363959 /libavutil
parentd312ffdd79bd22b5a051790c993eda6b1366cdfc (diff)
parent2a91ada8282f18d2807abee5188225bba1b19bda (diff)
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')
-rw-r--r--libavutil/Makefile5
-rw-r--r--libavutil/lzo.c44
-rw-r--r--libavutil/lzo.h11
-rw-r--r--libavutil/mem.c37
-rw-r--r--libavutil/mem.h12
5 files changed, 53 insertions, 56 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 3a6f7313ed..88a978f96f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -27,7 +27,6 @@ HEADERS = adler32.h \
intreadwrite.h \
lfg.h \
log.h \
- lzo.h \
mathematics.h \
md5.h \
mem.h \
@@ -47,6 +46,8 @@ HEADERS = adler32.h \
version.h \
xtea.h \
+HEADERS-$(CONFIG_LZO) += lzo.h
+
ARCH_HEADERS = bswap.h \
intmath.h \
intreadwrite.h \
@@ -77,7 +78,6 @@ OBJS = adler32.o \
log.o \
log2.o \
log2_tab.o \
- lzo.o \
mathematics.o \
md5.o \
mem.o \
@@ -97,6 +97,7 @@ OBJS = adler32.o \
xga_font_data.o \
xtea.o \
+OBJS-$(CONFIG_LZO) += lzo.o
OBJS += $(COMPAT_OBJS:%=../compat/%)
diff --git a/libavutil/lzo.c b/libavutil/lzo.c
index 47fc767a06..c723257212 100644
--- a/libavutil/lzo.c
+++ b/libavutil/lzo.c
@@ -100,8 +100,6 @@ 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 Copies previously decoded bytes to current position.
* @param back how many bytes back we start, must be > 0
@@ -122,50 +120,10 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt)
cnt = FFMAX(c->out_end - dst, 0);
c->error |= AV_LZO_OUTPUT_FULL;
}
- memcpy_backptr(dst, back, cnt);
+ av_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);
- } 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);
- }
- }
-}
-
-void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
-{
- memcpy_backptr(dst, back, cnt);
-}
-
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
{
int state = 0;
diff --git a/libavutil/lzo.h b/libavutil/lzo.h
index 60b7065b15..c03403992d 100644
--- a/libavutil/lzo.h
+++ b/libavutil/lzo.h
@@ -60,17 +60,6 @@
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
/**
- * @brief deliberately overlapping memcpy implementation
- * @param dst destination buffer
- * @param back how many bytes back we start (the initial size of the overlapping window), must be > 0
- * @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);
-
-/**
* @}
*/
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);
+ }
+ }
+}
+
diff --git a/libavutil/mem.h b/libavutil/mem.h
index c2f011552d..ced9453869 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -27,6 +27,7 @@
#define AVUTIL_MEM_H
#include <limits.h>
+#include <stdint.h>
#include "attributes.h"
#include "error.h"
@@ -217,6 +218,17 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
void av_max_alloc(size_t max);
/**
+ * @brief deliberately overlapping memcpy implementation
+ * @param dst destination buffer
+ * @param back how many bytes back we start (the initial size of the overlapping window), must be > 0
+ * @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);
+
+/**
* @}
*/