Mercurial > libavcodec.hg
comparison lcldec.c @ 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 |
comparison
equal
deleted
inserted
replaced
9769:6efef56e20b3 | 9770:e883c3dab3ec |
---|---|
42 #include <stdlib.h> | 42 #include <stdlib.h> |
43 | 43 |
44 #include "avcodec.h" | 44 #include "avcodec.h" |
45 #include "bytestream.h" | 45 #include "bytestream.h" |
46 #include "lcl.h" | 46 #include "lcl.h" |
47 #include "libavutil/lzo.h" | |
47 | 48 |
48 #if CONFIG_ZLIB_DECODER | 49 #if CONFIG_ZLIB_DECODER |
49 #include <zlib.h> | 50 #include <zlib.h> |
50 #endif | 51 #endif |
51 | 52 |
71 } LclDecContext; | 72 } LclDecContext; |
72 | 73 |
73 | 74 |
74 /** | 75 /** |
75 * \param srcptr compressed source buffer, must be padded with at least 4 extra bytes | 76 * \param srcptr compressed source buffer, must be padded with at least 4 extra bytes |
77 * \param destptr must be padded sufficiently for av_memcpy_backptr | |
76 */ | 78 */ |
77 static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) | 79 static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) |
78 { | 80 { |
79 unsigned char *destptr_bak = destptr; | 81 unsigned char *destptr_bak = destptr; |
80 unsigned char *destptr_end = destptr + destsize; | 82 unsigned char *destptr_end = destptr + destsize; |
101 ofs &= 0x7ff; | 103 ofs &= 0x7ff; |
102 cnt *= 4; | 104 cnt *= 4; |
103 if (destptr_end - destptr < cnt) { | 105 if (destptr_end - destptr < cnt) { |
104 cnt = destptr_end - destptr; | 106 cnt = destptr_end - destptr; |
105 } | 107 } |
106 for (; cnt > 0; cnt--) { | 108 av_memcpy_backptr(destptr, ofs, cnt); |
107 *destptr = *(destptr - ofs); | 109 destptr += cnt; |
108 destptr++; | |
109 } | |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 return destptr - destptr_bak; | 113 return destptr - destptr_bak; |
114 } | 114 } |
443 */ | 443 */ |
444 static av_cold int decode_init(AVCodecContext *avctx) | 444 static av_cold int decode_init(AVCodecContext *avctx) |
445 { | 445 { |
446 LclDecContext * const c = avctx->priv_data; | 446 LclDecContext * const c = avctx->priv_data; |
447 unsigned int basesize = avctx->width * avctx->height; | 447 unsigned int basesize = avctx->width * avctx->height; |
448 unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4); | 448 unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING; |
449 unsigned int max_decomp_size; | 449 unsigned int max_decomp_size; |
450 | 450 |
451 c->pic.data[0] = NULL; | 451 c->pic.data[0] = NULL; |
452 | 452 |
453 #if CONFIG_ZLIB_DECODER | 453 #if CONFIG_ZLIB_DECODER |