lzma_encoder_optimum_fast.c | lzma_encoder_optimum_fast.c | |||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
/// \file lzma_encoder_optimum_fast.c | /// \file lzma_encoder_optimum_fast.c | |||
// | // | |||
// Author: Igor Pavlov | // Author: Igor Pavlov | |||
// | // | |||
// This file has been put into the public domain. | // This file has been put into the public domain. | |||
// You can do whatever you want with this file. | // You can do whatever you want with this file. | |||
// | // | |||
/////////////////////////////////////////////////////////////////////////// //// | /////////////////////////////////////////////////////////////////////////// //// | |||
#include "lzma_encoder_private.h" | #include "lzma_encoder_private.h" | |||
#include "memcmplen.h" | ||||
#define change_pair(small_dist, big_dist) \ | #define change_pair(small_dist, big_dist) \ | |||
(((big_dist) >> 7) > (small_dist)) | (((big_dist) >> 7) > (small_dist)) | |||
extern void | extern void | |||
lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf, | lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf, | |||
uint32_t *restrict back_res, uint32_t *restrict len_res) | uint32_t *restrict back_res, uint32_t *restrict len_res) | |||
{ | { | |||
const uint32_t nice_len = mf->nice_len; | const uint32_t nice_len = mf->nice_len; | |||
skipping to change at line 58 | skipping to change at line 59 | |||
// Pointer to the beginning of the match candidate | // Pointer to the beginning of the match candidate | |||
const uint8_t *const buf_back = buf - coder->reps[i] - 1; | const uint8_t *const buf_back = buf - coder->reps[i] - 1; | |||
// If the first two bytes (2 == MATCH_LEN_MIN) do not match, | // If the first two bytes (2 == MATCH_LEN_MIN) do not match, | |||
// this rep is not useful. | // this rep is not useful. | |||
if (not_equal_16(buf, buf_back)) | if (not_equal_16(buf, buf_back)) | |||
continue; | continue; | |||
// The first two bytes matched. | // The first two bytes matched. | |||
// Calculate the length of the match. | // Calculate the length of the match. | |||
uint32_t len; | const uint32_t len = lzma_memcmplen( | |||
for (len = 2; len < buf_avail | buf, buf_back, 2, buf_avail); | |||
&& buf[len] == buf_back[len]; ++len) ; | ||||
// If we have found a repeated match that is at least | // If we have found a repeated match that is at least | |||
// nice_len long, return it immediately. | // nice_len long, return it immediately. | |||
if (len >= nice_len) { | if (len >= nice_len) { | |||
*back_res = i; | *back_res = i; | |||
*len_res = len; | *len_res = len; | |||
mf_skip(mf, len - 1); | mf_skip(mf, len - 1); | |||
return; | return; | |||
} | } | |||
skipping to change at line 156 | skipping to change at line 156 | |||
} | } | |||
// In contrast to LZMA SDK, dictionary could not have been moved | // In contrast to LZMA SDK, dictionary could not have been moved | |||
// between mf_find() calls, thus it is safe to just increment | // between mf_find() calls, thus it is safe to just increment | |||
// the old buf pointer instead of recalculating it with mf_ptr(). | // the old buf pointer instead of recalculating it with mf_ptr(). | |||
++buf; | ++buf; | |||
const uint32_t limit = len_main - 1; | const uint32_t limit = len_main - 1; | |||
for (uint32_t i = 0; i < REPS; ++i) { | for (uint32_t i = 0; i < REPS; ++i) { | |||
const uint8_t *const buf_back = buf - coder->reps[i] - 1; | if (memcmp(buf, buf - coder->reps[i] - 1, limit) == 0) { | |||
if (not_equal_16(buf, buf_back)) | ||||
continue; | ||||
uint32_t len; | ||||
for (len = 2; len < limit | ||||
&& buf[len] == buf_back[len]; ++len) ; | ||||
if (len >= limit) { | ||||
*back_res = UINT32_MAX; | *back_res = UINT32_MAX; | |||
*len_res = 1; | *len_res = 1; | |||
return; | return; | |||
} | } | |||
} | } | |||
*back_res = back_main + REPS; | *back_res = back_main + REPS; | |||
*len_res = len_main; | *len_res = len_main; | |||
mf_skip(mf, len_main - 2); | mf_skip(mf, len_main - 2); | |||
return; | return; | |||
End of changes. 3 change blocks. | ||||
13 lines changed or deleted | 4 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |