X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flcldec.c;h=23af5114554e20b68e86c9fc0e6d3f86f9861503;hb=deca86eab1623b3391b7113b4ac6e74b8408639d;hp=53637f25076a22dff0692ed76ce17fa3524bfb5a;hpb=bbf306742cd289929a423d5de847e6053aeaefa2;p=ffmpeg diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 53637f25076..23af5114554 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -20,7 +20,7 @@ */ /** - * @file libavcodec/lcldec.c + * @file * LCL (LossLess Codec Library) Video Codec * Decoder for MSZH and ZLIB codecs * Experimental encoder for ZLIB RGB24 @@ -93,6 +93,7 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign unsigned ofs = bytestream_get_le16(&srcptr); unsigned cnt = (ofs >> 11) + 1; ofs &= 0x7ff; + ofs = FFMIN(ofs, destptr - destptr_bak); cnt *= 4; cnt = FFMIN(cnt, destptr_end - destptr); av_memcpy_backptr(destptr, ofs, cnt); @@ -101,6 +102,13 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign maskbit >>= 1; if (!maskbit) { mask = *srcptr++; + while (!mask) { + if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break; + memcpy(destptr, srcptr, 32); + destptr += 32; + srcptr += 32; + mask = *srcptr++; + } maskbit = 0x80; } } @@ -109,6 +117,7 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign } +#if CONFIG_ZLIB_DECODER /** * \brief decompress a zlib-compressed data block into decomp_buf * \param src compressed input buffer @@ -140,6 +149,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i } return c->zstream.total_out; } +#endif /* @@ -448,10 +458,6 @@ static av_cold int decode_init(AVCodecContext *avctx) return 1; } - if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { - return 1; - } - /* Check codec type */ if ((avctx->codec_id == CODEC_ID_MSZH && avctx->extradata[7] != CODEC_MSZH) || (avctx->codec_id == CODEC_ID_ZLIB && avctx->extradata[7] != CODEC_ZLIB)) { @@ -605,7 +611,7 @@ static av_cold int decode_end(AVCodecContext *avctx) #if CONFIG_MSZH_DECODER AVCodec mszh_decoder = { "mszh", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_MSZH, sizeof(LclDecContext), decode_init, @@ -620,7 +626,7 @@ AVCodec mszh_decoder = { #if CONFIG_ZLIB_DECODER AVCodec zlib_decoder = { "zlib", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_ZLIB, sizeof(LclDecContext), decode_init,