Home | History | Annotate | Download | only in tools

Lines Matching defs:idat

601 /* Information about a sequence of IDAT chunks, the chunks have been re-synced
660 /* Insert a new, malloc'ed, block of IDAT information buffers, this
712 /* PUBLIC GLOBAL VARIABLES: USED INTERNALLY BY IDAT READ CODE */
713 struct IDAT_list idat_cache; /* Cache of file IDAT information buffers */
715 * structure to avoid reallocation between IDAT streams.
742 global->idat_max = 0; /* no re-chunking of IDAT */
826 struct IDAT;
881 # define STATE_CHUNKS 1 /* Non-IDAT chunks are being written */
882 # define STATE_IDAT 2 /* An IDAT stream is being written */
888 struct IDAT * idat;
890 /* Interface to allocate a new chunk or IDAT control structure. The result
896 void (*alloc)(struct file*,int idat);
897 /* idat: allocate IDAT not chunk */
980 static void IDAT_end(struct IDAT **);
987 /* If either of the chunk pointers are set end them here, the IDAT structure
990 if (file->idat != NULL)
991 IDAT_end(&file->idat);
1047 file->idat = NULL;
1133 * only happens with IDAT where libpng reads the header then jumps around
1135 * we are at the start of the IDAT (i.e. no IDAT data has yet been written.)
1139 * IDAT ERR status code read-errno write-errno message file
1149 type = current_type(file, code); /* Gropes in struct chunk and IDAT */
1157 else /* magic: an IDAT header, produces bogons for too many IDATs */
1530 * This structure is instantiated for each chunk, except for the IDAT chunks
1532 * IDAT chunks (see the IDAT control structure below).
1540 /* PUBLIC IDAT INFORMATION: SET BY THE ZLIB CODE */
1667 assert(chunk != NULL && file->idat == NULL);
1696 assert(chunk != NULL && file->idat == NULL);
1743 /* IDAT READ/WRITE CONTROL STRUCTURE */
1744 struct IDAT
1750 /* PROTECTED IDAT INFORMATION: SET BY THE IDAT READ CODE */
1751 struct IDAT_list *idat_list_head; /* START of the list of IDAT information */
1752 struct IDAT_list *idat_list_tail; /* *END* of the list of IDAT information */
1754 /* PROTECTED IDAT INFORMATION: USED BY THE IDAT WRITE CODE */
1762 * one IDAT sequence (i.e. MNG is not supported).
1766 IDAT_end(struct IDAT **idat_var)
1768 struct IDAT *idat = *idat_var;
1769 struct file *file = idat->file;
1773 CLEAR(*idat);
1778 /* Regardless of why the IDAT was killed set the state back to CHUNKS (it may
1786 IDAT_init(struct IDAT * const idat, struct file * const file)
1787 /* When the chunk is png_IDAT instantiate an IDAT control structure in place
1788 * of a chunk control structure. The IDAT will instantiate a chunk control
1795 assert(file->idat == NULL);
1797 CLEAR(*idat);
1799 idat->file = file;
1800 idat->global = file->global;
1805 idat->global->idat_cache.count = 0;
1806 idat->idat_list_head = idat->idat_list_tail = &idat->global->idat_cache;
1817 file->idat = idat;
1821 rechunk_length(struct IDAT *idat)
1822 /* Return the length for the next IDAT chunk, taking into account
1826 png_uint_32 len = idat->global->idat_max;
1833 if (idat->idat_index == 0) /* at the new chunk (first time) */
1834 return idat->idat_length; /* use the cache */
1839 cur = idat->idat_cur;
1840 count = idat->idat_count;
1842 assert(idat->idat_index == idat->idat_length &&
1843 idat->idat_length == cur->lengths[count]);
1850 assert(cur != idat->idat_list_tail);
1861 png_uint_32 have = idat->idat_length - idat->idat_index;
1865 struct IDAT_list *cur = idat->idat_cur;
1866 unsigned int j = idat->idat_count+1; /* the next IDAT in the list */
1887 if (cur == idat->idat_list_tail)
1903 /* Process the IDAT stream, this is the more complex than the preceding
1904 * cases because the compressed data is spread across multiple IDAT chunks
1909 * be written. It does this until the last IDAT chunk is passed in, then it
1914 * The caller must have an instantiated (IDAT) control structure and it must
1915 * have extent over the whole read of the IDAT stream. For a PNG this means
1921 assert(file->idat != NULL && file->chunk != NULL);
1923 /* We need to first check the entire sequence of IDAT chunks to ensure the
1932 list = file->idat->idat_list_tail;
1943 file->idat->idat_list_tail = list;
1946 /* And fill in the next IDAT information buffer. */
1955 /* This is the final IDAT chunk, so run the tests to check for the too far
1964 struct IDAT *idat;
1967 /* The IDAT stream was successfully uncompressed; see whether it
1977 stop(file, LIBPNG_ERROR_CODE, "IDAT: uncompressed data too small");
1979 /* Return the stream to the start of the first IDAT chunk; the length
1985 idat = file->idat;
1986 idat->idat_cur = idat->idat_list_head;
1987 idat->idat_length = idat->idat_cur->lengths[0];
1988 idat->idat_count = 0; /* Count of chunks read in current list */
1989 idat->idat_index = 0; /* Index into chunk data */
1991 /* Update the chunk length to the correct value for the IDAT chunk: */
1992 file->chunk->chunk_length = rechunk_length(idat);
1994 /* Change the state to writing IDAT chunks */
2000 else /* Failure to decompress the IDAT stream; give up. */
2001 stop(file, ZLIB_ERROR_CODE, "could not uncompress IDAT");
2008 struct IDAT * idat; /* NOTE: May be NULL */
2113 * IDAT reason flevel file-bits ok-bits compressed uncompressed file
2129 /* This is a zlib read error; the chunk will be skipped. For an IDAT
2134 * IDAT SKP flevel file-bits z-rc compressed message file
2190 zlib_init(struct zlib *zlib, struct IDAT *idat, struct chunk *chunk,
2196 zlib->idat = idat;
2484 /* Like zlib_advance but also handles a stream of IDAT chunks. */
2491 * IDAT specific check below.
2495 if (zlib->idat != NULL)
2497 struct IDAT_list *list = zlib->idat->idat_list_head;
2498 struct IDAT_list *last = zlib->idat->idat_list_tail;
2502 * IDAT it should be 0:
2507 * positioned at the start of the first IDAT chunk data.
2518 if (skip > 0) /* Skip CRC and next IDAT header */
2561 * length of the last IDAT too if required.
2565 zlib->idat->idat_list_tail = list;
2602 /* Check the stream of zlib compressed data in either idat (if given) or (if
2604 * a single chunk and a list of IDAT chunks.
2612 * In the case of IDAT chunks 'offset' should be 0.
2622 if (zlib_init(&zlib, file->idat, file->chunk, 0/*window bits*/, offset))
2761 * the per-file routine contains the chunk and IDAT control structures.
2837 * a chunk unless an IDAT is already instantiated (IDAT control structures
2843 else if (file->idat == NULL)
2844 file->alloc(file, 1/*IDAT*/);
2855 * this chunk have been copied. Notice that the IDAT chunks only make a
2926 * than IDAT this means that the zlib compressed data is fatally damanged and
2927 * the chunk will not be passed to libpng. For IDAT it means that the end of
2928 * the IDAT stream has not yet been reached and we must handle the next
2929 * (IDAT) chunk. If the LZ data in an IDAT stream cannot be read 'stop' must
3079 * routine (via process_chunk) instantiates a chunk or IDAT control structure
3081 * file::data_pos for the chunk after this one. For an IDAT chunk the whole
3082 * stream of IDATs will be read, until something other than an IDAT is
3252 /* This is the signature case; for IDAT and other chunks these values will
3267 * NOTE: at an IDAT any following IDAT chunks will also be read and the
3268 * next_ fields will refer to the chunk after the last IDAT.
3276 assert(file->idat == NULL);
3329 * notice that for the IDAT stream this must only happen once -
3330 * on the first IDAT - to get back to the start of the list and
3350 * and IDAT chunks which can be completely
3356 struct IDAT *idat = file->idat;
3358 assert(idat != NULL);
3360 /* Read an IDAT byte from the input stream of IDAT chunks.
3361 * Because the IDAT stream can be re-chunked this stream is
3362 * held in the struct IDAT members. The chunk members, in
3366 while (idat->idat_index >= idat->idat_length)
3369 struct IDAT_list *cur = idat->idat_cur;
3371 assert(idat->idat_index == idat->idat_length);
3375 if (++(idat->idat_count) >= cur->count)
3377 assert(idat->idat_count == cur->count);
3387 "read beyond end of IDAT");
3389 idat->idat_count = 0;
3390 idat->idat_cur = cur;
3393 idat->idat_index = 0;
3394 /* Zero length IDAT chunks are permitted, so the length
3397 idat->idat_length = cur->lengths[idat->idat_count];
3404 * the information is always the current IDAT chunk and the
3407 ++(idat->idat_index);
3454 /* The IDAT stream is written without a call to read_chunk
3459 * input stream stop writing IDAT chunks, otherwise continue.
3462 (file->idat->idat_index < file->idat->idat_length ||
3463 1+file->idat->idat_count < file->idat->idat_cur->count ||
3464 file->idat->idat_cur != file->idat->idat_list_tail))
3466 /* Write another IDAT chunk. Call rechunk_length to
3469 length = chunk->chunk_length = rechunk_length(file->idat);
3477 /* Entered at the end of a non-IDAT chunk and at the end of
3478 * the IDAT stream. The rewrite should have been cleared.
3490 if (file->idat == NULL)
3494 IDAT_end(&file->idat);
3513 /* Bundle the file and an uninitialized chunk and IDAT control structure
3514 * together to allow implementation of the chunk/IDAT allocate routine.
3520 struct IDAT idat;
3532 /* This just returns the (file*). The chunk and idat control structures
3547 assert(file->idat == NULL);
3548 IDAT_init(&control->idat, file);
3682 " of zlib issues founds for each compressed chunk and the IDAT stream in",
3709 " Use IDAT chunks sized <number>. If no number is given the the IDAT",
3714 " safe to copy across an IDAT size change. This is true of all chunks",
3810 " is reported by libpng at the start of the IDAT stream.",