Home | History | Annotate | Download | only in tools

Lines Matching refs:idat

606 /* Information about a sequence of IDAT chunks, the chunks have been re-synced
665 /* Insert a new, malloc'ed, block of IDAT information buffers, this
717 /* PUBLIC GLOBAL VARIABLES: USED INTERNALLY BY IDAT READ CODE */
718 struct IDAT_list idat_cache; /* Cache of file IDAT information buffers */
720 * structure to avoid reallocation between IDAT streams.
747 global->idat_max = 0; /* no re-chunking of IDAT */
831 struct IDAT;
886 # define STATE_CHUNKS 1 /* Non-IDAT chunks are being written */
887 # define STATE_IDAT 2 /* An IDAT stream is being written */
893 struct IDAT * idat;
895 /* Interface to allocate a new chunk or IDAT control structure. The result
901 void (*alloc)(struct file*,int idat);
902 /* idat: allocate IDAT not chunk */
985 static void IDAT_end(struct IDAT **);
992 /* If either of the chunk pointers are set end them here, the IDAT structure
995 if (file->idat != NULL)
996 IDAT_end(&file->idat);
1052 file->idat = NULL;
1138 * only happens with IDAT where libpng reads the header then jumps around
1140 * we are at the start of the IDAT (i.e. no IDAT data has yet been written.)
1144 * IDAT ERR status code read-errno write-errno message file
1154 type = current_type(file, code); /* Gropes in struct chunk and IDAT */
1162 else /* magic: an IDAT header, produces bogons for too many IDATs */
1535 * This structure is instantiated for each chunk, except for the IDAT chunks
1537 * IDAT chunks (see the IDAT control structure below).
1545 /* PUBLIC IDAT INFORMATION: SET BY THE ZLIB CODE */
1672 assert(chunk != NULL && file->idat == NULL);
1701 assert(chunk != NULL && file->idat == NULL);
1748 /* IDAT READ/WRITE CONTROL STRUCTURE */
1749 struct IDAT
1755 /* PROTECTED IDAT INFORMATION: SET BY THE IDAT READ CODE */
1756 struct IDAT_list *idat_list_head; /* START of the list of IDAT information */
1757 struct IDAT_list *idat_list_tail; /* *END* of the list of IDAT information */
1759 /* PROTECTED IDAT INFORMATION: USED BY THE IDAT WRITE CODE */
1767 * one IDAT sequence (i.e. MNG is not supported).
1771 IDAT_end(struct IDAT **idat_var)
1773 struct IDAT *idat = *idat_var;
1774 struct file *file = idat->file;
1778 CLEAR(*idat);
1783 /* Regardless of why the IDAT was killed set the state back to CHUNKS (it may
1791 IDAT_init(struct IDAT * const idat, struct file * const file)
1792 /* When the chunk is png_IDAT instantiate an IDAT control structure in place
1793 * of a chunk control structure. The IDAT will instantiate a chunk control
1800 assert(file->idat == NULL);
1802 CLEAR(*idat);
1804 idat->file = file;
1805 idat->global = file->global;
1810 idat->global->idat_cache.count = 0;
1811 idat->idat_list_head = idat->idat_list_tail = &idat->global->idat_cache;
1822 file->idat = idat;
1826 rechunk_length(struct IDAT *idat, int start)
1827 /* Return the length for the next IDAT chunk, taking into account
1831 png_uint_32 len = idat->global->idat_max;
1839 return idat->idat_length; /* use the cache */
1844 cur = idat->idat_cur;
1845 count = idat->idat_count;
1847 assert(idat->idat_index == idat->idat_length &&
1848 idat->idat_length == cur->lengths[count]);
1855 assert(cur != idat->idat_list_tail);
1866 png_uint_32 have = idat->idat_length - idat->idat_index;
1870 struct IDAT_list *cur = idat->idat_cur;
1871 unsigned int j = idat->idat_count+1; /* the next IDAT in the list */
1892 if (cur == idat->idat_list_tail)
1908 /* Process the IDAT stream, this is the more complex than the preceding
1909 * cases because the compressed data is spread across multiple IDAT chunks
1914 * be written. It does this until the last IDAT chunk is passed in, then it
1919 * The caller must have an instantiated (IDAT) control structure and it must
1920 * have extent over the whole read of the IDAT stream. For a PNG this means
1926 assert(file->idat != NULL && file->chunk != NULL);
1928 /* We need to first check the entire sequence of IDAT chunks to ensure the
1937 list = file->idat->idat_list_tail;
1948 file->idat->idat_list_tail = list;
1951 /* And fill in the next IDAT information buffer. */
1960 /* This is the final IDAT chunk, so run the tests to check for the too far
1969 struct IDAT *idat;
1972 /* The IDAT stream was successfully uncompressed; see whether it
1982 stop(file, LIBPNG_ERROR_CODE, "IDAT: uncompressed data too small");
1984 /* Return the stream to the start of the first IDAT chunk; the length
1990 idat = file->idat;
1991 idat->idat_cur = idat->idat_list_head;
1992 idat->idat_length = idat->idat_cur->lengths[0];
1993 idat->idat_count = 0; /* Count of chunks read in current list */
1994 idat->idat_index = 0; /* Index into chunk data */
1996 /* Update the chunk length to the correct value for the IDAT chunk: */
1997 file->chunk->chunk_length = rechunk_length(idat, 1/*start*/);
1999 /* Change the state to writing IDAT chunks */
2005 else /* Failure to decompress the IDAT stream; give up. */
2006 stop(file, ZLIB_ERROR_CODE, "could not uncompress IDAT");
2013 struct IDAT * idat; /* NOTE: May be NULL */
2118 * IDAT reason flevel file-bits ok-bits compressed uncompressed file
2134 /* This is a zlib read error; the chunk will be skipped. For an IDAT
2139 * IDAT SKP flevel file-bits z-rc compressed message file
2195 zlib_init(struct zlib *zlib, struct IDAT *idat, struct chunk *chunk,
2201 zlib->idat = idat;
2490 /* Like zlib_advance but also handles a stream of IDAT chunks. */
2497 * IDAT specific check below.
2501 if (zlib->idat != NULL)
2503 struct IDAT_list *list = zlib->idat->idat_list_head;
2504 struct IDAT_list *last = zlib->idat->idat_list_tail;
2508 * IDAT it should be 0:
2513 * positioned at the start of the first IDAT chunk data.
2524 if (skip > 0) /* Skip CRC and next IDAT header */
2567 * length of the last IDAT too if required.
2571 zlib->idat->idat_list_tail = list;
2608 /* Check the stream of zlib compressed data in either idat (if given) or (if
2610 * a single chunk and a list of IDAT chunks.
2618 * In the case of IDAT chunks 'offset' should be 0.
2628 if (zlib_init(&zlib, file->idat, file->chunk, 0/*window bits*/, offset))
2767 * the per-file routine contains the chunk and IDAT control structures.
2843 * a chunk unless an IDAT is already instantiated (IDAT control structures
2849 else if (file->idat == NULL)
2850 file->alloc(file, 1/*IDAT*/);
2861 * this chunk have been copied. Notice that the IDAT chunks only make a
2932 * than IDAT this means that the zlib compressed data is fatally damanged and
2933 * the chunk will not be passed to libpng. For IDAT it means that the end of
2934 * the IDAT stream has not yet been reached and we must handle the next
2935 * (IDAT) chunk. If the LZ data in an IDAT stream cannot be read 'stop' must
3085 * routine (via process_chunk) instantiates a chunk or IDAT control structure
3087 * file::data_pos for the chunk after this one. For an IDAT chunk the whole
3088 * stream of IDATs will be read, until something other than an IDAT is
3258 /* This is the signature case; for IDAT and other chunks these values will
3273 * NOTE: at an IDAT any following IDAT chunks will also be read and the
3274 * next_ fields will refer to the chunk after the last IDAT.
3282 assert(file->idat == NULL);
3335 * notice that for the IDAT stream this must only happen once -
3336 * on the first IDAT - to get back to the start of the list and
3356 * and IDAT chunks which can be completely
3362 struct IDAT *idat = file->idat;
3364 assert(idat != NULL);
3366 /* Read an IDAT byte from the input stream of IDAT chunks.
3367 * Because the IDAT stream can be re-chunked this stream is
3368 * held in the struct IDAT members. The chunk members, in
3372 while (idat->idat_index >= idat->idat_length)
3375 struct IDAT_list *cur = idat->idat_cur;
3377 assert(idat->idat_index == idat->idat_length);
3381 if (++(idat->idat_count) >= cur->count)
3383 assert(idat->idat_count == cur->count);
3393 "read beyond end of IDAT");
3395 idat->idat_count = 0;
3396 idat->idat_cur = cur;
3399 idat->idat_index = 0;
3400 /* Zero length IDAT chunks are permitted, so the length
3403 idat->idat_length = cur->lengths[idat->idat_count];
3410 * the information is always the current IDAT chunk and the
3413 ++(idat->idat_index);
3460 /* The IDAT stream is written without a call to read_chunk
3465 * input stream stop writing IDAT chunks, otherwise continue.
3468 (file->idat->idat_index < file->idat->idat_length ||
3469 1+file->idat->idat_count < file->idat->idat_cur->count ||
3470 file->idat->idat_cur != file->idat->idat_list_tail))
3472 /* Write another IDAT chunk. Call rechunk_length to
3476 rechunk_length(file->idat, 0/*end*/);
3484 /* Entered at the end of a non-IDAT chunk and at the end of
3485 * the IDAT stream. The rewrite should have been cleared.
3497 if (file->idat == NULL)
3501 IDAT_end(&file->idat);
3520 /* Bundle the file and an uninitialized chunk and IDAT control structure
3521 * together to allow implementation of the chunk/IDAT allocate routine.
3527 struct IDAT idat;
3539 /* This just returns the (file*). The chunk and idat control structures
3554 assert(file->idat == NULL);
3555 IDAT_init(&control->idat, file);
3686 " of zlib issues founds for each compressed chunk and the IDAT stream in",
3713 " Use IDAT chunks sized <number>. If no number is given the the IDAT",
3718 " safe to copy across an IDAT size change. This is true of all chunks",
3814 " is reported by libpng at the start of the IDAT stream.",