static inline void memcpy_backptr(uint8_t *dst, int back, int cnt)
{
const uint8_t *src = &dst[-back];
- if (back == 1) {
+ if (back <= 1) {
memset(dst, *src, cnt);
} else {
- #ifdef OUTBUF_PADDED
- AV_COPY16U(dst, src);
- AV_COPY16U(dst + 2, src + 2);
- src += 4;
- dst += 4;
- cnt -= 4;
- if (cnt > 0) {
+ 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);
/**
* @brief deliberately overlapping memcpy implementation
- * @param dst destination buffer; must be padded with 12 additional bytes
+ * @param dst destination buffer
- * @param back how many bytes back we start (the initial size of the overlapping window)
+ * @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,