Go to the documentation of this file.
34 return c ==
' ' ||
c ==
'\n' ||
c ==
'\r' ||
c ==
'\t';
48 while (
c !=
'\n' && bs < end) {
57 while (bs < end && !
pnm_space(
c) && (
s - str) < buf_size - 1) {
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[1] !=
'H' &&
78 s->bytestream[1] !=
'h')) {
79 s->bytestream +=
s->bytestream_end >
s->bytestream;
80 s->bytestream +=
s->bytestream_end >
s->bytestream;
89 }
else if (buf1[1] ==
'f') {
91 }
else if (buf1[1] ==
'H') {
94 }
else if (buf1[1] ==
'h') {
97 }
else if (
s->type==1 ||
s->type==4) {
99 }
else if (
s->type==2 ||
s->type==5) {
106 }
else if (
s->type==3 ||
s->type==6) {
108 }
else if (
s->type==7) {
113 tuple_type[0] =
'\0';
116 if (!strcmp(buf1,
"WIDTH")) {
118 w = strtol(buf1,
NULL, 10);
119 }
else if (!strcmp(buf1,
"HEIGHT")) {
121 h = strtol(buf1,
NULL, 10);
122 }
else if (!strcmp(buf1,
"DEPTH")) {
124 depth = strtol(buf1,
NULL, 10);
125 }
else if (!strcmp(buf1,
"MAXVAL")) {
127 maxval = strtol(buf1,
NULL, 10);
128 }
else if (!strcmp(buf1,
"TUPLTYPE") ||
130 !strcmp(buf1,
"TUPLETYPE")) {
131 pnm_get(
s, tuple_type,
sizeof(tuple_type));
132 }
else if (!strcmp(buf1,
"ENDHDR")) {
142 if (
w <= 0 ||
h <= 0 || maxval <= 0 || maxval > UINT16_MAX || depth <= 0 || tuple_type[0] ==
'\0' ||
153 }
else if (maxval < 256) {
158 }
else if (depth == 2) {
164 }
else if (depth == 3) {
170 }
else if (depth == 4) {
200 s->endian =
s->scale < 0.f;
202 s->maxval = (1ULL << 32) - 1;
205 s->maxval = atoi(buf1);
206 if (
s->maxval <= 0 ||
s->maxval > UINT16_MAX) {
210 if (
s->maxval >= 256) {
218 else if (
s->maxval < 1024)
237 if ((avctx->
width & 1) != 0)
static int pnm_space(int c)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
const uint8_t * bytestream_end
@ 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_YUV420P10
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.
static void pnm_get(PNMContext *sc, char *str, int buf_size)
#define AV_PIX_FMT_GRAY16
static __device__ float fabsf(float a)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_PIX_FMT_GRAYF32
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
#define AV_PIX_FMT_RGBA64
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
@ 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_GRAY8
Y , 8bpp.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_PIX_FMT_GBRPF32
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
main external API structure.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
const uint8_t * bytestream
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
int width
picture width / height.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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...