|
iPXE
|
Portable Network Graphics (PNG) format. More...
#include <stdint.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <byteswap.h>#include <ipxe/umalloc.h>#include <ipxe/pixbuf.h>#include <ipxe/deflate.h>#include <ipxe/png.h>Go to the source code of this file.
Data Structures | |
| struct | png_context |
| PNG context. More... | |
| struct | png_interlace |
| A PNG interlace pass. More... | |
| struct | png_filter |
| A PNG filter. More... | |
| struct | png_chunk_handler |
| A PNG chunk handler. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| static const char * | png_type_name (uint32_t type) |
| Transcribe PNG chunk type name (for debugging). | |
| static void | png_interlace (struct png_context *png, unsigned int pass, struct png_interlace *interlace) |
| Calculate PNG interlace pass parameters. | |
| static unsigned int | png_pixel_len (struct png_context *png) |
| Calculate PNG pixel length. | |
| static size_t | png_scanline_len (struct png_context *png, struct png_interlace *interlace) |
| Calculate PNG scanline length. | |
| static int | png_image_header (struct image *image, struct png_context *png, size_t len) |
| Handle PNG image header chunk. | |
| static int | png_palette (struct image *image, struct png_context *png, size_t len) |
| Handle PNG palette chunk. | |
| static int | png_image_data (struct image *image, struct png_context *png, size_t len) |
| Handle PNG image data chunk. | |
| static unsigned int | png_unfilter_none (unsigned int current, unsigned int left __unused, unsigned int above __unused, unsigned int above_left __unused) |
| Unfilter byte using the "None" filter. | |
| static unsigned int | png_unfilter_sub (unsigned int current, unsigned int left, unsigned int above __unused, unsigned int above_left __unused) |
| Unfilter byte using the "Sub" filter. | |
| static unsigned int | png_unfilter_up (unsigned int current, unsigned int left __unused, unsigned int above, unsigned int above_left __unused) |
| Unfilter byte using the "Up" filter. | |
| static unsigned int | png_unfilter_average (unsigned int current, unsigned int left, unsigned int above, unsigned int above_left __unused) |
| Unfilter byte using the "Average" filter. | |
| static unsigned int | png_paeth_predictor (unsigned int a, unsigned int b, unsigned int c) |
| Paeth predictor function (defined in RFC 2083). | |
| static unsigned int | png_unfilter_paeth (unsigned int current, unsigned int left, unsigned int above, unsigned int above_left) |
| Unfilter byte using the "Paeth" filter. | |
| static int | png_unfilter_pass (struct image *image, struct png_context *png, struct png_interlace *interlace) |
| Unfilter one interlace pass of PNG raw data. | |
| static int | png_unfilter (struct image *image, struct png_context *png) |
| Unfilter PNG raw data. | |
| static unsigned int | png_pixel (unsigned int raw, unsigned int alpha, unsigned int max) |
| Calculate PNG pixel component value. | |
| static void | png_pixels_pass (struct image *image, struct png_context *png, struct png_interlace *interlace) |
| Fill one interlace pass of PNG pixels. | |
| static void | png_pixels (struct image *image, struct png_context *png) |
| Fill PNG pixels. | |
| static int | png_image_end (struct image *image, struct png_context *png, size_t len) |
| Handle PNG image end chunk. | |
| static int | png_chunk (struct image *image, struct png_context *png, uint32_t type, size_t len) |
| Handle PNG chunk. | |
| static int | png_pixbuf (struct image *image, struct pixel_buffer **pixbuf) |
| Convert PNG image to pixel buffer. | |
| static int | png_probe (struct image *image) |
| Probe PNG image. | |
| struct image_type png_image_type | __image_type (PROBE_NORMAL) |
| PNG image type. | |
Variables | |
| static struct png_signature | png_signature = PNG_SIGNATURE |
| PNG file signature. | |
| static uint8_t | png_interlace_passes [] |
| Number of interlacing passes. | |
| static struct png_filter | png_filters [] |
| PNG filter types. | |
| static struct png_chunk_handler | png_chunk_handlers [] |
| PNG chunk handlers. | |
Portable Network Graphics (PNG) format.
The PNG format is defined in RFC 2083.
Definition in file png.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
static |
|
static |
Calculate PNG interlace pass parameters.
| png | PNG context |
| pass | Pass number (0=first pass) |
| interlace | Interlace pass to fill in |
Definition at line 119 of file png.c.
References assert, pixel_buffer::height, png_interlace::height, png_interlace::pass, png_context::passes, png_context::pixbuf, pixel_buffer::width, png_interlace::width, png_interlace::x_indent, png_interlace::x_stride, png_interlace::y_indent, and png_interlace::y_stride.
Referenced by png_image_header(), png_pixels(), and png_unfilter().
|
static |
Calculate PNG pixel length.
| png | PNG context |
| pixel_len | Pixel length |
Definition at line 172 of file png.c.
References png_context::channels, and png_context::depth.
Referenced by png_unfilter_pass().
|
static |
Calculate PNG scanline length.
| png | PNG context |
| interlace | Interlace pass |
| scanline_len | Scanline length (including filter byte), or 0 on error |
Definition at line 184 of file png.c.
References assert, bits, png_context::channels, png_context::depth, and png_interlace::width.
Referenced by png_image_header(), and png_unfilter_pass().
|
static |
Handle PNG image header chunk.
| rc | Return status code |
Definition at line 207 of file png.c.
References alloc_pixbuf(), png_context::channels, png_context::colour_type, png_image_header::colour_type, png_image_header::compression, deflate_chunk::data, image::data, DBGC, png_context::depth, png_image_header::depth, EINVAL, ENOMEM, ENOTSUP, ERANGE, png_image_header::filter, png_image_header::height, png_interlace::height, png_image_header::interlace, deflate_chunk::len, len, image::name, ntohl, png_context::offset, png_interlace::pass, png_context::passes, png_context::pixbuf, PNG_COLOUR_TYPE_ALPHA, PNG_COLOUR_TYPE_PALETTE, PNG_COLOUR_TYPE_RGB, PNG_COMPRESSION_UNKNOWN, PNG_FILTER_UNKNOWN, png_interlace(), png_interlace_passes, PNG_INTERLACE_UNKNOWN, png_scanline_len(), png_context::raw, umalloc(), png_image_header::width, and png_interlace::width.
|
static |
Handle PNG palette chunk.
| rc | Return status code |
Definition at line 316 of file png.c.
References png_palette_entry::blue, image::data, DBGC2, png_palette_entry::green, len, image::name, png_context::offset, png_context::palette, and png_palette_entry::red.
|
static |
Handle PNG image data chunk.
| rc | Return status code |
Definition at line 353 of file png.c.
References image::data, DBGC, png_context::deflate, deflate_inflate(), len, image::name, png_context::offset, png_context::raw, rc, and strerror().
|
static |
Unfilter byte using the "None" filter.
| current | Filtered current byte |
| left | Unfiltered left byte |
| above | Unfiltered above byte |
| above_left | Unfiltered above-left byte |
| current | Unfiltered current byte |
Definition at line 378 of file png.c.
References __unused.
|
static |
Unfilter byte using the "Sub" filter.
| current | Filtered current byte |
| left | Unfiltered left byte |
| above | Unfiltered above byte |
| above_left | Unfiltered above-left byte |
| current | Unfiltered current byte |
Definition at line 395 of file png.c.
References __unused.
|
static |
Unfilter byte using the "Up" filter.
| current | Filtered current byte |
| left | Unfiltered left byte |
| above | Unfiltered above byte |
| above_left | Unfiltered above-left byte |
| current | Unfiltered current byte |
Definition at line 412 of file png.c.
References __unused.
|
static |
Unfilter byte using the "Average" filter.
| current | Filtered current byte |
| left | Unfiltered left byte |
| above | Unfiltered above byte |
| above_left | Unfiltered above-left byte |
| current | Unfiltered current byte |
Definition at line 429 of file png.c.
References __unused.
|
static |
Paeth predictor function (defined in RFC 2083).
| a | Pixel A |
| b | Pixel B |
| c | Pixel C |
| predictor | Predictor pixel |
Definition at line 445 of file png.c.
References abs.
Referenced by png_unfilter_paeth().
|
static |
Unfilter byte using the "Paeth" filter.
| current | Filtered current byte |
| above_left | Unfiltered above-left byte |
| above | Unfiltered above byte |
| left | Unfiltered left byte |
| current | Unfiltered current byte |
Definition at line 475 of file png.c.
References png_paeth_predictor().
|
static |
Unfilter one interlace pass of PNG raw data.
| image | PNG image |
| png | PNG context |
| interlace | Interlace pass |
| rc | Return status code |
This routine may assume that it is impossible to overrun the raw data buffer, since the size is determined by the image dimensions.
Definition at line 520 of file png.c.
References assert, data, deflate_chunk::data, DBGC, DBGC2, ENOTSUP, filter, png_interlace::height, image::name, NULL, deflate_chunk::offset, png_interlace::pass, png_filters, png_pixel_len(), png_scanline_len(), and png_context::raw.
Referenced by png_unfilter().
|
static |
Unfilter PNG raw data.
| image | PNG image |
| png | PNG context |
| rc | Return status code |
This routine may assume that it is impossible to overrun the raw data buffer, since the size is determined by the image dimensions.
Definition at line 596 of file png.c.
References assert, deflate_chunk::len, deflate_chunk::offset, png_interlace::pass, png_context::passes, png_interlace(), png_unfilter_pass(), png_context::raw, rc, and png_interlace::width.
Referenced by png_image_end().
|
inlinestatic |
Calculate PNG pixel component value.
| value | Component value in range 0-255 |
Definition at line 630 of file png.c.
Referenced by png_pixels_pass().
|
static |
Fill one interlace pass of PNG pixels.
| image | PNG image |
| png | PNG context |
| interlace | Interlace pass |
This routine may assume that it is impossible to overrun either the raw data buffer or the pixel buffer, since the sizes of both are determined by the image dimensions.
Definition at line 653 of file png.c.
References assert, bits, channel, png_context::channels, png_context::colour_type, data, deflate_chunk::data, pixel_buffer::data, DBGC2, png_context::depth, png_interlace::height, max, image::name, deflate_chunk::offset, png_context::palette, png_interlace::pass, png_context::pixbuf, PNG_COLOUR_TYPE_ALPHA, PNG_COLOUR_TYPE_PALETTE, PNG_COLOUR_TYPE_RGB, png_pixel(), png_context::raw, raw, value, pixel_buffer::width, png_interlace::width, x, png_interlace::x_indent, png_interlace::x_stride, y, png_interlace::y_indent, and png_interlace::y_stride.
Referenced by png_pixels().
|
static |
Fill PNG pixels.
| image | PNG image |
| png | PNG context |
This routine may assume that it is impossible to overrun either the raw data buffer or the pixel buffer, since the sizes of both are determined by the image dimensions.
Definition at line 769 of file png.c.
References assert, deflate_chunk::len, deflate_chunk::offset, png_interlace::pass, png_context::passes, png_interlace(), png_pixels_pass(), png_context::raw, and png_interlace::width.
Referenced by png_image_end().
|
static |
Handle PNG image end chunk.
| rc | Return status code |
Definition at line 798 of file png.c.
References DBGC, png_context::deflate, deflate_finished(), EINVAL, deflate_chunk::len, len, image::name, deflate_chunk::offset, png_context::pixbuf, png_pixels(), png_unfilter(), png_context::raw, and rc.
|
static |
Handle PNG chunk.
| rc | Return status code |
Definition at line 868 of file png.c.
References DBGC, ENOTSUP, png_chunk_handler::handle, htonl, len, image::name, png_context::offset, PNG_CHUNK_ANCILLARY, png_chunk_handlers, png_type_name(), png_chunk_handler::type, and type.
Referenced by png_pixbuf().
|
static |
Convert PNG image to pixel buffer.
| image | PNG image |
| pixbuf | Pixel buffer to fill in |
| rc | Return status code |
Definition at line 902 of file png.c.
References deflate_chunk::data, image::data, DBGC, png_context::deflate, deflate_init(), DEFLATE_ZLIB, EINVAL, ENOMEM, free, header, htonl, image::len, image::name, ntohl, png_context::offset, png_context::pixbuf, png_chunk(), PNG_TYPE_IEND, png_context::raw, rc, ufree(), and zalloc().
Referenced by __image_type().
|
static |
Probe PNG image.
| image | PNG image |
| rc | Return status code |
Definition at line 983 of file png.c.
References image::data, DBGC, ENOEXEC, image::len, memcmp(), image::name, and signature.
Referenced by __image_type().
| struct image_type png_image_type __image_type | ( | PROBE_NORMAL | ) |
PNG image type.
References __image_type, png_pixbuf(), png_probe(), and PROBE_NORMAL.
|
static |
|
static |
Number of interlacing passes.
Definition at line 91 of file png.c.
Referenced by png_image_header().
|
static |
PNG filter types.
Definition at line 501 of file png.c.
Referenced by png_unfilter_pass().
|
static |
PNG chunk handlers.
Definition at line 852 of file png.c.
Referenced by png_chunk().