aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-12 21:36:22 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-12 22:25:25 +0200
commit375c0f74d190083ca1d0bf8f452afd9cd4502c37 (patch)
tree250e302c0ece51cd2474f5b48ed95eaeab8779d4 /libavutil
parent19ff479f694ddccc1fd1fa00eff94f96ca82671b (diff)
downloadffmpeg-375c0f74d190083ca1d0bf8f452afd9cd4502c37.tar.gz
av_samples_copy: support overlapping copies
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/samplefmt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index ae192ff3d4..a9c12ed6fd 100644
--- a/libavutil/samplefmt.c
+++ b/libavutil/samplefmt.c
@@ -208,8 +208,13 @@ int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
dst_offset *= block_align;
src_offset *= block_align;
- for (i = 0; i < planes; i++)
- memcpy(dst[i] + dst_offset, src[i] + src_offset, data_size);
+ if((dst[0] < src[0] ? src[0] - dst[0] : dst[0] - src[0]) >= data_size) {
+ for (i = 0; i < planes; i++)
+ memcpy(dst[i] + dst_offset, src[i] + src_offset, data_size);
+ } else {
+ for (i = 0; i < planes; i++)
+ memmove(dst[i] + dst_offset, src[i] + src_offset, data_size);
+ }
return 0;
}