/usr/share/doc/liblzma-doc/html/lz__encoder__mf_8c.html is in liblzma-doc 5.1.1alpha+20110809-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>XZ Utils: liblzma/lz/lz_encoder_mf.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">XZ Utils <span id="projectnumber">5.1.0alpha</span></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#define-members">Defines</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">liblzma/lz/lz_encoder_mf.c File Reference</div> </div>
</div>
<div class="contents">
<p>Match finders.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include "<a class="el" href="lz__encoder_8h.html">lz_encoder.h</a>"</code><br/>
<code>#include "<a class="el" href="lz__encoder__hash_8h.html">lz_encoder_hash.h</a>"</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#aa84dd0b4f5690a4f890f7be99792feeb">EMPTY_HASH_VALUE</a>   0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a73a2d7ca0b7c574a5043d0236fec29c8">MUST_NORMALIZE_POS</a>   UINT32_MAX</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#aafda9f47948ddd2342f44150a3489908">header</a>(is_bt, len_min, ret_op)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a8b1ccc141b3c8be0a63b15fec7f9c8b2">header_find</a>(is_bt, len_min)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#acbaeadaaa3485eaebf078fb5ed712a36">header_skip</a>(is_bt, len_min)   header(is_bt, len_min, continue)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a0e7fce36bf4da7e7bd9651901d22eddb">call_find</a>(func, len_best)</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a47b5a3f51e46b7ba5908fbf7150d3343">lzma_mf_find</a> (<a class="el" href="structlzma__mf__s.html">lzma_mf</a> *mf, uint32_t *count_ptr, <a class="el" href="structlzma__match.html">lzma_match</a> *matches)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Find matches starting from the current byte. <a href="#a47b5a3f51e46b7ba5908fbf7150d3343"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a648138094aea5aa00a259061633ab848">normalize</a> (<a class="el" href="structlzma__mf__s.html">lzma_mf</a> *mf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Normalizes hash values. <a href="#a648138094aea5aa00a259061633ab848"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a664d6298d1e02fb4817f416382953f20">move_pos</a> (<a class="el" href="structlzma__mf__s.html">lzma_mf</a> *mf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Mark the current byte as processed from point of view of the match finder. <a href="#a664d6298d1e02fb4817f416382953f20"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="lz__encoder__mf_8c.html#a38834174a29ae811fbd2ee848f069866">move_pending</a> (<a class="el" href="structlzma__mf__s.html">lzma_mf</a> *mf)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Match finders. </p>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="aa84dd0b4f5690a4f890f7be99792feeb"></a><!-- doxytag: member="lz_encoder_mf.c::EMPTY_HASH_VALUE" ref="aa84dd0b4f5690a4f890f7be99792feeb" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define EMPTY_HASH_VALUE   0</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Hash value to indicate unused element in the hash. Since we start the positions from dict_size + 1, zero is always too far to qualify as usable match position. </p>
<p>Referenced by <a class="el" href="lz__encoder__mf_8c.html#a648138094aea5aa00a259061633ab848">normalize()</a>.</p>
</div>
</div>
<a class="anchor" id="a73a2d7ca0b7c574a5043d0236fec29c8"></a><!-- doxytag: member="lz_encoder_mf.c::MUST_NORMALIZE_POS" ref="a73a2d7ca0b7c574a5043d0236fec29c8" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MUST_NORMALIZE_POS   UINT32_MAX</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Normalization must be done when <a class="el" href="structlzma__mf__s.html#a2f61158f799c0c4e77e6316038757fee">lzma_mf.offset</a> + <a class="el" href="structlzma__mf__s.html#a2d75d309fc59e61e468fcd9e3a38c150">lzma_mf.read_pos</a> reaches MUST_NORMALIZE_POS. </p>
<p>Referenced by <a class="el" href="lz__encoder__mf_8c.html#a648138094aea5aa00a259061633ab848">normalize()</a>.</p>
</div>
</div>
<a class="anchor" id="aafda9f47948ddd2342f44150a3489908"></a><!-- doxytag: member="lz_encoder_mf.c::header" ref="aafda9f47948ddd2342f44150a3489908" args="(is_bt, len_min, ret_op)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define header</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">is_bt, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">len_min, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">ret_op </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">uint32_t len_limit = <a class="code" href="lz__encoder_8h.html#a448bea3aca15ae451c69e197bb6720f9" title="Get the number of bytes that haven't been ran through the match finder yet.">mf_avail</a>(mf); \
<span class="keywordflow">if</span> (mf->nice_len <= len_limit) { \
len_limit = mf->nice_len; \
} <span class="keywordflow">else</span> <span class="keywordflow">if</span> (len_limit < (len_min) \
|| (is_bt && mf->action == <a class="code" href="base_8h.html#aa92efcbf3cecfcac79c81fc645fce77ea14d75152afcda85d215e877fdd9c4170" title="Make all the input available at output.">LZMA_SYNC_FLUSH</a>)) { \
assert(mf->action != <a class="code" href="base_8h.html#aa92efcbf3cecfcac79c81fc645fce77ea868472b76492afcaef54020a481890b1" title="Continue coding.">LZMA_RUN</a>); \
<a class="code" href="lz__encoder__mf_8c.html#a38834174a29ae811fbd2ee848f069866">move_pending</a>(mf); \
ret_op; \
} \
<span class="keyword">const</span> uint8_t *cur = <a class="code" href="lz__encoder_8h.html#a6e013d2ce6aa381e26fb6579cbd9ddae" title="Get pointer to the first byte not ran through the match finder.">mf_ptr</a>(mf); \
<span class="keyword">const</span> uint32_t pos = mf->read_pos + mf->offset
</pre></div><p>Calculate len_limit and determine if there is enough input to run the actual match finder code. Sets up "cur" and "pos". This macro is used by all find functions and binary tree skip functions. Hash chain skip function doesn't need len_limit so a simpler code is used in them. </p>
</div>
</div>
<a class="anchor" id="a8b1ccc141b3c8be0a63b15fec7f9c8b2"></a><!-- doxytag: member="lz_encoder_mf.c::header_find" ref="a8b1ccc141b3c8be0a63b15fec7f9c8b2" args="(is_bt, len_min)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define header_find</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">is_bt, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">len_min </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><a class="code" href="lz__encoder__mf_8c.html#aafda9f47948ddd2342f44150a3489908">header</a>(is_bt, len_min, <span class="keywordflow">return</span> 0); \
uint32_t matches_count = 0
</pre></div><p>Header for find functions. "return 0" indicates that zero matches were found. </p>
</div>
</div>
<a class="anchor" id="acbaeadaaa3485eaebf078fb5ed712a36"></a><!-- doxytag: member="lz_encoder_mf.c::header_skip" ref="acbaeadaaa3485eaebf078fb5ed712a36" args="(is_bt, len_min)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define header_skip</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">is_bt, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">len_min </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td>   header(is_bt, len_min, continue)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Header for a loop in a skip function. "continue" tells to skip the rest of the code in the loop. </p>
</div>
</div>
<a class="anchor" id="a0e7fce36bf4da7e7bd9651901d22eddb"></a><!-- doxytag: member="lz_encoder_mf.c::call_find" ref="a0e7fce36bf4da7e7bd9651901d22eddb" args="(func, len_best)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define call_find</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">func, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">len_best </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keywordflow">do</span> { \
matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \
mf->son, mf->cyclic_pos, mf->cyclic_size, \
matches + matches_count, len_best) \
- matches; \
<a class="code" href="lz__encoder__mf_8c.html#a664d6298d1e02fb4817f416382953f20" title="Mark the current byte as processed from point of view of the match finder.">move_pos</a>(mf); \
<span class="keywordflow">return</span> matches_count; \
} <span class="keywordflow">while</span> (0)
</pre></div><p>Calls hc_find_func() or bt_find_func() and calculates the total number of matches found. Updates the dictionary position and returns the number of matches found. </p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a47b5a3f51e46b7ba5908fbf7150d3343"></a><!-- doxytag: member="lz_encoder_mf.c::lzma_mf_find" ref="a47b5a3f51e46b7ba5908fbf7150d3343" args="(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t lzma_mf_find </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structlzma__mf__s.html">lzma_mf</a> * </td>
<td class="paramname"><em>mf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t * </td>
<td class="paramname"><em>count_ptr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structlzma__match.html">lzma_match</a> * </td>
<td class="paramname"><em>matches</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Find matches starting from the current byte. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>The length of the longest match found </dd></dl>
<p>References <a class="el" href="structlzma__mf__s.html#a62dbb517d02d31c51feb24ca810c1fa5">lzma_mf_s::find</a>, <a class="el" href="structlzma__mf__s.html#a6fa8887a90423f6833506f298ae76a8d">lzma_mf_s::match_len_max</a>, <a class="el" href="lz__encoder_8h.html#a448bea3aca15ae451c69e197bb6720f9">mf_avail()</a>, <a class="el" href="lz__encoder_8h.html#a6e013d2ce6aa381e26fb6579cbd9ddae">mf_ptr()</a>, <a class="el" href="structlzma__mf__s.html#aa4291f4276c419e74a95cb8accdf1396">lzma_mf_s::nice_len</a>, and <a class="el" href="structlzma__mf__s.html#ab5d64d7200396c7cd612c1fe3a064f22">lzma_mf_s::read_ahead</a>.</p>
</div>
</div>
<a class="anchor" id="a648138094aea5aa00a259061633ab848"></a><!-- doxytag: member="lz_encoder_mf.c::normalize" ref="a648138094aea5aa00a259061633ab848" args="(lzma_mf *mf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static void normalize </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structlzma__mf__s.html">lzma_mf</a> * </td>
<td class="paramname"><em>mf</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Normalizes hash values. </p>
<p>The hash arrays store positions of match candidates. The positions are relative to an arbitrary offset that is not the same as the absolute offset in the input stream. The relative position of the current byte is <a class="el" href="structlzma__mf__s.html#a2f61158f799c0c4e77e6316038757fee">lzma_mf.offset</a> + <a class="el" href="structlzma__mf__s.html#a2d75d309fc59e61e468fcd9e3a38c150">lzma_mf.read_pos</a>. The distances of the matches are the differences of the current read position and the position found from the hash.</p>
<p>To prevent integer overflows of the offsets stored in the hash arrays, we need to "normalize" the stored values now and then. During the normalization, we drop values that indicate distance greater than the dictionary size, thus making space for new values. </p>
<p>References <a class="el" href="lz__encoder__mf_8c.html#aa84dd0b4f5690a4f890f7be99792feeb">EMPTY_HASH_VALUE</a>, <a class="el" href="structlzma__mf__s.html#a148e0e2a9f52595b7d9d2dc93d04c50a">lzma_mf_s::hash_size_sum</a>, <a class="el" href="lz__encoder__mf_8c.html#a73a2d7ca0b7c574a5043d0236fec29c8">MUST_NORMALIZE_POS</a>, <a class="el" href="structlzma__mf__s.html#a2f61158f799c0c4e77e6316038757fee">lzma_mf_s::offset</a>, <a class="el" href="structlzma__mf__s.html#a2d75d309fc59e61e468fcd9e3a38c150">lzma_mf_s::read_pos</a>, and <a class="el" href="structlzma__mf__s.html#ad1e3c68f459903d161ed34a97ff43fdf">lzma_mf_s::sons_count</a>.</p>
<p>Referenced by <a class="el" href="lz__encoder__mf_8c.html#a664d6298d1e02fb4817f416382953f20">move_pos()</a>.</p>
</div>
</div>
<a class="anchor" id="a664d6298d1e02fb4817f416382953f20"></a><!-- doxytag: member="lz_encoder_mf.c::move_pos" ref="a664d6298d1e02fb4817f416382953f20" args="(lzma_mf *mf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static void move_pos </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structlzma__mf__s.html">lzma_mf</a> * </td>
<td class="paramname"><em>mf</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Mark the current byte as processed from point of view of the match finder. </p>
<p>References <a class="el" href="lz__encoder__mf_8c.html#a648138094aea5aa00a259061633ab848">normalize()</a>, <a class="el" href="structlzma__mf__s.html#a2f61158f799c0c4e77e6316038757fee">lzma_mf_s::offset</a>, <a class="el" href="structlzma__mf__s.html#a2d75d309fc59e61e468fcd9e3a38c150">lzma_mf_s::read_pos</a>, and <a class="el" href="structlzma__mf__s.html#afcc4a74eb85f8942d40a21d9155d948c">lzma_mf_s::write_pos</a>.</p>
</div>
</div>
<a class="anchor" id="a38834174a29ae811fbd2ee848f069866"></a><!-- doxytag: member="lz_encoder_mf.c::move_pending" ref="a38834174a29ae811fbd2ee848f069866" args="(lzma_mf *mf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static void move_pending </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structlzma__mf__s.html">lzma_mf</a> * </td>
<td class="paramname"><em>mf</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>When flushing, we cannot run the match finder unless there is nice_len bytes available in the dictionary. Instead, we skip running the match finder (indicating that no match was found), and count how many bytes we have ignored this way.</p>
<p>When new data is given after the flushing was completed, the match finder is restarted by rewinding mf->read_pos backwards by mf->pending. Then the missed bytes are added to the hash using the match finder's skip function (with small amount of input, it may start using mf->pending again if flushing).</p>
<p>Due to this rewinding, we don't touch cyclic_pos or test for normalization. It will be done when the match finder's skip function catches up after a flush. </p>
<p>References <a class="el" href="structlzma__mf__s.html#af6719fc22695f6e8569969009ba5a727">lzma_mf_s::pending</a>, <a class="el" href="structlzma__mf__s.html#a2d75d309fc59e61e468fcd9e3a38c150">lzma_mf_s::read_pos</a>, and <a class="el" href="structlzma__mf__s.html#afcc4a74eb85f8942d40a21d9155d948c">lzma_mf_s::write_pos</a>.</p>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Nov 1 2011 10:43:14 for XZ Utils by 
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
|