X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqpeg.c;h=d4195c5f0b7f145e7bbbf28dc894c8e0bed4b9ab;hb=c371463915aef11fb8d052fd25313d0444a42cfd;hp=e1210c197206024e95915f38688c87b08694eca4;hpb=7a10541109cc04ffddc15f0749139aab80f56ebf;p=ffmpeg diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index e1210c19720..d4195c5f0b7 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -80,16 +80,27 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst, p = bytestream2_get_byte(&qctx->buffer); for(i = 0; i < run; i++) { - dst[filled++] = p; + int step = FFMIN(run - i, width - filled); + memset(dst+filled, p, step); + filled += step; + i += step - 1; if (filled >= width) { filled = 0; dst -= stride; rows_to_go--; + while (run - i > width && rows_to_go > 0) { + memset(dst, p, width); + dst -= stride; + rows_to_go--; + i += width; + } if(rows_to_go <= 0) break; } } } else { + if (bytestream2_get_bytes_left(&qctx->buffer) < copy) + copy = bytestream2_get_bytes_left(&qctx->buffer); for(i = 0; i < copy; i++) { dst[filled++] = bytestream2_get_byte(&qctx->buffer); if (filled >= width) {