Home | History | Annotate | Download | only in applypatch

Lines Matching refs: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
116 * extra file of data that is appended to chunk #1 after it is
117 * compressed (it must be a CHUNK_DEFLATE chunk). The same file must
138 size_t start; // offset of chunk in original image file
344 // use a normal chunk to take all the data up to the start of the
371 * contents of the file; various pointers in the output chunk array
410 // 'pos' is the offset of the start of a gzip chunk.
416 // create a normal chunk for the header.
431 // We must decompress this chunk in order to discover where it
469 // create a normal chunk for the footer
493 // Reallocate the list for every chunk; we expect the number of
501 // 'pos' is not the offset of the start of a gzip chunk, so scan
524 * Takes the uncompressed data stored in the chunk, compresses it
525 * using the zlib parameters stored in the chunk, and checks that it
527 * the chunk). Return 0 on success.
529 int TryReconstruction(ImageChunk* chunk, unsigned char* out) {
534 chunk->level, chunk->method, chunk->windowBits,
535 chunk->memLevel, chunk->strategy);
542 strm.avail_in = chunk->len;
543 strm.next_in = chunk->data;
545 ret = deflateInit2(&strm, chunk->level, chunk->method, chunk->windowBits,
546 chunk->memLevel, chunk->strategy);
553 if (memcmp(out, chunk->deflate_data+p, have) != 0) {
561 if (p != chunk->deflate_len) {
571 * strategy fields in the chunk to the encoding parameters needed to
574 int ReconstructDeflateChunk(ImageChunk* chunk) {
575 if (chunk->type != CHUNK_DEFLATE) {
576 printf("attempt to reconstruct non-deflate chunk\n");
585 for (chunk->level = 6; chunk->level <= 9; chunk->level += 3) {
586 chunk->windowBits = -15; // 32kb window; negative to indicate a raw stream.
587 chunk->memLevel = 8; // the default value.
588 chunk->method = Z_DEFLATED;
589 chunk->strategy = Z_DEFAULT_STRATEGY;
591 if (TryReconstruction(chunk, out) == 0) {
672 * Cause a gzip chunk to be treated as a normal chunk (ie, as a blob
687 * Return true if the data in the chunk is identical (including the
702 printf("unknown chunk type %d\n", a->type);
709 * a single chunk. (Such runs can be produced when deflate chunks are
719 // in_start is a normal chunk. Look for a run of normal chunks
720 // that constitute a solid block of data (ie, each chunk begins
733 printf("chunk %d is now %d\n", in_start, out);
743 // Merge chunks [in_start, in_end-1] into one chunk. Since the
744 // data member of each chunk is just a pointer into an in-memory
746 // output chunk has the first chunk's start location and data
747 // pointer, and length equal to the sum of the input chunk
777 printf("chunk %d: type %d start %d len %d\n",
848 // Verify that the source and target images have the same chunk
868 printf("source and target don't have same chunk "
869 "structure! (chunk %d)\n", i);
881 // Confirm that given the uncompressed chunk data in the target, we
883 // input target image. If this fails, treat the chunk as a normal
884 // non-deflated chunk.
886 printf("failed to reconstruct target deflate chunk %d [%s]; "
930 // chunk lists, so do the merging in both the source and target
941 // Compute bsdiff patches for each chunk's data (the uncompressed
961 printf(" using %d bytes of bonus data for chunk %d\n", bonus_size, i);
1006 printf("chunk %3d: normal (%10d, %10d) %10d\n", i,
1015 printf("chunk %3d: deflate (%10d, %10d) %10d %s\n", i,
1032 printf("chunk %3d: raw (%10d, %10d)\n", i,
1040 // Append each chunk's bsdiff patch, in order.