256 | 5.73k | } Line | Count | Source | 69 | 355 | { | 70 | 355 | const lzo_bytep ip; | 71 | 355 | #if (DD_BITS > 0) | 72 | 355 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 355 | lzo_xint dv; | 74 | 355 | #endif | 75 | 355 | unsigned drun = 0; | 76 | 355 | #endif | 77 | 355 | lzo_bytep op; | 78 | 355 | const lzo_bytep const in_end = in + in_len; | 79 | 355 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 355 | 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 | 355 | 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 | 355 | #if (LZO_DETERMINISTIC) | 104 | 355 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 355 | #endif | 106 | | | 107 | | | 108 | 355 | op = out; | 109 | 355 | ip = in; | 110 | 355 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 355 | #if (DD_BITS > 0) | 114 | 355 | DVAL_FIRST(dv,ip); | 115 | 355 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 355 | ip++; | 117 | 355 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 355 | assert(ip < ip_end); | 123 | 355 | for (;;) | 124 | 8.16M | { | 125 | 8.16M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 8.16M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 8.16M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 8.16M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 8.16M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 8.16M | #endif | 143 | | | 144 | 8.16M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 8.16M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 8.16M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 8.16M | #endif | 150 | | | 151 | 8.16M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 8.09M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 8.09M | if (++ip >= ip_end) | 166 | 97 | break; | 167 | 8.09M | #if (DD_BITS > 0) | 168 | 8.09M | DVAL_NEXT(dv,ip); | 169 | 8.09M | #endif | 170 | 8.09M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 70.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 | 70.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 70.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 70.0k | #endif | 188 | | | 189 | 70.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 70.0k | 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 | 70.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 69.7k | assert(ii == ip); | 209 | | | 210 | 69.7k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 355 | 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 | 355 | if (pd(in_end,ii) > 0) | 249 | 290 | { | 250 | 290 | lzo_uint t = pd(in_end,ii); | 251 | 290 | op = STORE_RUN(op,ii,t); | 252 | 290 | } | 253 | | | 254 | 355 | *out_len = pd(op, out); | 255 | 355 | return LZO_E_OK; /* compression went ok */ | 256 | 355 | } |
Line | Count | Source | 69 | 360 | { | 70 | 360 | const lzo_bytep ip; | 71 | 360 | #if (DD_BITS > 0) | 72 | 360 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 360 | lzo_xint dv; | 74 | 360 | #endif | 75 | 360 | unsigned drun = 0; | 76 | 360 | #endif | 77 | 360 | lzo_bytep op; | 78 | 360 | const lzo_bytep const in_end = in + in_len; | 79 | 360 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 360 | const lzo_bytep ii; | 81 | 360 | #if defined(LZO_HAVE_R1) | 82 | 360 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 360 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 360 | 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 | 360 | #if (LZO_DETERMINISTIC) | 104 | 360 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 360 | #endif | 106 | | | 107 | | | 108 | 360 | op = out; | 109 | 360 | ip = in; | 110 | 360 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 360 | #if (DD_BITS > 0) | 114 | 360 | DVAL_FIRST(dv,ip); | 115 | 360 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 360 | ip++; | 117 | 360 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 360 | assert(ip < ip_end); | 123 | 360 | for (;;) | 124 | 10.2M | { | 125 | 10.2M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 10.2M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 10.2M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 10.2M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 10.2M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 10.2M | #endif | 143 | | | 144 | 10.2M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 10.2M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 10.2M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 10.2M | #endif | 150 | | | 151 | 10.2M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 10.1M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 10.1M | if (++ip >= ip_end) | 166 | 107 | break; | 167 | 10.1M | #if (DD_BITS > 0) | 168 | 10.1M | DVAL_NEXT(dv,ip); | 169 | 10.1M | #endif | 170 | 10.1M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 104k | 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 | 104k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 104k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 104k | #endif | 188 | | | 189 | 104k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 104k | 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 | 104k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 104k | assert(ii == ip); | 209 | | | 210 | 104k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 360 | 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 | 360 | if (pd(in_end,ii) > 0) | 249 | 300 | { | 250 | 300 | lzo_uint t = pd(in_end,ii); | 251 | 300 | op = STORE_RUN(op,ii,t); | 252 | 300 | } | 253 | | | 254 | 360 | *out_len = pd(op, out); | 255 | 360 | return LZO_E_OK; /* compression went ok */ | 256 | 360 | } |
Line | Count | Source | 69 | 352 | { | 70 | 352 | 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 | 352 | lzo_bytep op; | 78 | 352 | const lzo_bytep const in_end = in + in_len; | 79 | 352 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 352 | const lzo_bytep ii; | 81 | 352 | #if defined(LZO_HAVE_R1) | 82 | 352 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 352 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 352 | 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 | 352 | #if (LZO_DETERMINISTIC) | 104 | 352 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 352 | #endif | 106 | | | 107 | | | 108 | 352 | op = out; | 109 | 352 | ip = in; | 110 | 352 | 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 | 352 | ip++; | 120 | 352 | #endif | 121 | | | 122 | 352 | assert(ip < ip_end); | 123 | 352 | for (;;) | 124 | 2.43M | { | 125 | 2.43M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 2.43M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 2.43M | #if (DD_BITS == 0) | 131 | 2.43M | lzo_uint dindex; | 132 | 2.43M | #endif | 133 | 2.43M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 2.43M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 2.43M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 2.43M | #endif | 143 | | | 144 | 2.43M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 113k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 113k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 113k | #endif | 150 | | | 151 | 113k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 2.27M | literal: | 162 | 2.27M | #if (DD_BITS == 0) | 163 | 2.27M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 2.27M | #endif | 165 | 2.27M | if (++ip >= ip_end) | 166 | 141 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 2.27M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 2.27M | match: | 179 | 158k | #if (DD_BITS == 0) | 180 | 158k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 158k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 158k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 158k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 158k | #endif | 188 | | | 189 | 158k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 158k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 158k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 158k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 158k | #endif | 203 | | | 204 | 158k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 158k | assert(ii == ip); | 209 | | | 210 | 158k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 352 | 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 | 352 | if (pd(in_end,ii) > 0) | 249 | 327 | { | 250 | 327 | lzo_uint t = pd(in_end,ii); | 251 | 327 | op = STORE_RUN(op,ii,t); | 252 | 327 | } | 253 | | | 254 | 352 | *out_len = pd(op, out); | 255 | 352 | return LZO_E_OK; /* compression went ok */ | 256 | 352 | } |
Line | Count | Source | 69 | 319 | { | 70 | 319 | 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 | 319 | lzo_bytep op; | 78 | 319 | const lzo_bytep const in_end = in + in_len; | 79 | 319 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 319 | const lzo_bytep ii; | 81 | 319 | #if defined(LZO_HAVE_R1) | 82 | 319 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 319 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 319 | 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 | 319 | #if (LZO_DETERMINISTIC) | 104 | 319 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 319 | #endif | 106 | | | 107 | | | 108 | 319 | op = out; | 109 | 319 | ip = in; | 110 | 319 | 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 | 319 | ip++; | 120 | 319 | #endif | 121 | | | 122 | 319 | assert(ip < ip_end); | 123 | 319 | for (;;) | 124 | 2.73M | { | 125 | 2.73M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 2.73M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 2.73M | #if (DD_BITS == 0) | 131 | 2.73M | lzo_uint dindex; | 132 | 2.73M | #endif | 133 | 2.73M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 2.73M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 2.73M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 2.73M | #endif | 143 | | | 144 | 2.73M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 125k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 125k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 125k | #endif | 150 | | | 151 | 125k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 2.64M | literal: | 162 | 2.64M | #if (DD_BITS == 0) | 163 | 2.64M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 2.64M | #endif | 165 | 2.64M | if (++ip >= ip_end) | 166 | 125 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 2.64M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 2.64M | match: | 179 | 84.4k | #if (DD_BITS == 0) | 180 | 84.4k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 84.4k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 84.4k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 84.4k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 84.4k | #endif | 188 | | | 189 | 84.4k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 84.4k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 84.4k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 84.4k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 84.4k | #endif | 203 | | | 204 | 84.4k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 84.2k | assert(ii == ip); | 209 | | | 210 | 84.2k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 319 | 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 | 319 | if (pd(in_end,ii) > 0) | 249 | 295 | { | 250 | 295 | lzo_uint t = pd(in_end,ii); | 251 | 295 | op = STORE_RUN(op,ii,t); | 252 | 295 | } | 253 | | | 254 | 319 | *out_len = pd(op, out); | 255 | 319 | return LZO_E_OK; /* compression went ok */ | 256 | 319 | } |
Line | Count | Source | 69 | 323 | { | 70 | 323 | 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 | 323 | lzo_bytep op; | 78 | 323 | const lzo_bytep const in_end = in + in_len; | 79 | 323 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 323 | const lzo_bytep ii; | 81 | 323 | #if defined(LZO_HAVE_R1) | 82 | 323 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 323 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 323 | 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 | 323 | #if (LZO_DETERMINISTIC) | 104 | 323 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 323 | #endif | 106 | | | 107 | | | 108 | 323 | op = out; | 109 | 323 | ip = in; | 110 | 323 | 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 | 323 | ip++; | 120 | 323 | #endif | 121 | | | 122 | 323 | assert(ip < ip_end); | 123 | 323 | for (;;) | 124 | 1.10M | { | 125 | 1.10M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.10M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 1.10M | #if (DD_BITS == 0) | 131 | 1.10M | lzo_uint dindex; | 132 | 1.10M | #endif | 133 | 1.10M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.10M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.10M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.10M | #endif | 143 | | | 144 | 1.10M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 44.6k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 44.6k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 44.6k | #endif | 150 | | | 151 | 44.6k | #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 | 1.01M | #if (DD_BITS == 0) | 163 | 1.01M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 1.01M | #endif | 165 | 1.01M | if (++ip >= ip_end) | 166 | 118 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 1.01M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 1.01M | match: | 179 | 86.5k | #if (DD_BITS == 0) | 180 | 86.5k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 86.5k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 86.5k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 86.5k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 86.5k | #endif | 188 | | | 189 | 86.5k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 86.5k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 86.5k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 86.5k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 86.5k | #endif | 203 | | | 204 | 86.5k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 86.3k | assert(ii == ip); | 209 | | | 210 | 86.3k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 323 | 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 | 323 | if (pd(in_end,ii) > 0) | 249 | 302 | { | 250 | 302 | lzo_uint t = pd(in_end,ii); | 251 | 302 | op = STORE_RUN(op,ii,t); | 252 | 302 | } | 253 | | | 254 | 323 | *out_len = pd(op, out); | 255 | 323 | return LZO_E_OK; /* compression went ok */ | 256 | 323 | } |
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.49M | { | 125 | 1.49M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.49M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.49M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.49M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.49M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.49M | #endif | 143 | | | 144 | 1.49M | #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.48M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.36M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.36M | if (++ip >= ip_end) | 166 | 82 | break; | 167 | 1.36M | #if (DD_BITS > 0) | 168 | 1.36M | DVAL_NEXT(dv,ip); | 169 | 1.36M | #endif | 170 | 1.36M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 128k | 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 | 128k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 128k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 128k | #endif | 188 | | | 189 | 128k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 128k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 128k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 128k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 128k | #endif | 203 | | | 204 | 128k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 127k | assert(ii == ip); | 209 | | | 210 | 127k | } | 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 | 303 | { | 250 | 303 | lzo_uint t = pd(in_end,ii); | 251 | 303 | op = STORE_RUN(op,ii,t); | 252 | 303 | } | 253 | | | 254 | 327 | *out_len = pd(op, out); | 255 | 327 | return LZO_E_OK; /* compression went ok */ | 256 | 327 | } |
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 | 944k | { | 125 | 944k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 944k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 944k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 944k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 944k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 944k | #endif | 143 | | | 144 | 944k | #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 | 934k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 907k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 907k | if (++ip >= ip_end) | 166 | 70 | break; | 167 | 907k | #if (DD_BITS > 0) | 168 | 907k | DVAL_NEXT(dv,ip); | 169 | 907k | #endif | 170 | 907k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 37.3k | 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 | 37.3k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 37.3k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 37.3k | #endif | 188 | | | 189 | 37.3k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 37.3k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 37.3k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 37.3k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 37.3k | #endif | 203 | | | 204 | 37.3k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 37.0k | assert(ii == ip); | 209 | | | 210 | 37.0k | } | 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 | 283 | { | 250 | 283 | lzo_uint t = pd(in_end,ii); | 251 | 283 | op = STORE_RUN(op,ii,t); | 252 | 283 | } | 253 | | | 254 | 303 | *out_len = pd(op, out); | 255 | 303 | return LZO_E_OK; /* compression went ok */ | 256 | 303 | } |
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 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #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 | 340 | #if (LZO_DETERMINISTIC) | 104 | 340 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 340 | #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 | 1.46M | { | 125 | 1.46M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.46M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.46M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.46M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.46M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.46M | #endif | 143 | | | 144 | 1.46M | #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.44M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.28M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.28M | if (++ip >= ip_end) | 166 | 72 | break; | 167 | 1.28M | #if (DD_BITS > 0) | 168 | 1.28M | DVAL_NEXT(dv,ip); | 169 | 1.28M | #endif | 170 | 1.28M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 184k | 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 | 184k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 184k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 184k | #endif | 188 | | | 189 | 184k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 184k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 184k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 184k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 184k | #endif | 203 | | | 204 | 184k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 184k | assert(ii == ip); | 209 | | | 210 | 184k | } | 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 | 308 | { | 250 | 308 | lzo_uint t = pd(in_end,ii); | 251 | 308 | op = STORE_RUN(op,ii,t); | 252 | 308 | } | 253 | | | 254 | 340 | *out_len = pd(op, out); | 255 | 340 | return LZO_E_OK; /* compression went ok */ | 256 | 340 | } |
Line | Count | Source | 69 | 329 | { | 70 | 329 | const lzo_bytep ip; | 71 | 329 | #if (DD_BITS > 0) | 72 | 329 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 329 | lzo_xint dv; | 74 | 329 | #endif | 75 | 329 | unsigned drun = 0; | 76 | 329 | #endif | 77 | 329 | lzo_bytep op; | 78 | 329 | const lzo_bytep const in_end = in + in_len; | 79 | 329 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 329 | const lzo_bytep ii; | 81 | 329 | #if defined(LZO_HAVE_R1) | 82 | 329 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 329 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 329 | 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 | 329 | #if (LZO_DETERMINISTIC) | 104 | 329 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 329 | #endif | 106 | | | 107 | | | 108 | 329 | op = out; | 109 | 329 | ip = in; | 110 | 329 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 329 | #if (DD_BITS > 0) | 114 | 329 | DVAL_FIRST(dv,ip); | 115 | 329 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 329 | ip++; | 117 | 329 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 329 | assert(ip < ip_end); | 123 | 329 | for (;;) | 124 | 609k | { | 125 | 609k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 609k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 609k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 609k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 609k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 609k | #endif | 143 | | | 144 | 609k | #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 | 599k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 560k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 560k | if (++ip >= ip_end) | 166 | 81 | break; | 167 | 560k | #if (DD_BITS > 0) | 168 | 560k | DVAL_NEXT(dv,ip); | 169 | 560k | #endif | 170 | 560k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 48.9k | 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 | 48.9k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 48.9k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 48.9k | #endif | 188 | | | 189 | 48.9k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 48.9k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 48.9k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 48.9k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 48.9k | #endif | 203 | | | 204 | 48.9k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 48.6k | assert(ii == ip); | 209 | | | 210 | 48.6k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 329 | 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 | 329 | if (pd(in_end,ii) > 0) | 249 | 305 | { | 250 | 305 | lzo_uint t = pd(in_end,ii); | 251 | 305 | op = STORE_RUN(op,ii,t); | 252 | 305 | } | 253 | | | 254 | 329 | *out_len = pd(op, out); | 255 | 329 | return LZO_E_OK; /* compression went ok */ | 256 | 329 | } |
Line | Count | Source | 69 | 357 | { | 70 | 357 | const lzo_bytep ip; | 71 | 357 | #if (DD_BITS > 0) | 72 | 357 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 357 | lzo_xint dv; | 74 | 357 | #endif | 75 | 357 | unsigned drun = 0; | 76 | 357 | #endif | 77 | 357 | lzo_bytep op; | 78 | 357 | const lzo_bytep const in_end = in + in_len; | 79 | 357 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 357 | const lzo_bytep ii; | 81 | 357 | #if defined(LZO_HAVE_R1) | 82 | 357 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 357 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 357 | 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 | 357 | #if (LZO_DETERMINISTIC) | 104 | 357 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 357 | #endif | 106 | | | 107 | | | 108 | 357 | op = out; | 109 | 357 | ip = in; | 110 | 357 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 357 | #if (DD_BITS > 0) | 114 | 357 | DVAL_FIRST(dv,ip); | 115 | 357 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 357 | ip++; | 117 | 357 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 357 | assert(ip < ip_end); | 123 | 357 | for (;;) | 124 | 857k | { | 125 | 857k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 857k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 857k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 857k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 857k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 857k | #endif | 143 | | | 144 | 857k | #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 | 847k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 816k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 816k | if (++ip >= ip_end) | 166 | 85 | break; | 167 | 816k | #if (DD_BITS > 0) | 168 | 816k | DVAL_NEXT(dv,ip); | 169 | 816k | #endif | 170 | 816k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 41.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 | 41.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 41.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 41.0k | #endif | 188 | | | 189 | 41.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 41.0k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 41.0k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 41.0k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 41.0k | #endif | 203 | | | 204 | 41.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 40.7k | assert(ii == ip); | 209 | | | 210 | 40.7k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 357 | 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 | 357 | if (pd(in_end,ii) > 0) | 249 | 322 | { | 250 | 322 | lzo_uint t = pd(in_end,ii); | 251 | 322 | op = STORE_RUN(op,ii,t); | 252 | 322 | } | 253 | | | 254 | 357 | *out_len = pd(op, out); | 255 | 357 | return LZO_E_OK; /* compression went ok */ | 256 | 357 | } |
Line | Count | Source | 69 | 370 | { | 70 | 370 | const lzo_bytep ip; | 71 | 370 | #if (DD_BITS > 0) | 72 | 370 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 370 | lzo_xint dv; | 74 | 370 | #endif | 75 | 370 | unsigned drun = 0; | 76 | 370 | #endif | 77 | 370 | lzo_bytep op; | 78 | 370 | const lzo_bytep const in_end = in + in_len; | 79 | 370 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 370 | const lzo_bytep ii; | 81 | 370 | #if defined(LZO_HAVE_R1) | 82 | 370 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 370 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 370 | 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 | 370 | #if (LZO_DETERMINISTIC) | 104 | 370 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 370 | #endif | 106 | | | 107 | | | 108 | 370 | op = out; | 109 | 370 | ip = in; | 110 | 370 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 370 | #if (DD_BITS > 0) | 114 | 370 | DVAL_FIRST(dv,ip); | 115 | 370 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 370 | ip++; | 117 | 370 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 370 | assert(ip < ip_end); | 123 | 370 | for (;;) | 124 | 1.07M | { | 125 | 1.07M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.07M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.07M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.07M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.07M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.07M | #endif | 143 | | | 144 | 1.07M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 1.07M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 1.07M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 1.07M | #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.02M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.02M | if (++ip >= ip_end) | 166 | 86 | break; | 167 | 1.02M | #if (DD_BITS > 0) | 168 | 1.02M | DVAL_NEXT(dv,ip); | 169 | 1.02M | #endif | 170 | 1.02M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 49.4k | 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 | 49.4k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 49.4k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 49.4k | #endif | 188 | | | 189 | 49.4k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 49.4k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 49.4k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 49.4k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 49.4k | #endif | 203 | | | 204 | 49.4k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 49.2k | assert(ii == ip); | 209 | | | 210 | 49.2k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 370 | 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 | 370 | 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 | 370 | *out_len = pd(op, out); | 255 | 370 | return LZO_E_OK; /* compression went ok */ | 256 | 370 | } |
Line | Count | Source | 69 | 379 | { | 70 | 379 | const lzo_bytep ip; | 71 | 379 | #if (DD_BITS > 0) | 72 | 379 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 379 | lzo_xint dv; | 74 | 379 | #endif | 75 | 379 | unsigned drun = 0; | 76 | 379 | #endif | 77 | 379 | lzo_bytep op; | 78 | 379 | const lzo_bytep const in_end = in + in_len; | 79 | 379 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 379 | const lzo_bytep ii; | 81 | 379 | #if defined(LZO_HAVE_R1) | 82 | 379 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 379 | #endif | 84 | | #if defined(LZO_HAVE_M3) | 85 | | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | | #endif | 87 | | | 88 | 379 | 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 | 379 | #if (LZO_DETERMINISTIC) | 104 | 379 | BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); | 105 | 379 | #endif | 106 | | | 107 | | | 108 | 379 | op = out; | 109 | 379 | ip = in; | 110 | 379 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 379 | #if (DD_BITS > 0) | 114 | 379 | DVAL_FIRST(dv,ip); | 115 | 379 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 379 | ip++; | 117 | 379 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 379 | assert(ip < ip_end); | 123 | 379 | for (;;) | 124 | 912k | { | 125 | 912k | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 912k | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 912k | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 912k | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 912k | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 912k | #endif | 143 | | | 144 | 912k | #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 | 912k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 841k | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 841k | if (++ip >= ip_end) | 166 | 85 | break; | 167 | 841k | #if (DD_BITS > 0) | 168 | 841k | DVAL_NEXT(dv,ip); | 169 | 841k | #endif | 170 | 841k | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 71.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 | 71.2k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 71.2k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 71.2k | #endif | 188 | | | 189 | 71.2k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 71.2k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 71.2k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 71.2k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 71.2k | #endif | 203 | | | 204 | 71.2k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 70.9k | assert(ii == ip); | 209 | | | 210 | 70.9k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 379 | 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 | 379 | if (pd(in_end,ii) > 0) | 249 | 338 | { | 250 | 338 | lzo_uint t = pd(in_end,ii); | 251 | 338 | op = STORE_RUN(op,ii,t); | 252 | 338 | } | 253 | | | 254 | 379 | *out_len = pd(op, out); | 255 | 379 | return LZO_E_OK; /* compression went ok */ | 256 | 379 | } |
Line | Count | Source | 69 | 445 | { | 70 | 445 | 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 | 445 | lzo_bytep op; | 78 | 445 | const lzo_bytep const in_end = in + in_len; | 79 | 445 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 445 | const lzo_bytep ii; | 81 | 445 | #if defined(LZO_HAVE_R1) | 82 | 445 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 445 | #endif | 84 | 445 | #if defined(LZO_HAVE_M3) | 85 | 445 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 445 | #endif | 87 | | | 88 | 445 | 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 | 445 | op = out; | 109 | 445 | ip = in; | 110 | 445 | 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 | 445 | ip++; | 120 | 445 | #endif | 121 | | | 122 | 445 | assert(ip < ip_end); | 123 | 445 | for (;;) | 124 | 4.15M | { | 125 | 4.15M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 4.15M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | 4.15M | #if (DD_BITS == 0) | 131 | 4.15M | lzo_uint dindex; | 132 | 4.15M | #endif | 133 | 4.15M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 4.15M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 4.15M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 4.15M | #endif | 143 | | | 144 | 4.15M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 135k | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 135k | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 135k | #endif | 150 | | | 151 | 135k | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 4.07M | literal: | 162 | 4.07M | #if (DD_BITS == 0) | 163 | 4.07M | UPDATE_I(dict,0,dindex,ip,in); | 164 | 4.07M | #endif | 165 | 4.07M | if (++ip >= ip_end) | 166 | 177 | break; | 167 | | #if (DD_BITS > 0) | 168 | | DVAL_NEXT(dv,ip); | 169 | | #endif | 170 | 4.07M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 4.07M | match: | 179 | 79.2k | #if (DD_BITS == 0) | 180 | 79.2k | UPDATE_I(dict,0,dindex,ip,in); | 181 | 79.2k | #endif | 182 | | /* we have found a match of at least M2_MIN_LEN */ | 183 | | | 184 | | | 185 | 79.2k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 79.2k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 79.2k | #endif | 188 | | | 189 | 79.2k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 79.2k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 79.2k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 79.2k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 79.2k | #endif | 203 | | | 204 | 79.2k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 79.0k | assert(ii == ip); | 209 | | | 210 | 79.0k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 445 | 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 | 445 | if (pd(in_end,ii) > 0) | 249 | 395 | { | 250 | 395 | lzo_uint t = pd(in_end,ii); | 251 | 395 | op = STORE_RUN(op,ii,t); | 252 | 395 | } | 253 | | | 254 | 445 | *out_len = pd(op, out); | 255 | 445 | return LZO_E_OK; /* compression went ok */ | 256 | 445 | } |
Line | Count | Source | 69 | 350 | { | 70 | 350 | const lzo_bytep ip; | 71 | 350 | #if (DD_BITS > 0) | 72 | 350 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 350 | lzo_xint dv; | 74 | 350 | #endif | 75 | 350 | unsigned drun = 0; | 76 | 350 | #endif | 77 | 350 | lzo_bytep op; | 78 | 350 | const lzo_bytep const in_end = in + in_len; | 79 | 350 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 350 | const lzo_bytep ii; | 81 | 350 | #if defined(LZO_HAVE_R1) | 82 | 350 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 350 | #endif | 84 | 350 | #if defined(LZO_HAVE_M3) | 85 | 350 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 350 | #endif | 87 | | | 88 | 350 | 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 | 350 | op = out; | 109 | 350 | ip = in; | 110 | 350 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 350 | #if (DD_BITS > 0) | 114 | 350 | DVAL_FIRST(dv,ip); | 115 | 350 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 350 | ip++; | 117 | 350 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 350 | assert(ip < ip_end); | 123 | 350 | for (;;) | 124 | 3.59M | { | 125 | 3.59M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 3.59M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 3.59M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 3.59M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 3.59M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 3.59M | #endif | 143 | | | 144 | 3.59M | #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 | 3.58M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 3.53M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 3.53M | if (++ip >= ip_end) | 166 | 83 | break; | 167 | 3.53M | #if (DD_BITS > 0) | 168 | 3.53M | DVAL_NEXT(dv,ip); | 169 | 3.53M | #endif | 170 | 3.53M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 59.6k | 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 | 59.6k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 59.6k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 59.6k | #endif | 188 | | | 189 | 59.6k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 59.6k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 59.6k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 59.6k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 59.6k | #endif | 203 | | | 204 | 59.6k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 59.3k | assert(ii == ip); | 209 | | | 210 | 59.3k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 350 | 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 | 350 | if (pd(in_end,ii) > 0) | 249 | 323 | { | 250 | 323 | lzo_uint t = pd(in_end,ii); | 251 | 323 | op = STORE_RUN(op,ii,t); | 252 | 323 | } | 253 | | | 254 | 350 | *out_len = pd(op, out); | 255 | 350 | return LZO_E_OK; /* compression went ok */ | 256 | 350 | } |
Line | Count | Source | 69 | 383 | { | 70 | 383 | const lzo_bytep ip; | 71 | 383 | #if (DD_BITS > 0) | 72 | 383 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 383 | lzo_xint dv; | 74 | 383 | #endif | 75 | 383 | unsigned drun = 0; | 76 | 383 | #endif | 77 | 383 | lzo_bytep op; | 78 | 383 | const lzo_bytep const in_end = in + in_len; | 79 | 383 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 383 | const lzo_bytep ii; | 81 | 383 | #if defined(LZO_HAVE_R1) | 82 | 383 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 383 | #endif | 84 | 383 | #if defined(LZO_HAVE_M3) | 85 | 383 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 383 | #endif | 87 | | | 88 | 383 | 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 | 383 | op = out; | 109 | 383 | ip = in; | 110 | 383 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 383 | #if (DD_BITS > 0) | 114 | 383 | DVAL_FIRST(dv,ip); | 115 | 383 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 383 | ip++; | 117 | 383 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 383 | assert(ip < ip_end); | 123 | 383 | for (;;) | 124 | 1.26M | { | 125 | 1.26M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 1.26M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 1.26M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 1.26M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 1.26M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 1.26M | #endif | 143 | | | 144 | 1.26M | #include LZO_SEARCH_MATCH_INCLUDE_FILE | 145 | | | 146 | | | 147 | 1.26M | #if !defined(LZO_TEST_MATCH_INCLUDE_FILE) | 148 | 1.26M | # define LZO_TEST_MATCH_INCLUDE_FILE "lzo1b_tm.ch" | 149 | 1.26M | #endif | 150 | | | 151 | 1.26M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 1.21M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 1.21M | if (++ip >= ip_end) | 166 | 105 | break; | 167 | 1.21M | #if (DD_BITS > 0) | 168 | 1.21M | DVAL_NEXT(dv,ip); | 169 | 1.21M | #endif | 170 | 1.21M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 47.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 | 47.0k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 47.0k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 47.0k | #endif | 188 | | | 189 | 47.0k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 47.0k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 47.0k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 47.0k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 47.0k | #endif | 203 | | | 204 | 47.0k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 46.7k | assert(ii == ip); | 209 | | | 210 | 46.7k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 383 | 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 | 383 | if (pd(in_end,ii) > 0) | 249 | 333 | { | 250 | 333 | lzo_uint t = pd(in_end,ii); | 251 | 333 | op = STORE_RUN(op,ii,t); | 252 | 333 | } | 253 | | | 254 | 383 | *out_len = pd(op, out); | 255 | 383 | return LZO_E_OK; /* compression went ok */ | 256 | 383 | } |
Line | Count | Source | 69 | 439 | { | 70 | 439 | const lzo_bytep ip; | 71 | 439 | #if (DD_BITS > 0) | 72 | 439 | #if defined(__LZO_HASH_INCREMENTAL) | 73 | 439 | lzo_xint dv; | 74 | 439 | #endif | 75 | 439 | unsigned drun = 0; | 76 | 439 | #endif | 77 | 439 | lzo_bytep op; | 78 | 439 | const lzo_bytep const in_end = in + in_len; | 79 | 439 | const lzo_bytep const ip_end = in + in_len - MIN_LOOKAHEAD; | 80 | 439 | const lzo_bytep ii; | 81 | 439 | #if defined(LZO_HAVE_R1) | 82 | 439 | const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ | 83 | 439 | #endif | 84 | 439 | #if defined(LZO_HAVE_M3) | 85 | 439 | lzo_bytep m3 = out + 1; /* pointer after last m3/m4 match */ | 86 | 439 | #endif | 87 | | | 88 | 439 | 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 | 439 | op = out; | 109 | 439 | ip = in; | 110 | 439 | ii = ip; /* point to start of current literal run */ | 111 | | | 112 | | | 113 | 439 | #if (DD_BITS > 0) | 114 | 439 | DVAL_FIRST(dv,ip); | 115 | 439 | UPDATE_D(dict,drun,dv,ip,in); | 116 | 439 | ip++; | 117 | 439 | DVAL_NEXT(dv,ip); | 118 | | #else | 119 | | ip++; | 120 | | #endif | 121 | | | 122 | 439 | assert(ip < ip_end); | 123 | 439 | for (;;) | 124 | 2.98M | { | 125 | 2.98M | const lzo_bytep m_pos; | 126 | | #if !defined(NDEBUG) | 127 | | const lzo_bytep m_pos_sav = NULL; | 128 | | #endif | 129 | 2.98M | LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); | 130 | | #if (DD_BITS == 0) | 131 | | lzo_uint dindex; | 132 | | #endif | 133 | 2.98M | lzo_uint m_len; | 134 | | | 135 | | | 136 | | /*********************************************************************** | 137 | | // search for a match | 138 | | ************************************************************************/ | 139 | | | 140 | 2.98M | #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) | 141 | 2.98M | # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" | 142 | 2.98M | #endif | 143 | | | 144 | 2.98M | #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 | 2.98M | #include LZO_TEST_MATCH_INCLUDE_FILE | 152 | | | 153 | | | 154 | | | 155 | | /*********************************************************************** | 156 | | // found a literal | 157 | | ************************************************************************/ | 158 | | | 159 | | | 160 | | /* a literal */ | 161 | 2.94M | literal: | 162 | | #if (DD_BITS == 0) | 163 | | UPDATE_I(dict,0,dindex,ip,in); | 164 | | #endif | 165 | 2.94M | if (++ip >= ip_end) | 166 | 95 | break; | 167 | 2.94M | #if (DD_BITS > 0) | 168 | 2.94M | DVAL_NEXT(dv,ip); | 169 | 2.94M | #endif | 170 | 2.94M | continue; | 171 | | | 172 | | | 173 | | | 174 | | /*********************************************************************** | 175 | | // found a match | 176 | | ************************************************************************/ | 177 | | | 178 | 43.1k | 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.1k | #if !defined(LZO_CODE_RUN_INCLUDE_FILE) | 186 | 43.1k | # define LZO_CODE_RUN_INCLUDE_FILE "lzo1b_cr.ch" | 187 | 43.1k | #endif | 188 | | | 189 | 43.1k | #include LZO_CODE_RUN_INCLUDE_FILE | 190 | | | 191 | | | 192 | | /* ii now points to the start of the current match */ | 193 | 43.1k | assert(ii == ip); | 194 | | | 195 | | | 196 | | /*********************************************************************** | 197 | | // code the match | 198 | | ************************************************************************/ | 199 | | | 200 | 43.1k | #if !defined(LZO_CODE_MATCH_INCLUDE_FILE) | 201 | 43.1k | # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" | 202 | 43.1k | #endif | 203 | | | 204 | 43.1k | #include LZO_CODE_MATCH_INCLUDE_FILE | 205 | | | 206 | | | 207 | | /* ii now points to the start of the next literal run */ | 208 | 42.8k | assert(ii == ip); | 209 | | | 210 | 42.8k | } | 211 | | | 212 | | | 213 | | /*********************************************************************** | 214 | | // end of block | 215 | | ************************************************************************/ | 216 | | | 217 | 439 | 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 | 439 | if (pd(in_end,ii) > 0) | 249 | 392 | { | 250 | 392 | lzo_uint t = pd(in_end,ii); | 251 | 392 | op = STORE_RUN(op,ii,t); | 252 | 392 | } | 253 | | | 254 | 439 | *out_len = pd(op, out); | 255 | 439 | return LZO_E_OK; /* compression went ok */ | 256 | 439 | } |
|