Run dos2unix on all files:
authorStefan Reinauer <stepan@coresystems.de>
Sat, 2 May 2009 12:42:30 +0000 (12:42 +0000)
committerStefan Reinauer <stepan@openbios.org>
Sat, 2 May 2009 12:42:30 +0000 (12:42 +0000)
find . -type f| grep -v svn | xargs dos2unix

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4250 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

55 files changed:
documentation/codeflow.svg
documentation/hypertransport.svg
src/cpu/intel/model_f4x/microcode_MBDF410D.h
src/mainboard/asus/m2v-mx_se/Options.lb
src/mainboard/dell/s1850/irq_tables.c
src/mainboard/msi/ms9185/Options.lb
src/mainboard/msi/ms9282/Options.lb
src/mainboard/rca/rm4100/gpio.c
src/mainboard/thomson/ip1000/gpio.c
src/northbridge/intel/i82830/vga.c
src/southbridge/intel/i82801ca/i82801ca_pci.c
targets/intel/xe7501devkit/VERSION
util/cbfstool/tools/lzma/C/7zip/Common/InBuffer.h
util/cbfstool/tools/lzma/C/7zip/Common/OutBuffer.cpp
util/cbfstool/tools/lzma/C/7zip/Common/OutBuffer.h
util/cbfstool/tools/lzma/C/7zip/Common/StdAfx.h
util/cbfstool/tools/lzma/C/7zip/Common/StreamUtils.cpp
util/cbfstool/tools/lzma/C/7zip/Common/StreamUtils.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/BinTree/BinTree.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/BinTree/BinTree2.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/BinTree/BinTree3.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/BinTree/BinTree4.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/BinTree/BinTreeMain.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/HashChain/HC4.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/HashChain/HCMain.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/IMatchFinder.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/LZInWindow.cpp
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/LZInWindow.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZ/StdAfx.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZMA/LZMA.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZMA/LZMAEncoder.cpp
util/cbfstool/tools/lzma/C/7zip/Compress/LZMA/LZMAEncoder.h
util/cbfstool/tools/lzma/C/7zip/Compress/LZMA/StdAfx.h
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/RangeCoder.h
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.h
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/RangeCoderBitTree.h
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/RangeCoderOpt.h
util/cbfstool/tools/lzma/C/7zip/Compress/RangeCoder/StdAfx.h
util/cbfstool/tools/lzma/C/7zip/ICoder.h
util/cbfstool/tools/lzma/C/7zip/IStream.h
util/cbfstool/tools/lzma/C/Common/Alloc.cpp
util/cbfstool/tools/lzma/C/Common/Alloc.h
util/cbfstool/tools/lzma/C/Common/CRC.cpp
util/cbfstool/tools/lzma/C/Common/CRC.h
util/cbfstool/tools/lzma/C/Common/Defs.h
util/cbfstool/tools/lzma/C/Common/MyCom.h
util/cbfstool/tools/lzma/C/Common/MyGuidDef.h
util/cbfstool/tools/lzma/C/Common/MyInitGuid.h
util/cbfstool/tools/lzma/C/Common/MyUnknown.h
util/cbfstool/tools/lzma/C/Common/MyWindows.h
util/cbfstool/tools/lzma/C/Common/NewHandler.h
util/cbfstool/tools/lzma/C/Common/StdAfx.h
util/cbfstool/tools/lzma/C/Common/Types.h
util/cbfstool/tools/lzma/C/LGPL.txt

index fba8f29419235af00a89a595a3927113453a06ff..eccf19dbb44c76eb3ead17b48044cc05e2bd9e7c 100644 (file)
-<?xml version="1.0" encoding="utf-8"?>\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
-        width="256px" height="640px" viewBox="0 0 256 640" enable-background="new 0 0 256 640" xml:space="preserve">\r
-<font horiz-adv-x="1000">\r
-<font-face font-family="MyriadPro-Regular" units-per-em="1000" underline-position="-100" underline-thickness="50"/>\r
-<missing-glyph horiz-adv-x="500" d="M0,0l500,0l0,700l-500,0M250,395l-170,255l340,0M280,350l170,255l0,-510M80,50l170,255l170,-255M50,605l170,-255l-170,-255z"/>\r
-<glyph unicode="A" horiz-adv-x="612" d="M424,212l72,-212l93,0l-230,674l-104,0l-230,-674l90,0l70,212M203,280l66,195C283,516 293,558 303,597l2,0C315,558 325,518 340,474l67,-194z"/>\r
-<glyph unicode="B" horiz-adv-x="542" d="M76,2C105,-2 151,-6 211,-6C321,-6 397,14 443,57C478,89 501,134 501,192C501,292 426,345 362,360l0,3C432,388 476,445 476,511C476,564 454,604 419,630C378,664 322,679 235,679C175,679 114,673 76,664M163,606C177,609 200,612 240,612C328,612 387,580 387,502C387,437 333,388 242,388l-79,0M163,323l72,0C330,323 409,284 409,193C409,95 326,62 236,62C205,62 181,63 163,66z"/>\r
-<glyph unicode="C" horiz-adv-x="580" d="M529,91C494,74 440,63 386,63C223,63 128,168 128,334C128,511 233,612 391,612C447,612 494,600 526,584l22,71C525,667 471,685 388,685C179,685 36,543 36,331C36,109 178,-11 368,-11C450,-11 515,5 546,21z"/>\r
-<glyph unicode="D" horiz-adv-x="666" d="M76,2C120,-3 171,-6 234,-6C365,-6 469,28 533,91C595,153 630,243 630,353C630,462 595,540 534,595C475,649 386,679 261,679C192,679 129,673 76,664M163,601C186,606 220,610 265,610C449,610 539,509 538,350C538,168 438,64 251,64C217,64 185,65 163,68z"/>\r
-<glyph unicode="E" horiz-adv-x="492" d="M424,388l-261,0l0,213l277,0l0,73l-365,0l0,-674l380,0l0,73l-292,0l0,243l261,0z"/>\r
-<glyph unicode="F" horiz-adv-x="487" d="M75,0l88,0l0,305l254,0l0,72l-254,0l0,224l275,0l0,73l-363,0z"/>\r
-<glyph unicode="H" horiz-adv-x="652" d="M75,674l0,-674l88,0l0,316l326,0l0,-316l88,0l0,674l-88,0l0,-282l-326,0l0,282z"/>\r
-<glyph unicode="I" horiz-adv-x="239" d="M75,674l0,-674l88,0l0,674z"/>\r
-<glyph unicode="L" horiz-adv-x="472" d="M75,0l376,0l0,73l-288,0l0,601l-88,0z"/>\r
-<glyph unicode="M" horiz-adv-x="804" d="M660,0l86,0l-42,674l-111,0l-120,-326C443,263 419,189 401,121l-2,0C381,191 359,265 331,348l-115,326l-111,0l-47,-674l83,0l18,289C165,391 170,503 172,587l2,0C193,507 219,421 251,325l110,-321l66,0l119,327C580,424 607,509 631,587l2,0C633,504 639,390 644,296z"/>\r
-<glyph unicode="N" horiz-adv-x="658" d="M158,0l0,288C158,400 157,481 152,566l3,1C188,494 233,417 280,342l214,-342l88,0l0,674l-82,0l0,-282C500,287 502,205 510,115l-3,-1C476,183 436,254 387,333l-215,341l-96,0l0,-674z"/>\r
-<glyph unicode="O" horiz-adv-x="689" d="M348,686C168,686 36,546 36,332C36,128 160,-11 339,-11C511,-11 652,113 652,344C652,545 533,686 348,686M345,615C490,615 560,475 560,340C560,187 482,60 344,60C206,60 128,189 128,334C128,481 200,615 345,615z"/>\r
-<glyph unicode="P" horiz-adv-x="532" d="M76,0l87,0l0,270C183,265 207,264 233,264C318,264 392,289 439,338C473,373 491,421 491,482C491,542 468,591 432,623C392,659 329,679 243,679C173,679 118,673 76,666M163,603C178,607 207,610 245,610C340,610 404,567 404,477C404,386 340,334 235,334C206,334 182,336 163,341z"/>\r
-<glyph unicode="Q" horiz-adv-x="689" d="M657,-26C600,-16 527,0 460,17l0,4C572,61 652,171 652,345C652,544 533,686 349,686C167,686 36,547 36,331C36,113 172,-5 333,-11C346,-11 359,-16 374,-21C452,-48 541,-75 632,-99M344,60C206,60 128,189 128,333C128,479 200,615 347,615C490,615 560,476 560,340C560,187 482,60 344,60z"/>\r
-<glyph unicode="R" horiz-adv-x="538" d="M76,0l87,0l0,292l82,0C324,289 361,254 381,161C399,77 414,20 425,0l90,0C501,26 485,91 463,185C447,255 416,303 365,321l0,3C435,348 491,407 491,495C491,548 471,594 438,624C397,661 336,679 243,679C184,679 120,673 76,665M163,604C178,608 207,611 249,611C341,611 404,573 404,486C404,409 345,358 252,358l-89,0z"/>\r
-<glyph unicode="S" horiz-adv-x="493" d="M42,33C78,9 149,-11 214,-11C373,-11 449,80 449,184C449,283 392,338 278,382C185,418 144,449 144,512C144,558 179,613 271,613C332,613 377,594 398,581l24,71C393,669 342,685 274,685C143,685 56,607 56,502C56,408 124,350 234,310C325,276 361,239 361,177C361,109 309,62 220,62C160,62 104,81 65,106z"/>\r
-<glyph unicode="T" horiz-adv-x="497" d="M204,0l88,0l0,600l206,0l0,74l-499,0l0,-74l205,0z"/>\r
-<glyph unicode="U" horiz-adv-x="647" d="M75,674l0,-397C75,67 179,-11 317,-11C463,-11 572,73 572,280l0,394l-88,0l0,-400C484,126 419,60 320,60C230,60 163,124 163,274l0,400z"/>\r
-<glyph unicode="a" horiz-adv-x="482" d="M413,297C413,393 377,494 229,494C168,494 109,477 69,452l20,-59C123,416 170,429 216,429C315,430 326,357 326,318l0,-10C139,309 35,245 35,128C35,58 85,-11 183,-11C252,-11 304,23 331,61l3,0l7,-61l79,0C415,33 413,74 413,116M328,163C328,155 327,145 324,135C310,94 269,54 205,54C161,54 123,80 123,138C123,232 232,249 328,247z"/>\r
-<glyph unicode="b" horiz-adv-x="569" d="M73,125C73,82 71,33 69,0l75,0l5,79l2,0C188,16 244,-11 314,-11C422,-11 532,75 532,248C532,394 448,494 327,494C249,494 193,460 162,406l-2,0l0,304l-87,0M160,280C160,294 162,306 165,317C183,383 239,425 298,425C393,425 443,342 443,245C443,134 389,59 296,59C232,59 180,101 164,162C161,172 160,183 160,194z"/>\r
-<glyph unicode="c" horiz-adv-x="448" d="M403,83C378,72 345,60 295,60C199,60 127,129 127,241C127,341 187,424 298,424C346,424 379,412 400,401l20,67C396,481 350,494 298,494C140,494 38,385 38,236C38,88 133,-11 279,-11C344,-11 395,6 418,17z"/>\r
-<glyph unicode="," horiz-adv-x="207" d="M78,-117C106,-70 150,41 174,126l-98,-10C65,43 38,-64 16,-124z"/>\r
-<glyph unicode="d" horiz-adv-x="564" d="M403,710l0,-289l-2,0C379,459 330,494 255,494C138,494 37,396 38,235C38,88 129,-11 246,-11C325,-11 383,30 409,84l3,0l4,-84l78,0C492,33 490,82 490,125l0,585M403,203C403,189 402,177 399,165C383,100 329,60 270,60C176,60 127,141 127,239C127,345 181,425 272,425C338,425 386,379 399,324C402,313 403,298 403,287z"/>\r
-<glyph unicode="e" horiz-adv-x="501" d="M462,226C464,236 465,249 465,267C465,356 424,494 265,494C124,494 38,380 38,234C38,88 127,-11 276,-11C353,-11 407,6 438,20l-16,63C390,69 351,58 288,58C199,58 124,107 122,226M123,289C130,350 168,431 258,431C357,431 381,344 380,289z"/>\r
-<glyph unicode="h" horiz-adv-x="555" d="M73,0l88,0l0,292C161,308 162,321 167,334C184,381 228,421 285,421C368,421 397,356 397,278l0,-278l88,0l0,288C485,454 381,494 316,494C283,494 252,485 226,470C199,455 177,432 163,407l-2,0l0,303l-88,0z"/>\r
-<glyph unicode="-" horiz-adv-x="307" d="M30,302l0,-64l247,0l0,64z"/>\r
-<glyph unicode="i" horiz-adv-x="234" d="M161,0l0,484l-88,0l0,-484M117,675C84,675 62,650 62,620C62,590 83,566 115,566C150,566 171,590 171,620C171,651 149,675 117,675z"/>\r
-<glyph unicode="k" horiz-adv-x="469" d="M160,710l-87,0l0,-710l87,0l0,182l45,50l166,-232l108,0l-213,285l186,199l-105,0l-143,-167C190,300 174,279 162,262l-2,0z"/>\r
-<glyph unicode="l" horiz-adv-x="236" d="M73,0l88,0l0,710l-88,0z"/>\r
-<glyph unicode="m" horiz-adv-x="834" d="M73,0l86,0l0,291C159,306 161,322 166,334C180,378 221,422 275,422C342,422 376,367 376,290l0,-290l86,0l0,299C462,315 465,330 469,343C485,385 523,422 574,422C644,422 679,367 679,273l0,-273l86,0l0,284C765,452 670,494 605,494C559,494 528,482 499,460C479,445 459,425 444,397l-2,0C421,454 371,494 306,494C225,494 180,451 153,405l-3,0l-4,79l-77,0C71,444 73,404 73,353z"/>\r
-<glyph unicode="n" horiz-adv-x="555" d="M73,0l88,0l0,291C161,306 163,321 167,332C183,381 228,422 285,422C368,422 397,357 397,279l0,-279l88,0l0,288C485,454 381,494 314,494C234,494 178,449 154,404l-2,0l-5,80l-78,0C72,444 73,404 73,353z"/>\r
-<glyph unicode="o" horiz-adv-x="549" d="M278,494C145,494 38,399 38,238C38,85 140,-11 270,-11C386,-11 511,67 511,246C511,393 417,494 278,494M276,428C380,428 421,325 421,243C421,134 358,55 274,55C188,55 128,135 128,241C128,332 173,428 276,428z"/>\r
-<glyph unicode="p" horiz-adv-x="569" d="M73,-198l87,0l0,263l2,0C191,17 247,-11 311,-11C425,-11 532,75 532,249C532,395 444,494 326,494C247,494 189,460 154,401l-2,0l-5,83l-78,0C71,438 73,388 73,326M160,281C160,292 163,305 166,316C182,382 239,424 299,424C392,424 443,341 443,245C443,134 389,58 296,58C233,58 180,100 164,161C161,172 160,184 160,197z"/>\r
-<glyph unicode="(" horiz-adv-x="284" d="M195,694C132,610 65,481 64,285C64,90 132,-38 195,-121l68,0C193,-21 138,106 138,284C138,466 190,595 263,694z"/>\r
-<glyph unicode=")" horiz-adv-x="284" d="M88,-121C151,-37 218,91 219,287C219,483 151,612 88,694l-68,0C91,594 145,467 145,287C145,107 90,-22 20,-121z"/>\r
-<glyph unicode="." horiz-adv-x="207" d="M110,-11C147,-11 171,16 171,52C171,89 147,115 112,115C77,115 52,88 52,52C52,16 76,-11 110,-11z"/>\r
-<glyph unicode="?" horiz-adv-x="406" d="M220,192l-2,25C215,268 231,313 275,365C323,422 361,471 361,539C361,615 309,686 194,686C141,686 85,670 51,646l24,-63C100,602 140,614 176,614C239,613 271,579 271,528C271,483 246,444 201,391C151,331 133,271 139,218l2,-26M178,-11C215,-11 238,16 238,51C238,88 215,114 179,114C145,114 120,88 120,51C120,16 144,-11 178,-11z"/>\r
-<glyph unicode="r" horiz-adv-x="327" d="M73,0l88,0l0,258C161,272 162,287 164,299C176,365 220,411 282,411C294,411 303,411 312,409l0,83C304,493 297,494 288,494C229,494 175,453 153,388l-3,0l-4,96l-77,0C72,439 73,390 73,333z"/>\r
-<glyph unicode="s" horiz-adv-x="396" d="M40,23C74,3 123,-11 176,-11C289,-11 356,49 356,135C356,207 312,249 229,280C166,305 138,323 138,363C138,399 166,429 218,429C263,429 298,412 317,400l21,64C312,481 269,494 220,494C117,494 53,430 53,352C53,294 94,247 182,215C246,191 271,169 271,127C271,86 241,55 178,55C134,55 88,73 61,89z"/>\r
-<glyph unicode="/" horiz-adv-x="343" d="M66,-39l280,725l-69,0l-278,-725z"/>\r
-<glyph unicode=" " horiz-adv-x="212"/>\r
-<glyph unicode="t" horiz-adv-x="331" d="M93,574l0,-90l-75,0l0,-67l75,0l0,-264C93,96 103,53 127,26C148,3 181,-11 222,-11C256,-11 283,-5 300,1l-4,67C283,64 269,62 245,62C196,62 179,96 179,156l0,261l126,0l0,67l-126,0l0,116z"/>\r
-<glyph unicode="2" horiz-adv-x="513" d="M460,0l0,73l-291,0l0,2l51,48C357,255 444,352 444,472C444,565 385,661 245,661C171,661 106,632 62,595l28,-62C120,558 169,588 228,588C325,588 356,527 356,461C356,363 280,279 114,121l-69,-67l0,-54z"/>\r
-<glyph unicode="u" horiz-adv-x="551" d="M478,484l-88,0l0,-296C390,171 387,155 382,143C366,103 325,62 266,62C187,62 158,125 158,217l0,267l-88,0l0,-283C70,32 161,-11 237,-11C323,-11 375,40 397,79l2,0l5,-79l78,0C479,38 478,82 478,133z"/>\r
-<glyph unicode="v" horiz-adv-x="481" d="M13,484l184,-484l84,0l190,484l-92,0l-94,-271C269,168 255,128 244,88l-3,0C231,128 218,168 202,213l-95,271z"/>\r
-<glyph unicode="x" horiz-adv-x="463" d="M16,484l164,-237l-172,-247l97,0l70,109C194,138 210,164 226,193l2,0C245,164 261,137 280,109l72,-109l99,0l-169,250l165,234l-96,0l-67,-103C267,355 251,330 235,302l-2,0C217,329 202,353 183,380l-69,104z"/>\r
-<glyph unicode="y" horiz-adv-x="471" d="M9,484l178,-446C192,27 194,20 194,15C194,10 191,3 187,-6C166,-51 137,-85 113,-104C87,-126 58,-140 36,-147l22,-73C80,-216 122,-201 166,-164C226,-111 269,-27 332,139l132,345l-93,0l-96,-284C263,165 253,128 244,99l-2,0C234,128 222,166 210,198l-105,286z"/>\r
-<glyph unicode="z" horiz-adv-x="428" d="M18,0l392,0l0,70l-282,0l0,2C150,96 169,121 190,148l216,281l0,55l-368,0l0,-70l262,0l0,-2C278,386 258,363 236,336l-218,-285z"/>\r
-</font>\r
-\r
-       <g>\r
-       <rect y="1.152" fill="#AAAAAA" stroke="#000000" width="256" height="36.887"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 23.7046)" font-family="'MyriadPro-Regular'" font-size="14">Enter protected mode</text>\r
-</g>\r
-<g>\r
-       <rect y="45.642" fill="#AAAAAA" stroke="#000000" width="256" height="43.62"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 71.5605)" font-family="'MyriadPro-Regular'" font-size="14">non-coherent HT enumeration</text>\r
-</g>\r
-<g>\r
-       <rect y="98.359" fill="#AAAAAA" stroke="#000000" width="256" height="60.15"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 132.5435)" font-family="'MyriadPro-Regular'" font-size="14">coherent HT initialization</text>\r
-</g>\r
-<g>\r
-       <rect y="165.983" fill="#AAAAAA" stroke="#000000" width="256" height="68.421"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 204.3022)" font-family="'MyriadPro-Regular'" font-size="14">Fallback / Normal?</text>\r
-</g>\r
-<g>\r
-       <rect y="243.893" fill="#AAAAAA" stroke="#000000" width="256" height="69.173"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 282.5879)" font-family="'MyriadPro-Regular'" font-size="14">RAM initialization</text>\r
-</g>\r
-<g>\r
-       <rect y="410.747" fill="#AAAAAA" stroke="#000000" width="256" height="52.632"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 432.7725)"><tspan x="0" y="0" font-family="'MyriadPro-Regular'" font-size="14">Create external tables (coreboot table,</tspan><tspan x="0" y="16.8" font-family="'MyriadPro-Regular'" font-size="14">ACPI, MP, PIRQ, DMI)</tspan></text>\r
-</g>\r
-<g>\r
-       <rect y="323.526" fill="#AAAAAA" stroke="#000000" width="256" height="77.443"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 339.3154)"><tspan x="0" y="0" font-family="'MyriadPro-Regular'" font-size="14">Resource Allocation (PCI, PCIe, I2C, SIO, </tspan><tspan x="0" y="16.8" font-family="'MyriadPro-Regular'" font-size="14">CPU, mainboard...)</tspan></text>\r
-       <rect x="27.744" y="362.248" fill="#BCBCBC" width="228.256" height="38.722"/>\r
-</g>\r
-<g>\r
-       <rect y="473.781" fill="#AAAAAA" stroke="#000000" width="256" height="80.076"/>\r
-       <text transform="matrix(1 0 0 1 27.7441 497.4658)" font-family="'MyriadPro-Regular'" font-size="14">ELF / Payload Loader</text>\r
-       <rect x="27.744" y="507.993" fill="#BCBCBC" width="228.256" height="45.864"/>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,31.246 130.359,46.62 132.854,44.7 \r
-                                                                       132.027,51.206 131.201,57.711 124.701,56.845 118.201,55.98 120.608,54.127 110.178,33.439                                                                "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,57.636 132.228,59.101 133.828,45.178 133.062,44.181                                                     "/>\r
-                                                       <polygon fill="#231F20" points="131.152,57.643 132.28,59.108 118.41,57.093 117.644,56.096                                                       "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,81.246 130.359,96.62 132.854,94.7 \r
-                                                                       132.027,101.206 131.201,107.711 124.701,106.845 118.201,105.98 120.608,104.127 110.178,83.439                                                           "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,107.636 132.228,109.101 133.828,95.178 133.062,94.181                                                   "/>\r
-                                                       <polygon fill="#231F20" points="131.152,107.643 132.28,109.108 118.41,107.093 117.644,106.096                                                   "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,151.586 130.359,166.961 132.854,165.041 \r
-                                                                       132.027,171.546 131.201,178.052 124.701,177.186 118.201,176.321 120.608,174.468 110.178,153.78                                                          "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,177.977 132.228,179.442 133.828,165.519 133.062,164.522                                                         "/>\r
-                                                       <polygon fill="#231F20" points="131.152,177.983 132.28,179.449 118.41,177.434 117.644,176.437                                                   "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,227.013 130.359,242.387 132.854,240.467 \r
-                                                                       132.027,246.973 131.201,253.478 124.701,252.612 118.201,251.747 120.608,249.894 110.178,229.207                                                                 "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,253.403 132.228,254.868 133.828,240.945 133.062,239.948                                                         "/>\r
-                                                       <polygon fill="#231F20" points="131.152,253.41 132.28,254.875 118.41,252.86 117.644,251.863                                                     "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,303.013 130.359,318.388 132.854,316.468 \r
-                                                                       132.027,322.973 131.201,329.479 124.701,328.612 118.201,327.747 120.607,325.895 110.178,305.207                                                                 "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,329.404 132.228,330.868 133.829,316.945 133.062,315.948                                                         "/>\r
-                                                       <polygon fill="#231F20" points="131.152,329.41 132.28,330.876 118.41,328.86 117.643,327.864                                                     "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,395.872 130.359,411.247 132.854,409.327 \r
-                                                                       132.027,415.833 131.201,422.338 124.701,421.473 118.201,420.606 120.608,418.754 110.178,398.066                                                                 "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,422.264 132.228,423.728 133.828,409.805 133.062,408.808                                                         "/>\r
-                                                       <polygon fill="#231F20" points="131.152,422.27 132.28,423.735 118.41,421.72 117.644,420.724                                                     "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<g>\r
-       <g>\r
-               <g>\r
-                       <g>\r
-                               <g>\r
-                                       <g>\r
-                                               <g>\r
-                                                       <g>\r
-                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,452.152 130.359,467.528 132.854,465.608 \r
-                                                                       132.027,472.113 131.201,478.619 124.701,477.753 118.201,476.888 120.607,475.035 110.178,454.347                                                                 "/>\r
-                                                       </g>\r
-                                                       <polygon fill="#231F20" points="131.101,478.545 132.228,480.009 133.829,466.085 133.062,465.089                                                         "/>\r
-                                                       <polygon fill="#231F20" points="131.152,478.551 132.28,480.017 118.41,478.001 117.643,477.004                                                   "/>\r
-                                               </g>\r
-                                       </g>\r
-                               </g>\r
-                       </g>\r
-               </g>\r
-       </g>\r
-</g>\r
-<text transform="matrix(1 0 0 1 59.3232 385.7627)" font-family="'MyriadPro-Regular'" font-size="14">Drivers</text>\r
-<text transform="matrix(1 0 0 1 55.564 535.3789)" font-family="'MyriadPro-Regular'" font-size="14">Linux, FILO, SeaBIOS, ...</text>\r
-</svg>\r
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        width="256px" height="640px" viewBox="0 0 256 640" enable-background="new 0 0 256 640" xml:space="preserve">
+<font horiz-adv-x="1000">
+<font-face font-family="MyriadPro-Regular" units-per-em="1000" underline-position="-100" underline-thickness="50"/>
+<missing-glyph horiz-adv-x="500" d="M0,0l500,0l0,700l-500,0M250,395l-170,255l340,0M280,350l170,255l0,-510M80,50l170,255l170,-255M50,605l170,-255l-170,-255z"/>
+<glyph unicode="A" horiz-adv-x="612" d="M424,212l72,-212l93,0l-230,674l-104,0l-230,-674l90,0l70,212M203,280l66,195C283,516 293,558 303,597l2,0C315,558 325,518 340,474l67,-194z"/>
+<glyph unicode="B" horiz-adv-x="542" d="M76,2C105,-2 151,-6 211,-6C321,-6 397,14 443,57C478,89 501,134 501,192C501,292 426,345 362,360l0,3C432,388 476,445 476,511C476,564 454,604 419,630C378,664 322,679 235,679C175,679 114,673 76,664M163,606C177,609 200,612 240,612C328,612 387,580 387,502C387,437 333,388 242,388l-79,0M163,323l72,0C330,323 409,284 409,193C409,95 326,62 236,62C205,62 181,63 163,66z"/>
+<glyph unicode="C" horiz-adv-x="580" d="M529,91C494,74 440,63 386,63C223,63 128,168 128,334C128,511 233,612 391,612C447,612 494,600 526,584l22,71C525,667 471,685 388,685C179,685 36,543 36,331C36,109 178,-11 368,-11C450,-11 515,5 546,21z"/>
+<glyph unicode="D" horiz-adv-x="666" d="M76,2C120,-3 171,-6 234,-6C365,-6 469,28 533,91C595,153 630,243 630,353C630,462 595,540 534,595C475,649 386,679 261,679C192,679 129,673 76,664M163,601C186,606 220,610 265,610C449,610 539,509 538,350C538,168 438,64 251,64C217,64 185,65 163,68z"/>
+<glyph unicode="E" horiz-adv-x="492" d="M424,388l-261,0l0,213l277,0l0,73l-365,0l0,-674l380,0l0,73l-292,0l0,243l261,0z"/>
+<glyph unicode="F" horiz-adv-x="487" d="M75,0l88,0l0,305l254,0l0,72l-254,0l0,224l275,0l0,73l-363,0z"/>
+<glyph unicode="H" horiz-adv-x="652" d="M75,674l0,-674l88,0l0,316l326,0l0,-316l88,0l0,674l-88,0l0,-282l-326,0l0,282z"/>
+<glyph unicode="I" horiz-adv-x="239" d="M75,674l0,-674l88,0l0,674z"/>
+<glyph unicode="L" horiz-adv-x="472" d="M75,0l376,0l0,73l-288,0l0,601l-88,0z"/>
+<glyph unicode="M" horiz-adv-x="804" d="M660,0l86,0l-42,674l-111,0l-120,-326C443,263 419,189 401,121l-2,0C381,191 359,265 331,348l-115,326l-111,0l-47,-674l83,0l18,289C165,391 170,503 172,587l2,0C193,507 219,421 251,325l110,-321l66,0l119,327C580,424 607,509 631,587l2,0C633,504 639,390 644,296z"/>
+<glyph unicode="N" horiz-adv-x="658" d="M158,0l0,288C158,400 157,481 152,566l3,1C188,494 233,417 280,342l214,-342l88,0l0,674l-82,0l0,-282C500,287 502,205 510,115l-3,-1C476,183 436,254 387,333l-215,341l-96,0l0,-674z"/>
+<glyph unicode="O" horiz-adv-x="689" d="M348,686C168,686 36,546 36,332C36,128 160,-11 339,-11C511,-11 652,113 652,344C652,545 533,686 348,686M345,615C490,615 560,475 560,340C560,187 482,60 344,60C206,60 128,189 128,334C128,481 200,615 345,615z"/>
+<glyph unicode="P" horiz-adv-x="532" d="M76,0l87,0l0,270C183,265 207,264 233,264C318,264 392,289 439,338C473,373 491,421 491,482C491,542 468,591 432,623C392,659 329,679 243,679C173,679 118,673 76,666M163,603C178,607 207,610 245,610C340,610 404,567 404,477C404,386 340,334 235,334C206,334 182,336 163,341z"/>
+<glyph unicode="Q" horiz-adv-x="689" d="M657,-26C600,-16 527,0 460,17l0,4C572,61 652,171 652,345C652,544 533,686 349,686C167,686 36,547 36,331C36,113 172,-5 333,-11C346,-11 359,-16 374,-21C452,-48 541,-75 632,-99M344,60C206,60 128,189 128,333C128,479 200,615 347,615C490,615 560,476 560,340C560,187 482,60 344,60z"/>
+<glyph unicode="R" horiz-adv-x="538" d="M76,0l87,0l0,292l82,0C324,289 361,254 381,161C399,77 414,20 425,0l90,0C501,26 485,91 463,185C447,255 416,303 365,321l0,3C435,348 491,407 491,495C491,548 471,594 438,624C397,661 336,679 243,679C184,679 120,673 76,665M163,604C178,608 207,611 249,611C341,611 404,573 404,486C404,409 345,358 252,358l-89,0z"/>
+<glyph unicode="S" horiz-adv-x="493" d="M42,33C78,9 149,-11 214,-11C373,-11 449,80 449,184C449,283 392,338 278,382C185,418 144,449 144,512C144,558 179,613 271,613C332,613 377,594 398,581l24,71C393,669 342,685 274,685C143,685 56,607 56,502C56,408 124,350 234,310C325,276 361,239 361,177C361,109 309,62 220,62C160,62 104,81 65,106z"/>
+<glyph unicode="T" horiz-adv-x="497" d="M204,0l88,0l0,600l206,0l0,74l-499,0l0,-74l205,0z"/>
+<glyph unicode="U" horiz-adv-x="647" d="M75,674l0,-397C75,67 179,-11 317,-11C463,-11 572,73 572,280l0,394l-88,0l0,-400C484,126 419,60 320,60C230,60 163,124 163,274l0,400z"/>
+<glyph unicode="a" horiz-adv-x="482" d="M413,297C413,393 377,494 229,494C168,494 109,477 69,452l20,-59C123,416 170,429 216,429C315,430 326,357 326,318l0,-10C139,309 35,245 35,128C35,58 85,-11 183,-11C252,-11 304,23 331,61l3,0l7,-61l79,0C415,33 413,74 413,116M328,163C328,155 327,145 324,135C310,94 269,54 205,54C161,54 123,80 123,138C123,232 232,249 328,247z"/>
+<glyph unicode="b" horiz-adv-x="569" d="M73,125C73,82 71,33 69,0l75,0l5,79l2,0C188,16 244,-11 314,-11C422,-11 532,75 532,248C532,394 448,494 327,494C249,494 193,460 162,406l-2,0l0,304l-87,0M160,280C160,294 162,306 165,317C183,383 239,425 298,425C393,425 443,342 443,245C443,134 389,59 296,59C232,59 180,101 164,162C161,172 160,183 160,194z"/>
+<glyph unicode="c" horiz-adv-x="448" d="M403,83C378,72 345,60 295,60C199,60 127,129 127,241C127,341 187,424 298,424C346,424 379,412 400,401l20,67C396,481 350,494 298,494C140,494 38,385 38,236C38,88 133,-11 279,-11C344,-11 395,6 418,17z"/>
+<glyph unicode="," horiz-adv-x="207" d="M78,-117C106,-70 150,41 174,126l-98,-10C65,43 38,-64 16,-124z"/>
+<glyph unicode="d" horiz-adv-x="564" d="M403,710l0,-289l-2,0C379,459 330,494 255,494C138,494 37,396 38,235C38,88 129,-11 246,-11C325,-11 383,30 409,84l3,0l4,-84l78,0C492,33 490,82 490,125l0,585M403,203C403,189 402,177 399,165C383,100 329,60 270,60C176,60 127,141 127,239C127,345 181,425 272,425C338,425 386,379 399,324C402,313 403,298 403,287z"/>
+<glyph unicode="e" horiz-adv-x="501" d="M462,226C464,236 465,249 465,267C465,356 424,494 265,494C124,494 38,380 38,234C38,88 127,-11 276,-11C353,-11 407,6 438,20l-16,63C390,69 351,58 288,58C199,58 124,107 122,226M123,289C130,350 168,431 258,431C357,431 381,344 380,289z"/>
+<glyph unicode="h" horiz-adv-x="555" d="M73,0l88,0l0,292C161,308 162,321 167,334C184,381 228,421 285,421C368,421 397,356 397,278l0,-278l88,0l0,288C485,454 381,494 316,494C283,494 252,485 226,470C199,455 177,432 163,407l-2,0l0,303l-88,0z"/>
+<glyph unicode="-" horiz-adv-x="307" d="M30,302l0,-64l247,0l0,64z"/>
+<glyph unicode="i" horiz-adv-x="234" d="M161,0l0,484l-88,0l0,-484M117,675C84,675 62,650 62,620C62,590 83,566 115,566C150,566 171,590 171,620C171,651 149,675 117,675z"/>
+<glyph unicode="k" horiz-adv-x="469" d="M160,710l-87,0l0,-710l87,0l0,182l45,50l166,-232l108,0l-213,285l186,199l-105,0l-143,-167C190,300 174,279 162,262l-2,0z"/>
+<glyph unicode="l" horiz-adv-x="236" d="M73,0l88,0l0,710l-88,0z"/>
+<glyph unicode="m" horiz-adv-x="834" d="M73,0l86,0l0,291C159,306 161,322 166,334C180,378 221,422 275,422C342,422 376,367 376,290l0,-290l86,0l0,299C462,315 465,330 469,343C485,385 523,422 574,422C644,422 679,367 679,273l0,-273l86,0l0,284C765,452 670,494 605,494C559,494 528,482 499,460C479,445 459,425 444,397l-2,0C421,454 371,494 306,494C225,494 180,451 153,405l-3,0l-4,79l-77,0C71,444 73,404 73,353z"/>
+<glyph unicode="n" horiz-adv-x="555" d="M73,0l88,0l0,291C161,306 163,321 167,332C183,381 228,422 285,422C368,422 397,357 397,279l0,-279l88,0l0,288C485,454 381,494 314,494C234,494 178,449 154,404l-2,0l-5,80l-78,0C72,444 73,404 73,353z"/>
+<glyph unicode="o" horiz-adv-x="549" d="M278,494C145,494 38,399 38,238C38,85 140,-11 270,-11C386,-11 511,67 511,246C511,393 417,494 278,494M276,428C380,428 421,325 421,243C421,134 358,55 274,55C188,55 128,135 128,241C128,332 173,428 276,428z"/>
+<glyph unicode="p" horiz-adv-x="569" d="M73,-198l87,0l0,263l2,0C191,17 247,-11 311,-11C425,-11 532,75 532,249C532,395 444,494 326,494C247,494 189,460 154,401l-2,0l-5,83l-78,0C71,438 73,388 73,326M160,281C160,292 163,305 166,316C182,382 239,424 299,424C392,424 443,341 443,245C443,134 389,58 296,58C233,58 180,100 164,161C161,172 160,184 160,197z"/>
+<glyph unicode="(" horiz-adv-x="284" d="M195,694C132,610 65,481 64,285C64,90 132,-38 195,-121l68,0C193,-21 138,106 138,284C138,466 190,595 263,694z"/>
+<glyph unicode=")" horiz-adv-x="284" d="M88,-121C151,-37 218,91 219,287C219,483 151,612 88,694l-68,0C91,594 145,467 145,287C145,107 90,-22 20,-121z"/>
+<glyph unicode="." horiz-adv-x="207" d="M110,-11C147,-11 171,16 171,52C171,89 147,115 112,115C77,115 52,88 52,52C52,16 76,-11 110,-11z"/>
+<glyph unicode="?" horiz-adv-x="406" d="M220,192l-2,25C215,268 231,313 275,365C323,422 361,471 361,539C361,615 309,686 194,686C141,686 85,670 51,646l24,-63C100,602 140,614 176,614C239,613 271,579 271,528C271,483 246,444 201,391C151,331 133,271 139,218l2,-26M178,-11C215,-11 238,16 238,51C238,88 215,114 179,114C145,114 120,88 120,51C120,16 144,-11 178,-11z"/>
+<glyph unicode="r" horiz-adv-x="327" d="M73,0l88,0l0,258C161,272 162,287 164,299C176,365 220,411 282,411C294,411 303,411 312,409l0,83C304,493 297,494 288,494C229,494 175,453 153,388l-3,0l-4,96l-77,0C72,439 73,390 73,333z"/>
+<glyph unicode="s" horiz-adv-x="396" d="M40,23C74,3 123,-11 176,-11C289,-11 356,49 356,135C356,207 312,249 229,280C166,305 138,323 138,363C138,399 166,429 218,429C263,429 298,412 317,400l21,64C312,481 269,494 220,494C117,494 53,430 53,352C53,294 94,247 182,215C246,191 271,169 271,127C271,86 241,55 178,55C134,55 88,73 61,89z"/>
+<glyph unicode="/" horiz-adv-x="343" d="M66,-39l280,725l-69,0l-278,-725z"/>
+<glyph unicode=" " horiz-adv-x="212"/>
+<glyph unicode="t" horiz-adv-x="331" d="M93,574l0,-90l-75,0l0,-67l75,0l0,-264C93,96 103,53 127,26C148,3 181,-11 222,-11C256,-11 283,-5 300,1l-4,67C283,64 269,62 245,62C196,62 179,96 179,156l0,261l126,0l0,67l-126,0l0,116z"/>
+<glyph unicode="2" horiz-adv-x="513" d="M460,0l0,73l-291,0l0,2l51,48C357,255 444,352 444,472C444,565 385,661 245,661C171,661 106,632 62,595l28,-62C120,558 169,588 228,588C325,588 356,527 356,461C356,363 280,279 114,121l-69,-67l0,-54z"/>
+<glyph unicode="u" horiz-adv-x="551" d="M478,484l-88,0l0,-296C390,171 387,155 382,143C366,103 325,62 266,62C187,62 158,125 158,217l0,267l-88,0l0,-283C70,32 161,-11 237,-11C323,-11 375,40 397,79l2,0l5,-79l78,0C479,38 478,82 478,133z"/>
+<glyph unicode="v" horiz-adv-x="481" d="M13,484l184,-484l84,0l190,484l-92,0l-94,-271C269,168 255,128 244,88l-3,0C231,128 218,168 202,213l-95,271z"/>
+<glyph unicode="x" horiz-adv-x="463" d="M16,484l164,-237l-172,-247l97,0l70,109C194,138 210,164 226,193l2,0C245,164 261,137 280,109l72,-109l99,0l-169,250l165,234l-96,0l-67,-103C267,355 251,330 235,302l-2,0C217,329 202,353 183,380l-69,104z"/>
+<glyph unicode="y" horiz-adv-x="471" d="M9,484l178,-446C192,27 194,20 194,15C194,10 191,3 187,-6C166,-51 137,-85 113,-104C87,-126 58,-140 36,-147l22,-73C80,-216 122,-201 166,-164C226,-111 269,-27 332,139l132,345l-93,0l-96,-284C263,165 253,128 244,99l-2,0C234,128 222,166 210,198l-105,286z"/>
+<glyph unicode="z" horiz-adv-x="428" d="M18,0l392,0l0,70l-282,0l0,2C150,96 169,121 190,148l216,281l0,55l-368,0l0,-70l262,0l0,-2C278,386 258,363 236,336l-218,-285z"/>
+</font>
+
+       <g>
+       <rect y="1.152" fill="#AAAAAA" stroke="#000000" width="256" height="36.887"/>
+       <text transform="matrix(1 0 0 1 27.7441 23.7046)" font-family="'MyriadPro-Regular'" font-size="14">Enter protected mode</text>
+</g>
+<g>
+       <rect y="45.642" fill="#AAAAAA" stroke="#000000" width="256" height="43.62"/>
+       <text transform="matrix(1 0 0 1 27.7441 71.5605)" font-family="'MyriadPro-Regular'" font-size="14">non-coherent HT enumeration</text>
+</g>
+<g>
+       <rect y="98.359" fill="#AAAAAA" stroke="#000000" width="256" height="60.15"/>
+       <text transform="matrix(1 0 0 1 27.7441 132.5435)" font-family="'MyriadPro-Regular'" font-size="14">coherent HT initialization</text>
+</g>
+<g>
+       <rect y="165.983" fill="#AAAAAA" stroke="#000000" width="256" height="68.421"/>
+       <text transform="matrix(1 0 0 1 27.7441 204.3022)" font-family="'MyriadPro-Regular'" font-size="14">Fallback / Normal?</text>
+</g>
+<g>
+       <rect y="243.893" fill="#AAAAAA" stroke="#000000" width="256" height="69.173"/>
+       <text transform="matrix(1 0 0 1 27.7441 282.5879)" font-family="'MyriadPro-Regular'" font-size="14">RAM initialization</text>
+</g>
+<g>
+       <rect y="410.747" fill="#AAAAAA" stroke="#000000" width="256" height="52.632"/>
+       <text transform="matrix(1 0 0 1 27.7441 432.7725)"><tspan x="0" y="0" font-family="'MyriadPro-Regular'" font-size="14">Create external tables (coreboot table,</tspan><tspan x="0" y="16.8" font-family="'MyriadPro-Regular'" font-size="14">ACPI, MP, PIRQ, DMI)</tspan></text>
+</g>
+<g>
+       <rect y="323.526" fill="#AAAAAA" stroke="#000000" width="256" height="77.443"/>
+       <text transform="matrix(1 0 0 1 27.7441 339.3154)"><tspan x="0" y="0" font-family="'MyriadPro-Regular'" font-size="14">Resource Allocation (PCI, PCIe, I2C, SIO, </tspan><tspan x="0" y="16.8" font-family="'MyriadPro-Regular'" font-size="14">CPU, mainboard...)</tspan></text>
+       <rect x="27.744" y="362.248" fill="#BCBCBC" width="228.256" height="38.722"/>
+</g>
+<g>
+       <rect y="473.781" fill="#AAAAAA" stroke="#000000" width="256" height="80.076"/>
+       <text transform="matrix(1 0 0 1 27.7441 497.4658)" font-family="'MyriadPro-Regular'" font-size="14">ELF / Payload Loader</text>
+       <rect x="27.744" y="507.993" fill="#BCBCBC" width="228.256" height="45.864"/>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,31.246 130.359,46.62 132.854,44.7 
+                                                                       132.027,51.206 131.201,57.711 124.701,56.845 118.201,55.98 120.608,54.127 110.178,33.439                                                                "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,57.636 132.228,59.101 133.828,45.178 133.062,44.181                                                     "/>
+                                                       <polygon fill="#231F20" points="131.152,57.643 132.28,59.108 118.41,57.093 117.644,56.096                                                       "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,81.246 130.359,96.62 132.854,94.7 
+                                                                       132.027,101.206 131.201,107.711 124.701,106.845 118.201,105.98 120.608,104.127 110.178,83.439                                                           "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,107.636 132.228,109.101 133.828,95.178 133.062,94.181                                                   "/>
+                                                       <polygon fill="#231F20" points="131.152,107.643 132.28,109.108 118.41,107.093 117.644,106.096                                                   "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,151.586 130.359,166.961 132.854,165.041 
+                                                                       132.027,171.546 131.201,178.052 124.701,177.186 118.201,176.321 120.608,174.468 110.178,153.78                                                          "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,177.977 132.228,179.442 133.828,165.519 133.062,164.522                                                         "/>
+                                                       <polygon fill="#231F20" points="131.152,177.983 132.28,179.449 118.41,177.434 117.644,176.437                                                   "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,227.013 130.359,242.387 132.854,240.467 
+                                                                       132.027,246.973 131.201,253.478 124.701,252.612 118.201,251.747 120.608,249.894 110.178,229.207                                                                 "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,253.403 132.228,254.868 133.828,240.945 133.062,239.948                                                         "/>
+                                                       <polygon fill="#231F20" points="131.152,253.41 132.28,254.875 118.41,252.86 117.644,251.863                                                     "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,303.013 130.359,318.388 132.854,316.468 
+                                                                       132.027,322.973 131.201,329.479 124.701,328.612 118.201,327.747 120.607,325.895 110.178,305.207                                                                 "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,329.404 132.228,330.868 133.829,316.945 133.062,315.948                                                         "/>
+                                                       <polygon fill="#231F20" points="131.152,329.41 132.28,330.876 118.41,328.86 117.643,327.864                                                     "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,395.872 130.359,411.247 132.854,409.327 
+                                                                       132.027,415.833 131.201,422.338 124.701,421.473 118.201,420.606 120.608,418.754 110.178,398.066                                                                 "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,422.264 132.228,423.728 133.828,409.805 133.062,408.808                                                         "/>
+                                                       <polygon fill="#231F20" points="131.152,422.27 132.28,423.735 118.41,421.72 117.644,420.724                                                     "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<g>
+       <g>
+               <g>
+                       <g>
+                               <g>
+                                       <g>
+                                               <g>
+                                                       <g>
+                                                               <polygon fill="#FFFFFF" stroke="#231F20" stroke-width="0.3876" points="113.028,452.152 130.359,467.528 132.854,465.608 
+                                                                       132.027,472.113 131.201,478.619 124.701,477.753 118.201,476.888 120.607,475.035 110.178,454.347                                                                 "/>
+                                                       </g>
+                                                       <polygon fill="#231F20" points="131.101,478.545 132.228,480.009 133.829,466.085 133.062,465.089                                                         "/>
+                                                       <polygon fill="#231F20" points="131.152,478.551 132.28,480.017 118.41,478.001 117.643,477.004                                                   "/>
+                                               </g>
+                                       </g>
+                               </g>
+                       </g>
+               </g>
+       </g>
+</g>
+<text transform="matrix(1 0 0 1 59.3232 385.7627)" font-family="'MyriadPro-Regular'" font-size="14">Drivers</text>
+<text transform="matrix(1 0 0 1 55.564 535.3789)" font-family="'MyriadPro-Regular'" font-size="14">Linux, FILO, SeaBIOS, ...</text>
+</svg>
index bc8d8967d5b7f8567548db009d8ce578d39598e2..757e7f4200c7da664ee56055356a21fd4508d79f 100644 (file)
@@ -1,59 +1,59 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
-        width="256px" height="512px" viewBox="0 0 256 512" enable-background="new 0 0 256 512" xml:space="preserve">\r
-<font horiz-adv-x="2048">\r
-<font-face font-family="ArialMT" units-per-em="2048" underline-position="-217" underline-thickness="150"/>\r
-<missing-glyph horiz-adv-x="1536" d="M256,0l0,1280l1024,0l0,-1280M288,32l960,0l0,1216l-960,0z"/>\r
-<glyph unicode=" " horiz-adv-x="569"/>\r
-<glyph unicode="(" horiz-adv-x="682" d="M479,-431C380,-306 296,-159 227,9C158,177 124,351 124,531C124,690 150,842 201,987C261,1156 354,1324 479,1491l129,0C527,1352 474,1253 448,1194C407,1102 375,1006 352,906C323,781 309,656 309,530C309,209 409,-111 608,-431z"/>\r
-<glyph unicode=")" horiz-adv-x="682" d="M253,-431l-129,0C323,-111 423,209 423,530C423,655 409,780 380,903C357,1003 326,1099 285,1191C259,1251 205,1351 124,1491l129,0C378,1324 471,1156 531,987C582,842 608,690 608,531C608,351 574,177 505,9C436,-159 352,-306 253,-431z"/>\r
-<glyph unicode="-" horiz-adv-x="682" d="M65,440l0,181l553,0l0,-181z"/>\r
-<glyph unicode="0" horiz-adv-x="1139" d="M85,723C85,896 103,1036 139,1142C174,1247 227,1329 298,1386C368,1443 456,1472 563,1472C642,1472 711,1456 770,1425C829,1393 878,1347 917,1288C956,1228 986,1155 1008,1070C1030,984 1041,868 1041,723C1041,551 1023,412 988,307C953,201 900,119 830,62C759,4 670,-25 563,-25C422,-25 311,26 230,127C133,249 85,448 85,723M270,723C270,482 298,322 355,243C411,163 480,123 563,123C646,123 715,163 772,243C828,323 856,483 856,723C856,964 828,1125 772,1204C715,1283 645,1323 561,1323C478,1323 412,1288 363,1218C301,1129 270,964 270,723z"/>\r
-<glyph unicode="1" horiz-adv-x="1139" d="M763,0l-180,0l0,1147C540,1106 483,1064 413,1023C342,982 279,951 223,930l0,174C324,1151 412,1209 487,1276C562,1343 616,1409 647,1472l116,0z"/>\r
-<glyph unicode="2" horiz-adv-x="1139" d="M1031,173l0,-173l-969,0C61,43 68,85 83,125C108,191 147,256 202,320C256,384 334,458 437,542C596,673 704,776 760,853C816,929 844,1001 844,1069C844,1140 819,1201 768,1250C717,1299 650,1323 568,1323C481,1323 412,1297 360,1245C308,1193 282,1121 281,1029l-185,19C109,1186 156,1291 239,1364C322,1436 433,1472 572,1472C713,1472 824,1433 906,1355C988,1277 1029,1180 1029,1065C1029,1006 1017,949 993,892C969,835 929,776 874,713C818,650 725,564 596,455C488,364 419,303 388,271C357,238 332,206 312,173z"/>\r
-<glyph unicode="3" horiz-adv-x="1139" d="M86,387l180,24C287,309 322,236 372,191C421,146 482,123 553,123C638,123 709,152 768,211C826,270 855,342 855,429C855,512 828,580 774,634C720,687 651,714 568,714C534,714 492,707 441,694l20,158C473,851 483,850 490,850C567,850 636,870 697,910C758,950 789,1012 789,1095C789,1161 767,1216 722,1259C677,1302 620,1324 549,1324C479,1324 421,1302 374,1258C327,1214 297,1148 284,1060l-180,32C126,1213 176,1306 254,1373C332,1439 429,1472 545,1472C625,1472 699,1455 766,1421C833,1386 885,1339 921,1280C956,1221 974,1158 974,1091C974,1028 957,970 923,918C889,866 839,825 772,794C859,774 926,733 974,670C1022,607 1046,528 1046,433C1046,305 999,197 906,108C813,19 695,-26 552,-26C423,-26 317,12 232,89C147,166 98,265 86,387z"/>\r
-<glyph unicode="8" horiz-adv-x="1139" d="M362,795C287,822 232,861 196,912C160,963 142,1023 142,1094C142,1201 180,1290 257,1363C334,1436 436,1472 563,1472C691,1472 794,1435 872,1361C950,1286 989,1196 989,1089C989,1021 971,962 936,912C900,861 846,822 773,795C863,766 932,718 979,653C1026,588 1049,510 1049,419C1049,294 1005,188 916,103C827,18 711,-25 566,-25C421,-25 305,18 216,104C127,189 83,296 83,424C83,519 107,599 156,664C204,728 273,772 362,795M326,1100C326,1031 348,974 393,930C438,886 496,864 567,864C636,864 693,886 738,930C782,973 804,1027 804,1090C804,1156 781,1212 736,1257C690,1302 633,1324 565,1324C496,1324 439,1302 394,1258C349,1214 326,1161 326,1100M268,423C268,372 280,322 305,274C329,226 365,189 413,163C461,136 513,123 568,123C654,123 725,151 781,206C837,261 865,332 865,417C865,504 836,575 779,632C721,689 649,717 562,717C477,717 407,689 352,633C296,577 268,507 268,423z"/>\r
-<glyph unicode="B" horiz-adv-x="1366" d="M150,0l0,1466l550,0C812,1466 902,1451 970,1422C1037,1392 1090,1346 1129,1285C1167,1223 1186,1158 1186,1091C1186,1028 1169,969 1135,914C1101,859 1050,814 981,780C1070,754 1138,710 1186,647C1233,584 1257,510 1257,425C1257,356 1243,293 1214,234C1185,175 1149,129 1106,97C1063,65 1010,41 946,25C881,8 802,0 709,0M344,850l317,0C747,850 809,856 846,867C895,882 933,906 958,940C983,974 995,1017 995,1068C995,1117 983,1160 960,1197C937,1234 903,1259 860,1273C817,1286 742,1293 637,1293l-293,0M344,173l365,0C772,173 816,175 841,180C886,188 923,201 953,220C983,239 1008,266 1027,302C1046,337 1056,378 1056,425C1056,480 1042,527 1014,568C986,608 947,636 898,653C848,669 776,677 683,677l-339,0z"/>\r
-<glyph unicode="C" horiz-adv-x="1479" d="M1204,514l194,-49C1357,306 1284,184 1179,101C1073,17 944,-25 791,-25C633,-25 505,7 406,72C307,136 231,229 180,351C128,473 102,604 102,744C102,897 131,1030 190,1144C248,1257 331,1344 439,1403C546,1462 665,1491 794,1491C941,1491 1064,1454 1164,1379C1264,1304 1334,1199 1373,1064l-191,-45C1148,1126 1099,1203 1034,1252C969,1301 888,1325 790,1325C677,1325 583,1298 508,1244C432,1190 379,1118 348,1027C317,936 302,842 302,745C302,620 320,512 357,419C393,326 449,256 526,210C603,164 686,141 775,141C884,141 976,172 1051,235C1126,298 1177,391 1204,514z"/>\r
-<glyph unicode="D" horiz-adv-x="1479" d="M158,0l0,1466l505,0C777,1466 864,1459 924,1445C1008,1426 1080,1391 1139,1340C1216,1275 1274,1191 1313,1090C1351,988 1370,872 1370,741C1370,630 1357,531 1331,445C1305,359 1272,288 1231,232C1190,175 1146,131 1098,99C1049,66 991,42 923,25C854,8 776,0 687,0M352,173l313,0C762,173 838,182 893,200C948,218 991,243 1024,276C1070,322 1106,384 1132,462C1157,539 1170,633 1170,744C1170,897 1145,1015 1095,1098C1044,1180 983,1235 911,1263C859,1283 775,1293 660,1293l-308,0z"/>\r
-<glyph unicode="I" horiz-adv-x="569" d="M191,0l0,1466l194,0l0,-1466z"/>\r
-<glyph unicode="L" horiz-adv-x="1139" d="M150,0l0,1466l194,0l0,-1293l722,0l0,-173z"/>\r
-<glyph unicode="P" horiz-adv-x="1366" d="M158,0l0,1466l553,0C808,1466 883,1461 934,1452C1006,1440 1066,1417 1115,1384C1164,1350 1203,1303 1233,1242C1262,1181 1277,1115 1277,1042C1277,917 1237,812 1158,726C1079,639 935,596 728,596l-376,0l0,-596M352,769l379,0C856,769 945,792 998,839C1051,886 1077,951 1077,1036C1077,1097 1062,1150 1031,1194C1000,1237 959,1266 908,1280C875,1289 815,1293 727,1293l-375,0z"/>\r
-<glyph unicode="S" horiz-adv-x="1366" d="M92,471l183,16C284,414 304,354 336,307C367,260 416,222 483,193C550,164 625,149 708,149C782,149 847,160 904,182C961,204 1003,234 1031,273C1058,311 1072,353 1072,398C1072,444 1059,484 1032,519C1005,553 961,582 900,605C861,620 774,644 639,677C504,709 410,739 356,768C286,805 234,850 200,905C165,959 148,1020 148,1087C148,1161 169,1230 211,1295C253,1359 314,1408 395,1441C476,1474 565,1491 664,1491C773,1491 869,1474 952,1439C1035,1404 1098,1352 1143,1284C1188,1216 1212,1139 1215,1053l-186,-14C1019,1132 985,1202 928,1249C870,1296 785,1320 672,1320C555,1320 469,1299 416,1256C362,1213 335,1161 335,1100C335,1047 354,1004 392,970C429,936 527,901 685,866C842,830 950,799 1009,772C1094,733 1157,683 1198,623C1239,562 1259,493 1259,414C1259,336 1237,263 1192,194C1147,125 1083,71 1000,33C916,-6 822,-25 717,-25C584,-25 473,-6 384,33C294,72 224,130 173,208C122,285 95,373 92,471z"/>\r
-<glyph unicode="T" horiz-adv-x="1251" d="M531,0l0,1293l-483,0l0,173l1162,0l0,-173l-485,0l0,-1293z"/>\r
-<glyph unicode="U" horiz-adv-x="1479" d="M1120,1466l194,0l0,-847C1314,472 1297,355 1264,268C1231,181 1171,111 1084,57C997,2 882,-25 741,-25C604,-25 491,-1 404,46C317,93 254,162 217,252C180,341 161,464 161,619l0,847l194,0l0,-846C355,493 367,399 391,339C414,278 455,232 513,199C570,166 641,150 724,150C867,150 968,182 1029,247C1090,312 1120,436 1120,620z"/>\r
-<glyph unicode="X" horiz-adv-x="1366" d="M9,0l567,764l-500,702l231,0l266,-376C628,1012 668,952 691,910C724,963 762,1019 807,1077l295,389l211,0l-515,-691l555,-775l-240,0l-369,523C723,553 702,586 680,621C647,568 624,531 610,511l-368,-511z"/>\r
-</font>\r
-\r
-       <rect x="7.465" y="10.627" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>\r
-<rect x="150.491" y="10.923" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.178"/>\r
-<rect x="8.479" y="129.379" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>\r
-<rect x="150.491" y="129.674" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.178"/>\r
-<rect x="8.479" y="241.805" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>\r
-<rect x="150.491" y="242.1" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.177"/>\r
-<line fill="none" stroke="#000000" x1="48.716" y1="91.101" x2="48.716" y2="129.379"/>\r
-<line fill="none" stroke="#000000" x1="88.953" y1="50.864" x2="150.491" y2="51.012"/>\r
-<line fill="none" stroke="#000000" x1="88.953" y1="169.763" x2="150.491" y2="169.763"/>\r
-<line fill="none" stroke="#000000" x1="190.729" y1="91.101" x2="190.729" y2="129.379"/>\r
-<line fill="none" stroke="#000000" x1="48.716" y1="209.852" x2="48.716" y2="241.805"/>\r
-<line fill="none" stroke="#000000" x1="88.953" y1="282.189" x2="150.491" y2="282.189"/>\r
-<text transform="matrix(1 0 0 1 23.6948 57.3003)" font-family="'ArialMT'" font-size="18">CPU2</text>\r
-<text transform="matrix(1 0 0 1 22.3374 174.46)" font-family="'ArialMT'" font-size="18">CPU0</text>\r
-<text transform="matrix(1 0 0 1 169.082 55.1167)" font-family="'ArialMT'" font-size="18">CPU3</text>\r
-<text transform="matrix(1 0 0 1 169.082 175.8271)" font-family="'ArialMT'" font-size="18">CPU1</text>\r
-<text transform="matrix(1 0 0 1 22.6807 277.1895)"><tspan x="0" y="0" font-family="'ArialMT'" font-size="18">PCI-X</tspan><tspan x="0" y="21.601" font-family="'ArialMT'" font-size="18">(8131)</tspan></text>\r
-<text transform="matrix(1 0 0 1 169.082 275.1895)"><tspan x="0" y="0" font-family="'ArialMT'" font-size="18">  SB</tspan><tspan x="0" y="21.6" font-family="'ArialMT'" font-size="18">(8111)</tspan></text>\r
-<text transform="matrix(1 0 0 1 93.0947 63.8721)" font-family="'ArialMT'" font-size="10">LDT1</text>\r
-<text transform="matrix(1 0 0 1 124.5088 46.7715)" font-family="'ArialMT'" font-size="10">LDT1</text>\r
-<text transform="matrix(1 0 0 1 196.6982 102.9844)" font-family="'ArialMT'" font-size="10">LDT0</text>\r
-<text transform="matrix(1 0 0 1 161.1953 126.0615)" font-family="'ArialMT'" font-size="10">LDT1</text>\r
-<text transform="matrix(1 0 0 1 22.3374 126.0615)" font-family="'ArialMT'" font-size="10">LDT2</text>\r
-<text transform="matrix(1 0 0 1 55.2783 103.5767)" font-family="'ArialMT'" font-size="10">LDT0</text>\r
-<text transform="matrix(1 0 0 1 52.9111 221.3276)" font-family="'ArialMT'" font-size="10">LDT0</text>\r
-<text transform="matrix(1 0 0 1 93.0947 181.6719)" font-family="'ArialMT'" font-size="10">LDT1</text>\r
-<text transform="matrix(1 0 0 1 124.5088 166.2979)" font-family="'ArialMT'" font-size="10">LDT0</text>\r
-<ellipse fill="#FF0606" cx="150.491" cy="51.012" rx="4.438" ry="4.563"/>\r
-<ellipse fill="#FF0606" cx="88.953" cy="169.763" rx="4.438" ry="4.563"/>\r
-<ellipse fill="#FF0606" cx="190.729" cy="129.379" rx="4.438" ry="4.563"/>\r
-</svg>\r
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        width="256px" height="512px" viewBox="0 0 256 512" enable-background="new 0 0 256 512" xml:space="preserve">
+<font horiz-adv-x="2048">
+<font-face font-family="ArialMT" units-per-em="2048" underline-position="-217" underline-thickness="150"/>
+<missing-glyph horiz-adv-x="1536" d="M256,0l0,1280l1024,0l0,-1280M288,32l960,0l0,1216l-960,0z"/>
+<glyph unicode=" " horiz-adv-x="569"/>
+<glyph unicode="(" horiz-adv-x="682" d="M479,-431C380,-306 296,-159 227,9C158,177 124,351 124,531C124,690 150,842 201,987C261,1156 354,1324 479,1491l129,0C527,1352 474,1253 448,1194C407,1102 375,1006 352,906C323,781 309,656 309,530C309,209 409,-111 608,-431z"/>
+<glyph unicode=")" horiz-adv-x="682" d="M253,-431l-129,0C323,-111 423,209 423,530C423,655 409,780 380,903C357,1003 326,1099 285,1191C259,1251 205,1351 124,1491l129,0C378,1324 471,1156 531,987C582,842 608,690 608,531C608,351 574,177 505,9C436,-159 352,-306 253,-431z"/>
+<glyph unicode="-" horiz-adv-x="682" d="M65,440l0,181l553,0l0,-181z"/>
+<glyph unicode="0" horiz-adv-x="1139" d="M85,723C85,896 103,1036 139,1142C174,1247 227,1329 298,1386C368,1443 456,1472 563,1472C642,1472 711,1456 770,1425C829,1393 878,1347 917,1288C956,1228 986,1155 1008,1070C1030,984 1041,868 1041,723C1041,551 1023,412 988,307C953,201 900,119 830,62C759,4 670,-25 563,-25C422,-25 311,26 230,127C133,249 85,448 85,723M270,723C270,482 298,322 355,243C411,163 480,123 563,123C646,123 715,163 772,243C828,323 856,483 856,723C856,964 828,1125 772,1204C715,1283 645,1323 561,1323C478,1323 412,1288 363,1218C301,1129 270,964 270,723z"/>
+<glyph unicode="1" horiz-adv-x="1139" d="M763,0l-180,0l0,1147C540,1106 483,1064 413,1023C342,982 279,951 223,930l0,174C324,1151 412,1209 487,1276C562,1343 616,1409 647,1472l116,0z"/>
+<glyph unicode="2" horiz-adv-x="1139" d="M1031,173l0,-173l-969,0C61,43 68,85 83,125C108,191 147,256 202,320C256,384 334,458 437,542C596,673 704,776 760,853C816,929 844,1001 844,1069C844,1140 819,1201 768,1250C717,1299 650,1323 568,1323C481,1323 412,1297 360,1245C308,1193 282,1121 281,1029l-185,19C109,1186 156,1291 239,1364C322,1436 433,1472 572,1472C713,1472 824,1433 906,1355C988,1277 1029,1180 1029,1065C1029,1006 1017,949 993,892C969,835 929,776 874,713C818,650 725,564 596,455C488,364 419,303 388,271C357,238 332,206 312,173z"/>
+<glyph unicode="3" horiz-adv-x="1139" d="M86,387l180,24C287,309 322,236 372,191C421,146 482,123 553,123C638,123 709,152 768,211C826,270 855,342 855,429C855,512 828,580 774,634C720,687 651,714 568,714C534,714 492,707 441,694l20,158C473,851 483,850 490,850C567,850 636,870 697,910C758,950 789,1012 789,1095C789,1161 767,1216 722,1259C677,1302 620,1324 549,1324C479,1324 421,1302 374,1258C327,1214 297,1148 284,1060l-180,32C126,1213 176,1306 254,1373C332,1439 429,1472 545,1472C625,1472 699,1455 766,1421C833,1386 885,1339 921,1280C956,1221 974,1158 974,1091C974,1028 957,970 923,918C889,866 839,825 772,794C859,774 926,733 974,670C1022,607 1046,528 1046,433C1046,305 999,197 906,108C813,19 695,-26 552,-26C423,-26 317,12 232,89C147,166 98,265 86,387z"/>
+<glyph unicode="8" horiz-adv-x="1139" d="M362,795C287,822 232,861 196,912C160,963 142,1023 142,1094C142,1201 180,1290 257,1363C334,1436 436,1472 563,1472C691,1472 794,1435 872,1361C950,1286 989,1196 989,1089C989,1021 971,962 936,912C900,861 846,822 773,795C863,766 932,718 979,653C1026,588 1049,510 1049,419C1049,294 1005,188 916,103C827,18 711,-25 566,-25C421,-25 305,18 216,104C127,189 83,296 83,424C83,519 107,599 156,664C204,728 273,772 362,795M326,1100C326,1031 348,974 393,930C438,886 496,864 567,864C636,864 693,886 738,930C782,973 804,1027 804,1090C804,1156 781,1212 736,1257C690,1302 633,1324 565,1324C496,1324 439,1302 394,1258C349,1214 326,1161 326,1100M268,423C268,372 280,322 305,274C329,226 365,189 413,163C461,136 513,123 568,123C654,123 725,151 781,206C837,261 865,332 865,417C865,504 836,575 779,632C721,689 649,717 562,717C477,717 407,689 352,633C296,577 268,507 268,423z"/>
+<glyph unicode="B" horiz-adv-x="1366" d="M150,0l0,1466l550,0C812,1466 902,1451 970,1422C1037,1392 1090,1346 1129,1285C1167,1223 1186,1158 1186,1091C1186,1028 1169,969 1135,914C1101,859 1050,814 981,780C1070,754 1138,710 1186,647C1233,584 1257,510 1257,425C1257,356 1243,293 1214,234C1185,175 1149,129 1106,97C1063,65 1010,41 946,25C881,8 802,0 709,0M344,850l317,0C747,850 809,856 846,867C895,882 933,906 958,940C983,974 995,1017 995,1068C995,1117 983,1160 960,1197C937,1234 903,1259 860,1273C817,1286 742,1293 637,1293l-293,0M344,173l365,0C772,173 816,175 841,180C886,188 923,201 953,220C983,239 1008,266 1027,302C1046,337 1056,378 1056,425C1056,480 1042,527 1014,568C986,608 947,636 898,653C848,669 776,677 683,677l-339,0z"/>
+<glyph unicode="C" horiz-adv-x="1479" d="M1204,514l194,-49C1357,306 1284,184 1179,101C1073,17 944,-25 791,-25C633,-25 505,7 406,72C307,136 231,229 180,351C128,473 102,604 102,744C102,897 131,1030 190,1144C248,1257 331,1344 439,1403C546,1462 665,1491 794,1491C941,1491 1064,1454 1164,1379C1264,1304 1334,1199 1373,1064l-191,-45C1148,1126 1099,1203 1034,1252C969,1301 888,1325 790,1325C677,1325 583,1298 508,1244C432,1190 379,1118 348,1027C317,936 302,842 302,745C302,620 320,512 357,419C393,326 449,256 526,210C603,164 686,141 775,141C884,141 976,172 1051,235C1126,298 1177,391 1204,514z"/>
+<glyph unicode="D" horiz-adv-x="1479" d="M158,0l0,1466l505,0C777,1466 864,1459 924,1445C1008,1426 1080,1391 1139,1340C1216,1275 1274,1191 1313,1090C1351,988 1370,872 1370,741C1370,630 1357,531 1331,445C1305,359 1272,288 1231,232C1190,175 1146,131 1098,99C1049,66 991,42 923,25C854,8 776,0 687,0M352,173l313,0C762,173 838,182 893,200C948,218 991,243 1024,276C1070,322 1106,384 1132,462C1157,539 1170,633 1170,744C1170,897 1145,1015 1095,1098C1044,1180 983,1235 911,1263C859,1283 775,1293 660,1293l-308,0z"/>
+<glyph unicode="I" horiz-adv-x="569" d="M191,0l0,1466l194,0l0,-1466z"/>
+<glyph unicode="L" horiz-adv-x="1139" d="M150,0l0,1466l194,0l0,-1293l722,0l0,-173z"/>
+<glyph unicode="P" horiz-adv-x="1366" d="M158,0l0,1466l553,0C808,1466 883,1461 934,1452C1006,1440 1066,1417 1115,1384C1164,1350 1203,1303 1233,1242C1262,1181 1277,1115 1277,1042C1277,917 1237,812 1158,726C1079,639 935,596 728,596l-376,0l0,-596M352,769l379,0C856,769 945,792 998,839C1051,886 1077,951 1077,1036C1077,1097 1062,1150 1031,1194C1000,1237 959,1266 908,1280C875,1289 815,1293 727,1293l-375,0z"/>
+<glyph unicode="S" horiz-adv-x="1366" d="M92,471l183,16C284,414 304,354 336,307C367,260 416,222 483,193C550,164 625,149 708,149C782,149 847,160 904,182C961,204 1003,234 1031,273C1058,311 1072,353 1072,398C1072,444 1059,484 1032,519C1005,553 961,582 900,605C861,620 774,644 639,677C504,709 410,739 356,768C286,805 234,850 200,905C165,959 148,1020 148,1087C148,1161 169,1230 211,1295C253,1359 314,1408 395,1441C476,1474 565,1491 664,1491C773,1491 869,1474 952,1439C1035,1404 1098,1352 1143,1284C1188,1216 1212,1139 1215,1053l-186,-14C1019,1132 985,1202 928,1249C870,1296 785,1320 672,1320C555,1320 469,1299 416,1256C362,1213 335,1161 335,1100C335,1047 354,1004 392,970C429,936 527,901 685,866C842,830 950,799 1009,772C1094,733 1157,683 1198,623C1239,562 1259,493 1259,414C1259,336 1237,263 1192,194C1147,125 1083,71 1000,33C916,-6 822,-25 717,-25C584,-25 473,-6 384,33C294,72 224,130 173,208C122,285 95,373 92,471z"/>
+<glyph unicode="T" horiz-adv-x="1251" d="M531,0l0,1293l-483,0l0,173l1162,0l0,-173l-485,0l0,-1293z"/>
+<glyph unicode="U" horiz-adv-x="1479" d="M1120,1466l194,0l0,-847C1314,472 1297,355 1264,268C1231,181 1171,111 1084,57C997,2 882,-25 741,-25C604,-25 491,-1 404,46C317,93 254,162 217,252C180,341 161,464 161,619l0,847l194,0l0,-846C355,493 367,399 391,339C414,278 455,232 513,199C570,166 641,150 724,150C867,150 968,182 1029,247C1090,312 1120,436 1120,620z"/>
+<glyph unicode="X" horiz-adv-x="1366" d="M9,0l567,764l-500,702l231,0l266,-376C628,1012 668,952 691,910C724,963 762,1019 807,1077l295,389l211,0l-515,-691l555,-775l-240,0l-369,523C723,553 702,586 680,621C647,568 624,531 610,511l-368,-511z"/>
+</font>
+
+       <rect x="7.465" y="10.627" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>
+<rect x="150.491" y="10.923" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.178"/>
+<rect x="8.479" y="129.379" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>
+<rect x="150.491" y="129.674" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.178"/>
+<rect x="8.479" y="241.805" fill="#A0A0A0" stroke="#000000" width="80.473" height="80.473"/>
+<rect x="150.491" y="242.1" fill="#A0A0A0" stroke="#000000" width="80.474" height="80.177"/>
+<line fill="none" stroke="#000000" x1="48.716" y1="91.101" x2="48.716" y2="129.379"/>
+<line fill="none" stroke="#000000" x1="88.953" y1="50.864" x2="150.491" y2="51.012"/>
+<line fill="none" stroke="#000000" x1="88.953" y1="169.763" x2="150.491" y2="169.763"/>
+<line fill="none" stroke="#000000" x1="190.729" y1="91.101" x2="190.729" y2="129.379"/>
+<line fill="none" stroke="#000000" x1="48.716" y1="209.852" x2="48.716" y2="241.805"/>
+<line fill="none" stroke="#000000" x1="88.953" y1="282.189" x2="150.491" y2="282.189"/>
+<text transform="matrix(1 0 0 1 23.6948 57.3003)" font-family="'ArialMT'" font-size="18">CPU2</text>
+<text transform="matrix(1 0 0 1 22.3374 174.46)" font-family="'ArialMT'" font-size="18">CPU0</text>
+<text transform="matrix(1 0 0 1 169.082 55.1167)" font-family="'ArialMT'" font-size="18">CPU3</text>
+<text transform="matrix(1 0 0 1 169.082 175.8271)" font-family="'ArialMT'" font-size="18">CPU1</text>
+<text transform="matrix(1 0 0 1 22.6807 277.1895)"><tspan x="0" y="0" font-family="'ArialMT'" font-size="18">PCI-X</tspan><tspan x="0" y="21.601" font-family="'ArialMT'" font-size="18">(8131)</tspan></text>
+<text transform="matrix(1 0 0 1 169.082 275.1895)"><tspan x="0" y="0" font-family="'ArialMT'" font-size="18">  SB</tspan><tspan x="0" y="21.6" font-family="'ArialMT'" font-size="18">(8111)</tspan></text>
+<text transform="matrix(1 0 0 1 93.0947 63.8721)" font-family="'ArialMT'" font-size="10">LDT1</text>
+<text transform="matrix(1 0 0 1 124.5088 46.7715)" font-family="'ArialMT'" font-size="10">LDT1</text>
+<text transform="matrix(1 0 0 1 196.6982 102.9844)" font-family="'ArialMT'" font-size="10">LDT0</text>
+<text transform="matrix(1 0 0 1 161.1953 126.0615)" font-family="'ArialMT'" font-size="10">LDT1</text>
+<text transform="matrix(1 0 0 1 22.3374 126.0615)" font-family="'ArialMT'" font-size="10">LDT2</text>
+<text transform="matrix(1 0 0 1 55.2783 103.5767)" font-family="'ArialMT'" font-size="10">LDT0</text>
+<text transform="matrix(1 0 0 1 52.9111 221.3276)" font-family="'ArialMT'" font-size="10">LDT0</text>
+<text transform="matrix(1 0 0 1 93.0947 181.6719)" font-family="'ArialMT'" font-size="10">LDT1</text>
+<text transform="matrix(1 0 0 1 124.5088 166.2979)" font-family="'ArialMT'" font-size="10">LDT0</text>
+<ellipse fill="#FF0606" cx="150.491" cy="51.012" rx="4.438" ry="4.563"/>
+<ellipse fill="#FF0606" cx="88.953" cy="169.763" rx="4.438" ry="4.563"/>
+<ellipse fill="#FF0606" cx="190.729" cy="129.379" rx="4.438" ry="4.563"/>
+</svg>
index 9266ce5c34b0b51682fea0708bab666708fa03f7..492262456c1ba204b8d2ac159a312dcdffb2d83f 100644 (file)
-0x00000001, /* Header Version  */\r
-0x0000000d, /* Patch ID                */\r
-0x11032004, /* DATE            */\r
-0x00000f41, /* CPUID           */\r
-0xa3430d74, /* Checksum                */\r
-0x00000001, /* Loader Version  */\r
-0x000000bd, /* Platform ID     */\r
-0x00000fd0, /* Data size       */\r
-0x00001000, /* Total size      */\r
-0x00000000, /* reserved                */\r
-0x00000000, /* reserved                */\r
-0x00000000, /* reserved                */\r
-0x23869663,\r
-0x00e8d132,\r
-0xc1efa329,\r
-0x20662968,\r
-0xb833cad6,\r
-0x78012780,\r
-0x0971cf44,\r
-0xda1410ae,\r
-0xece61219,\r
-0x5ec0a10c,\r
-0x5a1c529c,\r
-0x9b5e4fac,\r
-0x35fee068,\r
-0x24bb3539,\r
-0xa6c23421,\r
-0x0309a01d,\r
-0x80331c7b,\r
-0x960d5da2,\r
-0x56d31115,\r
-0xdaadb98b,\r
-0x8d5c0ca8,\r
-0xc1fc4f86,\r
-0xef6ee956,\r
-0x512c9483,\r
-0x08a9c125,\r
-0x03b95162,\r
-0x6499668c,\r
-0x25e15127,\r
-0xfb4f0f0b,\r
-0x10d1b2c3,\r
-0x542be728,\r
-0xa0f11cc9,\r
-0xa5bc6bd2,\r
-0xf3b7cc86,\r
-0xe4a91466,\r
-0x41eceee1,\r
-0x5beb249b,\r
-0x6ab82791,\r
-0x2c5a86ac,\r
-0x90c2865d,\r
-0x4702c4a5,\r
-0xbddad5f1,\r
-0xb2e224fb,\r
-0x0ffb50d3,\r
-0x13c6933c,\r
-0xc573b9df,\r
-0x908510f6,\r
-0xca6f3a9e,\r
-0x2049f489,\r
-0xe20b8848,\r
-0xfd659d6e,\r
-0xc9afd397,\r
-0x1432aa70,\r
-0x62c3e20c,\r
-0xee6dda59,\r
-0xe8601135,\r
-0xa9e30f8e,\r
-0x691b59e5,\r
-0x0446816b,\r
-0xd63a3f0c,\r
-0x5d1b9d99,\r
-0xfe8d9637,\r
-0xee61a0a4,\r
-0xeeae5aa0,\r
-0x709d78e6,\r
-0x5468e7fb,\r
-0x7e0f2dc3,\r
-0x632591e1,\r
-0x990864bb,\r
-0x413a220b,\r
-0x5285bdcd,\r
-0xb7323fa6,\r
-0xfe0098ce,\r
-0xd05d24b2,\r
-0x51ee2e1e,\r
-0x0078c207,\r
-0x9d1e1514,\r
-0x1be23c59,\r
-0xa80398e4,\r
-0xe0fa94c8,\r
-0x2b2f841e,\r
-0x21144f67,\r
-0x0a6a1413,\r
-0xfa30499a,\r
-0xba49558e,\r
-0x1607d767,\r
-0xebd70987,\r
-0x00cb016d,\r
-0xac1de18a,\r
-0xfcde8566,\r
-0x23f51d05,\r
-0xb7368509,\r
-0x9b1947fd,\r
-0x0d0d3c22,\r
-0xfbeab67d,\r
-0xfc963120,\r
-0x0aeae56b,\r
-0x0dbe2aeb,\r
-0x6d4ba825,\r
-0xab4b8dae,\r
-0x23bbe7a0,\r
-0x53d38f2e,\r
-0x6ee7bed3,\r
-0x39869966,\r
-0x8e36076d,\r
-0x410dca57,\r
-0x133c4861,\r
-0xcc2920d0,\r
-0xb1cfc172,\r
-0xd3c2e94b,\r
-0x8cdb7550,\r
-0xcb14be86,\r
-0x1c72bb42,\r
-0x469a6066,\r
-0x912f65eb,\r
-0x173ac7b9,\r
-0xfa02afca,\r
-0x23fc44f2,\r
-0xbbf0c89f,\r
-0xa018ba5f,\r
-0x950654d1,\r
-0x1b6d7652,\r
-0xb2a04767,\r
-0x86630316,\r
-0xff3fd7b3,\r
-0x9c9b3aba,\r
-0xb7d6115b,\r
-0x7c7a354c,\r
-0x1761b195,\r
-0xc54b49dd,\r
-0x2e0f5f20,\r
-0xaf1e90b2,\r
-0x07056032,\r
-0x46ccdd94,\r
-0xcc751ec5,\r
-0x4774af8a,\r
-0x24a3dba1,\r
-0xa388bccc,\r
-0xacd1c25a,\r
-0x4ee406c1,\r
-0x9861931a,\r
-0x5bae36e2,\r
-0xafc6e087,\r
-0x8d36cd1b,\r
-0x25f894d1,\r
-0xd749fdaa,\r
-0x3cef917d,\r
-0xb85440c2,\r
-0x4d22a2bf,\r
-0x19703ee4,\r
-0xa5fd9e1e,\r
-0x76062779,\r
-0x14031f62,\r
-0x6e309271,\r
-0x55476f65,\r
-0xb4fd2411,\r
-0x554882db,\r
-0xee9d4d38,\r
-0x57faf730,\r
-0x730e0285,\r
-0xb882d382,\r
-0xc156852d,\r
-0xf2db8f7a,\r
-0xea52f3e4,\r
-0x323430d1,\r
-0x51ea5fe9,\r
-0x0929d601,\r
-0x8e6740cf,\r
-0x69c456e1,\r
-0xd9e2f5c1,\r
-0x0124bf3b,\r
-0x0220f415,\r
-0xfbe91365,\r
-0x2bc82d06,\r
-0x0a31f25c,\r
-0xbeaf32af,\r
-0x3c2175b7,\r
-0xe8f67a0e,\r
-0x177bb8fa,\r
-0x33b86eb3,\r
-0x3ba0e579,\r
-0x368fc48b,\r
-0xe6665da8,\r
-0x688bfd43,\r
-0x48448000,\r
-0xc5c99d34,\r
-0xab99cfeb,\r
-0x1ce9c58d,\r
-0x773ae448,\r
-0x3534d849,\r
-0x6d86470f,\r
-0x306db8d0,\r
-0x550c15ff,\r
-0x7a2c439a,\r
-0xe6f1b78f,\r
-0x0bf4cdd7,\r
-0xfbcab3d7,\r
-0x402e87ec,\r
-0xf4ee5874,\r
-0xc03c70d9,\r
-0x3b9ed9e6,\r
-0x04ef67e0,\r
-0xd04ae924,\r
-0xf6845607,\r
-0x5e58c954,\r
-0xc2fdf283,\r
-0xc558ae4e,\r
-0x8300ece1,\r
-0x7bbaea80,\r
-0xc5d0b0f1,\r
-0xfc9e8004,\r
-0xfcea494a,\r
-0x04f4eb47,\r
-0x129f505d,\r
-0xccbae019,\r
-0x59c0616f,\r
-0xaaba53a8,\r
-0x19d8a002,\r
-0x361fb171,\r
-0x00c4aee2,\r
-0x6bb0dfb0,\r
-0xc03d6b9a,\r
-0xabaed6fb,\r
-0xa23c48fe,\r
-0x50866e98,\r
-0xbb499854,\r
-0xb5730aad,\r
-0xbe89d93c,\r
-0xe6d35886,\r
-0x7ae05c20,\r
-0xc2708cbd,\r
-0xf8f18059,\r
-0xf492c48e,\r
-0x14121e3d,\r
-0x9e9dc5a7,\r
-0xafa3ef3a,\r
-0x17535114,\r
-0x08296547,\r
-0xe1ab5d3c,\r
-0x2e51d954,\r
-0x0e6953db,\r
-0xde0ea136,\r
-0xd1f37944,\r
-0x3074f7ed,\r
-0x3b196093,\r
-0x0efb3b56,\r
-0x3b904c2c,\r
-0xcef179ee,\r
-0xc854e7f5,\r
-0x48aa28ce,\r
-0x1c0cb17e,\r
-0xae4236b2,\r
-0x87c5dc18,\r
-0x7832ec05,\r
-0xc4212949,\r
-0xca5a40d2,\r
-0x8e8f431d,\r
-0x328df52b,\r
-0xe4dd2524,\r
-0x7b8ae78a,\r
-0x17ba24a3,\r
-0x25eb59d5,\r
-0x1a341b63,\r
-0x45f1e3f2,\r
-0x0e2d9cf8,\r
-0xa66c17e8,\r
-0x515bc934,\r
-0xfea866d3,\r
-0xd149deac,\r
-0x740a7cf5,\r
-0x2f47375b,\r
-0xa5fdd0c4,\r
-0xd8965720,\r
-0x4ecefd2f,\r
-0x1916443a,\r
-0x984995a9,\r
-0x7b919733,\r
-0x80f02747,\r
-0x30fe0d17,\r
-0x65a68843,\r
-0xdb0931ad,\r
-0x0929b113,\r
-0x1bd4cc0c,\r
-0x7b2f63fd,\r
-0x6238656c,\r
-0x8a1badab,\r
-0x6565a869,\r
-0xca48cce2,\r
-0x7ff6bdc3,\r
-0x772305d4,\r
-0x376639d3,\r
-0x56ed9f11,\r
-0x75e17cef,\r
-0x7dffbcf4,\r
-0xfbafb077,\r
-0x932aed24,\r
-0x8b04ebf4,\r
-0x768ac85f,\r
-0xb54a99f9,\r
-0xd4fdf692,\r
-0x43b09d0a,\r
-0x32d81423,\r
-0xcb2a74e6,\r
-0x59f40d29,\r
-0x6392b933,\r
-0x7a3bc72c,\r
-0xfa647af0,\r
-0x2c28e15f,\r
-0xa724e1b0,\r
-0x6174f8f6,\r
-0x651672ab,\r
-0xd8eb376a,\r
-0x61d18571,\r
-0xa9bab242,\r
-0x2ba20ac2,\r
-0x332c20a9,\r
-0x21e71331,\r
-0x7ba9dbe4,\r
-0x1e61e44d,\r
-0x07ee9579,\r
-0xd1846f7a,\r
-0xca29125b,\r
-0x11958b89,\r
-0xb6fe5a2b,\r
-0x249991b4,\r
-0x5f28c005,\r
-0x0b909d87,\r
-0x673159ab,\r
-0xf25d3b1a,\r
-0x2a7f0d31,\r
-0x2e741145,\r
-0x60c1525d,\r
-0x7a2996a7,\r
-0x5051ead4,\r
-0xb9473e57,\r
-0x7c5f9d0e,\r
-0x51584719,\r
-0xa25c2246,\r
-0xceec4103,\r
-0x813e68be,\r
-0xabf2eed8,\r
-0x4fb4988f,\r
-0x678fba46,\r
-0x801b82e1,\r
-0x7fc428dc,\r
-0xa30bf423,\r
-0xd1dc03db,\r
-0x65d1f1fb,\r
-0xfea39d25,\r
-0x7b8cfad4,\r
-0x7eda42af,\r
-0x4c7cb670,\r
-0x1ac54e69,\r
-0x6ecd00ae,\r
-0x2ff34b4e,\r
-0x0f7c1999,\r
-0x14713cb0,\r
-0x3942aea8,\r
-0x07832b5c,\r
-0x5cd3fa0c,\r
-0x918b4916,\r
-0xe9420e66,\r
-0x8bd0f43c,\r
-0x28e79a91,\r
-0x999c89a3,\r
-0x59da832c,\r
-0x3dd8cb18,\r
-0x67deb7fe,\r
-0xa4f503bb,\r
-0x77f8114f,\r
-0xe732a72b,\r
-0x7e8b8835,\r
-0x10192856,\r
-0x54da048f,\r
-0x8ea0f6cd,\r
-0x722ba57f,\r
-0x133ad6fc,\r
-0x7d486fb3,\r
-0x27764f83,\r
-0x8c0dff5f,\r
-0x9f137e77,\r
-0x5d6b4057,\r
-0xeef4eee0,\r
-0xb0e0e900,\r
-0xf37b72f1,\r
-0xec1b84f5,\r
-0x0a454136,\r
-0xc23a91a3,\r
-0x0ab3bae8,\r
-0x715496f9,\r
-0xc1082181,\r
-0xccf9217f,\r
-0x5213635d,\r
-0x2e29ab5b,\r
-0xb4574eef,\r
-0x2bc2fea8,\r
-0x1ee67ef8,\r
-0xd567c2b8,\r
-0xfc19ef2c,\r
-0xe19af740,\r
-0x28a28944,\r
-0x836be662,\r
-0xb0080f12,\r
-0xd6f61914,\r
-0x33c85c03,\r
-0x326e680f,\r
-0x87b45aa5,\r
-0xad7c015b,\r
-0x63e312a9,\r
-0x65fb08cf,\r
-0x5fca6d27,\r
-0x7b57bef5,\r
-0x466fa276,\r
-0x56c21f72,\r
-0x38fb8f1d,\r
-0xc1966d08,\r
-0x15d4c28b,\r
-0xeec1eade,\r
-0x905f5218,\r
-0x5be29b59,\r
-0xb64aa150,\r
-0xc8994548,\r
-0xe4bfb038,\r
-0xd63e54cf,\r
-0x98469c03,\r
-0xb28e3b7b,\r
-0xf852cae3,\r
-0xc76b8b09,\r
-0x16810021,\r
-0x8ea0bfec,\r
-0xdfc083e5,\r
-0x884c8453,\r
-0x908a80f2,\r
-0xb6d91870,\r
-0x56ad6422,\r
-0x05174668,\r
-0x380d8035,\r
-0xeef37603,\r
-0x38ff195e,\r
-0x44898288,\r
-0xb300620f,\r
-0xa814ec47,\r
-0xa58d3007,\r
-0x7d4536f5,\r
-0x2dfc2f4d,\r
-0xfa2ae308,\r
-0x24d4799f,\r
-0x1423df15,\r
-0x82dc572b,\r
-0xa3141ca3,\r
-0xa1210bb1,\r
-0xb7eecdc4,\r
-0x5d9ac524,\r
-0xb8f4b3fb,\r
-0x6cd8f8a8,\r
-0x0e745c45,\r
-0xb0041dbe,\r
-0x6ee22101,\r
-0xc9fb746b,\r
-0x69909b4d,\r
-0x9e63a31c,\r
-0xbc627065,\r
-0x6b24225b,\r
-0x1d2b80b1,\r
-0x4c08e46b,\r
-0x1f78a68c,\r
-0x75bc0a34,\r
-0x74d23ab8,\r
-0xb16d2786,\r
-0xfbb6fa5f,\r
-0xc9bbf303,\r
-0x69ebae66,\r
-0xcfa4bf29,\r
-0xaa69d19e,\r
-0x5d965c81,\r
-0x7cebac23,\r
-0x030b7aca,\r
-0x7983efba,\r
-0x03babdb7,\r
-0xd9d7a8bb,\r
-0xa939d7e1,\r
-0x6913d42f,\r
-0xfce3f3b5,\r
-0xb9d2a26b,\r
-0x32e614b2,\r
-0xbbb00851,\r
-0x4313ca42,\r
-0xe17a6d39,\r
-0x5b9f0631,\r
-0x90569ece,\r
-0xf980f983,\r
-0x13eb7233,\r
-0xc8da9166,\r
-0x60dbe5fc,\r
-0x4621997a,\r
-0xccd2a527,\r
-0x061180aa,\r
-0xa92467da,\r
-0x3dc79eef,\r
-0x39f31e91,\r
-0x9e45191c,\r
-0x7dcba672,\r
-0xfc23a8b8,\r
-0x1a773f6a,\r
-0x6fc6fa46,\r
-0x46b50e14,\r
-0x514bd261,\r
-0xe6cc3574,\r
-0x5a88dea2,\r
-0x9121d758,\r
-0x7f39e3bf,\r
-0x9ab043b6,\r
-0xc1007d0c,\r
-0xc3c3ff8e,\r
-0x08411386,\r
-0x0bd529d7,\r
-0xcaa9a1d8,\r
-0x27b19be2,\r
-0x95703f7e,\r
-0x44ab493a,\r
-0xcf1fc404,\r
-0x3f34062d,\r
-0xa56d454b,\r
-0x9464f996,\r
-0x1346eadf,\r
-0xdd6e6895,\r
-0x27b5ba10,\r
-0xb84c1d0c,\r
-0x5fa57ca4,\r
-0xad052de8,\r
-0xf5b4a3ae,\r
-0x6a61144d,\r
-0x48c00092,\r
-0x4897fad0,\r
-0x90b7b116,\r
-0xcdf29b2c,\r
-0xa41aac9a,\r
-0x147d09f7,\r
-0xebf3615d,\r
-0xb3ddf0b0,\r
-0xc8edc675,\r
-0x43cbf71b,\r
-0xfa0a0b5c,\r
-0xe0b63692,\r
-0x6c5870a9,\r
-0xe0b37be9,\r
-0xb16acc39,\r
-0xc55aed8c,\r
-0xd34fb041,\r
-0x24735885,\r
-0x0fff6e94,\r
-0x834181e8,\r
-0x56671872,\r
-0xb3f2e29b,\r
-0xfa383cd3,\r
-0xe585e5b6,\r
-0xa40cb894,\r
-0x1fe8376a,\r
-0xf794c60a,\r
-0xa3efdb18,\r
-0x0df1f1b4,\r
-0x54230798,\r
-0xd2a8ba49,\r
-0x349ce466,\r
-0xcbff13b4,\r
-0x71a63418,\r
-0x728ae615,\r
-0xf7c4f811,\r
-0x0dd072d8,\r
-0x9aa6fac7,\r
-0xa44210d0,\r
-0x2a1a85bf,\r
-0x1e18a8c6,\r
-0xbe2bb680,\r
-0xfed00f0e,\r
-0x2acc1b4b,\r
-0x4f049f6f,\r
-0x6f5aeec1,\r
-0x2db8f7b4,\r
-0xd61041a2,\r
-0x5cc7c861,\r
-0xb6ed3676,\r
-0x02aef566,\r
-0x2b6d41c8,\r
-0xaba9296e,\r
-0xf7b032cd,\r
-0xc290e538,\r
-0x584ad0f9,\r
-0x95289bc7,\r
-0x49b428b8,\r
-0x84bb41d4,\r
-0xdf0fcf91,\r
-0x9bd712a9,\r
-0xc6f730e1,\r
-0xe28b78d4,\r
-0x45b0480d,\r
-0x29d344bf,\r
-0xcd0101bb,\r
-0x18561b59,\r
-0xcfa84f65,\r
-0x76e798eb,\r
-0xac73f8af,\r
-0x71fe2488,\r
-0x207dd75d,\r
-0x198130e5,\r
-0x3604d44d,\r
-0xd895dc9b,\r
-0xf55fe7e2,\r
-0x4fed2e51,\r
-0xf434e20a,\r
-0x7c3204e8,\r
-0x4d653a59,\r
-0x6652a556,\r
-0x8713f1e2,\r
-0xa69dea42,\r
-0x2fd0ee37,\r
-0xe7617993,\r
-0xc0791c80,\r
-0x57e14435,\r
-0x87fcad6e,\r
-0x96505f56,\r
-0x838e7a38,\r
-0x78b228ab,\r
-0x84411d16,\r
-0x0b4e1d87,\r
-0x21f17d96,\r
-0x72021b3c,\r
-0xe69f4784,\r
-0x324fb9b4,\r
-0x041c7459,\r
-0x500ffe39,\r
-0x6e561c0f,\r
-0xadaf6fd7,\r
-0x0c91509f,\r
-0x8be04594,\r
-0x6a5ead5a,\r
-0x313c9f9d,\r
-0xe4754919,\r
-0x63d7cebc,\r
-0x02d0ad32,\r
-0x2dc3cdb7,\r
-0xd9b2e421,\r
-0xa1ad018c,\r
-0xd954f545,\r
-0x9f3871b2,\r
-0xf8a9a4a9,\r
-0x4cdc558d,\r
-0x300c9685,\r
-0x639f4b78,\r
-0x2181680d,\r
-0xb96442d6,\r
-0x7821a1a2,\r
-0x174a9e5b,\r
-0x79320590,\r
-0xf580c60c,\r
-0xba8539ce,\r
-0x59905669,\r
-0xc6f39c94,\r
-0xb57cc9bf,\r
-0xc2f7ad76,\r
-0x8d9ebc2d,\r
-0x6c33e47f,\r
-0x29294c84,\r
-0x49a2bef6,\r
-0x8aa6f79b,\r
-0x809f0eb5,\r
-0x3691aa7f,\r
-0xcf4b0e8f,\r
-0xec44f802,\r
-0x16bf83a7,\r
-0x82c00d36,\r
-0xa99071b1,\r
-0xe3815c76,\r
-0xc0835331,\r
-0xc794c55f,\r
-0x041b44af,\r
-0x2fa75171,\r
-0x985bd852,\r
-0xc4391e66,\r
-0x7bf08eaf,\r
-0x2b826882,\r
-0xfb8834dc,\r
-0x9128681e,\r
-0x6a2cb9ef,\r
-0x6d1d20f9,\r
-0x9f90ee4d,\r
-0xc48c3ee3,\r
-0xdd063585,\r
-0x82454044,\r
-0xf7077f1a,\r
-0x47e6e556,\r
-0xd803f7dd,\r
-0x98f67f71,\r
-0x9089e4ac,\r
-0xe7f09610,\r
-0xa9e3f93b,\r
-0x420c1550,\r
-0xc01f7710,\r
-0x0905da5e,\r
-0x02d71f99,\r
-0xbf36b473,\r
-0x50a96e32,\r
-0x2dedb8b9,\r
-0x9e3051a2,\r
-0x84c023c4,\r
-0xd43073b1,\r
-0x74f23fbb,\r
-0xd42a4487,\r
-0x266dfc42,\r
-0x6be0acdf,\r
-0xa986294c,\r
-0x3ee65aa8,\r
-0x19c1cf4f,\r
-0x2fdf8308,\r
-0xa6a64910,\r
-0xc3fa82e8,\r
-0x2943c8b8,\r
-0xf1a60b7b,\r
-0x4cc9ea04,\r
-0x3cc95270,\r
-0x054a8d2b,\r
-0xae7a4525,\r
-0x2e2abb62,\r
-0x24b9522b,\r
-0xb95a6668,\r
-0xad8c237d,\r
-0x1ea73bf8,\r
-0xff33f0d6,\r
-0x772a16a3,\r
-0xfefabdc4,\r
-0xb181234c,\r
-0xab59fb47,\r
-0x96f2c987,\r
-0xff0d4f54,\r
-0x6e938aba,\r
-0x727e6266,\r
-0xea0d851f,\r
-0x2ced3474,\r
-0x8c2e7718,\r
-0xa576c375,\r
-0xc97addeb,\r
-0x2f46a635,\r
-0xdb669986,\r
-0xa4333f93,\r
-0x7042c2c6,\r
-0x419fda5f,\r
-0x95b8aa3f,\r
-0x6ad05dc8,\r
-0x8b90655a,\r
-0xd8c77947,\r
-0x20508480,\r
-0xfa3cdf6b,\r
-0xdbb44af2,\r
-0x235941d0,\r
-0x3154c107,\r
-0x566bc32a,\r
-0x426fb2cd,\r
-0xd2010afa,\r
-0xe2775abe,\r
-0x6f543a20,\r
-0x2c626450,\r
-0x34f193f4,\r
-0x37ac5908,\r
-0x58a7eca6,\r
-0xc4859881,\r
-0x183393ff,\r
-0xab9abed9,\r
-0xde947d21,\r
-0xffec2b7d,\r
-0xb21b8788,\r
-0xb527117f,\r
-0x199dffe5,\r
-0xd7ebe4e6,\r
-0xc89a72b0,\r
-0x91cc3042,\r
-0x91bd3463,\r
-0x736e6f4f,\r
-0x0cc208bc,\r
-0x029f21cb,\r
-0x3f204418,\r
-0x050db787,\r
-0x71b56562,\r
-0xaf07f08f,\r
-0xaca4701f,\r
-0x88d4f2f8,\r
-0xf98fe016,\r
-0xb47672c6,\r
-0xed601c94,\r
-0x285db8b8,\r
-0x28a81c19,\r
-0x9e2763ce,\r
-0xe39741c0,\r
-0xcd9fce6d,\r
-0xe9917796,\r
-0xfdd3ebaf,\r
-0x99dcb253,\r
-0xe9aa0db4,\r
-0x3a65c0b0,\r
-0xb39c61fb,\r
-0x1f413c5e,\r
-0x60576c8c,\r
-0x48d6df34,\r
-0x0cbca786,\r
-0x4caff4b7,\r
-0x8473e181,\r
-0x36eed747,\r
-0x82f486af,\r
-0x79f02eed,\r
-0xab6886ed,\r
-0x06aef911,\r
-0xad42a654,\r
-0x5471c813,\r
-0xc8bbe710,\r
-0xfc65fd97,\r
-0x60f467af,\r
-0xf56b71d8,\r
-0xc1d6f193,\r
-0x3a1c42bf,\r
-0x46ce3b78,\r
-0x39472626,\r
-0x04dc137e,\r
-0xb48dc9dd,\r
-0xdfd27741,\r
-0x4718e5a2,\r
-0x00ba4728,\r
-0x855b661f,\r
-0x6d98577f,\r
-0xc3b48131,\r
-0x2b0384c1,\r
-0x8af572fe,\r
-0x760aa4e3,\r
-0x2f5b53fb,\r
-0xb9234297,\r
-0x401b47f5,\r
-0x44237cc0,\r
-0x2f7205f4,\r
-0x19b63c6e,\r
-0x7c375e6b,\r
-0x152c42d8,\r
-0x603731c7,\r
-0xc67601fb,\r
-0xa5d4826c,\r
-0x9068966f,\r
-0x864fe2f9,\r
-0xb37311d9,\r
-0xe6e4a34a,\r
-0xd46ee161,\r
-0xecd76c4a,\r
-0x90d0328a,\r
-0x4865b540,\r
-0xd2e13982,\r
-0x7e3925f4,\r
-0xc850a518,\r
-0x63bffcce,\r
-0x7cdb918f,\r
-0xcd8786d3,\r
-0xcf83df01,\r
-0x27122e50,\r
-0x0f014b76,\r
-0xde1485d7,\r
-0xa6ff496f,\r
-0xed0812f7,\r
-0x34efe965,\r
-0x12a63465,\r
-0xb83d9f77,\r
-0x040efa2e,\r
-0x4ac576d1,\r
-0x185430dd,\r
-0xb4271745,\r
-0x9bb58be2,\r
-0x7f55d4bb,\r
-0xca7dae0b,\r
-0x0bfe5147,\r
-0x4a9ade45,\r
-0x20bdc545,\r
-0xdf66689d,\r
-0x22e29493,\r
-0x31763c1f,\r
-0x2d021cd2,\r
-0x06286428,\r
-0xc7bba5d4,\r
-0x6bc42a0e,\r
-0x1c987082,\r
-0xd6c6c2f9,\r
-0x2c1ecdd0,\r
-0x84946249,\r
-0x42c1c41b,\r
-0x6d949e60,\r
-0x9dbb1571,\r
-0xf6b1df68,\r
-0x0705ae1a,\r
-0xa1ec5add,\r
-0x7e94d7c8,\r
-0x7d4d451d,\r
-0xd53c13d4,\r
-0x0204877b,\r
-0x0f0e44e0,\r
-0xdf25570f,\r
-0xd2a9adaf,\r
-0x556aeacf,\r
-0x2f985a30,\r
-0x706c42c6,\r
-0x2d5a76a5,\r
-0xdc428213,\r
-0xdf2864a2,\r
-0x0f6788a9,\r
-0xc764d3a6,\r
-0x9211d0ca,\r
-0x59e3f5cc,\r
-0xd31fd5b6,\r
-0xfa8b535b,\r
-0x2cac74bb,\r
-0xc43f36b2,\r
-0xf83b5bac,\r
-0x96c255bf,\r
-0x45915993,\r
-0x657d751a,\r
-0x9b86b994,\r
-0xddab62fd,\r
-0x1b6ac108,\r
-0x559073c9,\r
-0xe60a0bda,\r
-0xd65df6de,\r
-0x41f7e5d4,\r
-0x825a5701,\r
-0x377307b6,\r
-0x08176ce6,\r
-0x7a8a2c4a,\r
-0xd7ecb869,\r
-0x02710179,\r
-0x75e7517c,\r
-0xdfaf2c82,\r
-0x67590275,\r
-0x6ad621af,\r
-0xaedaa35c,\r
-0xfa8fbee3,\r
-0x9e5dda5f,\r
-0x09f571fa,\r
-0xe358dbfe,\r
-0x1b3300f1,\r
-0x05567c6b,\r
-0x5a9d335f,\r
-0x215114f8,\r
-0xd5744f0a,\r
-0x78ecc142,\r
-0x9b5f60b8,\r
-0x30f8fed2,\r
-0x5c013696,\r
-0x675c84de,\r
-0xdb50bbcc,\r
-0x7c504a4e,\r
-0x3ffc5fda,\r
-0x24b2c30a,\r
-0xac00d64a,\r
-0x97832b52,\r
-0xb34d9975,\r
-0x93c6cb4e,\r
-0x471bfcae,\r
-0xaabbb6d8,\r
-0x0bc6a5e5,\r
-0x6875c630,\r
-0xf4cce30c,\r
-0xdab0d64b,\r
-0x29aba8b9,\r
-0xe34b3cde,\r
-0x8654e470,\r
-0x2c5041f7,\r
-0xdcf5eff9,\r
-0x26a88f84,\r
-0x9d374761,\r
-0xefa60ac4,\r
-0xdf0d0fd3,\r
-0x72e37e59,\r
-0xa76d26e1,\r
-0x3ffe2408,\r
-0x13ecf42d,\r
-0x46de7cba,\r
-0x43330219,\r
-0xc2536a31,\r
-0xa69c4729,\r
-0x114990f8,\r
-0x3f08ed00,\r
-0xeaa05cae,\r
-0x08f06e57,\r
-0x30f4a62f,\r
-0x963a7557,\r
-0x631fb75f,\r
-0x1344a74b,\r
-0x1e80cef5,\r
-0x8a4f86dd,\r
-0x0f7f1c62,\r
-0xfe9f5809,\r
-0x710d86de,\r
-0x8939283d,\r
-0x19403076,\r
-0x26ce286b,\r
-0x6baaf798,\r
-0xbc1d2808,\r
-0xea980728,\r
-0x72288979,\r
-0x7c92be68,\r
-0x0a7af91b,\r
-0x7bb8059b,\r
-0xe7eca99c,\r
-0xd3a8819f,\r
-0xb9182916,\r
-0x0c48ba1e,\r
-0xb6aaf63b,\r
-0x10a740a6,\r
-0x0aa2e4e7,\r
-0x0bf27e94,\r
-0x6d266f86,\r
+0x00000001, /* Header Version  */
+0x0000000d, /* Patch ID                */
+0x11032004, /* DATE            */
+0x00000f41, /* CPUID           */
+0xa3430d74, /* Checksum                */
+0x00000001, /* Loader Version  */
+0x000000bd, /* Platform ID     */
+0x00000fd0, /* Data size       */
+0x00001000, /* Total size      */
+0x00000000, /* reserved                */
+0x00000000, /* reserved                */
+0x00000000, /* reserved                */
+0x23869663,
+0x00e8d132,
+0xc1efa329,
+0x20662968,
+0xb833cad6,
+0x78012780,
+0x0971cf44,
+0xda1410ae,
+0xece61219,
+0x5ec0a10c,
+0x5a1c529c,
+0x9b5e4fac,
+0x35fee068,
+0x24bb3539,
+0xa6c23421,
+0x0309a01d,
+0x80331c7b,
+0x960d5da2,
+0x56d31115,
+0xdaadb98b,
+0x8d5c0ca8,
+0xc1fc4f86,
+0xef6ee956,
+0x512c9483,
+0x08a9c125,
+0x03b95162,
+0x6499668c,
+0x25e15127,
+0xfb4f0f0b,
+0x10d1b2c3,
+0x542be728,
+0xa0f11cc9,
+0xa5bc6bd2,
+0xf3b7cc86,
+0xe4a91466,
+0x41eceee1,
+0x5beb249b,
+0x6ab82791,
+0x2c5a86ac,
+0x90c2865d,
+0x4702c4a5,
+0xbddad5f1,
+0xb2e224fb,
+0x0ffb50d3,
+0x13c6933c,
+0xc573b9df,
+0x908510f6,
+0xca6f3a9e,
+0x2049f489,
+0xe20b8848,
+0xfd659d6e,
+0xc9afd397,
+0x1432aa70,
+0x62c3e20c,
+0xee6dda59,
+0xe8601135,
+0xa9e30f8e,
+0x691b59e5,
+0x0446816b,
+0xd63a3f0c,
+0x5d1b9d99,
+0xfe8d9637,
+0xee61a0a4,
+0xeeae5aa0,
+0x709d78e6,
+0x5468e7fb,
+0x7e0f2dc3,
+0x632591e1,
+0x990864bb,
+0x413a220b,
+0x5285bdcd,
+0xb7323fa6,
+0xfe0098ce,
+0xd05d24b2,
+0x51ee2e1e,
+0x0078c207,
+0x9d1e1514,
+0x1be23c59,
+0xa80398e4,
+0xe0fa94c8,
+0x2b2f841e,
+0x21144f67,
+0x0a6a1413,
+0xfa30499a,
+0xba49558e,
+0x1607d767,
+0xebd70987,
+0x00cb016d,
+0xac1de18a,
+0xfcde8566,
+0x23f51d05,
+0xb7368509,
+0x9b1947fd,
+0x0d0d3c22,
+0xfbeab67d,
+0xfc963120,
+0x0aeae56b,
+0x0dbe2aeb,
+0x6d4ba825,
+0xab4b8dae,
+0x23bbe7a0,
+0x53d38f2e,
+0x6ee7bed3,
+0x39869966,
+0x8e36076d,
+0x410dca57,
+0x133c4861,
+0xcc2920d0,
+0xb1cfc172,
+0xd3c2e94b,
+0x8cdb7550,
+0xcb14be86,
+0x1c72bb42,
+0x469a6066,
+0x912f65eb,
+0x173ac7b9,
+0xfa02afca,
+0x23fc44f2,
+0xbbf0c89f,
+0xa018ba5f,
+0x950654d1,
+0x1b6d7652,
+0xb2a04767,
+0x86630316,
+0xff3fd7b3,
+0x9c9b3aba,
+0xb7d6115b,
+0x7c7a354c,
+0x1761b195,
+0xc54b49dd,
+0x2e0f5f20,
+0xaf1e90b2,
+0x07056032,
+0x46ccdd94,
+0xcc751ec5,
+0x4774af8a,
+0x24a3dba1,
+0xa388bccc,
+0xacd1c25a,
+0x4ee406c1,
+0x9861931a,
+0x5bae36e2,
+0xafc6e087,
+0x8d36cd1b,
+0x25f894d1,
+0xd749fdaa,
+0x3cef917d,
+0xb85440c2,
+0x4d22a2bf,
+0x19703ee4,
+0xa5fd9e1e,
+0x76062779,
+0x14031f62,
+0x6e309271,
+0x55476f65,
+0xb4fd2411,
+0x554882db,
+0xee9d4d38,
+0x57faf730,
+0x730e0285,
+0xb882d382,
+0xc156852d,
+0xf2db8f7a,
+0xea52f3e4,
+0x323430d1,
+0x51ea5fe9,
+0x0929d601,
+0x8e6740cf,
+0x69c456e1,
+0xd9e2f5c1,
+0x0124bf3b,
+0x0220f415,
+0xfbe91365,
+0x2bc82d06,
+0x0a31f25c,
+0xbeaf32af,
+0x3c2175b7,
+0xe8f67a0e,
+0x177bb8fa,
+0x33b86eb3,
+0x3ba0e579,
+0x368fc48b,
+0xe6665da8,
+0x688bfd43,
+0x48448000,
+0xc5c99d34,
+0xab99cfeb,
+0x1ce9c58d,
+0x773ae448,
+0x3534d849,
+0x6d86470f,
+0x306db8d0,
+0x550c15ff,
+0x7a2c439a,
+0xe6f1b78f,
+0x0bf4cdd7,
+0xfbcab3d7,
+0x402e87ec,
+0xf4ee5874,
+0xc03c70d9,
+0x3b9ed9e6,
+0x04ef67e0,
+0xd04ae924,
+0xf6845607,
+0x5e58c954,
+0xc2fdf283,
+0xc558ae4e,
+0x8300ece1,
+0x7bbaea80,
+0xc5d0b0f1,
+0xfc9e8004,
+0xfcea494a,
+0x04f4eb47,
+0x129f505d,
+0xccbae019,
+0x59c0616f,
+0xaaba53a8,
+0x19d8a002,
+0x361fb171,
+0x00c4aee2,
+0x6bb0dfb0,
+0xc03d6b9a,
+0xabaed6fb,
+0xa23c48fe,
+0x50866e98,
+0xbb499854,
+0xb5730aad,
+0xbe89d93c,
+0xe6d35886,
+0x7ae05c20,
+0xc2708cbd,
+0xf8f18059,
+0xf492c48e,
+0x14121e3d,
+0x9e9dc5a7,
+0xafa3ef3a,
+0x17535114,
+0x08296547,
+0xe1ab5d3c,
+0x2e51d954,
+0x0e6953db,
+0xde0ea136,
+0xd1f37944,
+0x3074f7ed,
+0x3b196093,
+0x0efb3b56,
+0x3b904c2c,
+0xcef179ee,
+0xc854e7f5,
+0x48aa28ce,
+0x1c0cb17e,
+0xae4236b2,
+0x87c5dc18,
+0x7832ec05,
+0xc4212949,
+0xca5a40d2,
+0x8e8f431d,
+0x328df52b,
+0xe4dd2524,
+0x7b8ae78a,
+0x17ba24a3,
+0x25eb59d5,
+0x1a341b63,
+0x45f1e3f2,
+0x0e2d9cf8,
+0xa66c17e8,
+0x515bc934,
+0xfea866d3,
+0xd149deac,
+0x740a7cf5,
+0x2f47375b,
+0xa5fdd0c4,
+0xd8965720,
+0x4ecefd2f,
+0x1916443a,
+0x984995a9,
+0x7b919733,
+0x80f02747,
+0x30fe0d17,
+0x65a68843,
+0xdb0931ad,
+0x0929b113,
+0x1bd4cc0c,
+0x7b2f63fd,
+0x6238656c,
+0x8a1badab,
+0x6565a869,
+0xca48cce2,
+0x7ff6bdc3,
+0x772305d4,
+0x376639d3,
+0x56ed9f11,
+0x75e17cef,
+0x7dffbcf4,
+0xfbafb077,
+0x932aed24,
+0x8b04ebf4,
+0x768ac85f,
+0xb54a99f9,
+0xd4fdf692,
+0x43b09d0a,
+0x32d81423,
+0xcb2a74e6,
+0x59f40d29,
+0x6392b933,
+0x7a3bc72c,
+0xfa647af0,
+0x2c28e15f,
+0xa724e1b0,
+0x6174f8f6,
+0x651672ab,
+0xd8eb376a,
+0x61d18571,
+0xa9bab242,
+0x2ba20ac2,
+0x332c20a9,
+0x21e71331,
+0x7ba9dbe4,
+0x1e61e44d,
+0x07ee9579,
+0xd1846f7a,
+0xca29125b,
+0x11958b89,
+0xb6fe5a2b,
+0x249991b4,
+0x5f28c005,
+0x0b909d87,
+0x673159ab,
+0xf25d3b1a,
+0x2a7f0d31,
+0x2e741145,
+0x60c1525d,
+0x7a2996a7,
+0x5051ead4,
+0xb9473e57,
+0x7c5f9d0e,
+0x51584719,
+0xa25c2246,
+0xceec4103,
+0x813e68be,
+0xabf2eed8,
+0x4fb4988f,
+0x678fba46,
+0x801b82e1,
+0x7fc428dc,
+0xa30bf423,
+0xd1dc03db,
+0x65d1f1fb,
+0xfea39d25,
+0x7b8cfad4,
+0x7eda42af,
+0x4c7cb670,
+0x1ac54e69,
+0x6ecd00ae,
+0x2ff34b4e,
+0x0f7c1999,
+0x14713cb0,
+0x3942aea8,
+0x07832b5c,
+0x5cd3fa0c,
+0x918b4916,
+0xe9420e66,
+0x8bd0f43c,
+0x28e79a91,
+0x999c89a3,
+0x59da832c,
+0x3dd8cb18,
+0x67deb7fe,
+0xa4f503bb,
+0x77f8114f,
+0xe732a72b,
+0x7e8b8835,
+0x10192856,
+0x54da048f,
+0x8ea0f6cd,
+0x722ba57f,
+0x133ad6fc,
+0x7d486fb3,
+0x27764f83,
+0x8c0dff5f,
+0x9f137e77,
+0x5d6b4057,
+0xeef4eee0,
+0xb0e0e900,
+0xf37b72f1,
+0xec1b84f5,
+0x0a454136,
+0xc23a91a3,
+0x0ab3bae8,
+0x715496f9,
+0xc1082181,
+0xccf9217f,
+0x5213635d,
+0x2e29ab5b,
+0xb4574eef,
+0x2bc2fea8,
+0x1ee67ef8,
+0xd567c2b8,
+0xfc19ef2c,
+0xe19af740,
+0x28a28944,
+0x836be662,
+0xb0080f12,
+0xd6f61914,
+0x33c85c03,
+0x326e680f,
+0x87b45aa5,
+0xad7c015b,
+0x63e312a9,
+0x65fb08cf,
+0x5fca6d27,
+0x7b57bef5,
+0x466fa276,
+0x56c21f72,
+0x38fb8f1d,
+0xc1966d08,
+0x15d4c28b,
+0xeec1eade,
+0x905f5218,
+0x5be29b59,
+0xb64aa150,
+0xc8994548,
+0xe4bfb038,
+0xd63e54cf,
+0x98469c03,
+0xb28e3b7b,
+0xf852cae3,
+0xc76b8b09,
+0x16810021,
+0x8ea0bfec,
+0xdfc083e5,
+0x884c8453,
+0x908a80f2,
+0xb6d91870,
+0x56ad6422,
+0x05174668,
+0x380d8035,
+0xeef37603,
+0x38ff195e,
+0x44898288,
+0xb300620f,
+0xa814ec47,
+0xa58d3007,
+0x7d4536f5,
+0x2dfc2f4d,
+0xfa2ae308,
+0x24d4799f,
+0x1423df15,
+0x82dc572b,
+0xa3141ca3,
+0xa1210bb1,
+0xb7eecdc4,
+0x5d9ac524,
+0xb8f4b3fb,
+0x6cd8f8a8,
+0x0e745c45,
+0xb0041dbe,
+0x6ee22101,
+0xc9fb746b,
+0x69909b4d,
+0x9e63a31c,
+0xbc627065,
+0x6b24225b,
+0x1d2b80b1,
+0x4c08e46b,
+0x1f78a68c,
+0x75bc0a34,
+0x74d23ab8,
+0xb16d2786,
+0xfbb6fa5f,
+0xc9bbf303,
+0x69ebae66,
+0xcfa4bf29,
+0xaa69d19e,
+0x5d965c81,
+0x7cebac23,
+0x030b7aca,
+0x7983efba,
+0x03babdb7,
+0xd9d7a8bb,
+0xa939d7e1,
+0x6913d42f,
+0xfce3f3b5,
+0xb9d2a26b,
+0x32e614b2,
+0xbbb00851,
+0x4313ca42,
+0xe17a6d39,
+0x5b9f0631,
+0x90569ece,
+0xf980f983,
+0x13eb7233,
+0xc8da9166,
+0x60dbe5fc,
+0x4621997a,
+0xccd2a527,
+0x061180aa,
+0xa92467da,
+0x3dc79eef,
+0x39f31e91,
+0x9e45191c,
+0x7dcba672,
+0xfc23a8b8,
+0x1a773f6a,
+0x6fc6fa46,
+0x46b50e14,
+0x514bd261,
+0xe6cc3574,
+0x5a88dea2,
+0x9121d758,
+0x7f39e3bf,
+0x9ab043b6,
+0xc1007d0c,
+0xc3c3ff8e,
+0x08411386,
+0x0bd529d7,
+0xcaa9a1d8,
+0x27b19be2,
+0x95703f7e,
+0x44ab493a,
+0xcf1fc404,
+0x3f34062d,
+0xa56d454b,
+0x9464f996,
+0x1346eadf,
+0xdd6e6895,
+0x27b5ba10,
+0xb84c1d0c,
+0x5fa57ca4,
+0xad052de8,
+0xf5b4a3ae,
+0x6a61144d,
+0x48c00092,
+0x4897fad0,
+0x90b7b116,
+0xcdf29b2c,
+0xa41aac9a,
+0x147d09f7,
+0xebf3615d,
+0xb3ddf0b0,
+0xc8edc675,
+0x43cbf71b,
+0xfa0a0b5c,
+0xe0b63692,
+0x6c5870a9,
+0xe0b37be9,
+0xb16acc39,
+0xc55aed8c,
+0xd34fb041,
+0x24735885,
+0x0fff6e94,
+0x834181e8,
+0x56671872,
+0xb3f2e29b,
+0xfa383cd3,
+0xe585e5b6,
+0xa40cb894,
+0x1fe8376a,
+0xf794c60a,
+0xa3efdb18,
+0x0df1f1b4,
+0x54230798,
+0xd2a8ba49,
+0x349ce466,
+0xcbff13b4,
+0x71a63418,
+0x728ae615,
+0xf7c4f811,
+0x0dd072d8,
+0x9aa6fac7,
+0xa44210d0,
+0x2a1a85bf,
+0x1e18a8c6,
+0xbe2bb680,
+0xfed00f0e,
+0x2acc1b4b,
+0x4f049f6f,
+0x6f5aeec1,
+0x2db8f7b4,
+0xd61041a2,
+0x5cc7c861,
+0xb6ed3676,
+0x02aef566,
+0x2b6d41c8,
+0xaba9296e,
+0xf7b032cd,
+0xc290e538,
+0x584ad0f9,
+0x95289bc7,
+0x49b428b8,
+0x84bb41d4,
+0xdf0fcf91,
+0x9bd712a9,
+0xc6f730e1,
+0xe28b78d4,
+0x45b0480d,
+0x29d344bf,
+0xcd0101bb,
+0x18561b59,
+0xcfa84f65,
+0x76e798eb,
+0xac73f8af,
+0x71fe2488,
+0x207dd75d,
+0x198130e5,
+0x3604d44d,
+0xd895dc9b,
+0xf55fe7e2,
+0x4fed2e51,
+0xf434e20a,
+0x7c3204e8,
+0x4d653a59,
+0x6652a556,
+0x8713f1e2,
+0xa69dea42,
+0x2fd0ee37,
+0xe7617993,
+0xc0791c80,
+0x57e14435,
+0x87fcad6e,
+0x96505f56,
+0x838e7a38,
+0x78b228ab,
+0x84411d16,
+0x0b4e1d87,
+0x21f17d96,
+0x72021b3c,
+0xe69f4784,
+0x324fb9b4,
+0x041c7459,
+0x500ffe39,
+0x6e561c0f,
+0xadaf6fd7,
+0x0c91509f,
+0x8be04594,
+0x6a5ead5a,
+0x313c9f9d,
+0xe4754919,
+0x63d7cebc,
+0x02d0ad32,
+0x2dc3cdb7,
+0xd9b2e421,
+0xa1ad018c,
+0xd954f545,
+0x9f3871b2,
+0xf8a9a4a9,
+0x4cdc558d,
+0x300c9685,
+0x639f4b78,
+0x2181680d,
+0xb96442d6,
+0x7821a1a2,
+0x174a9e5b,
+0x79320590,
+0xf580c60c,
+0xba8539ce,
+0x59905669,
+0xc6f39c94,
+0xb57cc9bf,
+0xc2f7ad76,
+0x8d9ebc2d,
+0x6c33e47f,
+0x29294c84,
+0x49a2bef6,
+0x8aa6f79b,
+0x809f0eb5,
+0x3691aa7f,
+0xcf4b0e8f,
+0xec44f802,
+0x16bf83a7,
+0x82c00d36,
+0xa99071b1,
+0xe3815c76,
+0xc0835331,
+0xc794c55f,
+0x041b44af,
+0x2fa75171,
+0x985bd852,
+0xc4391e66,
+0x7bf08eaf,
+0x2b826882,
+0xfb8834dc,
+0x9128681e,
+0x6a2cb9ef,
+0x6d1d20f9,
+0x9f90ee4d,
+0xc48c3ee3,
+0xdd063585,
+0x82454044,
+0xf7077f1a,
+0x47e6e556,
+0xd803f7dd,
+0x98f67f71,
+0x9089e4ac,
+0xe7f09610,
+0xa9e3f93b,
+0x420c1550,
+0xc01f7710,
+0x0905da5e,
+0x02d71f99,
+0xbf36b473,
+0x50a96e32,
+0x2dedb8b9,
+0x9e3051a2,
+0x84c023c4,
+0xd43073b1,
+0x74f23fbb,
+0xd42a4487,
+0x266dfc42,
+0x6be0acdf,
+0xa986294c,
+0x3ee65aa8,
+0x19c1cf4f,
+0x2fdf8308,
+0xa6a64910,
+0xc3fa82e8,
+0x2943c8b8,
+0xf1a60b7b,
+0x4cc9ea04,
+0x3cc95270,
+0x054a8d2b,
+0xae7a4525,
+0x2e2abb62,
+0x24b9522b,
+0xb95a6668,
+0xad8c237d,
+0x1ea73bf8,
+0xff33f0d6,
+0x772a16a3,
+0xfefabdc4,
+0xb181234c,
+0xab59fb47,
+0x96f2c987,
+0xff0d4f54,
+0x6e938aba,
+0x727e6266,
+0xea0d851f,
+0x2ced3474,
+0x8c2e7718,
+0xa576c375,
+0xc97addeb,
+0x2f46a635,
+0xdb669986,
+0xa4333f93,
+0x7042c2c6,
+0x419fda5f,
+0x95b8aa3f,
+0x6ad05dc8,
+0x8b90655a,
+0xd8c77947,
+0x20508480,
+0xfa3cdf6b,
+0xdbb44af2,
+0x235941d0,
+0x3154c107,
+0x566bc32a,
+0x426fb2cd,
+0xd2010afa,
+0xe2775abe,
+0x6f543a20,
+0x2c626450,
+0x34f193f4,
+0x37ac5908,
+0x58a7eca6,
+0xc4859881,
+0x183393ff,
+0xab9abed9,
+0xde947d21,
+0xffec2b7d,
+0xb21b8788,
+0xb527117f,
+0x199dffe5,
+0xd7ebe4e6,
+0xc89a72b0,
+0x91cc3042,
+0x91bd3463,
+0x736e6f4f,
+0x0cc208bc,
+0x029f21cb,
+0x3f204418,
+0x050db787,
+0x71b56562,
+0xaf07f08f,
+0xaca4701f,
+0x88d4f2f8,
+0xf98fe016,
+0xb47672c6,
+0xed601c94,
+0x285db8b8,
+0x28a81c19,
+0x9e2763ce,
+0xe39741c0,
+0xcd9fce6d,
+0xe9917796,
+0xfdd3ebaf,
+0x99dcb253,
+0xe9aa0db4,
+0x3a65c0b0,
+0xb39c61fb,
+0x1f413c5e,
+0x60576c8c,
+0x48d6df34,
+0x0cbca786,
+0x4caff4b7,
+0x8473e181,
+0x36eed747,
+0x82f486af,
+0x79f02eed,
+0xab6886ed,
+0x06aef911,
+0xad42a654,
+0x5471c813,
+0xc8bbe710,
+0xfc65fd97,
+0x60f467af,
+0xf56b71d8,
+0xc1d6f193,
+0x3a1c42bf,
+0x46ce3b78,
+0x39472626,
+0x04dc137e,
+0xb48dc9dd,
+0xdfd27741,
+0x4718e5a2,
+0x00ba4728,
+0x855b661f,
+0x6d98577f,
+0xc3b48131,
+0x2b0384c1,
+0x8af572fe,
+0x760aa4e3,
+0x2f5b53fb,
+0xb9234297,
+0x401b47f5,
+0x44237cc0,
+0x2f7205f4,
+0x19b63c6e,
+0x7c375e6b,
+0x152c42d8,
+0x603731c7,
+0xc67601fb,
+0xa5d4826c,
+0x9068966f,
+0x864fe2f9,
+0xb37311d9,
+0xe6e4a34a,
+0xd46ee161,
+0xecd76c4a,
+0x90d0328a,
+0x4865b540,
+0xd2e13982,
+0x7e3925f4,
+0xc850a518,
+0x63bffcce,
+0x7cdb918f,
+0xcd8786d3,
+0xcf83df01,
+0x27122e50,
+0x0f014b76,
+0xde1485d7,
+0xa6ff496f,
+0xed0812f7,
+0x34efe965,
+0x12a63465,
+0xb83d9f77,
+0x040efa2e,
+0x4ac576d1,
+0x185430dd,
+0xb4271745,
+0x9bb58be2,
+0x7f55d4bb,
+0xca7dae0b,
+0x0bfe5147,
+0x4a9ade45,
+0x20bdc545,
+0xdf66689d,
+0x22e29493,
+0x31763c1f,
+0x2d021cd2,
+0x06286428,
+0xc7bba5d4,
+0x6bc42a0e,
+0x1c987082,
+0xd6c6c2f9,
+0x2c1ecdd0,
+0x84946249,
+0x42c1c41b,
+0x6d949e60,
+0x9dbb1571,
+0xf6b1df68,
+0x0705ae1a,
+0xa1ec5add,
+0x7e94d7c8,
+0x7d4d451d,
+0xd53c13d4,
+0x0204877b,
+0x0f0e44e0,
+0xdf25570f,
+0xd2a9adaf,
+0x556aeacf,
+0x2f985a30,
+0x706c42c6,
+0x2d5a76a5,
+0xdc428213,
+0xdf2864a2,
+0x0f6788a9,
+0xc764d3a6,
+0x9211d0ca,
+0x59e3f5cc,
+0xd31fd5b6,
+0xfa8b535b,
+0x2cac74bb,
+0xc43f36b2,
+0xf83b5bac,
+0x96c255bf,
+0x45915993,
+0x657d751a,
+0x9b86b994,
+0xddab62fd,
+0x1b6ac108,
+0x559073c9,
+0xe60a0bda,
+0xd65df6de,
+0x41f7e5d4,
+0x825a5701,
+0x377307b6,
+0x08176ce6,
+0x7a8a2c4a,
+0xd7ecb869,
+0x02710179,
+0x75e7517c,
+0xdfaf2c82,
+0x67590275,
+0x6ad621af,
+0xaedaa35c,
+0xfa8fbee3,
+0x9e5dda5f,
+0x09f571fa,
+0xe358dbfe,
+0x1b3300f1,
+0x05567c6b,
+0x5a9d335f,
+0x215114f8,
+0xd5744f0a,
+0x78ecc142,
+0x9b5f60b8,
+0x30f8fed2,
+0x5c013696,
+0x675c84de,
+0xdb50bbcc,
+0x7c504a4e,
+0x3ffc5fda,
+0x24b2c30a,
+0xac00d64a,
+0x97832b52,
+0xb34d9975,
+0x93c6cb4e,
+0x471bfcae,
+0xaabbb6d8,
+0x0bc6a5e5,
+0x6875c630,
+0xf4cce30c,
+0xdab0d64b,
+0x29aba8b9,
+0xe34b3cde,
+0x8654e470,
+0x2c5041f7,
+0xdcf5eff9,
+0x26a88f84,
+0x9d374761,
+0xefa60ac4,
+0xdf0d0fd3,
+0x72e37e59,
+0xa76d26e1,
+0x3ffe2408,
+0x13ecf42d,
+0x46de7cba,
+0x43330219,
+0xc2536a31,
+0xa69c4729,
+0x114990f8,
+0x3f08ed00,
+0xeaa05cae,
+0x08f06e57,
+0x30f4a62f,
+0x963a7557,
+0x631fb75f,
+0x1344a74b,
+0x1e80cef5,
+0x8a4f86dd,
+0x0f7f1c62,
+0xfe9f5809,
+0x710d86de,
+0x8939283d,
+0x19403076,
+0x26ce286b,
+0x6baaf798,
+0xbc1d2808,
+0xea980728,
+0x72288979,
+0x7c92be68,
+0x0a7af91b,
+0x7bb8059b,
+0xe7eca99c,
+0xd3a8819f,
+0xb9182916,
+0x0c48ba1e,
+0xb6aaf63b,
+0x10a740a6,
+0x0aa2e4e7,
+0x0bf27e94,
+0x6d266f86,
index 93c1bd32e605185801bdd853c27a4cf09b71ac18..5d74fbce22ae2ad0a70577d2e16f3833f1752e5b 100644 (file)
@@ -94,7 +94,7 @@ uses SB_HT_CHAIN_UNITID_OFFSET_ONLY
 uses SB_HT_CHAIN_ON_BUS0
 uses CONFIG_COMPRESSED_PAYLOAD_NRV2B
 uses CONFIG_COMPRESSED_PAYLOAD_LZMA
-uses CONFIG_USE_PRINTK_IN_CAR\r
+uses CONFIG_USE_PRINTK_IN_CAR
 
 default ROM_SIZE = 512 * 1024
 default FALLBACK_SIZE = 256 * 1024
index d0e7be1cd95440e95373458058afc4f01bfc63c8..dc5514bbacdc509d03c82601e2b62d2e85329ea1 100644 (file)
@@ -1,48 +1,48 @@
-/* This file was generated by getpir.c, do not modify! \r
-   (but if you do, please run checkpir on it to verify)\r
- * Contains the IRQ Routing Table dumped directly from your memory, which BIOS sets up\r
- *\r
- * Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM\r
-*/\r
-\r
-#include <arch/pirq_routing.h>\r
-\r
-const struct irq_routing_table intel_irq_routing_table = {\r
-       PIRQ_SIGNATURE,  /* u32 signature */\r
-       PIRQ_VERSION,    /* u16 version   */\r
-       32+16*17,        /* there can be total 17 devices on the bus */\r
-       0x00,            /* Where the interrupt router lies (bus) */\r
-       (0x1f<<3)|0x0,   /* Where the interrupt router lies (dev) */\r
-       0,               /* IRQs devoted exclusively to PCI usage */\r
-       0x8086,          /* Vendor */\r
-       0x24d0,          /* Device */\r
-       0,               /* Crap (miniport) */\r
-       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */\r
-       0xc4,         /*  u8 checksum , this hase to set to some value that would give 0 after the sum of all bytes for this structure (including checksum) */\r
-       {\r
-               /* bus,     dev|fn,   {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap},  slot, rfu */\r
-               {0x00,(0x02<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x00,(0x04<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x00,(0x05<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x00,(0x06<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x05,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},\r
-               {0x01,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},\r
-               {0x00,(0x1d<<3)|0x0, {{0x60, 0xccf8}, {0x63, 0xccf8}, {0x62, 0xccf8}, {0x6b, 0x0ccf8}}, 0x0, 0x0},\r
-               {0x09,(0x05<<3)|0x0, {{0x68, 0xccf8}, {0x69, 0xccf8}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x09,(0x06<<3)|0x0, {{0x6b, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x09,(0x0d<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x09,(0x03<<3)|0x0, {{0x63, 0xccf8}, {0x63, 0xccf8}, {0x63, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},\r
-               {0x06,(0x07<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x07,(0x08<<3)|0x0, {{0x61, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x02,(0x05<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-               {0x04,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x1, 0x0},\r
-               {0x08,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x2, 0x0},\r
-               {0x02,(0x0e<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},\r
-       }\r
-};\r
-\r
-unsigned long write_pirq_routing_table(unsigned long addr)\r
-{\r
-        return copy_pirq_routing_table(addr);\r
-}\r
-\r
+/* This file was generated by getpir.c, do not modify! 
+   (but if you do, please run checkpir on it to verify)
+ * Contains the IRQ Routing Table dumped directly from your memory, which BIOS sets up
+ *
+ * Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM
+*/
+
+#include <arch/pirq_routing.h>
+
+const struct irq_routing_table intel_irq_routing_table = {
+       PIRQ_SIGNATURE,  /* u32 signature */
+       PIRQ_VERSION,    /* u16 version   */
+       32+16*17,        /* there can be total 17 devices on the bus */
+       0x00,            /* Where the interrupt router lies (bus) */
+       (0x1f<<3)|0x0,   /* Where the interrupt router lies (dev) */
+       0,               /* IRQs devoted exclusively to PCI usage */
+       0x8086,          /* Vendor */
+       0x24d0,          /* Device */
+       0,               /* Crap (miniport) */
+       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */
+       0xc4,         /*  u8 checksum , this hase to set to some value that would give 0 after the sum of all bytes for this structure (including checksum) */
+       {
+               /* bus,     dev|fn,   {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap},  slot, rfu */
+               {0x00,(0x02<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x00,(0x04<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x00,(0x05<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x00,(0x06<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x05,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},
+               {0x01,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},
+               {0x00,(0x1d<<3)|0x0, {{0x60, 0xccf8}, {0x63, 0xccf8}, {0x62, 0xccf8}, {0x6b, 0x0ccf8}}, 0x0, 0x0},
+               {0x09,(0x05<<3)|0x0, {{0x68, 0xccf8}, {0x69, 0xccf8}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x09,(0x06<<3)|0x0, {{0x6b, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x09,(0x0d<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x09,(0x03<<3)|0x0, {{0x63, 0xccf8}, {0x63, 0xccf8}, {0x63, 0xccf8}, {0x63, 0x0ccf8}}, 0x0, 0x0},
+               {0x06,(0x07<<3)|0x0, {{0x60, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x07,(0x08<<3)|0x0, {{0x61, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x02,(0x05<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+               {0x04,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x1, 0x0},
+               {0x08,(0x00<<3)|0x0, {{0x60, 0xccf8}, {0x61, 0xccf8}, {0x62, 0xccf8}, {0x63, 0x0ccf8}}, 0x2, 0x0},
+               {0x02,(0x0e<<3)|0x0, {{0x62, 0xccf8}, {0x00, 0x0000}, {0x00, 0x0000}, {0x00, 0x00000}}, 0x0, 0x0},
+       }
+};
+
+unsigned long write_pirq_routing_table(unsigned long addr)
+{
+        return copy_pirq_routing_table(addr);
+}
+
index efd5dc95bcea23c441baa7df4d1cef600e7e55db..5c3073e2d29a14c19c36e0f5831b3c11e91112a7 100644 (file)
@@ -220,7 +220,7 @@ default USE_DCACHE_RAM=1
 default DCACHE_RAM_BASE=0xcc000
 default DCACHE_RAM_SIZE=0x04000
 default DCACHE_RAM_GLOBAL_VAR_SIZE=0x01000
-default CONFIG_USE_INIT=0\r
+default CONFIG_USE_INIT=0
 
 ##
 ## Build code to setup a generic IOAPIC
index a666a8c61e5c9bef16244d88547a8100c4b308b6..1a686826cd20c3bb05bbbf23ff1712ab7a524b33 100644 (file)
@@ -100,7 +100,7 @@ uses SB_HT_CHAIN_ON_BUS0
 uses CONFIG_COMPRESSED_PAYLOAD_LZMA
 uses CONFIG_COMPRESSED_PAYLOAD_NRV2B
 uses CONFIG_PRECOMPRESSED_PAYLOAD
-uses CONFIG_USE_PRINTK_IN_CAR\r
+uses CONFIG_USE_PRINTK_IN_CAR
 
 ## ROM_SIZE is the size of boot ROM that this board will use.
 #512K bytes
@@ -265,7 +265,7 @@ default CONFIG_GDB_STUB=0
 ## The Serial Console
 ##
 default CONFIG_USE_PRINTK_IN_CAR=1
-\r
+
 # To Enable the Serial Console
 default CONFIG_CONSOLE_SERIAL8250=1
 
index 97231e52a087862940726c513c9ac2d46c41112e..d51bc90e789977670b8a551b1f70b9e461d32ac1 100644 (file)
-/*\r
- * This file is part of the coreboot project.\r
- *\r
- * Copyright (C) 2008 Joseph Smith <joe@settoplinux.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\r
- */\r
-\r
-#define PME_DEV                        PNP_DEV(0x2e, 0x0a)\r
-#define PME_IO_BASE_ADDR       0x800      /* Runtime register base address */\r
-#define ICH_IO_BASE_ADDR       0x00000500 /* GPIO base address register */\r
-\r
-/* Early mainboard specific GPIO setup. */\r
-static void mb_gpio_init(void)\r
-{\r
-       device_t dev;\r
-       uint16_t port;\r
-       uint32_t set_gpio;\r
-\r
-       /* Southbridge GPIOs. */\r
-       /* Set the LPC device statically. */\r
-       dev = PCI_DEV(0x0, 0x1f, 0x0);\r
-\r
-       /* Set the value for GPIO base address register and enable GPIO. */\r
-       pci_write_config32(dev, GPIO_BASE_ICH0_5, (ICH_IO_BASE_ADDR | 1));\r
-       pci_write_config8(dev, GPIO_CNTL_ICH0_5, 0x10);\r
-\r
-       /* Set GPIO23 to high, this enables the LAN controller. */\r
-       udelay(10);\r
-       set_gpio = inl(ICH_IO_BASE_ADDR + 0x0c);\r
-       set_gpio |= 1 << 23;\r
-       outl(set_gpio, ICH_IO_BASE_ADDR + 0x0c);\r
-\r
-       /* Super I/O GPIOs. */\r
-       dev = PME_DEV;\r
-       port = dev >> 8;\r
-\r
-       /* Enter the configuration state. */\r
-       outb(0x55, port);\r
-       pnp_set_logical_device(dev);\r
-       pnp_set_enable(dev, 0);\r
-       pnp_set_iobase(dev, PNP_IDX_IO0, PME_IO_BASE_ADDR);\r
-       pnp_set_enable(dev, 1);\r
-\r
-       /* GP21 - LED_RED */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x2c);\r
-\r
-       /* GP30 - FAN2_TACH */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x33); \r
-\r
-       /* GP31 - FAN1_TACH */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x34);\r
-\r
-       /* GP32 - FAN2_CTRL */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x35); \r
-\r
-       /* GP33 - FAN1_CTRL */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x36);\r
-\r
-       /* GP34 - AUD_MUTE_OUT_R */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x37);\r
-\r
-       /* GP36 - KBRST */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x39);\r
-\r
-       /* GP37 - A20GATE */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x3a);\r
-\r
-       /* GP42 - GPIO_PME_OUT */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x3d); \r
-\r
-       /* GP50 - SER2_RI */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x3f);\r
-\r
-       /* GP51 - SER2_DCD */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x40);\r
-\r
-       /* GP52 - SER2_RX */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x41);\r
-\r
-       /* GP53 - SER2_TX */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x42);\r
-\r
-       /* GP55 - SER2_RTS */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x44);\r
-\r
-       /* GP56 - SER2_CTS */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x45);\r
-\r
-       /* GP57 - SER2_DTR */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x46);\r
-\r
-       /* GP60 - LED_GREEN */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x47);\r
-\r
-       /* GP61 - LED_YELLOW */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x48);\r
-\r
-       /* GP3 */\r
-       outl(0xc0, PME_IO_BASE_ADDR + 0x4d);\r
-\r
-       /* GP4 */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x4e);\r
-\r
-       /* FAN1 */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x56);\r
-\r
-       /* FAN2 */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x57);\r
-\r
-       /* Fan Control */\r
-       outl(0x50, PME_IO_BASE_ADDR + 0x58);\r
-\r
-       /* Fan1 Tachometer */\r
-       outl(0xff, PME_IO_BASE_ADDR + 0x59);\r
-\r
-       /* Fan2 Tachometer */\r
-       outl(0xff, PME_IO_BASE_ADDR + 0x5a);\r
-\r
-       /* LED1 */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5d);\r
-\r
-       /* LED2 */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5e);\r
-\r
-       /* Keyboard Scan Code */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5f);\r
-\r
-       /* Exit the configuration state. */\r
-       outb(0xaa, port);\r
-}\r
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2008 Joseph Smith <joe@settoplinux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#define PME_DEV                        PNP_DEV(0x2e, 0x0a)
+#define PME_IO_BASE_ADDR       0x800      /* Runtime register base address */
+#define ICH_IO_BASE_ADDR       0x00000500 /* GPIO base address register */
+
+/* Early mainboard specific GPIO setup. */
+static void mb_gpio_init(void)
+{
+       device_t dev;
+       uint16_t port;
+       uint32_t set_gpio;
+
+       /* Southbridge GPIOs. */
+       /* Set the LPC device statically. */
+       dev = PCI_DEV(0x0, 0x1f, 0x0);
+
+       /* Set the value for GPIO base address register and enable GPIO. */
+       pci_write_config32(dev, GPIO_BASE_ICH0_5, (ICH_IO_BASE_ADDR | 1));
+       pci_write_config8(dev, GPIO_CNTL_ICH0_5, 0x10);
+
+       /* Set GPIO23 to high, this enables the LAN controller. */
+       udelay(10);
+       set_gpio = inl(ICH_IO_BASE_ADDR + 0x0c);
+       set_gpio |= 1 << 23;
+       outl(set_gpio, ICH_IO_BASE_ADDR + 0x0c);
+
+       /* Super I/O GPIOs. */
+       dev = PME_DEV;
+       port = dev >> 8;
+
+       /* Enter the configuration state. */
+       outb(0x55, port);
+       pnp_set_logical_device(dev);
+       pnp_set_enable(dev, 0);
+       pnp_set_iobase(dev, PNP_IDX_IO0, PME_IO_BASE_ADDR);
+       pnp_set_enable(dev, 1);
+
+       /* GP21 - LED_RED */
+       outl(0x01, PME_IO_BASE_ADDR + 0x2c);
+
+       /* GP30 - FAN2_TACH */
+       outl(0x05, PME_IO_BASE_ADDR + 0x33); 
+
+       /* GP31 - FAN1_TACH */
+       outl(0x05, PME_IO_BASE_ADDR + 0x34);
+
+       /* GP32 - FAN2_CTRL */
+       outl(0x04, PME_IO_BASE_ADDR + 0x35); 
+
+       /* GP33 - FAN1_CTRL */
+       outl(0x04, PME_IO_BASE_ADDR + 0x36);
+
+       /* GP34 - AUD_MUTE_OUT_R */
+       outl(0x00, PME_IO_BASE_ADDR + 0x37);
+
+       /* GP36 - KBRST */
+       outl(0x00, PME_IO_BASE_ADDR + 0x39);
+
+       /* GP37 - A20GATE */
+       outl(0x00, PME_IO_BASE_ADDR + 0x3a);
+
+       /* GP42 - GPIO_PME_OUT */
+       outl(0x00, PME_IO_BASE_ADDR + 0x3d); 
+
+       /* GP50 - SER2_RI */
+       outl(0x05, PME_IO_BASE_ADDR + 0x3f);
+
+       /* GP51 - SER2_DCD */
+       outl(0x05, PME_IO_BASE_ADDR + 0x40);
+
+       /* GP52 - SER2_RX */
+       outl(0x05, PME_IO_BASE_ADDR + 0x41);
+
+       /* GP53 - SER2_TX */
+       outl(0x04, PME_IO_BASE_ADDR + 0x42);
+
+       /* GP55 - SER2_RTS */
+       outl(0x04, PME_IO_BASE_ADDR + 0x44);
+
+       /* GP56 - SER2_CTS */
+       outl(0x05, PME_IO_BASE_ADDR + 0x45);
+
+       /* GP57 - SER2_DTR */
+       outl(0x04, PME_IO_BASE_ADDR + 0x46);
+
+       /* GP60 - LED_GREEN */
+       outl(0x01, PME_IO_BASE_ADDR + 0x47);
+
+       /* GP61 - LED_YELLOW */
+       outl(0x01, PME_IO_BASE_ADDR + 0x48);
+
+       /* GP3 */
+       outl(0xc0, PME_IO_BASE_ADDR + 0x4d);
+
+       /* GP4 */
+       outl(0x04, PME_IO_BASE_ADDR + 0x4e);
+
+       /* FAN1 */
+       outl(0x01, PME_IO_BASE_ADDR + 0x56);
+
+       /* FAN2 */
+       outl(0x01, PME_IO_BASE_ADDR + 0x57);
+
+       /* Fan Control */
+       outl(0x50, PME_IO_BASE_ADDR + 0x58);
+
+       /* Fan1 Tachometer */
+       outl(0xff, PME_IO_BASE_ADDR + 0x59);
+
+       /* Fan2 Tachometer */
+       outl(0xff, PME_IO_BASE_ADDR + 0x5a);
+
+       /* LED1 */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5d);
+
+       /* LED2 */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5e);
+
+       /* Keyboard Scan Code */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5f);
+
+       /* Exit the configuration state. */
+       outb(0xaa, port);
+}
index 97231e52a087862940726c513c9ac2d46c41112e..d51bc90e789977670b8a551b1f70b9e461d32ac1 100644 (file)
-/*\r
- * This file is part of the coreboot project.\r
- *\r
- * Copyright (C) 2008 Joseph Smith <joe@settoplinux.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\r
- */\r
-\r
-#define PME_DEV                        PNP_DEV(0x2e, 0x0a)\r
-#define PME_IO_BASE_ADDR       0x800      /* Runtime register base address */\r
-#define ICH_IO_BASE_ADDR       0x00000500 /* GPIO base address register */\r
-\r
-/* Early mainboard specific GPIO setup. */\r
-static void mb_gpio_init(void)\r
-{\r
-       device_t dev;\r
-       uint16_t port;\r
-       uint32_t set_gpio;\r
-\r
-       /* Southbridge GPIOs. */\r
-       /* Set the LPC device statically. */\r
-       dev = PCI_DEV(0x0, 0x1f, 0x0);\r
-\r
-       /* Set the value for GPIO base address register and enable GPIO. */\r
-       pci_write_config32(dev, GPIO_BASE_ICH0_5, (ICH_IO_BASE_ADDR | 1));\r
-       pci_write_config8(dev, GPIO_CNTL_ICH0_5, 0x10);\r
-\r
-       /* Set GPIO23 to high, this enables the LAN controller. */\r
-       udelay(10);\r
-       set_gpio = inl(ICH_IO_BASE_ADDR + 0x0c);\r
-       set_gpio |= 1 << 23;\r
-       outl(set_gpio, ICH_IO_BASE_ADDR + 0x0c);\r
-\r
-       /* Super I/O GPIOs. */\r
-       dev = PME_DEV;\r
-       port = dev >> 8;\r
-\r
-       /* Enter the configuration state. */\r
-       outb(0x55, port);\r
-       pnp_set_logical_device(dev);\r
-       pnp_set_enable(dev, 0);\r
-       pnp_set_iobase(dev, PNP_IDX_IO0, PME_IO_BASE_ADDR);\r
-       pnp_set_enable(dev, 1);\r
-\r
-       /* GP21 - LED_RED */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x2c);\r
-\r
-       /* GP30 - FAN2_TACH */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x33); \r
-\r
-       /* GP31 - FAN1_TACH */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x34);\r
-\r
-       /* GP32 - FAN2_CTRL */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x35); \r
-\r
-       /* GP33 - FAN1_CTRL */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x36);\r
-\r
-       /* GP34 - AUD_MUTE_OUT_R */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x37);\r
-\r
-       /* GP36 - KBRST */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x39);\r
-\r
-       /* GP37 - A20GATE */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x3a);\r
-\r
-       /* GP42 - GPIO_PME_OUT */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x3d); \r
-\r
-       /* GP50 - SER2_RI */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x3f);\r
-\r
-       /* GP51 - SER2_DCD */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x40);\r
-\r
-       /* GP52 - SER2_RX */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x41);\r
-\r
-       /* GP53 - SER2_TX */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x42);\r
-\r
-       /* GP55 - SER2_RTS */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x44);\r
-\r
-       /* GP56 - SER2_CTS */\r
-       outl(0x05, PME_IO_BASE_ADDR + 0x45);\r
-\r
-       /* GP57 - SER2_DTR */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x46);\r
-\r
-       /* GP60 - LED_GREEN */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x47);\r
-\r
-       /* GP61 - LED_YELLOW */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x48);\r
-\r
-       /* GP3 */\r
-       outl(0xc0, PME_IO_BASE_ADDR + 0x4d);\r
-\r
-       /* GP4 */\r
-       outl(0x04, PME_IO_BASE_ADDR + 0x4e);\r
-\r
-       /* FAN1 */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x56);\r
-\r
-       /* FAN2 */\r
-       outl(0x01, PME_IO_BASE_ADDR + 0x57);\r
-\r
-       /* Fan Control */\r
-       outl(0x50, PME_IO_BASE_ADDR + 0x58);\r
-\r
-       /* Fan1 Tachometer */\r
-       outl(0xff, PME_IO_BASE_ADDR + 0x59);\r
-\r
-       /* Fan2 Tachometer */\r
-       outl(0xff, PME_IO_BASE_ADDR + 0x5a);\r
-\r
-       /* LED1 */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5d);\r
-\r
-       /* LED2 */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5e);\r
-\r
-       /* Keyboard Scan Code */\r
-       outl(0x00, PME_IO_BASE_ADDR + 0x5f);\r
-\r
-       /* Exit the configuration state. */\r
-       outb(0xaa, port);\r
-}\r
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2008 Joseph Smith <joe@settoplinux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#define PME_DEV                        PNP_DEV(0x2e, 0x0a)
+#define PME_IO_BASE_ADDR       0x800      /* Runtime register base address */
+#define ICH_IO_BASE_ADDR       0x00000500 /* GPIO base address register */
+
+/* Early mainboard specific GPIO setup. */
+static void mb_gpio_init(void)
+{
+       device_t dev;
+       uint16_t port;
+       uint32_t set_gpio;
+
+       /* Southbridge GPIOs. */
+       /* Set the LPC device statically. */
+       dev = PCI_DEV(0x0, 0x1f, 0x0);
+
+       /* Set the value for GPIO base address register and enable GPIO. */
+       pci_write_config32(dev, GPIO_BASE_ICH0_5, (ICH_IO_BASE_ADDR | 1));
+       pci_write_config8(dev, GPIO_CNTL_ICH0_5, 0x10);
+
+       /* Set GPIO23 to high, this enables the LAN controller. */
+       udelay(10);
+       set_gpio = inl(ICH_IO_BASE_ADDR + 0x0c);
+       set_gpio |= 1 << 23;
+       outl(set_gpio, ICH_IO_BASE_ADDR + 0x0c);
+
+       /* Super I/O GPIOs. */
+       dev = PME_DEV;
+       port = dev >> 8;
+
+       /* Enter the configuration state. */
+       outb(0x55, port);
+       pnp_set_logical_device(dev);
+       pnp_set_enable(dev, 0);
+       pnp_set_iobase(dev, PNP_IDX_IO0, PME_IO_BASE_ADDR);
+       pnp_set_enable(dev, 1);
+
+       /* GP21 - LED_RED */
+       outl(0x01, PME_IO_BASE_ADDR + 0x2c);
+
+       /* GP30 - FAN2_TACH */
+       outl(0x05, PME_IO_BASE_ADDR + 0x33); 
+
+       /* GP31 - FAN1_TACH */
+       outl(0x05, PME_IO_BASE_ADDR + 0x34);
+
+       /* GP32 - FAN2_CTRL */
+       outl(0x04, PME_IO_BASE_ADDR + 0x35); 
+
+       /* GP33 - FAN1_CTRL */
+       outl(0x04, PME_IO_BASE_ADDR + 0x36);
+
+       /* GP34 - AUD_MUTE_OUT_R */
+       outl(0x00, PME_IO_BASE_ADDR + 0x37);
+
+       /* GP36 - KBRST */
+       outl(0x00, PME_IO_BASE_ADDR + 0x39);
+
+       /* GP37 - A20GATE */
+       outl(0x00, PME_IO_BASE_ADDR + 0x3a);
+
+       /* GP42 - GPIO_PME_OUT */
+       outl(0x00, PME_IO_BASE_ADDR + 0x3d); 
+
+       /* GP50 - SER2_RI */
+       outl(0x05, PME_IO_BASE_ADDR + 0x3f);
+
+       /* GP51 - SER2_DCD */
+       outl(0x05, PME_IO_BASE_ADDR + 0x40);
+
+       /* GP52 - SER2_RX */
+       outl(0x05, PME_IO_BASE_ADDR + 0x41);
+
+       /* GP53 - SER2_TX */
+       outl(0x04, PME_IO_BASE_ADDR + 0x42);
+
+       /* GP55 - SER2_RTS */
+       outl(0x04, PME_IO_BASE_ADDR + 0x44);
+
+       /* GP56 - SER2_CTS */
+       outl(0x05, PME_IO_BASE_ADDR + 0x45);
+
+       /* GP57 - SER2_DTR */
+       outl(0x04, PME_IO_BASE_ADDR + 0x46);
+
+       /* GP60 - LED_GREEN */
+       outl(0x01, PME_IO_BASE_ADDR + 0x47);
+
+       /* GP61 - LED_YELLOW */
+       outl(0x01, PME_IO_BASE_ADDR + 0x48);
+
+       /* GP3 */
+       outl(0xc0, PME_IO_BASE_ADDR + 0x4d);
+
+       /* GP4 */
+       outl(0x04, PME_IO_BASE_ADDR + 0x4e);
+
+       /* FAN1 */
+       outl(0x01, PME_IO_BASE_ADDR + 0x56);
+
+       /* FAN2 */
+       outl(0x01, PME_IO_BASE_ADDR + 0x57);
+
+       /* Fan Control */
+       outl(0x50, PME_IO_BASE_ADDR + 0x58);
+
+       /* Fan1 Tachometer */
+       outl(0xff, PME_IO_BASE_ADDR + 0x59);
+
+       /* Fan2 Tachometer */
+       outl(0xff, PME_IO_BASE_ADDR + 0x5a);
+
+       /* LED1 */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5d);
+
+       /* LED2 */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5e);
+
+       /* Keyboard Scan Code */
+       outl(0x00, PME_IO_BASE_ADDR + 0x5f);
+
+       /* Exit the configuration state. */
+       outb(0xaa, port);
+}
index 7a6d1f7a6bfe273f5d15ea2f91f12bb225d39175..e9cfdac0c65332ed3b9c54cfef4ced8b4ab49503 100644 (file)
@@ -1,50 +1,50 @@
-/*\r
- * This file is part of the coreboot project.\r
- *\r
- * Copyright (C) 2009 Joseph Smith <joe@settoplinux.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\r
- */\r
-\r
-#include <console/console.h>\r
-#include <arch/io.h>\r
-#include <stdint.h>\r
-#include <device/device.h>\r
-#include <device/pci.h>\r
-#include <device/pci_ids.h>\r
-\r
-static void vga_init(device_t dev) {\r
-\r
-       printk_info("Starting Graphics Initialization\n");\r
-       pci_dev_init(dev);\r
-       printk_info("Graphics Initialization Complete\n");\r
-       /* Future TV-OUT code will be called from here. */\r
-}\r
-\r
-static const struct device_operations vga_operations = {\r
-       .read_resources   = pci_dev_read_resources,\r
-       .set_resources    = pci_dev_set_resources,\r
-       .enable_resources = pci_dev_enable_resources,\r
-       .init             = vga_init,\r
-       .scan_bus         = 0,\r
-       .enable           = 0,\r
-       .ops_pci          = 0,\r
-};\r
-\r
-static const struct pci_driver vga_driver __pci_driver = {\r
-       .ops    = &vga_operations,\r
-       .vendor = PCI_VENDOR_ID_INTEL,\r
-       .device = 0x3577,\r
-};\r
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 Joseph Smith <joe@settoplinux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <console/console.h>
+#include <arch/io.h>
+#include <stdint.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+
+static void vga_init(device_t dev) {
+
+       printk_info("Starting Graphics Initialization\n");
+       pci_dev_init(dev);
+       printk_info("Graphics Initialization Complete\n");
+       /* Future TV-OUT code will be called from here. */
+}
+
+static const struct device_operations vga_operations = {
+       .read_resources   = pci_dev_read_resources,
+       .set_resources    = pci_dev_set_resources,
+       .enable_resources = pci_dev_enable_resources,
+       .init             = vga_init,
+       .scan_bus         = 0,
+       .enable           = 0,
+       .ops_pci          = 0,
+};
+
+static const struct pci_driver vga_driver __pci_driver = {
+       .ops    = &vga_operations,
+       .vendor = PCI_VENDOR_ID_INTEL,
+       .device = 0x3577,
+};
index 2508419d1ba4bb78d93ef5a61ca8ed16fff8c4e2..5f7b89700e0381d9fcd4b005c6bcd1bfd3bcee9f 100644 (file)
@@ -1,30 +1,30 @@
-#include <console/console.h>\r
-#include <device/device.h>\r
-#include <device/pci.h>\r
-#include <device/pci_ids.h>\r
-#include <device/pci_ops.h>\r
-#include "i82801ca.h"\r
-\r
-static void pci_init(struct device *dev)\r
-{\r
-       // NOTE: the original (v1) 'CA code set these in the bridge register (0x3E-3F)\r
-       /* Enable pci error detecting */\r
-       uint32_t dword = pci_read_config32(dev, PCI_COMMAND);\r
-       dword |= (PCI_COMMAND_SERR | PCI_COMMAND_PARITY);\r
-       pci_write_config32(dev, PCI_COMMAND, dword);\r
-}\r
-\r
-static struct device_operations pci_ops  = {\r
-       .read_resources   = pci_bus_read_resources,\r
-       .set_resources    = pci_dev_set_resources,\r
-       .enable_resources = pci_bus_enable_resources,\r
-       .init             = pci_init,\r
-       .scan_bus         = pci_scan_bridge,\r
-};\r
-\r
-static const struct pci_driver pci_driver __pci_driver = {\r
-       .ops    = &pci_ops,\r
-       .vendor = PCI_VENDOR_ID_INTEL,\r
-       .device = PCI_DEVICE_ID_INTEL_82801CA_PCI,\r
-};\r
-\r
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <device/pci_ops.h>
+#include "i82801ca.h"
+
+static void pci_init(struct device *dev)
+{
+       // NOTE: the original (v1) 'CA code set these in the bridge register (0x3E-3F)
+       /* Enable pci error detecting */
+       uint32_t dword = pci_read_config32(dev, PCI_COMMAND);
+       dword |= (PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
+       pci_write_config32(dev, PCI_COMMAND, dword);
+}
+
+static struct device_operations pci_ops  = {
+       .read_resources   = pci_bus_read_resources,
+       .set_resources    = pci_dev_set_resources,
+       .enable_resources = pci_bus_enable_resources,
+       .init             = pci_init,
+       .scan_bus         = pci_scan_bridge,
+};
+
+static const struct pci_driver pci_driver __pci_driver = {
+       .ops    = &pci_ops,
+       .vendor = PCI_VENDOR_ID_INTEL,
+       .device = PCI_DEVICE_ID_INTEL_82801CA_PCI,
+};
+
index 7239bcbb9c34eb3fa81ff77b71507da0b406061c..49d59571fbf6e077eece30f8c418b6aad15e20b0 100644 (file)
@@ -1 +1 @@
-0.1\r
+0.1
index a59ecefacd0d90ace0b88e37d233e7939f4fdf7e..057caa16593381a4ed1ef9be86af19ba129e9bda 100644 (file)
@@ -1,76 +1,76 @@
-// InBuffer.h\r
-\r
-#ifndef __INBUFFER_H\r
-#define __INBUFFER_H\r
-\r
-#include "../IStream.h"\r
-#include "../../Common/MyCom.h"\r
-\r
-#ifndef _NO_EXCEPTIONS\r
-class CInBufferException\r
-{\r
-public:\r
-  HRESULT ErrorCode;\r
-  CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {}\r
-};\r
-#endif\r
-\r
-class CInBuffer\r
-{\r
-  Byte *_buffer;\r
-  Byte *_bufferLimit;\r
-  Byte *_bufferBase;\r
-  CMyComPtr<ISequentialInStream> _stream;\r
-  UInt64 _processedSize;\r
-  UInt32 _bufferSize;\r
-  bool _wasFinished;\r
-\r
-  bool ReadBlock();\r
-  Byte ReadBlock2();\r
-\r
-public:\r
-  #ifdef _NO_EXCEPTIONS\r
-  HRESULT ErrorCode;\r
-  #endif\r
-\r
-  CInBuffer();\r
-  ~CInBuffer() { Free(); }\r
-\r
-  bool Create(UInt32 bufferSize);\r
-  void Free();\r
-  \r
-  void SetStream(ISequentialInStream *stream);\r
-  void Init();\r
-  void ReleaseStream() { _stream.Release(); }\r
-\r
-  bool ReadByte(Byte &b)\r
-  {\r
-    if(_buffer >= _bufferLimit)\r
-      if(!ReadBlock())\r
-        return false;\r
-    b = *_buffer++;\r
-    return true;\r
-  }\r
-  Byte ReadByte()\r
-  {\r
-    if(_buffer >= _bufferLimit)\r
-      return ReadBlock2();\r
-    return *_buffer++;\r
-  }\r
-  void ReadBytes(void *data, UInt32 size, UInt32 &processedSize)\r
-  {\r
-    for(processedSize = 0; processedSize < size; processedSize++)\r
-      if (!ReadByte(((Byte *)data)[processedSize]))\r
-        return;\r
-  }\r
-  bool ReadBytes(void *data, UInt32 size)\r
-  {\r
-    UInt32 processedSize;\r
-    ReadBytes(data, size, processedSize);\r
-    return (processedSize == size);\r
-  }\r
-  UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }\r
-  bool WasFinished() const { return _wasFinished; }\r
-};\r
-\r
-#endif\r
+// InBuffer.h
+
+#ifndef __INBUFFER_H
+#define __INBUFFER_H
+
+#include "../IStream.h"
+#include "../../Common/MyCom.h"
+
+#ifndef _NO_EXCEPTIONS
+class CInBufferException
+{
+public:
+  HRESULT ErrorCode;
+  CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
+};
+#endif
+
+class CInBuffer
+{
+  Byte *_buffer;
+  Byte *_bufferLimit;
+  Byte *_bufferBase;
+  CMyComPtr<ISequentialInStream> _stream;
+  UInt64 _processedSize;
+  UInt32 _bufferSize;
+  bool _wasFinished;
+
+  bool ReadBlock();
+  Byte ReadBlock2();
+
+public:
+  #ifdef _NO_EXCEPTIONS
+  HRESULT ErrorCode;
+  #endif
+
+  CInBuffer();
+  ~CInBuffer() { Free(); }
+
+  bool Create(UInt32 bufferSize);
+  void Free();
+  
+  void SetStream(ISequentialInStream *stream);
+  void Init();
+  void ReleaseStream() { _stream.Release(); }
+
+  bool ReadByte(Byte &b)
+  {
+    if(_buffer >= _bufferLimit)
+      if(!ReadBlock())
+        return false;
+    b = *_buffer++;
+    return true;
+  }
+  Byte ReadByte()
+  {
+    if(_buffer >= _bufferLimit)
+      return ReadBlock2();
+    return *_buffer++;
+  }
+  void ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
+  {
+    for(processedSize = 0; processedSize < size; processedSize++)
+      if (!ReadByte(((Byte *)data)[processedSize]))
+        return;
+  }
+  bool ReadBytes(void *data, UInt32 size)
+  {
+    UInt32 processedSize;
+    ReadBytes(data, size, processedSize);
+    return (processedSize == size);
+  }
+  UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
+  bool WasFinished() const { return _wasFinished; }
+};
+
+#endif
index 45da6d7f009596f60b777cb2c742a3701942828a..a73fa7c5b90140842db69c278a3b06e1173c7d88 100644 (file)
-// OutByte.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "OutBuffer.h"\r
-\r
-#include "../../Common/Alloc.h"\r
-\r
-bool COutBuffer::Create(UInt32 bufferSize)\r
-{\r
-  const UInt32 kMinBlockSize = 1;\r
-  if (bufferSize < kMinBlockSize)\r
-    bufferSize = kMinBlockSize;\r
-  if (_buffer != 0 && _bufferSize == bufferSize)\r
-    return true;\r
-  Free();\r
-  _bufferSize = bufferSize;\r
-  _buffer = (Byte *)::MidAlloc(bufferSize);\r
-  return (_buffer != 0);\r
-}\r
-\r
-void COutBuffer::Free()\r
-{\r
-  ::MidFree(_buffer);\r
-  _buffer = 0;\r
-}\r
-\r
-void COutBuffer::SetStream(ISequentialOutStream *stream)\r
-{\r
-  _stream = stream;\r
-}\r
-\r
-void COutBuffer::Init()\r
-{\r
-  _streamPos = 0;\r
-  _limitPos = _bufferSize;\r
-  _pos = 0;\r
-  _processedSize = 0;\r
-  _overDict = false;\r
-  #ifdef _NO_EXCEPTIONS\r
-  ErrorCode = S_OK;\r
-  #endif\r
-}\r
-\r
-UInt64 COutBuffer::GetProcessedSize() const\r
-{ \r
-  UInt64 res = _processedSize + _pos - _streamPos;\r
-  if (_streamPos > _pos) \r
-    res += _bufferSize;\r
-  return res;\r
-}\r
-\r
-\r
-HRESULT COutBuffer::FlushPart()\r
-{\r
-  // _streamPos < _bufferSize\r
-  UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);\r
-  HRESULT result = S_OK;\r
-  #ifdef _NO_EXCEPTIONS\r
-  result = ErrorCode;\r
-  #endif\r
-  if (_buffer2 != 0)\r
-  {\r
-    memmove(_buffer2, _buffer + _streamPos, size);\r
-    _buffer2 += size;\r
-  }\r
-\r
-  if (_stream != 0\r
-      #ifdef _NO_EXCEPTIONS\r
-      && (ErrorCode == S_OK)\r
-      #endif\r
-     )\r
-  {\r
-    UInt32 processedSize = 0;\r
-    result = _stream->Write(_buffer + _streamPos, size, &processedSize);\r
-    size = processedSize;\r
-  }\r
-  _streamPos += size;\r
-  if (_streamPos == _bufferSize)\r
-    _streamPos = 0;\r
-  if (_pos == _bufferSize)\r
-  {\r
-    _overDict = true;\r
-    _pos = 0;\r
-  }\r
-  _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;\r
-  _processedSize += size;\r
-  return result;\r
-}\r
-\r
-HRESULT COutBuffer::Flush()\r
-{\r
-  #ifdef _NO_EXCEPTIONS\r
-  if (ErrorCode != S_OK)\r
-    return ErrorCode;\r
-  #endif\r
-\r
-  while(_streamPos != _pos)\r
-  {\r
-    HRESULT result = FlushPart();\r
-    if (result != S_OK)\r
-      return result;\r
-  }\r
-  return S_OK;\r
-}\r
-\r
-void COutBuffer::FlushWithCheck()\r
-{\r
-  HRESULT result = FlushPart();\r
-  #ifdef _NO_EXCEPTIONS\r
-  ErrorCode = result;\r
-  #else\r
-  if (result != S_OK)\r
-    throw COutBufferException(result);\r
-  #endif\r
-}\r
+// OutByte.cpp
+
+#include "StdAfx.h"
+
+#include "OutBuffer.h"
+
+#include "../../Common/Alloc.h"
+
+bool COutBuffer::Create(UInt32 bufferSize)
+{
+  const UInt32 kMinBlockSize = 1;
+  if (bufferSize < kMinBlockSize)
+    bufferSize = kMinBlockSize;
+  if (_buffer != 0 && _bufferSize == bufferSize)
+    return true;
+  Free();
+  _bufferSize = bufferSize;
+  _buffer = (Byte *)::MidAlloc(bufferSize);
+  return (_buffer != 0);
+}
+
+void COutBuffer::Free()
+{
+  ::MidFree(_buffer);
+  _buffer = 0;
+}
+
+void COutBuffer::SetStream(ISequentialOutStream *stream)
+{
+  _stream = stream;
+}
+
+void COutBuffer::Init()
+{
+  _streamPos = 0;
+  _limitPos = _bufferSize;
+  _pos = 0;
+  _processedSize = 0;
+  _overDict = false;
+  #ifdef _NO_EXCEPTIONS
+  ErrorCode = S_OK;
+  #endif
+}
+
+UInt64 COutBuffer::GetProcessedSize() const
+{ 
+  UInt64 res = _processedSize + _pos - _streamPos;
+  if (_streamPos > _pos) 
+    res += _bufferSize;
+  return res;
+}
+
+
+HRESULT COutBuffer::FlushPart()
+{
+  // _streamPos < _bufferSize
+  UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);
+  HRESULT result = S_OK;
+  #ifdef _NO_EXCEPTIONS
+  result = ErrorCode;
+  #endif
+  if (_buffer2 != 0)
+  {
+    memmove(_buffer2, _buffer + _streamPos, size);
+    _buffer2 += size;
+  }
+
+  if (_stream != 0
+      #ifdef _NO_EXCEPTIONS
+      && (ErrorCode == S_OK)
+      #endif
+     )
+  {
+    UInt32 processedSize = 0;
+    result = _stream->Write(_buffer + _streamPos, size, &processedSize);
+    size = processedSize;
+  }
+  _streamPos += size;
+  if (_streamPos == _bufferSize)
+    _streamPos = 0;
+  if (_pos == _bufferSize)
+  {
+    _overDict = true;
+    _pos = 0;
+  }
+  _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;
+  _processedSize += size;
+  return result;
+}
+
+HRESULT COutBuffer::Flush()
+{
+  #ifdef _NO_EXCEPTIONS
+  if (ErrorCode != S_OK)
+    return ErrorCode;
+  #endif
+
+  while(_streamPos != _pos)
+  {
+    HRESULT result = FlushPart();
+    if (result != S_OK)
+      return result;
+  }
+  return S_OK;
+}
+
+void COutBuffer::FlushWithCheck()
+{
+  HRESULT result = FlushPart();
+  #ifdef _NO_EXCEPTIONS
+  ErrorCode = result;
+  #else
+  if (result != S_OK)
+    throw COutBufferException(result);
+  #endif
+}
index 37eefbdfcd5bb6668c1f9a111d492f5d52a9cc2d..0ce54e21e61a21132aa06c758575efc0b57d610c 100644 (file)
@@ -1,64 +1,64 @@
-// OutBuffer.h\r
-\r
-#ifndef __OUTBUFFER_H\r
-#define __OUTBUFFER_H\r
-\r
-#include "../IStream.h"\r
-#include "../../Common/MyCom.h"\r
-\r
-#ifndef _NO_EXCEPTIONS\r
-struct COutBufferException\r
-{\r
-  HRESULT ErrorCode;\r
-  COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}\r
-};\r
-#endif\r
-\r
-class COutBuffer\r
-{\r
-protected:\r
-  Byte *_buffer;\r
-  UInt32 _pos;\r
-  UInt32 _limitPos;\r
-  UInt32 _streamPos;\r
-  UInt32 _bufferSize;\r
-  CMyComPtr<ISequentialOutStream> _stream;\r
-  UInt64 _processedSize;\r
-  Byte  *_buffer2;\r
-  bool _overDict;\r
-\r
-  HRESULT FlushPart();\r
-  void FlushWithCheck();\r
-public:\r
-  #ifdef _NO_EXCEPTIONS\r
-  HRESULT ErrorCode;\r
-  #endif\r
-\r
-  COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}\r
-  ~COutBuffer() { Free(); }\r
-  \r
-  bool Create(UInt32 bufferSize);\r
-  void Free();\r
-\r
-  void SetMemStream(Byte *buffer) { _buffer2 = buffer; }\r
-  void SetStream(ISequentialOutStream *stream);\r
-  void Init();\r
-  HRESULT Flush();\r
-  void ReleaseStream() {  _stream.Release(); }\r
-\r
-  void WriteByte(Byte b)\r
-  {\r
-    _buffer[_pos++] = b;\r
-    if(_pos == _limitPos)\r
-      FlushWithCheck();\r
-  }\r
-  void WriteBytes(const void *data, size_t size)\r
-  {\r
-    for (size_t i = 0; i < size; i++)\r
-      WriteByte(((const Byte *)data)[i]);\r
-  }\r
-\r
-  UInt64 GetProcessedSize() const;\r
-};\r
-\r
-#endif\r
+// OutBuffer.h
+
+#ifndef __OUTBUFFER_H
+#define __OUTBUFFER_H
+
+#include "../IStream.h"
+#include "../../Common/MyCom.h"
+
+#ifndef _NO_EXCEPTIONS
+struct COutBufferException
+{
+  HRESULT ErrorCode;
+  COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
+};
+#endif
+
+class COutBuffer
+{
+protected:
+  Byte *_buffer;
+  UInt32 _pos;
+  UInt32 _limitPos;
+  UInt32 _streamPos;
+  UInt32 _bufferSize;
+  CMyComPtr<ISequentialOutStream> _stream;
+  UInt64 _processedSize;
+  Byte  *_buffer2;
+  bool _overDict;
+
+  HRESULT FlushPart();
+  void FlushWithCheck();
+public:
+  #ifdef _NO_EXCEPTIONS
+  HRESULT ErrorCode;
+  #endif
+
+  COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}
+  ~COutBuffer() { Free(); }
+  
+  bool Create(UInt32 bufferSize);
+  void Free();
+
+  void SetMemStream(Byte *buffer) { _buffer2 = buffer; }
+  void SetStream(ISequentialOutStream *stream);
+  void Init();
+  HRESULT Flush();
+  void ReleaseStream() {  _stream.Release(); }
+
+  void WriteByte(Byte b)
+  {
+    _buffer[_pos++] = b;
+    if(_pos == _limitPos)
+      FlushWithCheck();
+  }
+  void WriteBytes(const void *data, size_t size)
+  {
+    for (size_t i = 0; i < size; i++)
+      WriteByte(((const Byte *)data)[i]);
+  }
+
+  UInt64 GetProcessedSize() const;
+};
+
+#endif
index d7d9211b09a08f99fd504e67785cd8d7a042ff42..27a77b104bb180762cfb5d04a45bbf20a969a081 100644 (file)
@@ -1,9 +1,9 @@
-// StdAfx.h\r
-\r
-#ifndef __STDAFX_H\r
-#define __STDAFX_H\r
-\r
-#include "../../Common/MyWindows.h"\r
-#include "../../Common/NewHandler.h"\r
-\r
-#endif \r
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../Common/MyWindows.h"
+#include "../../Common/NewHandler.h"
+
+#endif 
index 712a78585aa0e4f64a4f05577ea37ec9eb6f398c..a5d9ac0ef07fb47cdcd20035cff5c4dda1af9b31 100644 (file)
@@ -1,44 +1,44 @@
-// StreamUtils.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "../../Common/MyCom.h"\r
-#include "StreamUtils.h"\r
-\r
-HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize)\r
-{\r
-  if (processedSize != 0)\r
-    *processedSize = 0;\r
-  while(size != 0)\r
-  {\r
-    UInt32 processedSizeLoc; \r
-    HRESULT res = stream->Read(data, size, &processedSizeLoc);\r
-    if (processedSize != 0)\r
-      *processedSize += processedSizeLoc;\r
-    data = (Byte *)((Byte *)data + processedSizeLoc);\r
-    size -= processedSizeLoc;\r
-    RINOK(res);\r
-    if (processedSizeLoc == 0)\r
-      return S_OK;\r
-  }\r
-  return S_OK;\r
-}\r
-\r
-HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize)\r
-{\r
-  if (processedSize != 0)\r
-    *processedSize = 0;\r
-  while(size != 0)\r
-  {\r
-    UInt32 processedSizeLoc; \r
-    HRESULT res = stream->Write(data, size, &processedSizeLoc);\r
-    if (processedSize != 0)\r
-      *processedSize += processedSizeLoc;\r
-    data = (const void *)((const Byte *)data + processedSizeLoc);\r
-    size -= processedSizeLoc;\r
-    RINOK(res);\r
-    if (processedSizeLoc == 0)\r
-      break;\r
-  }\r
-  return S_OK;\r
-}\r
+// StreamUtils.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyCom.h"
+#include "StreamUtils.h"
+
+HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize)
+{
+  if (processedSize != 0)
+    *processedSize = 0;
+  while(size != 0)
+  {
+    UInt32 processedSizeLoc; 
+    HRESULT res = stream->Read(data, size, &processedSizeLoc);
+    if (processedSize != 0)
+      *processedSize += processedSizeLoc;
+    data = (Byte *)((Byte *)data + processedSizeLoc);
+    size -= processedSizeLoc;
+    RINOK(res);
+    if (processedSizeLoc == 0)
+      return S_OK;
+  }
+  return S_OK;
+}
+
+HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize)
+{
+  if (processedSize != 0)
+    *processedSize = 0;
+  while(size != 0)
+  {
+    UInt32 processedSizeLoc; 
+    HRESULT res = stream->Write(data, size, &processedSizeLoc);
+    if (processedSize != 0)
+      *processedSize += processedSizeLoc;
+    data = (const void *)((const Byte *)data + processedSizeLoc);
+    size -= processedSizeLoc;
+    RINOK(res);
+    if (processedSizeLoc == 0)
+      break;
+  }
+  return S_OK;
+}
index c8cd8cef1a02fd49f2080843f130a171b52718cc..59f88733f685a54539fb621900ce4efa20afa7f7 100644 (file)
@@ -1,11 +1,11 @@
-// StreamUtils.h\r
-\r
-#ifndef __STREAMUTILS_H\r
-#define __STREAMUTILS_H\r
-\r
-#include "../IStream.h"\r
-\r
-HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize);\r
-HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize);\r
-\r
-#endif\r
+// StreamUtils.h
+
+#ifndef __STREAMUTILS_H
+#define __STREAMUTILS_H
+
+#include "../IStream.h"
+
+HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize);
+HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize);
+
+#endif
index d464d3b59c7bc833a43b60e719520f48f0f8c327..b3b3f13a564ca421486259cc60664bce9998cea0 100644 (file)
@@ -1,54 +1,54 @@
-// BinTree.h\r
-\r
-#include "../LZInWindow.h"\r
-#include "../IMatchFinder.h"\r
\r
-namespace BT_NAMESPACE {\r
-\r
-typedef UInt32 CIndex;\r
-const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1;\r
-\r
-class CMatchFinder: \r
-  public IMatchFinder,\r
-  public CLZInWindow,\r
-  public CMyUnknownImp,\r
-  public IMatchFinderSetNumPasses\r
-{\r
-  UInt32 _cyclicBufferPos;\r
-  UInt32 _cyclicBufferSize; // it must be historySize + 1\r
-  UInt32 _matchMaxLen;\r
-  CIndex *_hash;\r
-  CIndex *_son;\r
-  UInt32 _hashMask;\r
-  UInt32 _cutValue;\r
-  UInt32 _hashSizeSum;\r
-\r
-  void Normalize();\r
-  void FreeThisClassMemory();\r
-  void FreeMemory();\r
-\r
-  MY_UNKNOWN_IMP\r
-\r
-  STDMETHOD(SetStream)(ISequentialInStream *inStream);\r
-  STDMETHOD_(void, ReleaseStream)();\r
-  STDMETHOD(Init)();\r
-  HRESULT MovePos();\r
-  STDMETHOD_(Byte, GetIndexByte)(Int32 index);\r
-  STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit);\r
-  STDMETHOD_(UInt32, GetNumAvailableBytes)();\r
-  STDMETHOD_(const Byte *, GetPointerToCurrentPos)();\r
-  STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);\r
-  STDMETHOD_(void, ChangeBufferPos)();\r
-\r
-  STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, \r
-      UInt32 matchMaxLen, UInt32 keepAddBufferAfter);\r
-  STDMETHOD(GetMatches)(UInt32 *distances);\r
-  STDMETHOD(Skip)(UInt32 num);\r
-\r
-public:\r
-  CMatchFinder();\r
-  virtual ~CMatchFinder();\r
-  virtual void SetNumPasses(UInt32 numPasses) { _cutValue = numPasses; }\r
-};\r
-\r
-}\r
+// BinTree.h
+
+#include "../LZInWindow.h"
+#include "../IMatchFinder.h"
+namespace BT_NAMESPACE {
+
+typedef UInt32 CIndex;
+const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1;
+
+class CMatchFinder: 
+  public IMatchFinder,
+  public CLZInWindow,
+  public CMyUnknownImp,
+  public IMatchFinderSetNumPasses
+{
+  UInt32 _cyclicBufferPos;
+  UInt32 _cyclicBufferSize; // it must be historySize + 1
+  UInt32 _matchMaxLen;
+  CIndex *_hash;
+  CIndex *_son;
+  UInt32 _hashMask;
+  UInt32 _cutValue;
+  UInt32 _hashSizeSum;
+
+  void Normalize();
+  void FreeThisClassMemory();
+  void FreeMemory();
+
+  MY_UNKNOWN_IMP
+
+  STDMETHOD(SetStream)(ISequentialInStream *inStream);
+  STDMETHOD_(void, ReleaseStream)();
+  STDMETHOD(Init)();
+  HRESULT MovePos();
+  STDMETHOD_(Byte, GetIndexByte)(Int32 index);
+  STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit);
+  STDMETHOD_(UInt32, GetNumAvailableBytes)();
+  STDMETHOD_(const Byte *, GetPointerToCurrentPos)();
+  STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);
+  STDMETHOD_(void, ChangeBufferPos)();
+
+  STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, 
+      UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
+  STDMETHOD(GetMatches)(UInt32 *distances);
+  STDMETHOD(Skip)(UInt32 num);
+
+public:
+  CMatchFinder();
+  virtual ~CMatchFinder();
+  virtual void SetNumPasses(UInt32 numPasses) { _cutValue = numPasses; }
+};
+
+}
index c5b3939e47a3b26387f02b035be3ffe6ebb0b85b..74ca8d9d0eacced53066cc7da3579c23c80406d8 100644 (file)
@@ -1,12 +1,12 @@
-// BinTree2.h\r
-\r
-#ifndef __BINTREE2_H\r
-#define __BINTREE2_H\r
-\r
-#define BT_NAMESPACE NBT2\r
-\r
-#include "BinTreeMain.h"\r
-\r
-#undef BT_NAMESPACE\r
-\r
-#endif\r
+// BinTree2.h
+
+#ifndef __BINTREE2_H
+#define __BINTREE2_H
+
+#define BT_NAMESPACE NBT2
+
+#include "BinTreeMain.h"
+
+#undef BT_NAMESPACE
+
+#endif
index 74eb73e293dd3f8f55e168278cb9b23508d27980..76bd9ddd431d6d13e99cd569906e9e63478122bd 100644 (file)
@@ -1,16 +1,16 @@
-// BinTree3.h\r
-\r
-#ifndef __BINTREE3_H\r
-#define __BINTREE3_H\r
-\r
-#define BT_NAMESPACE NBT3\r
-\r
-#define HASH_ARRAY_2\r
-\r
-#include "BinTreeMain.h"\r
-\r
-#undef HASH_ARRAY_2\r
-\r
-#undef BT_NAMESPACE\r
-\r
-#endif\r
+// BinTree3.h
+
+#ifndef __BINTREE3_H
+#define __BINTREE3_H
+
+#define BT_NAMESPACE NBT3
+
+#define HASH_ARRAY_2
+
+#include "BinTreeMain.h"
+
+#undef HASH_ARRAY_2
+
+#undef BT_NAMESPACE
+
+#endif
index 62fc242aacadd2451801d4c134a8d38efc1d02fd..08e2d1ced6bd489cae168ed6d32212416027fd52 100644 (file)
@@ -1,18 +1,18 @@
-// BinTree4.h\r
-\r
-#ifndef __BINTREE4_H\r
-#define __BINTREE4_H\r
-\r
-#define BT_NAMESPACE NBT4\r
-\r
-#define HASH_ARRAY_2\r
-#define HASH_ARRAY_3\r
-\r
-#include "BinTreeMain.h"\r
-\r
-#undef HASH_ARRAY_2\r
-#undef HASH_ARRAY_3\r
-\r
-#undef BT_NAMESPACE\r
-\r
-#endif\r
+// BinTree4.h
+
+#ifndef __BINTREE4_H
+#define __BINTREE4_H
+
+#define BT_NAMESPACE NBT4
+
+#define HASH_ARRAY_2
+#define HASH_ARRAY_3
+
+#include "BinTreeMain.h"
+
+#undef HASH_ARRAY_2
+#undef HASH_ARRAY_3
+
+#undef BT_NAMESPACE
+
+#endif
index 61d11210432357ae71e1aa46d308a720a1a4b517..7a6f621a069f1ccd9c373261ecd075bc1acef522 100644 (file)
-// BinTreeMain.h\r
-\r
-#include "../../../../Common/Defs.h"\r
-#include "../../../../Common/CRC.h"\r
-#include "../../../../Common/Alloc.h"\r
-\r
-#include "BinTree.h"\r
-\r
-// #include <xmmintrin.h>\r
-// It's for prefetch\r
-// But prefetch doesn't give big gain in K8.\r
-\r
-namespace BT_NAMESPACE {\r
-\r
-#ifdef HASH_ARRAY_2\r
-  static const UInt32 kHash2Size = 1 << 10;\r
-  #define kNumHashDirectBytes 0\r
-  #ifdef HASH_ARRAY_3\r
-    static const UInt32 kNumHashBytes = 4;\r
-    static const UInt32 kHash3Size = 1 << 16;\r
-  #else\r
-    static const UInt32 kNumHashBytes = 3;\r
-  #endif\r
-  static const UInt32 kHashSize = 0;\r
-  static const UInt32 kMinMatchCheck = kNumHashBytes;\r
-  static const UInt32 kStartMaxLen = 1;\r
-#else\r
-  #ifdef HASH_ZIP \r
-    #define kNumHashDirectBytes 0\r
-    static const UInt32 kNumHashBytes = 3;\r
-    static const UInt32 kHashSize = 1 << 16;\r
-    static const UInt32 kMinMatchCheck = kNumHashBytes;\r
-    static const UInt32 kStartMaxLen = 1;\r
-  #else\r
-    #define kNumHashDirectBytes 2\r
-    static const UInt32 kNumHashBytes = 2;\r
-    static const UInt32 kHashSize = 1 << (8 * kNumHashBytes);\r
-    static const UInt32 kMinMatchCheck = kNumHashBytes + 1;\r
-    static const UInt32 kStartMaxLen = 1;\r
-  #endif\r
-#endif\r
-\r
-#ifdef HASH_ARRAY_2\r
-#ifdef HASH_ARRAY_3\r
-static const UInt32 kHash3Offset = kHash2Size;\r
-#endif\r
-#endif\r
-\r
-static const UInt32 kFixHashSize = 0\r
-    #ifdef HASH_ARRAY_2\r
-    + kHash2Size\r
-    #ifdef HASH_ARRAY_3\r
-    + kHash3Size\r
-    #endif\r
-    #endif\r
-    ;\r
-\r
-CMatchFinder::CMatchFinder():\r
-  _hash(0)\r
-{\r
-}\r
-\r
-void CMatchFinder::FreeThisClassMemory()\r
-{\r
-  BigFree(_hash);\r
-  _hash = 0;\r
-}\r
-\r
-void CMatchFinder::FreeMemory()\r
-{\r
-  FreeThisClassMemory();\r
-  CLZInWindow::Free();\r
-}\r
-\r
-CMatchFinder::~CMatchFinder()\r
-{ \r
-  FreeMemory();\r
-}\r
-\r
-STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore, \r
-    UInt32 matchMaxLen, UInt32 keepAddBufferAfter)\r
-{\r
-  if (historySize > kMaxValForNormalize - 256)\r
-  {\r
-    FreeMemory();\r
-    return E_INVALIDARG;\r
-  }\r
-  _cutValue = \r
-  #ifdef _HASH_CHAIN\r
-    8 + (matchMaxLen >> 2);\r
-  #else\r
-    16 + (matchMaxLen >> 1);\r
-  #endif\r
-  UInt32 sizeReserv = (historySize + keepAddBufferBefore + \r
-      matchMaxLen + keepAddBufferAfter) / 2 + 256;\r
-  if (CLZInWindow::Create(historySize + keepAddBufferBefore, \r
-      matchMaxLen + keepAddBufferAfter, sizeReserv))\r
-  {\r
-    _matchMaxLen = matchMaxLen;\r
-    UInt32 newCyclicBufferSize = historySize + 1;\r
-    if (_hash != 0 && newCyclicBufferSize == _cyclicBufferSize)\r
-      return S_OK;\r
-    FreeThisClassMemory();\r
-    _cyclicBufferSize = newCyclicBufferSize; // don't change it\r
-\r
-    UInt32 hs = kHashSize;\r
-\r
-    #ifdef HASH_ARRAY_2\r
-    hs = historySize - 1;\r
-    hs |= (hs >> 1);\r
-    hs |= (hs >> 2);\r
-    hs |= (hs >> 4);\r
-    hs |= (hs >> 8);\r
-    hs >>= 1;\r
-    hs |= 0xFFFF;\r
-    if (hs > (1 << 24))\r
-    {\r
-      #ifdef HASH_ARRAY_3\r
-      hs >>= 1;\r
-      #else\r
-      hs = (1 << 24) - 1;\r
-      #endif\r
-    }\r
-    _hashMask = hs;\r
-    hs++;\r
-    #endif\r
-    _hashSizeSum = hs + kFixHashSize;\r
-    UInt32 numItems = _hashSizeSum + _cyclicBufferSize\r
-    #ifndef _HASH_CHAIN\r
-     * 2\r
-    #endif\r
-    ;\r
-    size_t sizeInBytes = (size_t)numItems * sizeof(CIndex);\r
-    if (sizeInBytes / sizeof(CIndex) != numItems)\r
-      return E_OUTOFMEMORY;\r
-    _hash = (CIndex *)BigAlloc(sizeInBytes);\r
-    _son = _hash + _hashSizeSum;\r
-    if (_hash != 0)\r
-      return S_OK;\r
-  }\r
-  FreeMemory();\r
-  return E_OUTOFMEMORY;\r
-}\r
-\r
-static const UInt32 kEmptyHashValue = 0;\r
-\r
-STDMETHODIMP CMatchFinder::SetStream(ISequentialInStream *stream)\r
-{\r
-  CLZInWindow::SetStream(stream);\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP CMatchFinder::Init()\r
-{\r
-  RINOK(CLZInWindow::Init());\r
-  for(UInt32 i = 0; i < _hashSizeSum; i++)\r
-    _hash[i] = kEmptyHashValue;\r
-  _cyclicBufferPos = 0;\r
-  ReduceOffsets(-1);\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP_(void) CMatchFinder::ReleaseStream()\r
-{ \r
-  // ReleaseStream(); \r
-}\r
-\r
-#ifdef HASH_ARRAY_2\r
-#ifdef HASH_ARRAY_3\r
-\r
-#define HASH_CALC { \\r
-  UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \\r
-  hash2Value = temp & (kHash2Size - 1); \\r
-  hash3Value = (temp ^ (UInt32(cur[2]) << 8)) & (kHash3Size - 1); \\r
-  hashValue = (temp ^ (UInt32(cur[2]) << 8) ^ (CCRC::Table[cur[3]] << 5)) & _hashMask; }\r
-  \r
-#else // no HASH_ARRAY_3\r
-#define HASH_CALC { \\r
-  UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \\r
-  hash2Value = temp & (kHash2Size - 1); \\r
-  hashValue = (temp ^ (UInt32(cur[2]) << 8)) & _hashMask; }\r
-#endif // HASH_ARRAY_3\r
-#else // no HASH_ARRAY_2\r
-#ifdef HASH_ZIP \r
-inline UInt32 Hash(const Byte *pointer)\r
-{\r
-  return ((UInt32(pointer[0]) << 8) ^ CCRC::Table[pointer[1]] ^ pointer[2]) & (kHashSize - 1);\r
-}\r
-#else // no HASH_ZIP \r
-inline UInt32 Hash(const Byte *pointer)\r
-{\r
-  return pointer[0] ^ (UInt32(pointer[1]) << 8);\r
-}\r
-#endif // HASH_ZIP\r
-#endif // HASH_ARRAY_2\r
-\r
-STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances)\r
-{\r
-  UInt32 lenLimit;\r
-  if (_pos + _matchMaxLen <= _streamPos)\r
-    lenLimit = _matchMaxLen;\r
-  else\r
-  {\r
-    lenLimit = _streamPos - _pos;\r
-    if(lenLimit < kMinMatchCheck)\r
-    {\r
-      distances[0] = 0;\r
-      return MovePos(); \r
-    }\r
-  }\r
-\r
-  int offset = 1;\r
-\r
-  UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;\r
-  const Byte *cur = _buffer + _pos;\r
-\r
-  UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize;\r
-\r
-  #ifdef HASH_ARRAY_2\r
-  UInt32 hash2Value;\r
-  #ifdef HASH_ARRAY_3\r
-  UInt32 hash3Value;\r
-  #endif\r
-  UInt32 hashValue;\r
-  HASH_CALC;\r
-  #else\r
-  UInt32 hashValue = Hash(cur);\r
-  #endif\r
-\r
-  UInt32 curMatch = _hash[kFixHashSize + hashValue];\r
-  #ifdef HASH_ARRAY_2\r
-  UInt32 curMatch2 = _hash[hash2Value];\r
-  #ifdef HASH_ARRAY_3\r
-  UInt32 curMatch3 = _hash[kHash3Offset + hash3Value];\r
-  #endif\r
-  _hash[hash2Value] = _pos;\r
-  if(curMatch2 > matchMinPos)\r
-    if (_buffer[curMatch2] == cur[0])\r
-    {\r
-      distances[offset++] = maxLen = 2;\r
-      distances[offset++] = _pos - curMatch2 - 1;\r
-    }\r
-\r
-  #ifdef HASH_ARRAY_3\r
-  _hash[kHash3Offset + hash3Value] = _pos;\r
-  if(curMatch3 > matchMinPos)\r
-    if (_buffer[curMatch3] == cur[0])\r
-    {\r
-      if (curMatch3 == curMatch2)\r
-        offset -= 2;\r
-      distances[offset++] = maxLen = 3;\r
-      distances[offset++] = _pos - curMatch3 - 1;\r
-      curMatch2 = curMatch3;\r
-    }\r
-  #endif\r
-  if (offset != 1 && curMatch2 == curMatch)\r
-  {\r
-    offset -= 2;\r
-    maxLen = kStartMaxLen;\r
-  }\r
-  #endif\r
-\r
-  _hash[kFixHashSize + hashValue] = _pos;\r
-\r
-  CIndex *son = _son;\r
-\r
-  #ifdef _HASH_CHAIN\r
-  son[_cyclicBufferPos] = curMatch;\r
-  #else\r
-  CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CIndex *ptr1 = son + (_cyclicBufferPos << 1);\r
-\r
-  UInt32 len0, len1;\r
-  len0 = len1 = kNumHashDirectBytes;\r
-  #endif\r
-\r
-  #if kNumHashDirectBytes != 0\r
-  if(curMatch > matchMinPos)\r
-  {\r
-    if (_buffer[curMatch + kNumHashDirectBytes] != cur[kNumHashDirectBytes])\r
-    {\r
-      distances[offset++] = maxLen = kNumHashDirectBytes;\r
-      distances[offset++] = _pos - curMatch - 1;\r
-    }\r
-  }\r
-  #endif\r
-  UInt32 count = _cutValue;\r
-  while(true)\r
-  {\r
-    if(curMatch <= matchMinPos || count-- == 0)\r
-    {\r
-      #ifndef _HASH_CHAIN\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      #endif\r
-      break;\r
-    }\r
-    UInt32 delta = _pos - curMatch;\r
-    UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?\r
-        (_cyclicBufferPos - delta):\r
-        (_cyclicBufferPos - delta + _cyclicBufferSize);\r
-    CIndex *pair = son + \r
-    #ifdef _HASH_CHAIN\r
-      cyclicPos;\r
-    #else\r
-      (cyclicPos << 1);\r
-    #endif\r
-    \r
-    // _mm_prefetch((const char *)pair, _MM_HINT_T0);\r
-    \r
-    const Byte *pb = _buffer + curMatch;\r
-    UInt32 len = \r
-    #ifdef _HASH_CHAIN\r
-    kNumHashDirectBytes;\r
-    if (pb[maxLen] == cur[maxLen])\r
-    #else\r
-    MyMin(len0, len1);\r
-    #endif\r
-    if (pb[len] == cur[len])\r
-    {\r
-      while(++len != lenLimit)\r
-        if (pb[len] != cur[len])\r
-          break;\r
-      if (maxLen < len)\r
-      {\r
-        distances[offset++] = maxLen = len;\r
-        distances[offset++] = delta - 1;\r
-        if (len == lenLimit)\r
-        {\r
-          #ifndef _HASH_CHAIN\r
-          *ptr1 = pair[0];\r
-          *ptr0 = pair[1];\r
-          #endif\r
-          break;\r
-        }\r
-      }\r
-    }\r
-    #ifdef _HASH_CHAIN\r
-    curMatch = *pair;\r
-    #else\r
-    if (pb[len] < cur[len])\r
-    {\r
-      *ptr1 = curMatch;\r
-      ptr1 = pair + 1;\r
-      curMatch = *ptr1;\r
-      len1 = len;\r
-    }\r
-    else\r
-    {\r
-      *ptr0 = curMatch;\r
-      ptr0 = pair;\r
-      curMatch = *ptr0;\r
-      len0 = len;\r
-    }\r
-    #endif\r
-  }\r
-  distances[0] = offset - 1;\r
-  if (++_cyclicBufferPos == _cyclicBufferSize)\r
-    _cyclicBufferPos = 0;\r
-  RINOK(CLZInWindow::MovePos());\r
-  if (_pos == kMaxValForNormalize)\r
-    Normalize();\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP CMatchFinder::Skip(UInt32 num)\r
-{\r
-  do\r
-  {\r
-  #ifdef _HASH_CHAIN\r
-  if (_streamPos - _pos < kNumHashBytes)\r
-  {\r
-    RINOK(MovePos()); \r
-    continue;\r
-  }\r
-  #else\r
-  UInt32 lenLimit;\r
-  if (_pos + _matchMaxLen <= _streamPos)\r
-    lenLimit = _matchMaxLen;\r
-  else\r
-  {\r
-    lenLimit = _streamPos - _pos;\r
-    if(lenLimit < kMinMatchCheck)\r
-    {\r
-      RINOK(MovePos());\r
-      continue;\r
-    }\r
-  }\r
-  UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;\r
-  #endif\r
-  const Byte *cur = _buffer + _pos;\r
-\r
-  #ifdef HASH_ARRAY_2\r
-  UInt32 hash2Value;\r
-  #ifdef HASH_ARRAY_3\r
-  UInt32 hash3Value;\r
-  UInt32 hashValue;\r
-  HASH_CALC;\r
-  _hash[kHash3Offset + hash3Value] = _pos;\r
-  #else\r
-  UInt32 hashValue;\r
-  HASH_CALC;\r
-  #endif\r
-  _hash[hash2Value] = _pos;\r
-  #else\r
-  UInt32 hashValue = Hash(cur);\r
-  #endif\r
-\r
-  UInt32 curMatch = _hash[kFixHashSize + hashValue];\r
-  _hash[kFixHashSize + hashValue] = _pos;\r
-\r
-  #ifdef _HASH_CHAIN\r
-  _son[_cyclicBufferPos] = curMatch;\r
-  #else\r
-  CIndex *son = _son;\r
-  CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CIndex *ptr1 = son + (_cyclicBufferPos << 1);\r
-\r
-  UInt32 len0, len1;\r
-  len0 = len1 = kNumHashDirectBytes;\r
-  UInt32 count = _cutValue;\r
-  while(true)\r
-  {\r
-    if(curMatch <= matchMinPos || count-- == 0)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      break;\r
-    }\r
-    \r
-    UInt32 delta = _pos - curMatch;\r
-    UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?\r
-      (_cyclicBufferPos - delta):\r
-      (_cyclicBufferPos - delta + _cyclicBufferSize);\r
-    CIndex *pair = son + (cyclicPos << 1);\r
-    \r
-    // _mm_prefetch((const char *)pair, _MM_HINT_T0);\r
-    \r
-    const Byte *pb = _buffer + curMatch;\r
-    UInt32 len = MyMin(len0, len1);\r
-    \r
-    if (pb[len] == cur[len])\r
-    {\r
-      while(++len != lenLimit)\r
-        if (pb[len] != cur[len])\r
-          break;\r
-      if (len == lenLimit)\r
-      {\r
-        *ptr1 = pair[0];\r
-        *ptr0 = pair[1];\r
-        break;\r
-      }\r
-    }\r
-    if (pb[len] < cur[len])\r
-    {\r
-      *ptr1 = curMatch;\r
-      ptr1 = pair + 1;\r
-      curMatch = *ptr1;\r
-      len1 = len;\r
-    }\r
-    else\r
-    {\r
-      *ptr0 = curMatch;\r
-      ptr0 = pair;\r
-      curMatch = *ptr0;\r
-      len0 = len;\r
-    }\r
-  }\r
-  #endif\r
-  if (++_cyclicBufferPos == _cyclicBufferSize)\r
-    _cyclicBufferPos = 0;\r
-  RINOK(CLZInWindow::MovePos());\r
-  if (_pos == kMaxValForNormalize)\r
-    Normalize();\r
-  }\r
-  while(--num != 0);\r
-  return S_OK;\r
-}\r
-\r
-void CMatchFinder::Normalize()\r
-{\r
-  UInt32 subValue = _pos - _cyclicBufferSize;\r
-  CIndex *items = _hash;\r
-  UInt32 numItems = (_hashSizeSum + _cyclicBufferSize \r
-    #ifndef _HASH_CHAIN\r
-     * 2\r
-    #endif\r
-    );\r
-  for (UInt32 i = 0; i < numItems; i++)\r
-  {\r
-    UInt32 value = items[i];\r
-    if (value <= subValue)\r
-      value = kEmptyHashValue;\r
-    else\r
-      value -= subValue;\r
-    items[i] = value;\r
-  }\r
-  ReduceOffsets(subValue);\r
-}\r
-\r
-HRESULT CMatchFinder::MovePos()\r
-{\r
-  if (++_cyclicBufferPos == _cyclicBufferSize)\r
-    _cyclicBufferPos = 0;\r
-  RINOK(CLZInWindow::MovePos());\r
-  if (_pos == kMaxValForNormalize)\r
-    Normalize();\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP_(Byte) CMatchFinder::GetIndexByte(Int32 index)\r
-  { return CLZInWindow::GetIndexByte(index); }\r
-\r
-STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index, \r
-    UInt32 back, UInt32 limit)\r
-  { return CLZInWindow::GetMatchLen(index, back, limit); }\r
-\r
-STDMETHODIMP_(UInt32) CMatchFinder::GetNumAvailableBytes()\r
-  { return CLZInWindow::GetNumAvailableBytes(); }\r
-\r
-STDMETHODIMP_(const Byte *) CMatchFinder::GetPointerToCurrentPos()\r
-  { return CLZInWindow::GetPointerToCurrentPos(); }\r
-\r
-STDMETHODIMP_(Int32) CMatchFinder::NeedChangeBufferPos(UInt32 numCheckBytes)\r
-  { return CLZInWindow::NeedMove(numCheckBytes) ? 1: 0; }\r
-\r
-STDMETHODIMP_(void) CMatchFinder::ChangeBufferPos()\r
-  { CLZInWindow::MoveBlock();}\r
-\r
-#undef HASH_CALC\r
-#undef kNumHashDirectBytes\r
\r
-}\r
+// BinTreeMain.h
+
+#include "../../../../Common/Defs.h"
+#include "../../../../Common/CRC.h"
+#include "../../../../Common/Alloc.h"
+
+#include "BinTree.h"
+
+// #include <xmmintrin.h>
+// It's for prefetch
+// But prefetch doesn't give big gain in K8.
+
+namespace BT_NAMESPACE {
+
+#ifdef HASH_ARRAY_2
+  static const UInt32 kHash2Size = 1 << 10;
+  #define kNumHashDirectBytes 0
+  #ifdef HASH_ARRAY_3
+    static const UInt32 kNumHashBytes = 4;
+    static const UInt32 kHash3Size = 1 << 16;
+  #else
+    static const UInt32 kNumHashBytes = 3;
+  #endif
+  static const UInt32 kHashSize = 0;
+  static const UInt32 kMinMatchCheck = kNumHashBytes;
+  static const UInt32 kStartMaxLen = 1;
+#else
+  #ifdef HASH_ZIP 
+    #define kNumHashDirectBytes 0
+    static const UInt32 kNumHashBytes = 3;
+    static const UInt32 kHashSize = 1 << 16;
+    static const UInt32 kMinMatchCheck = kNumHashBytes;
+    static const UInt32 kStartMaxLen = 1;
+  #else
+    #define kNumHashDirectBytes 2
+    static const UInt32 kNumHashBytes = 2;
+    static const UInt32 kHashSize = 1 << (8 * kNumHashBytes);
+    static const UInt32 kMinMatchCheck = kNumHashBytes + 1;
+    static const UInt32 kStartMaxLen = 1;
+  #endif
+#endif
+
+#ifdef HASH_ARRAY_2
+#ifdef HASH_ARRAY_3
+static const UInt32 kHash3Offset = kHash2Size;
+#endif
+#endif
+
+static const UInt32 kFixHashSize = 0
+    #ifdef HASH_ARRAY_2
+    + kHash2Size
+    #ifdef HASH_ARRAY_3
+    + kHash3Size
+    #endif
+    #endif
+    ;
+
+CMatchFinder::CMatchFinder():
+  _hash(0)
+{
+}
+
+void CMatchFinder::FreeThisClassMemory()
+{
+  BigFree(_hash);
+  _hash = 0;
+}
+
+void CMatchFinder::FreeMemory()
+{
+  FreeThisClassMemory();
+  CLZInWindow::Free();
+}
+
+CMatchFinder::~CMatchFinder()
+{ 
+  FreeMemory();
+}
+
+STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore, 
+    UInt32 matchMaxLen, UInt32 keepAddBufferAfter)
+{
+  if (historySize > kMaxValForNormalize - 256)
+  {
+    FreeMemory();
+    return E_INVALIDARG;
+  }
+  _cutValue = 
+  #ifdef _HASH_CHAIN
+    8 + (matchMaxLen >> 2);
+  #else
+    16 + (matchMaxLen >> 1);
+  #endif
+  UInt32 sizeReserv = (historySize + keepAddBufferBefore + 
+      matchMaxLen + keepAddBufferAfter) / 2 + 256;
+  if (CLZInWindow::Create(historySize + keepAddBufferBefore, 
+      matchMaxLen + keepAddBufferAfter, sizeReserv))
+  {
+    _matchMaxLen = matchMaxLen;
+    UInt32 newCyclicBufferSize = historySize + 1;
+    if (_hash != 0 && newCyclicBufferSize == _cyclicBufferSize)
+      return S_OK;
+    FreeThisClassMemory();
+    _cyclicBufferSize = newCyclicBufferSize; // don't change it
+
+    UInt32 hs = kHashSize;
+
+    #ifdef HASH_ARRAY_2
+    hs = historySize - 1;
+    hs |= (hs >> 1);
+    hs |= (hs >> 2);
+    hs |= (hs >> 4);
+    hs |= (hs >> 8);
+    hs >>= 1;
+    hs |= 0xFFFF;
+    if (hs > (1 << 24))
+    {
+      #ifdef HASH_ARRAY_3
+      hs >>= 1;
+      #else
+      hs = (1 << 24) - 1;
+      #endif
+    }
+    _hashMask = hs;
+    hs++;
+    #endif
+    _hashSizeSum = hs + kFixHashSize;
+    UInt32 numItems = _hashSizeSum + _cyclicBufferSize
+    #ifndef _HASH_CHAIN
+     * 2
+    #endif
+    ;
+    size_t sizeInBytes = (size_t)numItems * sizeof(CIndex);
+    if (sizeInBytes / sizeof(CIndex) != numItems)
+      return E_OUTOFMEMORY;
+    _hash = (CIndex *)BigAlloc(sizeInBytes);
+    _son = _hash + _hashSizeSum;
+    if (_hash != 0)
+      return S_OK;
+  }
+  FreeMemory();
+  return E_OUTOFMEMORY;
+}
+
+static const UInt32 kEmptyHashValue = 0;
+
+STDMETHODIMP CMatchFinder::SetStream(ISequentialInStream *stream)
+{
+  CLZInWindow::SetStream(stream);
+  return S_OK;
+}
+
+STDMETHODIMP CMatchFinder::Init()
+{
+  RINOK(CLZInWindow::Init());
+  for(UInt32 i = 0; i < _hashSizeSum; i++)
+    _hash[i] = kEmptyHashValue;
+  _cyclicBufferPos = 0;
+  ReduceOffsets(-1);
+  return S_OK;
+}
+
+STDMETHODIMP_(void) CMatchFinder::ReleaseStream()
+{ 
+  // ReleaseStream(); 
+}
+
+#ifdef HASH_ARRAY_2
+#ifdef HASH_ARRAY_3
+
+#define HASH_CALC { \
+  UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
+  hash2Value = temp & (kHash2Size - 1); \
+  hash3Value = (temp ^ (UInt32(cur[2]) << 8)) & (kHash3Size - 1); \
+  hashValue = (temp ^ (UInt32(cur[2]) << 8) ^ (CCRC::Table[cur[3]] << 5)) & _hashMask; }
+  
+#else // no HASH_ARRAY_3
+#define HASH_CALC { \
+  UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
+  hash2Value = temp & (kHash2Size - 1); \
+  hashValue = (temp ^ (UInt32(cur[2]) << 8)) & _hashMask; }
+#endif // HASH_ARRAY_3
+#else // no HASH_ARRAY_2
+#ifdef HASH_ZIP 
+inline UInt32 Hash(const Byte *pointer)
+{
+  return ((UInt32(pointer[0]) << 8) ^ CCRC::Table[pointer[1]] ^ pointer[2]) & (kHashSize - 1);
+}
+#else // no HASH_ZIP 
+inline UInt32 Hash(const Byte *pointer)
+{
+  return pointer[0] ^ (UInt32(pointer[1]) << 8);
+}
+#endif // HASH_ZIP
+#endif // HASH_ARRAY_2
+
+STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances)
+{
+  UInt32 lenLimit;
+  if (_pos + _matchMaxLen <= _streamPos)
+    lenLimit = _matchMaxLen;
+  else
+  {
+    lenLimit = _streamPos - _pos;
+    if(lenLimit < kMinMatchCheck)
+    {
+      distances[0] = 0;
+      return MovePos(); 
+    }
+  }
+
+  int offset = 1;
+
+  UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
+  const Byte *cur = _buffer + _pos;
+
+  UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize;
+
+  #ifdef HASH_ARRAY_2
+  UInt32 hash2Value;
+  #ifdef HASH_ARRAY_3
+  UInt32 hash3Value;
+  #endif
+  UInt32 hashValue;
+  HASH_CALC;
+  #else
+  UInt32 hashValue = Hash(cur);
+  #endif
+
+  UInt32 curMatch = _hash[kFixHashSize + hashValue];
+  #ifdef HASH_ARRAY_2
+  UInt32 curMatch2 = _hash[hash2Value];
+  #ifdef HASH_ARRAY_3
+  UInt32 curMatch3 = _hash[kHash3Offset + hash3Value];
+  #endif
+  _hash[hash2Value] = _pos;
+  if(curMatch2 > matchMinPos)
+    if (_buffer[curMatch2] == cur[0])
+    {
+      distances[offset++] = maxLen = 2;
+      distances[offset++] = _pos - curMatch2 - 1;
+    }
+
+  #ifdef HASH_ARRAY_3
+  _hash[kHash3Offset + hash3Value] = _pos;
+  if(curMatch3 > matchMinPos)
+    if (_buffer[curMatch3] == cur[0])
+    {
+      if (curMatch3 == curMatch2)
+        offset -= 2;
+      distances[offset++] = maxLen = 3;
+      distances[offset++] = _pos - curMatch3 - 1;
+      curMatch2 = curMatch3;
+    }
+  #endif
+  if (offset != 1 && curMatch2 == curMatch)
+  {
+    offset -= 2;
+    maxLen = kStartMaxLen;
+  }
+  #endif
+
+  _hash[kFixHashSize + hashValue] = _pos;
+
+  CIndex *son = _son;
+
+  #ifdef _HASH_CHAIN
+  son[_cyclicBufferPos] = curMatch;
+  #else
+  CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+  CIndex *ptr1 = son + (_cyclicBufferPos << 1);
+
+  UInt32 len0, len1;
+  len0 = len1 = kNumHashDirectBytes;
+  #endif
+
+  #if kNumHashDirectBytes != 0
+  if(curMatch > matchMinPos)
+  {
+    if (_buffer[curMatch + kNumHashDirectBytes] != cur[kNumHashDirectBytes])
+    {
+      distances[offset++] = maxLen = kNumHashDirectBytes;
+      distances[offset++] = _pos - curMatch - 1;
+    }
+  }
+  #endif
+  UInt32 count = _cutValue;
+  while(true)
+  {
+    if(curMatch <= matchMinPos || count-- == 0)
+    {
+      #ifndef _HASH_CHAIN
+      *ptr0 = *ptr1 = kEmptyHashValue;
+      #endif
+      break;
+    }
+    UInt32 delta = _pos - curMatch;
+    UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
+        (_cyclicBufferPos - delta):
+        (_cyclicBufferPos - delta + _cyclicBufferSize);
+    CIndex *pair = son + 
+    #ifdef _HASH_CHAIN
+      cyclicPos;
+    #else
+      (cyclicPos << 1);
+    #endif
+    
+    // _mm_prefetch((const char *)pair, _MM_HINT_T0);
+    
+    const Byte *pb = _buffer + curMatch;
+    UInt32 len = 
+    #ifdef _HASH_CHAIN
+    kNumHashDirectBytes;
+    if (pb[maxLen] == cur[maxLen])
+    #else
+    MyMin(len0, len1);
+    #endif
+    if (pb[len] == cur[len])
+    {
+      while(++len != lenLimit)
+        if (pb[len] != cur[len])
+          break;
+      if (maxLen < len)
+      {
+        distances[offset++] = maxLen = len;
+        distances[offset++] = delta - 1;
+        if (len == lenLimit)
+        {
+          #ifndef _HASH_CHAIN
+          *ptr1 = pair[0];
+          *ptr0 = pair[1];
+          #endif
+          break;
+        }
+      }
+    }
+    #ifdef _HASH_CHAIN
+    curMatch = *pair;
+    #else
+    if (pb[len] < cur[len])
+    {
+      *ptr1 = curMatch;
+      ptr1 = pair + 1;
+      curMatch = *ptr1;
+      len1 = len;
+    }
+    else
+    {
+      *ptr0 = curMatch;
+      ptr0 = pair;
+      curMatch = *ptr0;
+      len0 = len;
+    }
+    #endif
+  }
+  distances[0] = offset - 1;
+  if (++_cyclicBufferPos == _cyclicBufferSize)
+    _cyclicBufferPos = 0;
+  RINOK(CLZInWindow::MovePos());
+  if (_pos == kMaxValForNormalize)
+    Normalize();
+  return S_OK;
+}
+
+STDMETHODIMP CMatchFinder::Skip(UInt32 num)
+{
+  do
+  {
+  #ifdef _HASH_CHAIN
+  if (_streamPos - _pos < kNumHashBytes)
+  {
+    RINOK(MovePos()); 
+    continue;
+  }
+  #else
+  UInt32 lenLimit;
+  if (_pos + _matchMaxLen <= _streamPos)
+    lenLimit = _matchMaxLen;
+  else
+  {
+    lenLimit = _streamPos - _pos;
+    if(lenLimit < kMinMatchCheck)
+    {
+      RINOK(MovePos());
+      continue;
+    }
+  }
+  UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
+  #endif
+  const Byte *cur = _buffer + _pos;
+
+  #ifdef HASH_ARRAY_2
+  UInt32 hash2Value;
+  #ifdef HASH_ARRAY_3
+  UInt32 hash3Value;
+  UInt32 hashValue;
+  HASH_CALC;
+  _hash[kHash3Offset + hash3Value] = _pos;
+  #else
+  UInt32 hashValue;
+  HASH_CALC;
+  #endif
+  _hash[hash2Value] = _pos;
+  #else
+  UInt32 hashValue = Hash(cur);
+  #endif
+
+  UInt32 curMatch = _hash[kFixHashSize + hashValue];
+  _hash[kFixHashSize + hashValue] = _pos;
+
+  #ifdef _HASH_CHAIN
+  _son[_cyclicBufferPos] = curMatch;
+  #else
+  CIndex *son = _son;
+  CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+  CIndex *ptr1 = son + (_cyclicBufferPos << 1);
+
+  UInt32 len0, len1;
+  len0 = len1 = kNumHashDirectBytes;
+  UInt32 count = _cutValue;
+  while(true)
+  {
+    if(curMatch <= matchMinPos || count-- == 0)
+    {
+      *ptr0 = *ptr1 = kEmptyHashValue;
+      break;
+    }
+    
+    UInt32 delta = _pos - curMatch;
+    UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
+      (_cyclicBufferPos - delta):
+      (_cyclicBufferPos - delta + _cyclicBufferSize);
+    CIndex *pair = son + (cyclicPos << 1);
+    
+    // _mm_prefetch((const char *)pair, _MM_HINT_T0);
+    
+    const Byte *pb = _buffer + curMatch;
+    UInt32 len = MyMin(len0, len1);
+    
+    if (pb[len] == cur[len])
+    {
+      while(++len != lenLimit)
+        if (pb[len] != cur[len])
+          break;
+      if (len == lenLimit)
+      {
+        *ptr1 = pair[0];
+        *ptr0 = pair[1];
+        break;
+      }
+    }
+    if (pb[len] < cur[len])
+    {
+      *ptr1 = curMatch;
+      ptr1 = pair + 1;
+      curMatch = *ptr1;
+      len1 = len;
+    }
+    else
+    {
+      *ptr0 = curMatch;
+      ptr0 = pair;
+      curMatch = *ptr0;
+      len0 = len;
+    }
+  }
+  #endif
+  if (++_cyclicBufferPos == _cyclicBufferSize)
+    _cyclicBufferPos = 0;
+  RINOK(CLZInWindow::MovePos());
+  if (_pos == kMaxValForNormalize)
+    Normalize();
+  }
+  while(--num != 0);
+  return S_OK;
+}
+
+void CMatchFinder::Normalize()
+{
+  UInt32 subValue = _pos - _cyclicBufferSize;
+  CIndex *items = _hash;
+  UInt32 numItems = (_hashSizeSum + _cyclicBufferSize 
+    #ifndef _HASH_CHAIN
+     * 2
+    #endif
+    );
+  for (UInt32 i = 0; i < numItems; i++)
+  {
+    UInt32 value = items[i];
+    if (value <= subValue)
+      value = kEmptyHashValue;
+    else
+      value -= subValue;
+    items[i] = value;
+  }
+  ReduceOffsets(subValue);
+}
+
+HRESULT CMatchFinder::MovePos()
+{
+  if (++_cyclicBufferPos == _cyclicBufferSize)
+    _cyclicBufferPos = 0;
+  RINOK(CLZInWindow::MovePos());
+  if (_pos == kMaxValForNormalize)
+    Normalize();
+  return S_OK;
+}
+
+STDMETHODIMP_(Byte) CMatchFinder::GetIndexByte(Int32 index)
+  { return CLZInWindow::GetIndexByte(index); }
+
+STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index, 
+    UInt32 back, UInt32 limit)
+  { return CLZInWindow::GetMatchLen(index, back, limit); }
+
+STDMETHODIMP_(UInt32) CMatchFinder::GetNumAvailableBytes()
+  { return CLZInWindow::GetNumAvailableBytes(); }
+
+STDMETHODIMP_(const Byte *) CMatchFinder::GetPointerToCurrentPos()
+  { return CLZInWindow::GetPointerToCurrentPos(); }
+
+STDMETHODIMP_(Int32) CMatchFinder::NeedChangeBufferPos(UInt32 numCheckBytes)
+  { return CLZInWindow::NeedMove(numCheckBytes) ? 1: 0; }
+
+STDMETHODIMP_(void) CMatchFinder::ChangeBufferPos()
+  { CLZInWindow::MoveBlock();}
+
+#undef HASH_CALC
+#undef kNumHashDirectBytes
+}
index 949863be5e34887e5245ab04d6008811e46736b4..1fda4ac6ba9b64e2a18beca18df11f3ac24e68d8 100644 (file)
@@ -1,19 +1,19 @@
-// HC4.h\r
-\r
-#ifndef __HC4_H\r
-#define __HC4_H\r
-\r
-#define BT_NAMESPACE NHC4\r
-\r
-#define HASH_ARRAY_2\r
-#define HASH_ARRAY_3\r
-\r
-#include "HCMain.h"\r
-\r
-#undef HASH_ARRAY_2\r
-#undef HASH_ARRAY_3\r
-\r
-#undef BT_NAMESPACE\r
-\r
-#endif\r
-\r
+// HC4.h
+
+#ifndef __HC4_H
+#define __HC4_H
+
+#define BT_NAMESPACE NHC4
+
+#define HASH_ARRAY_2
+#define HASH_ARRAY_3
+
+#include "HCMain.h"
+
+#undef HASH_ARRAY_2
+#undef HASH_ARRAY_3
+
+#undef BT_NAMESPACE
+
+#endif
+
index fafce39797b74317fc4d67e23c58f89b9b74c530..d509befea057377d473df8ea4c682a7637bb8c02 100644 (file)
@@ -1,6 +1,6 @@
-// HCMain.h\r
-\r
-#define _HASH_CHAIN\r
-#include "../BinTree/BinTreeMain.h"\r
-#undef _HASH_CHAIN\r
-\r
+// HCMain.h
+
+#define _HASH_CHAIN
+#include "../BinTree/BinTreeMain.h"
+#undef _HASH_CHAIN
+
index 4bbc14f35adae8ba7987785f02c7cf656196d0ac..9459f210d8ee065d8460b2d3e2d563e3cfa04621 100644 (file)
@@ -1,33 +1,33 @@
-// MatchFinders/IMatchFinder.h\r
-\r
-#ifndef __IMATCHFINDER_H\r
-#define __IMATCHFINDER_H\r
-\r
-struct IInWindowStream: public IUnknown\r
-{\r
-  STDMETHOD(SetStream)(ISequentialInStream *inStream) PURE;\r
-  STDMETHOD_(void, ReleaseStream)() PURE;\r
-  STDMETHOD(Init)() PURE;\r
-  STDMETHOD_(Byte, GetIndexByte)(Int32 index) PURE;\r
-  STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 distance, UInt32 limit) PURE;\r
-  STDMETHOD_(UInt32, GetNumAvailableBytes)() PURE;\r
-  STDMETHOD_(const Byte *, GetPointerToCurrentPos)() PURE;\r
-  STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes) PURE;\r
-  STDMETHOD_(void, ChangeBufferPos)() PURE;\r
-};\r
\r
-struct IMatchFinder: public IInWindowStream\r
-{\r
-  STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, \r
-      UInt32 matchMaxLen, UInt32 keepAddBufferAfter) PURE;\r
-  STDMETHOD(GetMatches)(UInt32 *distances) PURE;\r
-  STDMETHOD(Skip)(UInt32 num) PURE;\r
-};\r
-\r
-struct IMatchFinderSetNumPasses\r
-{\r
-  //virtual ~IMatchFinderSetNumPasses(){}\r
-  virtual void SetNumPasses(UInt32 numPasses) PURE;\r
-};\r
-\r
-#endif\r
+// MatchFinders/IMatchFinder.h
+
+#ifndef __IMATCHFINDER_H
+#define __IMATCHFINDER_H
+
+struct IInWindowStream: public IUnknown
+{
+  STDMETHOD(SetStream)(ISequentialInStream *inStream) PURE;
+  STDMETHOD_(void, ReleaseStream)() PURE;
+  STDMETHOD(Init)() PURE;
+  STDMETHOD_(Byte, GetIndexByte)(Int32 index) PURE;
+  STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 distance, UInt32 limit) PURE;
+  STDMETHOD_(UInt32, GetNumAvailableBytes)() PURE;
+  STDMETHOD_(const Byte *, GetPointerToCurrentPos)() PURE;
+  STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes) PURE;
+  STDMETHOD_(void, ChangeBufferPos)() PURE;
+};
+struct IMatchFinder: public IInWindowStream
+{
+  STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, 
+      UInt32 matchMaxLen, UInt32 keepAddBufferAfter) PURE;
+  STDMETHOD(GetMatches)(UInt32 *distances) PURE;
+  STDMETHOD(Skip)(UInt32 num) PURE;
+};
+
+struct IMatchFinderSetNumPasses
+{
+  //virtual ~IMatchFinderSetNumPasses(){}
+  virtual void SetNumPasses(UInt32 numPasses) PURE;
+};
+
+#endif
index a0f791173a7ce82440fdf82841622c5007e9707a..0e65c4254b35f63efa1bc69d6759a8d4f89d6657 100644 (file)
-// LZInWindow.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "LZInWindow.h"\r
-#include "../../../Common/MyCom.h"\r
-#include "../../../Common/Alloc.h"\r
-\r
-void CLZInWindow::Free()\r
-{\r
-  ::BigFree(_bufferBase);\r
-  _bufferBase = 0;\r
-}\r
-\r
-bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv)\r
-{\r
-  _keepSizeBefore = keepSizeBefore;\r
-  _keepSizeAfter = keepSizeAfter;\r
-  UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;\r
-  if (_bufferBase == 0 || _blockSize != blockSize)\r
-  {\r
-    Free();\r
-    _blockSize = blockSize;\r
-    if (_blockSize != 0)\r
-      _bufferBase = (Byte *)::BigAlloc(_blockSize);\r
-  }\r
-  _pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;\r
-  if (_blockSize == 0)\r
-    return true;\r
-  return (_bufferBase != 0);\r
-}\r
-\r
-void CLZInWindow::SetStream(ISequentialInStream *stream)\r
-{\r
-  _stream = stream;\r
-}\r
-\r
-HRESULT CLZInWindow::Init()\r
-{\r
-  _buffer = _bufferBase;\r
-  _pos = 0;\r
-  _streamPos = 0;\r
-  _streamEndWasReached = false;\r
-  return ReadBlock();\r
-}\r
-\r
-/*\r
-void CLZInWindow::ReleaseStream()\r
-{\r
-  _stream.Release();\r
-}\r
-*/\r
-\r
-///////////////////////////////////////////\r
-// ReadBlock\r
-\r
-// In State:\r
-//   (_buffer + _streamPos) <= (_bufferBase + _blockSize)\r
-// Out State:\r
-//   _posLimit <= _blockSize - _keepSizeAfter;\r
-//   if(_streamEndWasReached == false):\r
-//     _streamPos >= _pos + _keepSizeAfter\r
-//     _posLimit = _streamPos - _keepSizeAfter;\r
-//   else\r
-//          \r
-  \r
-HRESULT CLZInWindow::ReadBlock()\r
-{\r
-  if(_streamEndWasReached)\r
-    return S_OK;\r
-  while(true)\r
-  {\r
-    UInt32 size = (UInt32)(_bufferBase - _buffer) + _blockSize - _streamPos;\r
-    if(size == 0)\r
-      return S_OK;\r
-    UInt32 numReadBytes;\r
-    RINOK(_stream->Read(_buffer + _streamPos, size, &numReadBytes));\r
-    if(numReadBytes == 0)\r
-    {\r
-      _posLimit = _streamPos;\r
-      const Byte *pointerToPostion = _buffer + _posLimit;\r
-      if(pointerToPostion > _pointerToLastSafePosition)\r
-        _posLimit = (UInt32)(_pointerToLastSafePosition - _buffer);\r
-      _streamEndWasReached = true;\r
-      return S_OK;\r
-    }\r
-    _streamPos += numReadBytes;\r
-    if(_streamPos >= _pos + _keepSizeAfter)\r
-    {\r
-      _posLimit = _streamPos - _keepSizeAfter;\r
-      return S_OK;\r
-    }\r
-  }\r
-}\r
-\r
-void CLZInWindow::MoveBlock()\r
-{\r
-  UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore;\r
-  // we need one additional byte, since MovePos moves on 1 byte.\r
-  if (offset > 0)\r
-    offset--; \r
-  UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos -  offset;\r
-  memmove(_bufferBase, _bufferBase + offset, numBytes);\r
-  _buffer -= offset;\r
-}\r
+// LZInWindow.cpp
+
+#include "StdAfx.h"
+
+#include "LZInWindow.h"
+#include "../../../Common/MyCom.h"
+#include "../../../Common/Alloc.h"
+
+void CLZInWindow::Free()
+{
+  ::BigFree(_bufferBase);
+  _bufferBase = 0;
+}
+
+bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv)
+{
+  _keepSizeBefore = keepSizeBefore;
+  _keepSizeAfter = keepSizeAfter;
+  UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
+  if (_bufferBase == 0 || _blockSize != blockSize)
+  {
+    Free();
+    _blockSize = blockSize;
+    if (_blockSize != 0)
+      _bufferBase = (Byte *)::BigAlloc(_blockSize);
+  }
+  _pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;
+  if (_blockSize == 0)
+    return true;
+  return (_bufferBase != 0);
+}
+
+void CLZInWindow::SetStream(ISequentialInStream *stream)
+{
+  _stream = stream;
+}
+
+HRESULT CLZInWindow::Init()
+{
+  _buffer = _bufferBase;
+  _pos = 0;
+  _streamPos = 0;
+  _streamEndWasReached = false;
+  return ReadBlock();
+}
+
+/*
+void CLZInWindow::ReleaseStream()
+{
+  _stream.Release();
+}
+*/
+
+///////////////////////////////////////////
+// ReadBlock
+
+// In State:
+//   (_buffer + _streamPos) <= (_bufferBase + _blockSize)
+// Out State:
+//   _posLimit <= _blockSize - _keepSizeAfter;
+//   if(_streamEndWasReached == false):
+//     _streamPos >= _pos + _keepSizeAfter
+//     _posLimit = _streamPos - _keepSizeAfter;
+//   else
+//          
+  
+HRESULT CLZInWindow::ReadBlock()
+{
+  if(_streamEndWasReached)
+    return S_OK;
+  while(true)
+  {
+    UInt32 size = (UInt32)(_bufferBase - _buffer) + _blockSize - _streamPos;
+    if(size == 0)
+      return S_OK;
+    UInt32 numReadBytes;
+    RINOK(_stream->Read(_buffer + _streamPos, size, &numReadBytes));
+    if(numReadBytes == 0)
+    {
+      _posLimit = _streamPos;
+      const Byte *pointerToPostion = _buffer + _posLimit;
+      if(pointerToPostion > _pointerToLastSafePosition)
+        _posLimit = (UInt32)(_pointerToLastSafePosition - _buffer);
+      _streamEndWasReached = true;
+      return S_OK;
+    }
+    _streamPos += numReadBytes;
+    if(_streamPos >= _pos + _keepSizeAfter)
+    {
+      _posLimit = _streamPos - _keepSizeAfter;
+      return S_OK;
+    }
+  }
+}
+
+void CLZInWindow::MoveBlock()
+{
+  UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore;
+  // we need one additional byte, since MovePos moves on 1 byte.
+  if (offset > 0)
+    offset--; 
+  UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos -  offset;
+  memmove(_bufferBase, _bufferBase + offset, numBytes);
+  _buffer -= offset;
+}
index 87cb8e94fabc58e9c252e4ff97f88ca2b6bbfa38..54f2cb7bbad266de48af5920d192070da18f22d2 100644 (file)
@@ -1,87 +1,87 @@
-// LZInWindow.h\r
-\r
-#ifndef __LZ_IN_WINDOW_H\r
-#define __LZ_IN_WINDOW_H\r
-\r
-#include "../../IStream.h"\r
-\r
-class CLZInWindow\r
-{\r
-  Byte *_bufferBase; // pointer to buffer with data\r
-  ISequentialInStream *_stream;\r
-  UInt32 _posLimit;  // offset (from _buffer) when new block reading must be done\r
-  bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream\r
-  const Byte *_pointerToLastSafePosition;\r
-protected:\r
-  Byte  *_buffer;   // Pointer to virtual Buffer begin\r
-  UInt32 _blockSize;  // Size of Allocated memory block\r
-  UInt32 _pos;             // offset (from _buffer) of curent byte\r
-  UInt32 _keepSizeBefore;  // how many BYTEs must be kept in buffer before _pos\r
-  UInt32 _keepSizeAfter;   // how many BYTEs must be kept buffer after _pos\r
-  UInt32 _streamPos;   // offset (from _buffer) of first not read byte from Stream\r
-\r
-  void MoveBlock();\r
-  HRESULT ReadBlock();\r
-  void Free();\r
-public:\r
-  CLZInWindow(): _bufferBase(0) {}\r
-  virtual ~CLZInWindow() { Free(); }\r
-\r
-  // keepSizeBefore + keepSizeAfter + keepSizeReserv < 4G)\r
-  bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv = (1<<17));\r
-\r
-  void SetStream(ISequentialInStream *stream);\r
-  HRESULT Init();\r
-  // void ReleaseStream();\r
-\r
-  Byte *GetBuffer() const { return _buffer; }\r
-\r
-  const Byte *GetPointerToCurrentPos() const { return _buffer + _pos; }\r
-\r
-  HRESULT MovePos()\r
-  {\r
-    _pos++;\r
-    if (_pos > _posLimit)\r
-    {\r
-      const Byte *pointerToPostion = _buffer + _pos;\r
-      if(pointerToPostion > _pointerToLastSafePosition)\r
-        MoveBlock();\r
-      return ReadBlock();\r
-    }\r
-    else\r
-      return S_OK;\r
-  }\r
-  Byte GetIndexByte(Int32 index) const  {  return _buffer[(size_t)_pos + index]; }\r
-\r
-  // index + limit have not to exceed _keepSizeAfter;\r
-  // -2G <= index < 2G\r
-  UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const\r
-  {  \r
-    if(_streamEndWasReached)\r
-      if ((_pos + index) + limit > _streamPos)\r
-        limit = _streamPos - (_pos + index);\r
-    distance++;\r
-    const Byte *pby = _buffer + (size_t)_pos + index;\r
-    UInt32 i;\r
-    for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++);\r
-    return i;\r
-  }\r
-\r
-  UInt32 GetNumAvailableBytes() const { return _streamPos - _pos; }\r
-\r
-  void ReduceOffsets(Int32 subValue)\r
-  {\r
-    _buffer += subValue;\r
-    _posLimit -= subValue;\r
-    _pos -= subValue;\r
-    _streamPos -= subValue;\r
-  }\r
-\r
-  bool NeedMove(UInt32 numCheckBytes)\r
-  {\r
-    UInt32 reserv = _pointerToLastSafePosition - (_buffer + _pos);\r
-    return (reserv <= numCheckBytes);\r
-  }\r
-};\r
-\r
-#endif\r
+// LZInWindow.h
+
+#ifndef __LZ_IN_WINDOW_H
+#define __LZ_IN_WINDOW_H
+
+#include "../../IStream.h"
+
+class CLZInWindow
+{
+  Byte *_bufferBase; // pointer to buffer with data
+  ISequentialInStream *_stream;
+  UInt32 _posLimit;  // offset (from _buffer) when new block reading must be done
+  bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream
+  const Byte *_pointerToLastSafePosition;
+protected:
+  Byte  *_buffer;   // Pointer to virtual Buffer begin
+  UInt32 _blockSize;  // Size of Allocated memory block
+  UInt32 _pos;             // offset (from _buffer) of curent byte
+  UInt32 _keepSizeBefore;  // how many BYTEs must be kept in buffer before _pos
+  UInt32 _keepSizeAfter;   // how many BYTEs must be kept buffer after _pos
+  UInt32 _streamPos;   // offset (from _buffer) of first not read byte from Stream
+
+  void MoveBlock();
+  HRESULT ReadBlock();
+  void Free();
+public:
+  CLZInWindow(): _bufferBase(0) {}
+  virtual ~CLZInWindow() { Free(); }
+
+  // keepSizeBefore + keepSizeAfter + keepSizeReserv < 4G)
+  bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv = (1<<17));
+
+  void SetStream(ISequentialInStream *stream);
+  HRESULT Init();
+  // void ReleaseStream();
+
+  Byte *GetBuffer() const { return _buffer; }
+
+  const Byte *GetPointerToCurrentPos() const { return _buffer + _pos; }
+
+  HRESULT MovePos()
+  {
+    _pos++;
+    if (_pos > _posLimit)
+    {
+      const Byte *pointerToPostion = _buffer + _pos;
+      if(pointerToPostion > _pointerToLastSafePosition)
+        MoveBlock();
+      return ReadBlock();
+    }
+    else
+      return S_OK;
+  }
+  Byte GetIndexByte(Int32 index) const  {  return _buffer[(size_t)_pos + index]; }
+
+  // index + limit have not to exceed _keepSizeAfter;
+  // -2G <= index < 2G
+  UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const
+  {  
+    if(_streamEndWasReached)
+      if ((_pos + index) + limit > _streamPos)
+        limit = _streamPos - (_pos + index);
+    distance++;
+    const Byte *pby = _buffer + (size_t)_pos + index;
+    UInt32 i;
+    for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++);
+    return i;
+  }
+
+  UInt32 GetNumAvailableBytes() const { return _streamPos - _pos; }
+
+  void ReduceOffsets(Int32 subValue)
+  {
+    _buffer += subValue;
+    _posLimit -= subValue;
+    _pos -= subValue;
+    _streamPos -= subValue;
+  }
+
+  bool NeedMove(UInt32 numCheckBytes)
+  {
+    UInt32 reserv = _pointerToLastSafePosition - (_buffer + _pos);
+    return (reserv <= numCheckBytes);
+  }
+};
+
+#endif
index 3de038a4ffa275e84735e5cb0de59352802ee324..3ff6d8a29f11eef685e081722c69beca969208ce 100644 (file)
@@ -1,6 +1,6 @@
-// StdAfx.h\r
-\r
-#ifndef __STDAFX_H\r
-#define __STDAFX_H\r
-\r
-#endif \r
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#endif 
index d53296ee709a5e8fb276ea9c80c01383d2b47fad..7bc4c438af3c01e248965ea5612e83a83514f66b 100644 (file)
@@ -1,82 +1,82 @@
-// LZMA.h\r
-\r
-#ifndef __LZMA_H\r
-#define __LZMA_H\r
-\r
-namespace NCompress {\r
-namespace NLZMA {\r
-\r
-const UInt32 kNumRepDistances = 4;\r
-\r
-const int kNumStates = 12;\r
-\r
-const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4,  5,  6,   4, 5};\r
-const Byte kMatchNextStates[kNumStates]   = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};\r
-const Byte kRepNextStates[kNumStates]     = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};\r
-const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};\r
-\r
-class CState\r
-{\r
-public:\r
-  Byte Index;\r
-  void Init() { Index = 0; }\r
-  void UpdateChar() { Index = kLiteralNextStates[Index]; }\r
-  void UpdateMatch() { Index = kMatchNextStates[Index]; }\r
-  void UpdateRep() { Index = kRepNextStates[Index]; }\r
-  void UpdateShortRep() { Index = kShortRepNextStates[Index]; }\r
-  bool IsCharState() const { return Index < 7; }\r
-};\r
-\r
-const int kNumPosSlotBits = 6; \r
-const int kDicLogSizeMin = 0; \r
-const int kDicLogSizeMax = 32; \r
-const int kDistTableSizeMax = kDicLogSizeMax * 2; \r
-\r
-const UInt32 kNumLenToPosStates = 4;\r
-\r
-inline UInt32 GetLenToPosState(UInt32 len)\r
-{\r
-  len -= 2;\r
-  if (len < kNumLenToPosStates)\r
-    return len;\r
-  return kNumLenToPosStates - 1;\r
-}\r
-\r
-namespace NLength {\r
-\r
-const int kNumPosStatesBitsMax = 4;\r
-const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax);\r
-\r
-const int kNumPosStatesBitsEncodingMax = 4;\r
-const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);\r
-\r
-const int kNumLowBits = 3;\r
-const int kNumMidBits = 3;\r
-const int kNumHighBits = 8;\r
-const UInt32 kNumLowSymbols = 1 << kNumLowBits;\r
-const UInt32 kNumMidSymbols = 1 << kNumMidBits;\r
-const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits);\r
-\r
-}\r
-\r
-const UInt32 kMatchMinLen = 2;\r
-const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1;\r
-\r
-const int kNumAlignBits = 4;\r
-const UInt32 kAlignTableSize = 1 << kNumAlignBits;\r
-const UInt32 kAlignMask = (kAlignTableSize - 1);\r
-\r
-const UInt32 kStartPosModelIndex = 4;\r
-const UInt32 kEndPosModelIndex = 14;\r
-const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;\r
-\r
-const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2);\r
-\r
-const int kNumLitPosStatesBitsEncodingMax = 4;\r
-const int kNumLitContextBitsMax = 8;\r
-\r
-const int kNumMoveBits = 5;\r
-\r
-}}\r
-\r
-#endif\r
+// LZMA.h
+
+#ifndef __LZMA_H
+#define __LZMA_H
+
+namespace NCompress {
+namespace NLZMA {
+
+const UInt32 kNumRepDistances = 4;
+
+const int kNumStates = 12;
+
+const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4,  5,  6,   4, 5};
+const Byte kMatchNextStates[kNumStates]   = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
+const Byte kRepNextStates[kNumStates]     = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
+const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
+
+class CState
+{
+public:
+  Byte Index;
+  void Init() { Index = 0; }
+  void UpdateChar() { Index = kLiteralNextStates[Index]; }
+  void UpdateMatch() { Index = kMatchNextStates[Index]; }
+  void UpdateRep() { Index = kRepNextStates[Index]; }
+  void UpdateShortRep() { Index = kShortRepNextStates[Index]; }
+  bool IsCharState() const { return Index < 7; }
+};
+
+const int kNumPosSlotBits = 6; 
+const int kDicLogSizeMin = 0; 
+const int kDicLogSizeMax = 32; 
+const int kDistTableSizeMax = kDicLogSizeMax * 2; 
+
+const UInt32 kNumLenToPosStates = 4;
+
+inline UInt32 GetLenToPosState(UInt32 len)
+{
+  len -= 2;
+  if (len < kNumLenToPosStates)
+    return len;
+  return kNumLenToPosStates - 1;
+}
+
+namespace NLength {
+
+const int kNumPosStatesBitsMax = 4;
+const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
+
+const int kNumPosStatesBitsEncodingMax = 4;
+const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
+
+const int kNumLowBits = 3;
+const int kNumMidBits = 3;
+const int kNumHighBits = 8;
+const UInt32 kNumLowSymbols = 1 << kNumLowBits;
+const UInt32 kNumMidSymbols = 1 << kNumMidBits;
+const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits);
+
+}
+
+const UInt32 kMatchMinLen = 2;
+const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1;
+
+const int kNumAlignBits = 4;
+const UInt32 kAlignTableSize = 1 << kNumAlignBits;
+const UInt32 kAlignMask = (kAlignTableSize - 1);
+
+const UInt32 kStartPosModelIndex = 4;
+const UInt32 kEndPosModelIndex = 14;
+const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
+
+const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2);
+
+const int kNumLitPosStatesBitsEncodingMax = 4;
+const int kNumLitContextBitsMax = 8;
+
+const int kNumMoveBits = 5;
+
+}}
+
+#endif
index b6a2f7d591bd31350790f3634254caa83b0490eb..8d8f0a004c426c3144f57cc73e3251f4aa2ed6f3 100644 (file)
-// LZMA/Encoder.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "../../../Common/Defs.h"\r
-#include "../../Common/StreamUtils.h"\r
-\r
-#include "LZMAEncoder.h"\r
-\r
-// for minimal compressing code size define these:\r
-// #define COMPRESS_MF_BT\r
-// #define COMPRESS_MF_BT4\r
-\r
-#if !defined(COMPRESS_MF_BT) && !defined(COMPRESS_MF_HC)\r
-#define COMPRESS_MF_BT\r
-#define COMPRESS_MF_HC\r
-#endif\r
-\r
-#ifdef COMPRESS_MF_BT\r
-#if !defined(COMPRESS_MF_BT2) && !defined(COMPRESS_MF_BT3) && !defined(COMPRESS_MF_BT4)\r
-#define COMPRESS_MF_BT2\r
-#define COMPRESS_MF_BT3\r
-#define COMPRESS_MF_BT4\r
-#endif\r
-#ifdef COMPRESS_MF_BT2\r
-#include "../LZ/BinTree/BinTree2.h"\r
-#endif\r
-#ifdef COMPRESS_MF_BT3\r
-#include "../LZ/BinTree/BinTree3.h"\r
-#endif\r
-#ifdef COMPRESS_MF_BT4\r
-#include "../LZ/BinTree/BinTree4.h"\r
-#endif\r
-#endif\r
-\r
-#ifdef COMPRESS_MF_HC\r
-#include "../LZ/HashChain/HC4.h"\r
-#endif\r
-\r
-#ifdef COMPRESS_MF_MT\r
-#include "../LZ/MT/MT.h"\r
-#endif\r
-\r
-namespace NCompress {\r
-namespace NLZMA {\r
-\r
-const int kDefaultDictionaryLogSize = 22;\r
-const UInt32 kNumFastBytesDefault = 0x20;\r
-\r
-enum \r
-{\r
-  kBT2,\r
-  kBT3,\r
-  kBT4,\r
-  kHC4\r
-};\r
-\r
-static const wchar_t *kMatchFinderIDs[] = \r
-{\r
-  L"BT2",\r
-  L"BT3",\r
-  L"BT4",\r
-  L"HC4"\r
-};\r
-\r
-Byte g_FastPos[1 << 11];\r
-\r
-class CFastPosInit\r
-{\r
-public:\r
-  CFastPosInit() { Init(); }\r
-  void Init()\r
-  {\r
-    const Byte kFastSlots = 22;\r
-    int c = 2;\r
-    g_FastPos[0] = 0;\r
-    g_FastPos[1] = 1;\r
-\r
-    for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++)\r
-    {\r
-      UInt32 k = (1 << ((slotFast >> 1) - 1));\r
-      for (UInt32 j = 0; j < k; j++, c++)\r
-        g_FastPos[c] = slotFast;\r
-    }\r
-  }\r
-} g_FastPosInit;\r
-\r
-\r
-void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)\r
-{\r
-  UInt32 context = 1;\r
-  int i = 8;\r
-  do \r
-  {\r
-    i--;\r
-    UInt32 bit = (symbol >> i) & 1;\r
-    _encoders[context].Encode(rangeEncoder, bit);\r
-    context = (context << 1) | bit;\r
-  }\r
-  while(i != 0);\r
-}\r
-\r
-void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, \r
-    Byte matchByte, Byte symbol)\r
-{\r
-  UInt32 context = 1;\r
-  int i = 8;\r
-  do \r
-  {\r
-    i--;\r
-    UInt32 bit = (symbol >> i) & 1;\r
-    UInt32 matchBit = (matchByte >> i) & 1;\r
-    _encoders[0x100 + (matchBit << 8) + context].Encode(rangeEncoder, bit);\r
-    context = (context << 1) | bit;\r
-    if (matchBit != bit)\r
-    {\r
-      while(i != 0)\r
-      {\r
-        i--;\r
-        UInt32 bit = (symbol >> i) & 1;\r
-        _encoders[context].Encode(rangeEncoder, bit);\r
-        context = (context << 1) | bit;\r
-      }\r
-      break;\r
-    }\r
-  }\r
-  while(i != 0);\r
-}\r
-\r
-UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) const\r
-{\r
-  UInt32 price = 0;\r
-  UInt32 context = 1;\r
-  int i = 8;\r
-  if (matchMode)\r
-  {\r
-    do \r
-    {\r
-      i--;\r
-      UInt32 matchBit = (matchByte >> i) & 1;\r
-      UInt32 bit = (symbol >> i) & 1;\r
-      price += _encoders[0x100 + (matchBit << 8) + context].GetPrice(bit);\r
-      context = (context << 1) | bit;\r
-      if (matchBit != bit)\r
-        break;\r
-    }\r
-    while (i != 0);\r
-  }\r
-  while(i != 0)\r
-  {\r
-    i--;\r
-    UInt32 bit = (symbol >> i) & 1;\r
-    price += _encoders[context].GetPrice(bit);\r
-    context = (context << 1) | bit;\r
-  }\r
-  return price;\r
-};\r
-\r
-\r
-namespace NLength {\r
-\r
-void CEncoder::Init(UInt32 numPosStates)\r
-{\r
-  _choice.Init();\r
-  _choice2.Init();\r
-  for (UInt32 posState = 0; posState < numPosStates; posState++)\r
-  {\r
-    _lowCoder[posState].Init();\r
-    _midCoder[posState].Init();\r
-  }\r
-  _highCoder.Init();\r
-}\r
-\r
-void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)\r
-{\r
-  if(symbol < kNumLowSymbols)\r
-  {\r
-    _choice.Encode(rangeEncoder, 0);\r
-    _lowCoder[posState].Encode(rangeEncoder, symbol);\r
-  }\r
-  else\r
-  {\r
-    _choice.Encode(rangeEncoder, 1);\r
-    if(symbol < kNumLowSymbols + kNumMidSymbols)\r
-    {\r
-      _choice2.Encode(rangeEncoder, 0);\r
-      _midCoder[posState].Encode(rangeEncoder, symbol - kNumLowSymbols);\r
-    }\r
-    else\r
-    {\r
-      _choice2.Encode(rangeEncoder, 1);\r
-      _highCoder.Encode(rangeEncoder, symbol - kNumLowSymbols - kNumMidSymbols);\r
-    }\r
-  }\r
-}\r
-\r
-void CEncoder::SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const\r
-{\r
-  UInt32 a0 = _choice.GetPrice0();\r
-  UInt32 a1 = _choice.GetPrice1();\r
-  UInt32 b0 = a1 + _choice2.GetPrice0();\r
-  UInt32 b1 = a1 + _choice2.GetPrice1();\r
-  UInt32 i = 0;\r
-  for (i = 0; i < kNumLowSymbols; i++)\r
-  {\r
-    if (i >= numSymbols)\r
-      return;\r
-    prices[i] = a0 + _lowCoder[posState].GetPrice(i);\r
-  }\r
-  for (; i < kNumLowSymbols + kNumMidSymbols; i++)\r
-  {\r
-    if (i >= numSymbols)\r
-      return;\r
-    prices[i] = b0 + _midCoder[posState].GetPrice(i - kNumLowSymbols);\r
-  }\r
-  for (; i < numSymbols; i++)\r
-    prices[i] = b1 + _highCoder.GetPrice(i - kNumLowSymbols - kNumMidSymbols);\r
-}\r
-\r
-}\r
-CEncoder::CEncoder():\r
-  _numFastBytes(kNumFastBytesDefault),\r
-  _distTableSize(kDefaultDictionaryLogSize * 2),\r
-  _posStateBits(2),\r
-  _posStateMask(4 - 1),\r
-  _numLiteralPosStateBits(0),\r
-  _numLiteralContextBits(3),\r
-  _dictionarySize(1 << kDefaultDictionaryLogSize),\r
-  _dictionarySizePrev(UInt32(-1)),\r
-  _numFastBytesPrev(UInt32(-1)),\r
-  _matchFinderCycles(0),\r
-  _matchFinderIndex(kBT4),\r
-   #ifdef COMPRESS_MF_MT\r
-  _multiThread(false),\r
-   #endif\r
-  _writeEndMark(false),\r
-  setMfPasses(0)\r
-{\r
-  // _maxMode = false;\r
-  _fastMode = false;\r
-}\r
-\r
-HRESULT CEncoder::Create()\r
-{\r
-  if (!_rangeEncoder.Create(1 << 20))\r
-    return E_OUTOFMEMORY;\r
-  if (!_matchFinder)\r
-  {\r
-    switch(_matchFinderIndex)\r
-    {\r
-      #ifdef COMPRESS_MF_BT\r
-      #ifdef COMPRESS_MF_BT2\r
-      case kBT2:\r
-      {\r
-        NBT2::CMatchFinder *mfSpec = new NBT2::CMatchFinder;\r
-        setMfPasses = mfSpec;\r
-        _matchFinder = mfSpec;\r
-        break;\r
-      }\r
-      #endif\r
-      #ifdef COMPRESS_MF_BT3\r
-      case kBT3:\r
-      {\r
-        NBT3::CMatchFinder *mfSpec = new NBT3::CMatchFinder;\r
-        setMfPasses = mfSpec;\r
-        _matchFinder = mfSpec;\r
-        break;\r
-      }\r
-      #endif\r
-      #ifdef COMPRESS_MF_BT4\r
-      case kBT4:\r
-      {\r
-        NBT4::CMatchFinder *mfSpec = new NBT4::CMatchFinder;\r
-        setMfPasses = mfSpec;\r
-        _matchFinder = mfSpec;\r
-        break;\r
-      }\r
-      #endif\r
-      #endif\r
-      \r
-      #ifdef COMPRESS_MF_HC\r
-      case kHC4:\r
-      {\r
-        NHC4::CMatchFinder *mfSpec = new NHC4::CMatchFinder;\r
-        setMfPasses = mfSpec;\r
-        _matchFinder = mfSpec;\r
-        break;\r
-      }\r
-      #endif\r
-    }\r
-    if (_matchFinder == 0)\r
-      return E_OUTOFMEMORY;\r
-\r
-    #ifdef COMPRESS_MF_MT\r
-    if (_multiThread && !(_fastMode && (_matchFinderIndex == kHC4)))\r
-    {\r
-      CMatchFinderMT *mfSpec = new CMatchFinderMT;\r
-      if (mfSpec == 0)\r
-        return E_OUTOFMEMORY;\r
-      CMyComPtr<IMatchFinder> mf = mfSpec;\r
-      RINOK(mfSpec->SetMatchFinder(_matchFinder));\r
-      _matchFinder.Release();\r
-      _matchFinder = mf;\r
-    }\r
-    #endif\r
-  }\r
-  \r
-  if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits))\r
-    return E_OUTOFMEMORY;\r
-\r
-  if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)\r
-    return S_OK;\r
-  RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen + 1)); // actually it's + _numFastBytes - _numFastBytes\r
-  if (_matchFinderCycles != 0 && setMfPasses != 0)\r
-    setMfPasses->SetNumPasses(_matchFinderCycles);\r
-  _dictionarySizePrev = _dictionarySize;\r
-  _numFastBytesPrev = _numFastBytes;\r
-  return S_OK;\r
-}\r
-\r
-static bool AreStringsEqual(const wchar_t *base, const wchar_t *testString)\r
-{\r
-  while (true)\r
-  {\r
-    wchar_t c = *testString;\r
-    if (c >= 'a' && c <= 'z')\r
-      c -= 0x20;\r
-    if (*base != c)\r
-      return false;\r
-    if (c == 0)\r
-      return true;\r
-    base++;\r
-    testString++;\r
-  }\r
-}\r
-\r
-static int FindMatchFinder(const wchar_t *s)\r
-{\r
-  for (int m = 0; m < (int)(sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0])); m++)\r
-    if (AreStringsEqual(kMatchFinderIDs[m], s))\r
-      return m;\r
-  return -1;\r
-}\r
-\r
-STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, \r
-    const PROPVARIANT *properties, UInt32 numProperties)\r
-{\r
-  for (UInt32 i = 0; i < numProperties; i++)\r
-  {\r
-    const PROPVARIANT &prop = properties[i];\r
-    switch(propIDs[i])\r
-    {\r
-      case NCoderPropID::kNumFastBytes:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 numFastBytes = prop.ulVal;\r
-        if(numFastBytes < 5 || numFastBytes > kMatchMaxLen)\r
-          return E_INVALIDARG;\r
-        _numFastBytes = numFastBytes;\r
-        break;\r
-      }\r
-      case NCoderPropID::kMatchFinderCycles:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        _matchFinderCycles = prop.ulVal;\r
-        break;\r
-      }\r
-      case NCoderPropID::kAlgorithm:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 maximize = prop.ulVal;\r
-        _fastMode = (maximize == 0); \r
-        // _maxMode = (maximize >= 2);\r
-        break;\r
-      }\r
-      case NCoderPropID::kMatchFinder:\r
-      {\r
-        if (prop.vt != VT_BSTR)\r
-          return E_INVALIDARG;\r
-        int matchFinderIndexPrev = _matchFinderIndex;\r
-        int m = FindMatchFinder(prop.bstrVal);\r
-        if (m < 0)\r
-          return E_INVALIDARG;\r
-        _matchFinderIndex = m;\r
-        if (_matchFinder && matchFinderIndexPrev != _matchFinderIndex)\r
-        {\r
-          _dictionarySizePrev = (UInt32)-1;\r
-          ReleaseMatchFinder();\r
-        }\r
-        break;\r
-      }\r
-      #ifdef COMPRESS_MF_MT\r
-      case NCoderPropID::kMultiThread:\r
-      {\r
-        if (prop.vt != VT_BOOL)\r
-          return E_INVALIDARG;\r
-        bool newMultiThread = (prop.boolVal == VARIANT_TRUE);\r
-        if (newMultiThread != _multiThread)\r
-        {\r
-          _dictionarySizePrev = (UInt32)-1;\r
-          ReleaseMatchFinder();\r
-          _multiThread = newMultiThread;\r
-        }\r
-        break;\r
-      }\r
-      case NCoderPropID::kNumThreads:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        bool newMultiThread = (prop.ulVal > 1);\r
-        if (newMultiThread != _multiThread)\r
-        {\r
-          _dictionarySizePrev = (UInt32)-1;\r
-          ReleaseMatchFinder();\r
-          _multiThread = newMultiThread;\r
-        }\r
-        break;\r
-      }\r
-      #endif\r
-      case NCoderPropID::kDictionarySize:\r
-      {\r
-        const int kDicLogSizeMaxCompress = 30;\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 dictionarySize = prop.ulVal;\r
-        if (dictionarySize < UInt32(1 << kDicLogSizeMin) ||\r
-            dictionarySize > UInt32(1 << kDicLogSizeMaxCompress))\r
-          return E_INVALIDARG;\r
-        _dictionarySize = dictionarySize;\r
-        UInt32 dicLogSize;\r
-        for(dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++)\r
-          if (dictionarySize <= (UInt32(1) << dicLogSize))\r
-            break;\r
-        _distTableSize = dicLogSize * 2;\r
-        break;\r
-      }\r
-      case NCoderPropID::kPosStateBits:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 value = prop.ulVal;\r
-        if (value > (UInt32)NLength::kNumPosStatesBitsEncodingMax)\r
-          return E_INVALIDARG;\r
-        _posStateBits = value;\r
-        _posStateMask = (1 << _posStateBits) - 1;\r
-        break;\r
-      }\r
-      case NCoderPropID::kLitPosBits:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 value = prop.ulVal;\r
-        if (value > (UInt32)kNumLitPosStatesBitsEncodingMax)\r
-          return E_INVALIDARG;\r
-        _numLiteralPosStateBits = value;\r
-        break;\r
-      }\r
-      case NCoderPropID::kLitContextBits:\r
-      {\r
-        if (prop.vt != VT_UI4)\r
-          return E_INVALIDARG;\r
-        UInt32 value = prop.ulVal;\r
-        if (value > (UInt32)kNumLitContextBitsMax)\r
-          return E_INVALIDARG;\r
-        _numLiteralContextBits = value;\r
-        break;\r
-      }\r
-      case NCoderPropID::kEndMarker:\r
-      {\r
-        if (prop.vt != VT_BOOL)\r
-          return E_INVALIDARG;\r
-        SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE);\r
-        break;\r
-      }\r
-      default:\r
-        return E_INVALIDARG;\r
-    }\r
-  }\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)\r
-{ \r
-  const UInt32 kPropSize = 5;\r
-  Byte properties[kPropSize];\r
-  properties[0] = (_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits;\r
-  for (int i = 0; i < 4; i++)\r
-    properties[1 + i] = Byte(_dictionarySize >> (8 * i));\r
-  return WriteStream(outStream, properties, kPropSize, NULL);\r
-}\r
-\r
-STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream)\r
-{\r
-  _rangeEncoder.SetStream(outStream);\r
-  return S_OK;\r
-}\r
-\r
-STDMETHODIMP CEncoder::ReleaseOutStream()\r
-{\r
-  _rangeEncoder.ReleaseStream();\r
-  return S_OK;\r
-}\r
-\r
-HRESULT CEncoder::Init()\r
-{\r
-  CBaseState::Init();\r
-\r
-  // RINOK(_matchFinder->Init(inStream));\r
-  _rangeEncoder.Init();\r
-\r
-  for(int i = 0; i < kNumStates; i++)\r
-  {\r
-    for (UInt32 j = 0; j <= _posStateMask; j++)\r
-    {\r
-      _isMatch[i][j].Init();\r
-      _isRep0Long[i][j].Init();\r
-    }\r
-    _isRep[i].Init();\r
-    _isRepG0[i].Init();\r
-    _isRepG1[i].Init();\r
-    _isRepG2[i].Init();\r
-  }\r
-\r
-  _literalEncoder.Init();\r
-\r
-  {\r
-    for(UInt32 i = 0; i < kNumLenToPosStates; i++)\r
-      _posSlotEncoder[i].Init();\r
-  }\r
-  {\r
-    for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)\r
-      _posEncoders[i].Init();\r
-  }\r
-\r
-  _lenEncoder.Init(1 << _posStateBits);\r
-  _repMatchLenEncoder.Init(1 << _posStateBits);\r
-\r
-  _posAlignEncoder.Init();\r
-\r
-  _longestMatchWasFound = false;\r
-  _optimumEndIndex = 0;\r
-  _optimumCurrentIndex = 0;\r
-  _additionalOffset = 0;\r
-\r
-  return S_OK;\r
-}\r
-\r
-HRESULT CEncoder::MovePos(UInt32 num)\r
-{\r
-  if (num == 0)\r
-    return S_OK;\r
-  _additionalOffset += num;\r
-  return _matchFinder->Skip(num);\r
-}\r
-\r
-UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur)\r
-{\r
-  _optimumEndIndex = cur;\r
-  UInt32 posMem = _optimum[cur].PosPrev;\r
-  UInt32 backMem = _optimum[cur].BackPrev;\r
-  do\r
-  {\r
-    if (_optimum[cur].Prev1IsChar)\r
-    {\r
-      _optimum[posMem].MakeAsChar();\r
-      _optimum[posMem].PosPrev = posMem - 1;\r
-      if (_optimum[cur].Prev2)\r
-      {\r
-        _optimum[posMem - 1].Prev1IsChar = false;\r
-        _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2;\r
-        _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2;\r
-      }\r
-    }\r
-    UInt32 posPrev = posMem;\r
-    UInt32 backCur = backMem;\r
-\r
-    backMem = _optimum[posPrev].BackPrev;\r
-    posMem = _optimum[posPrev].PosPrev;\r
-\r
-    _optimum[posPrev].BackPrev = backCur;\r
-    _optimum[posPrev].PosPrev = cur;\r
-    cur = posPrev;\r
-  }\r
-  while(cur != 0);\r
-  backRes = _optimum[0].BackPrev;\r
-  _optimumCurrentIndex  = _optimum[0].PosPrev;\r
-  return _optimumCurrentIndex; \r
-}\r
-\r
-/*\r
-Out:\r
-  (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal\r
-*/\r
-\r
-HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)\r
-{\r
-  if(_optimumEndIndex != _optimumCurrentIndex)\r
-  {\r
-    const COptimal &optimum = _optimum[_optimumCurrentIndex];\r
-    lenRes = optimum.PosPrev - _optimumCurrentIndex;\r
-    backRes = optimum.BackPrev;\r
-    _optimumCurrentIndex = optimum.PosPrev;\r
-    return S_OK;\r
-  }\r
-  _optimumCurrentIndex = _optimumEndIndex = 0;\r
-  \r
-  UInt32 lenMain, numDistancePairs;\r
-  if (!_longestMatchWasFound)\r
-  {\r
-    RINOK(ReadMatchDistances(lenMain, numDistancePairs));\r
-  }\r
-  else\r
-  {\r
-    lenMain = _longestMatchLength;\r
-    numDistancePairs = _numDistancePairs;\r
-    _longestMatchWasFound = false;\r
-  }\r
-\r
-  const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;\r
-  UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;\r
-  if (numAvailableBytes < 2)\r
-  {\r
-    backRes = (UInt32)(-1);\r
-    lenRes = 1;\r
-    return S_OK;\r
-  }\r
-  if (numAvailableBytes > kMatchMaxLen)\r
-    numAvailableBytes = kMatchMaxLen;\r
-\r
-  UInt32 reps[kNumRepDistances];\r
-  UInt32 repLens[kNumRepDistances];\r
-  UInt32 repMaxIndex = 0;\r
-  UInt32 i;\r
-  for(i = 0; i < kNumRepDistances; i++)\r
-  {\r
-    reps[i] = _repDistances[i];\r
-    UInt32 backOffset = reps[i] + 1;\r
-    if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])\r
-    {\r
-      repLens[i] = 0;\r
-      continue;\r
-    }\r
-    UInt32 lenTest;\r
-    for (lenTest = 2; lenTest < numAvailableBytes && \r
-        data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);\r
-    repLens[i] = lenTest;\r
-    if (lenTest > repLens[repMaxIndex])\r
-      repMaxIndex = i;\r
-  }\r
-  if(repLens[repMaxIndex] >= _numFastBytes)\r
-  {\r
-    backRes = repMaxIndex;\r
-    lenRes = repLens[repMaxIndex];\r
-    return MovePos(lenRes - 1);\r
-  }\r
-\r
-  UInt32 *matchDistances = _matchDistances + 1;\r
-  if(lenMain >= _numFastBytes)\r
-  {\r
-    backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; \r
-    lenRes = lenMain;\r
-    return MovePos(lenMain - 1);\r
-  }\r
-  Byte currentByte = *data;\r
-  Byte matchByte = data[(size_t)0 - reps[0] - 1];\r
-\r
-  if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)\r
-  {\r
-    backRes = (UInt32)-1;\r
-    lenRes = 1;\r
-    return S_OK;\r
-  }\r
-\r
-  _optimum[0].State = _state;\r
-\r
-  UInt32 posState = (position & _posStateMask);\r
-\r
-  _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() + \r
-      _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte);\r
-  _optimum[1].MakeAsChar();\r
-\r
-  UInt32 matchPrice = _isMatch[_state.Index][posState].GetPrice1();\r
-  UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1();\r
-\r
-  if(matchByte == currentByte)\r
-  {\r
-    UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState);\r
-    if(shortRepPrice < _optimum[1].Price)\r
-    {\r
-      _optimum[1].Price = shortRepPrice;\r
-      _optimum[1].MakeAsShortRep();\r
-    }\r
-  }\r
-  UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);\r
-\r
-  if(lenEnd < 2)\r
-  {\r
-    backRes = _optimum[1].BackPrev;\r
-    lenRes = 1;\r
-    return S_OK;\r
-  }\r
-\r
-  _optimum[1].PosPrev = 0;\r
-  for (i = 0; i < kNumRepDistances; i++)\r
-    _optimum[0].Backs[i] = reps[i];\r
-\r
-  UInt32 len = lenEnd;\r
-  do\r
-    _optimum[len--].Price = kIfinityPrice;\r
-  while (len >= 2);\r
-\r
-  for(i = 0; i < kNumRepDistances; i++)\r
-  {\r
-    UInt32 repLen = repLens[i];\r
-    if (repLen < 2)\r
-      continue;\r
-    UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState);\r
-    do\r
-    {\r
-      UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState);\r
-      COptimal &optimum = _optimum[repLen];\r
-      if (curAndLenPrice < optimum.Price) \r
-      {\r
-        optimum.Price = curAndLenPrice;\r
-        optimum.PosPrev = 0;\r
-        optimum.BackPrev = i;\r
-        optimum.Prev1IsChar = false;\r
-      }\r
-    }\r
-    while(--repLen >= 2);\r
-  }\r
-\r
-  UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0();\r
-\r
-  len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);\r
-  if (len <= lenMain)\r
-  {\r
-    UInt32 offs = 0;\r
-    while (len > matchDistances[offs])\r
-      offs += 2;\r
-    for(; ; len++)\r
-    {\r
-      UInt32 distance = matchDistances[offs + 1];\r
-      UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);\r
-      COptimal &optimum = _optimum[len];\r
-      if (curAndLenPrice < optimum.Price) \r
-      {\r
-        optimum.Price = curAndLenPrice;\r
-        optimum.PosPrev = 0;\r
-        optimum.BackPrev = distance + kNumRepDistances;\r
-        optimum.Prev1IsChar = false;\r
-      }\r
-      if (len == matchDistances[offs])\r
-      {\r
-        offs += 2;\r
-        if (offs == numDistancePairs)\r
-          break;\r
-      }\r
-    }\r
-  }\r
-\r
-  UInt32 cur = 0;\r
-\r
-  while(true)\r
-  {\r
-    cur++;\r
-    if(cur == lenEnd)\r
-    {\r
-      lenRes = Backward(backRes, cur);\r
-      return S_OK;\r
-    }\r
-    UInt32 newLen, numDistancePairs;\r
-    RINOK(ReadMatchDistances(newLen, numDistancePairs));\r
-    if(newLen >= _numFastBytes)\r
-    {\r
-      _numDistancePairs = numDistancePairs;\r
-      _longestMatchLength = newLen;\r
-      _longestMatchWasFound = true;\r
-      lenRes = Backward(backRes, cur);\r
-      return S_OK;\r
-    }\r
-    position++;\r
-    COptimal &curOptimum = _optimum[cur];\r
-    UInt32 posPrev = curOptimum.PosPrev;\r
-    CState state;\r
-    if (curOptimum.Prev1IsChar)\r
-    {\r
-      posPrev--;\r
-      if (curOptimum.Prev2)\r
-      {\r
-        state = _optimum[curOptimum.PosPrev2].State;\r
-        if (curOptimum.BackPrev2 < kNumRepDistances)\r
-          state.UpdateRep();\r
-        else\r
-          state.UpdateMatch();\r
-      }\r
-      else\r
-        state = _optimum[posPrev].State;\r
-      state.UpdateChar();\r
-    }\r
-    else\r
-      state = _optimum[posPrev].State;\r
-    if (posPrev == cur - 1)\r
-    {\r
-      if (curOptimum.IsShortRep())\r
-        state.UpdateShortRep();\r
-      else\r
-        state.UpdateChar();\r
-    }\r
-    else\r
-    {\r
-      UInt32 pos;\r
-      if (curOptimum.Prev1IsChar && curOptimum.Prev2)\r
-      {\r
-        posPrev = curOptimum.PosPrev2;\r
-        pos = curOptimum.BackPrev2;\r
-        state.UpdateRep();\r
-      }\r
-      else\r
-      {\r
-        pos = curOptimum.BackPrev;\r
-        if (pos < kNumRepDistances)\r
-          state.UpdateRep();\r
-        else\r
-          state.UpdateMatch();\r
-      }\r
-      const COptimal &prevOptimum = _optimum[posPrev];\r
-      if (pos < kNumRepDistances)\r
-      {\r
-        reps[0] = prevOptimum.Backs[pos];\r
-               UInt32 i;\r
-        for(i = 1; i <= pos; i++)\r
-          reps[i] = prevOptimum.Backs[i - 1];\r
-        for(; i < kNumRepDistances; i++)\r
-          reps[i] = prevOptimum.Backs[i];\r
-      }\r
-      else\r
-      {\r
-        reps[0] = (pos - kNumRepDistances);\r
-        for(UInt32 i = 1; i < kNumRepDistances; i++)\r
-          reps[i] = prevOptimum.Backs[i - 1];\r
-      }\r
-    }\r
-    curOptimum.State = state;\r
-    for(UInt32 i = 0; i < kNumRepDistances; i++)\r
-      curOptimum.Backs[i] = reps[i];\r
-    UInt32 curPrice = curOptimum.Price; \r
-    const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;\r
-    const Byte currentByte = *data;\r
-    const Byte matchByte = data[(size_t)0 - reps[0] - 1];\r
-\r
-    UInt32 posState = (position & _posStateMask);\r
-\r
-    UInt32 curAnd1Price = curPrice +\r
-        _isMatch[state.Index][posState].GetPrice0() +\r
-        _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);\r
-\r
-    COptimal &nextOptimum = _optimum[cur + 1];\r
-\r
-    bool nextIsChar = false;\r
-    if (curAnd1Price < nextOptimum.Price) \r
-    {\r
-      nextOptimum.Price = curAnd1Price;\r
-      nextOptimum.PosPrev = cur;\r
-      nextOptimum.MakeAsChar();\r
-      nextIsChar = true;\r
-    }\r
-\r
-    UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1();\r
-    UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1();\r
-    \r
-    if(matchByte == currentByte &&\r
-        !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0))\r
-    {\r
-      UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);\r
-      if(shortRepPrice <= nextOptimum.Price)\r
-      {\r
-        nextOptimum.Price = shortRepPrice;\r
-        nextOptimum.PosPrev = cur;\r
-        nextOptimum.MakeAsShortRep();\r
-        nextIsChar = true;\r
-      }\r
-    }\r
-    /*\r
-    if(newLen == 2 && matchDistances[2] >= kDistLimit2) // test it maybe set 2000 ?\r
-      continue;\r
-    */\r
-\r
-    UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;\r
-    numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);\r
-    UInt32 numAvailableBytes = numAvailableBytesFull;\r
-\r
-    if (numAvailableBytes < 2)\r
-      continue;\r
-    if (numAvailableBytes > _numFastBytes)\r
-      numAvailableBytes = _numFastBytes;\r
-    if (!nextIsChar && matchByte != currentByte) // speed optimization\r
-    {\r
-      // try Literal + rep0\r
-      UInt32 backOffset = reps[0] + 1;\r
-      UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);\r
-      UInt32 temp;\r
-      for (temp = 1; temp < limit && \r
-          data[temp] == data[(size_t)temp - backOffset]; temp++);\r
-      UInt32 lenTest2 = temp - 1;\r
-      if (lenTest2 >= 2)\r
-      {\r
-        CState state2 = state;\r
-        state2.UpdateChar();\r
-        UInt32 posStateNext = (position + 1) & _posStateMask;\r
-        UInt32 nextRepMatchPrice = curAnd1Price + \r
-            _isMatch[state2.Index][posStateNext].GetPrice1() +\r
-            _isRep[state2.Index].GetPrice1();\r
-        // for (; lenTest2 >= 2; lenTest2--)\r
-        {\r
-          UInt32 offset = cur + 1 + lenTest2;\r
-          while(lenEnd < offset)\r
-            _optimum[++lenEnd].Price = kIfinityPrice;\r
-          UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(\r
-              0, lenTest2, state2, posStateNext);\r
-          COptimal &optimum = _optimum[offset];\r
-          if (curAndLenPrice < optimum.Price) \r
-          {\r
-            optimum.Price = curAndLenPrice;\r
-            optimum.PosPrev = cur + 1;\r
-            optimum.BackPrev = 0;\r
-            optimum.Prev1IsChar = true;\r
-            optimum.Prev2 = false;\r
-          }\r
-        }\r
-      }\r
-    }\r
-    \r
-    UInt32 startLen = 2; // speed optimization \r
-    for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)\r
-    {\r
-      // UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;\r
-      UInt32 backOffset = reps[repIndex] + 1;\r
-      if (data[0] != data[(size_t)0 - backOffset] ||\r
-          data[1] != data[(size_t)1 - backOffset])\r
-        continue;\r
-      UInt32 lenTest;\r
-      for (lenTest = 2; lenTest < numAvailableBytes && \r
-          data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);\r
-      while(lenEnd < cur + lenTest)\r
-        _optimum[++lenEnd].Price = kIfinityPrice;\r
-      UInt32 lenTestTemp = lenTest;\r
-      UInt32 price = repMatchPrice + GetPureRepPrice(repIndex, state, posState);\r
-      do\r
-      {\r
-        UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState);\r
-        COptimal &optimum = _optimum[cur + lenTest];\r
-        if (curAndLenPrice < optimum.Price) \r
-        {\r
-          optimum.Price = curAndLenPrice;\r
-          optimum.PosPrev = cur;\r
-          optimum.BackPrev = repIndex;\r
-          optimum.Prev1IsChar = false;\r
-        }\r
-      }\r
-      while(--lenTest >= 2);\r
-      lenTest = lenTestTemp;\r
-      \r
-      if (repIndex == 0)\r
-        startLen = lenTest + 1;\r
-        \r
-      // if (_maxMode)\r
-        {\r
-          UInt32 lenTest2 = lenTest + 1;\r
-          UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);\r
-          for (; lenTest2 < limit && \r
-              data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);\r
-          lenTest2 -= lenTest + 1;\r
-          if (lenTest2 >= 2)\r
-          {\r
-            CState state2 = state;\r
-            state2.UpdateRep();\r
-            UInt32 posStateNext = (position + lenTest) & _posStateMask;\r
-            UInt32 curAndLenCharPrice = \r
-                price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) + \r
-                _isMatch[state2.Index][posStateNext].GetPrice0() +\r
-                _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(\r
-                true, data[(size_t)lenTest - backOffset], data[lenTest]);\r
-            state2.UpdateChar();\r
-            posStateNext = (position + lenTest + 1) & _posStateMask;\r
-            UInt32 nextRepMatchPrice = curAndLenCharPrice + \r
-                _isMatch[state2.Index][posStateNext].GetPrice1() +\r
-                _isRep[state2.Index].GetPrice1();\r
-            \r
-            // for(; lenTest2 >= 2; lenTest2--)\r
-            {\r
-              UInt32 offset = cur + lenTest + 1 + lenTest2;\r
-              while(lenEnd < offset)\r
-                _optimum[++lenEnd].Price = kIfinityPrice;\r
-              UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(\r
-                  0, lenTest2, state2, posStateNext);\r
-              COptimal &optimum = _optimum[offset];\r
-              if (curAndLenPrice < optimum.Price) \r
-              {\r
-                optimum.Price = curAndLenPrice;\r
-                optimum.PosPrev = cur + lenTest + 1;\r
-                optimum.BackPrev = 0;\r
-                optimum.Prev1IsChar = true;\r
-                optimum.Prev2 = true;\r
-                optimum.PosPrev2 = cur;\r
-                optimum.BackPrev2 = repIndex;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    \r
-    //    for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)\r
-    if (newLen > numAvailableBytes)\r
-    {\r
-      newLen = numAvailableBytes;\r
-      for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);\r
-      matchDistances[numDistancePairs] = newLen;\r
-      numDistancePairs += 2;\r
-    }\r
-    if (newLen >= startLen)\r
-    {\r
-      UInt32 normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0();\r
-      while(lenEnd < cur + newLen)\r
-        _optimum[++lenEnd].Price = kIfinityPrice;\r
-\r
-      UInt32 offs = 0;\r
-      while(startLen > matchDistances[offs])\r
-        offs += 2;\r
-      UInt32 curBack = matchDistances[offs + 1];\r
-      UInt32 posSlot = GetPosSlot2(curBack);\r
-      for(UInt32 lenTest = /*2*/ startLen; ; lenTest++)\r
-      {\r
-        UInt32 curAndLenPrice = normalMatchPrice;\r
-        UInt32 lenToPosState = GetLenToPosState(lenTest);\r
-        if (curBack < kNumFullDistances)\r
-          curAndLenPrice += _distancesPrices[lenToPosState][curBack];\r
-        else\r
-          curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask];\r
-  \r
-        curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState);\r
-        \r
-        COptimal &optimum = _optimum[cur + lenTest];\r
-        if (curAndLenPrice < optimum.Price) \r
-        {\r
-          optimum.Price = curAndLenPrice;\r
-          optimum.PosPrev = cur;\r
-          optimum.BackPrev = curBack + kNumRepDistances;\r
-          optimum.Prev1IsChar = false;\r
-        }\r
-\r
-        if (/*_maxMode && */lenTest == matchDistances[offs])\r
-        {\r
-          // Try Match + Literal + Rep0\r
-          UInt32 backOffset = curBack + 1;\r
-          UInt32 lenTest2 = lenTest + 1;\r
-          UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);\r
-          for (; lenTest2 < limit && \r
-              data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);\r
-          lenTest2 -= lenTest + 1;\r
-          if (lenTest2 >= 2)\r
-          {\r
-            CState state2 = state;\r
-            state2.UpdateMatch();\r
-            UInt32 posStateNext = (position + lenTest) & _posStateMask;\r
-            UInt32 curAndLenCharPrice = curAndLenPrice + \r
-                _isMatch[state2.Index][posStateNext].GetPrice0() +\r
-                _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice( \r
-                true, data[(size_t)lenTest - backOffset], data[lenTest]);\r
-            state2.UpdateChar();\r
-            posStateNext = (posStateNext + 1) & _posStateMask;\r
-            UInt32 nextRepMatchPrice = curAndLenCharPrice + \r
-                _isMatch[state2.Index][posStateNext].GetPrice1() +\r
-                _isRep[state2.Index].GetPrice1();\r
-            \r
-            // for(; lenTest2 >= 2; lenTest2--)\r
-            {\r
-              UInt32 offset = cur + lenTest + 1 + lenTest2;\r
-              while(lenEnd < offset)\r
-                _optimum[++lenEnd].Price = kIfinityPrice;\r
-              UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);\r
-              COptimal &optimum = _optimum[offset];\r
-              if (curAndLenPrice < optimum.Price) \r
-              {\r
-                optimum.Price = curAndLenPrice;\r
-                optimum.PosPrev = cur + lenTest + 1;\r
-                optimum.BackPrev = 0;\r
-                optimum.Prev1IsChar = true;\r
-                optimum.Prev2 = true;\r
-                optimum.PosPrev2 = cur;\r
-                optimum.BackPrev2 = curBack + kNumRepDistances;\r
-              }\r
-            }\r
-          }\r
-          offs += 2;\r
-          if (offs == numDistancePairs)\r
-            break;\r
-          curBack = matchDistances[offs + 1];\r
-          if (curBack >= kNumFullDistances)\r
-            posSlot = GetPosSlot2(curBack);\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-static inline bool ChangePair(UInt32 smallDist, UInt32 bigDist)\r
-{\r
-  return ((bigDist >> 7) > smallDist);\r
-}\r
-\r
-\r
-HRESULT CEncoder::ReadMatchDistances(UInt32 &lenRes, UInt32 &numDistancePairs)\r
-{\r
-  lenRes = 0;\r
-  RINOK(_matchFinder->GetMatches(_matchDistances));\r
-  numDistancePairs = _matchDistances[0];\r
-  if (numDistancePairs > 0)\r
-  {\r
-    lenRes = _matchDistances[1 + numDistancePairs - 2];\r
-    if (lenRes == _numFastBytes)\r
-      lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1], \r
-          kMatchMaxLen - lenRes);\r
-  }\r
-  _additionalOffset++;\r
-  return S_OK;\r
-}\r
-\r
-HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes)\r
-{\r
-  UInt32 lenMain, numDistancePairs;\r
-  if (!_longestMatchWasFound)\r
-  {\r
-    RINOK(ReadMatchDistances(lenMain, numDistancePairs));\r
-  }\r
-  else\r
-  {\r
-    lenMain = _longestMatchLength;\r
-    numDistancePairs = _numDistancePairs;\r
-    _longestMatchWasFound = false;\r
-  }\r
-\r
-  const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;\r
-  UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;\r
-  if (numAvailableBytes > kMatchMaxLen)\r
-    numAvailableBytes = kMatchMaxLen;\r
-  if (numAvailableBytes < 2)\r
-  {\r
-    backRes = (UInt32)(-1);\r
-    lenRes = 1;\r
-    return S_OK;\r
-  }\r
-\r
-  UInt32 repLens[kNumRepDistances];\r
-  UInt32 repMaxIndex = 0;\r
-\r
-  for(UInt32 i = 0; i < kNumRepDistances; i++)\r
-  {\r
-    UInt32 backOffset = _repDistances[i] + 1;\r
-    if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])\r
-    {\r
-      repLens[i] = 0;\r
-      continue;\r
-    }\r
-    UInt32 len;\r
-    for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);\r
-    if(len >= _numFastBytes)\r
-    {\r
-      backRes = i;\r
-      lenRes = len;\r
-      return MovePos(lenRes - 1);\r
-    }\r
-    repLens[i] = len;\r
-    if (len > repLens[repMaxIndex])\r
-      repMaxIndex = i;\r
-  }\r
-  UInt32 *matchDistances = _matchDistances + 1;\r
-  if(lenMain >= _numFastBytes)\r
-  {\r
-    backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; \r
-    lenRes = lenMain;\r
-    return MovePos(lenMain - 1);\r
-  }\r
-\r
-  UInt32 backMain = 0;\r
-  if (lenMain >= 2)\r
-  {\r
-    backMain = matchDistances[numDistancePairs - 1];\r
-    while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)\r
-    {\r
-      if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))\r
-        break;\r
-      numDistancePairs -= 2;\r
-      lenMain = matchDistances[numDistancePairs - 2];\r
-      backMain = matchDistances[numDistancePairs - 1];\r
-    }\r
-    if (lenMain == 2 && backMain >= 0x80)\r
-      lenMain = 1;\r
-  }\r
-\r
-  if (repLens[repMaxIndex] >= 2)\r
-  {\r
-    if (repLens[repMaxIndex] + 1 >= lenMain || \r
-        repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9)) ||\r
-        repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15)))\r
-    {\r
-      backRes = repMaxIndex;\r
-      lenRes = repLens[repMaxIndex];\r
-      return MovePos(lenRes - 1);\r
-    }\r
-  }\r
-  \r
-  if (lenMain >= 2 && numAvailableBytes > 2)\r
-  {\r
-    RINOK(ReadMatchDistances(_longestMatchLength, _numDistancePairs));\r
-    if (_longestMatchLength >= 2)\r
-    {\r
-      UInt32 newDistance = matchDistances[_numDistancePairs - 1];\r
-      if (_longestMatchLength >= lenMain && newDistance < backMain || \r
-          _longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance) ||\r
-          _longestMatchLength > lenMain + 1 ||\r
-          _longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain))\r
-      {\r
-        _longestMatchWasFound = true;\r
-        backRes = UInt32(-1);\r
-        lenRes = 1;\r
-        return S_OK;\r
-      }\r
-    }\r
-    data++;\r
-    numAvailableBytes--;\r
-    for(UInt32 i = 0; i < kNumRepDistances; i++)\r
-    {\r
-      UInt32 backOffset = _repDistances[i] + 1;\r
-      if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])\r
-      {\r
-        repLens[i] = 0;\r
-        continue;\r
-      }\r
-      UInt32 len;\r
-      for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);\r
-      if (len + 1 >= lenMain)\r
-      {\r
-        _longestMatchWasFound = true;\r
-        backRes = UInt32(-1);\r
-        lenRes = 1;\r
-        return S_OK;\r
-      }\r
-    }\r
-    backRes = backMain + kNumRepDistances; \r
-    lenRes = lenMain;\r
-    return MovePos(lenMain - 2);\r
-  }\r
-  backRes = UInt32(-1);\r
-  lenRes = 1;\r
-  return S_OK;\r
-}\r
-\r
-HRESULT CEncoder::Flush(UInt32 nowPos)\r
-{\r
-  ReleaseMFStream();\r
-  WriteEndMarker(nowPos & _posStateMask);\r
-  _rangeEncoder.FlushData();\r
-  return _rangeEncoder.FlushStream();\r
-}\r
-\r
-void CEncoder::WriteEndMarker(UInt32 posState)\r
-{\r
-  // This function for writing End Mark for stream version of LZMA. \r
-  // In current version this feature is not used.\r
-  if (!_writeEndMark)\r
-    return;\r
-\r
-  _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);\r
-  _isRep[_state.Index].Encode(&_rangeEncoder, 0);\r
-  _state.UpdateMatch();\r
-  UInt32 len = kMatchMinLen; // kMatchMaxLen;\r
-  _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);\r
-  UInt32 posSlot = (1 << kNumPosSlotBits)  - 1;\r
-  UInt32 lenToPosState = GetLenToPosState(len);\r
-  _posSlotEncoder[lenToPosState].Encode(&_rangeEncoder, posSlot);\r
-  UInt32 footerBits = 30;\r
-  UInt32 posReduced = (UInt32(1) << footerBits) - 1;\r
-  _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);\r
-  _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);\r
-}\r
-\r
-HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream, \r
-      const UInt64 *inSize, const UInt64 *outSize,\r
-      ICompressProgressInfo *progress)\r
-{\r
-  _needReleaseMFStream = false;\r
-  CCoderReleaser coderReleaser(this);\r
-  RINOK(SetStreams(inStream, outStream, inSize, outSize));\r
-  while(true)\r
-  {\r
-    UInt64 processedInSize;\r
-    UInt64 processedOutSize;\r
-    Int32 finished;\r
-    RINOK(CodeOneBlock(&processedInSize, &processedOutSize, &finished));\r
-    if (finished != 0)\r
-      return S_OK;\r
-    if (progress != 0)\r
-    {\r
-      RINOK(progress->SetRatioInfo(&processedInSize, &processedOutSize));\r
-    }\r
-  }\r
-}\r
-\r
-HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream, \r
-      const UInt64 *inSize, const UInt64 *outSize)\r
-{\r
-  _inStream = inStream;\r
-  _finished = false;\r
-  RINOK(Create());\r
-  RINOK(SetOutStream(outStream));\r
-  RINOK(Init());\r
-  \r
-  // CCoderReleaser releaser(this);\r
-\r
-  /*\r
-  if (_matchFinder->GetNumAvailableBytes() == 0)\r
-    return Flush();\r
-  */\r
-\r
-  if (!_fastMode)\r
-  {\r
-    FillDistancesPrices();\r
-    FillAlignPrices();\r
-  }\r
-\r
-  _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);\r
-  _lenEncoder.UpdateTables(1 << _posStateBits);\r
-  _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);\r
-  _repMatchLenEncoder.UpdateTables(1 << _posStateBits);\r
-\r
-  nowPos64 = 0;\r
-  return S_OK;\r
-}\r
-\r
-HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished)\r
-{\r
-  if (_inStream != 0)\r
-  {\r
-    RINOK(_matchFinder->SetStream(_inStream));\r
-    RINOK(_matchFinder->Init());\r
-    _needReleaseMFStream = true;\r
-    _inStream = 0;\r
-  }\r
-\r
-\r
-  *finished = 1;\r
-  if (_finished)\r
-    return S_OK;\r
-  _finished = true;\r
-\r
-  if (nowPos64 == 0)\r
-  {\r
-    if (_matchFinder->GetNumAvailableBytes() == 0)\r
-      return Flush(UInt32(nowPos64));\r
-    UInt32 len, numDistancePairs;\r
-    RINOK(ReadMatchDistances(len, numDistancePairs));\r
-    UInt32 posState = UInt32(nowPos64) & _posStateMask;\r
-    _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);\r
-    _state.UpdateChar();\r
-    Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);\r
-    _literalEncoder.GetSubCoder(UInt32(nowPos64), _previousByte)->Encode(&_rangeEncoder, curByte);\r
-    _previousByte = curByte;\r
-    _additionalOffset--;\r
-    nowPos64++;\r
-  }\r
-\r
-  UInt32 nowPos32 = (UInt32)nowPos64;\r
-  UInt32 progressPosValuePrev = nowPos32;\r
-\r
-  if (_matchFinder->GetNumAvailableBytes() == 0)\r
-    return Flush(nowPos32);\r
-\r
-  while(true)\r
-  {\r
-    #ifdef _NO_EXCEPTIONS\r
-    if (_rangeEncoder.Stream.ErrorCode != S_OK)\r
-      return _rangeEncoder.Stream.ErrorCode;\r
-    #endif\r
-    UInt32 pos, len;\r
-    HRESULT result;\r
-    if (_fastMode)\r
-      result = GetOptimumFast(nowPos32, pos, len);\r
-    else\r
-      result = GetOptimum(nowPos32, pos, len);\r
-    RINOK(result);\r
-\r
-    UInt32 posState = nowPos32 & _posStateMask;\r
-    if(len == 1 && pos == 0xFFFFFFFF)\r
-    {\r
-      _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);\r
-      Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);\r
-      CLiteralEncoder2 *subCoder = _literalEncoder.GetSubCoder(nowPos32, _previousByte);\r
-      if(_state.IsCharState())\r
-        subCoder->Encode(&_rangeEncoder, curByte);\r
-      else\r
-      {\r
-        Byte matchByte = _matchFinder->GetIndexByte(0 - _repDistances[0] - 1 - _additionalOffset);\r
-        subCoder->EncodeMatched(&_rangeEncoder, matchByte, curByte);\r
-      }\r
-      _state.UpdateChar();\r
-      _previousByte = curByte;\r
-    }\r
-    else\r
-    {\r
-      _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);\r
-      if(pos < kNumRepDistances)\r
-      {\r
-        _isRep[_state.Index].Encode(&_rangeEncoder, 1);\r
-        if(pos == 0)\r
-        {\r
-          _isRepG0[_state.Index].Encode(&_rangeEncoder, 0);\r
-          _isRep0Long[_state.Index][posState].Encode(&_rangeEncoder, ((len == 1) ? 0 : 1));\r
-        }\r
-        else\r
-        {\r
-          UInt32 distance = _repDistances[pos];\r
-          _isRepG0[_state.Index].Encode(&_rangeEncoder, 1);\r
-          if (pos == 1)\r
-            _isRepG1[_state.Index].Encode(&_rangeEncoder, 0);\r
-          else\r
-          {\r
-            _isRepG1[_state.Index].Encode(&_rangeEncoder, 1);\r
-            _isRepG2[_state.Index].Encode(&_rangeEncoder, pos - 2);\r
-            if (pos == 3)\r
-              _repDistances[3] = _repDistances[2];\r
-            _repDistances[2] = _repDistances[1];\r
-          }\r
-          _repDistances[1] = _repDistances[0];\r
-          _repDistances[0] = distance;\r
-        }\r
-        if (len == 1)\r
-          _state.UpdateShortRep();\r
-        else\r
-        {\r
-          _repMatchLenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);\r
-          _state.UpdateRep();\r
-        }\r
-      }\r
-      else\r
-      {\r
-        _isRep[_state.Index].Encode(&_rangeEncoder, 0);\r
-        _state.UpdateMatch();\r
-        _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);\r
-        pos -= kNumRepDistances;\r
-        UInt32 posSlot = GetPosSlot(pos);\r
-        _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot);\r
-        \r
-        if (posSlot >= kStartPosModelIndex)\r
-        {\r
-          UInt32 footerBits = ((posSlot >> 1) - 1);\r
-          UInt32 base = ((2 | (posSlot & 1)) << footerBits);\r
-          UInt32 posReduced = pos - base;\r
-\r
-          if (posSlot < kEndPosModelIndex)\r
-            NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1, \r
-                &_rangeEncoder, footerBits, posReduced);\r
-          else\r
-          {\r
-            _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);\r
-            _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);\r
-            _alignPriceCount++;\r
-          }\r
-        }\r
-        _repDistances[3] = _repDistances[2];\r
-        _repDistances[2] = _repDistances[1];\r
-        _repDistances[1] = _repDistances[0];\r
-        _repDistances[0] = pos;\r
-        _matchPriceCount++;\r
-      }\r
-      _previousByte = _matchFinder->GetIndexByte(len - 1 - _additionalOffset);\r
-    }\r
-    _additionalOffset -= len;\r
-    nowPos32 += len;\r
-    if (_additionalOffset == 0)\r
-    {\r
-      if (!_fastMode)\r
-      {\r
-        if (_matchPriceCount >= (1 << 7))\r
-          FillDistancesPrices();\r
-        if (_alignPriceCount >= kAlignTableSize)\r
-          FillAlignPrices();\r
-      }\r
-      if (_matchFinder->GetNumAvailableBytes() == 0)\r
-        return Flush(nowPos32);\r
-      if (nowPos32 - progressPosValuePrev >= (1 << 14))\r
-      {\r
-        nowPos64 += nowPos32 - progressPosValuePrev;\r
-        *inSize = nowPos64;\r
-        *outSize = _rangeEncoder.GetProcessedSize();\r
-        _finished = false;\r
-        *finished = 0;\r
-        return S_OK;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,\r
-    ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,\r
-    ICompressProgressInfo *progress)\r
-{\r
-  #ifndef _NO_EXCEPTIONS\r
-  try \r
-  { \r
-  #endif\r
-    return CodeReal(inStream, outStream, inSize, outSize, progress); \r
-  #ifndef _NO_EXCEPTIONS\r
-  }\r
-  catch(const COutBufferException &e) { return e.ErrorCode; }\r
-  catch(...) { return E_FAIL; }\r
-  #endif\r
-}\r
-  \r
-void CEncoder::FillDistancesPrices()\r
-{\r
-  UInt32 tempPrices[kNumFullDistances];\r
-  for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++)\r
-  { \r
-    UInt32 posSlot = GetPosSlot(i);\r
-    UInt32 footerBits = ((posSlot >> 1) - 1);\r
-    UInt32 base = ((2 | (posSlot & 1)) << footerBits);\r
-    tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders + \r
-      base - posSlot - 1, footerBits, i - base);\r
-  }\r
-\r
-  for (UInt32 lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)\r
-  {\r
-         UInt32 posSlot;\r
-    NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> &encoder = _posSlotEncoder[lenToPosState];\r
-    UInt32 *posSlotPrices = _posSlotPrices[lenToPosState];\r
-    for (posSlot = 0; posSlot < _distTableSize; posSlot++)\r
-      posSlotPrices[posSlot] = encoder.GetPrice(posSlot);\r
-    for (posSlot = kEndPosModelIndex; posSlot < _distTableSize; posSlot++)\r
-      posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << NRangeCoder::kNumBitPriceShiftBits);\r
-\r
-    UInt32 *distancesPrices = _distancesPrices[lenToPosState];\r
-         UInt32 i;\r
-    for (i = 0; i < kStartPosModelIndex; i++)\r
-      distancesPrices[i] = posSlotPrices[i];\r
-    for (; i < kNumFullDistances; i++)\r
-      distancesPrices[i] = posSlotPrices[GetPosSlot(i)] + tempPrices[i];\r
-  }\r
-  _matchPriceCount = 0;\r
-}\r
-\r
-void CEncoder::FillAlignPrices()\r
-{\r
-  for (UInt32 i = 0; i < kAlignTableSize; i++)\r
-    _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i);\r
-  _alignPriceCount = 0;\r
-}\r
-\r
-}}\r
+// LZMA/Encoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/Defs.h"
+#include "../../Common/StreamUtils.h"
+
+#include "LZMAEncoder.h"
+
+// for minimal compressing code size define these:
+// #define COMPRESS_MF_BT
+// #define COMPRESS_MF_BT4
+
+#if !defined(COMPRESS_MF_BT) && !defined(COMPRESS_MF_HC)
+#define COMPRESS_MF_BT
+#define COMPRESS_MF_HC
+#endif
+
+#ifdef COMPRESS_MF_BT
+#if !defined(COMPRESS_MF_BT2) && !defined(COMPRESS_MF_BT3) && !defined(COMPRESS_MF_BT4)
+#define COMPRESS_MF_BT2
+#define COMPRESS_MF_BT3
+#define COMPRESS_MF_BT4
+#endif
+#ifdef COMPRESS_MF_BT2
+#include "../LZ/BinTree/BinTree2.h"
+#endif
+#ifdef COMPRESS_MF_BT3
+#include "../LZ/BinTree/BinTree3.h"
+#endif
+#ifdef COMPRESS_MF_BT4
+#include "../LZ/BinTree/BinTree4.h"
+#endif
+#endif
+
+#ifdef COMPRESS_MF_HC
+#include "../LZ/HashChain/HC4.h"
+#endif
+
+#ifdef COMPRESS_MF_MT
+#include "../LZ/MT/MT.h"
+#endif
+
+namespace NCompress {
+namespace NLZMA {
+
+const int kDefaultDictionaryLogSize = 22;
+const UInt32 kNumFastBytesDefault = 0x20;
+
+enum 
+{
+  kBT2,
+  kBT3,
+  kBT4,
+  kHC4
+};
+
+static const wchar_t *kMatchFinderIDs[] = 
+{
+  L"BT2",
+  L"BT3",
+  L"BT4",
+  L"HC4"
+};
+
+Byte g_FastPos[1 << 11];
+
+class CFastPosInit
+{
+public:
+  CFastPosInit() { Init(); }
+  void Init()
+  {
+    const Byte kFastSlots = 22;
+    int c = 2;
+    g_FastPos[0] = 0;
+    g_FastPos[1] = 1;
+
+    for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++)
+    {
+      UInt32 k = (1 << ((slotFast >> 1) - 1));
+      for (UInt32 j = 0; j < k; j++, c++)
+        g_FastPos[c] = slotFast;
+    }
+  }
+} g_FastPosInit;
+
+
+void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)
+{
+  UInt32 context = 1;
+  int i = 8;
+  do 
+  {
+    i--;
+    UInt32 bit = (symbol >> i) & 1;
+    _encoders[context].Encode(rangeEncoder, bit);
+    context = (context << 1) | bit;
+  }
+  while(i != 0);
+}
+
+void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, 
+    Byte matchByte, Byte symbol)
+{
+  UInt32 context = 1;
+  int i = 8;
+  do 
+  {
+    i--;
+    UInt32 bit = (symbol >> i) & 1;
+    UInt32 matchBit = (matchByte >> i) & 1;
+    _encoders[0x100 + (matchBit << 8) + context].Encode(rangeEncoder, bit);
+    context = (context << 1) | bit;
+    if (matchBit != bit)
+    {
+      while(i != 0)
+      {
+        i--;
+        UInt32 bit = (symbol >> i) & 1;
+        _encoders[context].Encode(rangeEncoder, bit);
+        context = (context << 1) | bit;
+      }
+      break;
+    }
+  }
+  while(i != 0);
+}
+
+UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) const
+{
+  UInt32 price = 0;
+  UInt32 context = 1;
+  int i = 8;
+  if (matchMode)
+  {
+    do 
+    {
+      i--;
+      UInt32 matchBit = (matchByte >> i) & 1;
+      UInt32 bit = (symbol >> i) & 1;
+      price += _encoders[0x100 + (matchBit << 8) + context].GetPrice(bit);
+      context = (context << 1) | bit;
+      if (matchBit != bit)
+        break;
+    }
+    while (i != 0);
+  }
+  while(i != 0)
+  {
+    i--;
+    UInt32 bit = (symbol >> i) & 1;
+    price += _encoders[context].GetPrice(bit);
+    context = (context << 1) | bit;
+  }
+  return price;
+};
+
+
+namespace NLength {
+
+void CEncoder::Init(UInt32 numPosStates)
+{
+  _choice.Init();
+  _choice2.Init();
+  for (UInt32 posState = 0; posState < numPosStates; posState++)
+  {
+    _lowCoder[posState].Init();
+    _midCoder[posState].Init();
+  }
+  _highCoder.Init();
+}
+
+void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)
+{
+  if(symbol < kNumLowSymbols)
+  {
+    _choice.Encode(rangeEncoder, 0);
+    _lowCoder[posState].Encode(rangeEncoder, symbol);
+  }
+  else
+  {
+    _choice.Encode(rangeEncoder, 1);
+    if(symbol < kNumLowSymbols + kNumMidSymbols)
+    {
+      _choice2.Encode(rangeEncoder, 0);
+      _midCoder[posState].Encode(rangeEncoder, symbol - kNumLowSymbols);
+    }
+    else
+    {
+      _choice2.Encode(rangeEncoder, 1);
+      _highCoder.Encode(rangeEncoder, symbol - kNumLowSymbols - kNumMidSymbols);
+    }
+  }
+}
+
+void CEncoder::SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const
+{
+  UInt32 a0 = _choice.GetPrice0();
+  UInt32 a1 = _choice.GetPrice1();
+  UInt32 b0 = a1 + _choice2.GetPrice0();
+  UInt32 b1 = a1 + _choice2.GetPrice1();
+  UInt32 i = 0;
+  for (i = 0; i < kNumLowSymbols; i++)
+  {
+    if (i >= numSymbols)
+      return;
+    prices[i] = a0 + _lowCoder[posState].GetPrice(i);
+  }
+  for (; i < kNumLowSymbols + kNumMidSymbols; i++)
+  {
+    if (i >= numSymbols)
+      return;
+    prices[i] = b0 + _midCoder[posState].GetPrice(i - kNumLowSymbols);
+  }
+  for (; i < numSymbols; i++)
+    prices[i] = b1 + _highCoder.GetPrice(i - kNumLowSymbols - kNumMidSymbols);
+}
+
+}
+CEncoder::CEncoder():
+  _numFastBytes(kNumFastBytesDefault),
+  _distTableSize(kDefaultDictionaryLogSize * 2),
+  _posStateBits(2),
+  _posStateMask(4 - 1),
+  _numLiteralPosStateBits(0),
+  _numLiteralContextBits(3),
+  _dictionarySize(1 << kDefaultDictionaryLogSize),
+  _dictionarySizePrev(UInt32(-1)),
+  _numFastBytesPrev(UInt32(-1)),
+  _matchFinderCycles(0),
+  _matchFinderIndex(kBT4),
+   #ifdef COMPRESS_MF_MT
+  _multiThread(false),
+   #endif
+  _writeEndMark(false),
+  setMfPasses(0)
+{
+  // _maxMode = false;
+  _fastMode = false;
+}
+
+HRESULT CEncoder::Create()
+{
+  if (!_rangeEncoder.Create(1 << 20))
+    return E_OUTOFMEMORY;
+  if (!_matchFinder)
+  {
+    switch(_matchFinderIndex)
+    {
+      #ifdef COMPRESS_MF_BT
+      #ifdef COMPRESS_MF_BT2
+      case kBT2:
+      {
+        NBT2::CMatchFinder *mfSpec = new NBT2::CMatchFinder;
+        setMfPasses = mfSpec;
+        _matchFinder = mfSpec;
+        break;
+      }
+      #endif
+      #ifdef COMPRESS_MF_BT3
+      case kBT3:
+      {
+        NBT3::CMatchFinder *mfSpec = new NBT3::CMatchFinder;
+        setMfPasses = mfSpec;
+        _matchFinder = mfSpec;
+        break;
+      }
+      #endif
+      #ifdef COMPRESS_MF_BT4
+      case kBT4:
+      {
+        NBT4::CMatchFinder *mfSpec = new NBT4::CMatchFinder;
+        setMfPasses = mfSpec;
+        _matchFinder = mfSpec;
+        break;
+      }
+      #endif
+      #endif
+      
+      #ifdef COMPRESS_MF_HC
+      case kHC4:
+      {
+        NHC4::CMatchFinder *mfSpec = new NHC4::CMatchFinder;
+        setMfPasses = mfSpec;
+        _matchFinder = mfSpec;
+        break;
+      }
+      #endif
+    }
+    if (_matchFinder == 0)
+      return E_OUTOFMEMORY;
+
+    #ifdef COMPRESS_MF_MT
+    if (_multiThread && !(_fastMode && (_matchFinderIndex == kHC4)))
+    {
+      CMatchFinderMT *mfSpec = new CMatchFinderMT;
+      if (mfSpec == 0)
+        return E_OUTOFMEMORY;
+      CMyComPtr<IMatchFinder> mf = mfSpec;
+      RINOK(mfSpec->SetMatchFinder(_matchFinder));
+      _matchFinder.Release();
+      _matchFinder = mf;
+    }
+    #endif
+  }
+  
+  if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits))
+    return E_OUTOFMEMORY;
+
+  if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
+    return S_OK;
+  RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen + 1)); // actually it's + _numFastBytes - _numFastBytes
+  if (_matchFinderCycles != 0 && setMfPasses != 0)
+    setMfPasses->SetNumPasses(_matchFinderCycles);
+  _dictionarySizePrev = _dictionarySize;
+  _numFastBytesPrev = _numFastBytes;
+  return S_OK;
+}
+
+static bool AreStringsEqual(const wchar_t *base, const wchar_t *testString)
+{
+  while (true)
+  {
+    wchar_t c = *testString;
+    if (c >= 'a' && c <= 'z')
+      c -= 0x20;
+    if (*base != c)
+      return false;
+    if (c == 0)
+      return true;
+    base++;
+    testString++;
+  }
+}
+
+static int FindMatchFinder(const wchar_t *s)
+{
+  for (int m = 0; m < (int)(sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0])); m++)
+    if (AreStringsEqual(kMatchFinderIDs[m], s))
+      return m;
+  return -1;
+}
+
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, 
+    const PROPVARIANT *properties, UInt32 numProperties)
+{
+  for (UInt32 i = 0; i < numProperties; i++)
+  {
+    const PROPVARIANT &prop = properties[i];
+    switch(propIDs[i])
+    {
+      case NCoderPropID::kNumFastBytes:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 numFastBytes = prop.ulVal;
+        if(numFastBytes < 5 || numFastBytes > kMatchMaxLen)
+          return E_INVALIDARG;
+        _numFastBytes = numFastBytes;
+        break;
+      }
+      case NCoderPropID::kMatchFinderCycles:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        _matchFinderCycles = prop.ulVal;
+        break;
+      }
+      case NCoderPropID::kAlgorithm:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 maximize = prop.ulVal;
+        _fastMode = (maximize == 0); 
+        // _maxMode = (maximize >= 2);
+        break;
+      }
+      case NCoderPropID::kMatchFinder:
+      {
+        if (prop.vt != VT_BSTR)
+          return E_INVALIDARG;
+        int matchFinderIndexPrev = _matchFinderIndex;
+        int m = FindMatchFinder(prop.bstrVal);
+        if (m < 0)
+          return E_INVALIDARG;
+        _matchFinderIndex = m;
+        if (_matchFinder && matchFinderIndexPrev != _matchFinderIndex)
+        {
+          _dictionarySizePrev = (UInt32)-1;
+          ReleaseMatchFinder();
+        }
+        break;
+      }
+      #ifdef COMPRESS_MF_MT
+      case NCoderPropID::kMultiThread:
+      {
+        if (prop.vt != VT_BOOL)
+          return E_INVALIDARG;
+        bool newMultiThread = (prop.boolVal == VARIANT_TRUE);
+        if (newMultiThread != _multiThread)
+        {
+          _dictionarySizePrev = (UInt32)-1;
+          ReleaseMatchFinder();
+          _multiThread = newMultiThread;
+        }
+        break;
+      }
+      case NCoderPropID::kNumThreads:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        bool newMultiThread = (prop.ulVal > 1);
+        if (newMultiThread != _multiThread)
+        {
+          _dictionarySizePrev = (UInt32)-1;
+          ReleaseMatchFinder();
+          _multiThread = newMultiThread;
+        }
+        break;
+      }
+      #endif
+      case NCoderPropID::kDictionarySize:
+      {
+        const int kDicLogSizeMaxCompress = 30;
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 dictionarySize = prop.ulVal;
+        if (dictionarySize < UInt32(1 << kDicLogSizeMin) ||
+            dictionarySize > UInt32(1 << kDicLogSizeMaxCompress))
+          return E_INVALIDARG;
+        _dictionarySize = dictionarySize;
+        UInt32 dicLogSize;
+        for(dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++)
+          if (dictionarySize <= (UInt32(1) << dicLogSize))
+            break;
+        _distTableSize = dicLogSize * 2;
+        break;
+      }
+      case NCoderPropID::kPosStateBits:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 value = prop.ulVal;
+        if (value > (UInt32)NLength::kNumPosStatesBitsEncodingMax)
+          return E_INVALIDARG;
+        _posStateBits = value;
+        _posStateMask = (1 << _posStateBits) - 1;
+        break;
+      }
+      case NCoderPropID::kLitPosBits:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 value = prop.ulVal;
+        if (value > (UInt32)kNumLitPosStatesBitsEncodingMax)
+          return E_INVALIDARG;
+        _numLiteralPosStateBits = value;
+        break;
+      }
+      case NCoderPropID::kLitContextBits:
+      {
+        if (prop.vt != VT_UI4)
+          return E_INVALIDARG;
+        UInt32 value = prop.ulVal;
+        if (value > (UInt32)kNumLitContextBitsMax)
+          return E_INVALIDARG;
+        _numLiteralContextBits = value;
+        break;
+      }
+      case NCoderPropID::kEndMarker:
+      {
+        if (prop.vt != VT_BOOL)
+          return E_INVALIDARG;
+        SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE);
+        break;
+      }
+      default:
+        return E_INVALIDARG;
+    }
+  }
+  return S_OK;
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{ 
+  const UInt32 kPropSize = 5;
+  Byte properties[kPropSize];
+  properties[0] = (_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits;
+  for (int i = 0; i < 4; i++)
+    properties[1 + i] = Byte(_dictionarySize >> (8 * i));
+  return WriteStream(outStream, properties, kPropSize, NULL);
+}
+
+STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream)
+{
+  _rangeEncoder.SetStream(outStream);
+  return S_OK;
+}
+
+STDMETHODIMP CEncoder::ReleaseOutStream()
+{
+  _rangeEncoder.ReleaseStream();
+  return S_OK;
+}
+
+HRESULT CEncoder::Init()
+{
+  CBaseState::Init();
+
+  // RINOK(_matchFinder->Init(inStream));
+  _rangeEncoder.Init();
+
+  for(int i = 0; i < kNumStates; i++)
+  {
+    for (UInt32 j = 0; j <= _posStateMask; j++)
+    {
+      _isMatch[i][j].Init();
+      _isRep0Long[i][j].Init();
+    }
+    _isRep[i].Init();
+    _isRepG0[i].Init();
+    _isRepG1[i].Init();
+    _isRepG2[i].Init();
+  }
+
+  _literalEncoder.Init();
+
+  {
+    for(UInt32 i = 0; i < kNumLenToPosStates; i++)
+      _posSlotEncoder[i].Init();
+  }
+  {
+    for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
+      _posEncoders[i].Init();
+  }
+
+  _lenEncoder.Init(1 << _posStateBits);
+  _repMatchLenEncoder.Init(1 << _posStateBits);
+
+  _posAlignEncoder.Init();
+
+  _longestMatchWasFound = false;
+  _optimumEndIndex = 0;
+  _optimumCurrentIndex = 0;
+  _additionalOffset = 0;
+
+  return S_OK;
+}
+
+HRESULT CEncoder::MovePos(UInt32 num)
+{
+  if (num == 0)
+    return S_OK;
+  _additionalOffset += num;
+  return _matchFinder->Skip(num);
+}
+
+UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur)
+{
+  _optimumEndIndex = cur;
+  UInt32 posMem = _optimum[cur].PosPrev;
+  UInt32 backMem = _optimum[cur].BackPrev;
+  do
+  {
+    if (_optimum[cur].Prev1IsChar)
+    {
+      _optimum[posMem].MakeAsChar();
+      _optimum[posMem].PosPrev = posMem - 1;
+      if (_optimum[cur].Prev2)
+      {
+        _optimum[posMem - 1].Prev1IsChar = false;
+        _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2;
+        _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2;
+      }
+    }
+    UInt32 posPrev = posMem;
+    UInt32 backCur = backMem;
+
+    backMem = _optimum[posPrev].BackPrev;
+    posMem = _optimum[posPrev].PosPrev;
+
+    _optimum[posPrev].BackPrev = backCur;
+    _optimum[posPrev].PosPrev = cur;
+    cur = posPrev;
+  }
+  while(cur != 0);
+  backRes = _optimum[0].BackPrev;
+  _optimumCurrentIndex  = _optimum[0].PosPrev;
+  return _optimumCurrentIndex; 
+}
+
+/*
+Out:
+  (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
+*/
+
+HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
+{
+  if(_optimumEndIndex != _optimumCurrentIndex)
+  {
+    const COptimal &optimum = _optimum[_optimumCurrentIndex];
+    lenRes = optimum.PosPrev - _optimumCurrentIndex;
+    backRes = optimum.BackPrev;
+    _optimumCurrentIndex = optimum.PosPrev;
+    return S_OK;
+  }
+  _optimumCurrentIndex = _optimumEndIndex = 0;
+  
+  UInt32 lenMain, numDistancePairs;
+  if (!_longestMatchWasFound)
+  {
+    RINOK(ReadMatchDistances(lenMain, numDistancePairs));
+  }
+  else
+  {
+    lenMain = _longestMatchLength;
+    numDistancePairs = _numDistancePairs;
+    _longestMatchWasFound = false;
+  }
+
+  const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
+  UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
+  if (numAvailableBytes < 2)
+  {
+    backRes = (UInt32)(-1);
+    lenRes = 1;
+    return S_OK;
+  }
+  if (numAvailableBytes > kMatchMaxLen)
+    numAvailableBytes = kMatchMaxLen;
+
+  UInt32 reps[kNumRepDistances];
+  UInt32 repLens[kNumRepDistances];
+  UInt32 repMaxIndex = 0;
+  UInt32 i;
+  for(i = 0; i < kNumRepDistances; i++)
+  {
+    reps[i] = _repDistances[i];
+    UInt32 backOffset = reps[i] + 1;
+    if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+    {
+      repLens[i] = 0;
+      continue;
+    }
+    UInt32 lenTest;
+    for (lenTest = 2; lenTest < numAvailableBytes && 
+        data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+    repLens[i] = lenTest;
+    if (lenTest > repLens[repMaxIndex])
+      repMaxIndex = i;
+  }
+  if(repLens[repMaxIndex] >= _numFastBytes)
+  {
+    backRes = repMaxIndex;
+    lenRes = repLens[repMaxIndex];
+    return MovePos(lenRes - 1);
+  }
+
+  UInt32 *matchDistances = _matchDistances + 1;
+  if(lenMain >= _numFastBytes)
+  {
+    backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; 
+    lenRes = lenMain;
+    return MovePos(lenMain - 1);
+  }
+  Byte currentByte = *data;
+  Byte matchByte = data[(size_t)0 - reps[0] - 1];
+
+  if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
+  {
+    backRes = (UInt32)-1;
+    lenRes = 1;
+    return S_OK;
+  }
+
+  _optimum[0].State = _state;
+
+  UInt32 posState = (position & _posStateMask);
+
+  _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() + 
+      _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte);
+  _optimum[1].MakeAsChar();
+
+  UInt32 matchPrice = _isMatch[_state.Index][posState].GetPrice1();
+  UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1();
+
+  if(matchByte == currentByte)
+  {
+    UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState);
+    if(shortRepPrice < _optimum[1].Price)
+    {
+      _optimum[1].Price = shortRepPrice;
+      _optimum[1].MakeAsShortRep();
+    }
+  }
+  UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);
+
+  if(lenEnd < 2)
+  {
+    backRes = _optimum[1].BackPrev;
+    lenRes = 1;
+    return S_OK;
+  }
+
+  _optimum[1].PosPrev = 0;
+  for (i = 0; i < kNumRepDistances; i++)
+    _optimum[0].Backs[i] = reps[i];
+
+  UInt32 len = lenEnd;
+  do
+    _optimum[len--].Price = kIfinityPrice;
+  while (len >= 2);
+
+  for(i = 0; i < kNumRepDistances; i++)
+  {
+    UInt32 repLen = repLens[i];
+    if (repLen < 2)
+      continue;
+    UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState);
+    do
+    {
+      UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState);
+      COptimal &optimum = _optimum[repLen];
+      if (curAndLenPrice < optimum.Price) 
+      {
+        optimum.Price = curAndLenPrice;
+        optimum.PosPrev = 0;
+        optimum.BackPrev = i;
+        optimum.Prev1IsChar = false;
+      }
+    }
+    while(--repLen >= 2);
+  }
+
+  UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0();
+
+  len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
+  if (len <= lenMain)
+  {
+    UInt32 offs = 0;
+    while (len > matchDistances[offs])
+      offs += 2;
+    for(; ; len++)
+    {
+      UInt32 distance = matchDistances[offs + 1];
+      UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);
+      COptimal &optimum = _optimum[len];
+      if (curAndLenPrice < optimum.Price) 
+      {
+        optimum.Price = curAndLenPrice;
+        optimum.PosPrev = 0;
+        optimum.BackPrev = distance + kNumRepDistances;
+        optimum.Prev1IsChar = false;
+      }
+      if (len == matchDistances[offs])
+      {
+        offs += 2;
+        if (offs == numDistancePairs)
+          break;
+      }
+    }
+  }
+
+  UInt32 cur = 0;
+
+  while(true)
+  {
+    cur++;
+    if(cur == lenEnd)
+    {
+      lenRes = Backward(backRes, cur);
+      return S_OK;
+    }
+    UInt32 newLen, numDistancePairs;
+    RINOK(ReadMatchDistances(newLen, numDistancePairs));
+    if(newLen >= _numFastBytes)
+    {
+      _numDistancePairs = numDistancePairs;
+      _longestMatchLength = newLen;
+      _longestMatchWasFound = true;
+      lenRes = Backward(backRes, cur);
+      return S_OK;
+    }
+    position++;
+    COptimal &curOptimum = _optimum[cur];
+    UInt32 posPrev = curOptimum.PosPrev;
+    CState state;
+    if (curOptimum.Prev1IsChar)
+    {
+      posPrev--;
+      if (curOptimum.Prev2)
+      {
+        state = _optimum[curOptimum.PosPrev2].State;
+        if (curOptimum.BackPrev2 < kNumRepDistances)
+          state.UpdateRep();
+        else
+          state.UpdateMatch();
+      }
+      else
+        state = _optimum[posPrev].State;
+      state.UpdateChar();
+    }
+    else
+      state = _optimum[posPrev].State;
+    if (posPrev == cur - 1)
+    {
+      if (curOptimum.IsShortRep())
+        state.UpdateShortRep();
+      else
+        state.UpdateChar();
+    }
+    else
+    {
+      UInt32 pos;
+      if (curOptimum.Prev1IsChar && curOptimum.Prev2)
+      {
+        posPrev = curOptimum.PosPrev2;
+        pos = curOptimum.BackPrev2;
+        state.UpdateRep();
+      }
+      else
+      {
+        pos = curOptimum.BackPrev;
+        if (pos < kNumRepDistances)
+          state.UpdateRep();
+        else
+          state.UpdateMatch();
+      }
+      const COptimal &prevOptimum = _optimum[posPrev];
+      if (pos < kNumRepDistances)
+      {
+        reps[0] = prevOptimum.Backs[pos];
+               UInt32 i;
+        for(i = 1; i <= pos; i++)
+          reps[i] = prevOptimum.Backs[i - 1];
+        for(; i < kNumRepDistances; i++)
+          reps[i] = prevOptimum.Backs[i];
+      }
+      else
+      {
+        reps[0] = (pos - kNumRepDistances);
+        for(UInt32 i = 1; i < kNumRepDistances; i++)
+          reps[i] = prevOptimum.Backs[i - 1];
+      }
+    }
+    curOptimum.State = state;
+    for(UInt32 i = 0; i < kNumRepDistances; i++)
+      curOptimum.Backs[i] = reps[i];
+    UInt32 curPrice = curOptimum.Price; 
+    const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
+    const Byte currentByte = *data;
+    const Byte matchByte = data[(size_t)0 - reps[0] - 1];
+
+    UInt32 posState = (position & _posStateMask);
+
+    UInt32 curAnd1Price = curPrice +
+        _isMatch[state.Index][posState].GetPrice0() +
+        _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
+
+    COptimal &nextOptimum = _optimum[cur + 1];
+
+    bool nextIsChar = false;
+    if (curAnd1Price < nextOptimum.Price) 
+    {
+      nextOptimum.Price = curAnd1Price;
+      nextOptimum.PosPrev = cur;
+      nextOptimum.MakeAsChar();
+      nextIsChar = true;
+    }
+
+    UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1();
+    UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1();
+    
+    if(matchByte == currentByte &&
+        !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0))
+    {
+      UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);
+      if(shortRepPrice <= nextOptimum.Price)
+      {
+        nextOptimum.Price = shortRepPrice;
+        nextOptimum.PosPrev = cur;
+        nextOptimum.MakeAsShortRep();
+        nextIsChar = true;
+      }
+    }
+    /*
+    if(newLen == 2 && matchDistances[2] >= kDistLimit2) // test it maybe set 2000 ?
+      continue;
+    */
+
+    UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
+    numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
+    UInt32 numAvailableBytes = numAvailableBytesFull;
+
+    if (numAvailableBytes < 2)
+      continue;
+    if (numAvailableBytes > _numFastBytes)
+      numAvailableBytes = _numFastBytes;
+    if (!nextIsChar && matchByte != currentByte) // speed optimization
+    {
+      // try Literal + rep0
+      UInt32 backOffset = reps[0] + 1;
+      UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
+      UInt32 temp;
+      for (temp = 1; temp < limit && 
+          data[temp] == data[(size_t)temp - backOffset]; temp++);
+      UInt32 lenTest2 = temp - 1;
+      if (lenTest2 >= 2)
+      {
+        CState state2 = state;
+        state2.UpdateChar();
+        UInt32 posStateNext = (position + 1) & _posStateMask;
+        UInt32 nextRepMatchPrice = curAnd1Price + 
+            _isMatch[state2.Index][posStateNext].GetPrice1() +
+            _isRep[state2.Index].GetPrice1();
+        // for (; lenTest2 >= 2; lenTest2--)
+        {
+          UInt32 offset = cur + 1 + lenTest2;
+          while(lenEnd < offset)
+            _optimum[++lenEnd].Price = kIfinityPrice;
+          UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
+              0, lenTest2, state2, posStateNext);
+          COptimal &optimum = _optimum[offset];
+          if (curAndLenPrice < optimum.Price) 
+          {
+            optimum.Price = curAndLenPrice;
+            optimum.PosPrev = cur + 1;
+            optimum.BackPrev = 0;
+            optimum.Prev1IsChar = true;
+            optimum.Prev2 = false;
+          }
+        }
+      }
+    }
+    
+    UInt32 startLen = 2; // speed optimization 
+    for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
+    {
+      // UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
+      UInt32 backOffset = reps[repIndex] + 1;
+      if (data[0] != data[(size_t)0 - backOffset] ||
+          data[1] != data[(size_t)1 - backOffset])
+        continue;
+      UInt32 lenTest;
+      for (lenTest = 2; lenTest < numAvailableBytes && 
+          data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+      while(lenEnd < cur + lenTest)
+        _optimum[++lenEnd].Price = kIfinityPrice;
+      UInt32 lenTestTemp = lenTest;
+      UInt32 price = repMatchPrice + GetPureRepPrice(repIndex, state, posState);
+      do
+      {
+        UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState);
+        COptimal &optimum = _optimum[cur + lenTest];
+        if (curAndLenPrice < optimum.Price) 
+        {
+          optimum.Price = curAndLenPrice;
+          optimum.PosPrev = cur;
+          optimum.BackPrev = repIndex;
+          optimum.Prev1IsChar = false;
+        }
+      }
+      while(--lenTest >= 2);
+      lenTest = lenTestTemp;
+      
+      if (repIndex == 0)
+        startLen = lenTest + 1;
+        
+      // if (_maxMode)
+        {
+          UInt32 lenTest2 = lenTest + 1;
+          UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+          for (; lenTest2 < limit && 
+              data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+          lenTest2 -= lenTest + 1;
+          if (lenTest2 >= 2)
+          {
+            CState state2 = state;
+            state2.UpdateRep();
+            UInt32 posStateNext = (position + lenTest) & _posStateMask;
+            UInt32 curAndLenCharPrice = 
+                price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) + 
+                _isMatch[state2.Index][posStateNext].GetPrice0() +
+                _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
+                true, data[(size_t)lenTest - backOffset], data[lenTest]);
+            state2.UpdateChar();
+            posStateNext = (position + lenTest + 1) & _posStateMask;
+            UInt32 nextRepMatchPrice = curAndLenCharPrice + 
+                _isMatch[state2.Index][posStateNext].GetPrice1() +
+                _isRep[state2.Index].GetPrice1();
+            
+            // for(; lenTest2 >= 2; lenTest2--)
+            {
+              UInt32 offset = cur + lenTest + 1 + lenTest2;
+              while(lenEnd < offset)
+                _optimum[++lenEnd].Price = kIfinityPrice;
+              UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
+                  0, lenTest2, state2, posStateNext);
+              COptimal &optimum = _optimum[offset];
+              if (curAndLenPrice < optimum.Price) 
+              {
+                optimum.Price = curAndLenPrice;
+                optimum.PosPrev = cur + lenTest + 1;
+                optimum.BackPrev = 0;
+                optimum.Prev1IsChar = true;
+                optimum.Prev2 = true;
+                optimum.PosPrev2 = cur;
+                optimum.BackPrev2 = repIndex;
+              }
+            }
+          }
+        }
+      }
+    
+    //    for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
+    if (newLen > numAvailableBytes)
+    {
+      newLen = numAvailableBytes;
+      for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);
+      matchDistances[numDistancePairs] = newLen;
+      numDistancePairs += 2;
+    }
+    if (newLen >= startLen)
+    {
+      UInt32 normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0();
+      while(lenEnd < cur + newLen)
+        _optimum[++lenEnd].Price = kIfinityPrice;
+
+      UInt32 offs = 0;
+      while(startLen > matchDistances[offs])
+        offs += 2;
+      UInt32 curBack = matchDistances[offs + 1];
+      UInt32 posSlot = GetPosSlot2(curBack);
+      for(UInt32 lenTest = /*2*/ startLen; ; lenTest++)
+      {
+        UInt32 curAndLenPrice = normalMatchPrice;
+        UInt32 lenToPosState = GetLenToPosState(lenTest);
+        if (curBack < kNumFullDistances)
+          curAndLenPrice += _distancesPrices[lenToPosState][curBack];
+        else
+          curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask];
+  
+        curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState);
+        
+        COptimal &optimum = _optimum[cur + lenTest];
+        if (curAndLenPrice < optimum.Price) 
+        {
+          optimum.Price = curAndLenPrice;
+          optimum.PosPrev = cur;
+          optimum.BackPrev = curBack + kNumRepDistances;
+          optimum.Prev1IsChar = false;
+        }
+
+        if (/*_maxMode && */lenTest == matchDistances[offs])
+        {
+          // Try Match + Literal + Rep0
+          UInt32 backOffset = curBack + 1;
+          UInt32 lenTest2 = lenTest + 1;
+          UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+          for (; lenTest2 < limit && 
+              data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+          lenTest2 -= lenTest + 1;
+          if (lenTest2 >= 2)
+          {
+            CState state2 = state;
+            state2.UpdateMatch();
+            UInt32 posStateNext = (position + lenTest) & _posStateMask;
+            UInt32 curAndLenCharPrice = curAndLenPrice + 
+                _isMatch[state2.Index][posStateNext].GetPrice0() +
+                _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice( 
+                true, data[(size_t)lenTest - backOffset], data[lenTest]);
+            state2.UpdateChar();
+            posStateNext = (posStateNext + 1) & _posStateMask;
+            UInt32 nextRepMatchPrice = curAndLenCharPrice + 
+                _isMatch[state2.Index][posStateNext].GetPrice1() +
+                _isRep[state2.Index].GetPrice1();
+            
+            // for(; lenTest2 >= 2; lenTest2--)
+            {
+              UInt32 offset = cur + lenTest + 1 + lenTest2;
+              while(lenEnd < offset)
+                _optimum[++lenEnd].Price = kIfinityPrice;
+              UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);
+              COptimal &optimum = _optimum[offset];
+              if (curAndLenPrice < optimum.Price) 
+              {
+                optimum.Price = curAndLenPrice;
+                optimum.PosPrev = cur + lenTest + 1;
+                optimum.BackPrev = 0;
+                optimum.Prev1IsChar = true;
+                optimum.Prev2 = true;
+                optimum.PosPrev2 = cur;
+                optimum.BackPrev2 = curBack + kNumRepDistances;
+              }
+            }
+          }
+          offs += 2;
+          if (offs == numDistancePairs)
+            break;
+          curBack = matchDistances[offs + 1];
+          if (curBack >= kNumFullDistances)
+            posSlot = GetPosSlot2(curBack);
+        }
+      }
+    }
+  }
+}
+
+static inline bool ChangePair(UInt32 smallDist, UInt32 bigDist)
+{
+  return ((bigDist >> 7) > smallDist);
+}
+
+
+HRESULT CEncoder::ReadMatchDistances(UInt32 &lenRes, UInt32 &numDistancePairs)
+{
+  lenRes = 0;
+  RINOK(_matchFinder->GetMatches(_matchDistances));
+  numDistancePairs = _matchDistances[0];
+  if (numDistancePairs > 0)
+  {
+    lenRes = _matchDistances[1 + numDistancePairs - 2];
+    if (lenRes == _numFastBytes)
+      lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1], 
+          kMatchMaxLen - lenRes);
+  }
+  _additionalOffset++;
+  return S_OK;
+}
+
+HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
+{
+  UInt32 lenMain, numDistancePairs;
+  if (!_longestMatchWasFound)
+  {
+    RINOK(ReadMatchDistances(lenMain, numDistancePairs));
+  }
+  else
+  {
+    lenMain = _longestMatchLength;
+    numDistancePairs = _numDistancePairs;
+    _longestMatchWasFound = false;
+  }
+
+  const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
+  UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
+  if (numAvailableBytes > kMatchMaxLen)
+    numAvailableBytes = kMatchMaxLen;
+  if (numAvailableBytes < 2)
+  {
+    backRes = (UInt32)(-1);
+    lenRes = 1;
+    return S_OK;
+  }
+
+  UInt32 repLens[kNumRepDistances];
+  UInt32 repMaxIndex = 0;
+
+  for(UInt32 i = 0; i < kNumRepDistances; i++)
+  {
+    UInt32 backOffset = _repDistances[i] + 1;
+    if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+    {
+      repLens[i] = 0;
+      continue;
+    }
+    UInt32 len;
+    for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+    if(len >= _numFastBytes)
+    {
+      backRes = i;
+      lenRes = len;
+      return MovePos(lenRes - 1);
+    }
+    repLens[i] = len;
+    if (len > repLens[repMaxIndex])
+      repMaxIndex = i;
+  }
+  UInt32 *matchDistances = _matchDistances + 1;
+  if(lenMain >= _numFastBytes)
+  {
+    backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; 
+    lenRes = lenMain;
+    return MovePos(lenMain - 1);
+  }
+
+  UInt32 backMain = 0;
+  if (lenMain >= 2)
+  {
+    backMain = matchDistances[numDistancePairs - 1];
+    while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)
+    {
+      if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))
+        break;
+      numDistancePairs -= 2;
+      lenMain = matchDistances[numDistancePairs - 2];
+      backMain = matchDistances[numDistancePairs - 1];
+    }
+    if (lenMain == 2 && backMain >= 0x80)
+      lenMain = 1;
+  }
+
+  if (repLens[repMaxIndex] >= 2)
+  {
+    if (repLens[repMaxIndex] + 1 >= lenMain || 
+        repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9)) ||
+        repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15)))
+    {
+      backRes = repMaxIndex;
+      lenRes = repLens[repMaxIndex];
+      return MovePos(lenRes - 1);
+    }
+  }
+  
+  if (lenMain >= 2 && numAvailableBytes > 2)
+  {
+    RINOK(ReadMatchDistances(_longestMatchLength, _numDistancePairs));
+    if (_longestMatchLength >= 2)
+    {
+      UInt32 newDistance = matchDistances[_numDistancePairs - 1];
+      if (_longestMatchLength >= lenMain && newDistance < backMain || 
+          _longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance) ||
+          _longestMatchLength > lenMain + 1 ||
+          _longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain))
+      {
+        _longestMatchWasFound = true;
+        backRes = UInt32(-1);
+        lenRes = 1;
+        return S_OK;
+      }
+    }
+    data++;
+    numAvailableBytes--;
+    for(UInt32 i = 0; i < kNumRepDistances; i++)
+    {
+      UInt32 backOffset = _repDistances[i] + 1;
+      if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])
+      {
+        repLens[i] = 0;
+        continue;
+      }
+      UInt32 len;
+      for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+      if (len + 1 >= lenMain)
+      {
+        _longestMatchWasFound = true;
+        backRes = UInt32(-1);
+        lenRes = 1;
+        return S_OK;
+      }
+    }
+    backRes = backMain + kNumRepDistances; 
+    lenRes = lenMain;
+    return MovePos(lenMain - 2);
+  }
+  backRes = UInt32(-1);
+  lenRes = 1;
+  return S_OK;
+}
+
+HRESULT CEncoder::Flush(UInt32 nowPos)
+{
+  ReleaseMFStream();
+  WriteEndMarker(nowPos & _posStateMask);
+  _rangeEncoder.FlushData();
+  return _rangeEncoder.FlushStream();
+}
+
+void CEncoder::WriteEndMarker(UInt32 posState)
+{
+  // This function for writing End Mark for stream version of LZMA. 
+  // In current version this feature is not used.
+  if (!_writeEndMark)
+    return;
+
+  _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
+  _isRep[_state.Index].Encode(&_rangeEncoder, 0);
+  _state.UpdateMatch();
+  UInt32 len = kMatchMinLen; // kMatchMaxLen;
+  _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+  UInt32 posSlot = (1 << kNumPosSlotBits)  - 1;
+  UInt32 lenToPosState = GetLenToPosState(len);
+  _posSlotEncoder[lenToPosState].Encode(&_rangeEncoder, posSlot);
+  UInt32 footerBits = 30;
+  UInt32 posReduced = (UInt32(1) << footerBits) - 1;
+  _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+  _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
+}
+
+HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream, 
+      const UInt64 *inSize, const UInt64 *outSize,
+      ICompressProgressInfo *progress)
+{
+  _needReleaseMFStream = false;
+  CCoderReleaser coderReleaser(this);
+  RINOK(SetStreams(inStream, outStream, inSize, outSize));
+  while(true)
+  {
+    UInt64 processedInSize;
+    UInt64 processedOutSize;
+    Int32 finished;
+    RINOK(CodeOneBlock(&processedInSize, &processedOutSize, &finished));
+    if (finished != 0)
+      return S_OK;
+    if (progress != 0)
+    {
+      RINOK(progress->SetRatioInfo(&processedInSize, &processedOutSize));
+    }
+  }
+}
+
+HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream, 
+      const UInt64 *inSize, const UInt64 *outSize)
+{
+  _inStream = inStream;
+  _finished = false;
+  RINOK(Create());
+  RINOK(SetOutStream(outStream));
+  RINOK(Init());
+  
+  // CCoderReleaser releaser(this);
+
+  /*
+  if (_matchFinder->GetNumAvailableBytes() == 0)
+    return Flush();
+  */
+
+  if (!_fastMode)
+  {
+    FillDistancesPrices();
+    FillAlignPrices();
+  }
+
+  _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
+  _lenEncoder.UpdateTables(1 << _posStateBits);
+  _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
+  _repMatchLenEncoder.UpdateTables(1 << _posStateBits);
+
+  nowPos64 = 0;
+  return S_OK;
+}
+
+HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished)
+{
+  if (_inStream != 0)
+  {
+    RINOK(_matchFinder->SetStream(_inStream));
+    RINOK(_matchFinder->Init());
+    _needReleaseMFStream = true;
+    _inStream = 0;
+  }
+
+
+  *finished = 1;
+  if (_finished)
+    return S_OK;
+  _finished = true;
+
+  if (nowPos64 == 0)
+  {
+    if (_matchFinder->GetNumAvailableBytes() == 0)
+      return Flush(UInt32(nowPos64));
+    UInt32 len, numDistancePairs;
+    RINOK(ReadMatchDistances(len, numDistancePairs));
+    UInt32 posState = UInt32(nowPos64) & _posStateMask;
+    _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
+    _state.UpdateChar();
+    Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
+    _literalEncoder.GetSubCoder(UInt32(nowPos64), _previousByte)->Encode(&_rangeEncoder, curByte);
+    _previousByte = curByte;
+    _additionalOffset--;
+    nowPos64++;
+  }
+
+  UInt32 nowPos32 = (UInt32)nowPos64;
+  UInt32 progressPosValuePrev = nowPos32;
+
+  if (_matchFinder->GetNumAvailableBytes() == 0)
+    return Flush(nowPos32);
+
+  while(true)
+  {
+    #ifdef _NO_EXCEPTIONS
+    if (_rangeEncoder.Stream.ErrorCode != S_OK)
+      return _rangeEncoder.Stream.ErrorCode;
+    #endif
+    UInt32 pos, len;
+    HRESULT result;
+    if (_fastMode)
+      result = GetOptimumFast(nowPos32, pos, len);
+    else
+      result = GetOptimum(nowPos32, pos, len);
+    RINOK(result);
+
+    UInt32 posState = nowPos32 & _posStateMask;
+    if(len == 1 && pos == 0xFFFFFFFF)
+    {
+      _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
+      Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
+      CLiteralEncoder2 *subCoder = _literalEncoder.GetSubCoder(nowPos32, _previousByte);
+      if(_state.IsCharState())
+        subCoder->Encode(&_rangeEncoder, curByte);
+      else
+      {
+        Byte matchByte = _matchFinder->GetIndexByte(0 - _repDistances[0] - 1 - _additionalOffset);
+        subCoder->EncodeMatched(&_rangeEncoder, matchByte, curByte);
+      }
+      _state.UpdateChar();
+      _previousByte = curByte;
+    }
+    else
+    {
+      _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
+      if(pos < kNumRepDistances)
+      {
+        _isRep[_state.Index].Encode(&_rangeEncoder, 1);
+        if(pos == 0)
+        {
+          _isRepG0[_state.Index].Encode(&_rangeEncoder, 0);
+          _isRep0Long[_state.Index][posState].Encode(&_rangeEncoder, ((len == 1) ? 0 : 1));
+        }
+        else
+        {
+          UInt32 distance = _repDistances[pos];
+          _isRepG0[_state.Index].Encode(&_rangeEncoder, 1);
+          if (pos == 1)
+            _isRepG1[_state.Index].Encode(&_rangeEncoder, 0);
+          else
+          {
+            _isRepG1[_state.Index].Encode(&_rangeEncoder, 1);
+            _isRepG2[_state.Index].Encode(&_rangeEncoder, pos - 2);
+            if (pos == 3)
+              _repDistances[3] = _repDistances[2];
+            _repDistances[2] = _repDistances[1];
+          }
+          _repDistances[1] = _repDistances[0];
+          _repDistances[0] = distance;
+        }
+        if (len == 1)
+          _state.UpdateShortRep();
+        else
+        {
+          _repMatchLenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+          _state.UpdateRep();
+        }
+      }
+      else
+      {
+        _isRep[_state.Index].Encode(&_rangeEncoder, 0);
+        _state.UpdateMatch();
+        _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+        pos -= kNumRepDistances;
+        UInt32 posSlot = GetPosSlot(pos);
+        _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot);
+        
+        if (posSlot >= kStartPosModelIndex)
+        {
+          UInt32 footerBits = ((posSlot >> 1) - 1);
+          UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+          UInt32 posReduced = pos - base;
+
+          if (posSlot < kEndPosModelIndex)
+            NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1, 
+                &_rangeEncoder, footerBits, posReduced);
+          else
+          {
+            _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+            _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
+            _alignPriceCount++;
+          }
+        }
+        _repDistances[3] = _repDistances[2];
+        _repDistances[2] = _repDistances[1];
+        _repDistances[1] = _repDistances[0];
+        _repDistances[0] = pos;
+        _matchPriceCount++;
+      }
+      _previousByte = _matchFinder->GetIndexByte(len - 1 - _additionalOffset);
+    }
+    _additionalOffset -= len;
+    nowPos32 += len;
+    if (_additionalOffset == 0)
+    {
+      if (!_fastMode)
+      {
+        if (_matchPriceCount >= (1 << 7))
+          FillDistancesPrices();
+        if (_alignPriceCount >= kAlignTableSize)
+          FillAlignPrices();
+      }
+      if (_matchFinder->GetNumAvailableBytes() == 0)
+        return Flush(nowPos32);
+      if (nowPos32 - progressPosValuePrev >= (1 << 14))
+      {
+        nowPos64 += nowPos32 - progressPosValuePrev;
+        *inSize = nowPos64;
+        *outSize = _rangeEncoder.GetProcessedSize();
+        _finished = false;
+        *finished = 0;
+        return S_OK;
+      }
+    }
+  }
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
+    ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+    ICompressProgressInfo *progress)
+{
+  #ifndef _NO_EXCEPTIONS
+  try 
+  { 
+  #endif
+    return CodeReal(inStream, outStream, inSize, outSize, progress); 
+  #ifndef _NO_EXCEPTIONS
+  }
+  catch(const COutBufferException &e) { return e.ErrorCode; }
+  catch(...) { return E_FAIL; }
+  #endif
+}
+  
+void CEncoder::FillDistancesPrices()
+{
+  UInt32 tempPrices[kNumFullDistances];
+  for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++)
+  { 
+    UInt32 posSlot = GetPosSlot(i);
+    UInt32 footerBits = ((posSlot >> 1) - 1);
+    UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+    tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders + 
+      base - posSlot - 1, footerBits, i - base);
+  }
+
+  for (UInt32 lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
+  {
+         UInt32 posSlot;
+    NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> &encoder = _posSlotEncoder[lenToPosState];
+    UInt32 *posSlotPrices = _posSlotPrices[lenToPosState];
+    for (posSlot = 0; posSlot < _distTableSize; posSlot++)
+      posSlotPrices[posSlot] = encoder.GetPrice(posSlot);
+    for (posSlot = kEndPosModelIndex; posSlot < _distTableSize; posSlot++)
+      posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << NRangeCoder::kNumBitPriceShiftBits);
+
+    UInt32 *distancesPrices = _distancesPrices[lenToPosState];
+         UInt32 i;
+    for (i = 0; i < kStartPosModelIndex; i++)
+      distancesPrices[i] = posSlotPrices[i];
+    for (; i < kNumFullDistances; i++)
+      distancesPrices[i] = posSlotPrices[GetPosSlot(i)] + tempPrices[i];
+  }
+  _matchPriceCount = 0;
+}
+
+void CEncoder::FillAlignPrices()
+{
+  for (UInt32 i = 0; i < kAlignTableSize; i++)
+    _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i);
+  _alignPriceCount = 0;
+}
+
+}}
index 55ac80c07c2421174b8120eb117c9c7ab53c7442..f4c2c1513169a5f5047365032b96d2b55c189a52 100644 (file)
-// LZMA/Encoder.h\r
-\r
-#ifndef __LZMA_ENCODER_H\r
-#define __LZMA_ENCODER_H\r
-\r
-#include "../../../Common/MyCom.h"\r
-#include "../../../Common/Alloc.h"\r
-#include "../../ICoder.h"\r
-#include "../LZ/IMatchFinder.h"\r
-#include "../RangeCoder/RangeCoderBitTree.h"\r
-\r
-#include "LZMA.h"\r
-\r
-namespace NCompress {\r
-namespace NLZMA {\r
-\r
-typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;\r
-\r
-class CBaseState\r
-{\r
-protected:\r
-  CState _state;\r
-  Byte _previousByte;\r
-  UInt32 _repDistances[kNumRepDistances];\r
-  void Init()\r
-  {\r
-    _state.Init();\r
-    _previousByte = 0;\r
-    for(UInt32 i = 0 ; i < kNumRepDistances; i++)\r
-      _repDistances[i] = 0;\r
-  }\r
-};\r
-\r
-struct COptimal\r
-{\r
-  CState State;\r
-\r
-  bool Prev1IsChar;\r
-  bool Prev2;\r
-\r
-  UInt32 PosPrev2;\r
-  UInt32 BackPrev2;     \r
-\r
-  UInt32 Price;    \r
-  UInt32 PosPrev;         // posNext;\r
-  UInt32 BackPrev;     \r
-  UInt32 Backs[kNumRepDistances];\r
-  void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }\r
-  void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }\r
-  bool IsShortRep() { return (BackPrev == 0); }\r
-};\r
-\r
-\r
-extern Byte g_FastPos[1 << 11];\r
-inline UInt32 GetPosSlot(UInt32 pos)\r
-{\r
-  if (pos < (1 << 11))\r
-    return g_FastPos[pos];\r
-  if (pos < (1 << 21))\r
-    return g_FastPos[pos >> 10] + 20;\r
-  return g_FastPos[pos >> 20] + 40;\r
-}\r
-\r
-inline UInt32 GetPosSlot2(UInt32 pos)\r
-{\r
-  if (pos < (1 << 17))\r
-    return g_FastPos[pos >> 6] + 12;\r
-  if (pos < (1 << 27))\r
-    return g_FastPos[pos >> 16] + 32;\r
-  return g_FastPos[pos >> 26] + 52;\r
-}\r
-\r
-const UInt32 kIfinityPrice = 0xFFFFFFF;\r
-\r
-const UInt32 kNumOpts = 1 << 12;\r
-\r
-\r
-class CLiteralEncoder2\r
-{\r
-  CMyBitEncoder _encoders[0x300];\r
-public:\r
-  void Init()\r
-  {\r
-    for (int i = 0; i < 0x300; i++)\r
-      _encoders[i].Init();\r
-  }\r
-  void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);\r
-  void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);\r
-  UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;\r
-};\r
-\r
-class CLiteralEncoder\r
-{\r
-  CLiteralEncoder2 *_coders;\r
-  int _numPrevBits;\r
-  int _numPosBits;\r
-  UInt32 _posMask;\r
-public:\r
-  CLiteralEncoder(): _coders(0) {}\r
-  ~CLiteralEncoder()  { Free(); }\r
-  void Free()\r
-  { \r
-    MyFree(_coders);\r
-    _coders = 0;\r
-  }\r
-  bool Create(int numPosBits, int numPrevBits)\r
-  {\r
-    if (_coders == 0 || (numPosBits + numPrevBits) != (_numPrevBits + _numPosBits))\r
-    {\r
-      Free();\r
-      UInt32 numStates = 1 << (numPosBits + numPrevBits);\r
-      _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));\r
-    }\r
-    _numPosBits = numPosBits;\r
-    _posMask = (1 << numPosBits) - 1;\r
-    _numPrevBits = numPrevBits;\r
-    return (_coders != 0);\r
-  }\r
-  void Init()\r
-  {\r
-    UInt32 numStates = 1 << (_numPrevBits + _numPosBits);\r
-    for (UInt32 i = 0; i < numStates; i++)\r
-      _coders[i].Init();\r
-  }\r
-  CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)\r
-    { return &_coders[((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits))]; }\r
-};\r
-\r
-namespace NLength {\r
-\r
-class CEncoder\r
-{\r
-  CMyBitEncoder _choice;\r
-  CMyBitEncoder _choice2;\r
-  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesEncodingMax];\r
-  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesEncodingMax];\r
-  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits> _highCoder;\r
-public:\r
-  void Init(UInt32 numPosStates);\r
-  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);\r
-  void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const;\r
-};\r
-\r
-const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;\r
-\r
-class CPriceTableEncoder: public CEncoder\r
-{\r
-  UInt32 _prices[kNumPosStatesEncodingMax][kNumSymbolsTotal];\r
-  UInt32 _tableSize;\r
-  UInt32 _counters[kNumPosStatesEncodingMax];\r
-public:\r
-  void SetTableSize(UInt32 tableSize) { _tableSize = tableSize;  }\r
-  UInt32 GetPrice(UInt32 symbol, UInt32 posState) const { return _prices[posState][symbol]; }\r
-  void UpdateTable(UInt32 posState)\r
-  {\r
-    SetPrices(posState, _tableSize, _prices[posState]);\r
-    _counters[posState] = _tableSize;\r
-  }\r
-  void UpdateTables(UInt32 numPosStates)\r
-  {\r
-    for (UInt32 posState = 0; posState < numPosStates; posState++)\r
-      UpdateTable(posState);\r
-  }\r
-  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState, bool updatePrice)\r
-  {\r
-    CEncoder::Encode(rangeEncoder, symbol, posState);\r
-    if (updatePrice)\r
-      if (--_counters[posState] == 0)\r
-        UpdateTable(posState);\r
-  }\r
-};\r
-\r
-}\r
-\r
-class CEncoder : \r
-  public ICompressCoder,\r
-  public ICompressSetOutStream,\r
-  public ICompressSetCoderProperties,\r
-  public ICompressWriteCoderProperties,\r
-  public CBaseState,\r
-  public CMyUnknownImp\r
-{\r
-  COptimal _optimum[kNumOpts];\r
-  CMyComPtr<IMatchFinder> _matchFinder; // test it\r
-  NRangeCoder::CEncoder _rangeEncoder;\r
-\r
-  CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];\r
-  CMyBitEncoder _isRep[kNumStates];\r
-  CMyBitEncoder _isRepG0[kNumStates];\r
-  CMyBitEncoder _isRepG1[kNumStates];\r
-  CMyBitEncoder _isRepG2[kNumStates];\r
-  CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];\r
-\r
-  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];\r
-\r
-  CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];\r
-  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;\r
-  \r
-  NLength::CPriceTableEncoder _lenEncoder;\r
-  NLength::CPriceTableEncoder _repMatchLenEncoder;\r
-\r
-  CLiteralEncoder _literalEncoder;\r
-\r
-  UInt32 _matchDistances[kMatchMaxLen * 2 + 2 + 1];\r
-\r
-  bool _fastMode;\r
-  // bool _maxMode;\r
-  UInt32 _numFastBytes;\r
-  UInt32 _longestMatchLength;    \r
-  UInt32 _numDistancePairs;\r
-\r
-  UInt32 _additionalOffset;\r
-\r
-  UInt32 _optimumEndIndex;\r
-  UInt32 _optimumCurrentIndex;\r
-\r
-  bool _longestMatchWasFound;\r
-\r
-  UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];\r
-  \r
-  UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];\r
-\r
-  UInt32 _alignPrices[kAlignTableSize];\r
-  UInt32 _alignPriceCount;\r
-\r
-  UInt32 _distTableSize;\r
-\r
-  UInt32 _posStateBits;\r
-  UInt32 _posStateMask;\r
-  UInt32 _numLiteralPosStateBits;\r
-  UInt32 _numLiteralContextBits;\r
-\r
-  UInt32 _dictionarySize;\r
-\r
-  UInt32 _dictionarySizePrev;\r
-  UInt32 _numFastBytesPrev;\r
-\r
-  UInt32 _matchPriceCount;\r
-  UInt64 nowPos64;\r
-  bool _finished;\r
-  ISequentialInStream *_inStream;\r
-\r
-  UInt32 _matchFinderCycles;\r
-  int _matchFinderIndex;\r
-  #ifdef COMPRESS_MF_MT\r
-  bool _multiThread;\r
-  #endif\r
-\r
-  bool _writeEndMark;\r
-\r
-  bool _needReleaseMFStream;\r
-\r
-  IMatchFinderSetNumPasses *setMfPasses;\r
-\r
-  void ReleaseMatchFinder()\r
-  {\r
-    setMfPasses = 0;\r
-    _matchFinder.Release();\r
-  }\r
-  \r
-  HRESULT ReadMatchDistances(UInt32 &len, UInt32 &numDistancePairs);\r
-\r
-  HRESULT MovePos(UInt32 num);\r
-  UInt32 GetRepLen1Price(CState state, UInt32 posState) const\r
-  {\r
-    return _isRepG0[state.Index].GetPrice0() +\r
-        _isRep0Long[state.Index][posState].GetPrice0();\r
-  }\r
-  \r
-  UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const\r
-  {\r
-    UInt32 price;\r
-    if(repIndex == 0)\r
-    {\r
-      price = _isRepG0[state.Index].GetPrice0();\r
-      price += _isRep0Long[state.Index][posState].GetPrice1();\r
-    }\r
-    else\r
-    {\r
-      price = _isRepG0[state.Index].GetPrice1();\r
-      if (repIndex == 1)\r
-        price += _isRepG1[state.Index].GetPrice0();\r
-      else\r
-      {\r
-        price += _isRepG1[state.Index].GetPrice1();\r
-        price += _isRepG2[state.Index].GetPrice(repIndex - 2);\r
-      }\r
-    }\r
-    return price;\r
-  }\r
-  UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const\r
-  {\r
-    return _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState) +\r
-        GetPureRepPrice(repIndex, state, posState);\r
-  }\r
-  /*\r
-  UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const\r
-  {\r
-    if (pos >= kNumFullDistances)\r
-      return kIfinityPrice;\r
-    return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);\r
-  }\r
-  UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const\r
-  {\r
-    UInt32 price;\r
-    UInt32 lenToPosState = GetLenToPosState(len);\r
-    if (pos < kNumFullDistances)\r
-      price = _distancesPrices[lenToPosState][pos];\r
-    else\r
-      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + \r
-          _alignPrices[pos & kAlignMask];\r
-    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);\r
-  }\r
-  */\r
-  UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const\r
-  {\r
-    UInt32 price;\r
-    UInt32 lenToPosState = GetLenToPosState(len);\r
-    if (pos < kNumFullDistances)\r
-      price = _distancesPrices[lenToPosState][pos];\r
-    else\r
-      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + \r
-          _alignPrices[pos & kAlignMask];\r
-    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);\r
-  }\r
-\r
-  UInt32 Backward(UInt32 &backRes, UInt32 cur);\r
-  HRESULT GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes);\r
-  HRESULT GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes);\r
-\r
-  void FillDistancesPrices();\r
-  void FillAlignPrices();\r
-    \r
-  void ReleaseMFStream()\r
-  {\r
-    if (_matchFinder && _needReleaseMFStream)\r
-    {\r
-      _matchFinder->ReleaseStream();\r
-      _needReleaseMFStream = false;\r
-    }\r
-  }\r
-\r
-  void ReleaseStreams()\r
-  {\r
-    ReleaseMFStream();\r
-    ReleaseOutStream();\r
-  }\r
-\r
-  HRESULT Flush(UInt32 nowPos);\r
-  class CCoderReleaser\r
-  {\r
-    CEncoder *_coder;\r
-  public:\r
-    CCoderReleaser(CEncoder *coder): _coder(coder) {}\r
-    ~CCoderReleaser()\r
-    {\r
-      _coder->ReleaseStreams();\r
-    }\r
-  };\r
-  friend class CCoderReleaser;\r
-\r
-  void WriteEndMarker(UInt32 posState);\r
-\r
-public:\r
-  CEncoder();\r
-  void SetWriteEndMarkerMode(bool writeEndMarker)\r
-    { _writeEndMark= writeEndMarker; }\r
-\r
-  HRESULT Create();\r
-\r
-  MY_UNKNOWN_IMP3(\r
-      ICompressSetOutStream,\r
-      ICompressSetCoderProperties,\r
-      ICompressWriteCoderProperties\r
-      )\r
-    \r
-  HRESULT Init();\r
-  \r
-  // ICompressCoder interface\r
-  HRESULT SetStreams(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream,\r
-      const UInt64 *inSize, const UInt64 *outSize);\r
-  HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);\r
-\r
-  HRESULT CodeReal(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream, \r
-      const UInt64 *inSize, const UInt64 *outSize,\r
-      ICompressProgressInfo *progress);\r
-\r
-  // ICompressCoder interface\r
-  STDMETHOD(Code)(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream, \r
-      const UInt64 *inSize, const UInt64 *outSize,\r
-      ICompressProgressInfo *progress);\r
-\r
-  // ICompressSetCoderProperties2\r
-  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, \r
-      const PROPVARIANT *properties, UInt32 numProperties);\r
-  \r
-  // ICompressWriteCoderProperties\r
-  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);\r
-\r
-  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);\r
-  STDMETHOD(ReleaseOutStream)();\r
-\r
-  virtual ~CEncoder() {}\r
-};\r
-\r
-}}\r
-\r
-#endif\r
+// LZMA/Encoder.h
+
+#ifndef __LZMA_ENCODER_H
+#define __LZMA_ENCODER_H
+
+#include "../../../Common/MyCom.h"
+#include "../../../Common/Alloc.h"
+#include "../../ICoder.h"
+#include "../LZ/IMatchFinder.h"
+#include "../RangeCoder/RangeCoderBitTree.h"
+
+#include "LZMA.h"
+
+namespace NCompress {
+namespace NLZMA {
+
+typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;
+
+class CBaseState
+{
+protected:
+  CState _state;
+  Byte _previousByte;
+  UInt32 _repDistances[kNumRepDistances];
+  void Init()
+  {
+    _state.Init();
+    _previousByte = 0;
+    for(UInt32 i = 0 ; i < kNumRepDistances; i++)
+      _repDistances[i] = 0;
+  }
+};
+
+struct COptimal
+{
+  CState State;
+
+  bool Prev1IsChar;
+  bool Prev2;
+
+  UInt32 PosPrev2;
+  UInt32 BackPrev2;     
+
+  UInt32 Price;    
+  UInt32 PosPrev;         // posNext;
+  UInt32 BackPrev;     
+  UInt32 Backs[kNumRepDistances];
+  void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }
+  void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }
+  bool IsShortRep() { return (BackPrev == 0); }
+};
+
+
+extern Byte g_FastPos[1 << 11];
+inline UInt32 GetPosSlot(UInt32 pos)
+{
+  if (pos < (1 << 11))
+    return g_FastPos[pos];
+  if (pos < (1 << 21))
+    return g_FastPos[pos >> 10] + 20;
+  return g_FastPos[pos >> 20] + 40;
+}
+
+inline UInt32 GetPosSlot2(UInt32 pos)
+{
+  if (pos < (1 << 17))
+    return g_FastPos[pos >> 6] + 12;
+  if (pos < (1 << 27))
+    return g_FastPos[pos >> 16] + 32;
+  return g_FastPos[pos >> 26] + 52;
+}
+
+const UInt32 kIfinityPrice = 0xFFFFFFF;
+
+const UInt32 kNumOpts = 1 << 12;
+
+
+class CLiteralEncoder2
+{
+  CMyBitEncoder _encoders[0x300];
+public:
+  void Init()
+  {
+    for (int i = 0; i < 0x300; i++)
+      _encoders[i].Init();
+  }
+  void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);
+  void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);
+  UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;
+};
+
+class CLiteralEncoder
+{
+  CLiteralEncoder2 *_coders;
+  int _numPrevBits;
+  int _numPosBits;
+  UInt32 _posMask;
+public:
+  CLiteralEncoder(): _coders(0) {}
+  ~CLiteralEncoder()  { Free(); }
+  void Free()
+  { 
+    MyFree(_coders);
+    _coders = 0;
+  }
+  bool Create(int numPosBits, int numPrevBits)
+  {
+    if (_coders == 0 || (numPosBits + numPrevBits) != (_numPrevBits + _numPosBits))
+    {
+      Free();
+      UInt32 numStates = 1 << (numPosBits + numPrevBits);
+      _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));
+    }
+    _numPosBits = numPosBits;
+    _posMask = (1 << numPosBits) - 1;
+    _numPrevBits = numPrevBits;
+    return (_coders != 0);
+  }
+  void Init()
+  {
+    UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
+    for (UInt32 i = 0; i < numStates; i++)
+      _coders[i].Init();
+  }
+  CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)
+    { return &_coders[((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits))]; }
+};
+
+namespace NLength {
+
+class CEncoder
+{
+  CMyBitEncoder _choice;
+  CMyBitEncoder _choice2;
+  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesEncodingMax];
+  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesEncodingMax];
+  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits> _highCoder;
+public:
+  void Init(UInt32 numPosStates);
+  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);
+  void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const;
+};
+
+const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;
+
+class CPriceTableEncoder: public CEncoder
+{
+  UInt32 _prices[kNumPosStatesEncodingMax][kNumSymbolsTotal];
+  UInt32 _tableSize;
+  UInt32 _counters[kNumPosStatesEncodingMax];
+public:
+  void SetTableSize(UInt32 tableSize) { _tableSize = tableSize;  }
+  UInt32 GetPrice(UInt32 symbol, UInt32 posState) const { return _prices[posState][symbol]; }
+  void UpdateTable(UInt32 posState)
+  {
+    SetPrices(posState, _tableSize, _prices[posState]);
+    _counters[posState] = _tableSize;
+  }
+  void UpdateTables(UInt32 numPosStates)
+  {
+    for (UInt32 posState = 0; posState < numPosStates; posState++)
+      UpdateTable(posState);
+  }
+  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState, bool updatePrice)
+  {
+    CEncoder::Encode(rangeEncoder, symbol, posState);
+    if (updatePrice)
+      if (--_counters[posState] == 0)
+        UpdateTable(posState);
+  }
+};
+
+}
+
+class CEncoder : 
+  public ICompressCoder,
+  public ICompressSetOutStream,
+  public ICompressSetCoderProperties,
+  public ICompressWriteCoderProperties,
+  public CBaseState,
+  public CMyUnknownImp
+{
+  COptimal _optimum[kNumOpts];
+  CMyComPtr<IMatchFinder> _matchFinder; // test it
+  NRangeCoder::CEncoder _rangeEncoder;
+
+  CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];
+  CMyBitEncoder _isRep[kNumStates];
+  CMyBitEncoder _isRepG0[kNumStates];
+  CMyBitEncoder _isRepG1[kNumStates];
+  CMyBitEncoder _isRepG2[kNumStates];
+  CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];
+
+  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];
+
+  CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];
+  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;
+  
+  NLength::CPriceTableEncoder _lenEncoder;
+  NLength::CPriceTableEncoder _repMatchLenEncoder;
+
+  CLiteralEncoder _literalEncoder;
+
+  UInt32 _matchDistances[kMatchMaxLen * 2 + 2 + 1];
+
+  bool _fastMode;
+  // bool _maxMode;
+  UInt32 _numFastBytes;
+  UInt32 _longestMatchLength;    
+  UInt32 _numDistancePairs;
+
+  UInt32 _additionalOffset;
+
+  UInt32 _optimumEndIndex;
+  UInt32 _optimumCurrentIndex;
+
+  bool _longestMatchWasFound;
+
+  UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
+  
+  UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];
+
+  UInt32 _alignPrices[kAlignTableSize];
+  UInt32 _alignPriceCount;
+
+  UInt32 _distTableSize;
+
+  UInt32 _posStateBits;
+  UInt32 _posStateMask;
+  UInt32 _numLiteralPosStateBits;
+  UInt32 _numLiteralContextBits;
+
+  UInt32 _dictionarySize;
+
+  UInt32 _dictionarySizePrev;
+  UInt32 _numFastBytesPrev;
+
+  UInt32 _matchPriceCount;
+  UInt64 nowPos64;
+  bool _finished;
+  ISequentialInStream *_inStream;
+
+  UInt32 _matchFinderCycles;
+  int _matchFinderIndex;
+  #ifdef COMPRESS_MF_MT
+  bool _multiThread;
+  #endif
+
+  bool _writeEndMark;
+
+  bool _needReleaseMFStream;
+
+  IMatchFinderSetNumPasses *setMfPasses;
+
+  void ReleaseMatchFinder()
+  {
+    setMfPasses = 0;
+    _matchFinder.Release();
+  }
+  
+  HRESULT ReadMatchDistances(UInt32 &len, UInt32 &numDistancePairs);
+
+  HRESULT MovePos(UInt32 num);
+  UInt32 GetRepLen1Price(CState state, UInt32 posState) const
+  {
+    return _isRepG0[state.Index].GetPrice0() +
+        _isRep0Long[state.Index][posState].GetPrice0();
+  }
+  
+  UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const
+  {
+    UInt32 price;
+    if(repIndex == 0)
+    {
+      price = _isRepG0[state.Index].GetPrice0();
+      price += _isRep0Long[state.Index][posState].GetPrice1();
+    }
+    else
+    {
+      price = _isRepG0[state.Index].GetPrice1();
+      if (repIndex == 1)
+        price += _isRepG1[state.Index].GetPrice0();
+      else
+      {
+        price += _isRepG1[state.Index].GetPrice1();
+        price += _isRepG2[state.Index].GetPrice(repIndex - 2);
+      }
+    }
+    return price;
+  }
+  UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const
+  {
+    return _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState) +
+        GetPureRepPrice(repIndex, state, posState);
+  }
+  /*
+  UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const
+  {
+    if (pos >= kNumFullDistances)
+      return kIfinityPrice;
+    return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);
+  }
+  UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const
+  {
+    UInt32 price;
+    UInt32 lenToPosState = GetLenToPosState(len);
+    if (pos < kNumFullDistances)
+      price = _distancesPrices[lenToPosState][pos];
+    else
+      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + 
+          _alignPrices[pos & kAlignMask];
+    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
+  }
+  */
+  UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const
+  {
+    UInt32 price;
+    UInt32 lenToPosState = GetLenToPosState(len);
+    if (pos < kNumFullDistances)
+      price = _distancesPrices[lenToPosState][pos];
+    else
+      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + 
+          _alignPrices[pos & kAlignMask];
+    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
+  }
+
+  UInt32 Backward(UInt32 &backRes, UInt32 cur);
+  HRESULT GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
+  HRESULT GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
+
+  void FillDistancesPrices();
+  void FillAlignPrices();
+    
+  void ReleaseMFStream()
+  {
+    if (_matchFinder && _needReleaseMFStream)
+    {
+      _matchFinder->ReleaseStream();
+      _needReleaseMFStream = false;
+    }
+  }
+
+  void ReleaseStreams()
+  {
+    ReleaseMFStream();
+    ReleaseOutStream();
+  }
+
+  HRESULT Flush(UInt32 nowPos);
+  class CCoderReleaser
+  {
+    CEncoder *_coder;
+  public:
+    CCoderReleaser(CEncoder *coder): _coder(coder) {}
+    ~CCoderReleaser()
+    {
+      _coder->ReleaseStreams();
+    }
+  };
+  friend class CCoderReleaser;
+
+  void WriteEndMarker(UInt32 posState);
+
+public:
+  CEncoder();
+  void SetWriteEndMarkerMode(bool writeEndMarker)
+    { _writeEndMark= writeEndMarker; }
+
+  HRESULT Create();
+
+  MY_UNKNOWN_IMP3(
+      ICompressSetOutStream,
+      ICompressSetCoderProperties,
+      ICompressWriteCoderProperties
+      )
+    
+  HRESULT Init();
+  
+  // ICompressCoder interface
+  HRESULT SetStreams(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream,
+      const UInt64 *inSize, const UInt64 *outSize);
+  HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);
+
+  HRESULT CodeReal(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream, 
+      const UInt64 *inSize, const UInt64 *outSize,
+      ICompressProgressInfo *progress);
+
+  // ICompressCoder interface
+  STDMETHOD(Code)(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream, 
+      const UInt64 *inSize, const UInt64 *outSize,
+      ICompressProgressInfo *progress);
+
+  // ICompressSetCoderProperties2
+  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, 
+      const PROPVARIANT *properties, UInt32 numProperties);
+  
+  // ICompressWriteCoderProperties
+  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+
+  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
+  STDMETHOD(ReleaseOutStream)();
+
+  virtual ~CEncoder() {}
+};
+
+}}
+
+#endif
index 83fdd22d58666dcd424320f059cd1074bc63ad80..e7fb6986d2a6de6bea13904aa686790a14b257fb 100644 (file)
@@ -1,8 +1,8 @@
-// StdAfx.h\r
-\r
-#ifndef __STDAFX_H\r
-#define __STDAFX_H\r
-\r
-#include "../../../Common/MyWindows.h"\r
-\r
-#endif\r
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../../Common/MyWindows.h"
+
+#endif
index 9828bc4b94845ddee5ff2e5e9ffda4e3f02ad54a..bbb2ba82d3c14bc54d0960ec69f53e8feb7af1ca 100644 (file)
-// Compress/RangeCoder/RangeCoder.h\r
-\r
-#ifndef __COMPRESS_RANGECODER_H\r
-#define __COMPRESS_RANGECODER_H\r
-\r
-#include "../../Common/InBuffer.h"\r
-#include "../../Common/OutBuffer.h"\r
-\r
-namespace NCompress {\r
-namespace NRangeCoder {\r
-\r
-const int kNumTopBits = 24;\r
-const UInt32 kTopValue = (1 << kNumTopBits);\r
-\r
-class CEncoder\r
-{\r
-  UInt32 _cacheSize;\r
-  Byte _cache;\r
-public:\r
-  UInt64 Low;\r
-  UInt32 Range;\r
-  COutBuffer Stream;\r
-  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }\r
-\r
-  void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }\r
-  void Init()\r
-  {\r
-    Stream.Init();\r
-    Low = 0;\r
-    Range = 0xFFFFFFFF;\r
-    _cacheSize = 1;\r
-    _cache = 0;\r
-  }\r
-\r
-  void FlushData()\r
-  {\r
-    // Low += 1; \r
-    for(int i = 0; i < 5; i++)\r
-      ShiftLow();\r
-  }\r
-\r
-  HRESULT FlushStream() { return Stream.Flush();  }\r
-\r
-  void ReleaseStream() { Stream.ReleaseStream(); }\r
-\r
-  void Encode(UInt32 start, UInt32 size, UInt32 total)\r
-  {\r
-    Low += start * (Range /= total);\r
-    Range *= size;\r
-    while (Range < kTopValue)\r
-    {\r
-      Range <<= 8;\r
-      ShiftLow();\r
-    }\r
-  }\r
-\r
-  void ShiftLow()\r
-  {\r
-    if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0) \r
-    {\r
-      Byte temp = _cache;\r
-      do\r
-      {\r
-        Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));\r
-        temp = 0xFF;\r
-      }\r
-      while(--_cacheSize != 0);\r
-      _cache = (Byte)((UInt32)Low >> 24);                      \r
-    } \r
-    _cacheSize++;                               \r
-    Low = (UInt32)Low << 8;                           \r
-  }\r
-  \r
-  void EncodeDirectBits(UInt32 value, int numTotalBits)\r
-  {\r
-    for (int i = numTotalBits - 1; i >= 0; i--)\r
-    {\r
-      Range >>= 1;\r
-      if (((value >> i) & 1) == 1)\r
-        Low += Range;\r
-      if (Range < kTopValue)\r
-      {\r
-        Range <<= 8;\r
-        ShiftLow();\r
-      }\r
-    }\r
-  }\r
-\r
-  void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)\r
-  {\r
-    UInt32 newBound = (Range >> numTotalBits) * size0;\r
-    if (symbol == 0)\r
-      Range = newBound;\r
-    else\r
-    {\r
-      Low += newBound;\r
-      Range -= newBound;\r
-    }\r
-    while (Range < kTopValue)\r
-    {\r
-      Range <<= 8;\r
-      ShiftLow();\r
-    }\r
-  }\r
-\r
-  UInt64 GetProcessedSize() {  return Stream.GetProcessedSize() + _cacheSize + 4; }\r
-};\r
-\r
-class CDecoder\r
-{\r
-public:\r
-  CInBuffer Stream;\r
-  UInt32 Range;\r
-  UInt32 Code;\r
-  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }\r
-\r
-  void Normalize()\r
-  {\r
-    while (Range < kTopValue)\r
-    {\r
-      Code = (Code << 8) | Stream.ReadByte();\r
-      Range <<= 8;\r
-    }\r
-  }\r
-  \r
-  void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }\r
-  void Init()\r
-  {\r
-    Stream.Init();\r
-    Code = 0;\r
-    Range = 0xFFFFFFFF;\r
-    for(int i = 0; i < 5; i++)\r
-      Code = (Code << 8) | Stream.ReadByte();\r
-  }\r
-\r
-  void ReleaseStream() { Stream.ReleaseStream(); }\r
-\r
-  UInt32 GetThreshold(UInt32 total)\r
-  {\r
-    return (Code) / ( Range /= total);\r
-  }\r
-\r
-  void Decode(UInt32 start, UInt32 size)\r
-  {\r
-    Code -= start * Range;\r
-    Range *= size;\r
-    Normalize();\r
-  }\r
-\r
-  UInt32 DecodeDirectBits(int numTotalBits)\r
-  {\r
-    UInt32 range = Range;\r
-    UInt32 code = Code;        \r
-    UInt32 result = 0;\r
-    for (int i = numTotalBits; i != 0; i--)\r
-    {\r
-      range >>= 1;\r
-      /*\r
-      result <<= 1;\r
-      if (code >= range)\r
-      {\r
-        code -= range;\r
-        result |= 1;\r
-      }\r
-      */\r
-      UInt32 t = (code - range) >> 31;\r
-      code -= range & (t - 1);\r
-      result = (result << 1) | (1 - t);\r
-\r
-      if (range < kTopValue)\r
-      {\r
-        code = (code << 8) | Stream.ReadByte();\r
-        range <<= 8; \r
-      }\r
-    }\r
-    Range = range;\r
-    Code = code;\r
-    return result;\r
-  }\r
-\r
-  UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)\r
-  {\r
-    UInt32 newBound = (Range >> numTotalBits) * size0;\r
-    UInt32 symbol;\r
-    if (Code < newBound)\r
-    {\r
-      symbol = 0;\r
-      Range = newBound;\r
-    }\r
-    else\r
-    {\r
-      symbol = 1;\r
-      Code -= newBound;\r
-      Range -= newBound;\r
-    }\r
-    Normalize();\r
-    return symbol;\r
-  }\r
-\r
-  UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }\r
-};\r
-\r
-}}\r
-\r
-#endif\r
+// Compress/RangeCoder/RangeCoder.h
+
+#ifndef __COMPRESS_RANGECODER_H
+#define __COMPRESS_RANGECODER_H
+
+#include "../../Common/InBuffer.h"
+#include "../../Common/OutBuffer.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+const int kNumTopBits = 24;
+const UInt32 kTopValue = (1 << kNumTopBits);
+
+class CEncoder
+{
+  UInt32 _cacheSize;
+  Byte _cache;
+public:
+  UInt64 Low;
+  UInt32 Range;
+  COutBuffer Stream;
+  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+
+  void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
+  void Init()
+  {
+    Stream.Init();
+    Low = 0;
+    Range = 0xFFFFFFFF;
+    _cacheSize = 1;
+    _cache = 0;
+  }
+
+  void FlushData()
+  {
+    // Low += 1; 
+    for(int i = 0; i < 5; i++)
+      ShiftLow();
+  }
+
+  HRESULT FlushStream() { return Stream.Flush();  }
+
+  void ReleaseStream() { Stream.ReleaseStream(); }
+
+  void Encode(UInt32 start, UInt32 size, UInt32 total)
+  {
+    Low += start * (Range /= total);
+    Range *= size;
+    while (Range < kTopValue)
+    {
+      Range <<= 8;
+      ShiftLow();
+    }
+  }
+
+  void ShiftLow()
+  {
+    if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0) 
+    {
+      Byte temp = _cache;
+      do
+      {
+        Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
+        temp = 0xFF;
+      }
+      while(--_cacheSize != 0);
+      _cache = (Byte)((UInt32)Low >> 24);                      
+    } 
+    _cacheSize++;                               
+    Low = (UInt32)Low << 8;                           
+  }
+  
+  void EncodeDirectBits(UInt32 value, int numTotalBits)
+  {
+    for (int i = numTotalBits - 1; i >= 0; i--)
+    {
+      Range >>= 1;
+      if (((value >> i) & 1) == 1)
+        Low += Range;
+      if (Range < kTopValue)
+      {
+        Range <<= 8;
+        ShiftLow();
+      }
+    }
+  }
+
+  void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)
+  {
+    UInt32 newBound = (Range >> numTotalBits) * size0;
+    if (symbol == 0)
+      Range = newBound;
+    else
+    {
+      Low += newBound;
+      Range -= newBound;
+    }
+    while (Range < kTopValue)
+    {
+      Range <<= 8;
+      ShiftLow();
+    }
+  }
+
+  UInt64 GetProcessedSize() {  return Stream.GetProcessedSize() + _cacheSize + 4; }
+};
+
+class CDecoder
+{
+public:
+  CInBuffer Stream;
+  UInt32 Range;
+  UInt32 Code;
+  bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+
+  void Normalize()
+  {
+    while (Range < kTopValue)
+    {
+      Code = (Code << 8) | Stream.ReadByte();
+      Range <<= 8;
+    }
+  }
+  
+  void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
+  void Init()
+  {
+    Stream.Init();
+    Code = 0;
+    Range = 0xFFFFFFFF;
+    for(int i = 0; i < 5; i++)
+      Code = (Code << 8) | Stream.ReadByte();
+  }
+
+  void ReleaseStream() { Stream.ReleaseStream(); }
+
+  UInt32 GetThreshold(UInt32 total)
+  {
+    return (Code) / ( Range /= total);
+  }
+
+  void Decode(UInt32 start, UInt32 size)
+  {
+    Code -= start * Range;
+    Range *= size;
+    Normalize();
+  }
+
+  UInt32 DecodeDirectBits(int numTotalBits)
+  {
+    UInt32 range = Range;
+    UInt32 code = Code;        
+    UInt32 result = 0;
+    for (int i = numTotalBits; i != 0; i--)
+    {
+      range >>= 1;
+      /*
+      result <<= 1;
+      if (code >= range)
+      {
+        code -= range;
+        result |= 1;
+      }
+      */
+      UInt32 t = (code - range) >> 31;
+      code -= range & (t - 1);
+      result = (result << 1) | (1 - t);
+
+      if (range < kTopValue)
+      {
+        code = (code << 8) | Stream.ReadByte();
+        range <<= 8; 
+      }
+    }
+    Range = range;
+    Code = code;
+    return result;
+  }
+
+  UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
+  {
+    UInt32 newBound = (Range >> numTotalBits) * size0;
+    UInt32 symbol;
+    if (Code < newBound)
+    {
+      symbol = 0;
+      Range = newBound;
+    }
+    else
+    {
+      symbol = 1;
+      Code -= newBound;
+      Range -= newBound;
+    }
+    Normalize();
+    return symbol;
+  }
+
+  UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
+};
+
+}}
+
+#endif
index 8d273c8f9353e01441c79509f5fc84dbdd7c5eaf..8e4c4d3a9ef5c4c6f581788bf0eb08d5bf1e8152 100644 (file)
@@ -1,80 +1,80 @@
-// Compress/RangeCoder/RangeCoderBit.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "RangeCoderBit.h"\r
-\r
-namespace NCompress {\r
-namespace NRangeCoder {\r
-\r
-UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
-static CPriceTables g_PriceTables;\r
-\r
-CPriceTables::CPriceTables() { Init(); }\r
-\r
-void CPriceTables::Init()\r
-{\r
-  const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits);\r
-  for(int i = kNumBits - 1; i >= 0; i--)\r
-  {\r
-    UInt32 start = 1 << (kNumBits - i - 1);\r
-    UInt32 end = 1 << (kNumBits - i);\r
-    for (UInt32 j = start; j < end; j++)\r
-      ProbPrices[j] = (i << kNumBitPriceShiftBits) + \r
-          (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1));\r
-  }\r
-\r
-  /*\r
-  // simplest: bad solution\r
-  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)\r
-    ProbPrices[i] = kBitPrice;\r
-  */\r
-  \r
-  /*\r
-  const double kDummyMultMid = (1.0 / kBitPrice) / 2;\r
-  const double kDummyMultMid = 0;\r
-  // float solution\r
-  double ln2 = log(double(2));\r
-  double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits));\r
-  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)\r
-    ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice);\r
-  */\r
-  \r
-  /*\r
-  // experimental, slow, solution:\r
-  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)\r
-  {\r
-    const int kCyclesBits = 5;\r
-    const UInt32 kCycles = (1 << kCyclesBits);\r
-\r
-    UInt32 range = UInt32(-1);\r
-    UInt32 bitCount = 0;\r
-    for (UInt32 j = 0; j < kCycles; j++)\r
-    {\r
-      range >>= (kNumBitModelTotalBits - kNumMoveReducingBits);\r
-      range *= i;\r
-      while(range < (1 << 31))\r
-      {\r
-        range <<= 1;\r
-        bitCount++;\r
-      }\r
-    }\r
-    bitCount <<= kNumBitPriceShiftBits;\r
-    range -= (1 << 31);\r
-    for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--)\r
-    {\r
-      range <<= 1;\r
-      if (range > (1 << 31))\r
-      {\r
-        bitCount += (1 << k);\r
-        range -= (1 << 31);\r
-      }\r
-    }\r
-    ProbPrices[i] = (bitCount \r
-      // + (1 << (kCyclesBits - 1))\r
-      ) >> kCyclesBits;\r
-  }\r
-  */\r
-}\r
-\r
-}}\r
+// Compress/RangeCoder/RangeCoderBit.cpp
+
+#include "StdAfx.h"
+
+#include "RangeCoderBit.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+static CPriceTables g_PriceTables;
+
+CPriceTables::CPriceTables() { Init(); }
+
+void CPriceTables::Init()
+{
+  const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits);
+  for(int i = kNumBits - 1; i >= 0; i--)
+  {
+    UInt32 start = 1 << (kNumBits - i - 1);
+    UInt32 end = 1 << (kNumBits - i);
+    for (UInt32 j = start; j < end; j++)
+      ProbPrices[j] = (i << kNumBitPriceShiftBits) + 
+          (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1));
+  }
+
+  /*
+  // simplest: bad solution
+  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
+    ProbPrices[i] = kBitPrice;
+  */
+  
+  /*
+  const double kDummyMultMid = (1.0 / kBitPrice) / 2;
+  const double kDummyMultMid = 0;
+  // float solution
+  double ln2 = log(double(2));
+  double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits));
+  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
+    ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice);
+  */
+  
+  /*
+  // experimental, slow, solution:
+  for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
+  {
+    const int kCyclesBits = 5;
+    const UInt32 kCycles = (1 << kCyclesBits);
+
+    UInt32 range = UInt32(-1);
+    UInt32 bitCount = 0;
+    for (UInt32 j = 0; j < kCycles; j++)
+    {
+      range >>= (kNumBitModelTotalBits - kNumMoveReducingBits);
+      range *= i;
+      while(range < (1 << 31))
+      {
+        range <<= 1;
+        bitCount++;
+      }
+    }
+    bitCount <<= kNumBitPriceShiftBits;
+    range -= (1 << 31);
+    for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--)
+    {
+      range <<= 1;
+      if (range > (1 << 31))
+      {
+        bitCount += (1 << k);
+        range -= (1 << 31);
+      }
+    }
+    ProbPrices[i] = (bitCount 
+      // + (1 << (kCyclesBits - 1))
+      ) >> kCyclesBits;
+  }
+  */
+}
+
+}}
index 64538e687948f1b8e50ab975636cac9460335609..624f887c946ab4877359e96498487533088d08c0 100644 (file)
-// Compress/RangeCoder/RangeCoderBit.h\r
-\r
-#ifndef __COMPRESS_RANGECODER_BIT_H\r
-#define __COMPRESS_RANGECODER_BIT_H\r
-\r
-#include "RangeCoder.h"\r
-\r
-namespace NCompress {\r
-namespace NRangeCoder {\r
-\r
-const int kNumBitModelTotalBits  = 11;\r
-const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);\r
-\r
-const int kNumMoveReducingBits = 2;\r
-\r
-const int kNumBitPriceShiftBits = 6;\r
-const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;\r
-\r
-class CPriceTables\r
-{\r
-public:\r
-  static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
-  static void Init();\r
-  CPriceTables();\r
-};\r
-\r
-template <int numMoveBits>\r
-class CBitModel\r
-{\r
-public:\r
-  UInt32 Prob;\r
-  void UpdateModel(UInt32 symbol)\r
-  {\r
-    /*\r
-    Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;\r
-    Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);\r
-    */\r
-    if (symbol == 0)\r
-      Prob += (kBitModelTotal - Prob) >> numMoveBits;\r
-    else\r
-      Prob -= (Prob) >> numMoveBits;\r
-  }\r
-public:\r
-  void Init() { Prob = kBitModelTotal / 2; }\r
-};\r
-\r
-template <int numMoveBits>\r
-class CBitEncoder: public CBitModel<numMoveBits>\r
-{\r
-public:\r
-  void Encode(CEncoder *encoder, UInt32 symbol)\r
-  {\r
-    /*\r
-    encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);\r
-    this->UpdateModel(symbol);\r
-    */\r
-    UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;\r
-    if (symbol == 0)\r
-    {\r
-      encoder->Range = newBound;\r
-      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;\r
-    }\r
-    else\r
-    {\r
-      encoder->Low += newBound;\r
-      encoder->Range -= newBound;\r
-      this->Prob -= (this->Prob) >> numMoveBits;\r
-    }\r
-    if (encoder->Range < kTopValue)\r
-    {\r
-      encoder->Range <<= 8;\r
-      encoder->ShiftLow();\r
-    }\r
-  }\r
-  UInt32 GetPrice(UInt32 symbol) const\r
-  {\r
-    return CPriceTables::ProbPrices[\r
-      (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];\r
-  }\r
-  UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }\r
-  UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }\r
-};\r
-\r
-\r
-template <int numMoveBits>\r
-class CBitDecoder: public CBitModel<numMoveBits>\r
-{\r
-public:\r
-  UInt32 Decode(CDecoder *decoder)\r
-  {\r
-    UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;\r
-    if (decoder->Code < newBound)\r
-    {\r
-      decoder->Range = newBound;\r
-      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;\r
-      if (decoder->Range < kTopValue)\r
-      {\r
-        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();\r
-        decoder->Range <<= 8;\r
-      }\r
-      return 0;\r
-    }\r
-    else\r
-    {\r
-      decoder->Range -= newBound;\r
-      decoder->Code -= newBound;\r
-      this->Prob -= (this->Prob) >> numMoveBits;\r
-      if (decoder->Range < kTopValue)\r
-      {\r
-        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();\r
-        decoder->Range <<= 8;\r
-      }\r
-      return 1;\r
-    }\r
-  }\r
-};\r
-\r
-}}\r
-\r
-#endif\r
+// Compress/RangeCoder/RangeCoderBit.h
+
+#ifndef __COMPRESS_RANGECODER_BIT_H
+#define __COMPRESS_RANGECODER_BIT_H
+
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+const int kNumBitModelTotalBits  = 11;
+const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
+
+const int kNumMoveReducingBits = 2;
+
+const int kNumBitPriceShiftBits = 6;
+const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
+
+class CPriceTables
+{
+public:
+  static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+  static void Init();
+  CPriceTables();
+};
+
+template <int numMoveBits>
+class CBitModel
+{
+public:
+  UInt32 Prob;
+  void UpdateModel(UInt32 symbol)
+  {
+    /*
+    Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
+    Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
+    */
+    if (symbol == 0)
+      Prob += (kBitModelTotal - Prob) >> numMoveBits;
+    else
+      Prob -= (Prob) >> numMoveBits;
+  }
+public:
+  void Init() { Prob = kBitModelTotal / 2; }
+};
+
+template <int numMoveBits>
+class CBitEncoder: public CBitModel<numMoveBits>
+{
+public:
+  void Encode(CEncoder *encoder, UInt32 symbol)
+  {
+    /*
+    encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
+    this->UpdateModel(symbol);
+    */
+    UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
+    if (symbol == 0)
+    {
+      encoder->Range = newBound;
+      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+    }
+    else
+    {
+      encoder->Low += newBound;
+      encoder->Range -= newBound;
+      this->Prob -= (this->Prob) >> numMoveBits;
+    }
+    if (encoder->Range < kTopValue)
+    {
+      encoder->Range <<= 8;
+      encoder->ShiftLow();
+    }
+  }
+  UInt32 GetPrice(UInt32 symbol) const
+  {
+    return CPriceTables::ProbPrices[
+      (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
+  }
+  UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }
+  UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }
+};
+
+
+template <int numMoveBits>
+class CBitDecoder: public CBitModel<numMoveBits>
+{
+public:
+  UInt32 Decode(CDecoder *decoder)
+  {
+    UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
+    if (decoder->Code < newBound)
+    {
+      decoder->Range = newBound;
+      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+      if (decoder->Range < kTopValue)
+      {
+        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+        decoder->Range <<= 8;
+      }
+      return 0;
+    }
+    else
+    {
+      decoder->Range -= newBound;
+      decoder->Code -= newBound;
+      this->Prob -= (this->Prob) >> numMoveBits;
+      if (decoder->Range < kTopValue)
+      {
+        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+        decoder->Range <<= 8;
+      }
+      return 1;
+    }
+  }
+};
+
+}}
+
+#endif
index 1fa023f3b8f5d539a3b57dc929079b3ed1e13143..4f0c78b49d8ee9dca4fbfbf5f29ed07bc9d19072 100644 (file)
-// Compress/RangeCoder/RangeCoderBitTree.h\r
-\r
-#ifndef __COMPRESS_RANGECODER_BIT_TREE_H\r
-#define __COMPRESS_RANGECODER_BIT_TREE_H\r
-\r
-#include "RangeCoderBit.h"\r
-#include "RangeCoderOpt.h"\r
-\r
-namespace NCompress {\r
-namespace NRangeCoder {\r
-\r
-template <int numMoveBits, int NumBitLevels>\r
-class CBitTreeEncoder\r
-{\r
-  CBitEncoder<numMoveBits> Models[1 << NumBitLevels];\r
-public:\r
-  void Init()\r
-  {\r
-    for(UInt32 i = 1; i < (1 << NumBitLevels); i++)\r
-      Models[i].Init();\r
-  }\r
-  void Encode(CEncoder *rangeEncoder, UInt32 symbol)\r
-  {\r
-    UInt32 modelIndex = 1;\r
-    for (int bitIndex = NumBitLevels; bitIndex != 0 ;)\r
-    {\r
-      bitIndex--;\r
-      UInt32 bit = (symbol >> bitIndex) & 1;\r
-      Models[modelIndex].Encode(rangeEncoder, bit);\r
-      modelIndex = (modelIndex << 1) | bit;\r
-    }\r
-  };\r
-  void ReverseEncode(CEncoder *rangeEncoder, UInt32 symbol)\r
-  {\r
-    UInt32 modelIndex = 1;\r
-    for (int i = 0; i < NumBitLevels; i++)\r
-    {\r
-      UInt32 bit = symbol & 1;\r
-      Models[modelIndex].Encode(rangeEncoder, bit);\r
-      modelIndex = (modelIndex << 1) | bit;\r
-      symbol >>= 1;\r
-    }\r
-  }\r
-  UInt32 GetPrice(UInt32 symbol) const\r
-  {\r
-    symbol |= (1 << NumBitLevels);\r
-    UInt32 price = 0;\r
-    while (symbol != 1)\r
-    {\r
-      price += Models[symbol >> 1].GetPrice(symbol & 1);\r
-      symbol >>= 1;\r
-    }\r
-    return price;\r
-  }\r
-  UInt32 ReverseGetPrice(UInt32 symbol) const\r
-  {\r
-    UInt32 price = 0;\r
-    UInt32 modelIndex = 1;\r
-    for (int i = NumBitLevels; i != 0; i--)\r
-    {\r
-      UInt32 bit = symbol & 1;\r
-      symbol >>= 1;\r
-      price += Models[modelIndex].GetPrice(bit);\r
-      modelIndex = (modelIndex << 1) | bit;\r
-    }\r
-    return price;\r
-  }\r
-};\r
-\r
-template <int numMoveBits, int NumBitLevels>\r
-class CBitTreeDecoder\r
-{\r
-  CBitDecoder<numMoveBits> Models[1 << NumBitLevels];\r
-public:\r
-  void Init()\r
-  {\r
-    for(UInt32 i = 1; i < (1 << NumBitLevels); i++)\r
-      Models[i].Init();\r
-  }\r
-  UInt32 Decode(CDecoder *rangeDecoder)\r
-  {\r
-    UInt32 modelIndex = 1;\r
-    RC_INIT_VAR\r
-    for(int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)\r
-    {\r
-      // modelIndex = (modelIndex << 1) + Models[modelIndex].Decode(rangeDecoder);\r
-      RC_GETBIT(numMoveBits, Models[modelIndex].Prob, modelIndex)\r
-    }\r
-    RC_FLUSH_VAR\r
-    return modelIndex - (1 << NumBitLevels);\r
-  };\r
-  UInt32 ReverseDecode(CDecoder *rangeDecoder)\r
-  {\r
-    UInt32 modelIndex = 1;\r
-    UInt32 symbol = 0;\r
-    RC_INIT_VAR\r
-    for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)\r
-    {\r
-      // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);\r
-      // modelIndex <<= 1;\r
-      // modelIndex += bit;\r
-      // symbol |= (bit << bitIndex);\r
-      RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))\r
-    }\r
-    RC_FLUSH_VAR\r
-    return symbol;\r
-  }\r
-};\r
-\r
-template <int numMoveBits>\r
-void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models, \r
-    CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol)\r
-{\r
-  UInt32 modelIndex = 1;\r
-  for (int i = 0; i < NumBitLevels; i++)\r
-  {\r
-    UInt32 bit = symbol & 1;\r
-    Models[modelIndex].Encode(rangeEncoder, bit);\r
-    modelIndex = (modelIndex << 1) | bit;\r
-    symbol >>= 1;\r
-  }\r
-}\r
-\r
-template <int numMoveBits>\r
-UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models, \r
-    UInt32 NumBitLevels, UInt32 symbol)\r
-{\r
-  UInt32 price = 0;\r
-  UInt32 modelIndex = 1;\r
-  for (int i = NumBitLevels; i != 0; i--)\r
-  {\r
-    UInt32 bit = symbol & 1;\r
-    symbol >>= 1;\r
-    price += Models[modelIndex].GetPrice(bit);\r
-    modelIndex = (modelIndex << 1) | bit;\r
-  }\r
-  return price;\r
-}\r
-\r
-template <int numMoveBits>\r
-UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models, \r
-    CDecoder *rangeDecoder, int NumBitLevels)\r
-{\r
-  UInt32 modelIndex = 1;\r
-  UInt32 symbol = 0;\r
-  RC_INIT_VAR\r
-  for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)\r
-  {\r
-    // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);\r
-    // modelIndex <<= 1;\r
-    // modelIndex += bit;\r
-    // symbol |= (bit << bitIndex);\r
-    RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))\r
-  }\r
-  RC_FLUSH_VAR\r
-  return symbol;\r
-}\r
-\r
-}}\r
-\r
-#endif\r
+// Compress/RangeCoder/RangeCoderBitTree.h
+
+#ifndef __COMPRESS_RANGECODER_BIT_TREE_H
+#define __COMPRESS_RANGECODER_BIT_TREE_H
+
+#include "RangeCoderBit.h"
+#include "RangeCoderOpt.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+template <int numMoveBits, int NumBitLevels>
+class CBitTreeEncoder
+{
+  CBitEncoder<numMoveBits> Models[1 << NumBitLevels];
+public:
+  void Init()
+  {
+    for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
+      Models[i].Init();
+  }
+  void Encode(CEncoder *rangeEncoder, UInt32 symbol)
+  {
+    UInt32 modelIndex = 1;
+    for (int bitIndex = NumBitLevels; bitIndex != 0 ;)
+    {
+      bitIndex--;
+      UInt32 bit = (symbol >> bitIndex) & 1;
+      Models[modelIndex].Encode(rangeEncoder, bit);
+      modelIndex = (modelIndex << 1) | bit;
+    }
+  };
+  void ReverseEncode(CEncoder *rangeEncoder, UInt32 symbol)
+  {
+    UInt32 modelIndex = 1;
+    for (int i = 0; i < NumBitLevels; i++)
+    {
+      UInt32 bit = symbol & 1;
+      Models[modelIndex].Encode(rangeEncoder, bit);
+      modelIndex = (modelIndex << 1) | bit;
+      symbol >>= 1;
+    }
+  }
+  UInt32 GetPrice(UInt32 symbol) const
+  {
+    symbol |= (1 << NumBitLevels);
+    UInt32 price = 0;
+    while (symbol != 1)
+    {
+      price += Models[symbol >> 1].GetPrice(symbol & 1);
+      symbol >>= 1;
+    }
+    return price;
+  }
+  UInt32 ReverseGetPrice(UInt32 symbol) const
+  {
+    UInt32 price = 0;
+    UInt32 modelIndex = 1;
+    for (int i = NumBitLevels; i != 0; i--)
+    {
+      UInt32 bit = symbol & 1;
+      symbol >>= 1;
+      price += Models[modelIndex].GetPrice(bit);
+      modelIndex = (modelIndex << 1) | bit;
+    }
+    return price;
+  }
+};
+
+template <int numMoveBits, int NumBitLevels>
+class CBitTreeDecoder
+{
+  CBitDecoder<numMoveBits> Models[1 << NumBitLevels];
+public:
+  void Init()
+  {
+    for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
+      Models[i].Init();
+  }
+  UInt32 Decode(CDecoder *rangeDecoder)
+  {
+    UInt32 modelIndex = 1;
+    RC_INIT_VAR
+    for(int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)
+    {
+      // modelIndex = (modelIndex << 1) + Models[modelIndex].Decode(rangeDecoder);
+      RC_GETBIT(numMoveBits, Models[modelIndex].Prob, modelIndex)
+    }
+    RC_FLUSH_VAR
+    return modelIndex - (1 << NumBitLevels);
+  };
+  UInt32 ReverseDecode(CDecoder *rangeDecoder)
+  {
+    UInt32 modelIndex = 1;
+    UInt32 symbol = 0;
+    RC_INIT_VAR
+    for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
+    {
+      // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
+      // modelIndex <<= 1;
+      // modelIndex += bit;
+      // symbol |= (bit << bitIndex);
+      RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
+    }
+    RC_FLUSH_VAR
+    return symbol;
+  }
+};
+
+template <int numMoveBits>
+void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models, 
+    CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol)
+{
+  UInt32 modelIndex = 1;
+  for (int i = 0; i < NumBitLevels; i++)
+  {
+    UInt32 bit = symbol & 1;
+    Models[modelIndex].Encode(rangeEncoder, bit);
+    modelIndex = (modelIndex << 1) | bit;
+    symbol >>= 1;
+  }
+}
+
+template <int numMoveBits>
+UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models, 
+    UInt32 NumBitLevels, UInt32 symbol)
+{
+  UInt32 price = 0;
+  UInt32 modelIndex = 1;
+  for (int i = NumBitLevels; i != 0; i--)
+  {
+    UInt32 bit = symbol & 1;
+    symbol >>= 1;
+    price += Models[modelIndex].GetPrice(bit);
+    modelIndex = (modelIndex << 1) | bit;
+  }
+  return price;
+}
+
+template <int numMoveBits>
+UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models, 
+    CDecoder *rangeDecoder, int NumBitLevels)
+{
+  UInt32 modelIndex = 1;
+  UInt32 symbol = 0;
+  RC_INIT_VAR
+  for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
+  {
+    // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
+    // modelIndex <<= 1;
+    // modelIndex += bit;
+    // symbol |= (bit << bitIndex);
+    RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
+  }
+  RC_FLUSH_VAR
+  return symbol;
+}
+
+}}
+
+#endif
index 829fc83d77387d7789e0024a8889259986cffc3d..668b9a5b0aa055bba58b500dc9e9eed2acc47333 100644 (file)
@@ -1,31 +1,31 @@
-// Compress/RangeCoder/RangeCoderOpt.h\r
-\r
-#ifndef __COMPRESS_RANGECODER_OPT_H\r
-#define __COMPRESS_RANGECODER_OPT_H\r
-\r
-#define RC_INIT_VAR \\r
-  UInt32 range = rangeDecoder->Range; \\r
-  UInt32 code = rangeDecoder->Code;        \r
-\r
-#define RC_FLUSH_VAR \\r
-  rangeDecoder->Range = range; \\r
-  rangeDecoder->Code = code;\r
-\r
-#define RC_NORMALIZE \\r
-  if (range < NCompress::NRangeCoder::kTopValue) \\r
-    { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }\r
-\r
-#define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \\r
-  { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \\r
-  if (code < bound) \\r
-  { A0; range = bound; \\r
-    prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \\r
-    mi <<= 1; } \\r
-  else \\r
-  { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \\r
-    mi = (mi + mi) + 1; }} \\r
-  RC_NORMALIZE\r
-\r
-#define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)\r
-\r
-#endif\r
+// Compress/RangeCoder/RangeCoderOpt.h
+
+#ifndef __COMPRESS_RANGECODER_OPT_H
+#define __COMPRESS_RANGECODER_OPT_H
+
+#define RC_INIT_VAR \
+  UInt32 range = rangeDecoder->Range; \
+  UInt32 code = rangeDecoder->Code;        
+
+#define RC_FLUSH_VAR \
+  rangeDecoder->Range = range; \
+  rangeDecoder->Code = code;
+
+#define RC_NORMALIZE \
+  if (range < NCompress::NRangeCoder::kTopValue) \
+    { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
+
+#define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \
+  { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \
+  if (code < bound) \
+  { A0; range = bound; \
+    prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \
+    mi <<= 1; } \
+  else \
+  { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \
+    mi = (mi + mi) + 1; }} \
+  RC_NORMALIZE
+
+#define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
+
+#endif
index 21c2fd780cfd588fb3c909d0872440d671fb2ff0..b637fd40075615837662becd3cd6d04fd100f230 100644 (file)
@@ -1,6 +1,6 @@
-// StdAfx.h\r
-\r
-#ifndef __STDAFX_H\r
-#define __STDAFX_H\r
-\r
-#endif\r
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#endif
index 508dac3fd0d5b104c1fcf4e326d7d2ea784442c7..d84575dc45f16d20c5cff79d546b5726cf917c6e 100644 (file)
-// ICoder.h\r
-\r
-#ifndef __ICODER_H\r
-#define __ICODER_H\r
-\r
-#include "IStream.h"\r
-\r
-// "23170F69-40C1-278A-0000-000400xx0000"\r
-#define CODER_INTERFACE(i, x) \\r
-DEFINE_GUID(IID_ ## i, \\r
-0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x04, 0x00, x, 0x00, 0x00); \\r
-struct i: public IUnknown\r
-\r
-CODER_INTERFACE(ICompressProgressInfo, 0x04)\r
-{\r
-  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressCoder, 0x05)\r
-{\r
-  STDMETHOD(Code)(ISequentialInStream *inStream,\r
-      ISequentialOutStream *outStream, \r
-      const UInt64 *inSize, \r
-      const UInt64 *outSize,\r
-      ICompressProgressInfo *progress) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressCoder2, 0x18)\r
-{\r
-  STDMETHOD(Code)(ISequentialInStream **inStreams,\r
-      const UInt64 **inSizes, \r
-      UInt32 numInStreams,\r
-      ISequentialOutStream **outStreams, \r
-      const UInt64 **outSizes,\r
-      UInt32 numOutStreams,\r
-      ICompressProgressInfo *progress) PURE;\r
-};\r
-\r
-namespace NCoderPropID\r
-{\r
-  enum EEnum\r
-  {\r
-    kDictionarySize = 0x400,\r
-    kUsedMemorySize,\r
-    kOrder,\r
-    kPosStateBits = 0x440,\r
-    kLitContextBits,\r
-    kLitPosBits,\r
-    kNumFastBytes = 0x450,\r
-    kMatchFinder,\r
-    kMatchFinderCycles,\r
-    kNumPasses = 0x460, \r
-    kAlgorithm = 0x470,\r
-    kMultiThread = 0x480,\r
-    kNumThreads,\r
-    kEndMarker = 0x490\r
-  };\r
-}\r
-\r
-CODER_INTERFACE(ICompressSetCoderProperties, 0x20)\r
-{\r
-  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, \r
-      const PROPVARIANT *properties, UInt32 numProperties) PURE;\r
-};\r
-\r
-/*\r
-CODER_INTERFACE(ICompressSetCoderProperties, 0x21)\r
-{\r
-  STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;\r
-};\r
-*/\r
-\r
-CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)\r
-{\r
-  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)\r
-{\r
-  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStreams) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)\r
-{\r
-  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressSetCoderMt, 0x25)\r
-{\r
-  STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)\r
-{\r
-  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressSetInStream, 0x31)\r
-{\r
-  STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;\r
-  STDMETHOD(ReleaseInStream)() PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressSetOutStream, 0x32)\r
-{\r
-  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;\r
-  STDMETHOD(ReleaseOutStream)() PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressSetInStreamSize, 0x33)\r
-{\r
-  STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)\r
-{\r
-  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICompressFilter, 0x40)\r
-{\r
-  STDMETHOD(Init)() PURE;\r
-  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;\r
-  // Filter return outSize (UInt32)\r
-  // if (outSize <= size): Filter have converted outSize bytes\r
-  // if (outSize > size): Filter have not converted anything.\r
-  //      and it needs at least outSize bytes to convert one block \r
-  //      (it's for crypto block algorithms).\r
-};\r
-\r
-CODER_INTERFACE(ICryptoProperties, 0x80)\r
-{\r
-  STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;\r
-  STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICryptoSetPassword, 0x90)\r
-{\r
-  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;\r
-};\r
-\r
-CODER_INTERFACE(ICryptoSetCRC, 0xA0)\r
-{\r
-  STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;\r
-};\r
-\r
-//////////////////////\r
-// It's for DLL file\r
-namespace NMethodPropID\r
-{\r
-  enum EEnum\r
-  {\r
-    kID,\r
-    kName,\r
-    kDecoder,\r
-    kEncoder,\r
-    kInStreams,\r
-    kOutStreams,\r
-    kDescription\r
-  };\r
-}\r
-\r
-#endif\r
+// ICoder.h
+
+#ifndef __ICODER_H
+#define __ICODER_H
+
+#include "IStream.h"
+
+// "23170F69-40C1-278A-0000-000400xx0000"
+#define CODER_INTERFACE(i, x) \
+DEFINE_GUID(IID_ ## i, \
+0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x04, 0x00, x, 0x00, 0x00); \
+struct i: public IUnknown
+
+CODER_INTERFACE(ICompressProgressInfo, 0x04)
+{
+  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;
+};
+
+CODER_INTERFACE(ICompressCoder, 0x05)
+{
+  STDMETHOD(Code)(ISequentialInStream *inStream,
+      ISequentialOutStream *outStream, 
+      const UInt64 *inSize, 
+      const UInt64 *outSize,
+      ICompressProgressInfo *progress) PURE;
+};
+
+CODER_INTERFACE(ICompressCoder2, 0x18)
+{
+  STDMETHOD(Code)(ISequentialInStream **inStreams,
+      const UInt64 **inSizes, 
+      UInt32 numInStreams,
+      ISequentialOutStream **outStreams, 
+      const UInt64 **outSizes,
+      UInt32 numOutStreams,
+      ICompressProgressInfo *progress) PURE;
+};
+
+namespace NCoderPropID
+{
+  enum EEnum
+  {
+    kDictionarySize = 0x400,
+    kUsedMemorySize,
+    kOrder,
+    kPosStateBits = 0x440,
+    kLitContextBits,
+    kLitPosBits,
+    kNumFastBytes = 0x450,
+    kMatchFinder,
+    kMatchFinderCycles,
+    kNumPasses = 0x460, 
+    kAlgorithm = 0x470,
+    kMultiThread = 0x480,
+    kNumThreads,
+    kEndMarker = 0x490
+  };
+}
+
+CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
+{
+  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, 
+      const PROPVARIANT *properties, UInt32 numProperties) PURE;
+};
+
+/*
+CODER_INTERFACE(ICompressSetCoderProperties, 0x21)
+{
+  STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
+};
+*/
+
+CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)
+{
+  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;
+};
+
+CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)
+{
+  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStreams) PURE;
+};
+
+CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)
+{
+  STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;
+};
+
+CODER_INTERFACE(ICompressSetCoderMt, 0x25)
+{
+  STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;
+};
+
+CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
+{
+  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;
+};
+
+CODER_INTERFACE(ICompressSetInStream, 0x31)
+{
+  STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
+  STDMETHOD(ReleaseInStream)() PURE;
+};
+
+CODER_INTERFACE(ICompressSetOutStream, 0x32)
+{
+  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
+  STDMETHOD(ReleaseOutStream)() PURE;
+};
+
+CODER_INTERFACE(ICompressSetInStreamSize, 0x33)
+{
+  STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;
+};
+
+CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
+{
+  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
+};
+
+CODER_INTERFACE(ICompressFilter, 0x40)
+{
+  STDMETHOD(Init)() PURE;
+  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
+  // Filter return outSize (UInt32)
+  // if (outSize <= size): Filter have converted outSize bytes
+  // if (outSize > size): Filter have not converted anything.
+  //      and it needs at least outSize bytes to convert one block 
+  //      (it's for crypto block algorithms).
+};
+
+CODER_INTERFACE(ICryptoProperties, 0x80)
+{
+  STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;
+  STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;
+};
+
+CODER_INTERFACE(ICryptoSetPassword, 0x90)
+{
+  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;
+};
+
+CODER_INTERFACE(ICryptoSetCRC, 0xA0)
+{
+  STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;
+};
+
+//////////////////////
+// It's for DLL file
+namespace NMethodPropID
+{
+  enum EEnum
+  {
+    kID,
+    kName,
+    kDecoder,
+    kEncoder,
+    kInStreams,
+    kOutStreams,
+    kDescription
+  };
+}
+
+#endif
index d92b89aa70a6c647460777323ece3dd4de478701..bba21a31583bd74dbec86ddeb6f039d5ba3fd01b 100644 (file)
@@ -1,62 +1,62 @@
-// IStream.h\r
-\r
-#ifndef __ISTREAM_H\r
-#define __ISTREAM_H\r
-\r
-#include "../Common/MyUnknown.h"\r
-#include "../Common/Types.h"\r
-\r
-// "23170F69-40C1-278A-0000-000300xx0000"\r
-\r
-#define STREAM_INTERFACE_SUB(i, b, x) \\r
-DEFINE_GUID(IID_ ## i, \\r
-0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, x, 0x00, 0x00); \\r
-struct i: public b\r
-\r
-#define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)\r
-\r
-STREAM_INTERFACE(ISequentialInStream, 0x01)\r
-{\r
-  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;\r
-  /*\r
-  Out: if size != 0, return_value = S_OK and (*processedSize == 0),\r
-    then there are no more bytes in stream.\r
-  if (size > 0) && there are bytes in stream, \r
-  this function must read at least 1 byte.\r
-  This function is allowed to read less than number of remaining bytes in stream.\r
-  You must call Read function in loop, if you need exact amount of data\r
-  */\r
-};\r
-\r
-STREAM_INTERFACE(ISequentialOutStream, 0x02)\r
-{\r
-  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;\r
-  /*\r
-  if (size > 0) this function must write at least 1 byte.\r
-  This function is allowed to write less than "size".\r
-  You must call Write function in loop, if you need to write exact amount of data\r
-  */\r
-};\r
-\r
-STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)\r
-{\r
-  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;\r
-};\r
-\r
-STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)\r
-{\r
-  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;\r
-  STDMETHOD(SetSize)(Int64 newSize) PURE;\r
-};\r
-\r
-STREAM_INTERFACE(IStreamGetSize, 0x06)\r
-{\r
-  STDMETHOD(GetSize)(UInt64 *size) PURE;\r
-};\r
-\r
-STREAM_INTERFACE(IOutStreamFlush, 0x07)\r
-{\r
-  STDMETHOD(Flush)() PURE;\r
-};\r
-\r
-#endif\r
+// IStream.h
+
+#ifndef __ISTREAM_H
+#define __ISTREAM_H
+
+#include "../Common/MyUnknown.h"
+#include "../Common/Types.h"
+
+// "23170F69-40C1-278A-0000-000300xx0000"
+
+#define STREAM_INTERFACE_SUB(i, b, x) \
+DEFINE_GUID(IID_ ## i, \
+0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, x, 0x00, 0x00); \
+struct i: public b
+
+#define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)
+
+STREAM_INTERFACE(ISequentialInStream, 0x01)
+{
+  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;
+  /*
+  Out: if size != 0, return_value = S_OK and (*processedSize == 0),
+    then there are no more bytes in stream.
+  if (size > 0) && there are bytes in stream, 
+  this function must read at least 1 byte.
+  This function is allowed to read less than number of remaining bytes in stream.
+  You must call Read function in loop, if you need exact amount of data
+  */
+};
+
+STREAM_INTERFACE(ISequentialOutStream, 0x02)
+{
+  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;
+  /*
+  if (size > 0) this function must write at least 1 byte.
+  This function is allowed to write less than "size".
+  You must call Write function in loop, if you need to write exact amount of data
+  */
+};
+
+STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
+{
+  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
+};
+
+STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
+{
+  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
+  STDMETHOD(SetSize)(Int64 newSize) PURE;
+};
+
+STREAM_INTERFACE(IStreamGetSize, 0x06)
+{
+  STDMETHOD(GetSize)(UInt64 *size) PURE;
+};
+
+STREAM_INTERFACE(IOutStreamFlush, 0x07)
+{
+  STDMETHOD(Flush)() PURE;
+};
+
+#endif
index dcb331ee9fac960129124994de26ada85a6b961e..e2b8c3d289e3f483500c550a3be005e0b883cfc8 100644 (file)
-// Common/Alloc.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#ifdef _WIN32\r
-#include "MyWindows.h"\r
-#else\r
-#include <stdlib.h>\r
-#endif\r
-\r
-#include "Alloc.h"\r
-\r
-/* #define _SZ_ALLOC_DEBUG */\r
-/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */\r
-#ifdef _SZ_ALLOC_DEBUG\r
-#include <stdio.h>\r
-int g_allocCount = 0;\r
-int g_allocCountMid = 0;\r
-int g_allocCountBig = 0;\r
-#endif\r
-\r
-void *MyAlloc(size_t size) throw()\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);\r
-  #endif\r
-  return ::malloc(size);\r
-}\r
-\r
-void MyFree(void *address) throw()\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree; count = %10d", --g_allocCount);\r
-  #endif\r
-  \r
-  ::free(address);\r
-}\r
-\r
-#ifdef _WIN32\r
-\r
-void *MidAlloc(size_t size) throw()\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc_Mid %10d bytes;  count = %10d", size, g_allocCountMid++);\r
-  #endif\r
-  return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);\r
-}\r
-\r
-void MidFree(void *address) throw()\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);\r
-  #endif\r
-  if (address == 0)\r
-    return;\r
-  ::VirtualFree(address, 0, MEM_RELEASE);\r
-}\r
-\r
-static SIZE_T g_LargePageSize = \r
-    #ifdef _WIN64\r
-    (1 << 21);\r
-    #else\r
-    (1 << 22);\r
-    #endif\r
-\r
-typedef SIZE_T (WINAPI *GetLargePageMinimumP)();\r
-\r
-bool SetLargePageSize()\r
-{\r
-  GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)\r
-        ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");\r
-  if (largePageMinimum == 0)\r
-    return false;\r
-  SIZE_T size = largePageMinimum();\r
-  if (size == 0 || (size & (size - 1)) != 0)\r
-    return false;\r
-  g_LargePageSize = size;\r
-  return true;\r
-}\r
-\r
-\r
-void *BigAlloc(size_t size) throw()\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc_Big %10d bytes;  count = %10d", size, g_allocCountBig++);\r
-  #endif\r
-  \r
-  if (size >= (1 << 18))\r
-  {\r
-    void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), \r
-        MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);\r
-    if (res != 0)\r
-      return res;\r
-  }\r
-  return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);\r
-}\r
-\r
-void BigFree(void *address) throw()\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);\r
-  #endif\r
-  \r
-  if (address == 0)\r
-    return;\r
-  ::VirtualFree(address, 0, MEM_RELEASE);\r
-}\r
-\r
-#endif\r
+// Common/Alloc.cpp
+
+#include "StdAfx.h"
+
+#ifdef _WIN32
+#include "MyWindows.h"
+#else
+#include <stdlib.h>
+#endif
+
+#include "Alloc.h"
+
+/* #define _SZ_ALLOC_DEBUG */
+/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
+#ifdef _SZ_ALLOC_DEBUG
+#include <stdio.h>
+int g_allocCount = 0;
+int g_allocCountMid = 0;
+int g_allocCountBig = 0;
+#endif
+
+void *MyAlloc(size_t size) throw()
+{
+  if (size == 0)
+    return 0;
+  #ifdef _SZ_ALLOC_DEBUG
+  fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);
+  #endif
+  return ::malloc(size);
+}
+
+void MyFree(void *address) throw()
+{
+  #ifdef _SZ_ALLOC_DEBUG
+  if (address != 0)
+    fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
+  #endif
+  
+  ::free(address);
+}
+
+#ifdef _WIN32
+
+void *MidAlloc(size_t size) throw()
+{
+  if (size == 0)
+    return 0;
+  #ifdef _SZ_ALLOC_DEBUG
+  fprintf(stderr, "\nAlloc_Mid %10d bytes;  count = %10d", size, g_allocCountMid++);
+  #endif
+  return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void MidFree(void *address) throw()
+{
+  #ifdef _SZ_ALLOC_DEBUG
+  if (address != 0)
+    fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
+  #endif
+  if (address == 0)
+    return;
+  ::VirtualFree(address, 0, MEM_RELEASE);
+}
+
+static SIZE_T g_LargePageSize = 
+    #ifdef _WIN64
+    (1 << 21);
+    #else
+    (1 << 22);
+    #endif
+
+typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
+
+bool SetLargePageSize()
+{
+  GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
+        ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
+  if (largePageMinimum == 0)
+    return false;
+  SIZE_T size = largePageMinimum();
+  if (size == 0 || (size & (size - 1)) != 0)
+    return false;
+  g_LargePageSize = size;
+  return true;
+}
+
+
+void *BigAlloc(size_t size) throw()
+{
+  if (size == 0)
+    return 0;
+  #ifdef _SZ_ALLOC_DEBUG
+  fprintf(stderr, "\nAlloc_Big %10d bytes;  count = %10d", size, g_allocCountBig++);
+  #endif
+  
+  if (size >= (1 << 18))
+  {
+    void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), 
+        MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
+    if (res != 0)
+      return res;
+  }
+  return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void BigFree(void *address) throw()
+{
+  #ifdef _SZ_ALLOC_DEBUG
+  if (address != 0)
+    fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
+  #endif
+  
+  if (address == 0)
+    return;
+  ::VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#endif
index 2ae3891de664a78640f82e8c096a3d4246bb1d47..d444f631930d81e3c14a14783ad713188d4e2aff 100644 (file)
@@ -1,29 +1,29 @@
-// Common/Alloc.h\r
-\r
-#ifndef __COMMON_ALLOC_H\r
-#define __COMMON_ALLOC_H\r
-\r
-#include <stddef.h>\r
-\r
-void *MyAlloc(size_t size) throw();\r
-void MyFree(void *address) throw();\r
-\r
-#ifdef _WIN32\r
-\r
-bool SetLargePageSize();\r
-\r
-void *MidAlloc(size_t size) throw();\r
-void MidFree(void *address) throw();\r
-void *BigAlloc(size_t size) throw();\r
-void BigFree(void *address) throw();\r
-\r
-#else\r
-\r
-#define MidAlloc(size) MyAlloc(size)\r
-#define MidFree(address) MyFree(address)\r
-#define BigAlloc(size) MyAlloc(size)\r
-#define BigFree(address) MyFree(address)\r
-\r
-#endif\r
-\r
-#endif\r
+// Common/Alloc.h
+
+#ifndef __COMMON_ALLOC_H
+#define __COMMON_ALLOC_H
+
+#include <stddef.h>
+
+void *MyAlloc(size_t size) throw();
+void MyFree(void *address) throw();
+
+#ifdef _WIN32
+
+bool SetLargePageSize();
+
+void *MidAlloc(size_t size) throw();
+void MidFree(void *address) throw();
+void *BigAlloc(size_t size) throw();
+void BigFree(void *address) throw();
+
+#else
+
+#define MidAlloc(size) MyAlloc(size)
+#define MidFree(address) MyFree(address)
+#define BigAlloc(size) MyAlloc(size)
+#define BigFree(address) MyFree(address)
+
+#endif
+
+#endif
index 92bc009c2ffe20a58710bb7954d663dffeec4f6f..35e1a18751707b926324a82ce1f942514c7fec45 100644 (file)
@@ -1,61 +1,61 @@
-// Common/CRC.cpp\r
-\r
-#include "StdAfx.h"\r
-\r
-#include "CRC.h"\r
-\r
-static const UInt32 kCRCPoly = 0xEDB88320;\r
-\r
-UInt32 CCRC::Table[256];\r
-\r
-void CCRC::InitTable()\r
-{\r
-  for (UInt32 i = 0; i < 256; i++)\r
-  {\r
-    UInt32 r = i;\r
-    for (int j = 0; j < 8; j++)\r
-      if (r & 1) \r
-        r = (r >> 1) ^ kCRCPoly;\r
-      else     \r
-        r >>= 1;\r
-    CCRC::Table[i] = r;\r
-  }\r
-}\r
-\r
-class CCRCTableInit\r
-{\r
-public:\r
-  CCRCTableInit() { CCRC::InitTable(); }\r
-} g_CRCTableInit;\r
-\r
-void CCRC::UpdateByte(Byte b)\r
-{\r
-  _value = Table[((Byte)(_value)) ^ b] ^ (_value >> 8);\r
-}\r
-\r
-void CCRC::UpdateUInt16(UInt16 v)\r
-{\r
-  UpdateByte(Byte(v));\r
-  UpdateByte(Byte(v >> 8));\r
-}\r
-\r
-void CCRC::UpdateUInt32(UInt32 v)\r
-{\r
-  for (int i = 0; i < 4; i++)\r
-    UpdateByte((Byte)(v >> (8 * i)));\r
-}\r
-\r
-void CCRC::UpdateUInt64(UInt64 v)\r
-{\r
-  for (int i = 0; i < 8; i++)\r
-    UpdateByte((Byte)(v >> (8 * i)));\r
-}\r
-\r
-void CCRC::Update(const void *data, size_t size)\r
-{\r
-  UInt32 v = _value;\r
-  const Byte *p = (const Byte *)data;\r
-  for (; size > 0 ; size--, p++)\r
-    v = Table[((Byte)(v)) ^ *p] ^ (v >> 8);\r
-  _value = v;\r
-}\r
+// Common/CRC.cpp
+
+#include "StdAfx.h"
+
+#include "CRC.h"
+
+static const UInt32 kCRCPoly = 0xEDB88320;
+
+UInt32 CCRC::Table[256];
+
+void CCRC::InitTable()
+{
+  for (UInt32 i = 0; i < 256; i++)
+  {
+    UInt32 r = i;
+    for (int j = 0; j < 8; j++)
+      if (r & 1) 
+        r = (r >> 1) ^ kCRCPoly;
+      else     
+        r >>= 1;
+    CCRC::Table[i] = r;
+  }
+}
+
+class CCRCTableInit
+{
+public:
+  CCRCTableInit() { CCRC::InitTable(); }
+} g_CRCTableInit;
+
+void CCRC::UpdateByte(Byte b)
+{
+  _value = Table[((Byte)(_value)) ^ b] ^ (_value >> 8);
+}
+
+void CCRC::UpdateUInt16(UInt16 v)
+{
+  UpdateByte(Byte(v));
+  UpdateByte(Byte(v >> 8));
+}
+
+void CCRC::UpdateUInt32(UInt32 v)
+{
+  for (int i = 0; i < 4; i++)
+    UpdateByte((Byte)(v >> (8 * i)));
+}
+
+void CCRC::UpdateUInt64(UInt64 v)
+{
+  for (int i = 0; i < 8; i++)
+    UpdateByte((Byte)(v >> (8 * i)));
+}
+
+void CCRC::Update(const void *data, size_t size)
+{
+  UInt32 v = _value;
+  const Byte *p = (const Byte *)data;
+  for (; size > 0 ; size--, p++)
+    v = Table[((Byte)(v)) ^ *p] ^ (v >> 8);
+  _value = v;
+}
index c9d43d0055d33e3e7bb4ec314fff01d5a6877fde..6b4f1b796b6b105978e4db3c0bf13bd75f2f965f 100644 (file)
@@ -1,36 +1,36 @@
-// Common/CRC.h\r
-\r
-#ifndef __COMMON_CRC_H\r
-#define __COMMON_CRC_H\r
-\r
-#include <stddef.h>\r
-#include "Types.h"\r
-\r
-class CCRC\r
-{\r
-  UInt32 _value;\r
-public:\r
-       static UInt32 Table[256];\r
-       static void InitTable();\r
-\r
-  CCRC():  _value(0xFFFFFFFF){};\r
-  void Init() { _value = 0xFFFFFFFF; }\r
-  void UpdateByte(Byte v);\r
-  void UpdateUInt16(UInt16 v);\r
-  void UpdateUInt32(UInt32 v);\r
-  void UpdateUInt64(UInt64 v);\r
-  void Update(const void *data, size_t size);\r
-  UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; } \r
-  static UInt32 CalculateDigest(const void *data, size_t size)\r
-  {\r
-    CCRC crc;\r
-    crc.Update(data, size);\r
-    return crc.GetDigest();\r
-  }\r
-  static bool VerifyDigest(UInt32 digest, const void *data, size_t size)\r
-  {\r
-    return (CalculateDigest(data, size) == digest);\r
-  }\r
-};\r
-\r
-#endif\r
+// Common/CRC.h
+
+#ifndef __COMMON_CRC_H
+#define __COMMON_CRC_H
+
+#include <stddef.h>
+#include "Types.h"
+
+class CCRC
+{
+  UInt32 _value;
+public:
+       static UInt32 Table[256];
+       static void InitTable();
+
+  CCRC():  _value(0xFFFFFFFF){};
+  void Init() { _value = 0xFFFFFFFF; }
+  void UpdateByte(Byte v);
+  void UpdateUInt16(UInt16 v);
+  void UpdateUInt32(UInt32 v);
+  void UpdateUInt64(UInt64 v);
+  void Update(const void *data, size_t size);
+  UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; } 
+  static UInt32 CalculateDigest(const void *data, size_t size)
+  {
+    CCRC crc;
+    crc.Update(data, size);
+    return crc.GetDigest();
+  }
+  static bool VerifyDigest(UInt32 digest, const void *data, size_t size)
+  {
+    return (CalculateDigest(data, size) == digest);
+  }
+};
+
+#endif
index 69b8ecea821c0deac813c16e0e657a03c38e3cc8..dad3ae8f11d18502c05dbc2989d29b0b435c8ba3 100644 (file)
@@ -1,20 +1,20 @@
-// Common/Defs.h\r
-\r
-#ifndef __COMMON_DEFS_H\r
-#define __COMMON_DEFS_H\r
-\r
-template <class T> inline T MyMin(T a, T b)\r
-  {  return a < b ? a : b; }\r
-template <class T> inline T MyMax(T a, T b)\r
-  {  return a > b ? a : b; }\r
-\r
-template <class T> inline int MyCompare(T a, T b)\r
-  {  return a < b ? -1 : (a == b ? 0 : 1); }\r
-\r
-inline int BoolToInt(bool value)\r
-  { return (value ? 1: 0); }\r
-\r
-inline bool IntToBool(int value)\r
-  { return (value != 0); }\r
-\r
-#endif\r
+// Common/Defs.h
+
+#ifndef __COMMON_DEFS_H
+#define __COMMON_DEFS_H
+
+template <class T> inline T MyMin(T a, T b)
+  {  return a < b ? a : b; }
+template <class T> inline T MyMax(T a, T b)
+  {  return a > b ? a : b; }
+
+template <class T> inline int MyCompare(T a, T b)
+  {  return a < b ? -1 : (a == b ? 0 : 1); }
+
+inline int BoolToInt(bool value)
+  { return (value ? 1: 0); }
+
+inline bool IntToBool(int value)
+  { return (value != 0); }
+
+#endif
index 8476b572826479b8c50d76aa1022613638c59a39..e903493013a15ec14dbdb1c24f44399021b764de 100644 (file)
-// MyCom.h\r
-\r
-#ifndef __MYCOM_H\r
-#define __MYCOM_H\r
-\r
-#include "MyWindows.h"\r
-\r
-#define RINOK(x) { HRESULT __result_ = (x); if(__result_ != S_OK) return __result_; }\r
-\r
-template <class T>\r
-class CMyComPtr\r
-{\r
-  T* _p;\r
-public:\r
-  // typedef T _PtrClass;\r
-  CMyComPtr() { _p = NULL;}\r
-  CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }\r
-  CMyComPtr(const CMyComPtr<T>& lp)\r
-  {\r
-    if ((_p = lp._p) != NULL)\r
-      _p->AddRef();\r
-  }\r
-  ~CMyComPtr() { if (_p) _p->Release(); }\r
-  void Release() { if (_p) { _p->Release(); _p = NULL; } }\r
-  operator T*() const {  return (T*)_p;  }\r
-  // T& operator*() const {  return *_p; }\r
-  T** operator&() { return &_p; }\r
-  T* operator->() const { return _p; }\r
-  T* operator=(T* p) \r
-  { \r
-    if (p != 0)\r
-      p->AddRef();\r
-    if (_p) \r
-      _p->Release();\r
-    _p = p;\r
-    return p;\r
-  }\r
-  T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }\r
-  bool operator!() const { return (_p == NULL); }\r
-  // bool operator==(T* pT) const {  return _p == pT; }\r
-  // Compare two objects for equivalence\r
-  void Attach(T* p2)\r
-  {\r
-    Release();\r
-    _p = p2;\r
-  }\r
-  T* Detach()\r
-  {\r
-    T* pt = _p;\r
-    _p = NULL;\r
-    return pt;\r
-  }\r
-  #ifdef _WIN32\r
-  HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)\r
-  {\r
-    return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);\r
-  }\r
-  #endif\r
-  /*\r
-  HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)\r
-  {\r
-    CLSID clsid;\r
-    HRESULT hr = CLSIDFromProgID(szProgID, &clsid);\r
-    ATLASSERT(_p == NULL);\r
-    if (SUCCEEDED(hr))\r
-      hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);\r
-    return hr;\r
-  }\r
-  */\r
-  template <class Q>\r
-  HRESULT QueryInterface(REFGUID iid, Q** pp) const\r
-  {\r
-    return _p->QueryInterface(iid, (void**)pp);\r
-  }\r
-};\r
-\r
-//////////////////////////////////////////////////////////\r
-\r
-class CMyComBSTR\r
-{\r
-public:\r
-  BSTR m_str;\r
-  CMyComBSTR() { m_str = NULL; }\r
-  CMyComBSTR(LPCOLESTR pSrc) {  m_str = ::SysAllocString(pSrc);  }\r
-  // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }\r
-  // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize);  }\r
-  CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }\r
-  /*\r
-  CMyComBSTR(REFGUID src)\r
-  {\r
-    LPOLESTR szGuid;\r
-    StringFromCLSID(src, &szGuid);\r
-    m_str = ::SysAllocString(szGuid);\r
-    CoTaskMemFree(szGuid);\r
-  }\r
-  */\r
-  ~CMyComBSTR() { ::SysFreeString(m_str); }\r
-  CMyComBSTR& operator=(const CMyComBSTR& src)\r
-  {\r
-    if (m_str != src.m_str)\r
-    {\r
-      if (m_str)\r
-        ::SysFreeString(m_str);\r
-      m_str = src.MyCopy();\r
-    }\r
-    return *this;\r
-  }\r
-  CMyComBSTR& operator=(LPCOLESTR pSrc)\r
-  {\r
-    ::SysFreeString(m_str);\r
-    m_str = ::SysAllocString(pSrc);\r
-    return *this;\r
-  }\r
-  unsigned int Length() const { return ::SysStringLen(m_str); }\r
-  operator BSTR() const { return m_str; }\r
-  BSTR* operator&() { return &m_str; }\r
-  BSTR MyCopy() const \r
-  { \r
-    int byteLen = ::SysStringByteLen(m_str);\r
-    BSTR res = ::SysAllocStringByteLen(NULL, byteLen);\r
-    memmove(res, m_str, byteLen);\r
-    return res;\r
-  }\r
-  void Attach(BSTR src) {  m_str = src; }\r
-  BSTR Detach()\r
-  {\r
-    BSTR s = m_str;\r
-    m_str = NULL;\r
-    return s;\r
-  }\r
-  void Empty()\r
-  {\r
-    ::SysFreeString(m_str);\r
-    m_str = NULL;\r
-  }\r
-  bool operator!() const {  return (m_str == NULL); }\r
-};\r
-\r
-\r
-//////////////////////////////////////////////////////////\r
-\r
-class CMyUnknownImp\r
-{\r
-public:\r
-  ULONG __m_RefCount;\r
-  CMyUnknownImp(): __m_RefCount(0) {}\r
-};\r
-\r
-#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \\r
-    (REFGUID iid, void **outObject) { \r
-\r
-#define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \\r
-    { *outObject = (void *)(i *)this; AddRef(); return S_OK; }\r
-\r
-#define MY_QUERYINTERFACE_END return E_NOINTERFACE; }\r
-\r
-#define MY_ADDREF_RELEASE \\r
-STDMETHOD_(ULONG, AddRef)() { return ++__m_RefCount; } \\r
-STDMETHOD_(ULONG, Release)() { if (--__m_RefCount != 0)  \\r
-  return __m_RefCount; delete this; return 0; }\r
-\r
-#define MY_UNKNOWN_IMP_SPEC(i) \\r
-  MY_QUERYINTERFACE_BEGIN \\r
-  i \\r
-  MY_QUERYINTERFACE_END \\r
-  MY_ADDREF_RELEASE\r
-\r
-\r
-#define MY_UNKNOWN_IMP STDMETHOD(QueryInterface)(REFGUID, void **) { \\r
-  MY_QUERYINTERFACE_END \\r
-  MY_ADDREF_RELEASE\r
-\r
-#define MY_UNKNOWN_IMP1(i) MY_UNKNOWN_IMP_SPEC( \\r
-  MY_QUERYINTERFACE_ENTRY(i) \\r
-  )\r
-\r
-#define MY_UNKNOWN_IMP2(i1, i2) MY_UNKNOWN_IMP_SPEC( \\r
-  MY_QUERYINTERFACE_ENTRY(i1) \\r
-  MY_QUERYINTERFACE_ENTRY(i2) \\r
-  )\r
-\r
-#define MY_UNKNOWN_IMP3(i1, i2, i3) MY_UNKNOWN_IMP_SPEC( \\r
-  MY_QUERYINTERFACE_ENTRY(i1) \\r
-  MY_QUERYINTERFACE_ENTRY(i2) \\r
-  MY_QUERYINTERFACE_ENTRY(i3) \\r
-  )\r
-\r
-#define MY_UNKNOWN_IMP4(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC( \\r
-  MY_QUERYINTERFACE_ENTRY(i1) \\r
-  MY_QUERYINTERFACE_ENTRY(i2) \\r
-  MY_QUERYINTERFACE_ENTRY(i3) \\r
-  MY_QUERYINTERFACE_ENTRY(i4) \\r
-  )\r
-\r
-#define MY_UNKNOWN_IMP5(i1, i2, i3, i4, i5) MY_UNKNOWN_IMP_SPEC( \\r
-  MY_QUERYINTERFACE_ENTRY(i1) \\r
-  MY_QUERYINTERFACE_ENTRY(i2) \\r
-  MY_QUERYINTERFACE_ENTRY(i3) \\r
-  MY_QUERYINTERFACE_ENTRY(i4) \\r
-  MY_QUERYINTERFACE_ENTRY(i5) \\r
-  )\r
-\r
-#endif\r
+// MyCom.h
+
+#ifndef __MYCOM_H
+#define __MYCOM_H
+
+#include "MyWindows.h"
+
+#define RINOK(x) { HRESULT __result_ = (x); if(__result_ != S_OK) return __result_; }
+
+template <class T>
+class CMyComPtr
+{
+  T* _p;
+public:
+  // typedef T _PtrClass;
+  CMyComPtr() { _p = NULL;}
+  CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }
+  CMyComPtr(const CMyComPtr<T>& lp)
+  {
+    if ((_p = lp._p) != NULL)
+      _p->AddRef();
+  }
+  ~CMyComPtr() { if (_p) _p->Release(); }
+  void Release() { if (_p) { _p->Release(); _p = NULL; } }
+  operator T*() const {  return (T*)_p;  }
+  // T& operator*() const {  return *_p; }
+  T** operator&() { return &_p; }
+  T* operator->() const { return _p; }
+  T* operator=(T* p) 
+  { 
+    if (p != 0)
+      p->AddRef();
+    if (_p) 
+      _p->Release();
+    _p = p;
+    return p;
+  }
+  T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
+  bool operator!() const { return (_p == NULL); }
+  // bool operator==(T* pT) const {  return _p == pT; }
+  // Compare two objects for equivalence
+  void Attach(T* p2)
+  {
+    Release();
+    _p = p2;
+  }
+  T* Detach()
+  {
+    T* pt = _p;
+    _p = NULL;
+    return pt;
+  }
+  #ifdef _WIN32
+  HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+  {
+    return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
+  }
+  #endif
+  /*
+  HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+  {
+    CLSID clsid;
+    HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
+    ATLASSERT(_p == NULL);
+    if (SUCCEEDED(hr))
+      hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
+    return hr;
+  }
+  */
+  template <class Q>
+  HRESULT QueryInterface(REFGUID iid, Q** pp) const
+  {
+    return _p->QueryInterface(iid, (void**)pp);
+  }
+};
+
+//////////////////////////////////////////////////////////
+
+class CMyComBSTR
+{
+public:
+  BSTR m_str;
+  CMyComBSTR() { m_str = NULL; }
+  CMyComBSTR(LPCOLESTR pSrc) {  m_str = ::SysAllocString(pSrc);  }
+  // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
+  // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize);  }
+  CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
+  /*
+  CMyComBSTR(REFGUID src)
+  {
+    LPOLESTR szGuid;
+    StringFromCLSID(src, &szGuid);
+    m_str = ::SysAllocString(szGuid);
+    CoTaskMemFree(szGuid);
+  }
+  */
+  ~CMyComBSTR() { ::SysFreeString(m_str); }
+  CMyComBSTR& operator=(const CMyComBSTR& src)
+  {
+    if (m_str != src.m_str)
+    {
+      if (m_str)
+        ::SysFreeString(m_str);
+      m_str = src.MyCopy();
+    }
+    return *this;
+  }
+  CMyComBSTR& operator=(LPCOLESTR pSrc)
+  {
+    ::SysFreeString(m_str);
+    m_str = ::SysAllocString(pSrc);
+    return *this;
+  }
+  unsigned int Length() const { return ::SysStringLen(m_str); }
+  operator BSTR() const { return m_str; }
+  BSTR* operator&() { return &m_str; }
+  BSTR MyCopy() const 
+  { 
+    int byteLen = ::SysStringByteLen(m_str);
+    BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
+    memmove(res, m_str, byteLen);
+    return res;
+  }
+  void Attach(BSTR src) {  m_str = src; }
+  BSTR Detach()
+  {
+    BSTR s = m_str;
+    m_str = NULL;
+    return s;
+  }
+  void Empty()
+  {
+    ::SysFreeString(m_str);
+    m_str = NULL;
+  }
+  bool operator!() const {  return (m_str == NULL); }
+};
+
+
+//////////////////////////////////////////////////////////
+
+class CMyUnknownImp
+{
+public:
+  ULONG __m_RefCount;
+  CMyUnknownImp(): __m_RefCount(0) {}
+};
+
+#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
+    (REFGUID iid, void **outObject) { 
+
+#define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \
+    { *outObject = (void *)(i *)this; AddRef(); return S_OK; }
+
+#define MY_QUERYINTERFACE_END return E_NOINTERFACE; }
+
+#define MY_ADDREF_RELEASE \
+STDMETHOD_(ULONG, AddRef)() { return ++__m_RefCount; } \
+STDMETHOD_(ULONG, Release)() { if (--__m_RefCount != 0)  \
+  return __m_RefCount; delete this; return 0; }
+
+#define MY_UNKNOWN_IMP_SPEC(i) \
+  MY_QUERYINTERFACE_BEGIN \
+  i \
+  MY_QUERYINTERFACE_END \
+  MY_ADDREF_RELEASE
+
+
+#define MY_UNKNOWN_IMP STDMETHOD(QueryInterface)(REFGUID, void **) { \
+  MY_QUERYINTERFACE_END \
+  MY_ADDREF_RELEASE
+
+#define MY_UNKNOWN_IMP1(i) MY_UNKNOWN_IMP_SPEC( \
+  MY_QUERYINTERFACE_ENTRY(i) \
+  )
+
+#define MY_UNKNOWN_IMP2(i1, i2) MY_UNKNOWN_IMP_SPEC( \
+  MY_QUERYINTERFACE_ENTRY(i1) \
+  MY_QUERYINTERFACE_ENTRY(i2) \
+  )
+
+#define MY_UNKNOWN_IMP3(i1, i2, i3) MY_UNKNOWN_IMP_SPEC( \
+  MY_QUERYINTERFACE_ENTRY(i1) \
+  MY_QUERYINTERFACE_ENTRY(i2) \
+  MY_QUERYINTERFACE_ENTRY(i3) \
+  )
+
+#define MY_UNKNOWN_IMP4(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC( \
+  MY_QUERYINTERFACE_ENTRY(i1) \
+  MY_QUERYINTERFACE_ENTRY(i2) \
+  MY_QUERYINTERFACE_ENTRY(i3) \
+  MY_QUERYINTERFACE_ENTRY(i4) \
+  )
+
+#define MY_UNKNOWN_IMP5(i1, i2, i3, i4, i5) MY_UNKNOWN_IMP_SPEC( \
+  MY_QUERYINTERFACE_ENTRY(i1) \
+  MY_QUERYINTERFACE_ENTRY(i2) \
+  MY_QUERYINTERFACE_ENTRY(i3) \
+  MY_QUERYINTERFACE_ENTRY(i4) \
+  MY_QUERYINTERFACE_ENTRY(i5) \
+  )
+
+#endif
index 889ea417b0605c2c93293566d4ec2234a0059779..a7f8118ec9d46fa53e39a4fc042465fc29eaba41 100644 (file)
@@ -1,54 +1,54 @@
-// Common/MyGuidDef.h\r
-\r
-#ifndef GUID_DEFINED\r
-#define GUID_DEFINED\r
-\r
-#include "Types.h"\r
-\r
-typedef struct {\r
-  UInt32 Data1;\r
-  UInt16 Data2;\r
-  UInt16 Data3;\r
-  unsigned char Data4[8];\r
-} GUID;\r
-\r
-#ifdef __cplusplus\r
-#define REFGUID const GUID &\r
-#else\r
-#define REFGUID const GUID *\r
-#endif\r
-\r
-#define REFCLSID REFGUID\r
-#define REFIID REFGUID\r
-\r
-#ifdef __cplusplus\r
-inline bool operator==(REFGUID g1, REFGUID g2)\r
-{ \r
-  for (int i = 0; i < (int)sizeof(g1); i++)\r
-    if (((const unsigned char *)&g1)[i] != ((const unsigned char *)&g2)[i])\r
-      return false;\r
-  return true;\r
-}\r
-inline bool operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); }\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-  #define MY_EXTERN_C extern "C"\r
-#else\r
-  #define MY_EXTERN_C extern\r
-#endif\r
-\r
-#endif // GUID_DEFINED\r
-\r
-\r
-#ifdef DEFINE_GUID\r
-#undef DEFINE_GUID\r
-#endif\r
-\r
-#ifdef INITGUID\r
-  #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\r
-    MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }\r
-#else\r
-  #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\r
-    MY_EXTERN_C const GUID name\r
-#endif\r
+// Common/MyGuidDef.h
+
+#ifndef GUID_DEFINED
+#define GUID_DEFINED
+
+#include "Types.h"
+
+typedef struct {
+  UInt32 Data1;
+  UInt16 Data2;
+  UInt16 Data3;
+  unsigned char Data4[8];
+} GUID;
+
+#ifdef __cplusplus
+#define REFGUID const GUID &
+#else
+#define REFGUID const GUID *
+#endif
+
+#define REFCLSID REFGUID
+#define REFIID REFGUID
+
+#ifdef __cplusplus
+inline bool operator==(REFGUID g1, REFGUID g2)
+{ 
+  for (int i = 0; i < (int)sizeof(g1); i++)
+    if (((const unsigned char *)&g1)[i] != ((const unsigned char *)&g2)[i])
+      return false;
+  return true;
+}
+inline bool operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); }
+#endif
+
+#ifdef __cplusplus
+  #define MY_EXTERN_C extern "C"
+#else
+  #define MY_EXTERN_C extern
+#endif
+
+#endif // GUID_DEFINED
+
+
+#ifdef DEFINE_GUID
+#undef DEFINE_GUID
+#endif
+
+#ifdef INITGUID
+  #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+    MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
+#else
+  #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+    MY_EXTERN_C const GUID name
+#endif
index 53b0f0342861d972f21a906fb3cf2ae92ab14e65..5bdfeed564cca27723e0b285488e8ff380c64acf 100644 (file)
@@ -1,13 +1,13 @@
-// Common/MyInitGuid.h\r
-\r
-#ifndef __COMMON_MYINITGUID_H\r
-#define __COMMON_MYINITGUID_H\r
-\r
-#ifdef _WIN32\r
-#include <initguid.h>\r
-#else\r
-#define INITGUID\r
-#include "MyGuidDef.h"\r
-#endif\r
-\r
-#endif\r
+// Common/MyInitGuid.h
+
+#ifndef __COMMON_MYINITGUID_H
+#define __COMMON_MYINITGUID_H
+
+#ifdef _WIN32
+#include <initguid.h>
+#else
+#define INITGUID
+#include "MyGuidDef.h"
+#endif
+
+#endif
index 6cd32caddbcd8b14aa59c6dad678d980f5707909..d28d8542563d5f76f9710208b6afb0a22e2c8910 100644 (file)
@@ -1,24 +1,24 @@
-// MyUnknown.h\r
-\r
-#ifndef __MYUNKNOWN_H\r
-#define __MYUNKNOWN_H\r
-\r
-#ifdef _WIN32\r
-\r
-#ifdef _WIN32_WCE\r
-#if (_WIN32_WCE > 300)\r
-#include <basetyps.h>\r
-#else\r
-#define MIDL_INTERFACE(x) struct \r
-#endif\r
-#else\r
-#include <basetyps.h>\r
-#endif\r
-\r
-#include <unknwn.h>\r
-\r
-#else \r
-#include "MyWindows.h"\r
-#endif\r
-  \r
-#endif\r
+// MyUnknown.h
+
+#ifndef __MYUNKNOWN_H
+#define __MYUNKNOWN_H
+
+#ifdef _WIN32
+
+#ifdef _WIN32_WCE
+#if (_WIN32_WCE > 300)
+#include <basetyps.h>
+#else
+#define MIDL_INTERFACE(x) struct 
+#endif
+#else
+#include <basetyps.h>
+#endif
+
+#include <unknwn.h>
+
+#else 
+#include "MyWindows.h"
+#endif
+  
+#endif
index 2929be7c30f03abcfef9a47d5e935be916e7cd57..4ac3dfc5c275a1b1d11362585e57f4652c0d3430 100644 (file)
-// MyWindows.h\r
-\r
-#ifndef __MYWINDOWS_H\r
-#define __MYWINDOWS_H\r
-\r
-#ifdef _WIN32\r
-\r
-#include <windows.h>\r
-\r
-#define CHAR_PATH_SEPARATOR '\\'\r
-#define WCHAR_PATH_SEPARATOR L'\\'\r
-#define STRING_PATH_SEPARATOR "\\"\r
-#define WSTRING_PATH_SEPARATOR L"\\"\r
-\r
-#else\r
-\r
-#define CHAR_PATH_SEPARATOR '/'\r
-#define WCHAR_PATH_SEPARATOR L'/'\r
-#define STRING_PATH_SEPARATOR "/"\r
-#define WSTRING_PATH_SEPARATOR L"/"\r
-\r
-#include <stddef.h> // for wchar_t\r
-#include <string.h>\r
-\r
-#include "MyGuidDef.h"\r
-\r
-typedef char CHAR;\r
-typedef unsigned char UCHAR;\r
-\r
-#undef BYTE\r
-typedef unsigned char BYTE;\r
-\r
-typedef short SHORT;\r
-typedef unsigned short USHORT;\r
-\r
-#undef WORD\r
-typedef unsigned short WORD;\r
-typedef short VARIANT_BOOL;\r
-\r
-typedef int INT;\r
-typedef Int32 INT32;\r
-typedef unsigned int UINT;\r
-typedef UInt32 UINT32;\r
-typedef INT32 LONG;   // LONG, ULONG and DWORD must be 32-bit\r
-typedef UINT32 ULONG;\r
-\r
-#undef DWORD\r
-typedef UINT32 DWORD;\r
-\r
-typedef Int64 LONGLONG;\r
-typedef UInt64 ULONGLONG;\r
-\r
-typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;\r
-typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;\r
-\r
-typedef const CHAR *LPCSTR;\r
-typedef CHAR TCHAR;\r
-typedef const TCHAR *LPCTSTR;\r
-typedef wchar_t WCHAR;\r
-typedef WCHAR OLECHAR;\r
-typedef const WCHAR *LPCWSTR;\r
-typedef OLECHAR *BSTR;\r
-typedef const OLECHAR *LPCOLESTR;\r
-typedef OLECHAR *LPOLESTR;\r
-\r
-typedef struct _FILETIME\r
-{\r
-  DWORD dwLowDateTime;\r
-  DWORD dwHighDateTime;\r
-}FILETIME;\r
-\r
-#define HRESULT LONG\r
-#define FAILED(Status) ((HRESULT)(Status)<0)\r
-typedef ULONG PROPID;\r
-typedef LONG SCODE;\r
-\r
-#define S_OK    ((HRESULT)0x00000000L)\r
-#define S_FALSE ((HRESULT)0x00000001L)\r
-#define E_NOTIMPL ((HRESULT)0x80004001L)\r
-#define E_NOINTERFACE ((HRESULT)0x80004002L)\r
-#define E_ABORT ((HRESULT)0x80004004L)\r
-#define E_FAIL ((HRESULT)0x80004005L)\r
-#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)\r
-#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)\r
-#define E_INVALIDARG ((HRESULT)0x80070057L)\r
-\r
-#ifdef _MSC_VER\r
-#define STDMETHODCALLTYPE __stdcall \r
-#else\r
-#define STDMETHODCALLTYPE \r
-#endif\r
-\r
-#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f\r
-#define STDMETHOD(f) STDMETHOD_(HRESULT, f)\r
-#define STDMETHODIMP_(type) type STDMETHODCALLTYPE\r
-#define STDMETHODIMP STDMETHODIMP_(HRESULT)\r
-\r
-#define PURE = 0\r
-\r
-#define MIDL_INTERFACE(x) struct \r
-\r
-struct IUnknown\r
-{\r
-  //virtual ~IUnknown() {}\r
-  STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;\r
-  STDMETHOD_(ULONG, AddRef)() PURE;\r
-  STDMETHOD_(ULONG, Release)() PURE;\r
-};\r
-\r
-typedef IUnknown *LPUNKNOWN;\r
-\r
-#define VARIANT_TRUE ((VARIANT_BOOL)-1)\r
-#define VARIANT_FALSE ((VARIANT_BOOL)0)\r
-\r
-enum VARENUM\r
-{      \r
-  VT_EMPTY     = 0,\r
-       VT_NULL = 1,\r
-       VT_I2   = 2,\r
-       VT_I4   = 3,\r
-       VT_R4   = 4,\r
-       VT_R8   = 5,\r
-       VT_CY   = 6,\r
-       VT_DATE = 7,\r
-       VT_BSTR = 8,\r
-       VT_DISPATCH     = 9,\r
-       VT_ERROR        = 10,\r
-       VT_BOOL = 11,\r
-       VT_VARIANT      = 12,\r
-       VT_UNKNOWN      = 13,\r
-       VT_DECIMAL      = 14,\r
-       VT_I1   = 16,\r
-       VT_UI1  = 17,\r
-       VT_UI2  = 18,\r
-       VT_UI4  = 19,\r
-       VT_I8   = 20,\r
-       VT_UI8  = 21,\r
-       VT_INT  = 22,\r
-       VT_UINT = 23,\r
-       VT_VOID = 24,\r
-       VT_HRESULT      = 25,\r
-       VT_FILETIME     = 64\r
-};\r
-\r
-typedef unsigned short VARTYPE;\r
-typedef WORD PROPVAR_PAD1;\r
-typedef WORD PROPVAR_PAD2;\r
-typedef WORD PROPVAR_PAD3;\r
-\r
-typedef struct tagPROPVARIANT\r
-{\r
-  VARTYPE vt;\r
-  PROPVAR_PAD1 wReserved1;\r
-  PROPVAR_PAD2 wReserved2;\r
-  PROPVAR_PAD3 wReserved3;\r
-  union \r
-  {\r
-    CHAR cVal;\r
-    UCHAR bVal;\r
-    SHORT iVal;\r
-    USHORT uiVal;\r
-    LONG lVal;\r
-    ULONG ulVal;\r
-    INT intVal;\r
-    UINT uintVal;\r
-    LARGE_INTEGER hVal;\r
-    ULARGE_INTEGER uhVal;\r
-    VARIANT_BOOL boolVal;\r
-    SCODE scode;\r
-    FILETIME filetime;\r
-    BSTR bstrVal;\r
-  };\r
-} PROPVARIANT;\r
-\r
-typedef PROPVARIANT tagVARIANT;\r
-typedef tagVARIANT VARIANT;\r
-typedef VARIANT VARIANTARG;\r
-\r
-MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);\r
-MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);\r
-MY_EXTERN_C void SysFreeString(BSTR bstr);\r
-MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);\r
-MY_EXTERN_C UINT SysStringLen(BSTR bstr);\r
-\r
-MY_EXTERN_C DWORD GetLastError();\r
-MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);\r
-MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);\r
-MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);\r
-\r
-#define CP_ACP    0\r
-#define CP_OEMCP  1\r
-\r
-typedef enum tagSTREAM_SEEK\r
-{      \r
-  STREAM_SEEK_SET      = 0,\r
-  STREAM_SEEK_CUR      = 1,\r
-  STREAM_SEEK_END      = 2\r
-} STREAM_SEEK;\r
-\r
-#endif\r
-#endif\r
+// MyWindows.h
+
+#ifndef __MYWINDOWS_H
+#define __MYWINDOWS_H
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+#define CHAR_PATH_SEPARATOR '\\'
+#define WCHAR_PATH_SEPARATOR L'\\'
+#define STRING_PATH_SEPARATOR "\\"
+#define WSTRING_PATH_SEPARATOR L"\\"
+
+#else
+
+#define CHAR_PATH_SEPARATOR '/'
+#define WCHAR_PATH_SEPARATOR L'/'
+#define STRING_PATH_SEPARATOR "/"
+#define WSTRING_PATH_SEPARATOR L"/"
+
+#include <stddef.h> // for wchar_t
+#include <string.h>
+
+#include "MyGuidDef.h"
+
+typedef char CHAR;
+typedef unsigned char UCHAR;
+
+#undef BYTE
+typedef unsigned char BYTE;
+
+typedef short SHORT;
+typedef unsigned short USHORT;
+
+#undef WORD
+typedef unsigned short WORD;
+typedef short VARIANT_BOOL;
+
+typedef int INT;
+typedef Int32 INT32;
+typedef unsigned int UINT;
+typedef UInt32 UINT32;
+typedef INT32 LONG;   // LONG, ULONG and DWORD must be 32-bit
+typedef UINT32 ULONG;
+
+#undef DWORD
+typedef UINT32 DWORD;
+
+typedef Int64 LONGLONG;
+typedef UInt64 ULONGLONG;
+
+typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
+typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
+
+typedef const CHAR *LPCSTR;
+typedef CHAR TCHAR;
+typedef const TCHAR *LPCTSTR;
+typedef wchar_t WCHAR;
+typedef WCHAR OLECHAR;
+typedef const WCHAR *LPCWSTR;
+typedef OLECHAR *BSTR;
+typedef const OLECHAR *LPCOLESTR;
+typedef OLECHAR *LPOLESTR;
+
+typedef struct _FILETIME
+{
+  DWORD dwLowDateTime;
+  DWORD dwHighDateTime;
+}FILETIME;
+
+#define HRESULT LONG
+#define FAILED(Status) ((HRESULT)(Status)<0)
+typedef ULONG PROPID;
+typedef LONG SCODE;
+
+#define S_OK    ((HRESULT)0x00000000L)
+#define S_FALSE ((HRESULT)0x00000001L)
+#define E_NOTIMPL ((HRESULT)0x80004001L)
+#define E_NOINTERFACE ((HRESULT)0x80004002L)
+#define E_ABORT ((HRESULT)0x80004004L)
+#define E_FAIL ((HRESULT)0x80004005L)
+#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
+#define E_INVALIDARG ((HRESULT)0x80070057L)
+
+#ifdef _MSC_VER
+#define STDMETHODCALLTYPE __stdcall 
+#else
+#define STDMETHODCALLTYPE 
+#endif
+
+#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
+#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
+#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
+#define STDMETHODIMP STDMETHODIMP_(HRESULT)
+
+#define PURE = 0
+
+#define MIDL_INTERFACE(x) struct 
+
+struct IUnknown
+{
+  //virtual ~IUnknown() {}
+  STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
+  STDMETHOD_(ULONG, AddRef)() PURE;
+  STDMETHOD_(ULONG, Release)() PURE;
+};
+
+typedef IUnknown *LPUNKNOWN;
+
+#define VARIANT_TRUE ((VARIANT_BOOL)-1)
+#define VARIANT_FALSE ((VARIANT_BOOL)0)
+
+enum VARENUM
+{      
+  VT_EMPTY     = 0,
+       VT_NULL = 1,
+       VT_I2   = 2,
+       VT_I4   = 3,
+       VT_R4   = 4,
+       VT_R8   = 5,
+       VT_CY   = 6,
+       VT_DATE = 7,
+       VT_BSTR = 8,
+       VT_DISPATCH     = 9,
+       VT_ERROR        = 10,
+       VT_BOOL = 11,
+       VT_VARIANT      = 12,
+       VT_UNKNOWN      = 13,
+       VT_DECIMAL      = 14,
+       VT_I1   = 16,
+       VT_UI1  = 17,
+       VT_UI2  = 18,
+       VT_UI4  = 19,
+       VT_I8   = 20,
+       VT_UI8  = 21,
+       VT_INT  = 22,
+       VT_UINT = 23,
+       VT_VOID = 24,
+       VT_HRESULT      = 25,
+       VT_FILETIME     = 64
+};
+
+typedef unsigned short VARTYPE;
+typedef WORD PROPVAR_PAD1;
+typedef WORD PROPVAR_PAD2;
+typedef WORD PROPVAR_PAD3;
+
+typedef struct tagPROPVARIANT
+{
+  VARTYPE vt;
+  PROPVAR_PAD1 wReserved1;
+  PROPVAR_PAD2 wReserved2;
+  PROPVAR_PAD3 wReserved3;
+  union 
+  {
+    CHAR cVal;
+    UCHAR bVal;
+    SHORT iVal;
+    USHORT uiVal;
+    LONG lVal;
+    ULONG ulVal;
+    INT intVal;
+    UINT uintVal;
+    LARGE_INTEGER hVal;
+    ULARGE_INTEGER uhVal;
+    VARIANT_BOOL boolVal;
+    SCODE scode;
+    FILETIME filetime;
+    BSTR bstrVal;
+  };
+} PROPVARIANT;
+
+typedef PROPVARIANT tagVARIANT;
+typedef tagVARIANT VARIANT;
+typedef VARIANT VARIANTARG;
+
+MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
+MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
+MY_EXTERN_C void SysFreeString(BSTR bstr);
+MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
+MY_EXTERN_C UINT SysStringLen(BSTR bstr);
+
+MY_EXTERN_C DWORD GetLastError();
+MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
+MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
+MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
+
+#define CP_ACP    0
+#define CP_OEMCP  1
+
+typedef enum tagSTREAM_SEEK
+{      
+  STREAM_SEEK_SET      = 0,
+  STREAM_SEEK_CUR      = 1,
+  STREAM_SEEK_END      = 2
+} STREAM_SEEK;
+
+#endif
+#endif
index 4c1727f8245229df05f1b0a7ec797063641fa483..0619fc69e56b651f8e240572942385a3f3bacf4b 100644 (file)
@@ -1,16 +1,16 @@
-// Common/NewHandler.h\r
-\r
-#ifndef __COMMON_NEWHANDLER_H\r
-#define __COMMON_NEWHANDLER_H\r
-\r
-class CNewException {};\r
-\r
-#ifdef _WIN32\r
-void \r
-#ifdef _MSC_VER\r
-__cdecl \r
-#endif\r
-operator delete(void *p) throw();\r
-#endif \r
-\r
-#endif \r
+// Common/NewHandler.h
+
+#ifndef __COMMON_NEWHANDLER_H
+#define __COMMON_NEWHANDLER_H
+
+class CNewException {};
+
+#ifdef _WIN32
+void 
+#ifdef _MSC_VER
+__cdecl 
+#endif
+operator delete(void *p) throw();
+#endif 
+
+#endif 
index 2547611bd73e50abf84572656d8b02d1847956b8..681ee9356e8fadc216f9074eea584ccfeddb3e29 100644 (file)
@@ -1,9 +1,9 @@
-// StdAfx.h\r
-\r
-#ifndef __STDAFX_H\r
-#define __STDAFX_H\r
-\r
-// #include "MyWindows.h"\r
-#include "NewHandler.h"\r
-\r
-#endif \r
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+// #include "MyWindows.h"
+#include "NewHandler.h"
+
+#endif 
index 52d07081e8d9201e9a10f1df96063926cc104f2e..0bf66e086b95e155a76a5ce2926012e7354c1b0d 100644 (file)
@@ -1,19 +1,19 @@
-// Common/Types.h\r
-\r
-#ifndef __COMMON_TYPES_H\r
-#define __COMMON_TYPES_H\r
-\r
-typedef unsigned char Byte;\r
-typedef short Int16;\r
-typedef unsigned short UInt16;\r
-typedef int Int32;\r
-typedef unsigned int UInt32;\r
-#ifdef _MSC_VER\r
-typedef __int64 Int64;\r
-typedef unsigned __int64 UInt64;\r
-#else\r
-typedef long long int Int64;\r
-typedef unsigned long long int UInt64;\r
-#endif\r
-\r
-#endif\r
+// Common/Types.h
+
+#ifndef __COMMON_TYPES_H
+#define __COMMON_TYPES_H
+
+typedef unsigned char Byte;
+typedef short Int16;
+typedef unsigned short UInt16;
+typedef int Int32;
+typedef unsigned int UInt32;
+#ifdef _MSC_VER
+typedef __int64 Int64;
+typedef unsigned __int64 UInt64;
+#else
+typedef long long int Int64;
+typedef unsigned long long int UInt64;
+#endif
+
+#endif
index f3926a6155f38a803257640da9412ede2015afca..4c3890127d43efcd6383bcc5ecd7a75c2f90e5e4 100644 (file)
-      GNU LESSER GENERAL PUBLIC LICENSE\r
-           Version 2.1, February 1999\r
-\r
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.\r
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- Everyone is permitted to copy and distribute verbatim copies\r
- of this license document, but changing it is not allowed.\r
-\r
-[This is the first released version of the Lesser GPL.  It also counts\r
- as the successor of the GNU Library Public License, version 2, hence\r
- the version number 2.1.]\r
-\r
-          Preamble\r
-\r
-  The licenses for most software are designed to take away your\r
-freedom to share and change it.  By contrast, the GNU General Public\r
-Licenses are intended to guarantee your freedom to share and change\r
-free software--to make sure the software is free for all its users.\r
-\r
-  This license, the Lesser General Public License, applies to some\r
-specially designated software packages--typically libraries--of the\r
-Free Software Foundation and other authors who decide to use it.  You\r
-can use it too, but we suggest you first think carefully about whether\r
-this license or the ordinary General Public License is the better\r
-strategy to use in any particular case, based on the explanations below.\r
-\r
-  When we speak of free software, we are referring to freedom of use,\r
-not price.  Our General Public Licenses are designed to make sure that\r
-you have the freedom to distribute copies of free software (and charge\r
-for this service if you wish); that you receive source code or can get\r
-it if you want it; that you can change the software and use pieces of\r
-it in new free programs; and that you are informed that you can do\r
-these things.\r
-\r
-  To protect your rights, we need to make restrictions that forbid\r
-distributors to deny you these rights or to ask you to surrender these\r
-rights.  These restrictions translate to certain responsibilities for\r
-you if you distribute copies of the library or if you modify it.\r
-\r
-  For example, if you distribute copies of the library, whether gratis\r
-or for a fee, you must give the recipients all the rights that we gave\r
-you.  You must make sure that they, too, receive or can get the source\r
-code.  If you link other code with the library, you must provide\r
-complete object files to the recipients, so that they can relink them\r
-with the library after making changes to the library and recompiling\r
-it.  And you must show them these terms so they know their rights.\r
-\r
-  We protect your rights with a two-step method: (1) we copyright the\r
-library, and (2) we offer you this license, which gives you legal\r
-permission to copy, distribute and/or modify the library.\r
-\r
-  To protect each distributor, we want to make it very clear that\r
-there is no warranty for the free library.  Also, if the library is\r
-modified by someone else and passed on, the recipients should know\r
-that what they have is not the original version, so that the original\r
-author's reputation will not be affected by problems that might be\r
-introduced by others.\r
-\f\r
-  Finally, software patents pose a constant threat to the existence of\r
-any free program.  We wish to make sure that a company cannot\r
-effectively restrict the users of a free program by obtaining a\r
-restrictive license from a patent holder.  Therefore, we insist that\r
-any patent license obtained for a version of the library must be\r
-consistent with the full freedom of use specified in this license.\r
-\r
-  Most GNU software, including some libraries, is covered by the\r
-ordinary GNU General Public License.  This license, the GNU Lesser\r
-General Public License, applies to certain designated libraries, and\r
-is quite different from the ordinary General Public License.  We use\r
-this license for certain libraries in order to permit linking those\r
-libraries into non-free programs.\r
-\r
-  When a program is linked with a library, whether statically or using\r
-a shared library, the combination of the two is legally speaking a\r
-combined work, a derivative of the original library.  The ordinary\r
-General Public License therefore permits such linking only if the\r
-entire combination fits its criteria of freedom.  The Lesser General\r
-Public License permits more lax criteria for linking other code with\r
-the library.\r
-\r
-  We call this license the "Lesser" General Public License because it\r
-does Less to protect the user's freedom than the ordinary General\r
-Public License.  It also provides other free software developers Less\r
-of an advantage over competing non-free programs.  These disadvantages\r
-are the reason we use the ordinary General Public License for many\r
-libraries.  However, the Lesser license provides advantages in certain\r
-special circumstances.\r
-\r
-  For example, on rare occasions, there may be a special need to\r
-encourage the widest possible use of a certain library, so that it becomes\r
-a de-facto standard.  To achieve this, non-free programs must be\r
-allowed to use the library.  A more frequent case is that a free\r
-library does the same job as widely used non-free libraries.  In this\r
-case, there is little to gain by limiting the free library to free\r
-software only, so we use the Lesser General Public License.\r
-\r
-  In other cases, permission to use a particular library in non-free\r
-programs enables a greater number of people to use a large body of\r
-free software.  For example, permission to use the GNU C Library in\r
-non-free programs enables many more people to use the whole GNU\r
-operating system, as well as its variant, the GNU/Linux operating\r
-system.\r
-\r
-  Although the Lesser General Public License is Less protective of the\r
-users' freedom, it does ensure that the user of a program that is\r
-linked with the Library has the freedom and the wherewithal to run\r
-that program using a modified version of the Library.\r
-\r
-  The precise terms and conditions for copying, distribution and\r
-modification follow.  Pay close attention to the difference between a\r
-"work based on the library" and a "work that uses the library".  The\r
-former contains code derived from the library, whereas the latter must\r
-be combined with the library in order to run.\r
-\f\r
-      GNU LESSER GENERAL PUBLIC LICENSE\r
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r
-\r
-  0. This License Agreement applies to any software library or other\r
-program which contains a notice placed by the copyright holder or\r
-other authorized party saying it may be distributed under the terms of\r
-this Lesser General Public License (also called "this License").\r
-Each licensee is addressed as "you".\r
-\r
-  A "library" means a collection of software functions and/or data\r
-prepared so as to be conveniently linked with application programs\r
-(which use some of those functions and data) to form executables.\r
-\r
-  The "Library", below, refers to any such software library or work\r
-which has been distributed under these terms.  A "work based on the\r
-Library" means either the Library or any derivative work under\r
-copyright law: that is to say, a work containing the Library or a\r
-portion of it, either verbatim or with modifications and/or translated\r
-straightforwardly into another language.  (Hereinafter, translation is\r
-included without limitation in the term "modification".)\r
-\r
-  "Source code" for a work means the preferred form of the work for\r
-making modifications to it.  For a library, complete source code means\r
-all the source code for all modules it contains, plus any associated\r
-interface definition files, plus the scripts used to control compilation\r
-and installation of the library.\r
-\r
-  Activities other than copying, distribution and modification are not\r
-covered by this License; they are outside its scope.  The act of\r
-running a program using the Library is not restricted, and output from\r
-such a program is covered only if its contents constitute a work based\r
-on the Library (independent of the use of the Library in a tool for\r
-writing it).  Whether that is true depends on what the Library does\r
-and what the program that uses the Library does.\r
-  \r
-  1. You may copy and distribute verbatim copies of the Library's\r
-complete source code as you receive it, in any medium, provided that\r
-you conspicuously and appropriately publish on each copy an\r
-appropriate copyright notice and disclaimer of warranty; keep intact\r
-all the notices that refer to this License and to the absence of any\r
-warranty; and distribute a copy of this License along with the\r
-Library.\r
-\r
-  You may charge a fee for the physical act of transferring a copy,\r
-and you may at your option offer warranty protection in exchange for a\r
-fee.\r
-\f\r
-  2. You may modify your copy or copies of the Library or any portion\r
-of it, thus forming a work based on the Library, and copy and\r
-distribute such modifications or work under the terms of Section 1\r
-above, provided that you also meet all of these conditions:\r
-\r
-    a) The modified work must itself be a software library.\r
-\r
-    b) You must cause the files modified to carry prominent notices\r
-    stating that you changed the files and the date of any change.\r
-\r
-    c) You must cause the whole of the work to be licensed at no\r
-    charge to all third parties under the terms of this License.\r
-\r
-    d) If a facility in the modified Library refers to a function or a\r
-    table of data to be supplied by an application program that uses\r
-    the facility, other than as an argument passed when the facility\r
-    is invoked, then you must make a good faith effort to ensure that,\r
-    in the event an application does not supply such function or\r
-    table, the facility still operates, and performs whatever part of\r
-    its purpose remains meaningful.\r
-\r
-    (For example, a function in a library to compute square roots has\r
-    a purpose that is entirely well-defined independent of the\r
-    application.  Therefore, Subsection 2d requires that any\r
-    application-supplied function or table used by this function must\r
-    be optional: if the application does not supply it, the square\r
-    root function must still compute square roots.)\r
-\r
-These requirements apply to the modified work as a whole.  If\r
-identifiable sections of that work are not derived from the Library,\r
-and can be reasonably considered independent and separate works in\r
-themselves, then this License, and its terms, do not apply to those\r
-sections when you distribute them as separate works.  But when you\r
-distribute the same sections as part of a whole which is a work based\r
-on the Library, the distribution of the whole must be on the terms of\r
-this License, whose permissions for other licensees extend to the\r
-entire whole, and thus to each and every part regardless of who wrote\r
-it.\r
-\r
-Thus, it is not the intent of this section to claim rights or contest\r
-your rights to work written entirely by you; rather, the intent is to\r
-exercise the right to control the distribution of derivative or\r
-collective works based on the Library.\r
-\r
-In addition, mere aggregation of another work not based on the Library\r
-with the Library (or with a work based on the Library) on a volume of\r
-a storage or distribution medium does not bring the other work under\r
-the scope of this License.\r
-\r
-  3. You may opt to apply the terms of the ordinary GNU General Public\r
-License instead of this License to a given copy of the Library.  To do\r
-this, you must alter all the notices that refer to this License, so\r
-that they refer to the ordinary GNU General Public License, version 2,\r
-instead of to this License.  (If a newer version than version 2 of the\r
-ordinary GNU General Public License has appeared, then you can specify\r
-that version instead if you wish.)  Do not make any other change in\r
-these notices.\r
-\f\r
-  Once this change is made in a given copy, it is irreversible for\r
-that copy, so the ordinary GNU General Public License applies to all\r
-subsequent copies and derivative works made from that copy.\r
-\r
-  This option is useful when you wish to copy part of the code of\r
-the Library into a program that is not a library.\r
-\r
-  4. You may copy and distribute the Library (or a portion or\r
-derivative of it, under Section 2) in object code or executable form\r
-under the terms of Sections 1 and 2 above provided that you accompany\r
-it with the complete corresponding machine-readable source code, which\r
-must be distributed under the terms of Sections 1 and 2 above on a\r
-medium customarily used for software interchange.\r
-\r
-  If distribution of object code is made by offering access to copy\r
-from a designated place, then offering equivalent access to copy the\r
-source code from the same place satisfies the requirement to\r
-distribute the source code, even though third parties are not\r
-compelled to copy the source along with the object code.\r
-\r
-  5. A program that contains no derivative of any portion of the\r
-Library, but is designed to work with the Library by being compiled or\r
-linked with it, is called a "work that uses the Library".  Such a\r
-work, in isolation, is not a derivative work of the Library, and\r
-therefore falls outside the scope of this License.\r
-\r
-  However, linking a "work that uses the Library" with the Library\r
-creates an executable that is a derivative of the Library (because it\r
-contains portions of the Library), rather than a "work that uses the\r
-library".  The executable is therefore covered by this License.\r
-Section 6 states terms for distribution of such executables.\r
-\r
-  When a "work that uses the Library" uses material from a header file\r
-that is part of the Library, the object code for the work may be a\r
-derivative work of the Library even though the source code is not.\r
-Whether this is true is especially significant if the work can be\r
-linked without the Library, or if the work is itself a library.  The\r
-threshold for this to be true is not precisely defined by law.\r
-\r
-  If such an object file uses only numerical parameters, data\r
-structure layouts and accessors, and small macros and small inline\r
-functions (ten lines or less in length), then the use of the object\r
-file is unrestricted, regardless of whether it is legally a derivative\r
-work.  (Executables containing this object code plus portions of the\r
-Library will still fall under Section 6.)\r
-\r
-  Otherwise, if the work is a derivative of the Library, you may\r
-distribute the object code for the work under the terms of Section 6.\r
-Any executables containing that work also fall under Section 6,\r
-whether or not they are linked directly with the Library itself.\r
-\f\r
-  6. As an exception to the Sections above, you may also combine or\r
-link a "work that uses the Library" with the Library to produce a\r
-work containing portions of the Library, and distribute that work\r
-under terms of your choice, provided that the terms permit\r
-modification of the work for the customer's own use and reverse\r
-engineering for debugging such modifications.\r
-\r
-  You must give prominent notice with each copy of the work that the\r
-Library is used in it and that the Library and its use are covered by\r
-this License.  You must supply a copy of this License.  If the work\r
-during execution displays copyright notices, you must include the\r
-copyright notice for the Library among them, as well as a reference\r
-directing the user to the copy of this License.  Also, you must do one\r
-of these things:\r
-\r
-    a) Accompany the work with the complete corresponding\r
-    machine-readable source code for the Library including whatever\r
-    changes were used in the work (which must be distributed under\r
-    Sections 1 and 2 above); and, if the work is an executable linked\r
-    with the Library, with the complete machine-readable "work that\r
-    uses the Library", as object code and/or source code, so that the\r
-    user can modify the Library and then relink to produce a modified\r
-    executable containing the modified Library.  (It is understood\r
-    that the user who changes the contents of definitions files in the\r
-    Library will not necessarily be able to recompile the application\r
-    to use the modified definitions.)\r
-\r
-    b) Use a suitable shared library mechanism for linking with the\r
-    Library.  A suitable mechanism is one that (1) uses at run time a\r
-    copy of the library already present on the user's computer system,\r
-    rather than copying library functions into the executable, and (2)\r
-    will operate properly with a modified version of the library, if\r
-    the user installs one, as long as the modified version is\r
-    interface-compatible with the version that the work was made with.\r
-\r
-    c) Accompany the work with a written offer, valid for at\r
-    least three years, to give the same user the materials\r
-    specified in Subsection 6a, above, for a charge no more\r
-    than the cost of performing this distribution.\r
-\r
-    d) If distribution of the work is made by offering access to copy\r
-    from a designated place, offer equivalent access to copy the above\r
-    specified materials from the same place.\r
-\r
-    e) Verify that the user has already received a copy of these\r
-    materials or that you have already sent this user a copy.\r
-\r
-  For an executable, the required form of the "work that uses the\r
-Library" must include any data and utility programs needed for\r
-reproducing the executable from it.  However, as a special exception,\r
-the materials to be distributed need not include anything that is\r
-normally distributed (in either source or binary form) with the major\r
-components (compiler, kernel, and so on) of the operating system on\r
-which the executable runs, unless that component itself accompanies\r
-the executable.\r
-\r
-  It may happen that this requirement contradicts the license\r
-restrictions of other proprietary libraries that do not normally\r
-accompany the operating system.  Such a contradiction means you cannot\r
-use both them and the Library together in an executable that you\r
-distribute.\r
-\f\r
-  7. You may place library facilities that are a work based on the\r
-Library side-by-side in a single library together with other library\r
-facilities not covered by this License, and distribute such a combined\r
-library, provided that the separate distribution of the work based on\r
-the Library and of the other library facilities is otherwise\r
-permitted, and provided that you do these two things:\r
-\r
-    a) Accompany the combined library with a copy of the same work\r
-    based on the Library, uncombined with any other library\r
-    facilities.  This must be distributed under the terms of the\r
-    Sections above.\r
-\r
-    b) Give prominent notice with the combined library of the fact\r
-    that part of it is a work based on the Library, and explaining\r
-    where to find the accompanying uncombined form of the same work.\r
-\r
-  8. You may not copy, modify, sublicense, link with, or distribute\r
-the Library except as expressly provided under this License.  Any\r
-attempt otherwise to copy, modify, sublicense, link with, or\r
-distribute the Library is void, and will automatically terminate your\r
-rights under this License.  However, parties who have received copies,\r
-or rights, from you under this License will not have their licenses\r
-terminated so long as such parties remain in full compliance.\r
-\r
-  9. You are not required to accept this License, since you have not\r
-signed it.  However, nothing else grants you permission to modify or\r
-distribute the Library or its derivative works.  These actions are\r
-prohibited by law if you do not accept this License.  Therefore, by\r
-modifying or distributing the Library (or any work based on the\r
-Library), you indicate your acceptance of this License to do so, and\r
-all its terms and conditions for copying, distributing or modifying\r
-the Library or works based on it.\r
-\r
-  10. Each time you redistribute the Library (or any work based on the\r
-Library), the recipient automatically receives a license from the\r
-original licensor to copy, distribute, link with or modify the Library\r
-subject to these terms and conditions.  You may not impose any further\r
-restrictions on the recipients' exercise of the rights granted herein.\r
-You are not responsible for enforcing compliance by third parties with\r
-this License.\r
-\f\r
-  11. If, as a consequence of a court judgment or allegation of patent\r
-infringement or for any other reason (not limited to patent issues),\r
-conditions are imposed on you (whether by court order, agreement or\r
-otherwise) that contradict the conditions of this License, they do not\r
-excuse you from the conditions of this License.  If you cannot\r
-distribute so as to satisfy simultaneously your obligations under this\r
-License and any other pertinent obligations, then as a consequence you\r
-may not distribute the Library at all.  For example, if a patent\r
-license would not permit royalty-free redistribution of the Library by\r
-all those who receive copies directly or indirectly through you, then\r
-the only way you could satisfy both it and this License would be to\r
-refrain entirely from distribution of the Library.\r
-\r
-If any portion of this section is held invalid or unenforceable under any\r
-particular circumstance, the balance of the section is intended to apply,\r
-and the section as a whole is intended to apply in other circumstances.\r
-\r
-It is not the purpose of this section to induce you to infringe any\r
-patents or other property right claims or to contest validity of any\r
-such claims; this section has the sole purpose of protecting the\r
-integrity of the free software distribution system which is\r
-implemented by public license practices.  Many people have made\r
-generous contributions to the wide range of software distributed\r
-through that system in reliance on consistent application of that\r
-system; it is up to the author/donor to decide if he or she is willing\r
-to distribute software through any other system and a licensee cannot\r
-impose that choice.\r
-\r
-This section is intended to make thoroughly clear what is believed to\r
-be a consequence of the rest of this License.\r
-\r
-  12. If the distribution and/or use of the Library is restricted in\r
-certain countries either by patents or by copyrighted interfaces, the\r
-original copyright holder who places the Library under this License may add\r
-an explicit geographical distribution limitation excluding those countries,\r
-so that distribution is permitted only in or among countries not thus\r
-excluded.  In such case, this License incorporates the limitation as if\r
-written in the body of this License.\r
-\r
-  13. The Free Software Foundation may publish revised and/or new\r
-versions of the Lesser General Public License from time to time.\r
-Such new versions will be similar in spirit to the present version,\r
-but may differ in detail to address new problems or concerns.\r
-\r
-Each version is given a distinguishing version number.  If the Library\r
-specifies a version number of this License which applies to it and\r
-"any later version", you have the option of following the terms and\r
-conditions either of that version or of any later version published by\r
-the Free Software Foundation.  If the Library does not specify a\r
-license version number, you may choose any version ever published by\r
-the Free Software Foundation.\r
-\f\r
-  14. If you wish to incorporate parts of the Library into other free\r
-programs whose distribution conditions are incompatible with these,\r
-write to the author to ask for permission.  For software which is\r
-copyrighted by the Free Software Foundation, write to the Free\r
-Software Foundation; we sometimes make exceptions for this.  Our\r
-decision will be guided by the two goals of preserving the free status\r
-of all derivatives of our free software and of promoting the sharing\r
-and reuse of software generally.\r
-\r
-          NO WARRANTY\r
-\r
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\r
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\r
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\r
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY\r
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\r
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\r
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\r
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r
-\r
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\r
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\r
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\r
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\r
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\r
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\r
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\r
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\r
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
-DAMAGES.\r
-\r
-         END OF TERMS AND CONDITIONS\r
-\f\r
-           How to Apply These Terms to Your New Libraries\r
-\r
-  If you develop a new library, and you want it to be of the greatest\r
-possible use to the public, we recommend making it free software that\r
-everyone can redistribute and change.  You can do so by permitting\r
-redistribution under these terms (or, alternatively, under the terms of the\r
-ordinary General Public License).\r
-\r
-  To apply these terms, attach the following notices to the library.  It is\r
-safest to attach them to the start of each source file to most effectively\r
-convey the exclusion of warranty; and each file should have at least the\r
-"copyright" line and a pointer to where the full notice is found.\r
-\r
-    <one line to give the library's name and a brief idea of what it does.>\r
-    Copyright (C) <year>  <name of author>\r
-\r
-    This library is free software; you can redistribute it and/or\r
-    modify it under the terms of the GNU Lesser General Public\r
-    License as published by the Free Software Foundation; either\r
-    version 2.1 of the License, or (at your option) any later version.\r
-\r
-    This library is distributed in the hope that it will be useful,\r
-    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-    Lesser General Public License for more details.\r
-\r
-    You should have received a copy of the GNU Lesser General Public\r
-    License along with this library; if not, write to the Free Software\r
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-\r
-Also add information on how to contact you by electronic and paper mail.\r
-\r
-You should also get your employer (if you work as a programmer) or your\r
-school, if any, to sign a "copyright disclaimer" for the library, if\r
-necessary.  Here is a sample; alter the names:\r
-\r
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the\r
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.\r
-\r
-  <signature of Ty Coon>, 1 April 1990\r
-  Ty Coon, President of Vice\r
-\r
-That's all there is to it!\r
-\r
-\r
+      GNU LESSER GENERAL PUBLIC LICENSE
+           Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+      GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+          NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+         END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+