Lines Matching defs:idat
607 /* Information about a sequence of IDAT chunks, the chunks have been re-synced
666 /* Insert a new, malloc'ed, block of IDAT information buffers, this
718 /* PUBLIC GLOBAL VARIABLES: USED INTERNALLY BY IDAT READ CODE */
719 struct IDAT_list idat_cache; /* Cache of file IDAT information buffers */
721 * structure to avoid reallocation between IDAT streams.
748 global->idat_max = 0; /* no re-chunking of IDAT */
832 struct IDAT;
887 # define STATE_CHUNKS 1 /* Non-IDAT chunks are being written */
888 # define STATE_IDAT 2 /* An IDAT stream is being written */
894 struct IDAT * idat;
896 /* Interface to allocate a new chunk or IDAT control structure. The result
902 void (*alloc)(struct file*,int idat);
903 /* idat: allocate IDAT not chunk */
986 static void IDAT_end(struct IDAT **);
993 /* If either of the chunk pointers are set end them here, the IDAT structure
996 if (file->idat != NULL)
997 IDAT_end(&file->idat);
1053 file->idat = NULL;
1139 * only happens with IDAT where libpng reads the header then jumps around
1141 * we are at the start of the IDAT (i.e. no IDAT data has yet been written.)
1145 * IDAT ERR status code read-errno write-errno message file
1155 type = current_type(file, code); /* Gropes in struct chunk and IDAT */
1163 else /* magic: an IDAT header, produces bogons for too many IDATs */
1536 * This structure is instantiated for each chunk, except for the IDAT chunks
1538 * IDAT chunks (see the IDAT control structure below).
1546 /* PUBLIC IDAT INFORMATION: SET BY THE ZLIB CODE */
1673 assert(chunk != NULL && file->idat == NULL);
1702 assert(chunk != NULL && file->idat == NULL);
1749 /* IDAT READ/WRITE CONTROL STRUCTURE */
1750 struct IDAT
1756 /* PROTECTED IDAT INFORMATION: SET BY THE IDAT READ CODE */
1757 struct IDAT_list *idat_list_head; /* START of the list of IDAT information */
1758 struct IDAT_list *idat_list_tail; /* *END* of the list of IDAT information */
1760 /* PROTECTED IDAT INFORMATION: USED BY THE IDAT WRITE CODE */
1768 * one IDAT sequence (i.e. MNG is not supported).
1772 IDAT_end(struct IDAT **idat_var)
1774 struct IDAT *idat = *idat_var;
1775 struct file *file = idat->file;
1779 CLEAR(*idat);
1784 /* Regardless of why the IDAT was killed set the state back to CHUNKS (it may
1792 IDAT_init(struct IDAT * const idat, struct file * const file)
1793 /* When the chunk is png_IDAT instantiate an IDAT control structure in place
1794 * of a chunk control structure. The IDAT will instantiate a chunk control
1801 assert(file->idat == NULL);
1803 CLEAR(*idat);
1805 idat->file = file;
1806 idat->global = file->global;
1811 idat->global->idat_cache.count = 0;
1812 idat->idat_list_head = idat->idat_list_tail = &idat->global->idat_cache;
1823 file->idat = idat;
1827 rechunk_length(struct IDAT *idat)
1828 /* Return the length for the next IDAT chunk, taking into account
1832 png_uint_32 len = idat->global->idat_max;
1839 if (idat->idat_index == 0) /* at the new chunk (first time) */
1840 return idat->idat_length; /* use the cache */
1845 cur = idat->idat_cur;
1846 count = idat->idat_count;
1848 assert(idat->idat_index == idat->idat_length &&
1849 idat->idat_length == cur->lengths[count]);
1856 assert(cur != idat->idat_list_tail);
1867 png_uint_32 have = idat->idat_length - idat->idat_index;
1871 struct IDAT_list *cur = idat->idat_cur;
1872 unsigned int j = idat->idat_count+1; /* the next IDAT in the list */
1893 if (cur == idat->idat_list_tail)
1909 /* Process the IDAT stream, this is the more complex than the preceding
1910 * cases because the compressed data is spread across multiple IDAT chunks
1915 * be written. It does this until the last IDAT chunk is passed in, then it
1920 * The caller must have an instantiated (IDAT) control structure and it must
1921 * have extent over the whole read of the IDAT stream. For a PNG this means
1927 assert(file->idat != NULL && file->chunk != NULL);
1929 /* We need to first check the entire sequence of IDAT chunks to ensure the
1938 list = file->idat->idat_list_tail;
1949 file->idat->idat_list_tail = list;
1952 /* And fill in the next IDAT information buffer. */
1961 /* This is the final IDAT chunk, so run the tests to check for the too far
1970 struct IDAT *idat;
1973 /* The IDAT stream was successfully uncompressed; see whether it
1983 stop(file, LIBPNG_ERROR_CODE, "IDAT: uncompressed data too small");
1985 /* Return the stream to the start of the first IDAT chunk; the length
1991 idat = file->idat;
1992 idat->idat_cur = idat->idat_list_head;
1993 idat->idat_length = idat->idat_cur->lengths[0];
1994 idat->idat_count = 0; /* Count of chunks read in current list */
1995 idat->idat_index = 0; /* Index into chunk data */
1997 /* Update the chunk length to the correct value for the IDAT chunk: */
1998 file->chunk->chunk_length = rechunk_length(idat);
2000 /* Change the state to writing IDAT chunks */
2006 else /* Failure to decompress the IDAT stream; give up. */
2007 stop(file, ZLIB_ERROR_CODE, "could not uncompress IDAT");
2014 struct IDAT * idat; /* NOTE: May be NULL */
2119 * IDAT reason flevel file-bits ok-bits compressed uncompressed file
2135 /* This is a zlib read error; the chunk will be skipped. For an IDAT
2140 * IDAT SKP flevel file-bits z-rc compressed message file
2196 zlib_init(struct zlib *zlib, struct IDAT *idat, struct chunk *chunk,
2202 zlib->idat = idat;
2491 /* Like zlib_advance but also handles a stream of IDAT chunks. */
2498 * IDAT specific check below.
2502 if (zlib->idat != NULL)
2504 struct IDAT_list *list = zlib->idat->idat_list_head;
2505 struct IDAT_list *last = zlib->idat->idat_list_tail;
2509 * IDAT it should be 0:
2514 * positioned at the start of the first IDAT chunk data.
2525 if (skip > 0) /* Skip CRC and next IDAT header */
2568 * length of the last IDAT too if required.
2572 zlib->idat->idat_list_tail = list;
2609 /* Check the stream of zlib compressed data in either idat (if given) or (if
2611 * a single chunk and a list of IDAT chunks.
2619 * In the case of IDAT chunks 'offset' should be 0.
2629 if (zlib_init(&zlib, file->idat, file->chunk, 0/*window bits*/, offset))
2768 * the per-file routine contains the chunk and IDAT control structures.
2844 * a chunk unless an IDAT is already instantiated (IDAT control structures
2850 else if (file->idat == NULL)
2851 file->alloc(file, 1/*IDAT*/);
2862 * this chunk have been copied. Notice that the IDAT chunks only make a
2933 * than IDAT this means that the zlib compressed data is fatally damanged and
2934 * the chunk will not be passed to libpng. For IDAT it means that the end of
2935 * the IDAT stream has not yet been reached and we must handle the next
2936 * (IDAT) chunk. If the LZ data in an IDAT stream cannot be read 'stop' must
3086 * routine (via process_chunk) instantiates a chunk or IDAT control structure
3088 * file::data_pos for the chunk after this one. For an IDAT chunk the whole
3089 * stream of IDATs will be read, until something other than an IDAT is
3259 /* This is the signature case; for IDAT and other chunks these values will
3274 * NOTE: at an IDAT any following IDAT chunks will also be read and the
3275 * next_ fields will refer to the chunk after the last IDAT.
3283 assert(file->idat == NULL);
3336 * notice that for the IDAT stream this must only happen once -
3337 * on the first IDAT - to get back to the start of the list and
3357 * and IDAT chunks which can be completely
3363 struct IDAT *idat = file->idat;
3365 assert(idat != NULL);
3367 /* Read an IDAT byte from the input stream of IDAT chunks.
3368 * Because the IDAT stream can be re-chunked this stream is
3369 * held in the struct IDAT members. The chunk members, in
3373 while (idat->idat_index >= idat->idat_length)
3376 struct IDAT_list *cur = idat->idat_cur;
3378 assert(idat->idat_index == idat->idat_length);
3382 if (++(idat->idat_count) >= cur->count)
3384 assert(idat->idat_count == cur->count);
3394 "read beyond end of IDAT");
3396 idat->idat_count = 0;
3397 idat->idat_cur = cur;
3400 idat->idat_index = 0;
3401 /* Zero length IDAT chunks are permitted, so the length
3404 idat->idat_length = cur->lengths[idat->idat_count];
3411 * the information is always the current IDAT chunk and the
3414 ++(idat->idat_index);
3461 /* The IDAT stream is written without a call to read_chunk
3466 * input stream stop writing IDAT chunks, otherwise continue.
3469 (file->idat->idat_index < file->idat->idat_length ||
3470 1+file->idat->idat_count < file->idat->idat_cur->count ||
3471 file->idat->idat_cur != file->idat->idat_list_tail))
3473 /* Write another IDAT chunk. Call rechunk_length to
3476 length = chunk->chunk_length = rechunk_length(file->idat);
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.",