[FFmpeg-cvslog] swr: fix cpy() after the len was changed to be in samples.

Michael Niedermayer git at videolan.org
Mon May 7 00:10:45 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon May  7 00:04:44 2012 +0200| [fecdc76a9ff685eec8807fc6cafadf8efdb3370c] | committer: Michael Niedermayer

swr: fix cpy() after the len was changed to be in samples.

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

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

 libswresample/audioconvert.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c
index 986c45d..3143d69 100644
--- a/libswresample/audioconvert.c
+++ b/libswresample/audioconvert.c
@@ -107,9 +107,18 @@ static conv_func_type * const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAM
     FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL),
 };
 
-static void cpy(uint8_t **dst, const uint8_t **src, int len){
+static void cpy1(uint8_t **dst, const uint8_t **src, int len){
     memcpy(*dst, *src, len);
 }
+static void cpy2(uint8_t **dst, const uint8_t **src, int len){
+    memcpy(*dst, *src, 2*len);
+}
+static void cpy4(uint8_t **dst, const uint8_t **src, int len){
+    memcpy(*dst, *src, 4*len);
+}
+static void cpy8(uint8_t **dst, const uint8_t **src, int len){
+    memcpy(*dst, *src, 8*len);
+}
 
 AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
                                        enum AVSampleFormat in_fmt,
@@ -136,8 +145,14 @@ AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
     if (in_fmt == AV_SAMPLE_FMT_U8)
         memset(ctx->silence, 0x80, sizeof(ctx->silence));
 
-    if(out_fmt == in_fmt && !ch_map)
-        ctx->simd_f = cpy;
+    if(out_fmt == in_fmt && !ch_map) {
+        switch(av_get_bytes_per_sample(in_fmt)){
+            case 1:ctx->simd_f = cpy1; break;
+            case 2:ctx->simd_f = cpy2; break;
+            case 4:ctx->simd_f = cpy4; break;
+            case 8:ctx->simd_f = cpy8; break;
+        }
+    }
 
     if(HAVE_YASM && HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);
 



More information about the ffmpeg-cvslog mailing list