From 63538a960e762e68ec23290ab198a0158339e109 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 1 Dec 2009 16:56:13 +0000 Subject: Support ASCII pnms. Implements issue1452. Originally committed as revision 20687 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/pnm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libavcodec/pnm.c') diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 4fd9c61a24..cb6a7139f2 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -59,16 +59,20 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) int h, w, depth, maxval; pnm_get(s, buf1, sizeof(buf1)); - if (!strcmp(buf1, "P4")) { + s->type= buf1[1]-'0'; + if(buf1[0] != 'P') + return -1; + + if (s->type==1 || s->type==4) { avctx->pix_fmt = PIX_FMT_MONOWHITE; - } else if (!strcmp(buf1, "P5")) { + } else if (s->type==2 || s->type==5) { if (avctx->codec_id == CODEC_ID_PGMYUV) avctx->pix_fmt = PIX_FMT_YUV420P; else avctx->pix_fmt = PIX_FMT_GRAY8; - } else if (!strcmp(buf1, "P6")) { + } else if (s->type==3 || s->type==6) { avctx->pix_fmt = PIX_FMT_RGB24; - } else if (!strcmp(buf1, "P7")) { + } else if (s->type==7) { w = -1; h = -1; maxval = -1; @@ -149,7 +153,8 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) return -1; } } - } + }else + s->maxval=1; /* more check if YUV420 */ if (avctx->pix_fmt == PIX_FMT_YUV420P) { if ((avctx->width & 1) != 0) -- cgit v1.2.3