summaryrefslogtreecommitdiff
path: root/packages/chm
diff options
context:
space:
mode:
authorandrew <andrew@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-10-09 10:50:41 +0000
committerandrew <andrew@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-10-09 10:50:41 +0000
commit086c83cedd44a26335a080c39f9b886e06a558a9 (patch)
tree8f031ab7943fe9b2545c9f521f98a7361bc8c076 /packages/chm
parentd29952ec92e1e1ef87c9751ff3806993c2c1b0fb (diff)
downloadfpc-086c83cedd44a26335a080c39f9b886e06a558a9.tar.gz
* added multithreaded lzx compression for lzx. Must be enabled with -dLZX_USETHREADS
* Updated makefile.fpc and Makefile for packages/chm git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@13819 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/chm')
-rw-r--r--packages/chm/Makefile118
-rw-r--r--packages/chm/Makefile.fpc2
-rw-r--r--packages/chm/fpmake.pp7
-rw-r--r--packages/chm/src/chmwriter.pas53
-rw-r--r--packages/chm/src/lzxcompressthread.pas529
-rw-r--r--packages/chm/src/paslzxcomp.pas18
6 files changed, 656 insertions, 71 deletions
diff --git a/packages/chm/Makefile b/packages/chm/Makefile
index 913e0bca51..f4b6c1c9b7 100644
--- a/packages/chm/Makefile
+++ b/packages/chm/Makefile
@@ -1,5 +1,5 @@
#
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/08/02]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/10/03]
#
default: all
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@@ -441,178 +441,178 @@ ifeq ($(FULL_TARGET),armeb-embedded)
override TARGET_PROGRAMS+=chmcmd chmls
endif
ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
endif
override INSTALL_FPCPACKAGE=y
ifeq ($(FULL_TARGET),i386-linux)
diff --git a/packages/chm/Makefile.fpc b/packages/chm/Makefile.fpc
index ffd2197ba1..a623e04f9c 100644
--- a/packages/chm/Makefile.fpc
+++ b/packages/chm/Makefile.fpc
@@ -9,7 +9,7 @@ version=2.5.1
[target]
units=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes \
chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer \
- chmfiftimain
+ chmfiftimain lzxcompressthread
programs=chmcmd chmls
examples=
diff --git a/packages/chm/fpmake.pp b/packages/chm/fpmake.pp
index 7c0897779d..3d28527058 100644
--- a/packages/chm/fpmake.pp
+++ b/packages/chm/fpmake.pp
@@ -56,7 +56,7 @@ begin
end;
T:=P.Targets.AddUnit('chmtypes.pas');
with T.Dependencies do
- begin
+ begin
AddUnit('chmbase');
end;
T:=P.Targets.AddUnit('htmlindexer.pas');
@@ -74,6 +74,11 @@ begin
AddUnit('paslzxcomp');
AddUnit('chmfiftimain');
end;
+ T:=P.Targets.AddUnit('lzxcompressthread');
+ with T.Dependencies do
+ begin
+ AddUnit('paslzxcomp');
+ end;
T:=P.Targets.AddUnit('fasthtmlparser.pas');
T:=P.Targets.AddUnit('htmlutil.pas');
T:=P.Targets.AddUnit('paslznonslide.pas');
diff --git a/packages/chm/src/chmwriter.pas b/packages/chm/src/chmwriter.pas
index 1e5a405098..db59a38429 100644
--- a/packages/chm/src/chmwriter.pas
+++ b/packages/chm/src/chmwriter.pas
@@ -20,9 +20,10 @@
}
unit chmwriter;
{$MODE OBJFPC}{$H+}
+{ $DEFINE LZX_USETHREADS}
interface
-uses Classes, ChmBase, chmtypes, chmspecialfiles, HtmlIndexer, chmsitemap, Avl_Tree;
+uses Classes, ChmBase, chmtypes, chmspecialfiles, HtmlIndexer, chmsitemap, Avl_Tree{$IFDEF LZX_USETHREADS}, lzxcompressthread{$ENDIF};
type
@@ -129,6 +130,14 @@ Type
function WriteCompressedData(Count: Longint; Buffer: Pointer): LongInt;
procedure MarkFrame(UnCompressedTotal, CompressedTotal: LongWord);
// end callbacks
+ {$IFDEF LZX_USETHREADS}
+ // callbacks for lzx compress threads
+ function LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer;
+ function LTIsEndOfFile(Sender: TLZXCompressor): Boolean;
+ procedure LTChunkDone(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer);
+ procedure LTMarkFrame(Sender: TLZXCompressor; CompressedTotal: Integer; UncompressedTotal: Integer);
+ {$ENDIF}
+ // end callbacks
public
constructor Create(OutStream: TStream; FreeStreamOnDestroy: Boolean);
destructor Destroy; override;
@@ -1091,6 +1100,33 @@ begin
// We have to trim the last entry off when we are done because there is no next block in that case
end;
+{$IFDEF LZX_USETHREADS}
+function TChmWriter.LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer;
+ Buffer: Pointer): Integer;
+begin
+ Result := GetData(WantedByteCount, Buffer);
+ //WriteLn('Wanted ', WantedByteCount, ' got ', Result);
+end;
+
+function TChmWriter.LTIsEndOfFile(Sender: TLZXCompressor): Boolean;
+begin
+ Result := AtEndOfData;
+end;
+
+procedure TChmWriter.LTChunkDone(Sender: TLZXCompressor;
+ CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer);
+begin
+ WriteCompressedData(CompressedSize, Buffer);
+end;
+
+procedure TChmWriter.LTMarkFrame(Sender: TLZXCompressor;
+ CompressedTotal: Integer; UncompressedTotal: Integer);
+begin
+ MarkFrame(UncompressedTotal, CompressedTotal);
+ //WriteLn('Mark Frame C = ', CompressedTotal, ' U = ', UncompressedTotal);
+end;
+{$ENDIF}
+
procedure TChmWriter.CheckFileMakeSearchable(AStream: TStream; AFileEntry: TFileEntryRec);
var
@@ -1487,9 +1523,14 @@ end;
procedure TChmWriter.StartCompressingStream;
var
+ {$IFNDEF LZX_USETHREADS}
LZXdata: Plzx_data;
WSize: LongInt;
+ {$ELSE}
+ Compressor: TLZXCompressor;
+ {$ENDIF}
begin
+ {$IFNDEF LZX_USETHREADS}
lzx_init(@LZXdata, LZX_WINDOW_SIZE, @_GetData, Self, @_AtEndOfData,
@_WriteCompressedData, Self, @_MarkFrame, Self);
@@ -1503,6 +1544,16 @@ begin
MarkFrame(LZXdata^.len_uncompressed_input, LZXdata^.len_compressed_output);
lzx_finish(LZXdata, nil);
+ {$ELSE}
+ Compressor := TLZXCompressor.Create(10);
+ Compressor.OnChunkDone :=@LTChunkDone;
+ Compressor.OnGetData :=@LTGetData;
+ Compressor.OnIsEndOfFile:=@LTIsEndOfFile;
+ Compressor.OnMarkFrame :=@LTMarkFrame;
+ Compressor.Execute(True);
+ //Sleep(20000);
+ Compressor.Free;
+ {$ENDIF}
end;
end.
diff --git a/packages/chm/src/lzxcompressthread.pas b/packages/chm/src/lzxcompressthread.pas
new file mode 100644
index 0000000000..f22dd2b1d2
--- /dev/null
+++ b/packages/chm/src/lzxcompressthread.pas
@@ -0,0 +1,529 @@
+{ Copyright (C) <2009> <Andrew Haines> lzxcompressthread.pas
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+}
+{
+ See the file COPYING.FPC, included in this distribution,
+ for details about the copyright.
+}
+unit lzxcompressthread;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, paslzxcomp;
+
+type
+ TLZXCompressor = class;
+ TLZXMasterThread = class;
+ TLZXWorkerThread = class;
+
+ TLZXGetDataMethod = function(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer of object;
+ TLZXIsEndOfFileMethod = function(Sender: TLZXCompressor): Boolean of object;
+ TLZXChunkDoneMethod = procedure(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer) of object;
+ TLZXMarkFrameMethod = procedure(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer) of object;
+
+ PLZXFinishedBlock = ^TLZXFinishedBlock;
+ TLZXFinishedBlock = record
+ CompressedSize: Integer;
+ UnCompressedSize: Integer;
+ Frame1CSize,
+ Frame1USize,
+ Frame2CSize,
+ Frame2USize: Integer;
+ Index: Integer;
+ Data: Pointer;
+ end;
+
+ { TLZXCompressor }
+
+ TLZXCompressor = class(TObject)
+ private
+ FOnMarkFrame: TLZXMarkFrameMethod;
+ FThreadCount: Integer;
+ FBlockSize: Integer;
+ FTotalCompressedSize: DWord;
+ FTotalUnCompressedSize: DWord;
+ FOnChunkDone: TLZXChunkDoneMethod;
+ FOnGetData: TLZXGetDataMethod;
+ FOnIsEndOfFile: TLZXIsEndOfFileMethod;
+ FWindowSizeCode: Integer;
+ FinishedBlocks: TFPList;
+ NextBlockNeeded: Integer;
+ FMasterThread: TLZXMasterThread;
+ procedure BlockIsFinished(ABlock: PLZXFinishedBlock);
+ function GetRunning: Boolean;
+ public
+ constructor Create(AThreadCount: Integer);
+ destructor Destroy; override;
+
+ procedure Execute(WaitForFinish: Boolean = True);
+
+ property BlockSize: Integer read FBlockSize write FBlockSize;
+ property Running: Boolean read GetRunning;
+ property WindowSizeCode: Integer read FWindowSizeCode write FWindowSizeCode;
+
+ // the following properties must all be assigned
+ property OnGetData: TLZXGetDataMethod read FOnGetData write FOnGetData;
+ property OnChunkDone: TLZXChunkDoneMethod read FOnChunkDone write FOnChunkDone;
+ property OnIsEndOfFile: TLZXIsEndOfFileMethod read FOnIsEndOfFile write FOnIsEndOfFile;
+ property OnMarkFrame: TLZXMarkFrameMethod read FOnMarkFrame write FOnMarkFrame;
+ end;
+
+ { TLZXMasterThread }
+
+ TLZXMasterThread = class(TThread)
+ FCompressor: TLZXCompressor;
+ FBusyThreads: TFPList;
+ FLockData: TRTLCriticalSection;
+ FLockQueueThread: TRTLCriticalSection;
+ FDataRemains: Boolean;
+ FBlockNumber: Integer;
+ FRunning: Boolean;
+ FMemList: TFPList;
+
+ // only used inside a critical section!!
+ // belongs to a Worker thread which will free it
+ FTmpData: Pointer;
+ FTmpDataSize: Integer;
+
+ procedure UpdateDataRemains;
+
+ function BlockDone(Worker: TLZXWorkerThread; ABlock: PLZXFinishedBlock): Boolean;
+ procedure WorkerFinished(Sender: TObject);
+ function GetFreeMemoryChunk: Pointer;
+
+
+ procedure Lock;
+ Procedure UnLock;
+ procedure LockTmpData;
+ procedure UnLockTmpData;
+ function Working: Boolean;
+ function DataRemains: Boolean;
+ function Running: Boolean;
+ function QueueThread(Thread: TLZXWorkerThread): Boolean;
+
+ public
+ procedure Execute; override;
+ constructor Create(Compressor: TLZXCompressor);
+ destructor Destroy; override;
+ end;
+
+ { TLZXWorkerThread }
+
+ TLZXWorkerThread = class(TThread)
+ private
+ Data: PByte;
+ DataSize: Integer;
+ DataCursor: Integer;
+ Frame1C,
+ Frame1U,
+ Frame2C,
+ Frame2U: Integer;
+
+ LZXData: Plzx_data;
+
+ CompressedData: PByte;
+ CompressedDataSize: Integer; // compressed written size. not the size of the array
+
+ BlockNumber: Integer;
+
+ WindowSizeCode: Integer;
+ BlockSize: Integer;
+
+ MasterThread: TLZXMasterThread;
+ ShouldSuspend: Boolean;
+
+ // callbacks for lzxcomp
+ function GetBytes(ACount: Longint; ABuffer: Pointer): LongInt; cdecl;
+ function WriteBytes(ACount: LongInt; ABuffer: Pointer): LongInt; cdecl;
+ procedure MarkFrame(UnCompressedSize: DWord; CompressedSize: DWord); cdecl;
+ function IsEndOfFile: LongBool; cdecl;
+ // end callbacks
+ procedure NotifyMasterDone;
+ protected
+ procedure Execute; override;
+ public
+ procedure CompressData(ABlockNumber: Integer);
+
+ constructor Create(AMaster: TLZXMasterThread; AWindowSizeCode: Integer; ABlockSize: Integer);
+ destructor Destroy; override;
+ end;
+
+implementation
+uses
+ Sysutils; // for Sleep()
+
+{ TLZXCompressor }
+
+procedure TLZXCompressor.BlockIsFinished(ABlock: PLZXFinishedBlock);
+ procedure SendChunk(AChunk: PLZXFinishedBlock);
+ begin
+ if Assigned(FOnMarkFrame) then
+ begin
+ Inc(FTotalCompressedSize, AChunk^.Frame1CSize);
+ Inc(FTotalUnCompressedSize, AChunk^.Frame1USize);
+ Inc(NextBlockNeeded);
+
+ FOnMarkFrame(Self, FTotalCompressedSize, FTotalUnCompressedSize);
+
+ if AChunk^.Frame2CSize > 0 then
+ begin
+ Inc(FTotalCompressedSize, AChunk^.Frame2CSize);
+ Inc(FTotalUnCompressedSize, AChunk^.Frame2USize);
+ FOnMarkFrame(Self, FTotalCompressedSize, FTotalUnCompressedSize);
+ end;
+ end;
+
+ FOnChunkDone(Self, AChunk^.CompressedSize, AChunk^.UnCompressedSize, AChunk^.Data);
+ FMasterThread.FMemList.Add(AChunk^.Data);
+ Dispose(AChunk);
+ end;
+var
+ TmpBlock : PLZXFinishedBlock;
+ FoundMatch: Boolean;
+ i: Integer;
+
+begin
+ if NextBlockNeeded = ABlock^.Index then
+ SendChunk(ABlock)
+ else
+ FinishedBlocks.Add(ABlock);
+
+ repeat
+ FoundMatch := False;
+ for i := FinishedBlocks.Count-1 downto 0 do
+ begin
+ TmpBlock := PLZXFinishedBlock(FinishedBlocks.Items[i]);
+ if TmpBlock^.Index = NextBlockNeeded then
+ begin
+ FoundMatch := True;
+ SendChunk(TmpBlock);
+ FinishedBlocks.Delete(i);
+ end;
+ end;
+ until not FoundMatch;
+end;
+
+function TLZXCompressor.GetRunning: Boolean;
+begin
+ Result := FMasterThread.Running;
+end;
+
+constructor TLZXCompressor.Create(AThreadCount: Integer);
+begin
+ inherited Create;
+ FThreadCount := AThreadCount;
+ FBlockSize := 1 shl 16 ; // $10000;
+ FWindowSizeCode := 16;
+ FMasterThread := TLZXMasterThread.Create(Self);
+ FinishedBlocks := TFPList.Create;
+end;
+
+destructor TLZXCompressor.Destroy;
+begin
+ FMasterThread.Free;
+ FinishedBlocks.Free;
+ inherited Destroy;
+end;
+
+procedure TLZXCompressor.Execute(WaitForFinish: Boolean = True);
+begin
+ FTotalCompressedSize := 0;
+ FTotalUnCompressedSize := 0;
+ FMasterThread.FRunning:=True;
+ FMasterThread.Resume;
+ if WaitForFinish then
+ While Running do
+ CheckSynchronize(50);
+end;
+
+{ TLZXMasterThread }
+
+procedure TLZXMasterThread.UpdateDataRemains;
+begin
+ FDataRemains := not FCompressor.FOnIsEndOfFile(FCompressor);
+end;
+
+function TLZXMasterThread.BlockDone(Worker: TLZXWorkerThread; ABlock: PLZXFinishedBlock): Boolean;
+begin
+ Lock;
+ REsult := True;
+ FCompressor.BlockIsFinished(ABlock);
+ if DataRemains then
+ QueueThread(Worker)
+ else
+ begin
+ Result := False;
+ FBusyThreads.Remove(Worker);
+ Worker.Terminate;
+ if FBusyThreads.Count = 0 then
+ Resume;
+ end;
+ Unlock;
+end;
+
+procedure TLZXMasterThread.WorkerFinished(Sender: TObject);
+begin
+ FBusyThreads.Remove(Sender);
+ if TThread(Sender).FatalException <> nil then
+ Raise Exception(TThread(Sender).FatalException);
+ Sender.Free;
+end;
+
+function TLZXMasterThread.GetFreeMemoryChunk: Pointer;
+begin
+ if FMemList.Count >0 then
+ begin
+ Result := FMemList.Items[0];
+ FMemList.Delete(0);
+ end
+ else
+ Result := Getmem(FCompressor.BlockSize);
+end;
+
+procedure TLZXMasterThread.Lock;
+begin
+ EnterCriticalsection(FLockData);
+end;
+
+procedure TLZXMasterThread.UnLock;
+begin
+ LeaveCriticalsection(FLockData);
+end;
+
+procedure TLZXMasterThread.LockTmpData;
+begin
+ EnterCriticalsection(FLockQueueThread);
+end;
+
+procedure TLZXMasterThread.UnLockTmpData;
+begin
+ LeaveCriticalsection(FLockQueueThread);
+end;
+
+function TLZXMasterThread.Working: Boolean;
+begin
+ Result := FBusyThreads.Count > 0;
+end;
+
+function TLZXMasterThread.DataRemains: Boolean;
+begin
+ UpdateDataRemains;
+ Result := FDataRemains;
+end;
+
+function TLZXMasterThread.Running: Boolean;
+begin
+ REsult := FRunning;
+end;
+
+function TLZXMasterThread.QueueThread(Thread: TLZXWorkerThread): Boolean;
+begin
+ LockTmpData;
+
+ Result := DataRemains;
+ if Not Result then
+ begin
+ UnLockTmpData;
+ Exit;
+ end;
+
+ FDataRemains := False;
+
+ Thread.DataSize := FCompressor.OnGetData(FCompressor, FCompressor.FBlockSize, Thread.Data);
+
+ Thread.CompressData(FBlockNumber);
+ Inc(FBlockNumber);
+ Thread.Resume;
+ UnLockTmpData;
+end;
+
+procedure TLZXMasterThread.Execute;
+var
+ i: Integer;
+ Thread: TLZXWorkerThread;
+begin
+ FRunning:= True;
+ for i := 0 to FCompressor.FThreadCount-1 do
+ begin
+ Thread := TLZXWorkerThread.Create(Self, FCompressor.WindowSizeCode, FCompressor.BlockSize);
+ Thread.FreeOnTerminate := True;
+ Thread.OnTerminate:= @WorkerFinished;
+ if QueueThread(Thread) then
+ FBusyThreads.Add(Thread);
+ end;
+ //Suspend;
+ while Working do
+ begin
+ Sleep(50);
+ end;
+ FRunning:= False;
+end;
+
+constructor TLZXMasterThread.Create(Compressor: TLZXCompressor);
+begin
+ Inherited Create(True);
+ FCompressor := Compressor;
+ FDataRemains := True;
+ FBusyThreads := TFPList.Create;
+ FMemList := TFPList.Create;
+ InitCriticalSection(FLockData);
+ InitCriticalSection(FLockQueueThread);
+end;
+
+destructor TLZXMasterThread.Destroy;
+var
+ i: Integer;
+begin
+ DoneCriticalsection(FLockData);
+ DoneCriticalsection(FLockQueueThread);
+
+ for i := 0 to FBusyThreads.Count-1 do TObject(FBusyThreads.Items[i]).Free;
+ for i := 0 to FMemList.Count-1 do Freemem(FMemList.Items[i]);
+
+ FBusyThreads.Free;
+ FMemList.Free;
+
+ inherited Destroy;
+end;
+
+{ TLZXWorkerThread }
+
+function TLZXWorkerThread.GetBytes(ACount: Longint; ABuffer: Pointer): LongInt; cdecl;
+var
+ MaxBytes: Integer;
+begin
+ MaxBytes := DataSize - DataCursor;
+
+ if ACount > MaxBytes then
+ ACount := MaxBytes;
+
+ Move(Data[DataCursor], ABuffer^, ACount);
+ Inc(DataCursor, ACount);
+
+ Result := ACount;
+end;
+
+function TLZXWorkerThread.WriteBytes(ACount: LongInt; ABuffer: Pointer
+ ): LongInt; cdecl;
+begin
+ Move(ABuffer^, CompressedData[CompressedDataSize], ACount);
+ Inc(CompressedDataSize, ACount);
+ Result := ACount;
+end;
+
+procedure TLZXWorkerThread.MarkFrame(UnCompressedSize: DWord;
+ CompressedSize: DWord); cdecl;
+begin
+ if Frame1C = 0 then
+ begin
+ Frame1C := CompressedSize;
+ Frame1U := UnCompressedSize;
+ end
+ else
+ begin
+ Frame2C := CompressedSize;
+ Frame2U := UnCompressedSize;
+ end;
+end;
+
+function TLZXWorkerThread.IsEndOfFile: LongBool; cdecl;
+begin
+ Result := LongBool(DataSize - DataCursor <= 0);
+end;
+
+procedure TLZXWorkerThread.NotifyMasterDone;
+var
+ Block: PLZXFinishedBlock;
+begin
+ LZXData^.len_compressed_output:=0;
+ LZXData^.len_uncompressed_input:=0;
+
+ New(Block);
+ Block^.Data := MasterThread.GetFreeMemoryChunk;
+ Move(CompressedData^, Block^.Data^, CompressedDataSize);
+ Block^.CompressedSize := CompressedDataSize;
+ Block^.UnCompressedSize:= DataSize;
+ Block^.Index := BlockNumber;
+ Block^.Frame1CSize := Frame1C;
+ Block^.Frame2CSize := Frame2C-Frame1C;
+ Block^.Frame1USize := Frame1U;
+ Block^.Frame2USize := Frame2U-Frame1U;
+
+ Frame1C := 0;
+ Frame2C := 0;
+ Frame1U := 0;
+ Frame2U := 0;
+
+ ShouldSuspend := not MasterThread.BlockDone(Self, Block);
+
+end;
+
+procedure TLZXWorkerThread.CompressData(ABlockNumber: Integer);
+begin
+ BlockNumber := ABlockNumber;
+ DataCursor := 0;
+ CompressedDataSize := 0;
+end;
+
+procedure TLZXWorkerThread.Execute;
+var
+ WSize: LongInt;
+begin
+ WSize := 1 shl WindowSizeCode;
+ while not Terminated do
+ begin
+ lzx_reset(LZXdata);
+ lzx_compress_block(LZXdata, WSize, True);
+
+ MasterThread.Synchronize(@NotifyMasterDone);
+
+ if ShouldSuspend then
+ Suspend;
+ end;
+end;
+
+constructor TLZXWorkerThread.Create(AMaster: TLZXMasterThread;
+ AWindowSizeCode: Integer; ABlockSize: Integer);
+begin
+ Inherited Create(True);
+ MasterThread := AMaster;
+ WindowSizeCode := AWindowSizeCode;
+ BlockSize := ABlockSize;
+ FreeOnTerminate := True;
+
+ Data := GetMem(ABlockSize);
+ CompressedData:=GetMem(ABlockSize);
+
+ lzx_init(@LZXdata, longint(WindowSizeCode),
+ TGetBytesFunc(@TLZXWorkerThread.GetBytes), Self,
+ TIsEndOfFileFunc(@TLZXWorkerThread.IsEndOfFile),
+ TWriteBytesFunc(@TLZXWorkerThread.WriteBytes), Self,
+ TMarkFrameFunc(@TLZXWorkerThread.MarkFrame), Self);
+end;
+
+destructor TLZXWorkerThread.Destroy;
+begin
+ lzx_finish(LZXdata, nil);
+ Freemem(Data);
+ FreeMem(CompressedData);
+ inherited Destroy;
+end;
+
+end.
+
diff --git a/packages/chm/src/paslzxcomp.pas b/packages/chm/src/paslzxcomp.pas
index 0290f69589..676744c71c 100644
--- a/packages/chm/src/paslzxcomp.pas
+++ b/packages/chm/src/paslzxcomp.pas
@@ -710,11 +710,11 @@ begin
end
else begin
mask_bits := (1 shl shift_bits) - 1;
- lzxd^.bit_buf := lzxd^.bit_buf shl shift_bits;
- lzxd^.bit_buf := lzxd^.bit_buf or (bits shr rshift_bits) and mask_bits;
+ lzxd^.bit_buf := word(lzxd^.bit_buf shl shift_bits);
+ lzxd^.bit_buf := word(lzxd^.bit_buf or (bits shr rshift_bits) and mask_bits);
end;
{$IFDEF ENDIAN_BIG}
- lzxd^.bit_buf := ((lzxd^.bit_buf and $FF)shl 8) or (lzxd^.bit_buf shr 8);
+ lzxd^.bit_buf := word(((lzxd^.bit_buf and $FF)shl 8) or (lzxd^.bit_buf shr 8));
{$ENDIF}
lzxd^.put_bytes(lzxd^.out_arg, sizeof(lzxd^.bit_buf), @lzxd^.bit_buf);
Inc(lzxd^.len_compressed_output, sizeof(lzxd^.bit_buf));
@@ -726,8 +726,8 @@ begin
// otherwise move bits in */
shift_bits := nbits;
mask_bits := (1 shl shift_bits) - 1;
- lzxd^.bit_buf := lzxd^.bit_buf shl shift_bits;
- lzxd^.bit_buf := lzxd^.bit_buf or bits and mask_bits;
+ lzxd^.bit_buf := word(lzxd^.bit_buf shl shift_bits);
+ lzxd^.bit_buf := word(lzxd^.bit_buf or bits and mask_bits);
Inc(cur_bits, nbits);
lzxd^.bits_in_buf := cur_bits;
@@ -892,8 +892,8 @@ begin
Inc(freqs[19]);
//* right, MS lies again. Code is NOT
// prev_len + len (mod 17), it's prev_len - len (mod 17)*/
- codep^ := prevlengths[i-cur_run] - last_len;
- if (codep^ > 16) then Inc(codep^, 17);
+ codep^ := byte(prevlengths[i-cur_run] - last_len);
+ if (codep^ > 16) then codep^ := byte(codep^ + 17); //Inc(codep^, 17);
Inc(freqs[codep^]);
Inc(codep);
runp^ := 0; //* not necessary */
@@ -901,8 +901,8 @@ begin
Dec(cur_run, excess+4);
end;
while (cur_run > 0) do begin
- codep^ := prevlengths[i-cur_run] - last_len;
- if (codep^ > 16) then Inc(codep^, 17);
+ codep^ := byte(prevlengths[i-cur_run] - last_len);
+ if (codep^ > 16) then codep^ := byte(codep^ + 17); //Inc(codep^, byte(17));
runp^ := 0; //* not necessary */
Inc(runp);
Dec(cur_run);