| OLD | NEW |
| 1 /* | 1 /* |
| 2 * PNM image format | 2 * PNM image format |
| 3 * Copyright (c) 2002, 2003 Fabrice Bellard | 3 * Copyright (c) 2002, 2003 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 maxval = strtol(buf1, NULL, 10); | 95 maxval = strtol(buf1, NULL, 10); |
| 96 } else if (!strcmp(buf1, "TUPLETYPE")) { | 96 } else if (!strcmp(buf1, "TUPLETYPE")) { |
| 97 pnm_get(s, tuple_type, sizeof(tuple_type)); | 97 pnm_get(s, tuple_type, sizeof(tuple_type)); |
| 98 } else if (!strcmp(buf1, "ENDHDR")) { | 98 } else if (!strcmp(buf1, "ENDHDR")) { |
| 99 break; | 99 break; |
| 100 } else { | 100 } else { |
| 101 return -1; | 101 return -1; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 /* check that all tags are present */ | 104 /* check that all tags are present */ |
| 105 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\
0' || av_check_image_size(w, h, 0, avctx)) | 105 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\
0' || av_image_check_size(w, h, 0, avctx)) |
| 106 return -1; | 106 return -1; |
| 107 | 107 |
| 108 avctx->width = w; | 108 avctx->width = w; |
| 109 avctx->height = h; | 109 avctx->height = h; |
| 110 if (depth == 1) { | 110 if (depth == 1) { |
| 111 if (maxval == 1) | 111 if (maxval == 1) |
| 112 avctx->pix_fmt = PIX_FMT_MONOWHITE; | 112 avctx->pix_fmt = PIX_FMT_MONOWHITE; |
| 113 else | 113 else |
| 114 avctx->pix_fmt = PIX_FMT_GRAY8; | 114 avctx->pix_fmt = PIX_FMT_GRAY8; |
| 115 } else if (depth == 3) { | 115 } else if (depth == 3) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 return 0; | 128 return 0; |
| 129 } else { | 129 } else { |
| 130 return -1; | 130 return -1; |
| 131 } | 131 } |
| 132 pnm_get(s, buf1, sizeof(buf1)); | 132 pnm_get(s, buf1, sizeof(buf1)); |
| 133 avctx->width = atoi(buf1); | 133 avctx->width = atoi(buf1); |
| 134 if (avctx->width <= 0) | 134 if (avctx->width <= 0) |
| 135 return -1; | 135 return -1; |
| 136 pnm_get(s, buf1, sizeof(buf1)); | 136 pnm_get(s, buf1, sizeof(buf1)); |
| 137 avctx->height = atoi(buf1); | 137 avctx->height = atoi(buf1); |
| 138 if(av_check_image_size(avctx->width, avctx->height, 0, avctx)) | 138 if(av_image_check_size(avctx->width, avctx->height, 0, avctx)) |
| 139 return -1; | 139 return -1; |
| 140 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) { | 140 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) { |
| 141 pnm_get(s, buf1, sizeof(buf1)); | 141 pnm_get(s, buf1, sizeof(buf1)); |
| 142 s->maxval = atoi(buf1); | 142 s->maxval = atoi(buf1); |
| 143 if (s->maxval >= 256) { | 143 if (s->maxval >= 256) { |
| 144 if (avctx->pix_fmt == PIX_FMT_GRAY8) { | 144 if (avctx->pix_fmt == PIX_FMT_GRAY8) { |
| 145 avctx->pix_fmt = PIX_FMT_GRAY16BE; | 145 avctx->pix_fmt = PIX_FMT_GRAY16BE; |
| 146 if (s->maxval != 65535) | 146 if (s->maxval != 65535) |
| 147 avctx->pix_fmt = PIX_FMT_GRAY16; | 147 avctx->pix_fmt = PIX_FMT_GRAY16; |
| 148 } else if (avctx->pix_fmt == PIX_FMT_RGB24) { | 148 } else if (avctx->pix_fmt == PIX_FMT_RGB24) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 av_cold int ff_pnm_init(AVCodecContext *avctx) | 182 av_cold int ff_pnm_init(AVCodecContext *avctx) |
| 183 { | 183 { |
| 184 PNMContext *s = avctx->priv_data; | 184 PNMContext *s = avctx->priv_data; |
| 185 | 185 |
| 186 avcodec_get_frame_defaults((AVFrame*)&s->picture); | 186 avcodec_get_frame_defaults((AVFrame*)&s->picture); |
| 187 avctx->coded_frame = (AVFrame*)&s->picture; | 187 avctx->coded_frame = (AVFrame*)&s->picture; |
| 188 | 188 |
| 189 return 0; | 189 return 0; |
| 190 } | 190 } |
| OLD | NEW |