changeset 9770:e883c3dab3ec libavcodec

Pad the decompression buffer and use av_memcpy_backptr for the mszh decompression.
author reimar
date Sun, 31 May 2009 10:42:26 +0000
parents 6efef56e20b3
children 85c99c1335bc
files lcldec.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lcldec.c	Sun May 31 10:38:17 2009 +0000
+++ b/lcldec.c	Sun May 31 10:42:26 2009 +0000
@@ -44,6 +44,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "lcl.h"
+#include "libavutil/lzo.h"
 
 #if CONFIG_ZLIB_DECODER
 #include <zlib.h>
@@ -73,6 +74,7 @@
 
 /**
  * \param srcptr compressed source buffer, must be padded with at least 4 extra bytes
+ * \param destptr must be padded sufficiently for av_memcpy_backptr
  */
 static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
 {
@@ -103,10 +105,8 @@
             if (destptr_end - destptr < cnt) {
                 cnt =  destptr_end - destptr;
             }
-            for (; cnt > 0; cnt--) {
-                *destptr = *(destptr - ofs);
-                destptr++;
-            }
+            av_memcpy_backptr(destptr, ofs, cnt);
+            destptr += cnt;
         }
     }
 
@@ -445,7 +445,7 @@
 {
     LclDecContext * const c = avctx->priv_data;
     unsigned int basesize = avctx->width * avctx->height;
-    unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4);
+    unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING;
     unsigned int max_decomp_size;
 
     c->pic.data[0] = NULL;