31 return c ==
' ' || c ==
'\n' || c ==
'\r' || c ==
'\t';
53 if ((s - str) < buf_size - 1)
62 char buf1[32], tuple_type[32];
63 int h, w, depth, maxval;
72 }
else if (s->
type==2 || s->
type==5) {
77 }
else if (s->
type==3 || s->
type==6) {
79 }
else if (s->
type==7) {
87 if (!strcmp(buf1,
"WIDTH")) {
89 w = strtol(buf1,
NULL, 10);
90 }
else if (!strcmp(buf1,
"HEIGHT")) {
92 h = strtol(buf1,
NULL, 10);
93 }
else if (!strcmp(buf1,
"DEPTH")) {
95 depth = strtol(buf1,
NULL, 10);
96 }
else if (!strcmp(buf1,
"MAXVAL")) {
98 maxval = strtol(buf1,
NULL, 10);
99 }
else if (!strcmp(buf1,
"TUPLTYPE") ||
101 !strcmp(buf1,
"TUPLETYPE")) {
102 pnm_get(s, tuple_type,
sizeof(tuple_type));
103 }
else if (!strcmp(buf1,
"ENDHDR")) {
110 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] ==
'\0' ||
av_image_check_size(w, h, 0, avctx))
120 }
else if (depth == 3) {
128 }
else if (depth == 4) {
137 pnm_get(s, buf1,
sizeof(buf1));
138 avctx->
width = atoi(buf1);
139 if (avctx->
width <= 0)
141 pnm_get(s, buf1,
sizeof(buf1));
142 avctx->
height = atoi(buf1);
146 pnm_get(s, buf1,
sizeof(buf1));
163 else if (s->
maxval < 1024)
177 if ((avctx->
width & 1) != 0)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int pnm_space(int c)
packed RGB 8:8:8, 24bpp, RGBRGB...
int maxval
maximum value of a pixel
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void pnm_get(PNMContext *sc, char *str, int buf_size)
void av_log(void *avcl, int level, const char *fmt,...)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
#define AV_PIX_FMT_GRAY16
int width
picture width / height.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
#define AV_PIX_FMT_YUV420P16
Libavcodec external API header.
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
main external API structure.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.