X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flcldec.c;h=d281733fdd2dbd110ab4ef242bbcc70f6276553d;hb=6e30b35b85b81c802e52a1078ec7a3097e353c6d;hp=104defa5f57f648beef789b17a7ef5ebe669b770;hpb=3e076faf3b86bb16f746e7c9b0cf3dac5f9a851a;p=ffmpeg diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 104defa5f57..d281733fdd2 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -136,7 +136,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); return AVERROR_UNKNOWN; } - c->zstream.next_in = (uint8_t *)src; + c->zstream.next_in = src; c->zstream.avail_in = src_len; c->zstream.next_out = c->decomp_buf + offset; c->zstream.avail_out = c->decomp_size - offset; @@ -173,7 +173,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac int uqvq, ret; unsigned int mthread_inlen, mthread_outlen; unsigned int len = buf_size; - int linesize; + int linesize, offset; if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) return ret; @@ -190,11 +190,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ; } else if (c->flags & FLAG_MULTITHREAD) { mthread_inlen = AV_RL32(buf); - if (len < 8) { + if (len < 8 || len - 8 < mthread_inlen) { av_log(avctx, AV_LOG_ERROR, "len %d is too small\n", len); return AVERROR_INVALIDDATA; } - mthread_inlen = FFMIN(mthread_inlen, len - 8); mthread_outlen = AV_RL32(buf + 4); mthread_outlen = FFMIN(mthread_outlen, c->decomp_size); mszh_dlen = mszh_decomp(buf + 8, mthread_inlen, c->decomp_buf, c->decomp_size); @@ -374,8 +373,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac /* Convert colorspace */ y_out = frame->data[0] + (height - 1) * frame->linesize[0]; - u_out = frame->data[1] + (height - 1) * frame->linesize[1]; - v_out = frame->data[2] + (height - 1) * frame->linesize[2]; + offset = (height - 1) * frame->linesize[1]; + u_out = FF_PTR_ADD(frame->data[1], offset); + offset = (height - 1) * frame->linesize[2]; + v_out = FF_PTR_ADD(frame->data[2], offset); switch (c->imgtype) { case IMGTYPE_YUV111: for (row = 0; row < height; row++) { @@ -623,13 +624,6 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -#if HAVE_THREADS -static int init_thread_copy(AVCodecContext *avctx) -{ - return decode_init(avctx); -} -#endif - static av_cold int decode_end(AVCodecContext *avctx) { LclDecContext * const c = avctx->priv_data; @@ -651,7 +645,6 @@ AVCodec ff_mszh_decoder = { .id = AV_CODEC_ID_MSZH, .priv_data_size = sizeof(LclDecContext), .init = decode_init, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, @@ -667,7 +660,6 @@ AVCodec ff_zlib_decoder = { .id = AV_CODEC_ID_ZLIB, .priv_data_size = sizeof(LclDecContext), .init = decode_init, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,