256 | 4.93k | } Line | Count | Source | 69 | 325 | { | 70 | 325 | const lzo_bytep ip; | 71 | 325 | #if (DD_BITS > 0) | 72 | 325 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 325 | lzo_xint dv; | 74 | 325 | #endif | 75 | 325 | unsigned drun = 0; | 76 | 325 | #endif | 77 | 325 | lzo_bytep op; | 78 | 325 | const lzo_bytep const in_end = in + in_len; | 79 | 325 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 325 | const lzo_bytep ii; | 81 | | #if defined(LZO_HAVE_R1) | 82 | | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 325 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 325 | #if (LZO_DETERMINISTIC) | 104 | 325 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 325 | #endif | 106 | | | 107 | | | 108 | 325 | op = out; | 109 | 325 | ip = in; | 110 | 325 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 325 | #if (DD_BITS > 0) | 114 | 325 | DVAL_FIRST(dv,ip); | 115 | 325 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 325 | ip++; | 117 | 325 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 325 | assert(ip < ip_end); | 123 | 325 | for (;;) | 124 | 4.07M | { | 125 | 4.07M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 4.07M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 4.07M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 4.07M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 4.07M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 4.07M | #endif | 143 | | | 144 | 4.07M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 4.07M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 4.07M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 4.07M | #endif | 150 | | | 151 | 4.07M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 3.73M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 3.73M | if (++ip >= ip_end) | 166 | 65 | break; | 167 | 3.73M | #if (DD_BITS > 0) | 168 | 3.73M | DVAL_NEXT(dv,ip); | 169 | 3.73M | #endif | 170 | 3.73M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 337k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 337k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 337k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 337k | #endif | 188 | | | 189 | 337k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 337k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | | #endif | 203 | | | 204 | 337k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 337k | assert(ii == ip); | 209 | | | 210 | 337k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 325 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 325 | if (pd(in_end,ii) > 0) | 249 | 267 | { | 250 | 267 | lzo_uint t = pd(in_end,ii); | 251 | 267 | op = STORE_RUN(op,ii,t); | 252 | 267 | } | 253 | | | 254 | 325 | *out_len = pd(op, out); | 255 | 325 | return LZO_E_OK; /* compression went ok */ | 256 | 325 | } |
Line | Count | Source | 69 | 303 | { | 70 | 303 | const lzo_bytep ip; | 71 | 303 | #if (DD_BITS > 0) | 72 | 303 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 303 | lzo_xint dv; | 74 | 303 | #endif | 75 | 303 | unsigned drun = 0; | 76 | 303 | #endif | 77 | 303 | lzo_bytep op; | 78 | 303 | const lzo_bytep const in_end = in + in_len; | 79 | 303 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 303 | const lzo_bytep ii; | 81 | 303 | #if defined(LZO_HAVE_R1) | 82 | 303 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 303 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 303 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 303 | #if (LZO_DETERMINISTIC) | 104 | 303 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 303 | #endif | 106 | | | 107 | | | 108 | 303 | op = out; | 109 | 303 | ip = in; | 110 | 303 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 303 | #if (DD_BITS > 0) | 114 | 303 | DVAL_FIRST(dv,ip); | 115 | 303 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 303 | ip++; | 117 | 303 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 303 | assert(ip < ip_end); | 123 | 303 | for (;;) | 124 | 3.37M | { | 125 | 3.37M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 3.37M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 3.37M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 3.37M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 3.37M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 3.37M | #endif | 143 | | | 144 | 3.37M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 3.37M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 3.37M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 3.37M | #endif | 150 | | | 151 | 3.37M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 3.24M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 3.24M | if (++ip >= ip_end) | 166 | 65 | break; | 167 | 3.24M | #if (DD_BITS > 0) | 168 | 3.24M | DVAL_NEXT(dv,ip); | 169 | 3.24M | #endif | 170 | 3.24M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 129k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 129k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 129k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 129k | #endif | 188 | | | 189 | 129k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 129k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | | #endif | 203 | | | 204 | 129k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 128k | assert(ii == ip); | 209 | | | 210 | 128k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 303 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 303 | if (pd(in_end,ii) > 0) | 249 | 241 | { | 250 | 241 | lzo_uint t = pd(in_end,ii); | 251 | 241 | op = STORE_RUN(op,ii,t); | 252 | 241 | } | 253 | | | 254 | 303 | *out_len = pd(op, out); | 255 | 303 | return LZO_E_OK; /* compression went ok */ | 256 | 303 | } |
Line | Count | Source | 69 | 305 | { | 70 | 305 | const lzo_bytep ip; | 71 | | #if (DD_BITS > 0) | 72 | | #if defined(__LZO_HASH_INCREMENTAL) | 73 | | lzo_xint dv; | 74 | | #endif | 75 | | unsigned drun = 0; | 76 | | #endif | 77 | 305 | lzo_bytep op; | 78 | 305 | const lzo_bytep const in_end = in + in_len; | 79 | 305 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 305 | const lzo_bytep ii; | 81 | 305 | #if defined(LZO_HAVE_R1) | 82 | 305 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 305 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 305 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 305 | #if (LZO_DETERMINISTIC) | 104 | 305 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 305 | #endif | 106 | | | 107 | | | 108 | 305 | op = out; | 109 | 305 | ip = in; | 110 | 305 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | | #if (DD_BITS > 0) | 114 | | DVAL_FIRST(dv,ip); | 115 | | UPDATE_D(dict,drun,dv,ip,in); | 116 | | ip++; | 117 | | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | 305 | ip++; | 120 | 305 | #endif | 121 | | | 122 | 305 | assert(ip < ip_end); | 123 | 305 | for (;;) | 124 | 1.97M | { | 125 | 1.97M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.97M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 1.97M | #if (DD_BITS == 0) | 131 | 1.97M | lzo_uint dindex; | 132 | 1.97M | #endif | 133 | 1.97M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.97M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.97M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.97M | #endif | 143 | | | 144 | 1.97M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 89.8k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 89.8k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 89.8k | #endif | 150 | | | 151 | 89.8k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.88M | literal: | 162 | 1.88M | #if (DD_BITS == 0) | 163 | 1.88M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 1.88M | #endif | 165 | 1.88M | if (++ip >= ip_end) | 166 | 92 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 1.88M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 1.88M | match: | 179 | 83.5k | #if (DD_BITS == 0) | 180 | 83.5k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 83.5k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 83.5k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 83.5k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 83.5k | #endif | 188 | | | 189 | 83.5k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 83.5k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 83.5k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 83.5k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 83.5k | #endif | 203 | | | 204 | 83.5k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 83.3k | assert(ii == ip); | 209 | | | 210 | 83.3k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 305 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 305 | if (pd(in_end,ii) > 0) | 249 | 265 | { | 250 | 265 | lzo_uint t = pd(in_end,ii); | 251 | 265 | op = STORE_RUN(op,ii,t); | 252 | 265 | } | 253 | | | 254 | 305 | *out_len = pd(op, out); | 255 | 305 | return LZO_E_OK; /* compression went ok */ | 256 | 305 | } |
Line | Count | Source | 69 | 257 | { | 70 | 257 | const lzo_bytep ip; | 71 | | #if (DD_BITS > 0) | 72 | | #if defined(__LZO_HASH_INCREMENTAL) | 73 | | lzo_xint dv; | 74 | | #endif | 75 | | unsigned drun = 0; | 76 | | #endif | 77 | 257 | lzo_bytep op; | 78 | 257 | const lzo_bytep const in_end = in + in_len; | 79 | 257 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 257 | const lzo_bytep ii; | 81 | 257 | #if defined(LZO_HAVE_R1) | 82 | 257 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 257 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 257 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 257 | #if (LZO_DETERMINISTIC) | 104 | 257 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 257 | #endif | 106 | | | 107 | | | 108 | 257 | op = out; | 109 | 257 | ip = in; | 110 | 257 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | | #if (DD_BITS > 0) | 114 | | DVAL_FIRST(dv,ip); | 115 | | UPDATE_D(dict,drun,dv,ip,in); | 116 | | ip++; | 117 | | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | 257 | ip++; | 120 | 257 | #endif | 121 | | | 122 | 257 | assert(ip < ip_end); | 123 | 257 | for (;;) | 124 | 1.37M | { | 125 | 1.37M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.37M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 1.37M | #if (DD_BITS == 0) | 131 | 1.37M | lzo_uint dindex; | 132 | 1.37M | #endif | 133 | 1.37M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.37M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.37M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.37M | #endif | 143 | | | 144 | 1.37M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 93.7k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 93.7k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 93.7k | #endif | 150 | | | 151 | 93.7k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.27M | literal: | 162 | 1.27M | #if (DD_BITS == 0) | 163 | 1.27M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 1.27M | #endif | 165 | 1.27M | if (++ip >= ip_end) | 166 | 85 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 1.27M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 1.27M | match: | 179 | 98.3k | #if (DD_BITS == 0) | 180 | 98.3k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 98.3k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 98.3k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 98.3k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 98.3k | #endif | 188 | | | 189 | 98.3k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 98.3k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 98.3k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 98.3k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 98.3k | #endif | 203 | | | 204 | 98.3k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 98.2k | assert(ii == ip); | 209 | | | 210 | 98.2k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 257 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 257 | if (pd(in_end,ii) > 0) | 249 | 234 | { | 250 | 234 | lzo_uint t = pd(in_end,ii); | 251 | 234 | op = STORE_RUN(op,ii,t); | 252 | 234 | } | 253 | | | 254 | 257 | *out_len = pd(op, out); | 255 | 257 | return LZO_E_OK; /* compression went ok */ | 256 | 257 | } |
Line | Count | Source | 69 | 282 | { | 70 | 282 | const lzo_bytep ip; | 71 | | #if (DD_BITS > 0) | 72 | | #if defined(__LZO_HASH_INCREMENTAL) | 73 | | lzo_xint dv; | 74 | | #endif | 75 | | unsigned drun = 0; | 76 | | #endif | 77 | 282 | lzo_bytep op; | 78 | 282 | const lzo_bytep const in_end = in + in_len; | 79 | 282 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 282 | const lzo_bytep ii; | 81 | 282 | #if defined(LZO_HAVE_R1) | 82 | 282 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 282 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 282 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 282 | #if (LZO_DETERMINISTIC) | 104 | 282 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 282 | #endif | 106 | | | 107 | | | 108 | 282 | op = out; | 109 | 282 | ip = in; | 110 | 282 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | | #if (DD_BITS > 0) | 114 | | DVAL_FIRST(dv,ip); | 115 | | UPDATE_D(dict,drun,dv,ip,in); | 116 | | ip++; | 117 | | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | 282 | ip++; | 120 | 282 | #endif | 121 | | | 122 | 282 | assert(ip < ip_end); | 123 | 282 | for (;;) | 124 | 3.31M | { | 125 | 3.31M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 3.31M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 3.31M | #if (DD_BITS == 0) | 131 | 3.31M | lzo_uint dindex; | 132 | 3.31M | #endif | 133 | 3.31M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 3.31M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 3.31M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 3.31M | #endif | 143 | | | 144 | 3.31M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 163k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 163k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 163k | #endif | 150 | | | 151 | 163k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 3.17M | literal: | 162 | 3.17M | #if (DD_BITS == 0) | 163 | 3.17M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 3.17M | #endif | 165 | 3.17M | if (++ip >= ip_end) | 166 | 106 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 3.17M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 3.17M | match: | 179 | 140k | #if (DD_BITS == 0) | 180 | 140k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 140k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 140k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 140k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 140k | #endif | 188 | | | 189 | 140k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 140k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 140k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 140k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 140k | #endif | 203 | | | 204 | 140k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 140k | assert(ii == ip); | 209 | | | 210 | 140k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 282 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 282 | if (pd(in_end,ii) > 0) | 249 | 260 | { | 250 | 260 | lzo_uint t = pd(in_end,ii); | 251 | 260 | op = STORE_RUN(op,ii,t); | 252 | 260 | } | 253 | | | 254 | 282 | *out_len = pd(op, out); | 255 | 282 | return LZO_E_OK; /* compression went ok */ | 256 | 282 | } |
Line | Count | Source | 69 | 289 | { | 70 | 289 | const lzo_bytep ip; | 71 | 289 | #if (DD_BITS > 0) | 72 | 289 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 289 | lzo_xint dv; | 74 | 289 | #endif | 75 | 289 | unsigned drun = 0; | 76 | 289 | #endif | 77 | 289 | lzo_bytep op; | 78 | 289 | const lzo_bytep const in_end = in + in_len; | 79 | 289 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 289 | const lzo_bytep ii; | 81 | 289 | #if defined(LZO_HAVE_R1) | 82 | 289 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 289 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 289 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 289 | #if (LZO_DETERMINISTIC) | 104 | 289 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 289 | #endif | 106 | | | 107 | | | 108 | 289 | op = out; | 109 | 289 | ip = in; | 110 | 289 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 289 | #if (DD_BITS > 0) | 114 | 289 | DVAL_FIRST(dv,ip); | 115 | 289 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 289 | ip++; | 117 | 289 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 289 | assert(ip < ip_end); | 123 | 289 | for (;;) | 124 | 826k | { | 125 | 826k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 826k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 826k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 826k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 826k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 826k | #endif | 143 | | | 144 | 826k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 803k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 720k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 720k | if (++ip >= ip_end) | 166 | 65 | break; | 167 | 720k | #if (DD_BITS > 0) | 168 | 720k | DVAL_NEXT(dv,ip); | 169 | 720k | #endif | 170 | 720k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 105k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 105k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 105k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 105k | #endif | 188 | | | 189 | 105k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 105k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 105k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 105k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 105k | #endif | 203 | | | 204 | 105k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 105k | assert(ii == ip); | 209 | | | 210 | 105k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 289 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 289 | if (pd(in_end,ii) > 0) | 249 | 262 | { | 250 | 262 | lzo_uint t = pd(in_end,ii); | 251 | 262 | op = STORE_RUN(op,ii,t); | 252 | 262 | } | 253 | | | 254 | 289 | *out_len = pd(op, out); | 255 | 289 | return LZO_E_OK; /* compression went ok */ | 256 | 289 | } |
Line | Count | Source | 69 | 285 | { | 70 | 285 | const lzo_bytep ip; | 71 | 285 | #if (DD_BITS > 0) | 72 | 285 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 285 | lzo_xint dv; | 74 | 285 | #endif | 75 | 285 | unsigned drun = 0; | 76 | 285 | #endif | 77 | 285 | lzo_bytep op; | 78 | 285 | const lzo_bytep const in_end = in + in_len; | 79 | 285 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 285 | const lzo_bytep ii; | 81 | 285 | #if defined(LZO_HAVE_R1) | 82 | 285 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 285 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 285 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 285 | #if (LZO_DETERMINISTIC) | 104 | 285 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 285 | #endif | 106 | | | 107 | | | 108 | 285 | op = out; | 109 | 285 | ip = in; | 110 | 285 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 285 | #if (DD_BITS > 0) | 114 | 285 | DVAL_FIRST(dv,ip); | 115 | 285 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 285 | ip++; | 117 | 285 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 285 | assert(ip < ip_end); | 123 | 285 | for (;;) | 124 | 731k | { | 125 | 731k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 731k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 731k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 731k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 731k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 731k | #endif | 143 | | | 144 | 731k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 716k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 654k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 654k | if (++ip >= ip_end) | 166 | 61 | break; | 167 | 654k | #if (DD_BITS > 0) | 168 | 654k | DVAL_NEXT(dv,ip); | 169 | 654k | #endif | 170 | 654k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 77.0k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 77.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 77.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 77.0k | #endif | 188 | | | 189 | 77.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 77.0k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 77.0k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 77.0k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 77.0k | #endif | 203 | | | 204 | 77.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 76.7k | assert(ii == ip); | 209 | | | 210 | 76.7k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 285 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 285 | if (pd(in_end,ii) > 0) | 249 | 255 | { | 250 | 255 | lzo_uint t = pd(in_end,ii); | 251 | 255 | op = STORE_RUN(op,ii,t); | 252 | 255 | } | 253 | | | 254 | 285 | *out_len = pd(op, out); | 255 | 285 | return LZO_E_OK; /* compression went ok */ | 256 | 285 | } |
Line | Count | Source | 69 | 283 | { | 70 | 283 | const lzo_bytep ip; | 71 | 283 | #if (DD_BITS > 0) | 72 | 283 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 283 | lzo_xint dv; | 74 | 283 | #endif | 75 | 283 | unsigned drun = 0; | 76 | 283 | #endif | 77 | 283 | lzo_bytep op; | 78 | 283 | const lzo_bytep const in_end = in + in_len; | 79 | 283 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 283 | const lzo_bytep ii; | 81 | 283 | #if defined(LZO_HAVE_R1) | 82 | 283 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 283 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 283 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 283 | #if (LZO_DETERMINISTIC) | 104 | 283 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 283 | #endif | 106 | | | 107 | | | 108 | 283 | op = out; | 109 | 283 | ip = in; | 110 | 283 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 283 | #if (DD_BITS > 0) | 114 | 283 | DVAL_FIRST(dv,ip); | 115 | 283 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 283 | ip++; | 117 | 283 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 283 | assert(ip < ip_end); | 123 | 283 | for (;;) | 124 | 843k | { | 125 | 843k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 843k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 843k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 843k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 843k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 843k | #endif | 143 | | | 144 | 843k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 828k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 768k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 768k | if (++ip >= ip_end) | 166 | 55 | break; | 167 | 768k | #if (DD_BITS > 0) | 168 | 768k | DVAL_NEXT(dv,ip); | 169 | 768k | #endif | 170 | 768k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 75.0k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 75.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 75.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 75.0k | #endif | 188 | | | 189 | 75.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 75.0k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 75.0k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 75.0k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 75.0k | #endif | 203 | | | 204 | 75.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 74.8k | assert(ii == ip); | 209 | | | 210 | 74.8k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 283 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 283 | if (pd(in_end,ii) > 0) | 249 | 262 | { | 250 | 262 | lzo_uint t = pd(in_end,ii); | 251 | 262 | op = STORE_RUN(op,ii,t); | 252 | 262 | } | 253 | | | 254 | 283 | *out_len = pd(op, out); | 255 | 283 | return LZO_E_OK; /* compression went ok */ | 256 | 283 | } |
Line | Count | Source | 69 | 271 | { | 70 | 271 | const lzo_bytep ip; | 71 | 271 | #if (DD_BITS > 0) | 72 | 271 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 271 | lzo_xint dv; | 74 | 271 | #endif | 75 | 271 | unsigned drun = 0; | 76 | 271 | #endif | 77 | 271 | lzo_bytep op; | 78 | 271 | const lzo_bytep const in_end = in + in_len; | 79 | 271 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 271 | const lzo_bytep ii; | 81 | 271 | #if defined(LZO_HAVE_R1) | 82 | 271 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 271 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 271 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 271 | #if (LZO_DETERMINISTIC) | 104 | 271 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 271 | #endif | 106 | | | 107 | | | 108 | 271 | op = out; | 109 | 271 | ip = in; | 110 | 271 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 271 | #if (DD_BITS > 0) | 114 | 271 | DVAL_FIRST(dv,ip); | 115 | 271 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 271 | ip++; | 117 | 271 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 271 | assert(ip < ip_end); | 123 | 271 | for (;;) | 124 | 704k | { | 125 | 704k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 704k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 704k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 704k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 704k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 704k | #endif | 143 | | | 144 | 704k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 686k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 641k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 641k | if (++ip >= ip_end) | 166 | 56 | break; | 167 | 641k | #if (DD_BITS > 0) | 168 | 641k | DVAL_NEXT(dv,ip); | 169 | 641k | #endif | 170 | 641k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 62.8k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 62.8k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 62.8k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 62.8k | #endif | 188 | | | 189 | 62.8k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 62.8k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 62.8k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 62.8k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 62.8k | #endif | 203 | | | 204 | 62.8k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 62.6k | assert(ii == ip); | 209 | | | 210 | 62.6k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 271 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 271 | if (pd(in_end,ii) > 0) | 249 | 246 | { | 250 | 246 | lzo_uint t = pd(in_end,ii); | 251 | 246 | op = STORE_RUN(op,ii,t); | 252 | 246 | } | 253 | | | 254 | 271 | *out_len = pd(op, out); | 255 | 271 | return LZO_E_OK; /* compression went ok */ | 256 | 271 | } |
Line | Count | Source | 69 | 295 | { | 70 | 295 | const lzo_bytep ip; | 71 | 295 | #if (DD_BITS > 0) | 72 | 295 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 295 | lzo_xint dv; | 74 | 295 | #endif | 75 | 295 | unsigned drun = 0; | 76 | 295 | #endif | 77 | 295 | lzo_bytep op; | 78 | 295 | const lzo_bytep const in_end = in + in_len; | 79 | 295 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 295 | const lzo_bytep ii; | 81 | 295 | #if defined(LZO_HAVE_R1) | 82 | 295 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 295 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 295 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 295 | #if (LZO_DETERMINISTIC) | 104 | 295 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 295 | #endif | 106 | | | 107 | | | 108 | 295 | op = out; | 109 | 295 | ip = in; | 110 | 295 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 295 | #if (DD_BITS > 0) | 114 | 295 | DVAL_FIRST(dv,ip); | 115 | 295 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 295 | ip++; | 117 | 295 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 295 | assert(ip < ip_end); | 123 | 295 | for (;;) | 124 | 1.09M | { | 125 | 1.09M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.09M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.09M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.09M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.09M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.09M | #endif | 143 | | | 144 | 1.09M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 1.07M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.01M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.01M | if (++ip >= ip_end) | 166 | 66 | break; | 167 | 1.01M | #if (DD_BITS > 0) | 168 | 1.01M | DVAL_NEXT(dv,ip); | 169 | 1.01M | #endif | 170 | 1.01M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 82.0k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 82.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 82.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 82.0k | #endif | 188 | | | 189 | 82.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 82.0k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 82.0k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 82.0k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 82.0k | #endif | 203 | | | 204 | 82.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 81.8k | assert(ii == ip); | 209 | | | 210 | 81.8k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 295 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 295 | if (pd(in_end,ii) > 0) | 249 | 265 | { | 250 | 265 | lzo_uint t = pd(in_end,ii); | 251 | 265 | op = STORE_RUN(op,ii,t); | 252 | 265 | } | 253 | | | 254 | 295 | *out_len = pd(op, out); | 255 | 295 | return LZO_E_OK; /* compression went ok */ | 256 | 295 | } |
Line | Count | Source | 69 | 327 | { | 70 | 327 | const lzo_bytep ip; | 71 | 327 | #if (DD_BITS > 0) | 72 | 327 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 327 | lzo_xint dv; | 74 | 327 | #endif | 75 | 327 | unsigned drun = 0; | 76 | 327 | #endif | 77 | 327 | lzo_bytep op; | 78 | 327 | const lzo_bytep const in_end = in + in_len; | 79 | 327 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 327 | const lzo_bytep ii; | 81 | 327 | #if defined(LZO_HAVE_R1) | 82 | 327 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 327 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 327 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 327 | #if (LZO_DETERMINISTIC) | 104 | 327 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 327 | #endif | 106 | | | 107 | | | 108 | 327 | op = out; | 109 | 327 | ip = in; | 110 | 327 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 327 | #if (DD_BITS > 0) | 114 | 327 | DVAL_FIRST(dv,ip); | 115 | 327 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 327 | ip++; | 117 | 327 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 327 | assert(ip < ip_end); | 123 | 327 | for (;;) | 124 | 1.63M | { | 125 | 1.63M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.63M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.63M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.63M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.63M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.63M | #endif | 143 | | | 144 | 1.63M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 1.63M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 1.63M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 1.63M | #endif | 150 | | | 151 | 1.63M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.55M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.55M | if (++ip >= ip_end) | 166 | 72 | break; | 167 | 1.55M | #if (DD_BITS > 0) | 168 | 1.55M | DVAL_NEXT(dv,ip); | 169 | 1.55M | #endif | 170 | 1.55M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 80.5k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 80.5k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 80.5k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 80.5k | #endif | 188 | | | 189 | 80.5k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 80.5k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 80.5k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 80.5k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 80.5k | #endif | 203 | | | 204 | 80.5k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 80.2k | assert(ii == ip); | 209 | | | 210 | 80.2k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 327 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 327 | if (pd(in_end,ii) > 0) | 249 | 288 | { | 250 | 288 | lzo_uint t = pd(in_end,ii); | 251 | 288 | op = STORE_RUN(op,ii,t); | 252 | 288 | } | 253 | | | 254 | 327 | *out_len = pd(op, out); | 255 | 327 | return LZO_E_OK; /* compression went ok */ | 256 | 327 | } |
Line | Count | Source | 69 | 332 | { | 70 | 332 | const lzo_bytep ip; | 71 | 332 | #if (DD_BITS > 0) | 72 | 332 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 332 | lzo_xint dv; | 74 | 332 | #endif | 75 | 332 | unsigned drun = 0; | 76 | 332 | #endif | 77 | 332 | lzo_bytep op; | 78 | 332 | const lzo_bytep const in_end = in + in_len; | 79 | 332 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 332 | const lzo_bytep ii; | 81 | 332 | #if defined(LZO_HAVE_R1) | 82 | 332 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 332 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 332 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | 332 | #if (LZO_DETERMINISTIC) | 104 | 332 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 332 | #endif | 106 | | | 107 | | | 108 | 332 | op = out; | 109 | 332 | ip = in; | 110 | 332 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 332 | #if (DD_BITS > 0) | 114 | 332 | DVAL_FIRST(dv,ip); | 115 | 332 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 332 | ip++; | 117 | 332 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 332 | assert(ip < ip_end); | 123 | 332 | for (;;) | 124 | 1.68M | { | 125 | 1.68M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.68M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.68M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.68M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.68M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.68M | #endif | 143 | | | 144 | 1.68M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 1.68M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.62M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.62M | if (++ip >= ip_end) | 166 | 62 | break; | 167 | 1.62M | #if (DD_BITS > 0) | 168 | 1.62M | DVAL_NEXT(dv,ip); | 169 | 1.62M | #endif | 170 | 1.62M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 63.2k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 63.2k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 63.2k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 63.2k | #endif | 188 | | | 189 | 63.2k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 63.2k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 63.2k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 63.2k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 63.2k | #endif | 203 | | | 204 | 63.2k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 63.0k | assert(ii == ip); | 209 | | | 210 | 63.0k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 332 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 332 | if (pd(in_end,ii) > 0) | 249 | 296 | { | 250 | 296 | lzo_uint t = pd(in_end,ii); | 251 | 296 | op = STORE_RUN(op,ii,t); | 252 | 296 | } | 253 | | | 254 | 332 | *out_len = pd(op, out); | 255 | 332 | return LZO_E_OK; /* compression went ok */ | 256 | 332 | } |
Line | Count | Source | 69 | 363 | { | 70 | 363 | const lzo_bytep ip; | 71 | | #if (DD_BITS > 0) | 72 | | #if defined(__LZO_HASH_INCREMENTAL) | 73 | | lzo_xint dv; | 74 | | #endif | 75 | | unsigned drun = 0; | 76 | | #endif | 77 | 363 | lzo_bytep op; | 78 | 363 | const lzo_bytep const in_end = in + in_len; | 79 | 363 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 363 | const lzo_bytep ii; | 81 | 363 | #if defined(LZO_HAVE_R1) | 82 | 363 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 363 | #endif | 84 | 363 | #if defined(LZO_HAVE_M3) | 85 | 363 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 363 | #endif | 87 | | | 88 | 363 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | | #if (LZO_DETERMINISTIC) | 104 | | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | | #endif | 106 | | | 107 | | | 108 | 363 | op = out; | 109 | 363 | ip = in; | 110 | 363 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | | #if (DD_BITS > 0) | 114 | | DVAL_FIRST(dv,ip); | 115 | | UPDATE_D(dict,drun,dv,ip,in); | 116 | | ip++; | 117 | | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | 363 | ip++; | 120 | 363 | #endif | 121 | | | 122 | 363 | assert(ip < ip_end); | 123 | 363 | for (;;) | 124 | 5.28M | { | 125 | 5.28M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 5.28M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 5.28M | #if (DD_BITS == 0) | 131 | 5.28M | lzo_uint dindex; | 132 | 5.28M | #endif | 133 | 5.28M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 5.28M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 5.28M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 5.28M | #endif | 143 | | | 144 | 5.28M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 179k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 179k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 179k | #endif | 150 | | | 151 | 179k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 5.16M | literal: | 162 | 5.16M | #if (DD_BITS == 0) | 163 | 5.16M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 5.16M | #endif | 165 | 5.16M | if (++ip >= ip_end) | 166 | 112 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 5.16M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 5.16M | match: | 179 | 118k | #if (DD_BITS == 0) | 180 | 118k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 118k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 118k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 118k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 118k | #endif | 188 | | | 189 | 118k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 118k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 118k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 118k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 118k | #endif | 203 | | | 204 | 118k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 118k | assert(ii == ip); | 209 | | | 210 | 118k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 363 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 363 | if (pd(in_end,ii) > 0) | 249 | 307 | { | 250 | 307 | lzo_uint t = pd(in_end,ii); | 251 | 307 | op = STORE_RUN(op,ii,t); | 252 | 307 | } | 253 | | | 254 | 363 | *out_len = pd(op, out); | 255 | 363 | return LZO_E_OK; /* compression went ok */ | 256 | 363 | } |
Line | Count | Source | 69 | 312 | { | 70 | 312 | const lzo_bytep ip; | 71 | 312 | #if (DD_BITS > 0) | 72 | 312 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 312 | lzo_xint dv; | 74 | 312 | #endif | 75 | 312 | unsigned drun = 0; | 76 | 312 | #endif | 77 | 312 | lzo_bytep op; | 78 | 312 | const lzo_bytep const in_end = in + in_len; | 79 | 312 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 312 | const lzo_bytep ii; | 81 | 312 | #if defined(LZO_HAVE_R1) | 82 | 312 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 312 | #endif | 84 | 312 | #if defined(LZO_HAVE_M3) | 85 | 312 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 312 | #endif | 87 | | | 88 | 312 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | | #if (LZO_DETERMINISTIC) | 104 | | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | | #endif | 106 | | | 107 | | | 108 | 312 | op = out; | 109 | 312 | ip = in; | 110 | 312 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 312 | #if (DD_BITS > 0) | 114 | 312 | DVAL_FIRST(dv,ip); | 115 | 312 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 312 | ip++; | 117 | 312 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 312 | assert(ip < ip_end); | 123 | 312 | for (;;) | 124 | 706k | { | 125 | 706k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 706k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 706k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 706k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 706k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 706k | #endif | 143 | | | 144 | 706k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 691k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 637k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 637k | if (++ip >= ip_end) | 166 | 63 | break; | 167 | 637k | #if (DD_BITS > 0) | 168 | 637k | DVAL_NEXT(dv,ip); | 169 | 637k | #endif | 170 | 637k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 69.8k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 69.8k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 69.8k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 69.8k | #endif | 188 | | | 189 | 69.8k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 69.8k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 69.8k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 69.8k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 69.8k | #endif | 203 | | | 204 | 69.8k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 69.5k | assert(ii == ip); | 209 | | | 210 | 69.5k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 312 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 312 | if (pd(in_end,ii) > 0) | 249 | 279 | { | 250 | 279 | lzo_uint t = pd(in_end,ii); | 251 | 279 | op = STORE_RUN(op,ii,t); | 252 | 279 | } | 253 | | | 254 | 312 | *out_len = pd(op, out); | 255 | 312 | return LZO_E_OK; /* compression went ok */ | 256 | 312 | } |
Line | Count | Source | 69 | 340 | { | 70 | 340 | const lzo_bytep ip; | 71 | 340 | #if (DD_BITS > 0) | 72 | 340 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 340 | lzo_xint dv; | 74 | 340 | #endif | 75 | 340 | unsigned drun = 0; | 76 | 340 | #endif | 77 | 340 | lzo_bytep op; | 78 | 340 | const lzo_bytep const in_end = in + in_len; | 79 | 340 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 340 | const lzo_bytep ii; | 81 | 340 | #if defined(LZO_HAVE_R1) | 82 | 340 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 340 | #endif | 84 | 340 | #if defined(LZO_HAVE_M3) | 85 | 340 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 340 | #endif | 87 | | | 88 | 340 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | | #if (LZO_DETERMINISTIC) | 104 | | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | | #endif | 106 | | | 107 | | | 108 | 340 | op = out; | 109 | 340 | ip = in; | 110 | 340 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 340 | #if (DD_BITS > 0) | 114 | 340 | DVAL_FIRST(dv,ip); | 115 | 340 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 340 | ip++; | 117 | 340 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 340 | assert(ip < ip_end); | 123 | 340 | for (;;) | 124 | 961k | { | 125 | 961k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 961k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 961k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 961k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 961k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 961k | #endif | 143 | | | 144 | 961k | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 961k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 961k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 961k | #endif | 150 | | | 151 | 961k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 918k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 918k | if (++ip >= ip_end) | 166 | 77 | break; | 167 | 918k | #if (DD_BITS > 0) | 168 | 918k | DVAL_NEXT(dv,ip); | 169 | 918k | #endif | 170 | 918k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 43.5k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 43.5k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 43.5k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 43.5k | #endif | 188 | | | 189 | 43.5k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 43.5k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 43.5k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 43.5k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 43.5k | #endif | 203 | | | 204 | 43.5k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 43.3k | assert(ii == ip); | 209 | | | 210 | 43.3k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 340 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 340 | if (pd(in_end,ii) > 0) | 249 | 304 | { | 250 | 304 | lzo_uint t = pd(in_end,ii); | 251 | 304 | op = STORE_RUN(op,ii,t); | 252 | 304 | } | 253 | | | 254 | 340 | *out_len = pd(op, out); | 255 | 340 | return LZO_E_OK; /* compression went ok */ | 256 | 340 | } |
Line | Count | Source | 69 | 367 | { | 70 | 367 | const lzo_bytep ip; | 71 | 367 | #if (DD_BITS > 0) | 72 | 367 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 367 | lzo_xint dv; | 74 | 367 | #endif | 75 | 367 | unsigned drun = 0; | 76 | 367 | #endif | 77 | 367 | lzo_bytep op; | 78 | 367 | const lzo_bytep const in_end = in + in_len; | 79 | 367 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 367 | const lzo_bytep ii; | 81 | 367 | #if defined(LZO_HAVE_R1) | 82 | 367 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 367 | #endif | 84 | 367 | #if defined(LZO_HAVE_M3) | 85 | 367 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 367 | #endif | 87 | | | 88 | 367 | lzo_dict_p const dict = (lzo_dict_p) wrkmem; | 89 | | | 90 | | | 91 | | #if (LZO_COLLECT_STATS) | 92 | | lzo_stats->r_bits = R_BITS; | 93 | | lzo_stats->m3o_bits = M3O_BITS; | 94 | | lzo_stats->dd_bits = DD_BITS; | 95 | | lzo_stats->clevel = CLEVEL; | 96 | | lzo_stats->d_bits = D_BITS; | 97 | | lzo_stats->min_lookahead = MIN_LOOKAHEAD; | 98 | | lzo_stats->max_lookbehind = MAX_LOOKBEHIND; | 99 | | lzo_stats->compress_id = LZO_PP_MACRO_EXPAND(COMPRESS_ID); | 100 | | #endif | 101 | | | 102 | | /* init dictionary */ | 103 | | #if (LZO_DETERMINISTIC) | 104 | | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | | #endif | 106 | | | 107 | | | 108 | 367 | op = out; | 109 | 367 | ip = in; | 110 | 367 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 367 | #if (DD_BITS > 0) | 114 | 367 | DVAL_FIRST(dv,ip); | 115 | 367 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 367 | ip++; | 117 | 367 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 367 | assert(ip < ip_end); | 123 | 367 | for (;;) | 124 | 1.41M | { | 125 | 1.41M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.41M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.41M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.41M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.41M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.41M | #endif | 143 | | | 144 | 1.41M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 0 | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 0 | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 0 | #endif | 150 | | | 151 | 1.41M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.34M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.34M | if (++ip >= ip_end) | 166 | 79 | break; | 167 | 1.34M | #if (DD_BITS > 0) | 168 | 1.34M | DVAL_NEXT(dv,ip); | 169 | 1.34M | #endif | 170 | 1.34M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 69.2k | match: | 179 | | #if (DD_BITS == 0) | 180 | | UPDATE_I(dict,0,dindex,ip,in); | 181 | | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 69.2k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 69.2k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 69.2k | #endif | 188 | | | 189 | 69.2k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 69.2k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 69.2k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 69.2k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 69.2k | #endif | 203 | | | 204 | 69.2k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 69.0k | assert(ii == ip); | 209 | | | 210 | 69.0k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 367 | assert(ip <= in_end); | 218 | | | 219 | | #if (LZO_COLLECT_STATS) | 220 | | { | 221 | | lzo_uint i; | 222 | | const lzo_bytep p; | 223 | | | 224 | | for (i = 0; i < D_SIZE; i++) | 225 | | { | 226 | | p = dict[i]; | 227 | | if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) | 228 | | lzo_stats->unused_dict_entries++; | 229 | | } | 230 | | lzo_stats->unused_dict_entries_percent = | 231 | | 100.0 * lzo_stats->unused_dict_entries / D_SIZE; | 232 | | } | 233 | | #endif | 234 | | | 235 | | | 236 | | #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) | 237 | | /* return if op == out to indicate that we | 238 | | * couldn't compress and didn't copy anything. | 239 | | */ | 240 | | if (op == out) | 241 | | { | 242 | | *out_len = 0; | 243 | | return LZO_E_NOT_COMPRESSIBLE; | 244 | | } | 245 | | #endif | 246 | | | 247 | | /* store the final literal run */ | 248 | 367 | if (pd(in_end,ii) > 0) | 249 | 319 | { | 250 | 319 | lzo_uint t = pd(in_end,ii); | 251 | 319 | op = STORE_RUN(op,ii,t); | 252 | 319 | } | 253 | | | 254 | 367 | *out_len = pd(op, out); | 255 | 367 | return LZO_E_OK; /* compression went ok */ | 256 | 367 | } |
|