28 return c ==
' ' || c ==
'\n' || c ==
'\r' || c ==
'\t';
50 if ((s - str) < buf_size - 1)
59 char buf1[32], tuple_type[32];
60 int h, w,
depth, maxval;
69 }
else if (s->
type==2 || s->
type==5) {
74 }
else if (s->
type==3 || s->
type==6) {
76 }
else if (s->
type==7) {
84 if (!strcmp(buf1,
"WIDTH")) {
86 w = strtol(buf1,
NULL, 10);
87 }
else if (!strcmp(buf1,
"HEIGHT")) {
89 h = strtol(buf1,
NULL, 10);
90 }
else if (!strcmp(buf1,
"DEPTH")) {
92 depth = strtol(buf1,
NULL, 10);
93 }
else if (!strcmp(buf1,
"MAXVAL")) {
95 maxval = strtol(buf1,
NULL, 10);
96 }
else if (!strcmp(buf1,
"TUPLETYPE")) {
97 pnm_get(s, tuple_type,
sizeof(tuple_type));
98 }
else if (!strcmp(buf1,
"ENDHDR")) {
105 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] ==
'\0' ||
av_image_check_size(w, h, 0, avctx))
115 }
else if (depth == 3) {
123 }
else if (depth == 4) {
132 pnm_get(s, buf1,
sizeof(buf1));
133 avctx->
width = atoi(buf1);
134 if (avctx->
width <= 0)
136 pnm_get(s, buf1,
sizeof(buf1));
137 avctx->
height = atoi(buf1);
141 pnm_get(s, buf1,
sizeof(buf1));
165 if ((avctx->
width & 1) != 0)
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
static int pnm_space(int c)
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
int maxval
maximum value of a pixel
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
static void pnm_get(PNMContext *sc, char *str, int buf_size)
void av_log(void *avcl, int level, const char *fmt,...)
av_cold int ff_pnm_end(AVCodecContext *avctx)
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 width
picture width / height.
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
av_cold int ff_pnm_init(AVCodecContext *avctx)
packed RGB 8:8:8, 24bpp, RGBRGB...
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.