summaryrefslogtreecommitdiff
path: root/libavcodec/pnm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-12-01 16:56:13 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-12-01 16:56:13 +0000
commit63538a960e762e68ec23290ab198a0158339e109 (patch)
treed30ba50d5b453e16d44713443599b2e613040660 /libavcodec/pnm.c
parent817d967d96995ac63b4f74101768b29b6da5aece (diff)
Support ASCII pnms.
Implements issue1452. Originally committed as revision 20687 to svn://svn.ffmpeg.org/ffmpeg/trunk
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)