pngcrush  1.8.13
About: Pngcrush is an optimizer for PNG (Portable Network Graphics) files.
  Fossies Dox: pngcrush-1.8.13.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

pngrutil.c File Reference
#include "pngpriv.h"
Include dependency graph for pngrutil.c:

Go to the source code of this file.

Macros

#define PNG_FIXED_ERROR   (-1)
 
#define PNG_LSR(x, s)   ((x)>>((s) & 0x1f))
 
#define PNG_LSL(x, s)   ((x)<<((s) & 0x1f))
 
#define S_COPY(p, x)
 
#define B_COPY(p, x)
 
#define PIXEL_MASK(p, x, d, s)   (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))
 
#define S_MASKx(p, x, d, s)   (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
 
#define B_MASKx(p, x, d, s)   (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
 
#define MASK_EXPAND(m, d)   ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))
 
#define S_MASK(p, d, s)
 
#define B_MASK(p, d, s)
 
#define S_MASKS(d, s)
 
#define B_MASKS(d, s)   { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }
 
#define DEPTH_INDEX(d)   ((d)==1?0:((d)==2?1:2))
 
#define MASK(pass, depth, display, png)
 

Functions

png_uint_32 png_get_uint_31 (png_const_structrp png_ptr, png_const_bytep buf)
 
static png_fixed_point png_get_fixed_point (png_structrp png_ptr, png_const_bytep buf)
 
png_uint_32() png_get_uint_32 (png_const_bytep buf)
 
png_int_32() png_get_int_32 (png_const_bytep buf)
 
png_uint_16() png_get_uint_16 (png_const_bytep buf)
 
void png_read_sig (png_structrp png_ptr, png_inforp info_ptr)
 
png_uint_32 png_read_chunk_header (png_structrp png_ptr)
 
void png_crc_read (png_structrp png_ptr, png_bytep buf, png_uint_32 length)
 
int png_crc_finish (png_structrp png_ptr, png_uint_32 skip)
 
int png_crc_error (png_structrp png_ptr)
 
static png_bytep png_read_buffer (png_structrp png_ptr, png_alloc_size_t new_size, int warn)
 
static int png_inflate_claim (png_structrp png_ptr, png_uint_32 owner)
 
int png_zlib_inflate (png_structrp png_ptr, int flush)
 
static int png_inflate (png_structrp png_ptr, png_uint_32 owner, int finish, png_const_bytep input, png_uint_32p input_size_ptr, png_bytep output, png_alloc_size_t *output_size_ptr)
 
static int png_decompress_chunk (png_structrp png_ptr, png_uint_32 chunklength, png_uint_32 prefix_size, png_alloc_size_t *newlength, int terminate)
 
static int png_inflate_read (png_structrp png_ptr, png_bytep read_buffer, uInt read_size, png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, int finish)
 
void png_handle_IHDR (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_PLTE (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_IEND (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_gAMA (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_sBIT (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_cHRM (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_sRGB (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_iCCP (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_sPLT (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_tRNS (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_bKGD (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_eXIf (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_hIST (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_pHYs (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_oFFs (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_pCAL (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_sCAL (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_tIME (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_tEXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_zTXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
void png_handle_iTXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
static int png_cache_unknown_chunk (png_structrp png_ptr, png_uint_32 length)
 
void png_handle_unknown (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep)
 
void png_check_chunk_name (png_const_structrp png_ptr, const png_uint_32 chunk_name)
 
void png_check_chunk_length (png_const_structrp png_ptr, const png_uint_32 length)
 
void png_combine_row (png_const_structrp png_ptr, png_bytep dp, int display)
 
void png_do_read_interlace (png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations)
 
static void png_read_filter_row_sub (png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
 
static void png_read_filter_row_up (png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
 
static void png_read_filter_row_avg (png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
 
static void png_read_filter_row_paeth_1byte_pixel (png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
 
static void png_read_filter_row_paeth_multibyte_pixel (png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
 
static void png_init_filter_functions (png_structrp pp)
 
void png_read_filter_row (png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter)
 
void png_read_IDAT_data (png_structrp png_ptr, png_bytep output, png_alloc_size_t avail_out)
 
void png_read_finish_IDAT (png_structrp png_ptr)
 
void png_read_finish_row (png_structrp png_ptr)
 
void png_read_start_row (png_structrp png_ptr)
 

Macro Definition Documentation

◆ B_COPY

#define B_COPY (   p,
 
)
Value:
(((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\
PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)

◆ B_MASK

#define B_MASK (   p,
  d,
 
)
Value:
MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\
B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\
B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)

◆ B_MASKS

#define B_MASKS (   d,
 
)    { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }

◆ B_MASKx

#define B_MASKx (   p,
  x,
  d,
 
)    (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)

◆ DEPTH_INDEX

#define DEPTH_INDEX (   d)    ((d)==1?0:((d)==2?1:2))

◆ MASK

#define MASK (   pass,
  depth,
  display,
  png 
)
Value:
((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\
row_mask[png][DEPTH_INDEX(depth)][pass])

◆ MASK_EXPAND

#define MASK_EXPAND (   m,
 
)    ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))

◆ PIXEL_MASK

#define PIXEL_MASK (   p,
  x,
  d,
 
)    (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))

◆ PNG_FIXED_ERROR

#define PNG_FIXED_ERROR   (-1)

Definition at line 38 of file pngrutil.c.

◆ PNG_LSL

#define PNG_LSL (   x,
 
)    ((x)<<((s) & 0x1f))

◆ PNG_LSR

#define PNG_LSR (   x,
 
)    ((x)>>((s) & 0x1f))

◆ S_COPY

#define S_COPY (   p,
 
)
Value:
(((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\
PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)

◆ S_MASK

#define S_MASK (   p,
  d,
 
)
Value:
MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\
S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\
S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)

◆ S_MASKS

#define S_MASKS (   d,
 
)
Value:
{ S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }

◆ S_MASKx

#define S_MASKx (   p,
  x,
  d,
 
)    (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)

Function Documentation

◆ png_cache_unknown_chunk()

static int png_cache_unknown_chunk ( png_structrp  png_ptr,
png_uint_32  length 
)
static

◆ png_check_chunk_length()

void png_check_chunk_length ( png_const_structrp  png_ptr,
const png_uint_32  length 
)

◆ png_check_chunk_name()

void png_check_chunk_name ( png_const_structrp  png_ptr,
const png_uint_32  chunk_name 
)

Definition at line 3124 of file pngrutil.c.

References png_chunk_error(), and png_debug.

Referenced by png_push_read_chunk(), and png_read_chunk_header().

◆ png_combine_row()

◆ png_crc_error()

◆ png_crc_finish()

◆ png_crc_read()

◆ png_decompress_chunk()

static int png_decompress_chunk ( png_structrp  png_ptr,
png_uint_32  chunklength,
png_uint_32  prefix_size,
png_alloc_size_t newlength,
int  terminate 
)
static

◆ png_do_read_interlace()

void png_do_read_interlace ( png_row_infop  row_info,
png_bytep  row,
int  pass,
png_uint_32  transformations 
)

◆ png_get_fixed_point()

static png_fixed_point png_get_fixed_point ( png_structrp  png_ptr,
png_const_bytep  buf 
)
static

Definition at line 41 of file pngrutil.c.

References PNG_FIXED_ERROR, png_get_uint_32(), PNG_UINT_31_MAX, and png_warning().

Referenced by png_handle_cHRM(), and png_handle_gAMA().

◆ png_get_int_32()

png_int_32() png_get_int_32 ( png_const_bytep  buf)

Definition at line 85 of file pngrutil.c.

References png_get_uint_32().

Referenced by png_handle_oFFs(), and png_handle_pCAL().

◆ png_get_uint_16()

png_uint_16() png_get_uint_16 ( png_const_bytep  buf)

◆ png_get_uint_31()

png_uint_32 png_get_uint_31 ( png_const_structrp  png_ptr,
png_const_bytep  buf 
)

◆ png_get_uint_32()

png_uint_32() png_get_uint_32 ( png_const_bytep  buf)

◆ png_handle_bKGD()

◆ png_handle_cHRM()

◆ png_handle_eXIf()

◆ png_handle_gAMA()

◆ png_handle_hIST()

◆ png_handle_iCCP()

◆ png_handle_IEND()

void png_handle_IEND ( png_structrp  png_ptr,
png_inforp  info_ptr,
png_uint_32  length 
)

◆ png_handle_IHDR()

◆ png_handle_iTXt()

◆ png_handle_oFFs()

◆ png_handle_pCAL()

◆ png_handle_pHYs()

◆ png_handle_PLTE()

◆ png_handle_sBIT()

◆ png_handle_sCAL()

◆ png_handle_sPLT()

◆ png_handle_sRGB()

◆ png_handle_tEXt()

◆ png_handle_tIME()

◆ png_handle_tRNS()

◆ png_handle_unknown()

◆ png_handle_zTXt()

◆ png_inflate()

◆ png_inflate_claim()

◆ png_inflate_read()

◆ png_init_filter_functions()

◆ png_read_buffer()

◆ png_read_chunk_header()

◆ png_read_filter_row()

void png_read_filter_row ( png_structrp  pp,
png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row,
int  filter 
)

◆ png_read_filter_row_avg()

static void png_read_filter_row_avg ( png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row 
)
static

◆ png_read_filter_row_paeth_1byte_pixel()

static void png_read_filter_row_paeth_1byte_pixel ( png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row 
)
static

Definition at line 3979 of file pngrutil.c.

References png_row_info_struct::rowbytes.

Referenced by png_init_filter_functions().

◆ png_read_filter_row_paeth_multibyte_pixel()

static void png_read_filter_row_paeth_multibyte_pixel ( png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row 
)
static

◆ png_read_filter_row_sub()

static void png_read_filter_row_sub ( png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row 
)
static

◆ png_read_filter_row_up()

static void png_read_filter_row_up ( png_row_infop  row_info,
png_bytep  row,
png_const_bytep  prev_row 
)
static

Definition at line 3936 of file pngrutil.c.

References png_const_bytep, and png_row_info_struct::rowbytes.

Referenced by png_init_filter_functions().

◆ png_read_finish_IDAT()

◆ png_read_finish_row()

◆ png_read_IDAT_data()

◆ png_read_sig()

void png_read_sig ( png_structrp  png_ptr,
png_inforp  info_ptr 
)

◆ png_read_start_row()

◆ png_zlib_inflate()

int png_zlib_inflate ( png_structrp  png_ptr,
int  flush 
)
B_MASKx
#define B_MASKx(p, x, d, s)
MASK_EXPAND
#define MASK_EXPAND(m, d)
S_MASK
#define S_MASK(p, d, s)
DEPTH_INDEX
#define DEPTH_INDEX(d)
S_MASKx
#define S_MASKx(p, x, d, s)
PNG_LSR
#define PNG_LSR(x, s)