Home | History | Annotate | Download | only in applypatch

Lines Matching full:chunk

41  * An "imgdiff" patch consists of a header describing the chunk structure
43 * chunks, followed by N bsdiff patches, one per chunk.
46 * same "chunk" structure: that is, the same number of gzipped and normal
59 * occur spuriously within a normal chunk to be a problem.)
65 * chunk count (4)
66 * for each chunk:
67 * chunk type (4) [CHUNK_{NORMAL, GZIP, DEFLATE, RAW}]
68 * if chunk type == CHUNK_NORMAL:
72 * if chunk type == CHUNK_GZIP: (version 1 only)
86 * if chunk type == CHUNK_DEFLATE: (version 2 only)
97 * if chunk type == RAW: (version 2 only)
102 * specify the section of the input image that comprises this chunk,
109 * compressed data to create the output chunk (so that header contents
112 * After the header there are 'chunk count' bsdiff patches; the offset
130 size_t start; // offset of chunk in original image file
336 // use a normal chunk to take all the data up to the start of the
363 * contents of the file; various pointers in the output chunk array
402 // 'pos' is the offset of the start of a gzip chunk.
408 // create a normal chunk for the header.
423 // We must decompress this chunk in order to discover where it
461 // create a normal chunk for the footer
485 // Reallocate the list for every chunk; we expect the number of
493 // 'pos' is not the offset of the start of a gzip chunk, so scan
516 * Takes the uncompressed data stored in the chunk, compresses it
517 * using the zlib parameters stored in the chunk, and checks that it
519 * the chunk). Return 0 on success.
521 int TryReconstruction(ImageChunk* chunk, unsigned char* out) {
526 chunk->level, chunk->method, chunk->windowBits,
527 chunk->memLevel, chunk->strategy);
534 strm.avail_in = chunk->len;
535 strm.next_in = chunk->data;
537 ret = deflateInit2(&strm, chunk->level, chunk->method, chunk->windowBits,
538 chunk->memLevel, chunk->strategy);
545 if (memcmp(out, chunk->deflate_data+p, have) != 0) {
553 if (p != chunk->deflate_len) {
563 * strategy fields in the chunk to the encoding parameters needed to
566 int ReconstructDeflateChunk(ImageChunk* chunk) {
567 if (chunk->type != CHUNK_DEFLATE) {
568 printf("attempt to reconstruct non-deflate chunk\n");
577 for (chunk->level = 6; chunk->level <= 9; chunk->level += 3) {
578 chunk->windowBits = -15; // 32kb window; negative to indicate a raw stream.
579 chunk->memLevel = 8; // the default value.
580 chunk->method = Z_DEFLATED;
581 chunk->strategy = Z_DEFAULT_STRATEGY;
583 if (TryReconstruction(chunk, out) == 0) {
664 * Cause a gzip chunk to be treated as a normal chunk (ie, as a blob
679 * Return true if the data in the chunk is identical (including the
694 printf("unknown chunk type %d\n", a->type);
701 * a single chunk. (Such runs can be produced when deflate chunks are
711 // in_start is a normal chunk. Look for a run of normal chunks
712 // that constitute a solid block of data (ie, each chunk begins
725 printf("chunk %d is now %d\n", in_start, out);
735 // Merge chunks [in_start, in_end-1] into one chunk. Since the
736 // data member of each chunk is just a pointer into an in-memory
738 // output chunk has the first chunk's start location and data
739 // pointer, and length equal to the sum of the input chunk
769 printf("chunk %d: type %d start %d len %d\n",
816 // Verify that the source and target images have the same chunk
836 printf("source and target don't have same chunk "
837 "structure! (chunk %d)\n", i);
849 // Confirm that given the uncompressed chunk data in the target, we
851 // input target image. If this fails, treat the chunk as a normal
852 // non-deflated chunk.
854 printf("failed to reconstruct target deflate chunk %d [%s]; "
898 // chunk lists, so do the merging in both the source and target
909 // Compute bsdiff patches for each chunk's data (the uncompressed
965 printf("chunk %3d: normal (%10d, %10d) %10d\n", i,
974 printf("chunk %3d: deflate (%10d, %10d) %10d %s\n", i,
991 printf("chunk %3d: raw (%10d, %10d)\n", i,
999 // Append each chunk's bsdiff patch, in order.