Initial Commit.

This commit is contained in:
Moinak Ghosh 2012-05-28 20:19:29 +05:30
parent 10e0a75b67
commit 07dfed7769
39 changed files with 12942 additions and 0 deletions

459
COPYING.LESSER Normal file
View file

@ -0,0 +1,459 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
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.
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.
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.
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.
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.
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.
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.
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

70
Makefile Normal file
View file

@ -0,0 +1,70 @@
#
# This file is a part of Pcompress, a chunked parallel multi-
# algorithm lossless compression and decompression program.
#
# Copyright (C) 2012 Moinak Ghosh. All rights reserved.
# Use is subject to license terms.
#
# This program 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 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
# Lesser General Public License for more details.
#
# moinakg@belenix.org, http://moinakg.wordpress.com/
#
# This program includes partly-modified public domain source
# code from the LZMA SDK: http://www.7-zip.org/sdk.html
#
PROG= pcompress
MAINSRCS= main.c utils.c allocator.c zlib_compress.c bzip2_compress.c \
lzma_compress.c ppmd_compress.c adaptive_compress.c
MAINOBJS = $(MAINSRCS:.c=.o)
LZMASRCS = lzma/LzmaEnc.c lzma/LzFind.c lzma/LzmaDec.c
LZMAOBJS = $(LZMASRCS:.c=.o)
PPMDSRCS = lzma/Ppmd8.c lzma/Ppmd8Enc.c lzma/Ppmd8Dec.c
PPMDHDRS = lzma/Ppmd.h lzma/Ppmd8.h
PPMDOBJS = $(PPMDSRCS:.c=.o)
CRCSRCS = lzma/crc64_fast.c lzma/crc64_table.c
CRCOBJS = $(CRCSRCS:.c=.o)
BAKFILES = *~ lzma/*~
RM = rm -f
CPPFLAGS = -I. -I./lzma -D_7ZIP_ST -DNODEFAULT_PROPS -DFILE_OFFSET_BITS=64 \
-D_REENTRANT -D__USE_SSE_INTRIN__ -DNDEBUG -D_LZMA_PROB32
VEC_FLAGS = -ftree-vectorize
LOOP_OPTFLAGS = $(VEC_FLAGS) -floop-interchange -floop-block
LDLIBS = -ldl -lbz2 $(ZLIB_DIR) -lz -lm
LINK = gcc -m64 -pthread -msse3
COMPILE = gcc -m64 -O3 -msse3 -c
all: $(PROG)
$(LZMAOBJS): $(LZMASRCS)
$(COMPILE) $(CPPFLAGS) $(@:.o=.c) -o $@
$(CRCOBJS): $(CRCSRCS)
$(COMPILE) $(VEC_FLAGS) $(CPPFLAGS) $(@:.o=.c) -o $@
$(PPMDOBJS): $(PPMDSRCS) $(PPMDHDRS)
$(COMPILE) $(VEC_FLAGS) $(CPPFLAGS) $(@:.o=.c) -o $@
$(MAINOBJS): $(MAINSRCS)
$(COMPILE) $(LOOP_OPTFLAGS) $(CPPFLAGS) $(@:.o=.c) -o $@
$(PROG): $(MAINOBJS) $(LZMAOBJS) $(PPMDOBJS) $(CRCOBJS)
$(LINK) -o $@ $(MAINOBJS) $(LZMAOBJS) $(PPMDOBJS) $(CRCOBJS) $(LDLIBS)
clean:
$(RM) $(PROG) $(MAINOBJS) $(LZMAOBJS) $(PPMDOBJS) $(CRCOBJS) $(BAKFILES)

189
adaptive_compress.c Normal file
View file

@ -0,0 +1,189 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <byteswap.h>
#include <utils.h>
#include <pcompress.h>
#include <allocator.h>
extern int lzma_compress(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
extern int bzip2_compress(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
extern int ppmd_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int lzma_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int bzip2_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int ppmd_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int lzma_init(void **data, int *level, ssize_t chunksize);
extern int lzma_deinit(void **data);
extern int ppmd_init(void **data, int *level, ssize_t chunksize);
extern int ppmd_deinit(void **data);
struct adapt_data {
void *lzma_data;
void *ppmd_data;
int adapt_mode;
};
int
adapt_init(void **data, int *level, ssize_t chunksize)
{
struct adapt_data *adat = (struct adapt_data *)(*data);
int rv;
if (!adat) {
adat = (struct adapt_data *)slab_alloc(NULL, sizeof (struct adapt_data));
adat->adapt_mode = 1;
adat->ppmd_data = NULL;
rv = lzma_init(&(adat->lzma_data), level, chunksize);
*data = adat;
if (*level > 9) *level = 9;
}
return (rv);
}
int
adapt2_init(void **data, int *level, ssize_t chunksize)
{
struct adapt_data *adat = (struct adapt_data *)(*data);
int rv, lv;
if (!adat) {
adat = (struct adapt_data *)slab_alloc(NULL, sizeof (struct adapt_data));
adat->adapt_mode = 2;
adat->ppmd_data = NULL;
lv = *level;
rv = lzma_init(&(adat->lzma_data), &lv, chunksize);
lv = *level;
if (rv == 0)
ppmd_init(&(adat->ppmd_data), &lv, chunksize);
*data = adat;
if (*level > 9) *level = 9;
}
return (rv);
}
int
adapt_deinit(void **data)
{
struct adapt_data *adat = (struct adapt_data *)(*data);
int rv;
if (adat) {
rv = lzma_deinit(&(adat->lzma_data));
if (adat->ppmd_data)
rv += ppmd_deinit(&(adat->ppmd_data));
slab_free(NULL, adat);
*data = NULL;
}
return (rv);
}
int
adapt_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
struct adapt_data *adat = (struct adapt_data *)(data);
int rv, rv1, rv2;
size_t dst2len, dst3len, smaller_dstlen;
uchar_t *dst2, *smaller_dst, *larger_dst;
void *tmp;
dst2 = slab_alloc(NULL, *dstlen);
if (!dst2) {
fprintf(stderr, "Adapt: Out of memory\n");
return (-1);
}
rv = COMPRESS_LZMA;
dst2len = *dstlen;
dst3len = *dstlen;
rv1 = bzip2_compress(src, srclen, dst2, &dst2len, level, data);
if (rv1 < 0) dst2len = dst3len;
rv2 = lzma_compress(src, srclen, dst, dstlen, level, adat->lzma_data);
if (rv2 < 0) *dstlen = dst3len;
if (dst2len < *dstlen) {
rv = COMPRESS_BZIP2;
larger_dst = dst;
smaller_dstlen = dst2len;
smaller_dst = dst2;
} else {
larger_dst = dst2;
smaller_dstlen = *dstlen;
smaller_dst = dst;
}
if (adat->adapt_mode == 2) {
rv2 = ppmd_compress(src, srclen, larger_dst, &dst2len,
level, adat->ppmd_data);
if (rv2 < 0) dst2len = dst3len;
if (dst2len < smaller_dstlen) {
rv = COMPRESS_PPMD;
smaller_dstlen = dst2len;
smaller_dst = larger_dst;
}
}
if (smaller_dst != dst) {
memcpy(dst, smaller_dst, smaller_dstlen);
*dstlen = smaller_dstlen;
}
slab_free(NULL, dst2);
return (rv);
}
int
adapt_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
struct adapt_data *adat = (struct adapt_data *)(data);
uchar_t HDR;
HDR = *((uchar_t *)src);
if (HDR & (COMPRESS_LZMA << 4)) {
return (lzma_decompress(src, srclen, dst, dstlen, level, adat->lzma_data));
} else if (HDR & (COMPRESS_BZIP2 << 4)) {
return (bzip2_decompress(src, srclen, dst, dstlen, level, NULL));
} else if (HDR & (COMPRESS_PPMD << 4)) {
return (ppmd_decompress(src, srclen, dst, dstlen, level, adat->ppmd_data));
} else {
fprintf(stderr, "Unrecognized compression mode, file corrupt.\n");
}
return (-1);
}

396
allocator.c Normal file
View file

@ -0,0 +1,396 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
/*
* A basic slab allocator that uses power of 2 and fixed interval
* slab sizes and uses integer hashing to track pointers. It uses
* per-slab and per-hash-bucket locking for scalability. This
* allocator is being used in Pcompress as repeated compression of
* fixed-size chunks causes repeated and predictable memory allocation
* and freeing patterns. Using pre-allocated buffer pools in this
* case causes significant speedup.
*
* There is no provision yet to reap buffers from high-usage slabs
* and return them to the heap.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <pthread.h>
#include <math.h>
#include "utils.h"
#include "allocator.h"
/*
* Number of slabs:
* 256 bytes to 1M in power of 2 steps: 13
* 1M to 256M in linear steps of 1M: 256
*
* By doing this we try to get reasonable memory usage while not
* sacrificing performance.
*/
#define NUM_SLABS 269
#define NUM_POW2 13
#define SLAB_START 256
#define SLAB_START_POW2 8 /* 2 ^ SLAB_START_POW2 = SLAB_START. */
#define HTABLE_SZ 16384
#define TWOM (2UL * 1024UL * 1024UL)
#define ONEM (1UL * 1024UL * 1024UL)
static const unsigned int bv[] = {
0xAAAAAAAA,
0xCCCCCCCC,
0xF0F0F0F0,
0xFF00FF00,
0xFFFF0000
};
struct bufentry {
void *ptr;
int slab_index;
struct bufentry *next;
};
struct slabentry {
struct bufentry *avail;
struct bufentry *used;
size_t sz;
uint64_t allocs, hits;
pthread_mutex_t slab_lock;
};
static struct slabentry slabheads[NUM_SLABS];
static struct bufentry **htable;
static pthread_mutex_t *hbucket_locks;
static pthread_mutex_t htable_lock = PTHREAD_MUTEX_INITIALIZER;
static int inited = 0;
static uint64_t total_allocs, oversize_allocs, hash_collisions, hash_entries;
/*
* Hash function for 64Bit pointers that generates a 32Bit hash value.
* Taken from Thomas Wang's Integer hashing paper:
* http://www.cris.com/~Ttwang/tech/inthash.htm
*/
uint32_t
hash6432shift(uint64_t key)
{
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
key = key ^ (key >> 31);
key = key * 21; // key = (key + (key << 2)) + (key << 4);
key = key ^ (key >> 11);
key = key + (key << 6);
key = key ^ (key >> 22);
return (uint32_t) key;
}
void
slab_init()
{
int i;
size_t slab_sz;
int nprocs;
/* Initialize first NUM_POW2 power of 2 slots. */
slab_sz = SLAB_START;
for (i = 0; i < NUM_POW2; i++) {
slabheads[i].avail = NULL;
slabheads[i].used = NULL;
slabheads[i].sz = slab_sz;
slabheads[i].allocs = 0;
slabheads[i].hits = 0;
/* Speed up: Copy from already inited but not yet used lock object. */
slabheads[i].slab_lock = htable_lock;
slab_sz *= 2;
}
/* At this point slab_sz is 2M. So linear slots start at 2M. */
for (i = NUM_POW2; i < NUM_SLABS; i++) {
slabheads[i].avail = NULL;
slabheads[i].used = NULL;
slabheads[i].sz = slab_sz;
slabheads[i].allocs = 0;
slabheads[i].hits = 0;
/* Speed up: Copy from already inited but not yet used lock object. */
slabheads[i].slab_lock = htable_lock;
slab_sz += ONEM;
}
htable = (struct bufentry **)calloc(HTABLE_SZ, sizeof (struct bufentry *));
hbucket_locks = (pthread_mutex_t *)malloc(HTABLE_SZ * sizeof (pthread_mutex_t));
for (i=0; i<HTABLE_SZ; i++)
hbucket_locks[i] = htable_lock;
total_allocs = 0;
oversize_allocs = 0;
hash_collisions = 0;
hash_entries = 0;
inited = 1;
}
void
slab_cleanup(int quiet)
{
int i;
struct bufentry *buf, *buf1;
uint64_t nonfreed_oversize;
if (!inited) return;
if (!quiet) {
fprintf(stderr, "Slab Allocation Stats\n");
fprintf(stderr, "==================================================================\n");
fprintf(stderr, " Slab Size | Allocations | Hits |\n");
fprintf(stderr, "==================================================================\n");
}
for (i=0; i<NUM_SLABS; i++)
{
if (slabheads[i].avail) {
if (!quiet) {
fprintf(stderr, "%21llu %21llu %21llu\n",slabheads[i].sz,
slabheads[i].allocs, slabheads[i].hits);
}
slabheads[i].allocs = 0;
buf = slabheads[i].avail;
do {
buf1 = buf->next;
free(buf->ptr);
free(buf);
buf = buf1;
} while (buf);
}
}
if (!quiet) {
fprintf(stderr, "==================================================================\n");
fprintf(stderr, "Oversize Allocations : %llu\n", oversize_allocs);
fprintf(stderr, "Total Requests : %llu\n", total_allocs);
fprintf(stderr, "Hash collisions : %llu\n", hash_collisions);
fprintf(stderr, "Leaked allocations : %llu\n", hash_entries);
}
if (hash_entries > 0) {
nonfreed_oversize = 0;
for (i=0; i<HTABLE_SZ; i++) {
buf = htable[i];
while (buf) {
if (buf->slab_index == -1) {
nonfreed_oversize++;
} else {
slabheads[buf->slab_index].allocs++;
}
buf1 = buf->next;
free(buf->ptr);
free(buf);
buf = buf1;
}
}
free(htable);
free(hbucket_locks);
if (!quiet) {
fprintf(stderr, "==================================================================\n");
fprintf(stderr, " Slab Size | Allocations: leaked |\n");
fprintf(stderr, "==================================================================\n");
for (i=0; i<NUM_SLABS; i++)
{
if (slabheads[i].allocs == 0) continue;
fprintf(stderr, "%21llu %21llu\n",slabheads[i].sz, slabheads[i].allocs);
}
}
}
if (!quiet) fprintf(stderr, "\n\n");
}
void *
slab_calloc(void *p, size_t items, size_t size) {
void *ptr;
ptr = slab_alloc(p, items * size);
memset(ptr, 0, items * size);
return (ptr);
}
/*
* Find the power of 2 slab slot which will hold a given size.
*/
static unsigned int
find_slot(unsigned int v)
{
unsigned int r, i;
/* Round up to nearest power of 2 */
v = roundup_pow_two(v);
/*
* Get the log2 of the above. From Bit Twiddling Hacks:
* http://graphics.stanford.edu/~seander/bithacks.html
*
* This essentially tells us which bit is set.
*/
r = (v & bv[0]) != 0;
r |= ((v & bv[4]) != 0) << 4;
r |= ((v & bv[3]) != 0) << 3;
r |= ((v & bv[2]) != 0) << 2;
r |= ((v & bv[1]) != 0) << 1;
/* Rebase to starting power of 2 slot number. */
if (r > SLAB_START_POW2)
r -= SLAB_START_POW2;
else
r = 0;
return (r);
}
void *
slab_alloc(void *p, size_t size)
{
size_t slab_sz = SLAB_START;
int i, found;
size_t div;
ATOMIC_ADD(total_allocs, 1);
found = -1;
if (size <= ONEM) {
/* First eleven slots are power of 2 sizes upto 1M. */
found = find_slot(size);
} else {
/* Next slots are in intervals of 1M. */
div = size / ONEM;
if (size % ONEM) div++;
if (div < NUM_SLABS) found = div + NUM_POW2;
}
if (found == -1) {
struct bufentry *buf = (struct bufentry *)malloc(sizeof (struct bufentry));
uint32_t hindx;
buf->ptr = malloc(size);
buf->slab_index = -1;
hindx = hash6432shift((unsigned long)(buf->ptr)) & (HTABLE_SZ - 1);
pthread_mutex_lock(&hbucket_locks[hindx]);
buf->next = htable[hindx];
htable[hindx] = buf;
pthread_mutex_unlock(&hbucket_locks[hindx]);
ATOMIC_ADD(oversize_allocs, 1);
return (buf->ptr);
} else {
struct bufentry *buf;
uint32_t hindx;
pthread_mutex_lock(&(slabheads[found].slab_lock));
if (slabheads[found].avail == NULL) {
slabheads[found].allocs++;
pthread_mutex_unlock(&(slabheads[found].slab_lock));
buf = (struct bufentry *)malloc(sizeof (struct bufentry));
buf->ptr = malloc(slabheads[found].sz);
buf->slab_index = found;
hindx = hash6432shift((unsigned long)(buf->ptr)) & (HTABLE_SZ - 1);
if (htable[hindx]) ATOMIC_ADD(hash_collisions, 1);
pthread_mutex_lock(&hbucket_locks[hindx]);
buf->next = htable[hindx];
htable[hindx] = buf;
pthread_mutex_unlock(&hbucket_locks[hindx]);
ATOMIC_ADD(hash_entries, 1);
} else {
buf = slabheads[found].avail;
slabheads[found].avail = buf->next;
slabheads[found].hits++;
pthread_mutex_unlock(&(slabheads[found].slab_lock));
hindx = hash6432shift((unsigned long)(buf->ptr)) & (HTABLE_SZ - 1);
if (htable[hindx]) ATOMIC_ADD(hash_collisions, 1);
pthread_mutex_lock(&hbucket_locks[hindx]);
buf->next = htable[hindx];
htable[hindx] = buf;
pthread_mutex_unlock(&hbucket_locks[hindx]);
ATOMIC_ADD(hash_entries, 1);
}
return (buf->ptr);
}
}
void
slab_free(void *p, void *address)
{
struct bufentry *buf, *pbuf;
int found = 0;
uint32_t hindx;
if (!address) return;
hindx = hash6432shift((uint64_t)(address)) & (HTABLE_SZ - 1);
pthread_mutex_lock(&hbucket_locks[hindx]);
buf = htable[hindx];
pbuf = NULL;
while (buf) {
if (buf->ptr == address) {
if (buf->slab_index == -1) {
if (pbuf)
pbuf->next = buf->next;
else
htable[hindx] = buf->next;
pthread_mutex_unlock(&hbucket_locks[hindx]);
ATOMIC_SUB(hash_entries, 1);
free(buf->ptr);
free(buf);
found = 1;
break;
} else {
if (pbuf)
pbuf->next = buf->next;
else
htable[hindx] = buf->next;
pthread_mutex_unlock(&hbucket_locks[hindx]);
ATOMIC_SUB(hash_entries, 1);
pthread_mutex_lock(&(slabheads[buf->slab_index].slab_lock));
buf->next = slabheads[buf->slab_index].avail;
slabheads[buf->slab_index].avail = buf;
pthread_mutex_unlock(&(slabheads[buf->slab_index].slab_lock));
found = 1;
break;
}
}
pbuf = buf;
buf = buf->next;
}
if (!found) {
pthread_mutex_unlock(&hbucket_locks[hindx]);
free(address);
fprintf(stderr, "Freed buf(%p) not in slab allocations!\n", address);
fflush(stderr);
}
}

34
allocator.h Normal file
View file

@ -0,0 +1,34 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#ifndef __ALLOCATOR_H__
#define __ALLOCATOR_H__
void slab_init();
void slab_cleanup(int quiet);
void *slab_alloc(void *p, size_t size);
void *slab_calloc(void *p, size_t items, size_t size);
void slab_free(void *p, void *address);
#endif

154
bzip2_compress.c Normal file
View file

@ -0,0 +1,154 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <sys/types.h>
#include <stdio.h>
#include <strings.h>
#include <bzlib.h>
#include <utils.h>
#include <pcompress.h>
#include <allocator.h>
static void *
slab_alloc_i(void *p, int items, int size) {
void *ptr;
size_t tot = (size_t)items * (size_t)size;
ptr = slab_alloc(p, tot);
return (ptr);
}
int
bzip2_init(void **data, int *level, ssize_t chunksize)
{
if (*level > 9) *level = 9;
return (0);
}
static void
bzerr(int err)
{
switch (err) {
case BZ_SEQUENCE_ERROR:
fprintf(stderr, "Bzip2: Call sequence error, buggy code ?\n");
break;
case BZ_PARAM_ERROR:
fprintf(stderr, "Bzip2: Invalid parameter\n");
break;
case BZ_MEM_ERROR:
fprintf(stderr, "Bzip2: Out of memory\n");
break;
case BZ_DATA_ERROR:
fprintf(stderr, "Bzip2: Data integrity checksum error\n");
break;
case BZ_DATA_ERROR_MAGIC:
fprintf(stderr, "Bzip2: Invalid magic number in compressed buf\n");
break;
case BZ_OUTBUFF_FULL:
fprintf(stderr, "Bzip2: Output buffer overflow\n");
break;
case BZ_CONFIG_ERROR:
fprintf(stderr, "Bzip2: Improper library config on platform\n");
break;
default:
fprintf(stderr, "Bzip2: Unknown error code: %d\n", err);
}
}
int
bzip2_compress(void *src, size_t srclen, void *dst, size_t *dstlen, int level, void *data)
{
bz_stream bzs;
int ret;
unsigned int _dstlen;
bzs.bzalloc = slab_alloc_i;
bzs.bzfree = slab_free;
bzs.opaque = NULL;
ret = BZ2_bzCompressInit(&bzs, level, 0, 30);
if (ret != BZ_OK) {
bzerr(ret);
return (-1);
}
bzs.next_in = src;
bzs.avail_in = srclen;
bzs.next_out = dst;
bzs.avail_out = *dstlen;
ret = BZ2_bzCompress(&bzs, BZ_FINISH);
if (ret == BZ_FINISH_OK) {
BZ2_bzCompressEnd(&bzs);
return (-1);
}
if (ret != BZ_STREAM_END) {
BZ2_bzCompressEnd(&bzs);
bzerr(ret);
return (-1);
}
/* normal termination */
*dstlen -= bzs.avail_out;
BZ2_bzCompressEnd(&bzs);
return (0);
}
int
bzip2_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, int level, void *data)
{
bz_stream bzs;
int ret;
bzs.bzalloc = slab_alloc_i;
bzs.bzfree = slab_free;
bzs.opaque = NULL;
ret = BZ2_bzDecompressInit(&bzs, 0, 0);
if (ret != BZ_OK) {
bzerr(ret);
return (-1);
}
bzs.next_in = (uchar_t *)src + CHDR_SZ;
bzs.avail_in = srclen;
bzs.next_out = dst;
bzs.avail_out = *dstlen;
ret = BZ2_bzDecompress(&bzs);
if (ret == BZ_FINISH_OK) {
BZ2_bzDecompressEnd(&bzs);
bzerr(ret);
return (-1);
}
if (ret != BZ_STREAM_END) {
BZ2_bzDecompressEnd(&bzs);
bzerr(ret);
return (-1);
}
/* normal termination */
*dstlen -= bzs.avail_out;
BZ2_bzDecompressEnd(&bzs);
return (0);
}

168
lzma/CpuArch.c Executable file
View file

@ -0,0 +1,168 @@
/* CpuArch.c -- CPU specific code
2010-10-26: Igor Pavlov : Public domain */
#include "CpuArch.h"
#ifdef MY_CPU_X86_OR_AMD64
#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__)
#define USE_ASM
#endif
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
static UInt32 CheckFlag(UInt32 flag)
{
#ifdef _MSC_VER
__asm pushfd;
__asm pop EAX;
__asm mov EDX, EAX;
__asm xor EAX, flag;
__asm push EAX;
__asm popfd;
__asm pushfd;
__asm pop EAX;
__asm xor EAX, EDX;
__asm push EDX;
__asm popfd;
__asm and flag, EAX;
#else
__asm__ __volatile__ (
"pushf\n\t"
"pop %%EAX\n\t"
"movl %%EAX,%%EDX\n\t"
"xorl %0,%%EAX\n\t"
"push %%EAX\n\t"
"popf\n\t"
"pushf\n\t"
"pop %%EAX\n\t"
"xorl %%EDX,%%EAX\n\t"
"push %%EDX\n\t"
"popf\n\t"
"andl %%EAX, %0\n\t":
"=c" (flag) : "c" (flag));
#endif
return flag;
}
#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False;
#else
#define CHECK_CPUID_IS_SUPPORTED
#endif
static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
{
#ifdef USE_ASM
#ifdef _MSC_VER
UInt32 a2, b2, c2, d2;
__asm xor EBX, EBX;
__asm xor ECX, ECX;
__asm xor EDX, EDX;
__asm mov EAX, function;
__asm cpuid;
__asm mov a2, EAX;
__asm mov b2, EBX;
__asm mov c2, ECX;
__asm mov d2, EDX;
*a = a2;
*b = b2;
*c = c2;
*d = d2;
#else
__asm__ __volatile__ (
"cpuid"
: "=a" (*a) ,
"=b" (*b) ,
"=c" (*c) ,
"=d" (*d)
: "0" (function)) ;
#endif
#else
int CPUInfo[4];
__cpuid(CPUInfo, function);
*a = CPUInfo[0];
*b = CPUInfo[1];
*c = CPUInfo[2];
*d = CPUInfo[3];
#endif
}
Bool x86cpuid_CheckAndRead(Cx86cpuid *p)
{
CHECK_CPUID_IS_SUPPORTED
MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);
MyCPUID(1, &p->ver, &p->b, &p->c, &p->d);
return True;
}
static UInt32 kVendors[][3] =
{
{ 0x756E6547, 0x49656E69, 0x6C65746E},
{ 0x68747541, 0x69746E65, 0x444D4163},
{ 0x746E6543, 0x48727561, 0x736C7561}
};
int x86cpuid_GetFirm(const Cx86cpuid *p)
{
unsigned i;
for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++)
{
const UInt32 *v = kVendors[i];
if (v[0] == p->vendor[0] &&
v[1] == p->vendor[1] &&
v[2] == p->vendor[2])
return (int)i;
}
return -1;
}
Bool CPU_Is_InOrder()
{
Cx86cpuid p;
int firm;
UInt32 family, model;
if (!x86cpuid_CheckAndRead(&p))
return True;
family = x86cpuid_GetFamily(&p);
model = x86cpuid_GetModel(&p);
firm = x86cpuid_GetFirm(&p);
switch (firm)
{
case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && model == 0x100C));
case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
}
return True;
}
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
static Bool CPU_Sys_Is_SSE_Supported()
{
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!GetVersionEx(&vi))
return False;
return (vi.dwMajorVersion >= 5);
}
#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False;
#else
#define CHECK_SYS_SSE_SUPPORT
#endif
Bool CPU_Is_Aes_Supported()
{
Cx86cpuid p;
CHECK_SYS_SSE_SUPPORT
if (!x86cpuid_CheckAndRead(&p))
return False;
return (p.c >> 25) & 1;
}
#endif

155
lzma/CpuArch.h Executable file
View file

@ -0,0 +1,155 @@
/* CpuArch.h -- CPU specific code
2010-10-26: Igor Pavlov : Public domain */
#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
#include "Types.h"
EXTERN_C_BEGIN
/*
MY_CPU_LE means that CPU is LITTLE ENDIAN.
If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN).
MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform.
*/
#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__)
#define MY_CPU_AMD64
#endif
#if defined(MY_CPU_AMD64) || defined(_M_IA64)
#define MY_CPU_64BIT
#endif
#if defined(_M_IX86) || defined(__i386__)
#define MY_CPU_X86
#endif
#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)
#define MY_CPU_X86_OR_AMD64
#endif
#if defined(MY_CPU_X86) || defined(_M_ARM)
#define MY_CPU_32BIT
#endif
#if defined(_WIN32) && defined(_M_ARM)
#define MY_CPU_ARM_LE
#endif
#if defined(_WIN32) && defined(_M_IA64)
#define MY_CPU_IA64_LE
#endif
#if defined(MY_CPU_X86_OR_AMD64)
#define MY_CPU_LE_UNALIGN
#endif
#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__)
#define MY_CPU_LE
#endif
#if defined(__BIG_ENDIAN__)
#define MY_CPU_BE
#endif
#if defined(MY_CPU_LE) && defined(MY_CPU_BE)
Stop_Compiling_Bad_Endian
#endif
#ifdef MY_CPU_LE_UNALIGN
#define GetUi16(p) (*(const UInt16 *)(p))
#define GetUi32(p) (*(const UInt32 *)(p))
#define GetUi64(p) (*(const UInt64 *)(p))
#define SetUi16(p, d) *(UInt16 *)(p) = (d);
#define SetUi32(p, d) *(UInt32 *)(p) = (d);
#define SetUi64(p, d) *(UInt64 *)(p) = (d);
#else
#define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8))
#define GetUi32(p) ( \
((const Byte *)(p))[0] | \
((UInt32)((const Byte *)(p))[1] << 8) | \
((UInt32)((const Byte *)(p))[2] << 16) | \
((UInt32)((const Byte *)(p))[3] << 24))
#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
#define SetUi16(p, d) { UInt32 _x_ = (d); \
((Byte *)(p))[0] = (Byte)_x_; \
((Byte *)(p))[1] = (Byte)(_x_ >> 8); }
#define SetUi32(p, d) { UInt32 _x_ = (d); \
((Byte *)(p))[0] = (Byte)_x_; \
((Byte *)(p))[1] = (Byte)(_x_ >> 8); \
((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
#define SetUi64(p, d) { UInt64 _x64_ = (d); \
SetUi32(p, (UInt32)_x64_); \
SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); }
#endif
#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
#else
#define GetBe32(p) ( \
((UInt32)((const Byte *)(p))[0] << 24) | \
((UInt32)((const Byte *)(p))[1] << 16) | \
((UInt32)((const Byte *)(p))[2] << 8) | \
((const Byte *)(p))[3] )
#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
#endif
#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1])
#ifdef MY_CPU_X86_OR_AMD64
typedef struct
{
UInt32 maxFunc;
UInt32 vendor[3];
UInt32 ver;
UInt32 b;
UInt32 c;
UInt32 d;
} Cx86cpuid;
enum
{
CPU_FIRM_INTEL,
CPU_FIRM_AMD,
CPU_FIRM_VIA
};
Bool x86cpuid_CheckAndRead(Cx86cpuid *p);
int x86cpuid_GetFirm(const Cx86cpuid *p);
#define x86cpuid_GetFamily(p) (((p)->ver >> 8) & 0xFF00F)
#define x86cpuid_GetModel(p) (((p)->ver >> 4) & 0xF00F)
#define x86cpuid_GetStepping(p) ((p)->ver & 0xF)
Bool CPU_Is_InOrder();
Bool CPU_Is_Aes_Supported();
#endif
EXTERN_C_END
#endif

856
lzma/LzFind.c Normal file
View file

@ -0,0 +1,856 @@
/* LzFind.c -- Match finder for LZ algorithms
2009-04-22 : Igor Pavlov : Public domain */
#include <string.h>
#ifdef __USE_SSE_INTRIN__
#include <emmintrin.h>
#endif
#include "LzFind.h"
#include "LzHash.h"
#define kEmptyHashValue 0
#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
#define kNormalizeMask (~(kNormalizeStepMin - 1))
#define kMaxHistorySize ((UInt32)3 << 30)
#define kStartMaxLen 3
static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
{
if (!p->directInput)
{
alloc->Free(alloc, p->bufferBase);
p->bufferBase = 0;
}
}
/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
{
UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
if (p->directInput)
{
p->blockSize = blockSize;
return 1;
}
if (p->bufferBase == 0 || p->blockSize != blockSize)
{
LzInWindow_Free(p, alloc);
p->blockSize = blockSize;
p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
}
return (p->bufferBase != 0);
}
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
{
p->posLimit -= subValue;
p->pos -= subValue;
p->streamPos -= subValue;
}
static void MatchFinder_ReadBlock(CMatchFinder *p)
{
if (p->streamEndWasReached || p->result != SZ_OK)
return;
if (p->directInput)
{
UInt32 curSize = 0xFFFFFFFF - p->streamPos;
if (curSize > p->directInputRem)
curSize = (UInt32)p->directInputRem;
p->directInputRem -= curSize;
p->streamPos += curSize;
if (p->directInputRem == 0)
p->streamEndWasReached = 1;
return;
}
for (;;)
{
Byte *dest = p->buffer + (p->streamPos - p->pos);
size_t size = (p->bufferBase + p->blockSize - dest);
if (size == 0)
return;
p->result = p->stream->Read(p->stream, dest, &size);
if (p->result != SZ_OK)
return;
if (size == 0)
{
p->streamEndWasReached = 1;
return;
}
p->streamPos += (UInt32)size;
if (p->streamPos - p->pos > p->keepSizeAfter)
return;
}
}
void MatchFinder_MoveBlock(CMatchFinder *p)
{
memmove(p->bufferBase,
p->buffer - p->keepSizeBefore,
(size_t)(p->streamPos - p->pos + p->keepSizeBefore));
p->buffer = p->bufferBase + p->keepSizeBefore;
}
int MatchFinder_NeedMove(CMatchFinder *p)
{
if (p->directInput)
return 0;
/* if (p->streamEndWasReached) return 0; */
return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
}
void MatchFinder_ReadIfRequired(CMatchFinder *p)
{
if (p->streamEndWasReached)
return;
if (p->keepSizeAfter >= p->streamPos - p->pos)
MatchFinder_ReadBlock(p);
}
static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
{
if (MatchFinder_NeedMove(p))
MatchFinder_MoveBlock(p);
MatchFinder_ReadBlock(p);
}
static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
{
p->cutValue = 32;
p->btMode = 1;
p->numHashBytes = 4;
p->bigHash = 0;
}
#define kCrcPoly 0xEDB88320
void MatchFinder_Construct(CMatchFinder *p)
{
UInt32 i;
p->bufferBase = 0;
p->directInput = 0;
p->hash = 0;
MatchFinder_SetDefaultSettings(p);
for (i = 0; i < 256; i++)
{
UInt32 r = i;
int j;
for (j = 0; j < 8; j++)
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
p->crc[i] = r;
}
}
static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
{
alloc->Free(alloc, p->hash);
p->hash = 0;
}
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
{
MatchFinder_FreeThisClassMemory(p, alloc);
LzInWindow_Free(p, alloc);
}
static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
{
size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
if (sizeInBytes / sizeof(CLzRef) != num)
return 0;
return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
}
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
ISzAlloc *alloc)
{
UInt32 sizeReserv;
if (historySize > kMaxHistorySize)
{
MatchFinder_Free(p, alloc);
return 0;
}
sizeReserv = historySize >> 1;
if (historySize > ((UInt32)2 << 30))
sizeReserv = historySize >> 2;
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
if (LzInWindow_Create(p, sizeReserv, alloc))
{
UInt32 newCyclicBufferSize = historySize + 1;
UInt32 hs;
p->matchMaxLen = matchMaxLen;
{
p->fixedHashSize = 0;
if (p->numHashBytes == 2)
hs = (1 << 16) - 1;
else
{
hs = historySize - 1;
hs |= (hs >> 1);
hs |= (hs >> 2);
hs |= (hs >> 4);
hs |= (hs >> 8);
hs >>= 1;
hs |= 0xFFFF; /* don't change it! It's required for Deflate */
if (hs > (1 << 24))
{
if (p->numHashBytes == 3)
hs = (1 << 24) - 1;
else
hs >>= 1;
}
}
p->hashMask = hs;
hs++;
if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
hs += p->fixedHashSize;
}
{
UInt32 prevSize = p->hashSizeSum + p->numSons;
UInt32 newSize;
p->historySize = historySize;
p->hashSizeSum = hs;
p->cyclicBufferSize = newCyclicBufferSize;
p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
newSize = p->hashSizeSum + p->numSons;
if (p->hash != 0 && prevSize == newSize)
return 1;
MatchFinder_FreeThisClassMemory(p, alloc);
p->hash = AllocRefs(newSize, alloc);
if (p->hash != 0)
{
p->son = p->hash + p->hashSizeSum;
return 1;
}
}
}
MatchFinder_Free(p, alloc);
return 0;
}
static void MatchFinder_SetLimits(CMatchFinder *p)
{
UInt32 limit = kMaxValForNormalize - p->pos;
UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
if (limit2 < limit)
limit = limit2;
limit2 = p->streamPos - p->pos;
if (limit2 <= p->keepSizeAfter)
{
if (limit2 > 0)
limit2 = 1;
}
else
limit2 -= p->keepSizeAfter;
if (limit2 < limit)
limit = limit2;
{
UInt32 lenLimit = p->streamPos - p->pos;
if (lenLimit > p->matchMaxLen)
lenLimit = p->matchMaxLen;
p->lenLimit = lenLimit;
}
p->posLimit = p->pos + limit;
}
void MatchFinder_Init(CMatchFinder *p)
{
UInt32 i;
/*
* Optimized following loop:
* for (i = 0; i < p->hashSizeSum; i++)
* p->hash[i] = kEmptyHashValue;
*
* Given that kEmptyHashValue == 0, we can use memset which uses SSE
* on x86.
*/
memset((void *)(p->hash), 0, p->hashSizeSum * sizeof (p->hash[0]));
p->cyclicBufferPos = 0;
p->buffer = p->bufferBase;
p->pos = p->streamPos = p->cyclicBufferSize;
p->result = SZ_OK;
p->streamEndWasReached = 0;
MatchFinder_ReadBlock(p);
MatchFinder_SetLimits(p);
}
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
}
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
{
UInt32 i;
for (i = 0; i < numItems; i++)
{
UInt32 value = items[i];
if (value <= subValue)
value = kEmptyHashValue;
else
value -= subValue;
items[i] = value;
}
}
static void MatchFinder_Normalize(CMatchFinder *p)
{
UInt32 subValue = MatchFinder_GetSubValue(p);
MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
MatchFinder_ReduceOffsets(p, subValue);
}
static void MatchFinder_CheckLimits(CMatchFinder *p)
{
if (p->pos == kMaxValForNormalize)
MatchFinder_Normalize(p);
if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
MatchFinder_CheckAndMoveAndRead(p);
if (p->cyclicBufferPos == p->cyclicBufferSize)
p->cyclicBufferPos = 0;
MatchFinder_SetLimits(p);
}
static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
UInt32 *distances, UInt32 maxLen)
{
son[_cyclicBufferPos] = curMatch;
for (;;)
{
UInt32 delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
return distances;
{
const Byte *pb = cur - delta;
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
if (pb[maxLen] == cur[maxLen] && *pb == *cur)
{
UInt32 len = 0;
while (++len != lenLimit)
if (pb[len] != cur[len])
break;
if (maxLen < len)
{
*distances++ = maxLen = len;
*distances++ = delta - 1;
if (len == lenLimit)
return distances;
}
}
}
}
}
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
UInt32 *distances, UInt32 maxLen)
{
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
UInt32 len0 = 0, len1 = 0;
for (;;)
{
UInt32 delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
return distances;
}
{
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
const Byte *pb = cur - delta;
UInt32 len = (len0 < len1 ? len0 : len1);
if (pb[len] == cur[len])
{
#ifndef __USE_SSE_INTRIN__
UInt64 a, b;
while (lenLimit - len > 8) {
a = *((UInt64 *)(&pb[len]));
b = *((UInt64 *)(&cur[len]));
if (a != b) {
UInt64 c = a ^ b;
if (c & 0xff) goto diff_cont_g;
len++;
if (c & 0xff00) goto diff_cont_g;
len++; c >>= 16;
if (c & 0xff) goto diff_cont_g;
len++;
if (c & 0xff00) goto diff_cont_g;
len++; c >>= 16;
if (c & 0xff) goto diff_cont_g;
len++;
if (c & 0xff00) goto diff_cont_g;
len++; c >>= 16;
if (c & 0xff) goto diff_cont_g;
len++;
goto diff_cont_g;
}
len += 8;
}
#else
int mask;
UInt32 byt;
while (lenLimit - len > 16) {
__m128i span1 = _mm_loadu_si128((__m128i *)(pb+len));
__m128i span2 = _mm_loadu_si128((__m128i *)(cur+len));
mask = _mm_movemask_epi8(_mm_cmpeq_epi8(span1, span2)) ^ 0xffff;
if (mask) {
byt = __builtin_ctz(mask);
len += byt;
goto diff_cont_g;
}
len += 16;
}
#endif
do {
if (pb[len] != cur[len]) break;
} while (++len != lenLimit);
/* while (++len != lenLimit && pb[len] == cur[len]);*/
diff_cont_g:
if (maxLen < len)
{
*distances++ = maxLen = len;
*distances++ = delta - 1;
if (len == lenLimit)
{
*ptr1 = pair[0];
*ptr0 = pair[1];
return distances;
}
}
}
if (pb[len] < cur[len])
{
*ptr1 = curMatch;
ptr1 = pair + 1;
curMatch = *ptr1;
len1 = len;
}
else
{
*ptr0 = curMatch;
ptr0 = pair;
curMatch = *ptr0;
len0 = len;
}
}
}
}
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
{
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
UInt32 len0 = 0, len1 = 0;
for (;;)
{
UInt32 delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
return;
}
{
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
const Byte *pb = cur - delta;
UInt32 len = (len0 < len1 ? len0 : len1);
if (pb[len] == cur[len])
{
#ifndef __USE_SSE_INTRIN__
UInt64 a, b;
while (lenLimit - len > 8) {
a = *((UInt64 *)(&pb[len]));
b = *((UInt64 *)(&cur[len]));
if (a != b) {
UInt64 c = a ^ b;
if (c & 0xff) goto diff_cont;
len++;
if (c & 0xff00) goto diff_cont;
len++; c >>= 16;
if (c & 0xff) goto diff_cont;
len++;
if (c & 0xff00) goto diff_cont;
len++; c >>= 16;
if (c & 0xff) goto diff_cont;
len++;
if (c & 0xff00) goto diff_cont;
len++; c >>= 16;
if (c & 0xff) goto diff_cont;
len++;
goto diff_cont;
}
len += 8;
}
#else
int mask;
UInt32 byt;
while (lenLimit - len > 16) {
__m128i span1 = _mm_loadu_si128((__m128i *)(pb+len));
__m128i span2 = _mm_loadu_si128((__m128i *)(cur+len));
mask = _mm_movemask_epi8(_mm_cmpeq_epi8(span1, span2)) ^ 0xffff;
if (mask) {
byt = __builtin_ctz(mask);
len += byt;
goto diff_cont;
}
len += 16;
}
#endif
do {
if (pb[len] != cur[len]) break;
} while (++len != lenLimit);
/* while (++len != lenLimit)
if (pb[len] != cur[len])
break;*/
diff_cont:
{
if (len == lenLimit)
{
*ptr1 = pair[0];
*ptr0 = pair[1];
return;
}
}
}
if (pb[len] < cur[len])
{
*ptr1 = curMatch;
ptr1 = pair + 1;
curMatch = *ptr1;
len1 = len;
}
else
{
*ptr0 = curMatch;
ptr0 = pair;
curMatch = *ptr0;
len0 = len;
}
}
}
}
#define MOVE_POS \
++p->cyclicBufferPos; \
p->buffer++; \
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
#define MOVE_POS_RET MOVE_POS return offset;
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
#define GET_MATCHES_HEADER2(minLen, ret_op) \
UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
cur = p->buffer;
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
#define GET_MATCHES_FOOTER(offset, maxLen) \
offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
distances + offset, maxLen) - distances); MOVE_POS_RET;
#define SKIP_FOOTER \
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 offset;
GET_MATCHES_HEADER(2)
HASH2_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
offset = 0;
GET_MATCHES_FOOTER(offset, 1)
}
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
offset = 0;
GET_MATCHES_FOOTER(offset, 2)
}
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 hash2Value, delta2, maxLen, offset;
GET_MATCHES_HEADER(3)
HASH3_CALC;
delta2 = p->pos - p->hash[hash2Value];
curMatch = p->hash[kFix3HashSize + hashValue];
p->hash[hash2Value] =
p->hash[kFix3HashSize + hashValue] = p->pos;
maxLen = 2;
offset = 0;
if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
{
for (; maxLen != lenLimit; maxLen++)
if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[0] = maxLen;
distances[1] = delta2 - 1;
offset = 2;
if (maxLen == lenLimit)
{
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
MOVE_POS_RET;
}
}
GET_MATCHES_FOOTER(offset, maxLen)
}
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
HASH4_CALC;
delta2 = p->pos - p->hash[ hash2Value];
delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
curMatch = p->hash[kFix4HashSize + hashValue];
p->hash[ hash2Value] =
p->hash[kFix3HashSize + hash3Value] =
p->hash[kFix4HashSize + hashValue] = p->pos;
maxLen = 1;
offset = 0;
if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
{
distances[0] = maxLen = 2;
distances[1] = delta2 - 1;
offset = 2;
}
if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
{
maxLen = 3;
distances[offset + 1] = delta3 - 1;
offset += 2;
delta2 = delta3;
}
if (offset != 0)
{
for (; maxLen != lenLimit; maxLen++)
if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[offset - 2] = maxLen;
if (maxLen == lenLimit)
{
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
MOVE_POS_RET;
}
}
if (maxLen < 3)
maxLen = 3;
GET_MATCHES_FOOTER(offset, maxLen)
}
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
HASH4_CALC;
delta2 = p->pos - p->hash[ hash2Value];
delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
curMatch = p->hash[kFix4HashSize + hashValue];
p->hash[ hash2Value] =
p->hash[kFix3HashSize + hash3Value] =
p->hash[kFix4HashSize + hashValue] = p->pos;
maxLen = 1;
offset = 0;
if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
{
distances[0] = maxLen = 2;
distances[1] = delta2 - 1;
offset = 2;
}
if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
{
maxLen = 3;
distances[offset + 1] = delta3 - 1;
offset += 2;
delta2 = delta3;
}
if (offset != 0)
{
for (; maxLen != lenLimit; maxLen++)
if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[offset - 2] = maxLen;
if (maxLen == lenLimit)
{
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS_RET;
}
}
if (maxLen < 3)
maxLen = 3;
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances + offset, maxLen) - (distances));
MOVE_POS_RET
}
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
{
UInt32 offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances, 2) - (distances));
MOVE_POS_RET
}
static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
SKIP_HEADER(2)
HASH2_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
SKIP_FOOTER
}
while (--num != 0);
}
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
SKIP_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
SKIP_FOOTER
}
while (--num != 0);
}
static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
UInt32 hash2Value;
SKIP_HEADER(3)
HASH3_CALC;
curMatch = p->hash[kFix3HashSize + hashValue];
p->hash[hash2Value] =
p->hash[kFix3HashSize + hashValue] = p->pos;
SKIP_FOOTER
}
while (--num != 0);
}
static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
UInt32 hash2Value, hash3Value;
SKIP_HEADER(4)
HASH4_CALC;
curMatch = p->hash[kFix4HashSize + hashValue];
p->hash[ hash2Value] =
p->hash[kFix3HashSize + hash3Value] = p->pos;
p->hash[kFix4HashSize + hashValue] = p->pos;
SKIP_FOOTER
}
while (--num != 0);
}
static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
UInt32 hash2Value, hash3Value;
SKIP_HEADER(4)
HASH4_CALC;
curMatch = p->hash[kFix4HashSize + hashValue];
p->hash[ hash2Value] =
p->hash[kFix3HashSize + hash3Value] =
p->hash[kFix4HashSize + hashValue] = p->pos;
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS
}
while (--num != 0);
}
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
{
do
{
SKIP_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS
}
while (--num != 0);
}
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
{
vTable->Init = (Mf_Init_Func)MatchFinder_Init;
vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
if (!p->btMode)
{
vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
}
else if (p->numHashBytes == 2)
{
vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
}
else if (p->numHashBytes == 3)
{
vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
}
else
{
vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
}
}

115
lzma/LzFind.h Normal file
View file

@ -0,0 +1,115 @@
/* LzFind.h -- Match finder for LZ algorithms
2009-04-22 : Igor Pavlov : Public domain */
#ifndef __LZ_FIND_H
#define __LZ_FIND_H
#include "Types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef UInt32 CLzRef;
typedef struct _CMatchFinder
{
Byte *buffer;
UInt32 pos;
UInt32 posLimit;
UInt32 streamPos;
UInt32 lenLimit;
UInt32 cyclicBufferPos;
UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
UInt32 matchMaxLen;
CLzRef *hash;
CLzRef *son;
UInt32 hashMask;
UInt32 cutValue;
Byte *bufferBase;
ISeqInStream *stream;
int streamEndWasReached;
UInt32 blockSize;
UInt32 keepSizeBefore;
UInt32 keepSizeAfter;
UInt32 numHashBytes;
int directInput;
size_t directInputRem;
int btMode;
int bigHash;
UInt32 historySize;
UInt32 fixedHashSize;
UInt32 hashSizeSum;
UInt32 numSons;
SRes result;
UInt32 crc[256];
} CMatchFinder;
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
int MatchFinder_NeedMove(CMatchFinder *p);
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
void MatchFinder_MoveBlock(CMatchFinder *p);
void MatchFinder_ReadIfRequired(CMatchFinder *p);
void MatchFinder_Construct(CMatchFinder *p);
/* Conditions:
historySize <= 3 GB
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
*/
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
ISzAlloc *alloc);
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
UInt32 *distances, UInt32 maxLen);
/*
Conditions:
Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
*/
typedef void (*Mf_Init_Func)(void *object);
typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
typedef void (*Mf_Skip_Func)(void *object, UInt32);
typedef struct _IMatchFinder
{
Mf_Init_Func Init;
Mf_GetIndexByte_Func GetIndexByte;
Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
Mf_GetMatches_Func GetMatches;
Mf_Skip_Func Skip;
} IMatchFinder;
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
void MatchFinder_Init(CMatchFinder *p);
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
#ifdef __cplusplus
}
#endif
#endif

54
lzma/LzHash.h Normal file
View file

@ -0,0 +1,54 @@
/* LzHash.h -- HASH functions for LZ algorithms
2009-02-07 : Igor Pavlov : Public domain */
#ifndef __LZ_HASH_H
#define __LZ_HASH_H
#define kHash2Size (1 << 10)
#define kHash3Size (1 << 16)
#define kHash4Size (1 << 20)
#define kFix3HashSize (kHash2Size)
#define kFix4HashSize (kHash2Size + kHash3Size)
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
#define HASH3_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
#define HASH4_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
#define HASH5_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
hash4Value &= (kHash4Size - 1); }
/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
#define MT_HASH2_CALC \
hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
#define MT_HASH3_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
#define MT_HASH4_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
#endif

999
lzma/LzmaDec.c Normal file
View file

@ -0,0 +1,999 @@
/* LzmaDec.c -- LZMA Decoder
2009-09-20 : Igor Pavlov : Public domain */
#include "LzmaDec.h"
#include <string.h>
#define kNumTopBits 24
#define kTopValue ((UInt32)1 << kNumTopBits)
#define kNumBitModelTotalBits 11
#define kBitModelTotal (1 << kNumBitModelTotalBits)
#define kNumMoveBits 5
#define RC_INIT_SIZE 5
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
{ UPDATE_0(p); i = (i + i); A0; } else \
{ UPDATE_1(p); i = (i + i) + 1; A1; }
#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
#define TREE_DECODE(probs, limit, i) \
{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
/* #define _LZMA_SIZE_OPT */
#ifdef _LZMA_SIZE_OPT
#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
#else
#define TREE_6_DECODE(probs, i) \
{ i = 1; \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
i -= 0x40; }
#endif
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
#define UPDATE_0_CHECK range = bound;
#define UPDATE_1_CHECK range -= bound; code -= bound;
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
{ UPDATE_0_CHECK; i = (i + i); A0; } else \
{ UPDATE_1_CHECK; i = (i + i) + 1; A1; }
#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
#define TREE_DECODE_CHECK(probs, limit, i) \
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
#define kNumPosBitsMax 4
#define kNumPosStatesMax (1 << kNumPosBitsMax)
#define kLenNumLowBits 3
#define kLenNumLowSymbols (1 << kLenNumLowBits)
#define kLenNumMidBits 3
#define kLenNumMidSymbols (1 << kLenNumMidBits)
#define kLenNumHighBits 8
#define kLenNumHighSymbols (1 << kLenNumHighBits)
#define LenChoice 0
#define LenChoice2 (LenChoice + 1)
#define LenLow (LenChoice2 + 1)
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
#define kNumStates 12
#define kNumLitStates 7
#define kStartPosModelIndex 4
#define kEndPosModelIndex 14
#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
#define kNumPosSlotBits 6
#define kNumLenToPosStates 4
#define kNumAlignBits 4
#define kAlignTableSize (1 << kNumAlignBits)
#define kMatchMinLen 2
#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
#define IsMatch 0
#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
#define IsRepG0 (IsRep + kNumStates)
#define IsRepG1 (IsRepG0 + kNumStates)
#define IsRepG2 (IsRepG1 + kNumStates)
#define IsRep0Long (IsRepG2 + kNumStates)
#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
#define LenCoder (Align + kAlignTableSize)
#define RepLenCoder (LenCoder + kNumLenProbs)
#define Literal (RepLenCoder + kNumLenProbs)
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
#if Literal != LZMA_BASE_SIZE
StopCompilingDueBUG
#endif
#define LZMA_DIC_MIN (1 << 12)
/* First LZMA-symbol is always decoded.
And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
Out:
Result:
SZ_OK - OK
SZ_ERROR_DATA - Error
p->remainLen:
< kMatchSpecLenStart : normal remain
= kMatchSpecLenStart : finished
= kMatchSpecLenStart + 1 : Flush marker
= kMatchSpecLenStart + 2 : State Init Marker
*/
static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
{
CLzmaProb *probs = p->probs;
unsigned state = p->state;
UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
unsigned lc = p->prop.lc;
Byte *dic = p->dic;
SizeT dicBufSize = p->dicBufSize;
SizeT dicPos = p->dicPos;
UInt32 processedPos = p->processedPos;
UInt32 checkDicSize = p->checkDicSize;
unsigned len = 0;
const Byte *buf = p->buf;
UInt32 range = p->range;
UInt32 code = p->code;
do
{
CLzmaProb *prob;
UInt32 bound;
unsigned ttt;
unsigned posState = processedPos & pbMask;
prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
IF_BIT_0(prob)
{
unsigned symbol;
UPDATE_0(prob);
prob = probs + Literal;
if (checkDicSize != 0 || processedPos != 0)
prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
(dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
if (state < kNumLitStates)
{
state -= (state < 4) ? state : 3;
symbol = 1;
do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
}
else
{
unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned offs = 0x100;
state -= (state < 10) ? 3 : 6;
symbol = 1;
do
{
unsigned bit;
CLzmaProb *probLit;
matchByte <<= 1;
bit = (matchByte & offs);
probLit = prob + offs + bit + symbol;
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
}
while (symbol < 0x100);
}
dic[dicPos++] = (Byte)symbol;
processedPos++;
continue;
}
else
{
UPDATE_1(prob);
prob = probs + IsRep + state;
IF_BIT_0(prob)
{
UPDATE_0(prob);
state += kNumStates;
prob = probs + LenCoder;
}
else
{
UPDATE_1(prob);
if (checkDicSize == 0 && processedPos == 0)
return SZ_ERROR_DATA;
prob = probs + IsRepG0 + state;
IF_BIT_0(prob)
{
UPDATE_0(prob);
prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
IF_BIT_0(prob)
{
UPDATE_0(prob);
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
dicPos++;
processedPos++;
state = state < kNumLitStates ? 9 : 11;
continue;
}
UPDATE_1(prob);
}
else
{
UInt32 distance;
UPDATE_1(prob);
prob = probs + IsRepG1 + state;
IF_BIT_0(prob)
{
UPDATE_0(prob);
distance = rep1;
}
else
{
UPDATE_1(prob);
prob = probs + IsRepG2 + state;
IF_BIT_0(prob)
{
UPDATE_0(prob);
distance = rep2;
}
else
{
UPDATE_1(prob);
distance = rep3;
rep3 = rep2;
}
rep2 = rep1;
}
rep1 = rep0;
rep0 = distance;
}
state = state < kNumLitStates ? 8 : 11;
prob = probs + RepLenCoder;
}
{
unsigned limit, offset;
CLzmaProb *probLen = prob + LenChoice;
IF_BIT_0(probLen)
{
UPDATE_0(probLen);
probLen = prob + LenLow + (posState << kLenNumLowBits);
offset = 0;
limit = (1 << kLenNumLowBits);
}
else
{
UPDATE_1(probLen);
probLen = prob + LenChoice2;
IF_BIT_0(probLen)
{
UPDATE_0(probLen);
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
limit = (1 << kLenNumMidBits);
}
else
{
UPDATE_1(probLen);
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
limit = (1 << kLenNumHighBits);
}
}
TREE_DECODE(probLen, limit, len);
len += offset;
}
if (state >= kNumStates)
{
UInt32 distance;
prob = probs + PosSlot +
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
TREE_6_DECODE(prob, distance);
if (distance >= kStartPosModelIndex)
{
unsigned posSlot = (unsigned)distance;
int numDirectBits = (int)(((distance >> 1) - 1));
distance = (2 | (distance & 1));
if (posSlot < kEndPosModelIndex)
{
distance <<= numDirectBits;
prob = probs + SpecPos + distance - posSlot - 1;
{
UInt32 mask = 1;
unsigned i = 1;
do
{
GET_BIT2(prob + i, i, ; , distance |= mask);
mask <<= 1;
}
while (--numDirectBits != 0);
}
}
else
{
numDirectBits -= kNumAlignBits;
do
{
NORMALIZE
range >>= 1;
{
UInt32 t;
code -= range;
t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
distance = (distance << 1) + (t + 1);
code += range & t;
}
/*
distance <<= 1;
if (code >= range)
{
code -= range;
distance |= 1;
}
*/
}
while (--numDirectBits != 0);
prob = probs + Align;
distance <<= kNumAlignBits;
{
unsigned i = 1;
GET_BIT2(prob + i, i, ; , distance |= 1);
GET_BIT2(prob + i, i, ; , distance |= 2);
GET_BIT2(prob + i, i, ; , distance |= 4);
GET_BIT2(prob + i, i, ; , distance |= 8);
}
if (distance == (UInt32)0xFFFFFFFF)
{
len += kMatchSpecLenStart;
state -= kNumStates;
break;
}
}
}
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
rep0 = distance + 1;
if (checkDicSize == 0)
{
if (distance >= processedPos)
return SZ_ERROR_DATA;
}
else if (distance >= checkDicSize)
return SZ_ERROR_DATA;
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
}
len += kMatchMinLen;
if (limit == dicPos)
return SZ_ERROR_DATA;
{
SizeT rem = limit - dicPos;
unsigned curLen = ((rem < len) ? (unsigned)rem : len);
SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
processedPos += curLen;
len -= curLen;
if (pos + curLen <= dicBufSize)
{
Byte *dest = dic + dicPos;
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
const Byte *lim = dest + curLen;
dicPos += curLen;
do
*(dest) = (Byte)*(dest + src);
while (++dest != lim);
}
else
{
do
{
dic[dicPos++] = dic[pos];
if (++pos == dicBufSize)
pos = 0;
}
while (--curLen != 0);
}
}
}
}
while (dicPos < limit && buf < bufLimit);
NORMALIZE;
p->buf = buf;
p->range = range;
p->code = code;
p->remainLen = len;
p->dicPos = dicPos;
p->processedPos = processedPos;
p->reps[0] = rep0;
p->reps[1] = rep1;
p->reps[2] = rep2;
p->reps[3] = rep3;
p->state = state;
return SZ_OK;
}
static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
{
if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
{
Byte *dic = p->dic;
SizeT dicPos = p->dicPos;
SizeT dicBufSize = p->dicBufSize;
unsigned len = p->remainLen;
UInt32 rep0 = p->reps[0];
if (limit - dicPos < len)
len = (unsigned)(limit - dicPos);
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
p->checkDicSize = p->prop.dicSize;
p->processedPos += len;
p->remainLen -= len;
while (len-- != 0)
{
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
dicPos++;
}
p->dicPos = dicPos;
}
}
static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
{
do
{
SizeT limit2 = limit;
if (p->checkDicSize == 0)
{
UInt32 rem = p->prop.dicSize - p->processedPos;
if (limit - p->dicPos > rem)
limit2 = p->dicPos + rem;
}
RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
if (p->processedPos >= p->prop.dicSize)
p->checkDicSize = p->prop.dicSize;
LzmaDec_WriteRem(p, limit);
}
while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
if (p->remainLen > kMatchSpecLenStart)
{
p->remainLen = kMatchSpecLenStart;
}
return 0;
}
typedef enum
{
DUMMY_ERROR, /* unexpected end of input stream */
DUMMY_LIT,
DUMMY_MATCH,
DUMMY_REP
} ELzmaDummy;
static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
{
UInt32 range = p->range;
UInt32 code = p->code;
const Byte *bufLimit = buf + inSize;
CLzmaProb *probs = p->probs;
unsigned state = p->state;
ELzmaDummy res;
{
CLzmaProb *prob;
UInt32 bound;
unsigned ttt;
unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK
/* if (bufLimit - buf >= 7) return DUMMY_LIT; */
prob = probs + Literal;
if (p->checkDicSize != 0 || p->processedPos != 0)
prob += (LZMA_LIT_SIZE *
((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
(p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
if (state < kNumLitStates)
{
unsigned symbol = 1;
do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
}
else
{
unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
unsigned offs = 0x100;
unsigned symbol = 1;
do
{
unsigned bit;
CLzmaProb *probLit;
matchByte <<= 1;
bit = (matchByte & offs);
probLit = prob + offs + bit + symbol;
GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
}
while (symbol < 0x100);
}
res = DUMMY_LIT;
}
else
{
unsigned len;
UPDATE_1_CHECK;
prob = probs + IsRep + state;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK;
state = 0;
prob = probs + LenCoder;
res = DUMMY_MATCH;
}
else
{
UPDATE_1_CHECK;
res = DUMMY_REP;
prob = probs + IsRepG0 + state;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK;
prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK;
NORMALIZE_CHECK;
return DUMMY_REP;
}
else
{
UPDATE_1_CHECK;
}
}
else
{
UPDATE_1_CHECK;
prob = probs + IsRepG1 + state;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK;
}
else
{
UPDATE_1_CHECK;
prob = probs + IsRepG2 + state;
IF_BIT_0_CHECK(prob)
{
UPDATE_0_CHECK;
}
else
{
UPDATE_1_CHECK;
}
}
}
state = kNumStates;
prob = probs + RepLenCoder;
}
{
unsigned limit, offset;
CLzmaProb *probLen = prob + LenChoice;
IF_BIT_0_CHECK(probLen)
{
UPDATE_0_CHECK;
probLen = prob + LenLow + (posState << kLenNumLowBits);
offset = 0;
limit = 1 << kLenNumLowBits;
}
else
{
UPDATE_1_CHECK;
probLen = prob + LenChoice2;
IF_BIT_0_CHECK(probLen)
{
UPDATE_0_CHECK;
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
limit = 1 << kLenNumMidBits;
}
else
{
UPDATE_1_CHECK;
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
limit = 1 << kLenNumHighBits;
}
}
TREE_DECODE_CHECK(probLen, limit, len);
len += offset;
}
if (state < 4)
{
unsigned posSlot;
prob = probs + PosSlot +
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
kNumPosSlotBits);
TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
if (posSlot >= kStartPosModelIndex)
{
int numDirectBits = ((posSlot >> 1) - 1);
/* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
if (posSlot < kEndPosModelIndex)
{
prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
}
else
{
numDirectBits -= kNumAlignBits;
do
{
NORMALIZE_CHECK
range >>= 1;
code -= range & (((code - range) >> 31) - 1);
/* if (code >= range) code -= range; */
}
while (--numDirectBits != 0);
prob = probs + Align;
numDirectBits = kNumAlignBits;
}
{
unsigned i = 1;
do
{
GET_BIT_CHECK(prob + i, i);
}
while (--numDirectBits != 0);
}
}
}
}
}
NORMALIZE_CHECK;
return res;
}
static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
{
p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
p->range = 0xFFFFFFFF;
p->needFlush = 0;
}
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
{
p->needFlush = 1;
p->remainLen = 0;
p->tempBufSize = 0;
if (initDic)
{
p->processedPos = 0;
p->checkDicSize = 0;
p->needInitState = 1;
}
if (initState)
p->needInitState = 1;
}
void LzmaDec_Init(CLzmaDec *p)
{
p->dicPos = 0;
LzmaDec_InitDicAndState(p, True, True);
}
static void LzmaDec_InitStateReal(CLzmaDec *p)
{
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
UInt32 i;
CLzmaProb *probs = p->probs;
for (i = 0; i < numProbs; i++)
probs[i] = kBitModelTotal >> 1;
p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
p->state = 0;
p->needInitState = 0;
}
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
ELzmaFinishMode finishMode, ELzmaStatus *status)
{
SizeT inSize = *srcLen;
(*srcLen) = 0;
LzmaDec_WriteRem(p, dicLimit);
*status = LZMA_STATUS_NOT_SPECIFIED;
while (p->remainLen != kMatchSpecLenStart)
{
int checkEndMarkNow;
if (p->needFlush != 0)
{
for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
p->tempBuf[p->tempBufSize++] = *src++;
if (p->tempBufSize < RC_INIT_SIZE)
{
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
if (p->tempBuf[0] != 0)
return SZ_ERROR_DATA;
LzmaDec_InitRc(p, p->tempBuf);
p->tempBufSize = 0;
}
checkEndMarkNow = 0;
if (p->dicPos >= dicLimit)
{
if (p->remainLen == 0 && p->code == 0)
{
*status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
return SZ_OK;
}
if (finishMode == LZMA_FINISH_ANY)
{
*status = LZMA_STATUS_NOT_FINISHED;
return SZ_OK;
}
if (p->remainLen != 0)
{
*status = LZMA_STATUS_NOT_FINISHED;
return SZ_ERROR_DATA;
}
checkEndMarkNow = 1;
}
if (p->needInitState)
LzmaDec_InitStateReal(p);
if (p->tempBufSize == 0)
{
SizeT processed;
const Byte *bufLimit;
if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
{
int dummyRes = LzmaDec_TryDummy(p, src, inSize);
if (dummyRes == DUMMY_ERROR)
{
memcpy(p->tempBuf, src, inSize);
p->tempBufSize = (unsigned)inSize;
(*srcLen) += inSize;
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
{
*status = LZMA_STATUS_NOT_FINISHED;
return SZ_ERROR_DATA;
}
bufLimit = src;
}
else
bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
p->buf = src;
if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
return SZ_ERROR_DATA;
processed = (SizeT)(p->buf - src);
(*srcLen) += processed;
src += processed;
inSize -= processed;
}
else
{
unsigned rem = p->tempBufSize, lookAhead = 0;
while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
p->tempBuf[rem++] = src[lookAhead++];
p->tempBufSize = rem;
if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
{
int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
if (dummyRes == DUMMY_ERROR)
{
(*srcLen) += lookAhead;
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
{
*status = LZMA_STATUS_NOT_FINISHED;
return SZ_ERROR_DATA;
}
}
p->buf = p->tempBuf;
if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
return SZ_ERROR_DATA;
lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
(*srcLen) += lookAhead;
src += lookAhead;
inSize -= lookAhead;
p->tempBufSize = 0;
}
}
if (p->code == 0)
*status = LZMA_STATUS_FINISHED_WITH_MARK;
return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
}
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
{
SizeT outSize = *destLen;
SizeT inSize = *srcLen;
*srcLen = *destLen = 0;
for (;;)
{
SizeT inSizeCur = inSize, outSizeCur, dicPos;
ELzmaFinishMode curFinishMode;
SRes res;
if (p->dicPos == p->dicBufSize)
p->dicPos = 0;
dicPos = p->dicPos;
if (outSize > p->dicBufSize - dicPos)
{
outSizeCur = p->dicBufSize;
curFinishMode = LZMA_FINISH_ANY;
}
else
{
outSizeCur = dicPos + outSize;
curFinishMode = finishMode;
}
res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
src += inSizeCur;
inSize -= inSizeCur;
*srcLen += inSizeCur;
outSizeCur = p->dicPos - dicPos;
memcpy(dest, p->dic + dicPos, outSizeCur);
dest += outSizeCur;
outSize -= outSizeCur;
*destLen += outSizeCur;
if (res != 0)
return res;
if (outSizeCur == 0 || outSize == 0)
return SZ_OK;
}
}
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
{
alloc->Free(alloc, p->probs);
p->probs = 0;
}
static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
{
alloc->Free(alloc, p->dic);
p->dic = 0;
}
void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
{
LzmaDec_FreeProbs(p, alloc);
LzmaDec_FreeDict(p, alloc);
}
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
{
UInt32 dicSize;
Byte d;
if (size < LZMA_PROPS_SIZE)
return SZ_ERROR_UNSUPPORTED;
else
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
if (dicSize < LZMA_DIC_MIN)
dicSize = LZMA_DIC_MIN;
p->dicSize = dicSize;
d = data[0];
if (d >= (9 * 5 * 5))
return SZ_ERROR_UNSUPPORTED;
p->lc = d % 9;
d /= 9;
p->pb = d / 5;
p->lp = d % 5;
return SZ_OK;
}
static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
{
UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
if (p->probs == 0 || numProbs != p->numProbs)
{
LzmaDec_FreeProbs(p, alloc);
p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
p->numProbs = numProbs;
if (p->probs == 0)
return SZ_ERROR_MEM;
}
return SZ_OK;
}
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
{
CLzmaProps propNew;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
p->prop = propNew;
return SZ_OK;
}
SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
{
CLzmaProps propNew;
SizeT dicBufSize;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
dicBufSize = propNew.dicSize;
if (p->dic == 0 || dicBufSize != p->dicBufSize)
{
LzmaDec_FreeDict(p, alloc);
p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
if (p->dic == 0)
{
LzmaDec_FreeProbs(p, alloc);
return SZ_ERROR_MEM;
}
}
p->dicBufSize = dicBufSize;
p->prop = propNew;
return SZ_OK;
}
SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
ELzmaStatus *status, ISzAlloc *alloc)
{
CLzmaDec p;
SRes res;
SizeT inSize = *srcLen;
SizeT outSize = *destLen;
*srcLen = *destLen = 0;
if (inSize < RC_INIT_SIZE)
return SZ_ERROR_INPUT_EOF;
LzmaDec_Construct(&p);
res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
if (res != 0)
return res;
p.dic = dest;
p.dicBufSize = outSize;
LzmaDec_Init(&p);
*srcLen = inSize;
res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
res = SZ_ERROR_INPUT_EOF;
(*destLen) = p.dicPos;
LzmaDec_FreeProbs(&p, alloc);
return res;
}

231
lzma/LzmaDec.h Normal file
View file

@ -0,0 +1,231 @@
/* LzmaDec.h -- LZMA Decoder
2009-02-07 : Igor Pavlov : Public domain */
#ifndef __LZMA_DEC_H
#define __LZMA_DEC_H
#include "Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* #define _LZMA_PROB32 */
/* _LZMA_PROB32 can increase the speed on some CPUs,
but memory usage for CLzmaDec::probs will be doubled in that case */
#ifdef _LZMA_PROB32
#define CLzmaProb UInt32
#else
#define CLzmaProb UInt16
#endif
/* ---------- LZMA Properties ---------- */
#define LZMA_PROPS_SIZE 5
typedef struct _CLzmaProps
{
unsigned lc, lp, pb;
UInt32 dicSize;
} CLzmaProps;
/* LzmaProps_Decode - decodes properties
Returns:
SZ_OK
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
/* ---------- LZMA Decoder state ---------- */
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
#define LZMA_REQUIRED_INPUT_MAX 20
typedef struct
{
CLzmaProps prop;
CLzmaProb *probs;
Byte *dic;
const Byte *buf;
UInt32 range, code;
SizeT dicPos;
SizeT dicBufSize;
UInt32 processedPos;
UInt32 checkDicSize;
unsigned state;
UInt32 reps[4];
unsigned remainLen;
int needFlush;
int needInitState;
UInt32 numProbs;
unsigned tempBufSize;
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
} CLzmaDec;
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
void LzmaDec_Init(CLzmaDec *p);
/* There are two types of LZMA streams:
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
typedef enum
{
LZMA_FINISH_ANY, /* finish at any point */
LZMA_FINISH_END /* block must be finished at the end */
} ELzmaFinishMode;
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
You must use LZMA_FINISH_END, when you know that current output buffer
covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
and output value of destLen will be less than output buffer size limit.
You can check status result also.
You can use multiple checks to test data integrity after full decompression:
1) Check Result and "status" variable.
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
You must use correct finish mode in that case. */
typedef enum
{
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
} ELzmaStatus;
/* ELzmaStatus is used only as output value for function call */
/* ---------- Interfaces ---------- */
/* There are 3 levels of interfaces:
1) Dictionary Interface
2) Buffer Interface
3) One Call Interface
You can select any of these interfaces, but don't mix functions from different
groups for same object. */
/* There are two variants to allocate state for Dictionary Interface:
1) LzmaDec_Allocate / LzmaDec_Free
2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
You can use variant 2, if you set dictionary buffer manually.
For Buffer Interface you must always use variant 1.
LzmaDec_Allocate* can return:
SZ_OK
SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
/* ---------- Dictionary Interface ---------- */
/* You can use it, if you want to eliminate the overhead for data copying from
dictionary to some other external buffer.
You must work with CLzmaDec variables directly in this interface.
STEPS:
LzmaDec_Constr()
LzmaDec_Allocate()
for (each new stream)
{
LzmaDec_Init()
while (it needs more decompression)
{
LzmaDec_DecodeToDic()
use data from CLzmaDec::dic and update CLzmaDec::dicPos
}
}
LzmaDec_Free()
*/
/* LzmaDec_DecodeToDic
The decoding to internal dictionary buffer (CLzmaDec::dic).
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
finishMode:
It has meaning only if the decoding reaches output limit (dicLimit).
LZMA_FINISH_ANY - Decode just dicLimit bytes.
LZMA_FINISH_END - Stream must be finished after dicLimit.
Returns:
SZ_OK
status:
LZMA_STATUS_FINISHED_WITH_MARK
LZMA_STATUS_NOT_FINISHED
LZMA_STATUS_NEEDS_MORE_INPUT
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
SZ_ERROR_DATA - Data error
*/
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
/* ---------- Buffer Interface ---------- */
/* It's zlib-like interface.
See LzmaDec_DecodeToDic description for information about STEPS and return results,
but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
to work with CLzmaDec variables manually.
finishMode:
It has meaning only if the decoding reaches output limit (*destLen).
LZMA_FINISH_ANY - Decode just destLen bytes.
LZMA_FINISH_END - Stream must be finished after (*destLen).
*/
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
/* ---------- One Call Interface ---------- */
/* LzmaDecode
finishMode:
It has meaning only if the decoding reaches output limit (*destLen).
LZMA_FINISH_ANY - Decode just destLen bytes.
LZMA_FINISH_END - Stream must be finished after (*destLen).
Returns:
SZ_OK
status:
LZMA_STATUS_FINISHED_WITH_MARK
LZMA_STATUS_NOT_FINISHED
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
SZ_ERROR_DATA - Data error
SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_UNSUPPORTED - Unsupported properties
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
*/
SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
ELzmaStatus *status, ISzAlloc *alloc);
#ifdef __cplusplus
}
#endif
#endif

2449
lzma/LzmaEnc.c Normal file

File diff suppressed because it is too large Load diff

79
lzma/LzmaEnc.h Normal file
View file

@ -0,0 +1,79 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* LzmaEnc.h -- LZMA Encoder
2008-10-04 : Igor Pavlov : Public domain */
#ifndef __LZMAENC_H
#define __LZMAENC_H
#include "Types.h"
#define LZMA_PROPS_SIZE 5
typedef struct _CLzmaEncProps
{
int level; /* 0 <= level <= 9 */
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
default = (1 << 24) */
int lc; /* 0 <= lc <= 8, default = 3 */
int lp; /* 0 <= lp <= 4, default = 0 */
int pb; /* 0 <= pb <= 4, default = 2 */
int algo; /* 0 - fast, 1 - normal, default = 1 */
int fb; /* 5 <= fb <= 273, default = 32 */
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
int numHashBytes; /* 2, 3 or 4, default = 4 */
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
int numThreads; /* 1 or 2, default = 2 */
int normalized;
} CLzmaEncProps;
extern void LzmaEncProps_Init(CLzmaEncProps *p);
void LzmaEncProps_Normalize(CLzmaEncProps *p);
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
/* ---------- CLzmaEncHandle Interface ---------- */
/* LzmaEnc_* functions can return the following exit codes:
Returns:
SZ_OK - OK
SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_PARAM - Incorrect paramater in props
SZ_ERROR_WRITE - Write callback error.
SZ_ERROR_PROGRESS - some break from progress callback
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
*/
typedef void * CLzmaEncHandle;
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
/* ---------- One Call Interface ---------- */
/* LzmaEncode
Return code:
SZ_OK - OK
SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_PARAM - Incorrect paramater
SZ_ERROR_OUTPUT_EOF - output buffer overflow
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
*/
extern SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
#endif

82
lzma/Ppmd.h Executable file
View file

@ -0,0 +1,82 @@
/* Ppmd.h -- PPMD codec common code
2010-03-12 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#ifndef __PPMD_H
#define __PPMD_H
#include <string.h>
#include "Types.h"
#include "CpuArch.h"
EXTERN_C_BEGIN
#ifdef MY_CPU_32BIT
#define PPMD_32BIT
#endif
#define PPMD_INT_BITS 7
#define PPMD_PERIOD_BITS 7
#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))
#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))
#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)
#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))
#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))
#define PPMD_N1 4
#define PPMD_N2 4
#define PPMD_N3 4
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
/* SEE-contexts for PPM-contexts with masked symbols */
typedef struct
{
UInt16 Summ; /* Freq */
Byte Shift; /* Speed of Freq change; low Shift is for fast change */
Byte Count; /* Count to next change of Shift */
} CPpmd_See;
#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
{ (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
typedef struct
{
Byte Symbol;
Byte Freq;
UInt16 SuccessorLow;
UInt16 SuccessorHigh;
} CPpmd_State;
typedef
#ifdef PPMD_32BIT
CPpmd_State *
#else
UInt32
#endif
CPpmd_State_Ref;
typedef
#ifdef PPMD_32BIT
void *
#else
UInt32
#endif
CPpmd_Void_Ref;
typedef
#ifdef PPMD_32BIT
Byte *
#else
UInt32
#endif
CPpmd_Byte_Ref;
#define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
EXTERN_C_END
#endif

1119
lzma/Ppmd8.c Executable file

File diff suppressed because it is too large Load diff

135
lzma/Ppmd8.h Executable file
View file

@ -0,0 +1,135 @@
/* Ppmd8.h -- PPMdI codec
2010-03-24 : Igor Pavlov : Public domain
This code is based on:
PPMd var.I (2002): Dmitry Shkarin : Public domain
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
#ifndef __PPMD8_H
#define __PPMD8_H
#include "Ppmd.h"
EXTERN_C_BEGIN
#define PPMD8_MIN_ORDER 2
#define PPMD8_MAX_ORDER 16
struct CPpmd8_Context_;
typedef
#ifdef PPMD_32BIT
struct CPpmd8_Context_ *
#else
UInt32
#endif
CPpmd8_Context_Ref;
typedef struct CPpmd8_Context_
{
Byte NumStats;
Byte Flags;
UInt16 SummFreq;
CPpmd_State_Ref Stats;
CPpmd8_Context_Ref Suffix;
} CPpmd8_Context;
#define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
/* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed
code is not compatible with original code for some files compressed
in FREEZE mode. So we disable FREEZE mode support. */
enum
{
PPMD8_RESTORE_METHOD_RESTART,
PPMD8_RESTORE_METHOD_CUT_OFF
#ifdef PPMD8_FREEZE_SUPPORT
, PPMD8_RESTORE_METHOD_FREEZE
#endif
};
typedef struct
{
CPpmd8_Context *MinContext, *MaxContext;
CPpmd_State *FoundState;
unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder;
Int32 RunLength, InitRL; /* must be 32-bit at least */
/* Model order to be used by calling program. */
Int32 Order;
UInt32 Size;
UInt32 GlueCount;
Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
UInt32 AlignOffset;
unsigned RestoreMethod;
/* Range Coder */
UInt32 Range;
UInt32 Code;
UInt32 Low;
Byte *buf;
UInt32 bufUsed, bufLen;
Byte Indx2Units[PPMD_NUM_INDEXES];
Byte Units2Indx[128];
CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
UInt32 Stamps[PPMD_NUM_INDEXES];
Byte NS2BSIndx[256], NS2Indx[260];
CPpmd_See DummySee, See[24][32];
UInt16 BinSumm[25][64];
} CPpmd8;
void Ppmd8_Construct(CPpmd8 *p);
Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAlloc *alloc);
void Ppmd8_Free(CPpmd8 *p, ISzAlloc *alloc);
void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod);
#define Ppmd8_WasAllocated(p) ((p)->Base != NULL)
/* ---------- Internal Functions ---------- */
extern const Byte PPMD8_kExpEscape[16];
#ifdef PPMD_32BIT
#define Ppmd8_GetPtr(p, ptr) (ptr)
#define Ppmd8_GetContext(p, ptr) (ptr)
#define Ppmd8_GetStats(p, ctx) ((ctx)->Stats)
#else
#define Ppmd8_GetPtr(p, offs) ((void *)((p)->Base + (offs)))
#define Ppmd8_GetContext(p, offs) ((CPpmd8_Context *)Ppmd8_GetPtr((p), (offs)))
#define Ppmd8_GetStats(p, ctx) ((CPpmd_State *)Ppmd8_GetPtr((p), ((ctx)->Stats)))
#endif
void Ppmd8_Update1(CPpmd8 *p);
void Ppmd8_Update1_0(CPpmd8 *p);
void Ppmd8_Update2(CPpmd8 *p);
void Ppmd8_UpdateBin(CPpmd8 *p);
#define Ppmd8_GetBinSumm(p) \
&p->BinSumm[p->NS2Indx[Ppmd8Context_OneState(p->MinContext)->Freq - 1]][ \
p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \
p->PrevSuccess + p->MinContext->Flags + ((p->RunLength >> 26) & 0x20)]
CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale);
/* ---------- Decode ---------- */
Bool Ppmd8_RangeDec_Init(CPpmd8 *p);
#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */
int Ppmd8_DecodeToBuffer(CPpmd8 *p, Byte *buf, size_t buflen, size_t *decodedlen);
/* ---------- Encode ---------- */
#define Ppmd8_RangeEnc_Init(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; }
void Ppmd8_RangeEnc_FlushData(CPpmd8 *p);
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */
void Ppmd8_EncodeBuffer(CPpmd8 *p, Byte *buf, size_t buflen);
EXTERN_C_END
#endif

198
lzma/Ppmd8Dec.c Executable file
View file

@ -0,0 +1,198 @@
/* Ppmd8Dec.c -- PPMdI Decoder
2010-04-16 : Igor Pavlov : Public domain
This code is based on:
PPMd var.I (2002): Dmitry Shkarin : Public domain
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
#include "Ppmd8.h"
#define kTop (1 << 24)
#define kBot (1 << 15)
Bool Ppmd8_RangeDec_Init(CPpmd8 *p)
{
unsigned i;
p->Low = 0;
p->Range = 0xFFFFFFFF;
p->Code = 0;
for (i = 0; i < 4; i++) {
p->Code = (p->Code << 8) | p->buf[p->bufUsed];
p->bufUsed++;
}
return (p->Code < 0xFFFFFFFF);
}
static UInt32 RangeDec_GetThreshold(CPpmd8 *p, UInt32 total)
{
return p->Code / (p->Range /= total);
}
static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size)
{
start *= p->Range;
p->Low += start;
p->Code -= start;
p->Range *= size;
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
(p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1)))
{
p->Code = (p->Code << 8) | p->buf[p->bufUsed];
p->bufUsed++;
p->Range <<= 8;
p->Low <<= 8;
}
}
#define MASK(sym) ((signed char *)charMask)[sym]
int Ppmd8_DecodeSymbol(CPpmd8 *p)
{
int res;
size_t dl;
Byte buf[1];
res = Ppmd8_DecodeToBuffer(p, buf, 1, &dl);
if (res < 0 || dl == 0)
return (res);
return (buf[0]);
}
int Ppmd8_DecodeToBuffer(CPpmd8 *p, Byte *buf, size_t buflen, size_t *decodedlen)
{
size_t charMask[256 / sizeof(size_t)];
size_t _cnt;
int _sym;
*decodedlen = 0;
for (_cnt = 0; _cnt < buflen; _cnt++) {
if (p->MinContext->NumStats != 0)
{
CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext);
unsigned i;
UInt32 count, hiCnt;
if ((count = RangeDec_GetThreshold(p, p->MinContext->SummFreq)) < (hiCnt = s->Freq))
{
Byte symbol;
RangeDec_Decode(p, 0, s->Freq);
p->FoundState = s;
symbol = s->Symbol;
Ppmd8_Update1_0(p);
_sym = symbol;
goto next_iter;
//return symbol;
}
p->PrevSuccess = 0;
i = p->MinContext->NumStats;
do
{
if ((hiCnt += (++s)->Freq) > count)
{
Byte symbol;
RangeDec_Decode(p, hiCnt - s->Freq, s->Freq);
p->FoundState = s;
symbol = s->Symbol;
Ppmd8_Update1(p);
_sym = symbol;
goto next_iter;
//return symbol;
}
}
while (--i);
if (count >= p->MinContext->SummFreq) {
_sym = -2;
goto next_iter;
//return -2;
}
RangeDec_Decode(p, hiCnt, p->MinContext->SummFreq - hiCnt);
PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0;
i = p->MinContext->NumStats;
do { MASK((--s)->Symbol) = 0; } while (--i);
}
else
{
UInt16 *prob = Ppmd8_GetBinSumm(p);
if (((p->Code / (p->Range >>= 14)) < *prob))
{
Byte symbol;
RangeDec_Decode(p, 0, *prob);
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
symbol = (p->FoundState = Ppmd8Context_OneState(p->MinContext))->Symbol;
Ppmd8_UpdateBin(p);
_sym = symbol;
goto next_iter;
//return symbol;
}
RangeDec_Decode(p, *prob, (1 << 14) - *prob);
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
p->InitEsc = PPMD8_kExpEscape[*prob >> 10];
PPMD_SetAllBitsIn256Bytes(charMask);
MASK(Ppmd8Context_OneState(p->MinContext)->Symbol) = 0;
p->PrevSuccess = 0;
}
for (;;)
{
CPpmd_State *ps[256], *s;
UInt32 freqSum, count, hiCnt;
CPpmd_See *see;
unsigned i, num, numMasked = p->MinContext->NumStats;
do
{
p->OrderFall++;
if (!p->MinContext->Suffix) {
_sym = -1;
goto next_iter;
//return -1;
}
p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix);
}
while (p->MinContext->NumStats == numMasked);
hiCnt = 0;
s = Ppmd8_GetStats(p, p->MinContext);
i = 0;
num = p->MinContext->NumStats - numMasked;
do
{
int k = (int)(MASK(s->Symbol));
hiCnt += (s->Freq & k);
ps[i] = s++;
i -= k;
}
while (i != num);
see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum);
freqSum += hiCnt;
count = RangeDec_GetThreshold(p, freqSum);
if (count < hiCnt)
{
Byte symbol;
CPpmd_State **pps = ps;
for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);
s = *pps;
RangeDec_Decode(p, hiCnt - s->Freq, s->Freq);
Ppmd_See_Update(see);
p->FoundState = s;
symbol = s->Symbol;
Ppmd8_Update2(p);
_sym = symbol;
goto next_iter;
//return symbol;
}
if (count >= freqSum) {
_sym = -2;
goto next_iter;
//return -2;
}
RangeDec_Decode(p, hiCnt, freqSum - hiCnt);
see->Summ = (UInt16)(see->Summ + freqSum);
do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);
}
next_iter:
if (_sym < -1) return (_sym);
(*decodedlen)++;
if (_sym < 0) return (_sym);
buf[_cnt] = _sym;
}
return (0);
}

201
lzma/Ppmd8Enc.c Executable file
View file

@ -0,0 +1,201 @@
/* Ppmd8Enc.c -- PPMdI Encoder
2010-04-16 : Igor Pavlov : Public domain
This code is based on:
PPMd var.I (2002): Dmitry Shkarin : Public domain
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
#include "Ppmd8.h"
#define kTop (1 << 24)
#define kBot (1 << 15)
void Ppmd8_RangeEnc_FlushData(CPpmd8 *p)
{
unsigned i;
for (i = 0; i < 4; i++, p->Low <<= 8 ) {
p->buf[p->bufUsed] = (Byte)(p->Low >> 24);
p->bufUsed++;
}
// p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
}
static void RangeEnc_Normalize(CPpmd8 *p)
{
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
(p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1)))
{
p->buf[p->bufUsed] = (Byte)(p->Low >> 24);
p->bufUsed++;
//p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
p->Range <<= 8;
p->Low <<= 8;
}
}
static void RangeEnc_Encode(CPpmd8 *p, UInt32 start, UInt32 size, UInt32 total)
{
p->Low += start * (p->Range /= total);
p->Range *= size;
RangeEnc_Normalize(p);
}
static void RangeEnc_EncodeBit_0(CPpmd8 *p, UInt32 size0)
{
p->Range >>= 14;
p->Range *= size0;
RangeEnc_Normalize(p);
}
static void RangeEnc_EncodeBit_1(CPpmd8 *p, UInt32 size0)
{
p->Low += size0 * (p->Range >>= 14);
p->Range *= ((1 << 14) - size0);
RangeEnc_Normalize(p);
}
#define MASK(sym) ((signed char *)charMask)[sym]
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
{
Byte buf[1];
if (symbol == -1) {
Ppmd8_EncodeBuffer(p, NULL, 1);
} else {
buf[0] = symbol;
Ppmd8_EncodeBuffer(p, buf, 1);
}
}
void Ppmd8_EncodeBuffer(CPpmd8 *p, Byte *buf, size_t buflen)
{
size_t charMask[256 / sizeof(size_t)];
size_t _cnt;
int symbol;
if (!buf) buflen = 1;
for (_cnt = 0; _cnt < buflen; _cnt++) {
if (buf)
symbol = buf[_cnt];
else
symbol = -1;
if (p->MinContext->NumStats != 0)
{
CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext);
UInt32 sum;
unsigned i;
if (s->Symbol == symbol)
{
RangeEnc_Encode(p, 0, s->Freq, p->MinContext->SummFreq);
p->FoundState = s;
Ppmd8_Update1_0(p);
//return;
goto next_iter;
}
p->PrevSuccess = 0;
sum = s->Freq;
i = p->MinContext->NumStats;
do
{
if ((++s)->Symbol == symbol)
{
RangeEnc_Encode(p, sum, s->Freq, p->MinContext->SummFreq);
p->FoundState = s;
Ppmd8_Update1(p);
//return;
goto next_iter;
}
sum += s->Freq;
}
while (--i);
PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0;
i = p->MinContext->NumStats;
do { MASK((--s)->Symbol) = 0; } while (--i);
RangeEnc_Encode(p, sum, p->MinContext->SummFreq - sum, p->MinContext->SummFreq);
}
else
{
UInt16 *prob = Ppmd8_GetBinSumm(p);
CPpmd_State *s = Ppmd8Context_OneState(p->MinContext);
if (s->Symbol == symbol)
{
RangeEnc_EncodeBit_0(p, *prob);
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
p->FoundState = s;
Ppmd8_UpdateBin(p);
//return;
goto next_iter;
}
else
{
RangeEnc_EncodeBit_1(p, *prob);
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
p->InitEsc = PPMD8_kExpEscape[*prob >> 10];
PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0;
p->PrevSuccess = 0;
}
}
for (;;)
{
UInt32 escFreq;
CPpmd_See *see;
CPpmd_State *s;
UInt32 sum;
unsigned i, numMasked = p->MinContext->NumStats;
do
{
p->OrderFall++;
if (!p->MinContext->Suffix)
goto next_iter;
//return; /* EndMarker (symbol = -1) */
p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix);
}
while (p->MinContext->NumStats == numMasked);
see = Ppmd8_MakeEscFreq(p, numMasked, &escFreq);
s = Ppmd8_GetStats(p, p->MinContext);
sum = 0;
i = p->MinContext->NumStats + 1;
do
{
int cur = s->Symbol;
if (cur == symbol)
{
UInt32 low = sum;
CPpmd_State *s1 = s;
while (i > 2)
{
sum += (s->Freq & (int)(MASK(s->Symbol)));
s++; i--;
sum += (s->Freq & (int)(MASK(s->Symbol)));
s++; i--;
}
do
{
sum += (s->Freq & (int)(MASK(s->Symbol)));
s++;
}
while (--i);
RangeEnc_Encode(p, low, s1->Freq, sum + escFreq);
Ppmd_See_Update(see);
p->FoundState = s1;
Ppmd8_Update2(p);
//return;
goto next_iter;
}
sum += (s->Freq & (int)(MASK(cur)));
MASK(cur) = 0;
s++;
}
while (--i);
RangeEnc_Encode(p, sum, escFreq, sum + escFreq);
see->Summ = (UInt16)(see->Summ + sum + escFreq);
}
next_iter:;
}
}

255
lzma/Types.h Normal file
View file

@ -0,0 +1,255 @@
/* Types.h -- Basic types
2010-10-09 : Igor Pavlov : Public domain */
#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H
#include <stddef.h>
#ifdef _WIN32
#include <windows.h>
#endif
#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
#define EXTERN_C_BEGIN extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_BEGIN
#define EXTERN_C_END
#endif
#endif
EXTERN_C_BEGIN
#define SZ_OK 0
#define SZ_ERROR_DATA 1
#define SZ_ERROR_MEM 2
#define SZ_ERROR_CRC 3
#define SZ_ERROR_UNSUPPORTED 4
#define SZ_ERROR_PARAM 5
#define SZ_ERROR_INPUT_EOF 6
#define SZ_ERROR_OUTPUT_EOF 7
#define SZ_ERROR_READ 8
#define SZ_ERROR_WRITE 9
#define SZ_ERROR_PROGRESS 10
#define SZ_ERROR_FAIL 11
#define SZ_ERROR_THREAD 12
#define SZ_ERROR_ARCHIVE 16
#define SZ_ERROR_NO_ARCHIVE 17
typedef int SRes;
#ifdef _WIN32
typedef DWORD WRes;
#else
typedef int WRes;
#endif
#ifndef RINOK
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
#endif
typedef unsigned char Byte;
typedef short Int16;
typedef unsigned short UInt16;
#ifdef _LZMA_UINT32_IS_ULONG
typedef long Int32;
typedef unsigned long UInt32;
#else
typedef int Int32;
typedef unsigned int UInt32;
#endif
#ifdef _SZ_NO_INT_64
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
NOTES: Some code will work incorrectly in that case! */
typedef long Int64;
typedef unsigned long UInt64;
#else
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#define UINT64_CONST(n) n
#else
typedef long long int Int64;
typedef unsigned long long int UInt64;
#define UINT64_CONST(n) n ## ULL
#endif
#endif
#ifdef _LZMA_NO_SYSTEM_SIZE_T
typedef UInt32 SizeT;
#else
typedef size_t SizeT;
#endif
typedef int Bool;
#define True 1
#define False 0
#ifdef _WIN32
#define MY_STD_CALL __stdcall
#else
#define MY_STD_CALL
#endif
#ifdef _MSC_VER
#if _MSC_VER >= 1300
#define MY_NO_INLINE __declspec(noinline)
#else
#define MY_NO_INLINE
#endif
#define MY_CDECL __cdecl
#define MY_FAST_CALL __fastcall
#else
#define MY_CDECL
#define MY_FAST_CALL
#endif
/* The following interfaces use first parameter as pointer to structure */
typedef struct
{
Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
} IByteIn;
typedef struct
{
void (*Write)(void *p, Byte b);
} IByteOut;
typedef struct
{
SRes (*Read)(void *p, void *buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
(output(*size) < input(*size)) is allowed */
} ISeqInStream;
/* it can return SZ_ERROR_INPUT_EOF */
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
typedef struct
{
size_t (*Write)(void *p, const void *buf, size_t size);
/* Returns: result - the number of actually written bytes.
(result < size) means error */
} ISeqOutStream;
typedef enum
{
SZ_SEEK_SET = 0,
SZ_SEEK_CUR = 1,
SZ_SEEK_END = 2
} ESzSeek;
typedef struct
{
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
} ISeekInStream;
typedef struct
{
SRes (*Look)(void *p, const void **buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
(output(*size) > input(*size)) is not allowed
(output(*size) < input(*size)) is allowed */
SRes (*Skip)(void *p, size_t offset);
/* offset must be <= output(*size) of Look */
SRes (*Read)(void *p, void *buf, size_t *size);
/* reads directly (without buffer). It's same as ISeqInStream::Read */
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
} ILookInStream;
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
/* reads via ILookInStream::Read */
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
#define LookToRead_BUF_SIZE (1 << 14)
typedef struct
{
ILookInStream s;
ISeekInStream *realStream;
size_t pos;
size_t size;
Byte buf[LookToRead_BUF_SIZE];
} CLookToRead;
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
void LookToRead_Init(CLookToRead *p);
typedef struct
{
ISeqInStream s;
ILookInStream *realStream;
} CSecToLook;
void SecToLook_CreateVTable(CSecToLook *p);
typedef struct
{
ISeqInStream s;
ILookInStream *realStream;
} CSecToRead;
void SecToRead_CreateVTable(CSecToRead *p);
typedef struct
{
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
/* Returns: result. (result != SZ_OK) means break.
Value (UInt64)(Int64)-1 for size means unknown value. */
} ICompressProgress;
typedef struct
{
void *(*Alloc)(void *p, size_t size);
void (*Free)(void *p, void *address); /* address can be 0 */
void (*FreeSz)(void *p, void *address, size_t size); /* address can be 0 */
} ISzAlloc;
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
#define IAlloc_Free(p, a) (p)->Free((p), a)
#ifdef _WIN32
#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"/"
#endif
EXTERN_C_END
#endif

82
lzma/crc32_fast.c Normal file
View file

@ -0,0 +1,82 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc32.c
/// \brief CRC32 calculation
///
/// Calculate the CRC32 using the slice-by-eight algorithm.
/// It is explained in this document:
/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf
/// The code in this file is not the same as in Intel's paper, but
/// the basic principle is identical.
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include <crc_macros.h>
extern const uint32_t lzma_crc32_table[8][256];
// If you make any changes, do some bench marking! Seemingly unrelated
// changes can very easily ruin the performance (and very probably is
// very compiler dependent).
extern uint32_t
lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
{
crc = ~crc;
#ifdef WORDS_BIGENDIAN
crc = bswap32(crc);
#endif
if (size > 8) {
// Fix the alignment, if needed. The if statement above
// ensures that this won't read past the end of buf[].
while ((uintptr_t)(buf) & 7) {
crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
--size;
}
// Calculate the position where to stop.
const uint8_t *const limit = buf + (size & ~(size_t)(7));
// Calculate how many bytes must be calculated separately
// before returning the result.
size &= (size_t)(7);
// Calculate the CRC32 using the slice-by-eight algorithm.
while (buf < limit) {
crc ^= *(const uint32_t *)(buf);
buf += 4;
crc = lzma_crc32_table[7][A(crc)]
^ lzma_crc32_table[6][B(crc)]
^ lzma_crc32_table[5][C(crc)]
^ lzma_crc32_table[4][D(crc)];
const uint32_t tmp = *(const uint32_t *)(buf);
buf += 4;
// At least with some compilers, it is critical for
// performance, that the crc variable is XORed
// between the two table-lookup pairs.
crc = lzma_crc32_table[3][A(tmp)]
^ lzma_crc32_table[2][B(tmp)]
^ crc
^ lzma_crc32_table[1][C(tmp)]
^ lzma_crc32_table[0][D(tmp)];
}
}
while (size-- != 0)
crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
#ifdef WORDS_BIGENDIAN
crc = bswap32(crc);
#endif
return ~crc;
}

23
lzma/crc32_table.c Normal file
View file

@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc32_table.c
/// \brief Precalculated CRC32 table with correct endianness
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
/*
* This gives us BYTE_ORDER macro both on Linux and Solaris derived
* systems.
*/
#include <arpa/nameser_compat.h>
#if BYTE_ORDER == LITTLE_ENDIAN
# include "crc32_table_le.h"
#else
# include "crc32_table_be.h"
#endif

526
lzma/crc32_table_be.h Normal file
View file

@ -0,0 +1,526 @@
/* This file has been automatically generated by crc32_tablegen.c. */
#include <utils.h>
const uint32_t lzma_crc32_table[8][256] = {
{
0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,
0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,
0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297,
0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90,
0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84,
0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383,
0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A,
0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D,
0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2,
0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5,
0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC,
0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB,
0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF,
0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8,
0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1,
0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6,
0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF,
0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8,
0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1,
0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6,
0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2,
0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5,
0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC,
0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB,
0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4,
0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3,
0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA,
0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD,
0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9,
0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE,
0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7,
0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0,
0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174,
0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73,
0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A,
0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D,
0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669,
0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E,
0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67,
0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060,
0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F,
0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248,
0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441,
0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946,
0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852,
0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555,
0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C,
0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B,
0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02,
0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005,
0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C,
0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B,
0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F,
0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718,
0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111,
0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16,
0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339,
0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E,
0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837,
0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530,
0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424,
0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923,
0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A,
0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D
}, {
0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B,
0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F,
0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3,
0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887,
0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61,
0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305,
0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9,
0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD,
0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE,
0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA,
0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076,
0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12,
0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4,
0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790,
0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C,
0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58,
0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB,
0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF,
0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13,
0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177,
0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691,
0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5,
0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59,
0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D,
0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E,
0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A,
0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986,
0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2,
0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204,
0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60,
0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC,
0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8,
0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10,
0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274,
0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8,
0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC,
0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A,
0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E,
0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592,
0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6,
0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85,
0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1,
0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D,
0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29,
0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF,
0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB,
0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107,
0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63,
0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0,
0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84,
0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28,
0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C,
0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA,
0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE,
0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62,
0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006,
0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375,
0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11,
0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD,
0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9,
0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F,
0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B,
0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7,
0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493
}, {
0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602,
0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05,
0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C,
0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B,
0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E,
0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919,
0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310,
0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17,
0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A,
0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D,
0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834,
0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133,
0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26,
0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421,
0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28,
0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F,
0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72,
0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575,
0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C,
0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B,
0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E,
0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369,
0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960,
0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067,
0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A,
0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D,
0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244,
0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43,
0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756,
0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51,
0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458,
0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F,
0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3,
0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4,
0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED,
0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA,
0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF,
0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8,
0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1,
0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6,
0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB,
0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC,
0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5,
0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2,
0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7,
0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0,
0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9,
0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE,
0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993,
0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094,
0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D,
0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A,
0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F,
0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688,
0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81,
0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586,
0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB,
0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC,
0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5,
0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2,
0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7,
0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0,
0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9,
0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE
}, {
0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512,
0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D,
0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7,
0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358,
0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42,
0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD,
0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887,
0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08,
0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2,
0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D,
0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377,
0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8,
0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2,
0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D,
0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27,
0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8,
0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189,
0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306,
0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C,
0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3,
0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9,
0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56,
0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C,
0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93,
0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329,
0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6,
0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC,
0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563,
0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79,
0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6,
0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC,
0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33,
0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF,
0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70,
0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A,
0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5,
0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF,
0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720,
0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A,
0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5,
0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F,
0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0,
0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A,
0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815,
0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F,
0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580,
0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA,
0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145,
0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864,
0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB,
0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1,
0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E,
0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134,
0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB,
0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1,
0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E,
0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4,
0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B,
0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01,
0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E,
0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394,
0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B,
0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751,
0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE
}, {
0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047,
0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2,
0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077,
0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082,
0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027,
0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2,
0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017,
0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2,
0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186,
0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173,
0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6,
0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143,
0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6,
0x461EA154, 0xF637C169, 0x264D612E, 0x96640113,
0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6,
0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123,
0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F,
0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA,
0x88138368, 0x383AE355, 0xE8404312, 0x5869232F,
0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA,
0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F,
0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A,
0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F,
0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA,
0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE,
0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B,
0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE,
0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B,
0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE,
0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B,
0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E,
0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B,
0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6,
0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603,
0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6,
0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633,
0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696,
0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663,
0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6,
0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653,
0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737,
0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2,
0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707,
0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2,
0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757,
0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2,
0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767,
0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792,
0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE,
0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B,
0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E,
0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B,
0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE,
0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B,
0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE,
0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B,
0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F,
0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A,
0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F,
0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA,
0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F,
0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA,
0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F,
0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA
}, {
0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486,
0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D,
0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A,
0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1,
0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285,
0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E,
0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169,
0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2,
0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881,
0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A,
0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D,
0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6,
0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82,
0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19,
0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E,
0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5,
0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89,
0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12,
0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65,
0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE,
0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A,
0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11,
0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966,
0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD,
0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E,
0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115,
0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362,
0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9,
0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D,
0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716,
0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561,
0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA,
0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498,
0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503,
0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774,
0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF,
0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B,
0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300,
0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177,
0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC,
0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F,
0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904,
0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73,
0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8,
0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C,
0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07,
0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70,
0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB,
0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97,
0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C,
0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B,
0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0,
0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94,
0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F,
0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978,
0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3,
0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090,
0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B,
0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C,
0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7,
0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693,
0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708,
0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F,
0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4
}, {
0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831,
0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5,
0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702,
0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6,
0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656,
0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2,
0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965,
0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691,
0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE,
0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A,
0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD,
0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539,
0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99,
0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D,
0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA,
0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E,
0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375,
0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81,
0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46,
0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2,
0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12,
0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6,
0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221,
0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5,
0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA,
0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E,
0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189,
0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D,
0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD,
0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29,
0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE,
0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A,
0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9,
0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D,
0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A,
0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E,
0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE,
0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A,
0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED,
0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019,
0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376,
0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82,
0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45,
0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1,
0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11,
0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5,
0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222,
0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6,
0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD,
0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09,
0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE,
0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A,
0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A,
0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E,
0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9,
0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D,
0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832,
0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6,
0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701,
0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5,
0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655,
0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1,
0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966,
0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692
}, {
0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E,
0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A,
0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D,
0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9,
0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2,
0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76,
0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121,
0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5,
0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977,
0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3,
0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4,
0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620,
0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B,
0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F,
0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8,
0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C,
0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7,
0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823,
0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774,
0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0,
0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB,
0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F,
0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08,
0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C,
0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E,
0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA,
0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D,
0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09,
0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22,
0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6,
0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1,
0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075,
0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD,
0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59,
0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E,
0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A,
0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1,
0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525,
0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72,
0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6,
0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224,
0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0,
0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7,
0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73,
0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958,
0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC,
0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B,
0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F,
0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4,
0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370,
0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27,
0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3,
0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288,
0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C,
0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B,
0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF,
0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D,
0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589,
0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE,
0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A,
0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471,
0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5,
0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2,
0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26
}
};

526
lzma/crc32_table_le.h Normal file
View file

@ -0,0 +1,526 @@
/* This file has been automatically generated by crc32_tablegen.c. */
#include <utils.h>
const uint32_t lzma_crc32_table[8][256] = {
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
}, {
0x00000000, 0x191B3141, 0x32366282, 0x2B2D53C3,
0x646CC504, 0x7D77F445, 0x565AA786, 0x4F4196C7,
0xC8D98A08, 0xD1C2BB49, 0xFAEFE88A, 0xE3F4D9CB,
0xACB54F0C, 0xB5AE7E4D, 0x9E832D8E, 0x87981CCF,
0x4AC21251, 0x53D92310, 0x78F470D3, 0x61EF4192,
0x2EAED755, 0x37B5E614, 0x1C98B5D7, 0x05838496,
0x821B9859, 0x9B00A918, 0xB02DFADB, 0xA936CB9A,
0xE6775D5D, 0xFF6C6C1C, 0xD4413FDF, 0xCD5A0E9E,
0x958424A2, 0x8C9F15E3, 0xA7B24620, 0xBEA97761,
0xF1E8E1A6, 0xE8F3D0E7, 0xC3DE8324, 0xDAC5B265,
0x5D5DAEAA, 0x44469FEB, 0x6F6BCC28, 0x7670FD69,
0x39316BAE, 0x202A5AEF, 0x0B07092C, 0x121C386D,
0xDF4636F3, 0xC65D07B2, 0xED705471, 0xF46B6530,
0xBB2AF3F7, 0xA231C2B6, 0x891C9175, 0x9007A034,
0x179FBCFB, 0x0E848DBA, 0x25A9DE79, 0x3CB2EF38,
0x73F379FF, 0x6AE848BE, 0x41C51B7D, 0x58DE2A3C,
0xF0794F05, 0xE9627E44, 0xC24F2D87, 0xDB541CC6,
0x94158A01, 0x8D0EBB40, 0xA623E883, 0xBF38D9C2,
0x38A0C50D, 0x21BBF44C, 0x0A96A78F, 0x138D96CE,
0x5CCC0009, 0x45D73148, 0x6EFA628B, 0x77E153CA,
0xBABB5D54, 0xA3A06C15, 0x888D3FD6, 0x91960E97,
0xDED79850, 0xC7CCA911, 0xECE1FAD2, 0xF5FACB93,
0x7262D75C, 0x6B79E61D, 0x4054B5DE, 0x594F849F,
0x160E1258, 0x0F152319, 0x243870DA, 0x3D23419B,
0x65FD6BA7, 0x7CE65AE6, 0x57CB0925, 0x4ED03864,
0x0191AEA3, 0x188A9FE2, 0x33A7CC21, 0x2ABCFD60,
0xAD24E1AF, 0xB43FD0EE, 0x9F12832D, 0x8609B26C,
0xC94824AB, 0xD05315EA, 0xFB7E4629, 0xE2657768,
0x2F3F79F6, 0x362448B7, 0x1D091B74, 0x04122A35,
0x4B53BCF2, 0x52488DB3, 0x7965DE70, 0x607EEF31,
0xE7E6F3FE, 0xFEFDC2BF, 0xD5D0917C, 0xCCCBA03D,
0x838A36FA, 0x9A9107BB, 0xB1BC5478, 0xA8A76539,
0x3B83984B, 0x2298A90A, 0x09B5FAC9, 0x10AECB88,
0x5FEF5D4F, 0x46F46C0E, 0x6DD93FCD, 0x74C20E8C,
0xF35A1243, 0xEA412302, 0xC16C70C1, 0xD8774180,
0x9736D747, 0x8E2DE606, 0xA500B5C5, 0xBC1B8484,
0x71418A1A, 0x685ABB5B, 0x4377E898, 0x5A6CD9D9,
0x152D4F1E, 0x0C367E5F, 0x271B2D9C, 0x3E001CDD,
0xB9980012, 0xA0833153, 0x8BAE6290, 0x92B553D1,
0xDDF4C516, 0xC4EFF457, 0xEFC2A794, 0xF6D996D5,
0xAE07BCE9, 0xB71C8DA8, 0x9C31DE6B, 0x852AEF2A,
0xCA6B79ED, 0xD37048AC, 0xF85D1B6F, 0xE1462A2E,
0x66DE36E1, 0x7FC507A0, 0x54E85463, 0x4DF36522,
0x02B2F3E5, 0x1BA9C2A4, 0x30849167, 0x299FA026,
0xE4C5AEB8, 0xFDDE9FF9, 0xD6F3CC3A, 0xCFE8FD7B,
0x80A96BBC, 0x99B25AFD, 0xB29F093E, 0xAB84387F,
0x2C1C24B0, 0x350715F1, 0x1E2A4632, 0x07317773,
0x4870E1B4, 0x516BD0F5, 0x7A468336, 0x635DB277,
0xCBFAD74E, 0xD2E1E60F, 0xF9CCB5CC, 0xE0D7848D,
0xAF96124A, 0xB68D230B, 0x9DA070C8, 0x84BB4189,
0x03235D46, 0x1A386C07, 0x31153FC4, 0x280E0E85,
0x674F9842, 0x7E54A903, 0x5579FAC0, 0x4C62CB81,
0x8138C51F, 0x9823F45E, 0xB30EA79D, 0xAA1596DC,
0xE554001B, 0xFC4F315A, 0xD7626299, 0xCE7953D8,
0x49E14F17, 0x50FA7E56, 0x7BD72D95, 0x62CC1CD4,
0x2D8D8A13, 0x3496BB52, 0x1FBBE891, 0x06A0D9D0,
0x5E7EF3EC, 0x4765C2AD, 0x6C48916E, 0x7553A02F,
0x3A1236E8, 0x230907A9, 0x0824546A, 0x113F652B,
0x96A779E4, 0x8FBC48A5, 0xA4911B66, 0xBD8A2A27,
0xF2CBBCE0, 0xEBD08DA1, 0xC0FDDE62, 0xD9E6EF23,
0x14BCE1BD, 0x0DA7D0FC, 0x268A833F, 0x3F91B27E,
0x70D024B9, 0x69CB15F8, 0x42E6463B, 0x5BFD777A,
0xDC656BB5, 0xC57E5AF4, 0xEE530937, 0xF7483876,
0xB809AEB1, 0xA1129FF0, 0x8A3FCC33, 0x9324FD72
}, {
0x00000000, 0x01C26A37, 0x0384D46E, 0x0246BE59,
0x0709A8DC, 0x06CBC2EB, 0x048D7CB2, 0x054F1685,
0x0E1351B8, 0x0FD13B8F, 0x0D9785D6, 0x0C55EFE1,
0x091AF964, 0x08D89353, 0x0A9E2D0A, 0x0B5C473D,
0x1C26A370, 0x1DE4C947, 0x1FA2771E, 0x1E601D29,
0x1B2F0BAC, 0x1AED619B, 0x18ABDFC2, 0x1969B5F5,
0x1235F2C8, 0x13F798FF, 0x11B126A6, 0x10734C91,
0x153C5A14, 0x14FE3023, 0x16B88E7A, 0x177AE44D,
0x384D46E0, 0x398F2CD7, 0x3BC9928E, 0x3A0BF8B9,
0x3F44EE3C, 0x3E86840B, 0x3CC03A52, 0x3D025065,
0x365E1758, 0x379C7D6F, 0x35DAC336, 0x3418A901,
0x3157BF84, 0x3095D5B3, 0x32D36BEA, 0x331101DD,
0x246BE590, 0x25A98FA7, 0x27EF31FE, 0x262D5BC9,
0x23624D4C, 0x22A0277B, 0x20E69922, 0x2124F315,
0x2A78B428, 0x2BBADE1F, 0x29FC6046, 0x283E0A71,
0x2D711CF4, 0x2CB376C3, 0x2EF5C89A, 0x2F37A2AD,
0x709A8DC0, 0x7158E7F7, 0x731E59AE, 0x72DC3399,
0x7793251C, 0x76514F2B, 0x7417F172, 0x75D59B45,
0x7E89DC78, 0x7F4BB64F, 0x7D0D0816, 0x7CCF6221,
0x798074A4, 0x78421E93, 0x7A04A0CA, 0x7BC6CAFD,
0x6CBC2EB0, 0x6D7E4487, 0x6F38FADE, 0x6EFA90E9,
0x6BB5866C, 0x6A77EC5B, 0x68315202, 0x69F33835,
0x62AF7F08, 0x636D153F, 0x612BAB66, 0x60E9C151,
0x65A6D7D4, 0x6464BDE3, 0x662203BA, 0x67E0698D,
0x48D7CB20, 0x4915A117, 0x4B531F4E, 0x4A917579,
0x4FDE63FC, 0x4E1C09CB, 0x4C5AB792, 0x4D98DDA5,
0x46C49A98, 0x4706F0AF, 0x45404EF6, 0x448224C1,
0x41CD3244, 0x400F5873, 0x4249E62A, 0x438B8C1D,
0x54F16850, 0x55330267, 0x5775BC3E, 0x56B7D609,
0x53F8C08C, 0x523AAABB, 0x507C14E2, 0x51BE7ED5,
0x5AE239E8, 0x5B2053DF, 0x5966ED86, 0x58A487B1,
0x5DEB9134, 0x5C29FB03, 0x5E6F455A, 0x5FAD2F6D,
0xE1351B80, 0xE0F771B7, 0xE2B1CFEE, 0xE373A5D9,
0xE63CB35C, 0xE7FED96B, 0xE5B86732, 0xE47A0D05,
0xEF264A38, 0xEEE4200F, 0xECA29E56, 0xED60F461,
0xE82FE2E4, 0xE9ED88D3, 0xEBAB368A, 0xEA695CBD,
0xFD13B8F0, 0xFCD1D2C7, 0xFE976C9E, 0xFF5506A9,
0xFA1A102C, 0xFBD87A1B, 0xF99EC442, 0xF85CAE75,
0xF300E948, 0xF2C2837F, 0xF0843D26, 0xF1465711,
0xF4094194, 0xF5CB2BA3, 0xF78D95FA, 0xF64FFFCD,
0xD9785D60, 0xD8BA3757, 0xDAFC890E, 0xDB3EE339,
0xDE71F5BC, 0xDFB39F8B, 0xDDF521D2, 0xDC374BE5,
0xD76B0CD8, 0xD6A966EF, 0xD4EFD8B6, 0xD52DB281,
0xD062A404, 0xD1A0CE33, 0xD3E6706A, 0xD2241A5D,
0xC55EFE10, 0xC49C9427, 0xC6DA2A7E, 0xC7184049,
0xC25756CC, 0xC3953CFB, 0xC1D382A2, 0xC011E895,
0xCB4DAFA8, 0xCA8FC59F, 0xC8C97BC6, 0xC90B11F1,
0xCC440774, 0xCD866D43, 0xCFC0D31A, 0xCE02B92D,
0x91AF9640, 0x906DFC77, 0x922B422E, 0x93E92819,
0x96A63E9C, 0x976454AB, 0x9522EAF2, 0x94E080C5,
0x9FBCC7F8, 0x9E7EADCF, 0x9C381396, 0x9DFA79A1,
0x98B56F24, 0x99770513, 0x9B31BB4A, 0x9AF3D17D,
0x8D893530, 0x8C4B5F07, 0x8E0DE15E, 0x8FCF8B69,
0x8A809DEC, 0x8B42F7DB, 0x89044982, 0x88C623B5,
0x839A6488, 0x82580EBF, 0x801EB0E6, 0x81DCDAD1,
0x8493CC54, 0x8551A663, 0x8717183A, 0x86D5720D,
0xA9E2D0A0, 0xA820BA97, 0xAA6604CE, 0xABA46EF9,
0xAEEB787C, 0xAF29124B, 0xAD6FAC12, 0xACADC625,
0xA7F18118, 0xA633EB2F, 0xA4755576, 0xA5B73F41,
0xA0F829C4, 0xA13A43F3, 0xA37CFDAA, 0xA2BE979D,
0xB5C473D0, 0xB40619E7, 0xB640A7BE, 0xB782CD89,
0xB2CDDB0C, 0xB30FB13B, 0xB1490F62, 0xB08B6555,
0xBBD72268, 0xBA15485F, 0xB853F606, 0xB9919C31,
0xBCDE8AB4, 0xBD1CE083, 0xBF5A5EDA, 0xBE9834ED
}, {
0x00000000, 0xB8BC6765, 0xAA09C88B, 0x12B5AFEE,
0x8F629757, 0x37DEF032, 0x256B5FDC, 0x9DD738B9,
0xC5B428EF, 0x7D084F8A, 0x6FBDE064, 0xD7018701,
0x4AD6BFB8, 0xF26AD8DD, 0xE0DF7733, 0x58631056,
0x5019579F, 0xE8A530FA, 0xFA109F14, 0x42ACF871,
0xDF7BC0C8, 0x67C7A7AD, 0x75720843, 0xCDCE6F26,
0x95AD7F70, 0x2D111815, 0x3FA4B7FB, 0x8718D09E,
0x1ACFE827, 0xA2738F42, 0xB0C620AC, 0x087A47C9,
0xA032AF3E, 0x188EC85B, 0x0A3B67B5, 0xB28700D0,
0x2F503869, 0x97EC5F0C, 0x8559F0E2, 0x3DE59787,
0x658687D1, 0xDD3AE0B4, 0xCF8F4F5A, 0x7733283F,
0xEAE41086, 0x525877E3, 0x40EDD80D, 0xF851BF68,
0xF02BF8A1, 0x48979FC4, 0x5A22302A, 0xE29E574F,
0x7F496FF6, 0xC7F50893, 0xD540A77D, 0x6DFCC018,
0x359FD04E, 0x8D23B72B, 0x9F9618C5, 0x272A7FA0,
0xBAFD4719, 0x0241207C, 0x10F48F92, 0xA848E8F7,
0x9B14583D, 0x23A83F58, 0x311D90B6, 0x89A1F7D3,
0x1476CF6A, 0xACCAA80F, 0xBE7F07E1, 0x06C36084,
0x5EA070D2, 0xE61C17B7, 0xF4A9B859, 0x4C15DF3C,
0xD1C2E785, 0x697E80E0, 0x7BCB2F0E, 0xC377486B,
0xCB0D0FA2, 0x73B168C7, 0x6104C729, 0xD9B8A04C,
0x446F98F5, 0xFCD3FF90, 0xEE66507E, 0x56DA371B,
0x0EB9274D, 0xB6054028, 0xA4B0EFC6, 0x1C0C88A3,
0x81DBB01A, 0x3967D77F, 0x2BD27891, 0x936E1FF4,
0x3B26F703, 0x839A9066, 0x912F3F88, 0x299358ED,
0xB4446054, 0x0CF80731, 0x1E4DA8DF, 0xA6F1CFBA,
0xFE92DFEC, 0x462EB889, 0x549B1767, 0xEC277002,
0x71F048BB, 0xC94C2FDE, 0xDBF98030, 0x6345E755,
0x6B3FA09C, 0xD383C7F9, 0xC1366817, 0x798A0F72,
0xE45D37CB, 0x5CE150AE, 0x4E54FF40, 0xF6E89825,
0xAE8B8873, 0x1637EF16, 0x048240F8, 0xBC3E279D,
0x21E91F24, 0x99557841, 0x8BE0D7AF, 0x335CB0CA,
0xED59B63B, 0x55E5D15E, 0x47507EB0, 0xFFEC19D5,
0x623B216C, 0xDA874609, 0xC832E9E7, 0x708E8E82,
0x28ED9ED4, 0x9051F9B1, 0x82E4565F, 0x3A58313A,
0xA78F0983, 0x1F336EE6, 0x0D86C108, 0xB53AA66D,
0xBD40E1A4, 0x05FC86C1, 0x1749292F, 0xAFF54E4A,
0x322276F3, 0x8A9E1196, 0x982BBE78, 0x2097D91D,
0x78F4C94B, 0xC048AE2E, 0xD2FD01C0, 0x6A4166A5,
0xF7965E1C, 0x4F2A3979, 0x5D9F9697, 0xE523F1F2,
0x4D6B1905, 0xF5D77E60, 0xE762D18E, 0x5FDEB6EB,
0xC2098E52, 0x7AB5E937, 0x680046D9, 0xD0BC21BC,
0x88DF31EA, 0x3063568F, 0x22D6F961, 0x9A6A9E04,
0x07BDA6BD, 0xBF01C1D8, 0xADB46E36, 0x15080953,
0x1D724E9A, 0xA5CE29FF, 0xB77B8611, 0x0FC7E174,
0x9210D9CD, 0x2AACBEA8, 0x38191146, 0x80A57623,
0xD8C66675, 0x607A0110, 0x72CFAEFE, 0xCA73C99B,
0x57A4F122, 0xEF189647, 0xFDAD39A9, 0x45115ECC,
0x764DEE06, 0xCEF18963, 0xDC44268D, 0x64F841E8,
0xF92F7951, 0x41931E34, 0x5326B1DA, 0xEB9AD6BF,
0xB3F9C6E9, 0x0B45A18C, 0x19F00E62, 0xA14C6907,
0x3C9B51BE, 0x842736DB, 0x96929935, 0x2E2EFE50,
0x2654B999, 0x9EE8DEFC, 0x8C5D7112, 0x34E11677,
0xA9362ECE, 0x118A49AB, 0x033FE645, 0xBB838120,
0xE3E09176, 0x5B5CF613, 0x49E959FD, 0xF1553E98,
0x6C820621, 0xD43E6144, 0xC68BCEAA, 0x7E37A9CF,
0xD67F4138, 0x6EC3265D, 0x7C7689B3, 0xC4CAEED6,
0x591DD66F, 0xE1A1B10A, 0xF3141EE4, 0x4BA87981,
0x13CB69D7, 0xAB770EB2, 0xB9C2A15C, 0x017EC639,
0x9CA9FE80, 0x241599E5, 0x36A0360B, 0x8E1C516E,
0x866616A7, 0x3EDA71C2, 0x2C6FDE2C, 0x94D3B949,
0x090481F0, 0xB1B8E695, 0xA30D497B, 0x1BB12E1E,
0x43D23E48, 0xFB6E592D, 0xE9DBF6C3, 0x516791A6,
0xCCB0A91F, 0x740CCE7A, 0x66B96194, 0xDE0506F1
}, {
0x00000000, 0x3D6029B0, 0x7AC05360, 0x47A07AD0,
0xF580A6C0, 0xC8E08F70, 0x8F40F5A0, 0xB220DC10,
0x30704BC1, 0x0D106271, 0x4AB018A1, 0x77D03111,
0xC5F0ED01, 0xF890C4B1, 0xBF30BE61, 0x825097D1,
0x60E09782, 0x5D80BE32, 0x1A20C4E2, 0x2740ED52,
0x95603142, 0xA80018F2, 0xEFA06222, 0xD2C04B92,
0x5090DC43, 0x6DF0F5F3, 0x2A508F23, 0x1730A693,
0xA5107A83, 0x98705333, 0xDFD029E3, 0xE2B00053,
0xC1C12F04, 0xFCA106B4, 0xBB017C64, 0x866155D4,
0x344189C4, 0x0921A074, 0x4E81DAA4, 0x73E1F314,
0xF1B164C5, 0xCCD14D75, 0x8B7137A5, 0xB6111E15,
0x0431C205, 0x3951EBB5, 0x7EF19165, 0x4391B8D5,
0xA121B886, 0x9C419136, 0xDBE1EBE6, 0xE681C256,
0x54A11E46, 0x69C137F6, 0x2E614D26, 0x13016496,
0x9151F347, 0xAC31DAF7, 0xEB91A027, 0xD6F18997,
0x64D15587, 0x59B17C37, 0x1E1106E7, 0x23712F57,
0x58F35849, 0x659371F9, 0x22330B29, 0x1F532299,
0xAD73FE89, 0x9013D739, 0xD7B3ADE9, 0xEAD38459,
0x68831388, 0x55E33A38, 0x124340E8, 0x2F236958,
0x9D03B548, 0xA0639CF8, 0xE7C3E628, 0xDAA3CF98,
0x3813CFCB, 0x0573E67B, 0x42D39CAB, 0x7FB3B51B,
0xCD93690B, 0xF0F340BB, 0xB7533A6B, 0x8A3313DB,
0x0863840A, 0x3503ADBA, 0x72A3D76A, 0x4FC3FEDA,
0xFDE322CA, 0xC0830B7A, 0x872371AA, 0xBA43581A,
0x9932774D, 0xA4525EFD, 0xE3F2242D, 0xDE920D9D,
0x6CB2D18D, 0x51D2F83D, 0x167282ED, 0x2B12AB5D,
0xA9423C8C, 0x9422153C, 0xD3826FEC, 0xEEE2465C,
0x5CC29A4C, 0x61A2B3FC, 0x2602C92C, 0x1B62E09C,
0xF9D2E0CF, 0xC4B2C97F, 0x8312B3AF, 0xBE729A1F,
0x0C52460F, 0x31326FBF, 0x7692156F, 0x4BF23CDF,
0xC9A2AB0E, 0xF4C282BE, 0xB362F86E, 0x8E02D1DE,
0x3C220DCE, 0x0142247E, 0x46E25EAE, 0x7B82771E,
0xB1E6B092, 0x8C869922, 0xCB26E3F2, 0xF646CA42,
0x44661652, 0x79063FE2, 0x3EA64532, 0x03C66C82,
0x8196FB53, 0xBCF6D2E3, 0xFB56A833, 0xC6368183,
0x74165D93, 0x49767423, 0x0ED60EF3, 0x33B62743,
0xD1062710, 0xEC660EA0, 0xABC67470, 0x96A65DC0,
0x248681D0, 0x19E6A860, 0x5E46D2B0, 0x6326FB00,
0xE1766CD1, 0xDC164561, 0x9BB63FB1, 0xA6D61601,
0x14F6CA11, 0x2996E3A1, 0x6E369971, 0x5356B0C1,
0x70279F96, 0x4D47B626, 0x0AE7CCF6, 0x3787E546,
0x85A73956, 0xB8C710E6, 0xFF676A36, 0xC2074386,
0x4057D457, 0x7D37FDE7, 0x3A978737, 0x07F7AE87,
0xB5D77297, 0x88B75B27, 0xCF1721F7, 0xF2770847,
0x10C70814, 0x2DA721A4, 0x6A075B74, 0x576772C4,
0xE547AED4, 0xD8278764, 0x9F87FDB4, 0xA2E7D404,
0x20B743D5, 0x1DD76A65, 0x5A7710B5, 0x67173905,
0xD537E515, 0xE857CCA5, 0xAFF7B675, 0x92979FC5,
0xE915E8DB, 0xD475C16B, 0x93D5BBBB, 0xAEB5920B,
0x1C954E1B, 0x21F567AB, 0x66551D7B, 0x5B3534CB,
0xD965A31A, 0xE4058AAA, 0xA3A5F07A, 0x9EC5D9CA,
0x2CE505DA, 0x11852C6A, 0x562556BA, 0x6B457F0A,
0x89F57F59, 0xB49556E9, 0xF3352C39, 0xCE550589,
0x7C75D999, 0x4115F029, 0x06B58AF9, 0x3BD5A349,
0xB9853498, 0x84E51D28, 0xC34567F8, 0xFE254E48,
0x4C059258, 0x7165BBE8, 0x36C5C138, 0x0BA5E888,
0x28D4C7DF, 0x15B4EE6F, 0x521494BF, 0x6F74BD0F,
0xDD54611F, 0xE03448AF, 0xA794327F, 0x9AF41BCF,
0x18A48C1E, 0x25C4A5AE, 0x6264DF7E, 0x5F04F6CE,
0xED242ADE, 0xD044036E, 0x97E479BE, 0xAA84500E,
0x4834505D, 0x755479ED, 0x32F4033D, 0x0F942A8D,
0xBDB4F69D, 0x80D4DF2D, 0xC774A5FD, 0xFA148C4D,
0x78441B9C, 0x4524322C, 0x028448FC, 0x3FE4614C,
0x8DC4BD5C, 0xB0A494EC, 0xF704EE3C, 0xCA64C78C
}, {
0x00000000, 0xCB5CD3A5, 0x4DC8A10B, 0x869472AE,
0x9B914216, 0x50CD91B3, 0xD659E31D, 0x1D0530B8,
0xEC53826D, 0x270F51C8, 0xA19B2366, 0x6AC7F0C3,
0x77C2C07B, 0xBC9E13DE, 0x3A0A6170, 0xF156B2D5,
0x03D6029B, 0xC88AD13E, 0x4E1EA390, 0x85427035,
0x9847408D, 0x531B9328, 0xD58FE186, 0x1ED33223,
0xEF8580F6, 0x24D95353, 0xA24D21FD, 0x6911F258,
0x7414C2E0, 0xBF481145, 0x39DC63EB, 0xF280B04E,
0x07AC0536, 0xCCF0D693, 0x4A64A43D, 0x81387798,
0x9C3D4720, 0x57619485, 0xD1F5E62B, 0x1AA9358E,
0xEBFF875B, 0x20A354FE, 0xA6372650, 0x6D6BF5F5,
0x706EC54D, 0xBB3216E8, 0x3DA66446, 0xF6FAB7E3,
0x047A07AD, 0xCF26D408, 0x49B2A6A6, 0x82EE7503,
0x9FEB45BB, 0x54B7961E, 0xD223E4B0, 0x197F3715,
0xE82985C0, 0x23755665, 0xA5E124CB, 0x6EBDF76E,
0x73B8C7D6, 0xB8E41473, 0x3E7066DD, 0xF52CB578,
0x0F580A6C, 0xC404D9C9, 0x4290AB67, 0x89CC78C2,
0x94C9487A, 0x5F959BDF, 0xD901E971, 0x125D3AD4,
0xE30B8801, 0x28575BA4, 0xAEC3290A, 0x659FFAAF,
0x789ACA17, 0xB3C619B2, 0x35526B1C, 0xFE0EB8B9,
0x0C8E08F7, 0xC7D2DB52, 0x4146A9FC, 0x8A1A7A59,
0x971F4AE1, 0x5C439944, 0xDAD7EBEA, 0x118B384F,
0xE0DD8A9A, 0x2B81593F, 0xAD152B91, 0x6649F834,
0x7B4CC88C, 0xB0101B29, 0x36846987, 0xFDD8BA22,
0x08F40F5A, 0xC3A8DCFF, 0x453CAE51, 0x8E607DF4,
0x93654D4C, 0x58399EE9, 0xDEADEC47, 0x15F13FE2,
0xE4A78D37, 0x2FFB5E92, 0xA96F2C3C, 0x6233FF99,
0x7F36CF21, 0xB46A1C84, 0x32FE6E2A, 0xF9A2BD8F,
0x0B220DC1, 0xC07EDE64, 0x46EAACCA, 0x8DB67F6F,
0x90B34FD7, 0x5BEF9C72, 0xDD7BEEDC, 0x16273D79,
0xE7718FAC, 0x2C2D5C09, 0xAAB92EA7, 0x61E5FD02,
0x7CE0CDBA, 0xB7BC1E1F, 0x31286CB1, 0xFA74BF14,
0x1EB014D8, 0xD5ECC77D, 0x5378B5D3, 0x98246676,
0x852156CE, 0x4E7D856B, 0xC8E9F7C5, 0x03B52460,
0xF2E396B5, 0x39BF4510, 0xBF2B37BE, 0x7477E41B,
0x6972D4A3, 0xA22E0706, 0x24BA75A8, 0xEFE6A60D,
0x1D661643, 0xD63AC5E6, 0x50AEB748, 0x9BF264ED,
0x86F75455, 0x4DAB87F0, 0xCB3FF55E, 0x006326FB,
0xF135942E, 0x3A69478B, 0xBCFD3525, 0x77A1E680,
0x6AA4D638, 0xA1F8059D, 0x276C7733, 0xEC30A496,
0x191C11EE, 0xD240C24B, 0x54D4B0E5, 0x9F886340,
0x828D53F8, 0x49D1805D, 0xCF45F2F3, 0x04192156,
0xF54F9383, 0x3E134026, 0xB8873288, 0x73DBE12D,
0x6EDED195, 0xA5820230, 0x2316709E, 0xE84AA33B,
0x1ACA1375, 0xD196C0D0, 0x5702B27E, 0x9C5E61DB,
0x815B5163, 0x4A0782C6, 0xCC93F068, 0x07CF23CD,
0xF6999118, 0x3DC542BD, 0xBB513013, 0x700DE3B6,
0x6D08D30E, 0xA65400AB, 0x20C07205, 0xEB9CA1A0,
0x11E81EB4, 0xDAB4CD11, 0x5C20BFBF, 0x977C6C1A,
0x8A795CA2, 0x41258F07, 0xC7B1FDA9, 0x0CED2E0C,
0xFDBB9CD9, 0x36E74F7C, 0xB0733DD2, 0x7B2FEE77,
0x662ADECF, 0xAD760D6A, 0x2BE27FC4, 0xE0BEAC61,
0x123E1C2F, 0xD962CF8A, 0x5FF6BD24, 0x94AA6E81,
0x89AF5E39, 0x42F38D9C, 0xC467FF32, 0x0F3B2C97,
0xFE6D9E42, 0x35314DE7, 0xB3A53F49, 0x78F9ECEC,
0x65FCDC54, 0xAEA00FF1, 0x28347D5F, 0xE368AEFA,
0x16441B82, 0xDD18C827, 0x5B8CBA89, 0x90D0692C,
0x8DD55994, 0x46898A31, 0xC01DF89F, 0x0B412B3A,
0xFA1799EF, 0x314B4A4A, 0xB7DF38E4, 0x7C83EB41,
0x6186DBF9, 0xAADA085C, 0x2C4E7AF2, 0xE712A957,
0x15921919, 0xDECECABC, 0x585AB812, 0x93066BB7,
0x8E035B0F, 0x455F88AA, 0xC3CBFA04, 0x089729A1,
0xF9C19B74, 0x329D48D1, 0xB4093A7F, 0x7F55E9DA,
0x6250D962, 0xA90C0AC7, 0x2F987869, 0xE4C4ABCC
}, {
0x00000000, 0xA6770BB4, 0x979F1129, 0x31E81A9D,
0xF44F2413, 0x52382FA7, 0x63D0353A, 0xC5A73E8E,
0x33EF4E67, 0x959845D3, 0xA4705F4E, 0x020754FA,
0xC7A06A74, 0x61D761C0, 0x503F7B5D, 0xF64870E9,
0x67DE9CCE, 0xC1A9977A, 0xF0418DE7, 0x56368653,
0x9391B8DD, 0x35E6B369, 0x040EA9F4, 0xA279A240,
0x5431D2A9, 0xF246D91D, 0xC3AEC380, 0x65D9C834,
0xA07EF6BA, 0x0609FD0E, 0x37E1E793, 0x9196EC27,
0xCFBD399C, 0x69CA3228, 0x582228B5, 0xFE552301,
0x3BF21D8F, 0x9D85163B, 0xAC6D0CA6, 0x0A1A0712,
0xFC5277FB, 0x5A257C4F, 0x6BCD66D2, 0xCDBA6D66,
0x081D53E8, 0xAE6A585C, 0x9F8242C1, 0x39F54975,
0xA863A552, 0x0E14AEE6, 0x3FFCB47B, 0x998BBFCF,
0x5C2C8141, 0xFA5B8AF5, 0xCBB39068, 0x6DC49BDC,
0x9B8CEB35, 0x3DFBE081, 0x0C13FA1C, 0xAA64F1A8,
0x6FC3CF26, 0xC9B4C492, 0xF85CDE0F, 0x5E2BD5BB,
0x440B7579, 0xE27C7ECD, 0xD3946450, 0x75E36FE4,
0xB044516A, 0x16335ADE, 0x27DB4043, 0x81AC4BF7,
0x77E43B1E, 0xD19330AA, 0xE07B2A37, 0x460C2183,
0x83AB1F0D, 0x25DC14B9, 0x14340E24, 0xB2430590,
0x23D5E9B7, 0x85A2E203, 0xB44AF89E, 0x123DF32A,
0xD79ACDA4, 0x71EDC610, 0x4005DC8D, 0xE672D739,
0x103AA7D0, 0xB64DAC64, 0x87A5B6F9, 0x21D2BD4D,
0xE47583C3, 0x42028877, 0x73EA92EA, 0xD59D995E,
0x8BB64CE5, 0x2DC14751, 0x1C295DCC, 0xBA5E5678,
0x7FF968F6, 0xD98E6342, 0xE86679DF, 0x4E11726B,
0xB8590282, 0x1E2E0936, 0x2FC613AB, 0x89B1181F,
0x4C162691, 0xEA612D25, 0xDB8937B8, 0x7DFE3C0C,
0xEC68D02B, 0x4A1FDB9F, 0x7BF7C102, 0xDD80CAB6,
0x1827F438, 0xBE50FF8C, 0x8FB8E511, 0x29CFEEA5,
0xDF879E4C, 0x79F095F8, 0x48188F65, 0xEE6F84D1,
0x2BC8BA5F, 0x8DBFB1EB, 0xBC57AB76, 0x1A20A0C2,
0x8816EAF2, 0x2E61E146, 0x1F89FBDB, 0xB9FEF06F,
0x7C59CEE1, 0xDA2EC555, 0xEBC6DFC8, 0x4DB1D47C,
0xBBF9A495, 0x1D8EAF21, 0x2C66B5BC, 0x8A11BE08,
0x4FB68086, 0xE9C18B32, 0xD82991AF, 0x7E5E9A1B,
0xEFC8763C, 0x49BF7D88, 0x78576715, 0xDE206CA1,
0x1B87522F, 0xBDF0599B, 0x8C184306, 0x2A6F48B2,
0xDC27385B, 0x7A5033EF, 0x4BB82972, 0xEDCF22C6,
0x28681C48, 0x8E1F17FC, 0xBFF70D61, 0x198006D5,
0x47ABD36E, 0xE1DCD8DA, 0xD034C247, 0x7643C9F3,
0xB3E4F77D, 0x1593FCC9, 0x247BE654, 0x820CEDE0,
0x74449D09, 0xD23396BD, 0xE3DB8C20, 0x45AC8794,
0x800BB91A, 0x267CB2AE, 0x1794A833, 0xB1E3A387,
0x20754FA0, 0x86024414, 0xB7EA5E89, 0x119D553D,
0xD43A6BB3, 0x724D6007, 0x43A57A9A, 0xE5D2712E,
0x139A01C7, 0xB5ED0A73, 0x840510EE, 0x22721B5A,
0xE7D525D4, 0x41A22E60, 0x704A34FD, 0xD63D3F49,
0xCC1D9F8B, 0x6A6A943F, 0x5B828EA2, 0xFDF58516,
0x3852BB98, 0x9E25B02C, 0xAFCDAAB1, 0x09BAA105,
0xFFF2D1EC, 0x5985DA58, 0x686DC0C5, 0xCE1ACB71,
0x0BBDF5FF, 0xADCAFE4B, 0x9C22E4D6, 0x3A55EF62,
0xABC30345, 0x0DB408F1, 0x3C5C126C, 0x9A2B19D8,
0x5F8C2756, 0xF9FB2CE2, 0xC813367F, 0x6E643DCB,
0x982C4D22, 0x3E5B4696, 0x0FB35C0B, 0xA9C457BF,
0x6C636931, 0xCA146285, 0xFBFC7818, 0x5D8B73AC,
0x03A0A617, 0xA5D7ADA3, 0x943FB73E, 0x3248BC8A,
0xF7EF8204, 0x519889B0, 0x6070932D, 0xC6079899,
0x304FE870, 0x9638E3C4, 0xA7D0F959, 0x01A7F2ED,
0xC400CC63, 0x6277C7D7, 0x539FDD4A, 0xF5E8D6FE,
0x647E3AD9, 0xC209316D, 0xF3E12BF0, 0x55962044,
0x90311ECA, 0x3646157E, 0x07AE0FE3, 0xA1D90457,
0x579174BE, 0xF1E67F0A, 0xC00E6597, 0x66796E23,
0xA3DE50AD, 0x05A95B19, 0x34414184, 0x92364A30
}, {
0x00000000, 0xCCAA009E, 0x4225077D, 0x8E8F07E3,
0x844A0EFA, 0x48E00E64, 0xC66F0987, 0x0AC50919,
0xD3E51BB5, 0x1F4F1B2B, 0x91C01CC8, 0x5D6A1C56,
0x57AF154F, 0x9B0515D1, 0x158A1232, 0xD92012AC,
0x7CBB312B, 0xB01131B5, 0x3E9E3656, 0xF23436C8,
0xF8F13FD1, 0x345B3F4F, 0xBAD438AC, 0x767E3832,
0xAF5E2A9E, 0x63F42A00, 0xED7B2DE3, 0x21D12D7D,
0x2B142464, 0xE7BE24FA, 0x69312319, 0xA59B2387,
0xF9766256, 0x35DC62C8, 0xBB53652B, 0x77F965B5,
0x7D3C6CAC, 0xB1966C32, 0x3F196BD1, 0xF3B36B4F,
0x2A9379E3, 0xE639797D, 0x68B67E9E, 0xA41C7E00,
0xAED97719, 0x62737787, 0xECFC7064, 0x205670FA,
0x85CD537D, 0x496753E3, 0xC7E85400, 0x0B42549E,
0x01875D87, 0xCD2D5D19, 0x43A25AFA, 0x8F085A64,
0x562848C8, 0x9A824856, 0x140D4FB5, 0xD8A74F2B,
0xD2624632, 0x1EC846AC, 0x9047414F, 0x5CED41D1,
0x299DC2ED, 0xE537C273, 0x6BB8C590, 0xA712C50E,
0xADD7CC17, 0x617DCC89, 0xEFF2CB6A, 0x2358CBF4,
0xFA78D958, 0x36D2D9C6, 0xB85DDE25, 0x74F7DEBB,
0x7E32D7A2, 0xB298D73C, 0x3C17D0DF, 0xF0BDD041,
0x5526F3C6, 0x998CF358, 0x1703F4BB, 0xDBA9F425,
0xD16CFD3C, 0x1DC6FDA2, 0x9349FA41, 0x5FE3FADF,
0x86C3E873, 0x4A69E8ED, 0xC4E6EF0E, 0x084CEF90,
0x0289E689, 0xCE23E617, 0x40ACE1F4, 0x8C06E16A,
0xD0EBA0BB, 0x1C41A025, 0x92CEA7C6, 0x5E64A758,
0x54A1AE41, 0x980BAEDF, 0x1684A93C, 0xDA2EA9A2,
0x030EBB0E, 0xCFA4BB90, 0x412BBC73, 0x8D81BCED,
0x8744B5F4, 0x4BEEB56A, 0xC561B289, 0x09CBB217,
0xAC509190, 0x60FA910E, 0xEE7596ED, 0x22DF9673,
0x281A9F6A, 0xE4B09FF4, 0x6A3F9817, 0xA6959889,
0x7FB58A25, 0xB31F8ABB, 0x3D908D58, 0xF13A8DC6,
0xFBFF84DF, 0x37558441, 0xB9DA83A2, 0x7570833C,
0x533B85DA, 0x9F918544, 0x111E82A7, 0xDDB48239,
0xD7718B20, 0x1BDB8BBE, 0x95548C5D, 0x59FE8CC3,
0x80DE9E6F, 0x4C749EF1, 0xC2FB9912, 0x0E51998C,
0x04949095, 0xC83E900B, 0x46B197E8, 0x8A1B9776,
0x2F80B4F1, 0xE32AB46F, 0x6DA5B38C, 0xA10FB312,
0xABCABA0B, 0x6760BA95, 0xE9EFBD76, 0x2545BDE8,
0xFC65AF44, 0x30CFAFDA, 0xBE40A839, 0x72EAA8A7,
0x782FA1BE, 0xB485A120, 0x3A0AA6C3, 0xF6A0A65D,
0xAA4DE78C, 0x66E7E712, 0xE868E0F1, 0x24C2E06F,
0x2E07E976, 0xE2ADE9E8, 0x6C22EE0B, 0xA088EE95,
0x79A8FC39, 0xB502FCA7, 0x3B8DFB44, 0xF727FBDA,
0xFDE2F2C3, 0x3148F25D, 0xBFC7F5BE, 0x736DF520,
0xD6F6D6A7, 0x1A5CD639, 0x94D3D1DA, 0x5879D144,
0x52BCD85D, 0x9E16D8C3, 0x1099DF20, 0xDC33DFBE,
0x0513CD12, 0xC9B9CD8C, 0x4736CA6F, 0x8B9CCAF1,
0x8159C3E8, 0x4DF3C376, 0xC37CC495, 0x0FD6C40B,
0x7AA64737, 0xB60C47A9, 0x3883404A, 0xF42940D4,
0xFEEC49CD, 0x32464953, 0xBCC94EB0, 0x70634E2E,
0xA9435C82, 0x65E95C1C, 0xEB665BFF, 0x27CC5B61,
0x2D095278, 0xE1A352E6, 0x6F2C5505, 0xA386559B,
0x061D761C, 0xCAB77682, 0x44387161, 0x889271FF,
0x825778E6, 0x4EFD7878, 0xC0727F9B, 0x0CD87F05,
0xD5F86DA9, 0x19526D37, 0x97DD6AD4, 0x5B776A4A,
0x51B26353, 0x9D1863CD, 0x1397642E, 0xDF3D64B0,
0x83D02561, 0x4F7A25FF, 0xC1F5221C, 0x0D5F2282,
0x079A2B9B, 0xCB302B05, 0x45BF2CE6, 0x89152C78,
0x50353ED4, 0x9C9F3E4A, 0x121039A9, 0xDEBA3937,
0xD47F302E, 0x18D530B0, 0x965A3753, 0x5AF037CD,
0xFF6B144A, 0x33C114D4, 0xBD4E1337, 0x71E413A9,
0x7B211AB0, 0xB78B1A2E, 0x39041DCD, 0xF5AE1D53,
0x2C8E0FFF, 0xE0240F61, 0x6EAB0882, 0xA201081C,
0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6
}
};

117
lzma/crc32_tablegen.c Normal file
View file

@ -0,0 +1,117 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc32_tablegen.c
/// \brief Generate crc32_table_le.h and crc32_table_be.h
///
/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c
/// Add -DWORDS_BIGENDIAN to generate big endian table.
/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian).
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "../../common/tuklib_integer.h"
static uint32_t crc32_table[8][256];
static void
init_crc32_table(void)
{
static const uint32_t poly32 = UINT32_C(0xEDB88320);
for (size_t s = 0; s < 8; ++s) {
for (size_t b = 0; b < 256; ++b) {
uint32_t r = s == 0 ? b : crc32_table[s - 1][b];
for (size_t i = 0; i < 8; ++i) {
if (r & 1)
r = (r >> 1) ^ poly32;
else
r >>= 1;
}
crc32_table[s][b] = r;
}
}
#ifdef WORDS_BIGENDIAN
for (size_t s = 0; s < 8; ++s)
for (size_t b = 0; b < 256; ++b)
crc32_table[s][b] = bswap32(crc32_table[s][b]);
#endif
return;
}
static void
print_crc32_table(void)
{
printf("/* This file has been automatically generated by "
"crc32_tablegen.c. */\n\n"
"const uint32_t lzma_crc32_table[8][256] = {\n\t{");
for (size_t s = 0; s < 8; ++s) {
for (size_t b = 0; b < 256; ++b) {
if ((b % 4) == 0)
printf("\n\t\t");
printf("0x%08" PRIX32, crc32_table[s][b]);
if (b != 255)
printf(",%s", (b+1) % 4 == 0 ? "" : " ");
}
if (s == 7)
printf("\n\t}\n};\n");
else
printf("\n\t}, {");
}
return;
}
static void
print_lz_table(void)
{
printf("/* This file has been automatically generated by "
"crc32_tablegen.c. */\n\n"
"const uint32_t lzma_lz_hash_table[256] = {");
for (size_t b = 0; b < 256; ++b) {
if ((b % 4) == 0)
printf("\n\t");
printf("0x%08" PRIX32, crc32_table[0][b]);
if (b != 255)
printf(",%s", (b+1) % 4 == 0 ? "" : " ");
}
printf("\n};\n");
return;
}
int
main(void)
{
init_crc32_table();
#ifdef LZ_HASH_TABLE
print_lz_table();
#else
print_crc32_table();
#endif
return 0;
}

120
lzma/crc64_fast.c Normal file
View file

@ -0,0 +1,120 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc64.c
/// \brief CRC64 calculation
///
/// Calculate the CRC64 using the slice-by-four algorithm. This is the same
/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables
/// instead of eight to avoid increasing CPU cache usage.
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include <crc_macros.h>
#ifdef WORDS_BIGENDIAN
# define A1(x) ((x) >> 56)
#else
# define A1 A
#endif
extern const uint64_t lzma_crc64_table[4][256];
// See the comments in crc32_fast.c. They aren't duplicated here.
extern uint64_t
lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
{
crc = ~crc;
#ifdef WORDS_BIGENDIAN
crc = bswap64(crc);
#endif
if (size > 4) {
while ((uintptr_t)(buf) & 3) {
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
--size;
}
const uint8_t *const limit = buf + (size & ~(size_t)(3));
size &= (size_t)(3);
while (buf < limit) {
#ifdef WORDS_BIGENDIAN
const uint32_t tmp = (crc >> 32)
^ *(const uint32_t *)(buf);
#else
const uint32_t tmp = crc ^ *(const uint32_t *)(buf);
#endif
buf += 4;
crc = lzma_crc64_table[3][A(tmp)]
^ lzma_crc64_table[2][B(tmp)]
^ S32(crc)
^ lzma_crc64_table[1][C(tmp)]
^ lzma_crc64_table[0][D(tmp)];
}
}
while (size-- != 0)
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
#ifdef WORDS_BIGENDIAN
crc = bswap64(crc);
#endif
return ~crc;
}
extern uint64_t
lzma_crc64_8bchk(const uint8_t *buf, size_t size, uint64_t crc, uint64_t *cnt)
{
crc = ~crc;
uint64_t cnt1 = 0;
#ifdef WORDS_BIGENDIAN
crc = bswap64(crc);
#endif
if (size > 4) {
while ((uintptr_t)(buf) & 3) {
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
--size;
}
const uint8_t *const limit = buf + (size & ~(size_t)(3));
size &= (size_t)(3);
while (buf < limit) {
uint32_t val = *(const uint32_t *)(buf);
#ifdef WORDS_BIGENDIAN
const uint32_t tmp = (crc >> 32) ^ val;
#else
const uint32_t tmp = crc ^ val;
#endif
buf += 4;
val >>= 7; cnt1 += (val & 1);
val >>= 8; cnt1 += (val & 1);
crc = lzma_crc64_table[3][A(tmp)]
^ lzma_crc64_table[2][B(tmp)]
^ S32(crc)
^ lzma_crc64_table[1][C(tmp)]
^ lzma_crc64_table[0][D(tmp)];
}
}
while (size-- != 0)
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
#ifdef WORDS_BIGENDIAN
crc = bswap64(crc);
#endif
*cnt = cnt1;
return ~crc;
}

24
lzma/crc64_table.c Normal file
View file

@ -0,0 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc64_table.c
/// \brief Precalculated CRC64 table with correct endianness
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
/*
* This gives us BYTE_ORDER macro both on Linux and Solaris derived
* systems.
*/
#include <arpa/nameser_compat.h>
#if BYTE_ORDER == LITTLE_ENDIAN
# include "crc64_table_le.h"
#else
# include "crc64_table_be.h"
#endif

521
lzma/crc64_table_be.h Normal file
View file

@ -0,0 +1,521 @@
/* This file has been automatically generated by crc64_tablegen.c. */
const uint64_t lzma_crc64_table[4][256] = {
{
UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3),
UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47),
UINT64_C(0x335E8FFF84C3D07B), UINT64_C(0x5C0128FC3A8FFEC8),
UINT64_C(0x68FECF57D3F5548F), UINT64_C(0x07A168546DB97A3C),
UINT64_C(0x66BC1EFF0987A1F7), UINT64_C(0x09E3B9FCB7CB8F44),
UINT64_C(0x3D1C5E575EB12503), UINT64_C(0x5243F954E0FD0BB0),
UINT64_C(0x55E291008D44718C), UINT64_C(0x3ABD360333085F3F),
UINT64_C(0x0E42D1A8DA72F578), UINT64_C(0x611D76AB643EDBCB),
UINT64_C(0x4966335138A19B7D), UINT64_C(0x2639945286EDB5CE),
UINT64_C(0x12C673F96F971F89), UINT64_C(0x7D99D4FAD1DB313A),
UINT64_C(0x7A38BCAEBC624B06), UINT64_C(0x15671BAD022E65B5),
UINT64_C(0x2198FC06EB54CFF2), UINT64_C(0x4EC75B055518E141),
UINT64_C(0x2FDA2DAE31263A8A), UINT64_C(0x40858AAD8F6A1439),
UINT64_C(0x747A6D066610BE7E), UINT64_C(0x1B25CA05D85C90CD),
UINT64_C(0x1C84A251B5E5EAF1), UINT64_C(0x73DB05520BA9C442),
UINT64_C(0x4724E2F9E2D36E05), UINT64_C(0x287B45FA5C9F40B6),
UINT64_C(0x92CC66A2704237FB), UINT64_C(0xFD93C1A1CE0E1948),
UINT64_C(0xC96C260A2774B30F), UINT64_C(0xA633810999389DBC),
UINT64_C(0xA192E95DF481E780), UINT64_C(0xCECD4E5E4ACDC933),
UINT64_C(0xFA32A9F5A3B76374), UINT64_C(0x956D0EF61DFB4DC7),
UINT64_C(0xF470785D79C5960C), UINT64_C(0x9B2FDF5EC789B8BF),
UINT64_C(0xAFD038F52EF312F8), UINT64_C(0xC08F9FF690BF3C4B),
UINT64_C(0xC72EF7A2FD064677), UINT64_C(0xA87150A1434A68C4),
UINT64_C(0x9C8EB70AAA30C283), UINT64_C(0xF3D11009147CEC30),
UINT64_C(0xDBAA55F348E3AC86), UINT64_C(0xB4F5F2F0F6AF8235),
UINT64_C(0x800A155B1FD52872), UINT64_C(0xEF55B258A19906C1),
UINT64_C(0xE8F4DA0CCC207CFD), UINT64_C(0x87AB7D0F726C524E),
UINT64_C(0xB3549AA49B16F809), UINT64_C(0xDC0B3DA7255AD6BA),
UINT64_C(0xBD164B0C41640D71), UINT64_C(0xD249EC0FFF2823C2),
UINT64_C(0xE6B60BA416528985), UINT64_C(0x89E9ACA7A81EA736),
UINT64_C(0x8E48C4F3C5A7DD0A), UINT64_C(0xE11763F07BEBF3B9),
UINT64_C(0xD5E8845B929159FE), UINT64_C(0xBAB723582CDD774D),
UINT64_C(0xA187C3EBCA2BB664), UINT64_C(0xCED864E8746798D7),
UINT64_C(0xFA2783439D1D3290), UINT64_C(0x9578244023511C23),
UINT64_C(0x92D94C144EE8661F), UINT64_C(0xFD86EB17F0A448AC),
UINT64_C(0xC9790CBC19DEE2EB), UINT64_C(0xA626ABBFA792CC58),
UINT64_C(0xC73BDD14C3AC1793), UINT64_C(0xA8647A177DE03920),
UINT64_C(0x9C9B9DBC949A9367), UINT64_C(0xF3C43ABF2AD6BDD4),
UINT64_C(0xF46552EB476FC7E8), UINT64_C(0x9B3AF5E8F923E95B),
UINT64_C(0xAFC512431059431C), UINT64_C(0xC09AB540AE156DAF),
UINT64_C(0xE8E1F0BAF28A2D19), UINT64_C(0x87BE57B94CC603AA),
UINT64_C(0xB341B012A5BCA9ED), UINT64_C(0xDC1E17111BF0875E),
UINT64_C(0xDBBF7F457649FD62), UINT64_C(0xB4E0D846C805D3D1),
UINT64_C(0x801F3FED217F7996), UINT64_C(0xEF4098EE9F335725),
UINT64_C(0x8E5DEE45FB0D8CEE), UINT64_C(0xE10249464541A25D),
UINT64_C(0xD5FDAEEDAC3B081A), UINT64_C(0xBAA209EE127726A9),
UINT64_C(0xBD0361BA7FCE5C95), UINT64_C(0xD25CC6B9C1827226),
UINT64_C(0xE6A3211228F8D861), UINT64_C(0x89FC861196B4F6D2),
UINT64_C(0x334BA549BA69819F), UINT64_C(0x5C14024A0425AF2C),
UINT64_C(0x68EBE5E1ED5F056B), UINT64_C(0x07B442E253132BD8),
UINT64_C(0x00152AB63EAA51E4), UINT64_C(0x6F4A8DB580E67F57),
UINT64_C(0x5BB56A1E699CD510), UINT64_C(0x34EACD1DD7D0FBA3),
UINT64_C(0x55F7BBB6B3EE2068), UINT64_C(0x3AA81CB50DA20EDB),
UINT64_C(0x0E57FB1EE4D8A49C), UINT64_C(0x61085C1D5A948A2F),
UINT64_C(0x66A93449372DF013), UINT64_C(0x09F6934A8961DEA0),
UINT64_C(0x3D0974E1601B74E7), UINT64_C(0x5256D3E2DE575A54),
UINT64_C(0x7A2D961882C81AE2), UINT64_C(0x1572311B3C843451),
UINT64_C(0x218DD6B0D5FE9E16), UINT64_C(0x4ED271B36BB2B0A5),
UINT64_C(0x497319E7060BCA99), UINT64_C(0x262CBEE4B847E42A),
UINT64_C(0x12D3594F513D4E6D), UINT64_C(0x7D8CFE4CEF7160DE),
UINT64_C(0x1C9188E78B4FBB15), UINT64_C(0x73CE2FE4350395A6),
UINT64_C(0x4731C84FDC793FE1), UINT64_C(0x286E6F4C62351152),
UINT64_C(0x2FCF07180F8C6B6E), UINT64_C(0x4090A01BB1C045DD),
UINT64_C(0x746F47B058BAEF9A), UINT64_C(0x1B30E0B3E6F6C129),
UINT64_C(0x420F87D795576CC9), UINT64_C(0x2D5020D42B1B427A),
UINT64_C(0x19AFC77FC261E83D), UINT64_C(0x76F0607C7C2DC68E),
UINT64_C(0x715108281194BCB2), UINT64_C(0x1E0EAF2BAFD89201),
UINT64_C(0x2AF1488046A23846), UINT64_C(0x45AEEF83F8EE16F5),
UINT64_C(0x24B399289CD0CD3E), UINT64_C(0x4BEC3E2B229CE38D),
UINT64_C(0x7F13D980CBE649CA), UINT64_C(0x104C7E8375AA6779),
UINT64_C(0x17ED16D718131D45), UINT64_C(0x78B2B1D4A65F33F6),
UINT64_C(0x4C4D567F4F2599B1), UINT64_C(0x2312F17CF169B702),
UINT64_C(0x0B69B486ADF6F7B4), UINT64_C(0x6436138513BAD907),
UINT64_C(0x50C9F42EFAC07340), UINT64_C(0x3F96532D448C5DF3),
UINT64_C(0x38373B79293527CF), UINT64_C(0x57689C7A9779097C),
UINT64_C(0x63977BD17E03A33B), UINT64_C(0x0CC8DCD2C04F8D88),
UINT64_C(0x6DD5AA79A4715643), UINT64_C(0x028A0D7A1A3D78F0),
UINT64_C(0x3675EAD1F347D2B7), UINT64_C(0x592A4DD24D0BFC04),
UINT64_C(0x5E8B258620B28638), UINT64_C(0x31D482859EFEA88B),
UINT64_C(0x052B652E778402CC), UINT64_C(0x6A74C22DC9C82C7F),
UINT64_C(0xD0C3E175E5155B32), UINT64_C(0xBF9C46765B597581),
UINT64_C(0x8B63A1DDB223DFC6), UINT64_C(0xE43C06DE0C6FF175),
UINT64_C(0xE39D6E8A61D68B49), UINT64_C(0x8CC2C989DF9AA5FA),
UINT64_C(0xB83D2E2236E00FBD), UINT64_C(0xD762892188AC210E),
UINT64_C(0xB67FFF8AEC92FAC5), UINT64_C(0xD920588952DED476),
UINT64_C(0xEDDFBF22BBA47E31), UINT64_C(0x8280182105E85082),
UINT64_C(0x8521707568512ABE), UINT64_C(0xEA7ED776D61D040D),
UINT64_C(0xDE8130DD3F67AE4A), UINT64_C(0xB1DE97DE812B80F9),
UINT64_C(0x99A5D224DDB4C04F), UINT64_C(0xF6FA752763F8EEFC),
UINT64_C(0xC205928C8A8244BB), UINT64_C(0xAD5A358F34CE6A08),
UINT64_C(0xAAFB5DDB59771034), UINT64_C(0xC5A4FAD8E73B3E87),
UINT64_C(0xF15B1D730E4194C0), UINT64_C(0x9E04BA70B00DBA73),
UINT64_C(0xFF19CCDBD43361B8), UINT64_C(0x90466BD86A7F4F0B),
UINT64_C(0xA4B98C738305E54C), UINT64_C(0xCBE62B703D49CBFF),
UINT64_C(0xCC47432450F0B1C3), UINT64_C(0xA318E427EEBC9F70),
UINT64_C(0x97E7038C07C63537), UINT64_C(0xF8B8A48FB98A1B84),
UINT64_C(0xE388443C5F7CDAAD), UINT64_C(0x8CD7E33FE130F41E),
UINT64_C(0xB8280494084A5E59), UINT64_C(0xD777A397B60670EA),
UINT64_C(0xD0D6CBC3DBBF0AD6), UINT64_C(0xBF896CC065F32465),
UINT64_C(0x8B768B6B8C898E22), UINT64_C(0xE4292C6832C5A091),
UINT64_C(0x85345AC356FB7B5A), UINT64_C(0xEA6BFDC0E8B755E9),
UINT64_C(0xDE941A6B01CDFFAE), UINT64_C(0xB1CBBD68BF81D11D),
UINT64_C(0xB66AD53CD238AB21), UINT64_C(0xD935723F6C748592),
UINT64_C(0xEDCA9594850E2FD5), UINT64_C(0x829532973B420166),
UINT64_C(0xAAEE776D67DD41D0), UINT64_C(0xC5B1D06ED9916F63),
UINT64_C(0xF14E37C530EBC524), UINT64_C(0x9E1190C68EA7EB97),
UINT64_C(0x99B0F892E31E91AB), UINT64_C(0xF6EF5F915D52BF18),
UINT64_C(0xC210B83AB428155F), UINT64_C(0xAD4F1F390A643BEC),
UINT64_C(0xCC5269926E5AE027), UINT64_C(0xA30DCE91D016CE94),
UINT64_C(0x97F2293A396C64D3), UINT64_C(0xF8AD8E3987204A60),
UINT64_C(0xFF0CE66DEA99305C), UINT64_C(0x9053416E54D51EEF),
UINT64_C(0xA4ACA6C5BDAFB4A8), UINT64_C(0xCBF301C603E39A1B),
UINT64_C(0x7144229E2F3EED56), UINT64_C(0x1E1B859D9172C3E5),
UINT64_C(0x2AE46236780869A2), UINT64_C(0x45BBC535C6444711),
UINT64_C(0x421AAD61ABFD3D2D), UINT64_C(0x2D450A6215B1139E),
UINT64_C(0x19BAEDC9FCCBB9D9), UINT64_C(0x76E54ACA4287976A),
UINT64_C(0x17F83C6126B94CA1), UINT64_C(0x78A79B6298F56212),
UINT64_C(0x4C587CC9718FC855), UINT64_C(0x2307DBCACFC3E6E6),
UINT64_C(0x24A6B39EA27A9CDA), UINT64_C(0x4BF9149D1C36B269),
UINT64_C(0x7F06F336F54C182E), UINT64_C(0x105954354B00369D),
UINT64_C(0x382211CF179F762B), UINT64_C(0x577DB6CCA9D35898),
UINT64_C(0x6382516740A9F2DF), UINT64_C(0x0CDDF664FEE5DC6C),
UINT64_C(0x0B7C9E30935CA650), UINT64_C(0x642339332D1088E3),
UINT64_C(0x50DCDE98C46A22A4), UINT64_C(0x3F83799B7A260C17),
UINT64_C(0x5E9E0F301E18D7DC), UINT64_C(0x31C1A833A054F96F),
UINT64_C(0x053E4F98492E5328), UINT64_C(0x6A61E89BF7627D9B),
UINT64_C(0x6DC080CF9ADB07A7), UINT64_C(0x029F27CC24972914),
UINT64_C(0x3660C067CDED8353), UINT64_C(0x593F676473A1ADE0)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0x0DF1D05C9279E954),
UINT64_C(0x1AE2A1B924F3D2A9), UINT64_C(0x171371E5B68A3BFD),
UINT64_C(0xB1DA4DDC62497DC1), UINT64_C(0xBC2B9D80F0309495),
UINT64_C(0xAB38EC6546BAAF68), UINT64_C(0xA6C93C39D4C3463C),
UINT64_C(0xE7AB9517EE3D2210), UINT64_C(0xEA5A454B7C44CB44),
UINT64_C(0xFD4934AECACEF0B9), UINT64_C(0xF0B8E4F258B719ED),
UINT64_C(0x5671D8CB8C745FD1), UINT64_C(0x5B8008971E0DB685),
UINT64_C(0x4C937972A8878D78), UINT64_C(0x4162A92E3AFE642C),
UINT64_C(0xCE572B2FDC7B4420), UINT64_C(0xC3A6FB734E02AD74),
UINT64_C(0xD4B58A96F8889689), UINT64_C(0xD9445ACA6AF17FDD),
UINT64_C(0x7F8D66F3BE3239E1), UINT64_C(0x727CB6AF2C4BD0B5),
UINT64_C(0x656FC74A9AC1EB48), UINT64_C(0x689E171608B8021C),
UINT64_C(0x29FCBE3832466630), UINT64_C(0x240D6E64A03F8F64),
UINT64_C(0x331E1F8116B5B499), UINT64_C(0x3EEFCFDD84CC5DCD),
UINT64_C(0x9826F3E4500F1BF1), UINT64_C(0x95D723B8C276F2A5),
UINT64_C(0x82C4525D74FCC958), UINT64_C(0x8F358201E685200C),
UINT64_C(0x9CAF565EB8F78840), UINT64_C(0x915E86022A8E6114),
UINT64_C(0x864DF7E79C045AE9), UINT64_C(0x8BBC27BB0E7DB3BD),
UINT64_C(0x2D751B82DABEF581), UINT64_C(0x2084CBDE48C71CD5),
UINT64_C(0x3797BA3BFE4D2728), UINT64_C(0x3A666A676C34CE7C),
UINT64_C(0x7B04C34956CAAA50), UINT64_C(0x76F51315C4B34304),
UINT64_C(0x61E662F0723978F9), UINT64_C(0x6C17B2ACE04091AD),
UINT64_C(0xCADE8E953483D791), UINT64_C(0xC72F5EC9A6FA3EC5),
UINT64_C(0xD03C2F2C10700538), UINT64_C(0xDDCDFF708209EC6C),
UINT64_C(0x52F87D71648CCC60), UINT64_C(0x5F09AD2DF6F52534),
UINT64_C(0x481ADCC8407F1EC9), UINT64_C(0x45EB0C94D206F79D),
UINT64_C(0xE32230AD06C5B1A1), UINT64_C(0xEED3E0F194BC58F5),
UINT64_C(0xF9C0911422366308), UINT64_C(0xF4314148B04F8A5C),
UINT64_C(0xB553E8668AB1EE70), UINT64_C(0xB8A2383A18C80724),
UINT64_C(0xAFB149DFAE423CD9), UINT64_C(0xA24099833C3BD58D),
UINT64_C(0x0489A5BAE8F893B1), UINT64_C(0x097875E67A817AE5),
UINT64_C(0x1E6B0403CC0B4118), UINT64_C(0x139AD45F5E72A84C),
UINT64_C(0x385FADBC70EF1181), UINT64_C(0x35AE7DE0E296F8D5),
UINT64_C(0x22BD0C05541CC328), UINT64_C(0x2F4CDC59C6652A7C),
UINT64_C(0x8985E06012A66C40), UINT64_C(0x8474303C80DF8514),
UINT64_C(0x936741D93655BEE9), UINT64_C(0x9E969185A42C57BD),
UINT64_C(0xDFF438AB9ED23391), UINT64_C(0xD205E8F70CABDAC5),
UINT64_C(0xC5169912BA21E138), UINT64_C(0xC8E7494E2858086C),
UINT64_C(0x6E2E7577FC9B4E50), UINT64_C(0x63DFA52B6EE2A704),
UINT64_C(0x74CCD4CED8689CF9), UINT64_C(0x793D04924A1175AD),
UINT64_C(0xF6088693AC9455A1), UINT64_C(0xFBF956CF3EEDBCF5),
UINT64_C(0xECEA272A88678708), UINT64_C(0xE11BF7761A1E6E5C),
UINT64_C(0x47D2CB4FCEDD2860), UINT64_C(0x4A231B135CA4C134),
UINT64_C(0x5D306AF6EA2EFAC9), UINT64_C(0x50C1BAAA7857139D),
UINT64_C(0x11A3138442A977B1), UINT64_C(0x1C52C3D8D0D09EE5),
UINT64_C(0x0B41B23D665AA518), UINT64_C(0x06B06261F4234C4C),
UINT64_C(0xA0795E5820E00A70), UINT64_C(0xAD888E04B299E324),
UINT64_C(0xBA9BFFE10413D8D9), UINT64_C(0xB76A2FBD966A318D),
UINT64_C(0xA4F0FBE2C81899C1), UINT64_C(0xA9012BBE5A617095),
UINT64_C(0xBE125A5BECEB4B68), UINT64_C(0xB3E38A077E92A23C),
UINT64_C(0x152AB63EAA51E400), UINT64_C(0x18DB666238280D54),
UINT64_C(0x0FC817878EA236A9), UINT64_C(0x0239C7DB1CDBDFFD),
UINT64_C(0x435B6EF52625BBD1), UINT64_C(0x4EAABEA9B45C5285),
UINT64_C(0x59B9CF4C02D66978), UINT64_C(0x54481F1090AF802C),
UINT64_C(0xF2812329446CC610), UINT64_C(0xFF70F375D6152F44),
UINT64_C(0xE8638290609F14B9), UINT64_C(0xE59252CCF2E6FDED),
UINT64_C(0x6AA7D0CD1463DDE1), UINT64_C(0x67560091861A34B5),
UINT64_C(0x7045717430900F48), UINT64_C(0x7DB4A128A2E9E61C),
UINT64_C(0xDB7D9D11762AA020), UINT64_C(0xD68C4D4DE4534974),
UINT64_C(0xC19F3CA852D97289), UINT64_C(0xCC6EECF4C0A09BDD),
UINT64_C(0x8D0C45DAFA5EFFF1), UINT64_C(0x80FD9586682716A5),
UINT64_C(0x97EEE463DEAD2D58), UINT64_C(0x9A1F343F4CD4C40C),
UINT64_C(0x3CD6080698178230), UINT64_C(0x3127D85A0A6E6B64),
UINT64_C(0x2634A9BFBCE45099), UINT64_C(0x2BC579E32E9DB9CD),
UINT64_C(0xF5A054D6CA71FB90), UINT64_C(0xF851848A580812C4),
UINT64_C(0xEF42F56FEE822939), UINT64_C(0xE2B325337CFBC06D),
UINT64_C(0x447A190AA8388651), UINT64_C(0x498BC9563A416F05),
UINT64_C(0x5E98B8B38CCB54F8), UINT64_C(0x536968EF1EB2BDAC),
UINT64_C(0x120BC1C1244CD980), UINT64_C(0x1FFA119DB63530D4),
UINT64_C(0x08E9607800BF0B29), UINT64_C(0x0518B02492C6E27D),
UINT64_C(0xA3D18C1D4605A441), UINT64_C(0xAE205C41D47C4D15),
UINT64_C(0xB9332DA462F676E8), UINT64_C(0xB4C2FDF8F08F9FBC),
UINT64_C(0x3BF77FF9160ABFB0), UINT64_C(0x3606AFA5847356E4),
UINT64_C(0x2115DE4032F96D19), UINT64_C(0x2CE40E1CA080844D),
UINT64_C(0x8A2D32257443C271), UINT64_C(0x87DCE279E63A2B25),
UINT64_C(0x90CF939C50B010D8), UINT64_C(0x9D3E43C0C2C9F98C),
UINT64_C(0xDC5CEAEEF8379DA0), UINT64_C(0xD1AD3AB26A4E74F4),
UINT64_C(0xC6BE4B57DCC44F09), UINT64_C(0xCB4F9B0B4EBDA65D),
UINT64_C(0x6D86A7329A7EE061), UINT64_C(0x6077776E08070935),
UINT64_C(0x7764068BBE8D32C8), UINT64_C(0x7A95D6D72CF4DB9C),
UINT64_C(0x690F0288728673D0), UINT64_C(0x64FED2D4E0FF9A84),
UINT64_C(0x73EDA3315675A179), UINT64_C(0x7E1C736DC40C482D),
UINT64_C(0xD8D54F5410CF0E11), UINT64_C(0xD5249F0882B6E745),
UINT64_C(0xC237EEED343CDCB8), UINT64_C(0xCFC63EB1A64535EC),
UINT64_C(0x8EA4979F9CBB51C0), UINT64_C(0x835547C30EC2B894),
UINT64_C(0x94463626B8488369), UINT64_C(0x99B7E67A2A316A3D),
UINT64_C(0x3F7EDA43FEF22C01), UINT64_C(0x328F0A1F6C8BC555),
UINT64_C(0x259C7BFADA01FEA8), UINT64_C(0x286DABA6487817FC),
UINT64_C(0xA75829A7AEFD37F0), UINT64_C(0xAAA9F9FB3C84DEA4),
UINT64_C(0xBDBA881E8A0EE559), UINT64_C(0xB04B584218770C0D),
UINT64_C(0x1682647BCCB44A31), UINT64_C(0x1B73B4275ECDA365),
UINT64_C(0x0C60C5C2E8479898), UINT64_C(0x0191159E7A3E71CC),
UINT64_C(0x40F3BCB040C015E0), UINT64_C(0x4D026CECD2B9FCB4),
UINT64_C(0x5A111D096433C749), UINT64_C(0x57E0CD55F64A2E1D),
UINT64_C(0xF129F16C22896821), UINT64_C(0xFCD82130B0F08175),
UINT64_C(0xEBCB50D5067ABA88), UINT64_C(0xE63A8089940353DC),
UINT64_C(0xCDFFF96ABA9EEA11), UINT64_C(0xC00E293628E70345),
UINT64_C(0xD71D58D39E6D38B8), UINT64_C(0xDAEC888F0C14D1EC),
UINT64_C(0x7C25B4B6D8D797D0), UINT64_C(0x71D464EA4AAE7E84),
UINT64_C(0x66C7150FFC244579), UINT64_C(0x6B36C5536E5DAC2D),
UINT64_C(0x2A546C7D54A3C801), UINT64_C(0x27A5BC21C6DA2155),
UINT64_C(0x30B6CDC470501AA8), UINT64_C(0x3D471D98E229F3FC),
UINT64_C(0x9B8E21A136EAB5C0), UINT64_C(0x967FF1FDA4935C94),
UINT64_C(0x816C801812196769), UINT64_C(0x8C9D504480608E3D),
UINT64_C(0x03A8D24566E5AE31), UINT64_C(0x0E590219F49C4765),
UINT64_C(0x194A73FC42167C98), UINT64_C(0x14BBA3A0D06F95CC),
UINT64_C(0xB2729F9904ACD3F0), UINT64_C(0xBF834FC596D53AA4),
UINT64_C(0xA8903E20205F0159), UINT64_C(0xA561EE7CB226E80D),
UINT64_C(0xE403475288D88C21), UINT64_C(0xE9F2970E1AA16575),
UINT64_C(0xFEE1E6EBAC2B5E88), UINT64_C(0xF31036B73E52B7DC),
UINT64_C(0x55D90A8EEA91F1E0), UINT64_C(0x5828DAD278E818B4),
UINT64_C(0x4F3BAB37CE622349), UINT64_C(0x42CA7B6B5C1BCA1D),
UINT64_C(0x5150AF3402696251), UINT64_C(0x5CA17F6890108B05),
UINT64_C(0x4BB20E8D269AB0F8), UINT64_C(0x4643DED1B4E359AC),
UINT64_C(0xE08AE2E860201F90), UINT64_C(0xED7B32B4F259F6C4),
UINT64_C(0xFA68435144D3CD39), UINT64_C(0xF799930DD6AA246D),
UINT64_C(0xB6FB3A23EC544041), UINT64_C(0xBB0AEA7F7E2DA915),
UINT64_C(0xAC199B9AC8A792E8), UINT64_C(0xA1E84BC65ADE7BBC),
UINT64_C(0x072177FF8E1D3D80), UINT64_C(0x0AD0A7A31C64D4D4),
UINT64_C(0x1DC3D646AAEEEF29), UINT64_C(0x1032061A3897067D),
UINT64_C(0x9F07841BDE122671), UINT64_C(0x92F654474C6BCF25),
UINT64_C(0x85E525A2FAE1F4D8), UINT64_C(0x8814F5FE68981D8C),
UINT64_C(0x2EDDC9C7BC5B5BB0), UINT64_C(0x232C199B2E22B2E4),
UINT64_C(0x343F687E98A88919), UINT64_C(0x39CEB8220AD1604D),
UINT64_C(0x78AC110C302F0461), UINT64_C(0x755DC150A256ED35),
UINT64_C(0x624EB0B514DCD6C8), UINT64_C(0x6FBF60E986A53F9C),
UINT64_C(0xC9765CD0526679A0), UINT64_C(0xC4878C8CC01F90F4),
UINT64_C(0xD394FD697695AB09), UINT64_C(0xDE652D35E4EC425D)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0xCB6D6A914AE10B3F),
UINT64_C(0x96DBD42295C2177E), UINT64_C(0x5DB6BEB3DF231C41),
UINT64_C(0x2CB7A9452A852FFC), UINT64_C(0xE7DAC3D4606424C3),
UINT64_C(0xBA6C7D67BF473882), UINT64_C(0x710117F6F5A633BD),
UINT64_C(0xDD705D247FA5876A), UINT64_C(0x161D37B535448C55),
UINT64_C(0x4BAB8906EA679014), UINT64_C(0x80C6E397A0869B2B),
UINT64_C(0xF1C7F4615520A896), UINT64_C(0x3AAA9EF01FC1A3A9),
UINT64_C(0x671C2043C0E2BFE8), UINT64_C(0xAC714AD28A03B4D7),
UINT64_C(0xBAE1BA48FE4A0FD5), UINT64_C(0x718CD0D9B4AB04EA),
UINT64_C(0x2C3A6E6A6B8818AB), UINT64_C(0xE75704FB21691394),
UINT64_C(0x9656130DD4CF2029), UINT64_C(0x5D3B799C9E2E2B16),
UINT64_C(0x008DC72F410D3757), UINT64_C(0xCBE0ADBE0BEC3C68),
UINT64_C(0x6791E76C81EF88BF), UINT64_C(0xACFC8DFDCB0E8380),
UINT64_C(0xF14A334E142D9FC1), UINT64_C(0x3A2759DF5ECC94FE),
UINT64_C(0x4B264E29AB6AA743), UINT64_C(0x804B24B8E18BAC7C),
UINT64_C(0xDDFD9A0B3EA8B03D), UINT64_C(0x1690F09A7449BB02),
UINT64_C(0xF1DD7B3ED73AC638), UINT64_C(0x3AB011AF9DDBCD07),
UINT64_C(0x6706AF1C42F8D146), UINT64_C(0xAC6BC58D0819DA79),
UINT64_C(0xDD6AD27BFDBFE9C4), UINT64_C(0x1607B8EAB75EE2FB),
UINT64_C(0x4BB10659687DFEBA), UINT64_C(0x80DC6CC8229CF585),
UINT64_C(0x2CAD261AA89F4152), UINT64_C(0xE7C04C8BE27E4A6D),
UINT64_C(0xBA76F2383D5D562C), UINT64_C(0x711B98A977BC5D13),
UINT64_C(0x001A8F5F821A6EAE), UINT64_C(0xCB77E5CEC8FB6591),
UINT64_C(0x96C15B7D17D879D0), UINT64_C(0x5DAC31EC5D3972EF),
UINT64_C(0x4B3CC1762970C9ED), UINT64_C(0x8051ABE76391C2D2),
UINT64_C(0xDDE71554BCB2DE93), UINT64_C(0x168A7FC5F653D5AC),
UINT64_C(0x678B683303F5E611), UINT64_C(0xACE602A24914ED2E),
UINT64_C(0xF150BC119637F16F), UINT64_C(0x3A3DD680DCD6FA50),
UINT64_C(0x964C9C5256D54E87), UINT64_C(0x5D21F6C31C3445B8),
UINT64_C(0x00974870C31759F9), UINT64_C(0xCBFA22E189F652C6),
UINT64_C(0xBAFB35177C50617B), UINT64_C(0x71965F8636B16A44),
UINT64_C(0x2C20E135E9927605), UINT64_C(0xE74D8BA4A3737D3A),
UINT64_C(0xE2BBF77CAE758C71), UINT64_C(0x29D69DEDE494874E),
UINT64_C(0x7460235E3BB79B0F), UINT64_C(0xBF0D49CF71569030),
UINT64_C(0xCE0C5E3984F0A38D), UINT64_C(0x056134A8CE11A8B2),
UINT64_C(0x58D78A1B1132B4F3), UINT64_C(0x93BAE08A5BD3BFCC),
UINT64_C(0x3FCBAA58D1D00B1B), UINT64_C(0xF4A6C0C99B310024),
UINT64_C(0xA9107E7A44121C65), UINT64_C(0x627D14EB0EF3175A),
UINT64_C(0x137C031DFB5524E7), UINT64_C(0xD811698CB1B42FD8),
UINT64_C(0x85A7D73F6E973399), UINT64_C(0x4ECABDAE247638A6),
UINT64_C(0x585A4D34503F83A4), UINT64_C(0x933727A51ADE889B),
UINT64_C(0xCE819916C5FD94DA), UINT64_C(0x05ECF3878F1C9FE5),
UINT64_C(0x74EDE4717ABAAC58), UINT64_C(0xBF808EE0305BA767),
UINT64_C(0xE2363053EF78BB26), UINT64_C(0x295B5AC2A599B019),
UINT64_C(0x852A10102F9A04CE), UINT64_C(0x4E477A81657B0FF1),
UINT64_C(0x13F1C432BA5813B0), UINT64_C(0xD89CAEA3F0B9188F),
UINT64_C(0xA99DB955051F2B32), UINT64_C(0x62F0D3C44FFE200D),
UINT64_C(0x3F466D7790DD3C4C), UINT64_C(0xF42B07E6DA3C3773),
UINT64_C(0x13668C42794F4A49), UINT64_C(0xD80BE6D333AE4176),
UINT64_C(0x85BD5860EC8D5D37), UINT64_C(0x4ED032F1A66C5608),
UINT64_C(0x3FD1250753CA65B5), UINT64_C(0xF4BC4F96192B6E8A),
UINT64_C(0xA90AF125C60872CB), UINT64_C(0x62679BB48CE979F4),
UINT64_C(0xCE16D16606EACD23), UINT64_C(0x057BBBF74C0BC61C),
UINT64_C(0x58CD05449328DA5D), UINT64_C(0x93A06FD5D9C9D162),
UINT64_C(0xE2A178232C6FE2DF), UINT64_C(0x29CC12B2668EE9E0),
UINT64_C(0x747AAC01B9ADF5A1), UINT64_C(0xBF17C690F34CFE9E),
UINT64_C(0xA987360A8705459C), UINT64_C(0x62EA5C9BCDE44EA3),
UINT64_C(0x3F5CE22812C752E2), UINT64_C(0xF43188B9582659DD),
UINT64_C(0x85309F4FAD806A60), UINT64_C(0x4E5DF5DEE761615F),
UINT64_C(0x13EB4B6D38427D1E), UINT64_C(0xD88621FC72A37621),
UINT64_C(0x74F76B2EF8A0C2F6), UINT64_C(0xBF9A01BFB241C9C9),
UINT64_C(0xE22CBF0C6D62D588), UINT64_C(0x2941D59D2783DEB7),
UINT64_C(0x5840C26BD225ED0A), UINT64_C(0x932DA8FA98C4E635),
UINT64_C(0xCE9B164947E7FA74), UINT64_C(0x05F67CD80D06F14B),
UINT64_C(0xC477EFF95CEB18E3), UINT64_C(0x0F1A8568160A13DC),
UINT64_C(0x52AC3BDBC9290F9D), UINT64_C(0x99C1514A83C804A2),
UINT64_C(0xE8C046BC766E371F), UINT64_C(0x23AD2C2D3C8F3C20),
UINT64_C(0x7E1B929EE3AC2061), UINT64_C(0xB576F80FA94D2B5E),
UINT64_C(0x1907B2DD234E9F89), UINT64_C(0xD26AD84C69AF94B6),
UINT64_C(0x8FDC66FFB68C88F7), UINT64_C(0x44B10C6EFC6D83C8),
UINT64_C(0x35B01B9809CBB075), UINT64_C(0xFEDD7109432ABB4A),
UINT64_C(0xA36BCFBA9C09A70B), UINT64_C(0x6806A52BD6E8AC34),
UINT64_C(0x7E9655B1A2A11736), UINT64_C(0xB5FB3F20E8401C09),
UINT64_C(0xE84D819337630048), UINT64_C(0x2320EB027D820B77),
UINT64_C(0x5221FCF4882438CA), UINT64_C(0x994C9665C2C533F5),
UINT64_C(0xC4FA28D61DE62FB4), UINT64_C(0x0F9742475707248B),
UINT64_C(0xA3E60895DD04905C), UINT64_C(0x688B620497E59B63),
UINT64_C(0x353DDCB748C68722), UINT64_C(0xFE50B62602278C1D),
UINT64_C(0x8F51A1D0F781BFA0), UINT64_C(0x443CCB41BD60B49F),
UINT64_C(0x198A75F26243A8DE), UINT64_C(0xD2E71F6328A2A3E1),
UINT64_C(0x35AA94C78BD1DEDB), UINT64_C(0xFEC7FE56C130D5E4),
UINT64_C(0xA37140E51E13C9A5), UINT64_C(0x681C2A7454F2C29A),
UINT64_C(0x191D3D82A154F127), UINT64_C(0xD2705713EBB5FA18),
UINT64_C(0x8FC6E9A03496E659), UINT64_C(0x44AB83317E77ED66),
UINT64_C(0xE8DAC9E3F47459B1), UINT64_C(0x23B7A372BE95528E),
UINT64_C(0x7E011DC161B64ECF), UINT64_C(0xB56C77502B5745F0),
UINT64_C(0xC46D60A6DEF1764D), UINT64_C(0x0F000A3794107D72),
UINT64_C(0x52B6B4844B336133), UINT64_C(0x99DBDE1501D26A0C),
UINT64_C(0x8F4B2E8F759BD10E), UINT64_C(0x4426441E3F7ADA31),
UINT64_C(0x1990FAADE059C670), UINT64_C(0xD2FD903CAAB8CD4F),
UINT64_C(0xA3FC87CA5F1EFEF2), UINT64_C(0x6891ED5B15FFF5CD),
UINT64_C(0x352753E8CADCE98C), UINT64_C(0xFE4A3979803DE2B3),
UINT64_C(0x523B73AB0A3E5664), UINT64_C(0x9956193A40DF5D5B),
UINT64_C(0xC4E0A7899FFC411A), UINT64_C(0x0F8DCD18D51D4A25),
UINT64_C(0x7E8CDAEE20BB7998), UINT64_C(0xB5E1B07F6A5A72A7),
UINT64_C(0xE8570ECCB5796EE6), UINT64_C(0x233A645DFF9865D9),
UINT64_C(0x26CC1885F29E9492), UINT64_C(0xEDA17214B87F9FAD),
UINT64_C(0xB017CCA7675C83EC), UINT64_C(0x7B7AA6362DBD88D3),
UINT64_C(0x0A7BB1C0D81BBB6E), UINT64_C(0xC116DB5192FAB051),
UINT64_C(0x9CA065E24DD9AC10), UINT64_C(0x57CD0F730738A72F),
UINT64_C(0xFBBC45A18D3B13F8), UINT64_C(0x30D12F30C7DA18C7),
UINT64_C(0x6D67918318F90486), UINT64_C(0xA60AFB1252180FB9),
UINT64_C(0xD70BECE4A7BE3C04), UINT64_C(0x1C668675ED5F373B),
UINT64_C(0x41D038C6327C2B7A), UINT64_C(0x8ABD5257789D2045),
UINT64_C(0x9C2DA2CD0CD49B47), UINT64_C(0x5740C85C46359078),
UINT64_C(0x0AF676EF99168C39), UINT64_C(0xC19B1C7ED3F78706),
UINT64_C(0xB09A0B882651B4BB), UINT64_C(0x7BF761196CB0BF84),
UINT64_C(0x2641DFAAB393A3C5), UINT64_C(0xED2CB53BF972A8FA),
UINT64_C(0x415DFFE973711C2D), UINT64_C(0x8A30957839901712),
UINT64_C(0xD7862BCBE6B30B53), UINT64_C(0x1CEB415AAC52006C),
UINT64_C(0x6DEA56AC59F433D1), UINT64_C(0xA6873C3D131538EE),
UINT64_C(0xFB31828ECC3624AF), UINT64_C(0x305CE81F86D72F90),
UINT64_C(0xD71163BB25A452AA), UINT64_C(0x1C7C092A6F455995),
UINT64_C(0x41CAB799B06645D4), UINT64_C(0x8AA7DD08FA874EEB),
UINT64_C(0xFBA6CAFE0F217D56), UINT64_C(0x30CBA06F45C07669),
UINT64_C(0x6D7D1EDC9AE36A28), UINT64_C(0xA610744DD0026117),
UINT64_C(0x0A613E9F5A01D5C0), UINT64_C(0xC10C540E10E0DEFF),
UINT64_C(0x9CBAEABDCFC3C2BE), UINT64_C(0x57D7802C8522C981),
UINT64_C(0x26D697DA7084FA3C), UINT64_C(0xEDBBFD4B3A65F103),
UINT64_C(0xB00D43F8E546ED42), UINT64_C(0x7B602969AFA7E67D),
UINT64_C(0x6DF0D9F3DBEE5D7F), UINT64_C(0xA69DB362910F5640),
UINT64_C(0xFB2B0DD14E2C4A01), UINT64_C(0x3046674004CD413E),
UINT64_C(0x414770B6F16B7283), UINT64_C(0x8A2A1A27BB8A79BC),
UINT64_C(0xD79CA49464A965FD), UINT64_C(0x1CF1CE052E486EC2),
UINT64_C(0xB08084D7A44BDA15), UINT64_C(0x7BEDEE46EEAAD12A),
UINT64_C(0x265B50F53189CD6B), UINT64_C(0xED363A647B68C654),
UINT64_C(0x9C372D928ECEF5E9), UINT64_C(0x575A4703C42FFED6),
UINT64_C(0x0AECF9B01B0CE297), UINT64_C(0xC181932151EDE9A8)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0xDCA12C225E8AEE1D),
UINT64_C(0xB8435944BC14DD3B), UINT64_C(0x64E27566E29E3326),
UINT64_C(0x7087B2887829BA77), UINT64_C(0xAC269EAA26A3546A),
UINT64_C(0xC8C4EBCCC43D674C), UINT64_C(0x1465C7EE9AB78951),
UINT64_C(0xE00E6511F15274EF), UINT64_C(0x3CAF4933AFD89AF2),
UINT64_C(0x584D3C554D46A9D4), UINT64_C(0x84EC107713CC47C9),
UINT64_C(0x9089D799897BCE98), UINT64_C(0x4C28FBBBD7F12085),
UINT64_C(0x28CA8EDD356F13A3), UINT64_C(0xF46BA2FF6BE5FDBE),
UINT64_C(0x4503C48DC90A304C), UINT64_C(0x99A2E8AF9780DE51),
UINT64_C(0xFD409DC9751EED77), UINT64_C(0x21E1B1EB2B94036A),
UINT64_C(0x35847605B1238A3B), UINT64_C(0xE9255A27EFA96426),
UINT64_C(0x8DC72F410D375700), UINT64_C(0x5166036353BDB91D),
UINT64_C(0xA50DA19C385844A3), UINT64_C(0x79AC8DBE66D2AABE),
UINT64_C(0x1D4EF8D8844C9998), UINT64_C(0xC1EFD4FADAC67785),
UINT64_C(0xD58A13144071FED4), UINT64_C(0x092B3F361EFB10C9),
UINT64_C(0x6DC94A50FC6523EF), UINT64_C(0xB1686672A2EFCDF2),
UINT64_C(0x8A06881B93156098), UINT64_C(0x56A7A439CD9F8E85),
UINT64_C(0x3245D15F2F01BDA3), UINT64_C(0xEEE4FD7D718B53BE),
UINT64_C(0xFA813A93EB3CDAEF), UINT64_C(0x262016B1B5B634F2),
UINT64_C(0x42C263D7572807D4), UINT64_C(0x9E634FF509A2E9C9),
UINT64_C(0x6A08ED0A62471477), UINT64_C(0xB6A9C1283CCDFA6A),
UINT64_C(0xD24BB44EDE53C94C), UINT64_C(0x0EEA986C80D92751),
UINT64_C(0x1A8F5F821A6EAE00), UINT64_C(0xC62E73A044E4401D),
UINT64_C(0xA2CC06C6A67A733B), UINT64_C(0x7E6D2AE4F8F09D26),
UINT64_C(0xCF054C965A1F50D4), UINT64_C(0x13A460B40495BEC9),
UINT64_C(0x774615D2E60B8DEF), UINT64_C(0xABE739F0B88163F2),
UINT64_C(0xBF82FE1E2236EAA3), UINT64_C(0x6323D23C7CBC04BE),
UINT64_C(0x07C1A75A9E223798), UINT64_C(0xDB608B78C0A8D985),
UINT64_C(0x2F0B2987AB4D243B), UINT64_C(0xF3AA05A5F5C7CA26),
UINT64_C(0x974870C31759F900), UINT64_C(0x4BE95CE149D3171D),
UINT64_C(0x5F8C9B0FD3649E4C), UINT64_C(0x832DB72D8DEE7051),
UINT64_C(0xE7CFC24B6F704377), UINT64_C(0x3B6EEE6931FAAD6A),
UINT64_C(0x91131E980D8418A2), UINT64_C(0x4DB232BA530EF6BF),
UINT64_C(0x295047DCB190C599), UINT64_C(0xF5F16BFEEF1A2B84),
UINT64_C(0xE194AC1075ADA2D5), UINT64_C(0x3D3580322B274CC8),
UINT64_C(0x59D7F554C9B97FEE), UINT64_C(0x8576D976973391F3),
UINT64_C(0x711D7B89FCD66C4D), UINT64_C(0xADBC57ABA25C8250),
UINT64_C(0xC95E22CD40C2B176), UINT64_C(0x15FF0EEF1E485F6B),
UINT64_C(0x019AC90184FFD63A), UINT64_C(0xDD3BE523DA753827),
UINT64_C(0xB9D9904538EB0B01), UINT64_C(0x6578BC676661E51C),
UINT64_C(0xD410DA15C48E28EE), UINT64_C(0x08B1F6379A04C6F3),
UINT64_C(0x6C538351789AF5D5), UINT64_C(0xB0F2AF7326101BC8),
UINT64_C(0xA497689DBCA79299), UINT64_C(0x783644BFE22D7C84),
UINT64_C(0x1CD431D900B34FA2), UINT64_C(0xC0751DFB5E39A1BF),
UINT64_C(0x341EBF0435DC5C01), UINT64_C(0xE8BF93266B56B21C),
UINT64_C(0x8C5DE64089C8813A), UINT64_C(0x50FCCA62D7426F27),
UINT64_C(0x44990D8C4DF5E676), UINT64_C(0x983821AE137F086B),
UINT64_C(0xFCDA54C8F1E13B4D), UINT64_C(0x207B78EAAF6BD550),
UINT64_C(0x1B1596839E91783A), UINT64_C(0xC7B4BAA1C01B9627),
UINT64_C(0xA356CFC72285A501), UINT64_C(0x7FF7E3E57C0F4B1C),
UINT64_C(0x6B92240BE6B8C24D), UINT64_C(0xB7330829B8322C50),
UINT64_C(0xD3D17D4F5AAC1F76), UINT64_C(0x0F70516D0426F16B),
UINT64_C(0xFB1BF3926FC30CD5), UINT64_C(0x27BADFB03149E2C8),
UINT64_C(0x4358AAD6D3D7D1EE), UINT64_C(0x9FF986F48D5D3FF3),
UINT64_C(0x8B9C411A17EAB6A2), UINT64_C(0x573D6D38496058BF),
UINT64_C(0x33DF185EABFE6B99), UINT64_C(0xEF7E347CF5748584),
UINT64_C(0x5E16520E579B4876), UINT64_C(0x82B77E2C0911A66B),
UINT64_C(0xE6550B4AEB8F954D), UINT64_C(0x3AF42768B5057B50),
UINT64_C(0x2E91E0862FB2F201), UINT64_C(0xF230CCA471381C1C),
UINT64_C(0x96D2B9C293A62F3A), UINT64_C(0x4A7395E0CD2CC127),
UINT64_C(0xBE18371FA6C93C99), UINT64_C(0x62B91B3DF843D284),
UINT64_C(0x065B6E5B1ADDE1A2), UINT64_C(0xDAFA427944570FBF),
UINT64_C(0xCE9F8597DEE086EE), UINT64_C(0x123EA9B5806A68F3),
UINT64_C(0x76DCDCD362F45BD5), UINT64_C(0xAA7DF0F13C7EB5C8),
UINT64_C(0xA739329F30A7E9D6), UINT64_C(0x7B981EBD6E2D07CB),
UINT64_C(0x1F7A6BDB8CB334ED), UINT64_C(0xC3DB47F9D239DAF0),
UINT64_C(0xD7BE8017488E53A1), UINT64_C(0x0B1FAC351604BDBC),
UINT64_C(0x6FFDD953F49A8E9A), UINT64_C(0xB35CF571AA106087),
UINT64_C(0x4737578EC1F59D39), UINT64_C(0x9B967BAC9F7F7324),
UINT64_C(0xFF740ECA7DE14002), UINT64_C(0x23D522E8236BAE1F),
UINT64_C(0x37B0E506B9DC274E), UINT64_C(0xEB11C924E756C953),
UINT64_C(0x8FF3BC4205C8FA75), UINT64_C(0x535290605B421468),
UINT64_C(0xE23AF612F9ADD99A), UINT64_C(0x3E9BDA30A7273787),
UINT64_C(0x5A79AF5645B904A1), UINT64_C(0x86D883741B33EABC),
UINT64_C(0x92BD449A818463ED), UINT64_C(0x4E1C68B8DF0E8DF0),
UINT64_C(0x2AFE1DDE3D90BED6), UINT64_C(0xF65F31FC631A50CB),
UINT64_C(0x0234930308FFAD75), UINT64_C(0xDE95BF2156754368),
UINT64_C(0xBA77CA47B4EB704E), UINT64_C(0x66D6E665EA619E53),
UINT64_C(0x72B3218B70D61702), UINT64_C(0xAE120DA92E5CF91F),
UINT64_C(0xCAF078CFCCC2CA39), UINT64_C(0x165154ED92482424),
UINT64_C(0x2D3FBA84A3B2894E), UINT64_C(0xF19E96A6FD386753),
UINT64_C(0x957CE3C01FA65475), UINT64_C(0x49DDCFE2412CBA68),
UINT64_C(0x5DB8080CDB9B3339), UINT64_C(0x8119242E8511DD24),
UINT64_C(0xE5FB5148678FEE02), UINT64_C(0x395A7D6A3905001F),
UINT64_C(0xCD31DF9552E0FDA1), UINT64_C(0x1190F3B70C6A13BC),
UINT64_C(0x757286D1EEF4209A), UINT64_C(0xA9D3AAF3B07ECE87),
UINT64_C(0xBDB66D1D2AC947D6), UINT64_C(0x6117413F7443A9CB),
UINT64_C(0x05F5345996DD9AED), UINT64_C(0xD954187BC85774F0),
UINT64_C(0x683C7E096AB8B902), UINT64_C(0xB49D522B3432571F),
UINT64_C(0xD07F274DD6AC6439), UINT64_C(0x0CDE0B6F88268A24),
UINT64_C(0x18BBCC8112910375), UINT64_C(0xC41AE0A34C1BED68),
UINT64_C(0xA0F895C5AE85DE4E), UINT64_C(0x7C59B9E7F00F3053),
UINT64_C(0x88321B189BEACDED), UINT64_C(0x5493373AC56023F0),
UINT64_C(0x3071425C27FE10D6), UINT64_C(0xECD06E7E7974FECB),
UINT64_C(0xF8B5A990E3C3779A), UINT64_C(0x241485B2BD499987),
UINT64_C(0x40F6F0D45FD7AAA1), UINT64_C(0x9C57DCF6015D44BC),
UINT64_C(0x362A2C073D23F174), UINT64_C(0xEA8B002563A91F69),
UINT64_C(0x8E69754381372C4F), UINT64_C(0x52C85961DFBDC252),
UINT64_C(0x46AD9E8F450A4B03), UINT64_C(0x9A0CB2AD1B80A51E),
UINT64_C(0xFEEEC7CBF91E9638), UINT64_C(0x224FEBE9A7947825),
UINT64_C(0xD6244916CC71859B), UINT64_C(0x0A85653492FB6B86),
UINT64_C(0x6E671052706558A0), UINT64_C(0xB2C63C702EEFB6BD),
UINT64_C(0xA6A3FB9EB4583FEC), UINT64_C(0x7A02D7BCEAD2D1F1),
UINT64_C(0x1EE0A2DA084CE2D7), UINT64_C(0xC2418EF856C60CCA),
UINT64_C(0x7329E88AF429C138), UINT64_C(0xAF88C4A8AAA32F25),
UINT64_C(0xCB6AB1CE483D1C03), UINT64_C(0x17CB9DEC16B7F21E),
UINT64_C(0x03AE5A028C007B4F), UINT64_C(0xDF0F7620D28A9552),
UINT64_C(0xBBED03463014A674), UINT64_C(0x674C2F646E9E4869),
UINT64_C(0x93278D9B057BB5D7), UINT64_C(0x4F86A1B95BF15BCA),
UINT64_C(0x2B64D4DFB96F68EC), UINT64_C(0xF7C5F8FDE7E586F1),
UINT64_C(0xE3A03F137D520FA0), UINT64_C(0x3F01133123D8E1BD),
UINT64_C(0x5BE36657C146D29B), UINT64_C(0x87424A759FCC3C86),
UINT64_C(0xBC2CA41CAE3691EC), UINT64_C(0x608D883EF0BC7FF1),
UINT64_C(0x046FFD5812224CD7), UINT64_C(0xD8CED17A4CA8A2CA),
UINT64_C(0xCCAB1694D61F2B9B), UINT64_C(0x100A3AB68895C586),
UINT64_C(0x74E84FD06A0BF6A0), UINT64_C(0xA84963F2348118BD),
UINT64_C(0x5C22C10D5F64E503), UINT64_C(0x8083ED2F01EE0B1E),
UINT64_C(0xE4619849E3703838), UINT64_C(0x38C0B46BBDFAD625),
UINT64_C(0x2CA57385274D5F74), UINT64_C(0xF0045FA779C7B169),
UINT64_C(0x94E62AC19B59824F), UINT64_C(0x484706E3C5D36C52),
UINT64_C(0xF92F6091673CA1A0), UINT64_C(0x258E4CB339B64FBD),
UINT64_C(0x416C39D5DB287C9B), UINT64_C(0x9DCD15F785A29286),
UINT64_C(0x89A8D2191F151BD7), UINT64_C(0x5509FE3B419FF5CA),
UINT64_C(0x31EB8B5DA301C6EC), UINT64_C(0xED4AA77FFD8B28F1),
UINT64_C(0x19210580966ED54F), UINT64_C(0xC58029A2C8E43B52),
UINT64_C(0xA1625CC42A7A0874), UINT64_C(0x7DC370E674F0E669),
UINT64_C(0x69A6B708EE476F38), UINT64_C(0xB5079B2AB0CD8125),
UINT64_C(0xD1E5EE4C5253B203), UINT64_C(0x0D44C26E0CD95C1E)
}
};

522
lzma/crc64_table_le.h Normal file
View file

@ -0,0 +1,522 @@
/* This file has been automatically generated by crc64_tablegen.c. */
#include <utils.h>
const uint64_t lzma_crc64_table[4][256] = {
{
UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F),
UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34),
UINT64_C(0x7BD0C384FF8F5E33), UINT64_C(0xC8FE8F3AFC28015C),
UINT64_C(0x8F54F5D357CFFE68), UINT64_C(0x3C7AB96D5468A107),
UINT64_C(0xF7A18709FF1EBC66), UINT64_C(0x448FCBB7FCB9E309),
UINT64_C(0x0325B15E575E1C3D), UINT64_C(0xB00BFDE054F94352),
UINT64_C(0x8C71448D0091E255), UINT64_C(0x3F5F08330336BD3A),
UINT64_C(0x78F572DAA8D1420E), UINT64_C(0xCBDB3E64AB761D61),
UINT64_C(0x7D9BA13851336649), UINT64_C(0xCEB5ED8652943926),
UINT64_C(0x891F976FF973C612), UINT64_C(0x3A31DBD1FAD4997D),
UINT64_C(0x064B62BCAEBC387A), UINT64_C(0xB5652E02AD1B6715),
UINT64_C(0xF2CF54EB06FC9821), UINT64_C(0x41E11855055BC74E),
UINT64_C(0x8A3A2631AE2DDA2F), UINT64_C(0x39146A8FAD8A8540),
UINT64_C(0x7EBE1066066D7A74), UINT64_C(0xCD905CD805CA251B),
UINT64_C(0xF1EAE5B551A2841C), UINT64_C(0x42C4A90B5205DB73),
UINT64_C(0x056ED3E2F9E22447), UINT64_C(0xB6409F5CFA457B28),
UINT64_C(0xFB374270A266CC92), UINT64_C(0x48190ECEA1C193FD),
UINT64_C(0x0FB374270A266CC9), UINT64_C(0xBC9D3899098133A6),
UINT64_C(0x80E781F45DE992A1), UINT64_C(0x33C9CD4A5E4ECDCE),
UINT64_C(0x7463B7A3F5A932FA), UINT64_C(0xC74DFB1DF60E6D95),
UINT64_C(0x0C96C5795D7870F4), UINT64_C(0xBFB889C75EDF2F9B),
UINT64_C(0xF812F32EF538D0AF), UINT64_C(0x4B3CBF90F69F8FC0),
UINT64_C(0x774606FDA2F72EC7), UINT64_C(0xC4684A43A15071A8),
UINT64_C(0x83C230AA0AB78E9C), UINT64_C(0x30EC7C140910D1F3),
UINT64_C(0x86ACE348F355AADB), UINT64_C(0x3582AFF6F0F2F5B4),
UINT64_C(0x7228D51F5B150A80), UINT64_C(0xC10699A158B255EF),
UINT64_C(0xFD7C20CC0CDAF4E8), UINT64_C(0x4E526C720F7DAB87),
UINT64_C(0x09F8169BA49A54B3), UINT64_C(0xBAD65A25A73D0BDC),
UINT64_C(0x710D64410C4B16BD), UINT64_C(0xC22328FF0FEC49D2),
UINT64_C(0x85895216A40BB6E6), UINT64_C(0x36A71EA8A7ACE989),
UINT64_C(0x0ADDA7C5F3C4488E), UINT64_C(0xB9F3EB7BF06317E1),
UINT64_C(0xFE5991925B84E8D5), UINT64_C(0x4D77DD2C5823B7BA),
UINT64_C(0x64B62BCAEBC387A1), UINT64_C(0xD7986774E864D8CE),
UINT64_C(0x90321D9D438327FA), UINT64_C(0x231C512340247895),
UINT64_C(0x1F66E84E144CD992), UINT64_C(0xAC48A4F017EB86FD),
UINT64_C(0xEBE2DE19BC0C79C9), UINT64_C(0x58CC92A7BFAB26A6),
UINT64_C(0x9317ACC314DD3BC7), UINT64_C(0x2039E07D177A64A8),
UINT64_C(0x67939A94BC9D9B9C), UINT64_C(0xD4BDD62ABF3AC4F3),
UINT64_C(0xE8C76F47EB5265F4), UINT64_C(0x5BE923F9E8F53A9B),
UINT64_C(0x1C4359104312C5AF), UINT64_C(0xAF6D15AE40B59AC0),
UINT64_C(0x192D8AF2BAF0E1E8), UINT64_C(0xAA03C64CB957BE87),
UINT64_C(0xEDA9BCA512B041B3), UINT64_C(0x5E87F01B11171EDC),
UINT64_C(0x62FD4976457FBFDB), UINT64_C(0xD1D305C846D8E0B4),
UINT64_C(0x96797F21ED3F1F80), UINT64_C(0x2557339FEE9840EF),
UINT64_C(0xEE8C0DFB45EE5D8E), UINT64_C(0x5DA24145464902E1),
UINT64_C(0x1A083BACEDAEFDD5), UINT64_C(0xA9267712EE09A2BA),
UINT64_C(0x955CCE7FBA6103BD), UINT64_C(0x267282C1B9C65CD2),
UINT64_C(0x61D8F8281221A3E6), UINT64_C(0xD2F6B4961186FC89),
UINT64_C(0x9F8169BA49A54B33), UINT64_C(0x2CAF25044A02145C),
UINT64_C(0x6B055FEDE1E5EB68), UINT64_C(0xD82B1353E242B407),
UINT64_C(0xE451AA3EB62A1500), UINT64_C(0x577FE680B58D4A6F),
UINT64_C(0x10D59C691E6AB55B), UINT64_C(0xA3FBD0D71DCDEA34),
UINT64_C(0x6820EEB3B6BBF755), UINT64_C(0xDB0EA20DB51CA83A),
UINT64_C(0x9CA4D8E41EFB570E), UINT64_C(0x2F8A945A1D5C0861),
UINT64_C(0x13F02D374934A966), UINT64_C(0xA0DE61894A93F609),
UINT64_C(0xE7741B60E174093D), UINT64_C(0x545A57DEE2D35652),
UINT64_C(0xE21AC88218962D7A), UINT64_C(0x5134843C1B317215),
UINT64_C(0x169EFED5B0D68D21), UINT64_C(0xA5B0B26BB371D24E),
UINT64_C(0x99CA0B06E7197349), UINT64_C(0x2AE447B8E4BE2C26),
UINT64_C(0x6D4E3D514F59D312), UINT64_C(0xDE6071EF4CFE8C7D),
UINT64_C(0x15BB4F8BE788911C), UINT64_C(0xA6950335E42FCE73),
UINT64_C(0xE13F79DC4FC83147), UINT64_C(0x521135624C6F6E28),
UINT64_C(0x6E6B8C0F1807CF2F), UINT64_C(0xDD45C0B11BA09040),
UINT64_C(0x9AEFBA58B0476F74), UINT64_C(0x29C1F6E6B3E0301B),
UINT64_C(0xC96C5795D7870F42), UINT64_C(0x7A421B2BD420502D),
UINT64_C(0x3DE861C27FC7AF19), UINT64_C(0x8EC62D7C7C60F076),
UINT64_C(0xB2BC941128085171), UINT64_C(0x0192D8AF2BAF0E1E),
UINT64_C(0x4638A2468048F12A), UINT64_C(0xF516EEF883EFAE45),
UINT64_C(0x3ECDD09C2899B324), UINT64_C(0x8DE39C222B3EEC4B),
UINT64_C(0xCA49E6CB80D9137F), UINT64_C(0x7967AA75837E4C10),
UINT64_C(0x451D1318D716ED17), UINT64_C(0xF6335FA6D4B1B278),
UINT64_C(0xB199254F7F564D4C), UINT64_C(0x02B769F17CF11223),
UINT64_C(0xB4F7F6AD86B4690B), UINT64_C(0x07D9BA1385133664),
UINT64_C(0x4073C0FA2EF4C950), UINT64_C(0xF35D8C442D53963F),
UINT64_C(0xCF273529793B3738), UINT64_C(0x7C0979977A9C6857),
UINT64_C(0x3BA3037ED17B9763), UINT64_C(0x888D4FC0D2DCC80C),
UINT64_C(0x435671A479AAD56D), UINT64_C(0xF0783D1A7A0D8A02),
UINT64_C(0xB7D247F3D1EA7536), UINT64_C(0x04FC0B4DD24D2A59),
UINT64_C(0x3886B22086258B5E), UINT64_C(0x8BA8FE9E8582D431),
UINT64_C(0xCC0284772E652B05), UINT64_C(0x7F2CC8C92DC2746A),
UINT64_C(0x325B15E575E1C3D0), UINT64_C(0x8175595B76469CBF),
UINT64_C(0xC6DF23B2DDA1638B), UINT64_C(0x75F16F0CDE063CE4),
UINT64_C(0x498BD6618A6E9DE3), UINT64_C(0xFAA59ADF89C9C28C),
UINT64_C(0xBD0FE036222E3DB8), UINT64_C(0x0E21AC88218962D7),
UINT64_C(0xC5FA92EC8AFF7FB6), UINT64_C(0x76D4DE52895820D9),
UINT64_C(0x317EA4BB22BFDFED), UINT64_C(0x8250E80521188082),
UINT64_C(0xBE2A516875702185), UINT64_C(0x0D041DD676D77EEA),
UINT64_C(0x4AAE673FDD3081DE), UINT64_C(0xF9802B81DE97DEB1),
UINT64_C(0x4FC0B4DD24D2A599), UINT64_C(0xFCEEF8632775FAF6),
UINT64_C(0xBB44828A8C9205C2), UINT64_C(0x086ACE348F355AAD),
UINT64_C(0x34107759DB5DFBAA), UINT64_C(0x873E3BE7D8FAA4C5),
UINT64_C(0xC094410E731D5BF1), UINT64_C(0x73BA0DB070BA049E),
UINT64_C(0xB86133D4DBCC19FF), UINT64_C(0x0B4F7F6AD86B4690),
UINT64_C(0x4CE50583738CB9A4), UINT64_C(0xFFCB493D702BE6CB),
UINT64_C(0xC3B1F050244347CC), UINT64_C(0x709FBCEE27E418A3),
UINT64_C(0x3735C6078C03E797), UINT64_C(0x841B8AB98FA4B8F8),
UINT64_C(0xADDA7C5F3C4488E3), UINT64_C(0x1EF430E13FE3D78C),
UINT64_C(0x595E4A08940428B8), UINT64_C(0xEA7006B697A377D7),
UINT64_C(0xD60ABFDBC3CBD6D0), UINT64_C(0x6524F365C06C89BF),
UINT64_C(0x228E898C6B8B768B), UINT64_C(0x91A0C532682C29E4),
UINT64_C(0x5A7BFB56C35A3485), UINT64_C(0xE955B7E8C0FD6BEA),
UINT64_C(0xAEFFCD016B1A94DE), UINT64_C(0x1DD181BF68BDCBB1),
UINT64_C(0x21AB38D23CD56AB6), UINT64_C(0x9285746C3F7235D9),
UINT64_C(0xD52F0E859495CAED), UINT64_C(0x6601423B97329582),
UINT64_C(0xD041DD676D77EEAA), UINT64_C(0x636F91D96ED0B1C5),
UINT64_C(0x24C5EB30C5374EF1), UINT64_C(0x97EBA78EC690119E),
UINT64_C(0xAB911EE392F8B099), UINT64_C(0x18BF525D915FEFF6),
UINT64_C(0x5F1528B43AB810C2), UINT64_C(0xEC3B640A391F4FAD),
UINT64_C(0x27E05A6E926952CC), UINT64_C(0x94CE16D091CE0DA3),
UINT64_C(0xD3646C393A29F297), UINT64_C(0x604A2087398EADF8),
UINT64_C(0x5C3099EA6DE60CFF), UINT64_C(0xEF1ED5546E415390),
UINT64_C(0xA8B4AFBDC5A6ACA4), UINT64_C(0x1B9AE303C601F3CB),
UINT64_C(0x56ED3E2F9E224471), UINT64_C(0xE5C372919D851B1E),
UINT64_C(0xA26908783662E42A), UINT64_C(0x114744C635C5BB45),
UINT64_C(0x2D3DFDAB61AD1A42), UINT64_C(0x9E13B115620A452D),
UINT64_C(0xD9B9CBFCC9EDBA19), UINT64_C(0x6A978742CA4AE576),
UINT64_C(0xA14CB926613CF817), UINT64_C(0x1262F598629BA778),
UINT64_C(0x55C88F71C97C584C), UINT64_C(0xE6E6C3CFCADB0723),
UINT64_C(0xDA9C7AA29EB3A624), UINT64_C(0x69B2361C9D14F94B),
UINT64_C(0x2E184CF536F3067F), UINT64_C(0x9D36004B35545910),
UINT64_C(0x2B769F17CF112238), UINT64_C(0x9858D3A9CCB67D57),
UINT64_C(0xDFF2A94067518263), UINT64_C(0x6CDCE5FE64F6DD0C),
UINT64_C(0x50A65C93309E7C0B), UINT64_C(0xE388102D33392364),
UINT64_C(0xA4226AC498DEDC50), UINT64_C(0x170C267A9B79833F),
UINT64_C(0xDCD7181E300F9E5E), UINT64_C(0x6FF954A033A8C131),
UINT64_C(0x28532E49984F3E05), UINT64_C(0x9B7D62F79BE8616A),
UINT64_C(0xA707DB9ACF80C06D), UINT64_C(0x14299724CC279F02),
UINT64_C(0x5383EDCD67C06036), UINT64_C(0xE0ADA17364673F59)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0x54E979925CD0F10D),
UINT64_C(0xA9D2F324B9A1E21A), UINT64_C(0xFD3B8AB6E5711317),
UINT64_C(0xC17D4962DC4DDAB1), UINT64_C(0x959430F0809D2BBC),
UINT64_C(0x68AFBA4665EC38AB), UINT64_C(0x3C46C3D4393CC9A6),
UINT64_C(0x10223DEE1795ABE7), UINT64_C(0x44CB447C4B455AEA),
UINT64_C(0xB9F0CECAAE3449FD), UINT64_C(0xED19B758F2E4B8F0),
UINT64_C(0xD15F748CCBD87156), UINT64_C(0x85B60D1E9708805B),
UINT64_C(0x788D87A87279934C), UINT64_C(0x2C64FE3A2EA96241),
UINT64_C(0x20447BDC2F2B57CE), UINT64_C(0x74AD024E73FBA6C3),
UINT64_C(0x899688F8968AB5D4), UINT64_C(0xDD7FF16ACA5A44D9),
UINT64_C(0xE13932BEF3668D7F), UINT64_C(0xB5D04B2CAFB67C72),
UINT64_C(0x48EBC19A4AC76F65), UINT64_C(0x1C02B80816179E68),
UINT64_C(0x3066463238BEFC29), UINT64_C(0x648F3FA0646E0D24),
UINT64_C(0x99B4B516811F1E33), UINT64_C(0xCD5DCC84DDCFEF3E),
UINT64_C(0xF11B0F50E4F32698), UINT64_C(0xA5F276C2B823D795),
UINT64_C(0x58C9FC745D52C482), UINT64_C(0x0C2085E60182358F),
UINT64_C(0x4088F7B85E56AF9C), UINT64_C(0x14618E2A02865E91),
UINT64_C(0xE95A049CE7F74D86), UINT64_C(0xBDB37D0EBB27BC8B),
UINT64_C(0x81F5BEDA821B752D), UINT64_C(0xD51CC748DECB8420),
UINT64_C(0x28274DFE3BBA9737), UINT64_C(0x7CCE346C676A663A),
UINT64_C(0x50AACA5649C3047B), UINT64_C(0x0443B3C41513F576),
UINT64_C(0xF9783972F062E661), UINT64_C(0xAD9140E0ACB2176C),
UINT64_C(0x91D78334958EDECA), UINT64_C(0xC53EFAA6C95E2FC7),
UINT64_C(0x380570102C2F3CD0), UINT64_C(0x6CEC098270FFCDDD),
UINT64_C(0x60CC8C64717DF852), UINT64_C(0x3425F5F62DAD095F),
UINT64_C(0xC91E7F40C8DC1A48), UINT64_C(0x9DF706D2940CEB45),
UINT64_C(0xA1B1C506AD3022E3), UINT64_C(0xF558BC94F1E0D3EE),
UINT64_C(0x086336221491C0F9), UINT64_C(0x5C8A4FB0484131F4),
UINT64_C(0x70EEB18A66E853B5), UINT64_C(0x2407C8183A38A2B8),
UINT64_C(0xD93C42AEDF49B1AF), UINT64_C(0x8DD53B3C839940A2),
UINT64_C(0xB193F8E8BAA58904), UINT64_C(0xE57A817AE6757809),
UINT64_C(0x18410BCC03046B1E), UINT64_C(0x4CA8725E5FD49A13),
UINT64_C(0x8111EF70BCAD5F38), UINT64_C(0xD5F896E2E07DAE35),
UINT64_C(0x28C31C54050CBD22), UINT64_C(0x7C2A65C659DC4C2F),
UINT64_C(0x406CA61260E08589), UINT64_C(0x1485DF803C307484),
UINT64_C(0xE9BE5536D9416793), UINT64_C(0xBD572CA48591969E),
UINT64_C(0x9133D29EAB38F4DF), UINT64_C(0xC5DAAB0CF7E805D2),
UINT64_C(0x38E121BA129916C5), UINT64_C(0x6C0858284E49E7C8),
UINT64_C(0x504E9BFC77752E6E), UINT64_C(0x04A7E26E2BA5DF63),
UINT64_C(0xF99C68D8CED4CC74), UINT64_C(0xAD75114A92043D79),
UINT64_C(0xA15594AC938608F6), UINT64_C(0xF5BCED3ECF56F9FB),
UINT64_C(0x088767882A27EAEC), UINT64_C(0x5C6E1E1A76F71BE1),
UINT64_C(0x6028DDCE4FCBD247), UINT64_C(0x34C1A45C131B234A),
UINT64_C(0xC9FA2EEAF66A305D), UINT64_C(0x9D135778AABAC150),
UINT64_C(0xB177A9428413A311), UINT64_C(0xE59ED0D0D8C3521C),
UINT64_C(0x18A55A663DB2410B), UINT64_C(0x4C4C23F46162B006),
UINT64_C(0x700AE020585E79A0), UINT64_C(0x24E399B2048E88AD),
UINT64_C(0xD9D81304E1FF9BBA), UINT64_C(0x8D316A96BD2F6AB7),
UINT64_C(0xC19918C8E2FBF0A4), UINT64_C(0x9570615ABE2B01A9),
UINT64_C(0x684BEBEC5B5A12BE), UINT64_C(0x3CA2927E078AE3B3),
UINT64_C(0x00E451AA3EB62A15), UINT64_C(0x540D28386266DB18),
UINT64_C(0xA936A28E8717C80F), UINT64_C(0xFDDFDB1CDBC73902),
UINT64_C(0xD1BB2526F56E5B43), UINT64_C(0x85525CB4A9BEAA4E),
UINT64_C(0x7869D6024CCFB959), UINT64_C(0x2C80AF90101F4854),
UINT64_C(0x10C66C44292381F2), UINT64_C(0x442F15D675F370FF),
UINT64_C(0xB9149F60908263E8), UINT64_C(0xEDFDE6F2CC5292E5),
UINT64_C(0xE1DD6314CDD0A76A), UINT64_C(0xB5341A8691005667),
UINT64_C(0x480F903074714570), UINT64_C(0x1CE6E9A228A1B47D),
UINT64_C(0x20A02A76119D7DDB), UINT64_C(0x744953E44D4D8CD6),
UINT64_C(0x8972D952A83C9FC1), UINT64_C(0xDD9BA0C0F4EC6ECC),
UINT64_C(0xF1FF5EFADA450C8D), UINT64_C(0xA51627688695FD80),
UINT64_C(0x582DADDE63E4EE97), UINT64_C(0x0CC4D44C3F341F9A),
UINT64_C(0x308217980608D63C), UINT64_C(0x646B6E0A5AD82731),
UINT64_C(0x9950E4BCBFA93426), UINT64_C(0xCDB99D2EE379C52B),
UINT64_C(0x90FB71CAD654A0F5), UINT64_C(0xC41208588A8451F8),
UINT64_C(0x392982EE6FF542EF), UINT64_C(0x6DC0FB7C3325B3E2),
UINT64_C(0x518638A80A197A44), UINT64_C(0x056F413A56C98B49),
UINT64_C(0xF854CB8CB3B8985E), UINT64_C(0xACBDB21EEF686953),
UINT64_C(0x80D94C24C1C10B12), UINT64_C(0xD43035B69D11FA1F),
UINT64_C(0x290BBF007860E908), UINT64_C(0x7DE2C69224B01805),
UINT64_C(0x41A405461D8CD1A3), UINT64_C(0x154D7CD4415C20AE),
UINT64_C(0xE876F662A42D33B9), UINT64_C(0xBC9F8FF0F8FDC2B4),
UINT64_C(0xB0BF0A16F97FF73B), UINT64_C(0xE4567384A5AF0636),
UINT64_C(0x196DF93240DE1521), UINT64_C(0x4D8480A01C0EE42C),
UINT64_C(0x71C2437425322D8A), UINT64_C(0x252B3AE679E2DC87),
UINT64_C(0xD810B0509C93CF90), UINT64_C(0x8CF9C9C2C0433E9D),
UINT64_C(0xA09D37F8EEEA5CDC), UINT64_C(0xF4744E6AB23AADD1),
UINT64_C(0x094FC4DC574BBEC6), UINT64_C(0x5DA6BD4E0B9B4FCB),
UINT64_C(0x61E07E9A32A7866D), UINT64_C(0x350907086E777760),
UINT64_C(0xC8328DBE8B066477), UINT64_C(0x9CDBF42CD7D6957A),
UINT64_C(0xD073867288020F69), UINT64_C(0x849AFFE0D4D2FE64),
UINT64_C(0x79A1755631A3ED73), UINT64_C(0x2D480CC46D731C7E),
UINT64_C(0x110ECF10544FD5D8), UINT64_C(0x45E7B682089F24D5),
UINT64_C(0xB8DC3C34EDEE37C2), UINT64_C(0xEC3545A6B13EC6CF),
UINT64_C(0xC051BB9C9F97A48E), UINT64_C(0x94B8C20EC3475583),
UINT64_C(0x698348B826364694), UINT64_C(0x3D6A312A7AE6B799),
UINT64_C(0x012CF2FE43DA7E3F), UINT64_C(0x55C58B6C1F0A8F32),
UINT64_C(0xA8FE01DAFA7B9C25), UINT64_C(0xFC177848A6AB6D28),
UINT64_C(0xF037FDAEA72958A7), UINT64_C(0xA4DE843CFBF9A9AA),
UINT64_C(0x59E50E8A1E88BABD), UINT64_C(0x0D0C771842584BB0),
UINT64_C(0x314AB4CC7B648216), UINT64_C(0x65A3CD5E27B4731B),
UINT64_C(0x989847E8C2C5600C), UINT64_C(0xCC713E7A9E159101),
UINT64_C(0xE015C040B0BCF340), UINT64_C(0xB4FCB9D2EC6C024D),
UINT64_C(0x49C73364091D115A), UINT64_C(0x1D2E4AF655CDE057),
UINT64_C(0x216889226CF129F1), UINT64_C(0x7581F0B03021D8FC),
UINT64_C(0x88BA7A06D550CBEB), UINT64_C(0xDC53039489803AE6),
UINT64_C(0x11EA9EBA6AF9FFCD), UINT64_C(0x4503E72836290EC0),
UINT64_C(0xB8386D9ED3581DD7), UINT64_C(0xECD1140C8F88ECDA),
UINT64_C(0xD097D7D8B6B4257C), UINT64_C(0x847EAE4AEA64D471),
UINT64_C(0x794524FC0F15C766), UINT64_C(0x2DAC5D6E53C5366B),
UINT64_C(0x01C8A3547D6C542A), UINT64_C(0x5521DAC621BCA527),
UINT64_C(0xA81A5070C4CDB630), UINT64_C(0xFCF329E2981D473D),
UINT64_C(0xC0B5EA36A1218E9B), UINT64_C(0x945C93A4FDF17F96),
UINT64_C(0x6967191218806C81), UINT64_C(0x3D8E608044509D8C),
UINT64_C(0x31AEE56645D2A803), UINT64_C(0x65479CF41902590E),
UINT64_C(0x987C1642FC734A19), UINT64_C(0xCC956FD0A0A3BB14),
UINT64_C(0xF0D3AC04999F72B2), UINT64_C(0xA43AD596C54F83BF),
UINT64_C(0x59015F20203E90A8), UINT64_C(0x0DE826B27CEE61A5),
UINT64_C(0x218CD888524703E4), UINT64_C(0x7565A11A0E97F2E9),
UINT64_C(0x885E2BACEBE6E1FE), UINT64_C(0xDCB7523EB73610F3),
UINT64_C(0xE0F191EA8E0AD955), UINT64_C(0xB418E878D2DA2858),
UINT64_C(0x492362CE37AB3B4F), UINT64_C(0x1DCA1B5C6B7BCA42),
UINT64_C(0x5162690234AF5051), UINT64_C(0x058B1090687FA15C),
UINT64_C(0xF8B09A268D0EB24B), UINT64_C(0xAC59E3B4D1DE4346),
UINT64_C(0x901F2060E8E28AE0), UINT64_C(0xC4F659F2B4327BED),
UINT64_C(0x39CDD344514368FA), UINT64_C(0x6D24AAD60D9399F7),
UINT64_C(0x414054EC233AFBB6), UINT64_C(0x15A92D7E7FEA0ABB),
UINT64_C(0xE892A7C89A9B19AC), UINT64_C(0xBC7BDE5AC64BE8A1),
UINT64_C(0x803D1D8EFF772107), UINT64_C(0xD4D4641CA3A7D00A),
UINT64_C(0x29EFEEAA46D6C31D), UINT64_C(0x7D0697381A063210),
UINT64_C(0x712612DE1B84079F), UINT64_C(0x25CF6B4C4754F692),
UINT64_C(0xD8F4E1FAA225E585), UINT64_C(0x8C1D9868FEF51488),
UINT64_C(0xB05B5BBCC7C9DD2E), UINT64_C(0xE4B2222E9B192C23),
UINT64_C(0x1989A8987E683F34), UINT64_C(0x4D60D10A22B8CE39),
UINT64_C(0x61042F300C11AC78), UINT64_C(0x35ED56A250C15D75),
UINT64_C(0xC8D6DC14B5B04E62), UINT64_C(0x9C3FA586E960BF6F),
UINT64_C(0xA0796652D05C76C9), UINT64_C(0xF4901FC08C8C87C4),
UINT64_C(0x09AB957669FD94D3), UINT64_C(0x5D42ECE4352D65DE)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0x3F0BE14A916A6DCB),
UINT64_C(0x7E17C29522D4DB96), UINT64_C(0x411C23DFB3BEB65D),
UINT64_C(0xFC2F852A45A9B72C), UINT64_C(0xC3246460D4C3DAE7),
UINT64_C(0x823847BF677D6CBA), UINT64_C(0xBD33A6F5F6170171),
UINT64_C(0x6A87A57F245D70DD), UINT64_C(0x558C4435B5371D16),
UINT64_C(0x149067EA0689AB4B), UINT64_C(0x2B9B86A097E3C680),
UINT64_C(0x96A8205561F4C7F1), UINT64_C(0xA9A3C11FF09EAA3A),
UINT64_C(0xE8BFE2C043201C67), UINT64_C(0xD7B4038AD24A71AC),
UINT64_C(0xD50F4AFE48BAE1BA), UINT64_C(0xEA04ABB4D9D08C71),
UINT64_C(0xAB18886B6A6E3A2C), UINT64_C(0x94136921FB0457E7),
UINT64_C(0x2920CFD40D135696), UINT64_C(0x162B2E9E9C793B5D),
UINT64_C(0x57370D412FC78D00), UINT64_C(0x683CEC0BBEADE0CB),
UINT64_C(0xBF88EF816CE79167), UINT64_C(0x80830ECBFD8DFCAC),
UINT64_C(0xC19F2D144E334AF1), UINT64_C(0xFE94CC5EDF59273A),
UINT64_C(0x43A76AAB294E264B), UINT64_C(0x7CAC8BE1B8244B80),
UINT64_C(0x3DB0A83E0B9AFDDD), UINT64_C(0x02BB49749AF09016),
UINT64_C(0x38C63AD73E7BDDF1), UINT64_C(0x07CDDB9DAF11B03A),
UINT64_C(0x46D1F8421CAF0667), UINT64_C(0x79DA19088DC56BAC),
UINT64_C(0xC4E9BFFD7BD26ADD), UINT64_C(0xFBE25EB7EAB80716),
UINT64_C(0xBAFE7D685906B14B), UINT64_C(0x85F59C22C86CDC80),
UINT64_C(0x52419FA81A26AD2C), UINT64_C(0x6D4A7EE28B4CC0E7),
UINT64_C(0x2C565D3D38F276BA), UINT64_C(0x135DBC77A9981B71),
UINT64_C(0xAE6E1A825F8F1A00), UINT64_C(0x9165FBC8CEE577CB),
UINT64_C(0xD079D8177D5BC196), UINT64_C(0xEF72395DEC31AC5D),
UINT64_C(0xEDC9702976C13C4B), UINT64_C(0xD2C29163E7AB5180),
UINT64_C(0x93DEB2BC5415E7DD), UINT64_C(0xACD553F6C57F8A16),
UINT64_C(0x11E6F50333688B67), UINT64_C(0x2EED1449A202E6AC),
UINT64_C(0x6FF1379611BC50F1), UINT64_C(0x50FAD6DC80D63D3A),
UINT64_C(0x874ED556529C4C96), UINT64_C(0xB845341CC3F6215D),
UINT64_C(0xF95917C370489700), UINT64_C(0xC652F689E122FACB),
UINT64_C(0x7B61507C1735FBBA), UINT64_C(0x446AB136865F9671),
UINT64_C(0x057692E935E1202C), UINT64_C(0x3A7D73A3A48B4DE7),
UINT64_C(0x718C75AE7CF7BBE2), UINT64_C(0x4E8794E4ED9DD629),
UINT64_C(0x0F9BB73B5E236074), UINT64_C(0x30905671CF490DBF),
UINT64_C(0x8DA3F084395E0CCE), UINT64_C(0xB2A811CEA8346105),
UINT64_C(0xF3B432111B8AD758), UINT64_C(0xCCBFD35B8AE0BA93),
UINT64_C(0x1B0BD0D158AACB3F), UINT64_C(0x2400319BC9C0A6F4),
UINT64_C(0x651C12447A7E10A9), UINT64_C(0x5A17F30EEB147D62),
UINT64_C(0xE72455FB1D037C13), UINT64_C(0xD82FB4B18C6911D8),
UINT64_C(0x9933976E3FD7A785), UINT64_C(0xA6387624AEBDCA4E),
UINT64_C(0xA4833F50344D5A58), UINT64_C(0x9B88DE1AA5273793),
UINT64_C(0xDA94FDC5169981CE), UINT64_C(0xE59F1C8F87F3EC05),
UINT64_C(0x58ACBA7A71E4ED74), UINT64_C(0x67A75B30E08E80BF),
UINT64_C(0x26BB78EF533036E2), UINT64_C(0x19B099A5C25A5B29),
UINT64_C(0xCE049A2F10102A85), UINT64_C(0xF10F7B65817A474E),
UINT64_C(0xB01358BA32C4F113), UINT64_C(0x8F18B9F0A3AE9CD8),
UINT64_C(0x322B1F0555B99DA9), UINT64_C(0x0D20FE4FC4D3F062),
UINT64_C(0x4C3CDD90776D463F), UINT64_C(0x73373CDAE6072BF4),
UINT64_C(0x494A4F79428C6613), UINT64_C(0x7641AE33D3E60BD8),
UINT64_C(0x375D8DEC6058BD85), UINT64_C(0x08566CA6F132D04E),
UINT64_C(0xB565CA530725D13F), UINT64_C(0x8A6E2B19964FBCF4),
UINT64_C(0xCB7208C625F10AA9), UINT64_C(0xF479E98CB49B6762),
UINT64_C(0x23CDEA0666D116CE), UINT64_C(0x1CC60B4CF7BB7B05),
UINT64_C(0x5DDA28934405CD58), UINT64_C(0x62D1C9D9D56FA093),
UINT64_C(0xDFE26F2C2378A1E2), UINT64_C(0xE0E98E66B212CC29),
UINT64_C(0xA1F5ADB901AC7A74), UINT64_C(0x9EFE4CF390C617BF),
UINT64_C(0x9C4505870A3687A9), UINT64_C(0xA34EE4CD9B5CEA62),
UINT64_C(0xE252C71228E25C3F), UINT64_C(0xDD592658B98831F4),
UINT64_C(0x606A80AD4F9F3085), UINT64_C(0x5F6161E7DEF55D4E),
UINT64_C(0x1E7D42386D4BEB13), UINT64_C(0x2176A372FC2186D8),
UINT64_C(0xF6C2A0F82E6BF774), UINT64_C(0xC9C941B2BF019ABF),
UINT64_C(0x88D5626D0CBF2CE2), UINT64_C(0xB7DE83279DD54129),
UINT64_C(0x0AED25D26BC24058), UINT64_C(0x35E6C498FAA82D93),
UINT64_C(0x74FAE74749169BCE), UINT64_C(0x4BF1060DD87CF605),
UINT64_C(0xE318EB5CF9EF77C4), UINT64_C(0xDC130A1668851A0F),
UINT64_C(0x9D0F29C9DB3BAC52), UINT64_C(0xA204C8834A51C199),
UINT64_C(0x1F376E76BC46C0E8), UINT64_C(0x203C8F3C2D2CAD23),
UINT64_C(0x6120ACE39E921B7E), UINT64_C(0x5E2B4DA90FF876B5),
UINT64_C(0x899F4E23DDB20719), UINT64_C(0xB694AF694CD86AD2),
UINT64_C(0xF7888CB6FF66DC8F), UINT64_C(0xC8836DFC6E0CB144),
UINT64_C(0x75B0CB09981BB035), UINT64_C(0x4ABB2A430971DDFE),
UINT64_C(0x0BA7099CBACF6BA3), UINT64_C(0x34ACE8D62BA50668),
UINT64_C(0x3617A1A2B155967E), UINT64_C(0x091C40E8203FFBB5),
UINT64_C(0x4800633793814DE8), UINT64_C(0x770B827D02EB2023),
UINT64_C(0xCA382488F4FC2152), UINT64_C(0xF533C5C265964C99),
UINT64_C(0xB42FE61DD628FAC4), UINT64_C(0x8B2407574742970F),
UINT64_C(0x5C9004DD9508E6A3), UINT64_C(0x639BE59704628B68),
UINT64_C(0x2287C648B7DC3D35), UINT64_C(0x1D8C270226B650FE),
UINT64_C(0xA0BF81F7D0A1518F), UINT64_C(0x9FB460BD41CB3C44),
UINT64_C(0xDEA84362F2758A19), UINT64_C(0xE1A3A228631FE7D2),
UINT64_C(0xDBDED18BC794AA35), UINT64_C(0xE4D530C156FEC7FE),
UINT64_C(0xA5C9131EE54071A3), UINT64_C(0x9AC2F254742A1C68),
UINT64_C(0x27F154A1823D1D19), UINT64_C(0x18FAB5EB135770D2),
UINT64_C(0x59E69634A0E9C68F), UINT64_C(0x66ED777E3183AB44),
UINT64_C(0xB15974F4E3C9DAE8), UINT64_C(0x8E5295BE72A3B723),
UINT64_C(0xCF4EB661C11D017E), UINT64_C(0xF045572B50776CB5),
UINT64_C(0x4D76F1DEA6606DC4), UINT64_C(0x727D1094370A000F),
UINT64_C(0x3361334B84B4B652), UINT64_C(0x0C6AD20115DEDB99),
UINT64_C(0x0ED19B758F2E4B8F), UINT64_C(0x31DA7A3F1E442644),
UINT64_C(0x70C659E0ADFA9019), UINT64_C(0x4FCDB8AA3C90FDD2),
UINT64_C(0xF2FE1E5FCA87FCA3), UINT64_C(0xCDF5FF155BED9168),
UINT64_C(0x8CE9DCCAE8532735), UINT64_C(0xB3E23D8079394AFE),
UINT64_C(0x64563E0AAB733B52), UINT64_C(0x5B5DDF403A195699),
UINT64_C(0x1A41FC9F89A7E0C4), UINT64_C(0x254A1DD518CD8D0F),
UINT64_C(0x9879BB20EEDA8C7E), UINT64_C(0xA7725A6A7FB0E1B5),
UINT64_C(0xE66E79B5CC0E57E8), UINT64_C(0xD96598FF5D643A23),
UINT64_C(0x92949EF28518CC26), UINT64_C(0xAD9F7FB81472A1ED),
UINT64_C(0xEC835C67A7CC17B0), UINT64_C(0xD388BD2D36A67A7B),
UINT64_C(0x6EBB1BD8C0B17B0A), UINT64_C(0x51B0FA9251DB16C1),
UINT64_C(0x10ACD94DE265A09C), UINT64_C(0x2FA73807730FCD57),
UINT64_C(0xF8133B8DA145BCFB), UINT64_C(0xC718DAC7302FD130),
UINT64_C(0x8604F9188391676D), UINT64_C(0xB90F185212FB0AA6),
UINT64_C(0x043CBEA7E4EC0BD7), UINT64_C(0x3B375FED7586661C),
UINT64_C(0x7A2B7C32C638D041), UINT64_C(0x45209D785752BD8A),
UINT64_C(0x479BD40CCDA22D9C), UINT64_C(0x789035465CC84057),
UINT64_C(0x398C1699EF76F60A), UINT64_C(0x0687F7D37E1C9BC1),
UINT64_C(0xBBB45126880B9AB0), UINT64_C(0x84BFB06C1961F77B),
UINT64_C(0xC5A393B3AADF4126), UINT64_C(0xFAA872F93BB52CED),
UINT64_C(0x2D1C7173E9FF5D41), UINT64_C(0x121790397895308A),
UINT64_C(0x530BB3E6CB2B86D7), UINT64_C(0x6C0052AC5A41EB1C),
UINT64_C(0xD133F459AC56EA6D), UINT64_C(0xEE3815133D3C87A6),
UINT64_C(0xAF2436CC8E8231FB), UINT64_C(0x902FD7861FE85C30),
UINT64_C(0xAA52A425BB6311D7), UINT64_C(0x9559456F2A097C1C),
UINT64_C(0xD44566B099B7CA41), UINT64_C(0xEB4E87FA08DDA78A),
UINT64_C(0x567D210FFECAA6FB), UINT64_C(0x6976C0456FA0CB30),
UINT64_C(0x286AE39ADC1E7D6D), UINT64_C(0x176102D04D7410A6),
UINT64_C(0xC0D5015A9F3E610A), UINT64_C(0xFFDEE0100E540CC1),
UINT64_C(0xBEC2C3CFBDEABA9C), UINT64_C(0x81C922852C80D757),
UINT64_C(0x3CFA8470DA97D626), UINT64_C(0x03F1653A4BFDBBED),
UINT64_C(0x42ED46E5F8430DB0), UINT64_C(0x7DE6A7AF6929607B),
UINT64_C(0x7F5DEEDBF3D9F06D), UINT64_C(0x40560F9162B39DA6),
UINT64_C(0x014A2C4ED10D2BFB), UINT64_C(0x3E41CD0440674630),
UINT64_C(0x83726BF1B6704741), UINT64_C(0xBC798ABB271A2A8A),
UINT64_C(0xFD65A96494A49CD7), UINT64_C(0xC26E482E05CEF11C),
UINT64_C(0x15DA4BA4D78480B0), UINT64_C(0x2AD1AAEE46EEED7B),
UINT64_C(0x6BCD8931F5505B26), UINT64_C(0x54C6687B643A36ED),
UINT64_C(0xE9F5CE8E922D379C), UINT64_C(0xD6FE2FC403475A57),
UINT64_C(0x97E20C1BB0F9EC0A), UINT64_C(0xA8E9ED51219381C1)
}, {
UINT64_C(0x0000000000000000), UINT64_C(0x1DEE8A5E222CA1DC),
UINT64_C(0x3BDD14BC445943B8), UINT64_C(0x26339EE26675E264),
UINT64_C(0x77BA297888B28770), UINT64_C(0x6A54A326AA9E26AC),
UINT64_C(0x4C673DC4CCEBC4C8), UINT64_C(0x5189B79AEEC76514),
UINT64_C(0xEF7452F111650EE0), UINT64_C(0xF29AD8AF3349AF3C),
UINT64_C(0xD4A9464D553C4D58), UINT64_C(0xC947CC137710EC84),
UINT64_C(0x98CE7B8999D78990), UINT64_C(0x8520F1D7BBFB284C),
UINT64_C(0xA3136F35DD8ECA28), UINT64_C(0xBEFDE56BFFA26BF4),
UINT64_C(0x4C300AC98DC40345), UINT64_C(0x51DE8097AFE8A299),
UINT64_C(0x77ED1E75C99D40FD), UINT64_C(0x6A03942BEBB1E121),
UINT64_C(0x3B8A23B105768435), UINT64_C(0x2664A9EF275A25E9),
UINT64_C(0x0057370D412FC78D), UINT64_C(0x1DB9BD5363036651),
UINT64_C(0xA34458389CA10DA5), UINT64_C(0xBEAAD266BE8DAC79),
UINT64_C(0x98994C84D8F84E1D), UINT64_C(0x8577C6DAFAD4EFC1),
UINT64_C(0xD4FE714014138AD5), UINT64_C(0xC910FB1E363F2B09),
UINT64_C(0xEF2365FC504AC96D), UINT64_C(0xF2CDEFA2726668B1),
UINT64_C(0x986015931B88068A), UINT64_C(0x858E9FCD39A4A756),
UINT64_C(0xA3BD012F5FD14532), UINT64_C(0xBE538B717DFDE4EE),
UINT64_C(0xEFDA3CEB933A81FA), UINT64_C(0xF234B6B5B1162026),
UINT64_C(0xD4072857D763C242), UINT64_C(0xC9E9A209F54F639E),
UINT64_C(0x771447620AED086A), UINT64_C(0x6AFACD3C28C1A9B6),
UINT64_C(0x4CC953DE4EB44BD2), UINT64_C(0x5127D9806C98EA0E),
UINT64_C(0x00AE6E1A825F8F1A), UINT64_C(0x1D40E444A0732EC6),
UINT64_C(0x3B737AA6C606CCA2), UINT64_C(0x269DF0F8E42A6D7E),
UINT64_C(0xD4501F5A964C05CF), UINT64_C(0xC9BE9504B460A413),
UINT64_C(0xEF8D0BE6D2154677), UINT64_C(0xF26381B8F039E7AB),
UINT64_C(0xA3EA36221EFE82BF), UINT64_C(0xBE04BC7C3CD22363),
UINT64_C(0x9837229E5AA7C107), UINT64_C(0x85D9A8C0788B60DB),
UINT64_C(0x3B244DAB87290B2F), UINT64_C(0x26CAC7F5A505AAF3),
UINT64_C(0x00F95917C3704897), UINT64_C(0x1D17D349E15CE94B),
UINT64_C(0x4C9E64D30F9B8C5F), UINT64_C(0x5170EE8D2DB72D83),
UINT64_C(0x7743706F4BC2CFE7), UINT64_C(0x6AADFA3169EE6E3B),
UINT64_C(0xA218840D981E1391), UINT64_C(0xBFF60E53BA32B24D),
UINT64_C(0x99C590B1DC475029), UINT64_C(0x842B1AEFFE6BF1F5),
UINT64_C(0xD5A2AD7510AC94E1), UINT64_C(0xC84C272B3280353D),
UINT64_C(0xEE7FB9C954F5D759), UINT64_C(0xF391339776D97685),
UINT64_C(0x4D6CD6FC897B1D71), UINT64_C(0x50825CA2AB57BCAD),
UINT64_C(0x76B1C240CD225EC9), UINT64_C(0x6B5F481EEF0EFF15),
UINT64_C(0x3AD6FF8401C99A01), UINT64_C(0x273875DA23E53BDD),
UINT64_C(0x010BEB384590D9B9), UINT64_C(0x1CE5616667BC7865),
UINT64_C(0xEE288EC415DA10D4), UINT64_C(0xF3C6049A37F6B108),
UINT64_C(0xD5F59A785183536C), UINT64_C(0xC81B102673AFF2B0),
UINT64_C(0x9992A7BC9D6897A4), UINT64_C(0x847C2DE2BF443678),
UINT64_C(0xA24FB300D931D41C), UINT64_C(0xBFA1395EFB1D75C0),
UINT64_C(0x015CDC3504BF1E34), UINT64_C(0x1CB2566B2693BFE8),
UINT64_C(0x3A81C88940E65D8C), UINT64_C(0x276F42D762CAFC50),
UINT64_C(0x76E6F54D8C0D9944), UINT64_C(0x6B087F13AE213898),
UINT64_C(0x4D3BE1F1C854DAFC), UINT64_C(0x50D56BAFEA787B20),
UINT64_C(0x3A78919E8396151B), UINT64_C(0x27961BC0A1BAB4C7),
UINT64_C(0x01A58522C7CF56A3), UINT64_C(0x1C4B0F7CE5E3F77F),
UINT64_C(0x4DC2B8E60B24926B), UINT64_C(0x502C32B8290833B7),
UINT64_C(0x761FAC5A4F7DD1D3), UINT64_C(0x6BF126046D51700F),
UINT64_C(0xD50CC36F92F31BFB), UINT64_C(0xC8E24931B0DFBA27),
UINT64_C(0xEED1D7D3D6AA5843), UINT64_C(0xF33F5D8DF486F99F),
UINT64_C(0xA2B6EA171A419C8B), UINT64_C(0xBF586049386D3D57),
UINT64_C(0x996BFEAB5E18DF33), UINT64_C(0x848574F57C347EEF),
UINT64_C(0x76489B570E52165E), UINT64_C(0x6BA611092C7EB782),
UINT64_C(0x4D958FEB4A0B55E6), UINT64_C(0x507B05B56827F43A),
UINT64_C(0x01F2B22F86E0912E), UINT64_C(0x1C1C3871A4CC30F2),
UINT64_C(0x3A2FA693C2B9D296), UINT64_C(0x27C12CCDE095734A),
UINT64_C(0x993CC9A61F3718BE), UINT64_C(0x84D243F83D1BB962),
UINT64_C(0xA2E1DD1A5B6E5B06), UINT64_C(0xBF0F57447942FADA),
UINT64_C(0xEE86E0DE97859FCE), UINT64_C(0xF3686A80B5A93E12),
UINT64_C(0xD55BF462D3DCDC76), UINT64_C(0xC8B57E3CF1F07DAA),
UINT64_C(0xD6E9A7309F3239A7), UINT64_C(0xCB072D6EBD1E987B),
UINT64_C(0xED34B38CDB6B7A1F), UINT64_C(0xF0DA39D2F947DBC3),
UINT64_C(0xA1538E481780BED7), UINT64_C(0xBCBD041635AC1F0B),
UINT64_C(0x9A8E9AF453D9FD6F), UINT64_C(0x876010AA71F55CB3),
UINT64_C(0x399DF5C18E573747), UINT64_C(0x24737F9FAC7B969B),
UINT64_C(0x0240E17DCA0E74FF), UINT64_C(0x1FAE6B23E822D523),
UINT64_C(0x4E27DCB906E5B037), UINT64_C(0x53C956E724C911EB),
UINT64_C(0x75FAC80542BCF38F), UINT64_C(0x6814425B60905253),
UINT64_C(0x9AD9ADF912F63AE2), UINT64_C(0x873727A730DA9B3E),
UINT64_C(0xA104B94556AF795A), UINT64_C(0xBCEA331B7483D886),
UINT64_C(0xED6384819A44BD92), UINT64_C(0xF08D0EDFB8681C4E),
UINT64_C(0xD6BE903DDE1DFE2A), UINT64_C(0xCB501A63FC315FF6),
UINT64_C(0x75ADFF0803933402), UINT64_C(0x6843755621BF95DE),
UINT64_C(0x4E70EBB447CA77BA), UINT64_C(0x539E61EA65E6D666),
UINT64_C(0x0217D6708B21B372), UINT64_C(0x1FF95C2EA90D12AE),
UINT64_C(0x39CAC2CCCF78F0CA), UINT64_C(0x24244892ED545116),
UINT64_C(0x4E89B2A384BA3F2D), UINT64_C(0x536738FDA6969EF1),
UINT64_C(0x7554A61FC0E37C95), UINT64_C(0x68BA2C41E2CFDD49),
UINT64_C(0x39339BDB0C08B85D), UINT64_C(0x24DD11852E241981),
UINT64_C(0x02EE8F674851FBE5), UINT64_C(0x1F0005396A7D5A39),
UINT64_C(0xA1FDE05295DF31CD), UINT64_C(0xBC136A0CB7F39011),
UINT64_C(0x9A20F4EED1867275), UINT64_C(0x87CE7EB0F3AAD3A9),
UINT64_C(0xD647C92A1D6DB6BD), UINT64_C(0xCBA943743F411761),
UINT64_C(0xED9ADD965934F505), UINT64_C(0xF07457C87B1854D9),
UINT64_C(0x02B9B86A097E3C68), UINT64_C(0x1F5732342B529DB4),
UINT64_C(0x3964ACD64D277FD0), UINT64_C(0x248A26886F0BDE0C),
UINT64_C(0x7503911281CCBB18), UINT64_C(0x68ED1B4CA3E01AC4),
UINT64_C(0x4EDE85AEC595F8A0), UINT64_C(0x53300FF0E7B9597C),
UINT64_C(0xEDCDEA9B181B3288), UINT64_C(0xF02360C53A379354),
UINT64_C(0xD610FE275C427130), UINT64_C(0xCBFE74797E6ED0EC),
UINT64_C(0x9A77C3E390A9B5F8), UINT64_C(0x879949BDB2851424),
UINT64_C(0xA1AAD75FD4F0F640), UINT64_C(0xBC445D01F6DC579C),
UINT64_C(0x74F1233D072C2A36), UINT64_C(0x691FA96325008BEA),
UINT64_C(0x4F2C37814375698E), UINT64_C(0x52C2BDDF6159C852),
UINT64_C(0x034B0A458F9EAD46), UINT64_C(0x1EA5801BADB20C9A),
UINT64_C(0x38961EF9CBC7EEFE), UINT64_C(0x257894A7E9EB4F22),
UINT64_C(0x9B8571CC164924D6), UINT64_C(0x866BFB923465850A),
UINT64_C(0xA05865705210676E), UINT64_C(0xBDB6EF2E703CC6B2),
UINT64_C(0xEC3F58B49EFBA3A6), UINT64_C(0xF1D1D2EABCD7027A),
UINT64_C(0xD7E24C08DAA2E01E), UINT64_C(0xCA0CC656F88E41C2),
UINT64_C(0x38C129F48AE82973), UINT64_C(0x252FA3AAA8C488AF),
UINT64_C(0x031C3D48CEB16ACB), UINT64_C(0x1EF2B716EC9DCB17),
UINT64_C(0x4F7B008C025AAE03), UINT64_C(0x52958AD220760FDF),
UINT64_C(0x74A614304603EDBB), UINT64_C(0x69489E6E642F4C67),
UINT64_C(0xD7B57B059B8D2793), UINT64_C(0xCA5BF15BB9A1864F),
UINT64_C(0xEC686FB9DFD4642B), UINT64_C(0xF186E5E7FDF8C5F7),
UINT64_C(0xA00F527D133FA0E3), UINT64_C(0xBDE1D8233113013F),
UINT64_C(0x9BD246C15766E35B), UINT64_C(0x863CCC9F754A4287),
UINT64_C(0xEC9136AE1CA42CBC), UINT64_C(0xF17FBCF03E888D60),
UINT64_C(0xD74C221258FD6F04), UINT64_C(0xCAA2A84C7AD1CED8),
UINT64_C(0x9B2B1FD69416ABCC), UINT64_C(0x86C59588B63A0A10),
UINT64_C(0xA0F60B6AD04FE874), UINT64_C(0xBD188134F26349A8),
UINT64_C(0x03E5645F0DC1225C), UINT64_C(0x1E0BEE012FED8380),
UINT64_C(0x383870E3499861E4), UINT64_C(0x25D6FABD6BB4C038),
UINT64_C(0x745F4D278573A52C), UINT64_C(0x69B1C779A75F04F0),
UINT64_C(0x4F82599BC12AE694), UINT64_C(0x526CD3C5E3064748),
UINT64_C(0xA0A13C6791602FF9), UINT64_C(0xBD4FB639B34C8E25),
UINT64_C(0x9B7C28DBD5396C41), UINT64_C(0x8692A285F715CD9D),
UINT64_C(0xD71B151F19D2A889), UINT64_C(0xCAF59F413BFE0955),
UINT64_C(0xECC601A35D8BEB31), UINT64_C(0xF1288BFD7FA74AED),
UINT64_C(0x4FD56E9680052119), UINT64_C(0x523BE4C8A22980C5),
UINT64_C(0x74087A2AC45C62A1), UINT64_C(0x69E6F074E670C37D),
UINT64_C(0x386F47EE08B7A669), UINT64_C(0x2581CDB02A9B07B5),
UINT64_C(0x03B253524CEEE5D1), UINT64_C(0x1E5CD90C6EC2440D)
}
};

88
lzma/crc64_tablegen.c Normal file
View file

@ -0,0 +1,88 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc64_tablegen.c
/// \brief Generate crc64_table_le.h and crc64_table_be.h
///
/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c
/// Add -DWORDS_BIGENDIAN to generate big endian table.
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "../../common/tuklib_integer.h"
static uint64_t crc64_table[4][256];
extern void
init_crc64_table(void)
{
static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
for (size_t s = 0; s < 4; ++s) {
for (size_t b = 0; b < 256; ++b) {
uint64_t r = s == 0 ? b : crc64_table[s - 1][b];
for (size_t i = 0; i < 8; ++i) {
if (r & 1)
r = (r >> 1) ^ poly64;
else
r >>= 1;
}
crc64_table[s][b] = r;
}
}
#ifdef WORDS_BIGENDIAN
for (size_t s = 0; s < 4; ++s)
for (size_t b = 0; b < 256; ++b)
crc64_table[s][b] = bswap64(crc64_table[s][b]);
#endif
return;
}
static void
print_crc64_table(void)
{
printf("/* This file has been automatically generated by "
"crc64_tablegen.c. */\n\n"
"const uint64_t lzma_crc64_table[4][256] = {\n\t{");
for (size_t s = 0; s < 4; ++s) {
for (size_t b = 0; b < 256; ++b) {
if ((b % 2) == 0)
printf("\n\t\t");
printf("UINT64_C(0x%016" PRIX64 ")",
crc64_table[s][b]);
if (b != 255)
printf(",%s", (b+1) % 2 == 0 ? "" : " ");
}
if (s == 3)
printf("\n\t}\n};\n");
else
printf("\n\t}, {");
}
return;
}
int
main(void)
{
init_crc64_table();
print_crc64_table();
return 0;
}

32
lzma/crc_macros.h Normal file
View file

@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
//
/// \file crc_macros.h
/// \brief Some endian-dependent macros for CRC32 and CRC64
//
// Author: Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
#include <utils.h>
#ifdef WORDS_BIGENDIAN
# define A(x) ((x) >> 24)
# define B(x) (((x) >> 16) & 0xFF)
# define C(x) (((x) >> 8) & 0xFF)
# define D(x) ((x) & 0xFF)
# define S8(x) ((x) << 8)
# define S32(x) ((x) << 32)
#else
# define A(x) ((x) & 0xFF)
# define B(x) (((x) >> 8) & 0xFF)
# define C(x) (((x) >> 16) & 0xFF)
# define D(x) ((x) >> 24)
# define S8(x) ((x) >> 8)
# define S32(x) ((x) >> 32)
#endif

190
lzma_compress.c Normal file
View file

@ -0,0 +1,190 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <sys/types.h>
#include <stdio.h>
#include <strings.h>
#include <LzmaEnc.h>
#include <LzmaDec.h>
#include <utils.h>
#include <pcompress.h>
#include <allocator.h>
#define SZ_ERROR_DESTLEN 100
#define LZMA_MAX_DICT (1 << 30)
#define LZMA_DICT_THRESH (1 << 29)
#define LZMA_DEFAULT_DICT (1 << 24)
CLzmaEncProps *p = NULL;
static ISzAlloc g_Alloc = {
slab_alloc,
slab_free,
NULL
};
/*
* The two functions below are not thread-safe, by design.
*/
int
lzma_init(void **data, int *level, ssize_t chunksize)
{
if (!p) {
p = (CLzmaEncProps *)slab_alloc(NULL, sizeof (CLzmaEncProps));
LzmaEncProps_Init(p);
/*
* Set the dictionary size and fast bytes based on level.
*/
if (*level < 8) {
/*
* Choose a dict size with a balance between perf and
* compression.
*/
p->dictSize = LZMA_DEFAULT_DICT;
} else {
/*
* Let LZMA determine best dict size.
*/
p->dictSize = 0;
}
/* Determine the fast bytes value. */
if (*level < 7)
p->fb = 32;
else if (*level < 10)
p->fb = 64;
else
p->fb = 128;
if (*level > 9) *level = 9;
p->level = *level;
LzmaEncProps_Normalize(p);
}
*data = p;
return (0);
}
int
lzma_deinit(void **data)
{
if (p) {
slab_free(NULL, p);
p = NULL;
}
*data = NULL;
return (0);
}
static void
lzerr(int err)
{
switch (err) {
case SZ_ERROR_MEM:
fprintf(stderr, "LZMA: Memory allocation error\n");
break;
case SZ_ERROR_PARAM:
fprintf(stderr, "LZMA: Incorrect paramater\n");
break;
case SZ_ERROR_WRITE:
fprintf(stderr, "LZMA: Write callback error\n");
break;
case SZ_ERROR_PROGRESS:
fprintf(stderr, "LZMA: Progress callback errored\n");
break;
case SZ_ERROR_OUTPUT_EOF:
fprintf(stderr, "LZMA: Output buffer overflow\n");
break;
case SZ_ERROR_UNSUPPORTED:
fprintf(stderr, "LZMA: Unsupported properties\n");
break;
case SZ_ERROR_DESTLEN:
fprintf(stderr, "LZMA: Output chunk size too small\n");
break;
case SZ_ERROR_DATA:
fprintf(stderr, "LZMA: Data Error\n");
break;
default:
fprintf(stderr, "LZMA: Unknown error code: %d\n", err);
}
}
/*
* LZMA compressed segment format(simplified)
* ------------------------------------------
* Offset Size Description
* 0 1 Special LZMA properties for compressed data
* 1 4 Dictionary size (little endian)
* 13 Compressed data
*
* Derived from http://docs.bugaco.com/7zip/lzma.txt
* We do not store the uncompressed chunk size here. It is stored in
* our chunk header.
*/
int
lzma_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
size_t props_len = LZMA_PROPS_SIZE;
SRes res;
Byte *_dst;
CLzmaEncProps *props = (CLzmaEncProps *)data;
if (*dstlen < LZMA_PROPS_SIZE) {
lzerr(SZ_ERROR_DESTLEN);
return (-1);
}
props->level = level;
_dst = (Byte *)dst;
*dstlen -= LZMA_PROPS_SIZE;
res = LzmaEncode(_dst + LZMA_PROPS_SIZE, dstlen, src, srclen,
props, _dst, &props_len, 0, NULL, &g_Alloc, &g_Alloc);
if (res != 0) {
lzerr(res);
return (-1);
}
*dstlen += LZMA_PROPS_SIZE;
return (0);
}
int
lzma_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
size_t _srclen;
const uchar_t *_src;
SRes res;
ELzmaStatus status;
_srclen = srclen - LZMA_PROPS_SIZE;
_src = (uchar_t *)src + LZMA_PROPS_SIZE + CHDR_SZ;
if ((res = LzmaDecode((uchar_t *)dst, dstlen, _src, &_srclen,
src + CHDR_SZ, LZMA_PROPS_SIZE, LZMA_FINISH_ANY,
&status, &g_Alloc)) != SZ_OK) {
lzerr(res);
return (-1);
}
return (0);
}

1066
main.c Normal file

File diff suppressed because it is too large Load diff

121
pcompress.h Normal file
View file

@ -0,0 +1,121 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#ifndef _PCOMPRESS_H
#define _PCOMPRESS_H
#include <sys/types.h>
#include <pthread.h>
#include <semaphore.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CHDR_SZ 1
#define ALGO_SZ 8
#define MIN_CHUNK 2048
#define VERSION 1
#define COMPRESSED 1
#define UNCOMPRESSED 0
#define CHSIZE_MASK 0x80
#define BZIP2_A_NUM 16
#define LZMA_A_NUM 32
#define COMPRESS_LZMA 1
#define COMPRESS_BZIP2 2
#define COMPRESS_PPMD 3
#define COMP_EXTN ".pz"
/* Pointer type for compress and decompress functions. */
typedef int (*compress_func_ptr)(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
/* Pointer type for algo specific init/deinit functions. */
typedef int (*init_func_ptr)(void **data, int *level, ssize_t chunksize);
typedef int (*deinit_func_ptr)(void **data);
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, size_t size,
uint64_t crc, uint64_t *cnt);
extern int zlib_compress(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
extern int lzma_compress(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
extern int bzip2_compress(void *src, size_t srclen, void *dst,
size_t *destlen, int level, void *data);
extern int adapt_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int ppmd_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int zlib_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int lzma_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int bzip2_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int adapt_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int ppmd_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data);
extern int adapt_init(void **data, int *level, ssize_t chunksize);
extern int adapt2_init(void **data, int *level, ssize_t chunksize);
extern int lzma_init(void **data, int *level, ssize_t chunksize);
extern int ppmd_init(void **data, int *level, ssize_t chunksize);
extern int bzip2_init(void **data, int *level, ssize_t chunksize);
extern int zlib_init(void **data, int *level, ssize_t chunksize);
extern int adapt_deinit(void **data);
extern int lzma_deinit(void **data);
extern int ppmd_deinit(void **data);
/*
* Per-thread data structure for compression and decompression threads.
*/
struct cmp_data {
uchar_t *cmp_seg;
uchar_t *compressed_chunk;
uchar_t *uncompressed_chunk;
ssize_t rbytes;
ssize_t chunksize;
ssize_t len_cmp;
uint64_t crc64;
int level;
unsigned int id;
compress_func_ptr compress;
compress_func_ptr decompress;
int cancel;
sem_t start_sem;
sem_t cmp_done_sem;
sem_t write_done_sem;
void *data;
pthread_t thr;
};
#ifdef __cplusplus
}
#endif
#endif

147
ppmd_compress.c Normal file
View file

@ -0,0 +1,147 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <stdio.h>
#include <sys/types.h>
#include <strings.h>
#include <utils.h>
#include <pcompress.h>
#include <allocator.h>
#include <Ppmd8.h>
/*
* PPMd model order to working set memory size mappings.
*/
unsigned int ppmd8_mem_sz[] = {
(16 << 20),
(16 << 20),
(32 << 20),
(32 << 20),
(64 << 20),
(64 << 20),
(100 << 20),
(100 << 20),
(400 << 20),
(400 << 20),
(700 << 20),
(700 << 20),
(700 << 20),
(1200 << 20),
(1200 << 20)
};
static ISzAlloc g_Alloc = {
slab_alloc,
slab_free,
NULL
};
int
ppmd_init(void **data, int *level, ssize_t chunksize)
{
CPpmd8 *_ppmd;
_ppmd = (CPpmd8 *)slab_alloc(NULL, sizeof (CPpmd8));
if (!_ppmd)
return (-1);
/* Levels 0 - 14 correspond to PPMd model orders 0 - 14. */
if (*level > 14) *level = 14;
_ppmd->Order = *level;
_ppmd->Base = 0;
_ppmd->Size = 0;
if (!Ppmd8_Alloc(_ppmd, ppmd8_mem_sz[*level], &g_Alloc)) {
fprintf(stderr, "Out of memory.\n");
return (-1);
}
Ppmd8_Construct(_ppmd);
*data = _ppmd;
if (*level > 9) *level = 9;
return (0);
}
int
ppmd_deinit(void **data)
{
CPpmd8 *_ppmd = (CPpmd8 *)(*data);
if (_ppmd) {
Ppmd8_Free(_ppmd, &g_Alloc);
slab_free(NULL, _ppmd);
}
*data = NULL;
return (0);
}
int
ppmd_compress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
CPpmd8 *_ppmd = (CPpmd8 *)data;
uchar_t *_src = (uchar_t *)src;
UInt32 i;
Ppmd8_RangeEnc_Init(_ppmd);
Ppmd8_Init(_ppmd, _ppmd->Order, PPMD8_RESTORE_METHOD_RESTART);
_ppmd->buf = (Byte *)dst;
_ppmd->bufLen = *dstlen;
_ppmd->bufUsed = 0;
Ppmd8_EncodeBuffer(_ppmd, _src, srclen);
Ppmd8_EncodeSymbol(_ppmd, -1);
Ppmd8_RangeEnc_FlushData(_ppmd);
*dstlen = _ppmd->bufUsed;
return (0);
}
int
ppmd_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, void *data)
{
CPpmd8 *_ppmd = (CPpmd8 *)data;
Byte *_src = (Byte *)src + CHDR_SZ;
Byte *_dst = (Byte *)dst;
size_t i;
int res;
if (*((char *)_src) < 2)
return (-1);
_ppmd->buf = (Byte *)_src;
_ppmd->bufLen = srclen;
_ppmd->bufUsed = 0;
Ppmd8_RangeDec_Init(_ppmd);
Ppmd8_Init(_ppmd, _ppmd->Order, PPMD8_RESTORE_METHOD_RESTART);
res = Ppmd8_DecodeToBuffer(_ppmd, _dst, *dstlen, &i);
if (res < 0 && res != -1) {
if (Ppmd8_DecodeSymbol(_ppmd) != -1)
return (-1);
i++;
}
if (i < *dstlen)
return (-1);
return (0);
}

179
utils.c Normal file
View file

@ -0,0 +1,179 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <sys/types.h>
#include <sys/param.h>
#include <libgen.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <link.h>
#include "utils.h"
void
err_exit(int show_errno, const char *format, ...)
{
int err = errno;
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
if (show_errno)
fprintf(stderr, "\nError: %s\n", strerror(err));
exit(1);
}
/*
* Fetch the command name that started the current process.
* The returned string must be freed by the caller.
*/
const char *
get_execname(const char *argv0)
{
char path[MAXPATHLEN];
char apath[128];
char *tmp1, *tmp2;
pid_t pid;
/* The easiest case: we are in linux */
if (readlink("/proc/self/exe", path, MAXPATHLEN) != -1) {
return (strdup(basename(path)));
}
/* Next easy case: Solaris/Illumos */
pid = getpid();
sprintf(apath, "/proc/%d/path/a.out", pid);
if (readlink(apath, path, MAXPATHLEN) != -1) {
return (strdup(basename(path)));
}
/* Oops... not in linux, not in Solaris no guarantee */
/* check if we have something like execve("foobar", NULL, NULL) */
if (argv0 == NULL) {
/* Give up */
return (strdup("Unknown"));
}
tmp1 = strdup(argv0);
tmp2 = strdup(basename(tmp1));
free(tmp1);
return (tmp2);
}
/*
* Routines to parse a numeric string which can have the following suffixes:
* k - Kilobyte
* m - Megabyte
* g - Gigabyte
*
* The number should fit in an ssize_t data type.
* Numeric overflow is also checked. The routine parse_numeric() returns
* 1 if there was a numeric overflow.
*/
static int
raise_by_multiplier(ssize_t *val, int mult, int power) {
ssize_t result;
while (power-- > 0) {
result = *val * mult;
if (result/mult != *val)
return (1);
*val = result;
}
return (0);
}
int
parse_numeric(ssize_t *val, const char *str)
{
int i, ovr;
char *mult;
*val = strtoll(str, &mult, 0);
if (*mult != '\0') {
switch (*mult) {
case 'k':
case 'K':
ovr = raise_by_multiplier(val, 1024, 1);
break;
case 'm':
case 'M':
ovr = raise_by_multiplier(val, 1024, 2);
break;
case 'g':
case 'G':
ovr = raise_by_multiplier(val, 1024, 3);
break;
default:
ovr = 2;
}
}
return (ovr);
}
/*
* Read/Write helpers to ensure a full chunk is read or written
* unless there is an error.
*/
ssize_t
Read(int fd, void *buf, size_t count)
{
ssize_t rcount, rem;
uchar_t *cbuf;
rem = count;
cbuf = (uchar_t *)buf;
do {
rcount = read(fd, cbuf, rem);
if (rcount < 0) return (rcount);
if (rcount == 0) break;
rem = rem - rcount;
cbuf += rcount;
} while (rem);
return (count - rem);
}
ssize_t
Write(int fd, const void *buf, size_t count)
{
ssize_t wcount, rem;
uchar_t *cbuf;
rem = count;
cbuf = (uchar_t *)buf;
do {
wcount = write(fd, cbuf, rem);
if (wcount < 0) return (wcount);
rem = rem - wcount;
cbuf += wcount;
} while (rem);
return (count - rem);
}

116
utils.h Normal file
View file

@ -0,0 +1,116 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#ifndef _UTILS_H
#define _UTILS_H
#include <arpa/nameser_compat.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ulong_t u_long
#define uchar_t u_char
#define uint8_t u_char
#define uint64_t u_int64_t
#define uint32_t u_int32_t
#if ULONG_MAX == 4294967295UL
# ifndef UINT64_C
# define UINT64_C(n) n ## ULL
# endif
#else
# ifndef UINT64_C
# define UINT64_C(n) n ## UL
# endif
#endif
typedef unsigned long uintptr_t;
#undef WORDS_BIGENDIAN
#if BYTE_ORDER == BIG_ENDIAN
# define WORDS_BIGENDIAN
# ifndef htonll
# define htonll(x) (x)
# endif
# ifndef ntonll
# define ntohll(x) (x)
# endif
#else
# ifndef htonll
# define htonll(x) __bswap_64(x)
# endif
# ifndef ntohll
# define ntohll(x) __bswap_64(x)
# endif
#endif
// These allow helping the compiler in some often-executed branches, whose
// result is almost always the same.
#ifdef __GNUC__
# define likely(expr) __builtin_expect(expr, 1)
# define unlikely(expr) __builtin_expect(expr, 0)
# define ATOMIC_ADD(var, val) __sync_fetch_and_add(&var, val)
# define ATOMIC_SUB(var, val) __sync_fetch_and_sub(&var, val)
#else
# define likely(expr) (expr)
# define unlikely(expr) (expr)
# if defined(sun) || defined (__sun)
# include <atomic.h>
# define ATOMIC_ADD(var, val) atomic_add_int(&var, val)
# define ATOMIC_SUB(var, val) atomic_add_int(&var, -val)
# else
// Dunno what to do
# define ATOMIC_ADD(var, val) var += val
# define ATOMIC_SUB(var, val) var -= val
# endif
#endif
extern void err_exit(int show_errno, const char *format, ...);
extern const char *get_execname(const char *);
extern int parse_numeric(ssize_t *val, const char *str);
extern ssize_t Read(int fd, void *buf, size_t count);
extern ssize_t Write(int fd, const void *buf, size_t count);
/*
* Roundup v to the nearest power of 2. From Bit Twiddling Hacks:
* http://graphics.stanford.edu/~seander/bithacks.html
*/
static inline unsigned int
roundup_pow_two(unsigned int v) {
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
return (v);
}
#ifdef __cplusplus
}
#endif
#endif

144
zlib_compress.c Normal file
View file

@ -0,0 +1,144 @@
/*
* This file is a part of Pcompress, a chunked parallel multi-
* algorithm lossless compression and decompression program.
*
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
* Use is subject to license terms.
*
* This program 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 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
* Lesser General Public License for more details.
*
* moinakg@belenix.org, http://moinakg.wordpress.com/
*
* This program includes partly-modified public domain source
* code from the LZMA SDK: http://www.7-zip.org/sdk.html
*/
#include <stdio.h>
#include <sys/types.h>
#include <strings.h>
#include <zlib.h>
#include <utils.h>
#include <pcompress.h>
#include <allocator.h>
static void *
slab_alloc_ui(void *p, unsigned int items, unsigned int size) {
void *ptr;
size_t tot = (size_t)items * (size_t)size;
ptr = slab_alloc(p, tot);
return (ptr);
}
int
zlib_init(void **data, int *level, ssize_t chunksize)
{
if (*level > 9) *level = 9;
return (0);
}
static
void zerr(int ret)
{
switch (ret) {
case Z_ERRNO:
perror(" ");
break;
case Z_STREAM_ERROR:
fprintf(stderr, "Zlib: Invalid compression level\n");
break;
case Z_DATA_ERROR:
fprintf(stderr, "Zlib: Invalid or incomplete deflate data\n");
break;
case Z_MEM_ERROR:
fprintf(stderr, "Zlib: Out of memory\n");
break;
case Z_VERSION_ERROR:
fprintf(stderr, "Zlib: Version mismatch!\n");
break;
default:
fprintf(stderr, "Zlib: Unknown error code: %d\n", ret);
}
}
int
zlib_compress(void *src, size_t srclen, void *dst, size_t *dstlen, int level, void *data)
{
z_stream zs;
int ret;
zs.next_in = src;
zs.avail_in = srclen;
zs.next_out = dst;
zs.avail_out = *dstlen;
zs.zalloc = slab_alloc_ui;
zs.zfree = slab_free;
zs.opaque = NULL;
ret = deflateInit(&zs, level);
if (ret != Z_OK) {
zerr(ret);
return (-1);
}
ret = deflate(&zs, Z_FINISH);
if (ret != Z_STREAM_END) {
deflateEnd(&zs);
if (ret == Z_OK)
zerr(Z_BUF_ERROR);
else
zerr(ret);
return (-1);
}
*dstlen = zs.total_out;
ret = deflateEnd(&zs);
if (ret != Z_OK) {
zerr(ret);
return (-1);
}
return (0);
}
int
zlib_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, int level, void *data)
{
z_stream zs;
int err;
bzero(&zs, sizeof (zs));
zs.next_in = (unsigned char *)src + CHDR_SZ;
zs.avail_in = srclen;
zs.next_out = dst;
zs.avail_out = *dstlen;
zs.zalloc = slab_alloc_ui;
zs.zfree = slab_free;
zs.opaque = NULL;
if ((err = inflateInit(&zs)) != Z_OK) {
zerr(err);
return (-1);
}
if ((err = inflate(&zs, Z_FINISH)) != Z_STREAM_END) {
inflateEnd(&zs);
if (err == Z_OK)
zerr(Z_BUF_ERROR);
else
zerr(err);
return (-1);
}
*dstlen = zs.total_out;
inflateEnd(&zs);
return (0);
}