[FFmpeg-cvslog] sanm: make use of dsputil

Paul B Mahol git at videolan.org
Sun Jul 8 00:36:43 CEST 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Jul  7 17:01:31 2012 +0000| [2d42008757efb0328308179a2190ff04b38315fd] | committer: Paul B Mahol

sanm: make use of dsputil

About 27% faster decoding.

Signed-off-by: Paul B Mahol <onemda at gmail.com>

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

 libavcodec/sanm.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 2b548f2..2a0fb77 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -25,6 +25,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "libavutil/bswap.h"
+#include "libavcodec/dsputil.h"
 #include "sanm_data.h"
 
 #define NGLYPHS 256
@@ -449,8 +450,7 @@ static int old_codec37(SANMVideoContext *ctx, int top,
                     int code;
                     if (skip_run) {
                         skip_run--;
-                        for (k = 0; k < 4; k++)
-                            memcpy(dst + i + k * stride, prev + i + k * stride, 4);
+                        copy_block4(dst + i, prev + i, stride, stride, 4);
                         continue;
                     }
                     if (bytestream2_get_bytes_left(&ctx->gb) < 1)
@@ -501,8 +501,7 @@ static int old_codec37(SANMVideoContext *ctx, int top,
                     int code;
                     if (skip_run) {
                         skip_run--;
-                        for (k = 0; k < 4; k++)
-                            memcpy(dst + i + k * stride, prev + i + k * stride, 4);
+                        copy_block4(dst + i, prev + i, stride, stride, 4);
                         continue;
                     }
                     code = bytestream2_get_byte(&ctx->gb);
@@ -769,10 +768,21 @@ static int decode_nop(SANMVideoContext *ctx)
 
 static void copy_block(uint16_t *pdest, uint16_t *psrc, int block_size, int pitch)
 {
-    int y;
+    uint8_t *dst = (uint8_t *)pdest;
+    uint8_t *src = (uint8_t *)psrc;
+    int stride = pitch * 2;
 
-    for (y = 0; y < block_size; y++, pdest += pitch, psrc += pitch)
-        memcpy(pdest, psrc, block_size * sizeof(pdest[0]));
+    switch (block_size) {
+    case 2:
+        copy_block4(dst, src, stride, stride, 2);
+        break;
+    case 4:
+        copy_block8(dst, src, stride, stride, 4);
+        break;
+    case 8:
+        copy_block16(dst, src, stride, stride, 8);
+        break;
+    }
 }
 
 static void fill_block(uint16_t *pdest, uint16_t color, int block_size, int pitch)



More information about the ffmpeg-cvslog mailing list