Lines Matching refs:that

13  *   This is a C program that is intended to be linked against libpng.  It
16 * read code) and validates that the result has the correct data.
152 * handlers often themselves have bugs which lead to programs that detect
155 * warning messages into buffers that are too small.
207 * is implemented here so that it gives the same set of numbers on every
339 /* Convenience API and defines to list valid formats. Note that 16 bit read and
465 * that pixels 8 or more bits in size are byte aligned and that pixels
952 /* These somewhat odd functions are used when reading an image to ensure that
1026 * the start and three at the end of each (this ensures that the row
1228 /* Notice that a call to store_read will cause this function to fail because
1302 * that a memory problem while libpng is running will abort (png_error) the
1323 /* Note that pp may be NULL (see store_pool_delete below), the caller has
1470 /* First check that this 'memory' really is valid memory - it must be in the
1511 /* And make sure that all the memory has been freed - this will output
1660 * by default is stored in png_struct and that has not been allocated!)
1661 * However, given that store_error works correctly in these circumstances
1720 * to a list of png_modification structures that actually perform the
1736 * all spectra that produce this response as the same color, therefore this
1746 * (0,0,1) plus an encoding value that is used to encode the linear
1748 * B^gamma that are stored.
1871 * following must be set to 0 and tested by the function that uses the
1893 /* This is set by transforms that need to allow a higher limit, it is an
1894 * internal check on pngvalid to ensure that the calculated error limits are
1896 * that allows any value through.
1934 * validation code checks. If set any value that is within the transformed
1943 /* If set assume that the calculation bit depth is set by the input
1948 /* If set assume that the calculations are done in 16 bits even if the sample
1965 /* Buffer information, the buffer size limits the size of the chunks that can
2035 /* This controls use of checks that explicitly know how libpng digitizes the
2046 * bit precision. This only affects those of the following limits that pertain
2106 /* Percentage error permitted in the linear values. Note that the specified
2296 * that this function changes the colour space encoding so it must only be
2364 * that looks at the encodings. (Not the 'add' function!)
2416 /* Enquiry functions to find out what is set. Notice that there is an implicit
2417 * assumption below that the first encoding in the list is the one for sRGB.
2526 * IEND. 'flush' indicates that there is still some data to
2603 * otherwise the code will end up modifying a chunk that was
2712 /* Check that this number of bytes are available (in the current buffer.)
2748 /* Do this first so that the modifier fields are cleared even if an error
3008 * (maximum) this actually makes a random palette in the hope that enough tests
3009 * will catch enough errors. (Note that the same palette isn't produced every
3436 * that test odd sizes along with the libpng interlace handling.
3563 * because 'ps' is not used in this branch of the setjmp. Note that fault
3609 /* Note that this can, trivially, be optimized to a memcpy on pass 7, the
3756 * that aren't set below all '1':
3788 * that there are two conditions here, either the row isn't
3814 * incrementing is so that Paeth gets used in all images bigger
3861 * because 'ps' is not used in this branch of the setjmp. Note that fault
3932 * to ensure that they get detected - it should not be possible to write an
4040 /* Now write the whole image, just to make sure that the detected, or
4072 /* The following deletes the file that was just written. */
4117 #ifdef PNG_WARNINGS_SUPPORTED /* else there are no cases that work! */
4148 * nothing if that is compiled out.
4217 * sequential reader it is necessary to deal with the fact that the progressive
4224 * that a nested function definition can access the local (C auto) variables of
4225 * the functions that contain its definition. In fact C provides the first
4229 * local variables (and function call parameters) of the function that actually
4235 * requirement that the pointer to the first member of a structure must be the
4237 * functions in the gamma test code; something that could not be done with
4310 * comes from the particular png_store_file that is selected.
4399 * result above and fails to check that the variables it passed have
4400 * actually been filled in! Note that if the app were to pass the
4574 /* In any case always check for a tranparent color (notice that the
4635 /* Record cbRow now that it can be found. */
4653 /* Note that the validation routine has the side effect of turning on
4659 * below in the png_modifier code for that variant.
4672 /* Validate the height, width and rowbytes plus ensure that sufficient buffer
4944 * that have been read so far, but 'display' will have those pixels
4947 * The side effect inside the libpng sequential reader is that the 'row'
5030 * function and initialize the locals that are filled in later.
5065 /* Note that this takes the store, not the display. */
5071 /* The code tests both versions of the images that the sequential
5083 /* After the last pass loop over the rows again to check that the
5334 * Note that this currently assumes a simple palette where entry x has colour
5389 * palette validation works means that the original palette is never updated,
5407 /* The bit depth of the row changes at this point too (notice that this is
5509 struct transform_display *that);
5514 struct transform_display *that, png_structp pp, png_infop pi);
5516 /* Then a transform that takes an input pixel in one PNG format or another
5522 void (*mod)(PNG_CONST struct image_transform *this, image_pixel *that,
5531 PNG_CONST struct image_transform **that, png_byte colour_type,
5583 transform_display *that)
5586 UNUSED(that)
5591 transform_display *that, png_structp pp, png_infop pi)
5594 UNUSED(that)
5617 image_transform_mod_end(PNG_CONST image_transform *this, image_pixel *that,
5620 PNG_CONST unsigned int scale = (1U<<that->sample_depth)-1;
5631 * including simple size scaling, though libpng doesn't do that at present.
5633 that->red = sample_scale(that->redf, scale);
5636 * value seen. Common sense tells us that the intermediate integer
5640 * but that is ignored here. Instead the final digitized value is compared,
5643 * any algorithm that digitizes intermediate results can be more accurate.
5645 that->rede += 1./(2*((1U<<that->red_sBIT)-1));
5647 if (that->colour_type & PNG_COLOR_MASK_COLOR)
5649 that->green = sample_scale(that->greenf, scale);
5650 that->blue = sample_scale(that->bluef, scale);
5651 that->greene += 1./(2*((1U<<that->green_sBIT)-1));
5652 that->bluee += 1./(2*((1U<<that->blue_sBIT)-1));
5656 that->blue = that->green = that->red;
5657 that->bluef = that->greenf = that->redf;
5658 that->bluee = that->greene = that->rede;
5661 if ((that->colour_type & PNG_COLOR_MASK_ALPHA) ||
5662 that->colour_type == PNG_COLOR_TYPE_PALETTE)
5664 that->alpha = sample_scale(that->alphaf, scale);
5665 that->alphae += 1./(2*((1U<<that->alpha_sBIT)-1));
5669 that->alpha = scale; /* opaque */
5670 that->alpha = 1; /* Override this. */
5671 that->alphae = 0; /* It's exact ;-) */
5737 /* Validate the combination of colour type and bit depth that we are getting
5770 /* Use a test pixel to check that the output agrees with what we expect -
5923 /* Validate that the palette count itself has not changed - this is not
5940 /* use-input-precision means assume that if the input has 8 bit (or less)
6042 /* Record that something was actually checked to avoid a false positive. */
6165 transform_display *that)
6167 this->next->ini(this->next, that);
6173 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6178 this->next = *that;
6179 *that = this;
6189 transform_display *that, png_structp pp, png_infop pi)
6192 this->next->set(this->next, that, pp, pi);
6197 image_pixel *that, png_const_structp pp,
6200 if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
6201 image_pixel_convert_PLTE(that);
6203 this->next->mod(this->next, that, pp, display);
6208 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6212 this->next = *that;
6213 *that = this;
6227 transform_display *that, png_structp pp, png_infop pi)
6230 this->next->set(this->next, that, pp, pi);
6235 image_pixel *that, png_const_structp pp,
6239 if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
6240 image_pixel_convert_PLTE(that);
6245 if (that->have_tRNS)
6246 image_pixel_add_alpha(that, &display->this);
6251 if (that->bit_depth < 8)
6252 that->bit_depth =8;
6253 if (that->sample_depth < 8)
6254 that->sample_depth = 8;
6257 this->next->mod(this->next, that, pp, display);
6262 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6266 this->next = *that;
6267 *that = this;
6269 /* We don't know yet whether there will be a tRNS chunk, but we know that
6285 transform_display *that, png_structp pp, png_infop pi)
6288 this->next->set(this->next, that, pp, pi);
6293 image_pixel *that, png_const_structp pp,
6301 if ((that->colour_type & PNG_COLOR_MASK_COLOR) == 0 && that->have_tRNS)
6302 image_pixel_add_alpha(that, &display->this);
6305 if (that->colour_type == PNG_COLOR_TYPE_GRAY)
6308 if (that->bit_depth < 8)
6309 that->sample_depth = that->bit_depth = 8;
6314 that->colour_type = PNG_COLOR_TYPE_RGB;
6317 else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA)
6318 that->colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
6320 this->next->mod(this->next, that, pp, display);
6325 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6329 this->next = *that;
6330 *that = this;
6344 transform_display *that, png_structp pp, png_infop pi)
6347 this->next->set(this->next, that, pp, pi);
6352 image_pixel *that, png_const_structp pp,
6356 if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
6357 image_pixel_convert_PLTE(that);
6358 else if (that->bit_depth < 8) /* grayscale */
6359 that->sample_depth = that->bit_depth = 8;
6361 if (that->have_tRNS)
6362 image_pixel_add_alpha(that, &display->this);
6364 this->next->mod(this->next, that, pp, display);
6369 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6373 this->next = *that;
6374 *that = this;
6393 PNG_CONST image_transform *this, transform_display *that, png_structp pp,
6397 this->next->set(this->next, that, pp, pi);
6402 PNG_CONST image_transform *this, image_pixel *that, png_const_structp pp,
6405 image_transform_png_set_expand_mod(this, that, pp, display);
6410 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6412 return image_transform_png_set_expand_add(this, that, colour_type,
6425 transform_display *that, png_structp pp, png_infop pi)
6428 this->next->set(this->next, that, pp, pi);
6433 image_pixel *that, png_const_structp pp,
6439 if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
6440 image_pixel_convert_PLTE(that);
6442 if (that->have_tRNS)
6443 image_pixel_add_alpha(that, &display->this);
6445 if (that->bit_depth < 16)
6446 that->sample_depth = that->bit_depth = 16;
6448 this->next->mod(this->next, that, pp, display);
6453 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6457 this->next = *that;
6458 *that = this;
6473 transform_display *that, png_structp pp, png_infop pi)
6476 this->next->set(this->next, that, pp, pi);
6481 image_pixel *that, png_const_structp pp,
6484 if (that->bit_depth == 16)
6486 that->sample_depth = that->bit_depth = 8;
6487 if (that->red_sBIT > 8) that->red_sBIT = 8;
6488 if (that->green_sBIT > 8) that->green_sBIT = 8;
6489 if (that->blue_sBIT > 8) that->blue_sBIT = 8;
6490 if (that->alpha_sBIT > 8) that->alpha_sBIT = 8;
6493 this->next->mod(this->next, that, pp, display);
6498 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6502 this->next = *that;
6503 *that = this;
6517 transform_display *that, png_structp pp, png_infop pi)
6520 this->next->set(this->next, that, pp, pi);
6525 image_pixel *that, png_const_structp pp,
6528 if (that->bit_depth == 16)
6530 that->sample_depth = that->bit_depth = 8;
6531 if (that->red_sBIT > 8) that->red_sBIT = 8;
6532 if (that->green_sBIT > 8) that->green_sBIT = 8;
6533 if (that->blue_sBIT > 8) that->blue_sBIT = 8;
6534 if (that->alpha_sBIT > 8) that->alpha_sBIT = 8;
6547 * Notice that this is only relevant prior to the addition of the
6552 that->rede += d;
6553 that->greene += d;
6554 that->bluee += d;
6555 that->alphae += d;
6560 this->next->mod(this->next, that, pp, display);
6565 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6569 this->next = *that;
6570 *that = this;
6584 transform_display *that, png_structp pp, png_infop pi)
6587 this->next->set(this->next, that, pp, pi);
6592 image_pixel *that, png_const_structp pp,
6595 if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA)
6596 that->colour_type = PNG_COLOR_TYPE_GRAY;
6597 else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA)
6598 that->colour_type = PNG_COLOR_TYPE_RGB;
6600 that->have_tRNS = 0;
6601 that->alphaf = 1;
6603 this->next->mod(this->next, that, pp, display);
6608 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
6612 this->next = *that;
6613 *that = this;
6667 transform_display *that)
6669 png_modifier *pm = that->pm;
6721 * skip a non-override test, ignore that.
6768 if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations)
6779 that->pm->limit += pow(
6781 (that->this.bit_depth == 16 ? 8. :
6792 * will trigger the error check in transform_range_check. Fix that
6804 that->pm->limit += pow(
6817 * calculation in the 8 bit case, allow for that here.
6819 if (that->this.bit_depth != 16 && !pm->assume_16_bit_calculations)
6820 that->pm->limit += 4E-3;
6826 transform_display *that, png_structp pp, png_infop pi)
6838 if (that->pm->current_encoding != 0)
6841 * check that the libpng APIs give the correct (X,Y,Z) values within
6871 modifier_current_encoding(that->pm, &o);
6948 this->next->set(this->next, that, pp, pi);
6953 image_pixel *that, png_const_structp pp,
6956 if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0)
6960 if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
6961 image_pixel_convert_PLTE(that);
6967 const unsigned int sample_depth = that->sample_depth;
6985 r = rlo = rhi = that->redf;
6986 rlo -= that->rede;
6988 rhi += that->rede;
6991 g = glo = ghi = that->greenf;
6992 glo -= that->greene;
6994 ghi += that->greene;
6997 b = blo = bhi = that->bluef;
6998 blo -= that->bluee;
7000 bhi += that->greene;
7033 * 1/32768, because even in the rounding case the requirement that
7075 err = (that->rede + that->greene + that->bluee)/3;
7083 /* Check that this worked: */
7099 double r = that->redf;
7100 double re = that->rede;
7101 double g = that->greenf;
7102 double ge = that->greene;
7103 double b = that->bluef;
7104 double be = that->bluee;
7122 * that adding the 1/32768 here avoids needing to increase the
7140 double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255);
7141 double out_qe = (that->sample_depth > 8 ? .5/65535 :
7189 /* Validate that the error is within limits (this has caused
7207 that->bluef = that->greenf = that->redf = gray;
7208 that->bluee = that->greene = that->rede = err;
7211 if (that->red_sBIT > that->green_sBIT)
7212 that->red_sBIT = that->green_sBIT;
7213 if (that->red_sBIT > that->blue_sBIT)
7214 that->red_sBIT = that->blue_sBIT;
7215 that->blue_sBIT = that->green_sBIT = that->red_sBIT;
7218 if (that->colour_type == PNG_COLOR_TYPE_RGB)
7219 that->colour_type = PNG_COLOR_TYPE_GRAY;
7220 else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA)
7221 that->colour_type = PNG_COLOR_TYPE_GRAY_ALPHA;
7224 this->next->mod(this->next, that, pp, display);
7229 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
7233 this->next = *that;
7234 *that = this;
7261 transform_display *that, png_structp pp, png_infop pi)
7270 * so we need to know what that is! The background colour is stored in the
7278 colour_type = that->this.colour_type;
7288 bit_depth = that->this.bit_depth;
7316 this->next->set(this->next, that, pp, pi);
7321 image_pixel *that, png_const_structp pp,
7325 if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE)
7326 image_pixel_add_alpha(that, &display->this);
7329 if (that->alphaf < 1)
7332 if (that->alphaf <= 0)
7334 that->redf = data.redf;
7335 that->greenf = data.greenf;
7336 that->bluef = data.bluef;
7338 that->rede = data.rede;
7339 that->greene = data.greene;
7340 that->bluee = data.bluee;
7342 that->red_sBIT= data.red_sBIT;
7343 that->green_sBIT= data.green_sBIT;
7344 that->blue_sBIT= data.blue_sBIT;
7349 double alf = 1 - that->alphaf;
7351 that->redf = that->redf * that->alphaf + data.redf * alf;
7352 that->rede = that->rede * that->alphaf + data.rede * alf +
7354 that->greenf = that->greenf * that->alphaf + data.greenf * alf;
7355 that->greene = that->greene * that->alphaf + data.greene * alf +
7357 that->bluef = that->bluef * that->alphaf + data.bluef * alf;
7358 that->bluee = that->bluee * that->alphaf + data.bluee * alf +
7362 /* Remove the alpha type and set the alpha (not in that order.) */
7363 that->alphaf = 1;
7364 that->alphae = 0;
7366 if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA)
7367 that->colour_type = PNG_COLOR_TYPE_RGB;
7368 else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA)
7369 that->colour_type = PNG_COLOR_TYPE_GRAY;
7373 this->next->mod(this->next, that, pp, display);
7520 /* Go through the whole list adding anything that the counter selects: */
7564 transform_display *that, png_structp pp, png_infop pi)
7567 this->next->set(this->next, that, pp, pi);
7572 image_pixel *that, png_const_structp pp,
7575 this->next->mod(this->next, that, pp, display);
7580 PNG_CONST image_transform **that, char *name, size_t sizeof_name,
7583 this->next = *that;
7584 *that = this;
7751 * because the output bit depth is read from the library. Note that there
8034 /* The optimization is that the partial-alpha entries are linear
8125 * the actual sample values - unencoded light intensity values. Note that in
8253 * 'max' values. Note that maxout is in the encoded space but maxpc and
8264 * into account the possibility that even for 16 bit output 8 bit space
8306 /* The primary test is that the final encoded value returned by the
8307 * library should be between the two limits (inclusive) that were
8333 * 16-to-8 processing. Assume that the input value (id, adjusted
8656 * pixel value. Therefore we assume that the *input* value is exact -
8669 * decoder to assume that the PNG values have been scaled if sBIT is
8674 * This means that only a subset of the possible PNG values should
8679 * Nevertheless the spec requires that the upper 'sBIT' bits of the
8684 * Because there is limited precision in the input it is arguable that
9145 /* Note that this requires a 16 bit source image but produces 8 bit output, so
9156 /* Include the alpha cases here. Note that sbit matches the internal value
9238 /* This tests the handling of a unique value, the math is such that the
9329 /* This assumes no expand gray->rgb - the current code won't handle that!
9384 /* Use -1 to catch tests that were not actually run */
9579 * be indexed adam7[y][x] and notice that the pass numbers are based at
9597 * named internal routines that feed off the above array.
9793 /* The macros to validate, first those that depend only on pass:
9838 /* Macros that depend on the image or sub-image height too:
9930 * The png_modifier code assumes that encodings[0] is sRGB and treats it
9960 * context pointer so that it can throw an exception (call longjmp) to recover
10057 * end up ignoring FP conditions that other platforms fault.
10065 * note that, for testing purposes, it is deliberately mis-aligned by tag
10078 * code that 16-bit arithmetic is used for 8-bit samples when it would make a
10127 /* NOTE: this is a reasonable perceptual limit. We assume that humans can
10409 * parameters, where possible. The limitation is that all the progressive