summaryrefslogtreecommitdiffstats
path: root/libavcodec/pnm_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/pnm_parser.c')
-rw-r--r--libavcodec/pnm_parser.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 03d2da9..9bf1fdc 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -2,20 +2,20 @@
* PNM image parser
* Copyright (c) 2002, 2003 Fabrice Bellard
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -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,24 +44,27 @@ 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) {
if (pc->index) {
pc->index = 0;
} else {
- buf++;
- buf_size--;
+ unsigned step = FFMAX(1, pnmctx.bytestream - pnmctx.bytestream_start);
+
+ skip += step;
}
goto retry;
}
next = END_NOT_FOUND;
+ } 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;
OpenPOWER on IntegriCloud