34 return c ==
' ' ||
c ==
'\n' ||
c ==
'\r' ||
c ==
'\t';
48 while (
c !=
'\n' && bs < end) {
67 char buf1[32], tuple_type[32];
68 int h,
w, depth, maxval;
71 if (
s->bytestream_end -
s->bytestream < 3 ||
72 s->bytestream[0] !=
'P' ||
73 (
s->bytestream[1] <
'1' ||
74 s->bytestream[1] >
'7' &&
75 s->bytestream[1] !=
'f' &&
76 s->bytestream[1] !=
'F')) {
77 s->bytestream +=
s->bytestream_end >
s->bytestream;
78 s->bytestream +=
s->bytestream_end >
s->bytestream;
86 }
else if (buf1[1] ==
'f') {
88 }
else if (
s->type==1 ||
s->type==4) {
90 }
else if (
s->type==2 ||
s->type==5) {
95 }
else if (
s->type==3 ||
s->type==6) {
97 }
else if (
s->type==7) {
102 tuple_type[0] =
'\0';
105 if (!strcmp(buf1,
"WIDTH")) {
107 w = strtol(buf1,
NULL, 10);
108 }
else if (!strcmp(buf1,
"HEIGHT")) {
110 h = strtol(buf1,
NULL, 10);
111 }
else if (!strcmp(buf1,
"DEPTH")) {
113 depth = strtol(buf1,
NULL, 10);
114 }
else if (!strcmp(buf1,
"MAXVAL")) {
116 maxval = strtol(buf1,
NULL, 10);
117 }
else if (!strcmp(buf1,
"TUPLTYPE") ||
119 !strcmp(buf1,
"TUPLETYPE")) {
120 pnm_get(
s, tuple_type,
sizeof(tuple_type));
121 }
else if (!strcmp(buf1,
"ENDHDR")) {
131 if (
w <= 0 ||
h <= 0 || maxval <= 0 || maxval > UINT16_MAX || depth <= 0 || tuple_type[0] ==
'\0' ||
142 }
else if (maxval < 256) {
147 }
else if (depth == 2) {
153 }
else if (depth == 3) {
159 }
else if (depth == 4) {
189 s->endian =
s->scale < 0.f;
191 s->maxval = (1ULL << 32) - 1;
194 s->maxval = atoi(buf1);
195 if (
s->maxval <= 0 ||
s->maxval > UINT16_MAX) {
199 if (
s->maxval >= 256) {
207 else if (
s->maxval < 1024)
226 if ((avctx->
width & 1) != 0)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static __device__ float fabsf(float a)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
common internal API header
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_GRAYF32
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
#define AV_PIX_FMT_GRAY16
static int pnm_space(int c)
static void pnm_get(PNMContext *sc, char *str, int buf_size)
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...