summaryrefslogtreecommitdiff
path: root/libavcodec/pnm.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/pnm.c')
-rw-r--r--libavcodec/pnm.c15
1 files changed, 10 insertions, 5 deletions
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)