comparison pnm.c @ 10612:d6860312274c libavcodec

Support ASCII pnms. Implements issue1452.
author michael
date Tue, 01 Dec 2009 16:56:13 +0000
parents 059265d3cc65
children 914f484bb476
comparison
equal deleted inserted replaced
10611:eb37707704e4 10612:d6860312274c
57 { 57 {
58 char buf1[32], tuple_type[32]; 58 char buf1[32], tuple_type[32];
59 int h, w, depth, maxval; 59 int h, w, depth, maxval;
60 60
61 pnm_get(s, buf1, sizeof(buf1)); 61 pnm_get(s, buf1, sizeof(buf1));
62 if (!strcmp(buf1, "P4")) { 62 s->type= buf1[1]-'0';
63 if(buf1[0] != 'P')
64 return -1;
65
66 if (s->type==1 || s->type==4) {
63 avctx->pix_fmt = PIX_FMT_MONOWHITE; 67 avctx->pix_fmt = PIX_FMT_MONOWHITE;
64 } else if (!strcmp(buf1, "P5")) { 68 } else if (s->type==2 || s->type==5) {
65 if (avctx->codec_id == CODEC_ID_PGMYUV) 69 if (avctx->codec_id == CODEC_ID_PGMYUV)
66 avctx->pix_fmt = PIX_FMT_YUV420P; 70 avctx->pix_fmt = PIX_FMT_YUV420P;
67 else 71 else
68 avctx->pix_fmt = PIX_FMT_GRAY8; 72 avctx->pix_fmt = PIX_FMT_GRAY8;
69 } else if (!strcmp(buf1, "P6")) { 73 } else if (s->type==3 || s->type==6) {
70 avctx->pix_fmt = PIX_FMT_RGB24; 74 avctx->pix_fmt = PIX_FMT_RGB24;
71 } else if (!strcmp(buf1, "P7")) { 75 } else if (s->type==7) {
72 w = -1; 76 w = -1;
73 h = -1; 77 h = -1;
74 maxval = -1; 78 maxval = -1;
75 depth = -1; 79 depth = -1;
76 tuple_type[0] = '\0'; 80 tuple_type[0] = '\0';
147 av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n"); 151 av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
148 avctx->pix_fmt = PIX_FMT_NONE; 152 avctx->pix_fmt = PIX_FMT_NONE;
149 return -1; 153 return -1;
150 } 154 }
151 } 155 }
152 } 156 }else
157 s->maxval=1;
153 /* more check if YUV420 */ 158 /* more check if YUV420 */
154 if (avctx->pix_fmt == PIX_FMT_YUV420P) { 159 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
155 if ((avctx->width & 1) != 0) 160 if ((avctx->width & 1) != 0)
156 return -1; 161 return -1;
157 h = (avctx->height * 2); 162 h = (avctx->height * 2);