Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: src/liblzma/simple/simple_coder.c

Issue 12568011: Update XZ Utils to 5.0.4 (third_party) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xz/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /////////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////////
2 // 2 //
3 /// \file simple_coder.c 3 /// \file simple_coder.c
4 /// \brief Wrapper for simple filters 4 /// \brief Wrapper for simple filters
5 /// 5 ///
6 /// Simple filters don't change the size of the data i.e. number of bytes 6 /// Simple filters don't change the size of the data i.e. number of bytes
7 /// in equals the number of bytes out. 7 /// in equals the number of bytes out.
8 // 8 //
9 // Author: Lasse Collin 9 // Author: Lasse Collin
10 // 10 //
(...skipping 17 matching lines...) Expand all
28 if (coder->next.code == NULL) { 28 if (coder->next.code == NULL) {
29 lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size); 29 lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size);
30 30
31 // Check if end of stream was reached. 31 // Check if end of stream was reached.
32 if (coder->is_encoder && action == LZMA_FINISH 32 if (coder->is_encoder && action == LZMA_FINISH
33 && *in_pos == in_size) 33 && *in_pos == in_size)
34 coder->end_was_reached = true; 34 coder->end_was_reached = true;
35 35
36 } else { 36 } else {
37 // Call the next coder in the chain to provide us some data. 37 // Call the next coder in the chain to provide us some data.
38 // We don't care about uncompressed_size here, because
39 // the next filter in the chain will do it for us (since
40 // we don't change the size of the data).
41 const lzma_ret ret = coder->next.code( 38 const lzma_ret ret = coder->next.code(
42 coder->next.coder, allocator, 39 coder->next.coder, allocator,
43 in, in_pos, in_size, 40 in, in_pos, in_size,
44 out, out_pos, out_size, action); 41 out, out_pos, out_size, action);
45 42
46 if (ret == LZMA_STREAM_END) { 43 if (ret == LZMA_STREAM_END) {
47 assert(!coder->is_encoder 44 assert(!coder->is_encoder
48 || action == LZMA_FINISH); 45 || action == LZMA_FINISH);
49 coder->end_was_reached = true; 46 coder->end_was_reached = true;
50 47
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 100
104 assert(!coder->end_was_reached); 101 assert(!coder->end_was_reached);
105 102
106 // If there is more output space left than there is unfiltered data 103 // If there is more output space left than there is unfiltered data
107 // in coder->buffer[], flush coder->buffer[] to out[], and copy/code 104 // in coder->buffer[], flush coder->buffer[] to out[], and copy/code
108 // more data to out[] hopefully filling it completely. Then filter 105 // more data to out[] hopefully filling it completely. Then filter
109 // the data in out[]. This step is where most of the data gets 106 // the data in out[]. This step is where most of the data gets
110 // filtered if the buffer sizes used by the application are reasonable. 107 // filtered if the buffer sizes used by the application are reasonable.
111 const size_t out_avail = out_size - *out_pos; 108 const size_t out_avail = out_size - *out_pos;
112 const size_t buf_avail = coder->size - coder->pos; 109 const size_t buf_avail = coder->size - coder->pos;
113 » if (out_avail > buf_avail) { 110 » if (out_avail > buf_avail || buf_avail == 0) {
114 // Store the old position so that we know from which byte 111 // Store the old position so that we know from which byte
115 // to start filtering. 112 // to start filtering.
116 const size_t out_start = *out_pos; 113 const size_t out_start = *out_pos;
117 114
118 // Flush data from coder->buffer[] to out[], but don't reset 115 // Flush data from coder->buffer[] to out[], but don't reset
119 // coder->pos and coder->size yet. This way the coder can be 116 // coder->pos and coder->size yet. This way the coder can be
120 // restarted if the next filter in the chain returns e.g. 117 // restarted if the next filter in the chain returns e.g.
121 // LZMA_MEM_ERROR. 118 // LZMA_MEM_ERROR.
122 memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail); 119 memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail);
123 *out_pos += buf_avail; 120 *out_pos += buf_avail;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // Reset variables. 268 // Reset variables.
272 next->coder->is_encoder = is_encoder; 269 next->coder->is_encoder = is_encoder;
273 next->coder->end_was_reached = false; 270 next->coder->end_was_reached = false;
274 next->coder->pos = 0; 271 next->coder->pos = 0;
275 next->coder->filtered = 0; 272 next->coder->filtered = 0;
276 next->coder->size = 0; 273 next->coder->size = 0;
277 274
278 return lzma_next_filter_init( 275 return lzma_next_filter_init(
279 &next->coder->next, allocator, filters + 1); 276 &next->coder->next, allocator, filters + 1);
280 } 277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698