1 /* 2 * Copyright (c) 2000-2013 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 29 /* direct-mapped partial matching compressor with simple 22/10 split 30 * 31 * Compresses buffers using a dictionary based match and partial match 32 * (high bits only or full match) scheme. 33 * 34 * Paul Wilson -- [email protected] 35 * Scott F. Kaplan -- [email protected] 36 * September 1997 37 */ 38 39 /* compressed output format, in memory order 40 * 1. a four-word HEADER containing four one-word values: 41 * i. a one-word code saying what algorithm compressed the data 42 * ii. an integer WORD offset into the page saying 43 * where the queue position area starts 44 * iii. an integer WORD offset into the page saying where 45 * the low-bits area starts 46 * iv. an integer WORD offset into the page saying where the 47 * low-bits area ends 48 * 49 * 2. a 64-word TAGS AREA holding one two-bit tag for each word in 50 * the original (1024-word) page, packed 16 per word 51 * 52 * 3. a variable-sized FULL WORDS AREA (always word aligned and an 53 * integral number of words) holding full-word patterns that 54 * were not in the dictionary when encoded (i.e., dictionary misses) 55 * 56 * 4. a variable-sized QUEUE POSITIONS AREA (always word aligned and 57 * an integral number of words) holding four-bit queue positions, 58 * packed eight per word. 59 * 60 * 5. a variable-sized LOW BITS AREA (always word aligned and an 61 * integral number of words) holding ten-bit low-bit patterns 62 * (from partial matches), packed three per word. 63 */ 64 65 #ifdef __cplusplus 66 extern "C" { 67 #endif 68 69 #include <mach/vm_param.h> 70 71 72 #define WKdm_SCRATCH_BUF_SIZE_INTERNAL PAGE_SIZE 73 74 typedef unsigned int WK_word; 75 76 #if defined(__arm64__) 77 78 void 79 WKdm_decompress_4k(const WK_word* src_buf, 80 WK_word* dest_buf, 81 WK_word* scratch, 82 unsigned int bytes); 83 int 84 WKdm_compress_4k(const WK_word* src_buf, 85 WK_word* dest_buf, 86 WK_word* scratch, 87 unsigned int limit); 88 89 void 90 WKdm_decompress_16k(WK_word* src_buf, 91 WK_word* dest_buf, 92 WK_word* scratch, 93 unsigned int bytes); 94 int 95 WKdm_compress_16k(WK_word* src_buf, 96 WK_word* dest_buf, 97 WK_word* scratch, 98 unsigned int limit); 99 #else 100 101 void 102 WKdm_decompress_new(WK_word* src_buf, 103 WK_word* dest_buf, 104 WK_word* scratch, 105 unsigned int bytes); 106 int 107 WKdm_compress_new(const WK_word* src_buf, 108 WK_word* dest_buf, 109 WK_word* scratch, 110 unsigned int limit); 111 #endif 112 113 #ifdef __cplusplus 114 } /* extern "C" */ 115 #endif 116