X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqpeg.c;h=2e66d3bf8ade7e25dac3319985f4bb6784b5eeb2;hb=e83717e63eab1f1b78dc0990e5b8e927097fca29;hp=40931e3bdc6ac46950398468b1e79c8851cf4966;hpb=ef46de695f1f54ec1025ec20c07b25685787d956;p=ffmpeg diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 40931e3bdc6..2e66d3bf8ad 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "decode.h" #include "internal.h" typedef struct QpegContext{ @@ -101,8 +102,11 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst, } 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); + while (copy > 0) { + int step = FFMIN(copy, width - filled); + bytestream2_get_bufferu(&qctx->buffer, dst + filled, step); + filled += step; + copy -= step; if (filled >= width) { filled = 0; dst -= stride; @@ -271,8 +275,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame * const ref = a->ref; uint8_t* outdata; int delta, intra, ret; - int pal_size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); if (avpkt->size < 0x86) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); @@ -297,12 +299,7 @@ static int decode_frame(AVCodecContext *avctx, } /* make the palette available on the way out */ - if (pal && pal_size == AVPALETTE_SIZE) { - p->palette_has_changed = 1; - memcpy(a->pal, pal, AVPALETTE_SIZE); - } else if (pal) { - av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); - } + p->palette_has_changed = ff_copy_palette(a->pal, avpkt, avctx); memcpy(p->data[1], a->pal, AVPALETTE_SIZE); av_frame_unref(ref);