[FFmpeg-devel] [PATCH] av_samples_copy: always use memmove.

Nicolas George nicolas.george at normalesup.org
Fri Jul 13 20:00:37 CEST 2012


On any reasonable implementation, the cost of memmove over memcpy
is a test to decide the direction. Doing the test and calling memcpy
is just as expensive.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavutil/samplefmt.c |    5 -----
 1 file changed, 5 deletions(-)


Of course, I'll reindent the two remaining lines afterwards.


diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
index a9c12ed..3944f83 100644
--- a/libavutil/samplefmt.c
+++ b/libavutil/samplefmt.c
@@ -208,13 +208,8 @@ int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
     dst_offset *= block_align;
     src_offset *= block_align;
 
-    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;
 }
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list