diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2007-02-13 02:44:36 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2007-02-13 02:44:36 +0000 |
commit | 4be58a9a9ab199ef2b3765f57e649398e8dd5890 (patch) | |
tree | 24a3afe267a091aff093102eb230a82936b82990 /xdelta3/xdelta3.c | |
parent | 792f7c0cf9cb987e3d2a0501e1b228836ec798e7 (diff) |
Adds xd3_flags for setting compression level in xd3_encode_memory().
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r-- | xdelta3/xdelta3.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index b3fd2ef..32dc8b0 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -94,7 +94,7 @@ | |||
94 | challenge. Search in this file for "black magic", a heuristic. | 94 | challenge. Search in this file for "black magic", a heuristic. |
95 | 95 | ||
96 | 3. STREAM ALIGNMENT. Stream alignment is needed to compress large | 96 | 3. STREAM ALIGNMENT. Stream alignment is needed to compress large |
97 | inputs in constant space. TODO: redocument | 97 | inputs in constant space. See xd3_srcwin_move_point(). |
98 | 98 | ||
99 | 4. WINDOW SELECTION. When the IOPT buffer flushes, in the first call | 99 | 4. WINDOW SELECTION. When the IOPT buffer flushes, in the first call |
100 | to xd3_iopt_finish_encoding containing any kind of copy instruction, | 100 | to xd3_iopt_finish_encoding containing any kind of copy instruction, |
@@ -779,7 +779,7 @@ static const xd3_sec_type djw_sec_type = | |||
779 | * allowing to vary the distribution of single- and | 779 | * allowing to vary the distribution of single- and |
780 | * double-instructions and change the number of near and same copy | 780 | * double-instructions and change the number of near and same copy |
781 | * modes. More exotic tables are only possible by extending this | 781 | * modes. More exotic tables are only possible by extending this |
782 | * code. TODO: experiment with a double-copy instruction. | 782 | * code. |
783 | * | 783 | * |
784 | * For performance reasons, both the parametrized and non-parametrized | 784 | * For performance reasons, both the parametrized and non-parametrized |
785 | * versions of xd3_choose_instruction remain. The parametrized | 785 | * versions of xd3_choose_instruction remain. The parametrized |
@@ -2543,6 +2543,28 @@ xd3_config_stream(xd3_stream *stream, | |||
2543 | return XD3_INTERNAL; | 2543 | return XD3_INTERNAL; |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | if (config->smatch_cfg == XD3_SMATCH_DEFAULT && | ||
2547 | (stream->flags & XD3_COMPLEVEL_MASK) != 0) | ||
2548 | { | ||
2549 | int level = (stream->flags & XD3_COMPLEVEL_MASK) >> XD3_COMPLEVEL_SHIFT; | ||
2550 | |||
2551 | switch (level) | ||
2552 | { | ||
2553 | case 1: case 2: | ||
2554 | IF_BUILD_FASTEST(*smatcher = __smatcher_fastest; | ||
2555 | break;) | ||
2556 | case 3: case 4: case 5: | ||
2557 | IF_BUILD_FAST(*smatcher = __smatcher_fast; | ||
2558 | break;) | ||
2559 | case 6: | ||
2560 | IF_BUILD_DEFAULT(*smatcher = __smatcher_default; | ||
2561 | break;) | ||
2562 | default: | ||
2563 | IF_BUILD_SLOW(*smatcher = __smatcher_slow; | ||
2564 | break;) | ||
2565 | } | ||
2566 | } | ||
2567 | |||
2546 | return 0; | 2568 | return 0; |
2547 | } | 2569 | } |
2548 | 2570 | ||
@@ -3520,7 +3542,7 @@ xd3_encode_init (xd3_stream *stream) | |||
3520 | * first call to string_match--that way identical or short inputs require no table | 3542 | * first call to string_match--that way identical or short inputs require no table |
3521 | * allocation. */ | 3543 | * allocation. */ |
3522 | 3544 | ||
3523 | // TODO: experiments have to be done!!! | 3545 | /* TODO: need to experiment w/ XD3_DEFAULT_SPREVSZ and large has functions */ |
3524 | if (large_comp) | 3546 | if (large_comp) |
3525 | { | 3547 | { |
3526 | usize_t hash_values = (stream->srcwin_maxsz / stream->smatcher.large_step); | 3548 | usize_t hash_values = (stream->srcwin_maxsz / stream->smatcher.large_step); |
@@ -3532,8 +3554,7 @@ xd3_encode_init (xd3_stream *stream) | |||
3532 | 3554 | ||
3533 | if (small_comp) | 3555 | if (small_comp) |
3534 | { | 3556 | { |
3535 | /* Hard-coded, keeps table small because small matches become inefficient. | 3557 | /* Hard-coded, keeps table small because small matches become inefficient. */ |
3536 | * TODO: verify this stuff. */ | ||
3537 | usize_t hash_values = min(stream->winsize, XD3_DEFAULT_SPREVSZ); | 3558 | usize_t hash_values = min(stream->winsize, XD3_DEFAULT_SPREVSZ); |
3538 | 3559 | ||
3539 | xd3_size_hashtable (stream, | 3560 | xd3_size_hashtable (stream, |
@@ -3931,7 +3952,7 @@ xd3_process_memory (int is_encode, | |||
3931 | 3952 | ||
3932 | if (is_encode) | 3953 | if (is_encode) |
3933 | { | 3954 | { |
3934 | /* TODO: for large inputs, limit window size ... */ | 3955 | /* TODO: for large inputs, limit window size, need to select a default ... */ |
3935 | config.srcwin_maxsz = source_size; | 3956 | config.srcwin_maxsz = source_size; |
3936 | config.winsize = min(input_size, (usize_t) (1<<20)); | 3957 | config.winsize = min(input_size, (usize_t) (1<<20)); |
3937 | } | 3958 | } |
@@ -4117,7 +4138,8 @@ xd3_source_cksum_offset(xd3_stream *stream, usize_t low) | |||
4117 | return low; | 4138 | return low; |
4118 | } | 4139 | } |
4119 | 4140 | ||
4120 | // This should not be >= because srcwin_cksum_pos is the next position to index | 4141 | /* This should not be >= because srcwin_cksum_pos is the next |
4142 | * position to index. */ | ||
4121 | if (low > sr) { | 4143 | if (low > sr) { |
4122 | return (--s0 << 32) | low; | 4144 | return (--s0 << 32) | low; |
4123 | } | 4145 | } |
@@ -4564,8 +4586,6 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4564 | usize_t total = stream->match_fwd + stream->match_back; | 4586 | usize_t total = stream->match_fwd + stream->match_back; |
4565 | 4587 | ||
4566 | /* Correct the variables to remove match_back from the equation. */ | 4588 | /* Correct the variables to remove match_back from the equation. */ |
4567 | // IT'S A BUG! | ||
4568 | |||
4569 | usize_t target_position = stream->input_position - stream->match_back; | 4589 | usize_t target_position = stream->input_position - stream->match_back; |
4570 | usize_t match_length = stream->match_back + stream->match_fwd; | 4590 | usize_t match_length = stream->match_back + stream->match_fwd; |
4571 | xoff_t match_position = stream->match_srcpos - stream->match_back; | 4591 | xoff_t match_position = stream->match_srcpos - stream->match_back; |
@@ -4589,13 +4609,13 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4589 | 4609 | ||
4590 | if (match_end > stream->match_maxaddr) | 4610 | if (match_end > stream->match_maxaddr) |
4591 | { | 4611 | { |
4592 | // Note: per-window | 4612 | /* Note: per-window */ |
4593 | stream->match_maxaddr = match_end; | 4613 | stream->match_maxaddr = match_end; |
4594 | } | 4614 | } |
4595 | 4615 | ||
4596 | if (match_end > stream->maxsrcaddr) | 4616 | if (match_end > stream->maxsrcaddr) |
4597 | { | 4617 | { |
4598 | // Note: across windows | 4618 | /* Note: across windows */ |
4599 | stream->maxsrcaddr = match_end; | 4619 | stream->maxsrcaddr = match_end; |
4600 | } | 4620 | } |
4601 | 4621 | ||
@@ -4927,7 +4947,7 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream) | |||
4927 | int run_l; | 4947 | int run_l; |
4928 | int ret; | 4948 | int ret; |
4929 | usize_t match_length; | 4949 | usize_t match_length; |
4930 | usize_t match_offset; // Note: "may be unused" warnings are bogus (due to min_match test) | 4950 | usize_t match_offset; /* "may be unused" warnings are bogus (due to min_match test) */ |
4931 | usize_t next_move_point; | 4951 | usize_t next_move_point; |
4932 | 4952 | ||
4933 | /* If there will be no compression due to settings or short input, skip it entirely. */ | 4953 | /* If there will be no compression due to settings or short input, skip it entirely. */ |