From c0d6fc1f739135fe72059a0d5ea9b33e8840fe7e Mon Sep 17 00:00:00 2001
From: Kostya Shishkov <kostya.shishkov@gmail.com>
Date: Tue, 5 Sep 2006 07:29:26 +0000
Subject: [PATCH] Handle raw blocks correctly (both updating pointer and
 storing to memory)

Originally committed as revision 6172 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/vmnc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index 87718917065..927cdcaf879 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -105,7 +105,17 @@ static always_inline void paint_raw(uint8_t *dst, int w, int h, uint8_t* src, in
         for(i = 0; i < w; i++) {
             p = vmnc_get_pixel(src, bpp, be);
             src += bpp;
-            memcpy(dst + i*bpp, &p, bpp);
+            switch(bpp){
+            case 1:
+                dst[i] = p;
+                break;
+            case 2:
+                ((uint16_t*)dst)[i] = p;
+                break;
+            case 4:
+                ((uint32_t*)dst)[i] = p;
+                break;
+            }
         }
         dst += stride;
     }
@@ -129,6 +139,7 @@ static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int w, int
             flags = *src++;
             if(flags & HT_RAW) {
                 paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
+                src += bw * bh * bpp;
             } else {
                 if(flags & HT_BKG) {
                     bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
-- 
GitLab