[FFmpeg-cvslog] av_samples_copy: support overlapping copies

Michael Niedermayer git at videolan.org
Thu Jul 12 22:31:06 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Jul 12 21:36:22 2012 +0200| [375c0f74d190083ca1d0bf8f452afd9cd4502c37] | committer: Michael Niedermayer

av_samples_copy: support overlapping copies

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=375c0f74d190083ca1d0bf8f452afd9cd4502c37
---

 libavutil/samplefmt.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index ae192ff..a9c12ed 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;
 }



More information about the ffmpeg-cvslog mailing list