X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fpnm_parser.c;h=9bf1fdcece4873a23d48fa0fc6ce0c998b06f560;hb=1046e880884bb5f0da4fb7d50028ff599550245c;hp=4bcd0ddd5d04c7292448db2a22e2d91e4e074248;hpb=0ff76ca86e0ea4dcf2b392c45f5fac8e5576bb0d;p=ffmpeg diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c index 4bcd0ddd5d0..9bf1fdcece4 100644 --- a/libavcodec/pnm_parser.c +++ b/libavcodec/pnm_parser.c @@ -32,6 +32,7 @@ static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx, ParseContext *pc = s->priv_data; PNMContext pnmctx; int next; + int skip = 0; for (; pc->overread > 0; pc->overread--) { pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; @@ -43,8 +44,8 @@ retry: pnmctx.bytestream_end = pc->buffer + pc->index; } else { pnmctx.bytestream_start = - pnmctx.bytestream = (uint8_t *) buf; /* casts avoid warnings */ - pnmctx.bytestream_end = (uint8_t *) buf + buf_size; + pnmctx.bytestream = (uint8_t *) buf + skip; /* casts avoid warnings */ + pnmctx.bytestream_end = (uint8_t *) buf + buf_size - skip; } if (ff_pnm_decode_header(avctx, &pnmctx) < 0) { if (pnmctx.bytestream < pnmctx.bytestream_end) { @@ -52,8 +53,8 @@ retry: pc->index = 0; } else { unsigned step = FFMAX(1, pnmctx.bytestream - pnmctx.bytestream_start); - buf += step; - buf_size -= step; + + skip += step; } goto retry; } @@ -61,9 +62,9 @@ retry: } else if (pnmctx.type < 4) { next = END_NOT_FOUND; } else { - next = pnmctx.bytestream - pnmctx.bytestream_start + next = pnmctx.bytestream - pnmctx.bytestream_start + skip + av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); - if (pnmctx.bytestream_start != buf) + if (pnmctx.bytestream_start != buf + skip) next -= pc->index; if (next > buf_size) next = END_NOT_FOUND;