[FFmpeg-cvslog] ws_snd: use memcpy() and memset() instead of loops

Justin Ruggles git at videolan.org
Tue Sep 27 02:25:31 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Sep 12 10:04:37 2011 -0400| [618b067d2132b0336e609bc311e85c557ffb30ed] | committer: Justin Ruggles

ws_snd: use memcpy() and memset() instead of loops

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

 libavcodec/ws-snd1.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c
index 3842ec9..57902a8 100644
--- a/libavcodec/ws-snd1.c
+++ b/libavcodec/ws-snd1.c
@@ -60,7 +60,6 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
 
     int in_size, out_size;
     int sample = 128;
-    int i;
     uint8_t *samples = data;
     uint8_t *samples_end;
 
@@ -87,8 +86,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
     samples_end = samples + out_size;
 
     if (in_size == out_size) {
-        for (i = 0; i < out_size; i++)
-            *samples++ = *buf++;
+        memcpy(samples, buf, out_size);
         *data_size = out_size;
         return buf_size;
     }
@@ -153,16 +151,15 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
                 sample = av_clip_uint8(sample);
                 *samples++ = sample;
             } else { /* copy */
-                for (count++; count > 0; count--) {
-                    *samples++ = *buf++;
-                }
+                memcpy(samples, buf, smp);
+                samples += smp;
+                buf     += smp;
                 sample = buf[-1];
             }
             break;
         default: /* run */
-            for(count++; count > 0; count--) {
-                *samples++ = sample;
-            }
+            memset(samples, sample, smp);
+            samples += smp;
         }
     }
 



More information about the ffmpeg-cvslog mailing list