| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define THRESHOLD (M2_MIN_LEN - 1) |
| #define MSIZE LZO_SIZE(M2L_BITS) |
| |
| |
| |
| |
| |
| |
| #if (DD_BITS == 0) |
| |
| |
| |
| ip += M2_MIN_LEN; |
| assert(m_pos < ip); |
| |
| |
| |
| #define M2_OR_M3 (MATCH_M2) |
| |
| #else /* (DD_BITS == 0) */ |
| |
| |
| assert(m_len >= M2_MIN_LEN); |
| ip += m_len; |
| assert(ip <= in_end); |
| |
| #define M2_OR_M3 (m_len <= M2_MAX_LEN) |
| |
| #endif /* (DD_BITS == 0) */ |
| |
| |
| if (M2_OR_M3) |
| { |
| |
| assert(ip <= in_end); |
| |
| |
| #if (DD_BITS == 0) |
| assert(pd(ip,m_pos) == m_off); |
| --ip; |
| m_len = ip - ii; |
| #endif |
| assert(m_len >= M2_MIN_LEN); |
| assert(m_len <= M2_MAX_LEN); |
| |
| assert(m_off >= M2_MIN_OFFSET); |
| assert(m_off <= M2_MAX_OFFSET); |
| assert(ii-m_off == m_pos_sav); |
| assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); |
| |
| |
| m_off -= M2_MIN_OFFSET; |
| |
| *op++ = LZO_BYTE(((m_len - THRESHOLD) << M2O_BITS) | |
| (m_off & M2O_MASK)); |
| |
| *op++ = LZO_BYTE(m_off >> M2O_BITS); |
| |
| |
| if (ip >= ip_end) |
| { |
| ii = ip; |
| break; |
| } |
| |
| |
| |
| |
| #if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3) |
| |
| ++ii; |
| do { |
| DVAL_NEXT(dv,ii); |
| #if 0 |
| UPDATE_D(dict,drun,dv,ii,in); |
| #else |
| dict[ DINDEX(dv,ii) ] = DENTRY(ii,in); |
| #endif |
| MI |
| } while (++ii < ip); |
| DVAL_NEXT(dv,ii); |
| assert(ii == ip); |
| DVAL_ASSERT(dv,ip); |
| #elif (CLEVEL >= 3) |
| SI DI DI XI |
| #elif (CLEVEL >= 2) |
| SI DI XI |
| #else |
| XI |
| #endif |
| } |
| |
| else |
| |
| { |
| |
| const lzo_bytep end; |
| |
| assert(ip <= in_end); |
| assert(ii == ip - (M2_MAX_LEN + 1)); |
| assert(lzo_memcmp(m_pos_sav,ii,(lzo_uint)(ip-ii)) == 0); |
| |
| #if (DD_BITS > 0) |
| assert(m_len == (lzo_uint)(ip-ii)); |
| m_pos = ip - m_off; |
| assert(m_pos == m_pos_sav + m_len); |
| #endif |
| |
| if (pd(in_end,ip) <= (M3_MAX_LEN - M3_MIN_LEN)) |
| end = in_end; |
| else |
| { |
| end = ip + (M3_MAX_LEN - M3_MIN_LEN); |
| assert(end < in_end); |
| } |
| |
| while (ip < end && *m_pos == *ip) |
| m_pos++, ip++; |
| assert(ip <= in_end); |
| |
| |
| m_len = pd(ip, ii); |
| assert(m_len >= M3_MIN_LEN); |
| assert(m_len <= M3_MAX_LEN); |
| |
| assert(m_off >= M3_MIN_OFFSET); |
| assert(m_off <= M3_MAX_OFFSET); |
| assert(ii-m_off == m_pos_sav); |
| assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); |
| assert(pd(ip,m_pos) == m_off); |
| |
| |
| m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET; |
| |
| *op++ = LZO_BYTE(((MSIZE - 1) << M3O_BITS) | (m_off & M3O_MASK)); |
| |
| *op++ = LZO_BYTE(m_off >> M3O_BITS); |
| |
| *op++ = LZO_BYTE(m_len - M3_MIN_LEN); |
| |
| |
| if (ip >= ip_end) |
| { |
| ii = ip; |
| break; |
| } |
| |
| |
| |
| #if (CLEVEL == 9) |
| |
| |
| ++ii; |
| do { |
| DVAL_NEXT(dv,ii); |
| #if 0 |
| UPDATE_D(dict,drun,dv,ii,in); |
| #else |
| dict[ DINDEX(dv,ii) ] = DENTRY(ii,in); |
| #endif |
| MI |
| } while (++ii < ip); |
| DVAL_NEXT(dv,ii); |
| assert(ii == ip); |
| DVAL_ASSERT(dv,ip); |
| #elif (CLEVEL >= 8) |
| SI DI DI DI DI DI DI DI DI XI |
| #elif (CLEVEL >= 7) |
| SI DI DI DI DI DI DI DI XI |
| #elif (CLEVEL >= 6) |
| SI DI DI DI DI DI DI XI |
| #elif (CLEVEL >= 5) |
| SI DI DI DI DI XI |
| #elif (CLEVEL >= 4) |
| SI DI DI DI XI |
| #elif (CLEVEL >= 3) |
| SI DI DI XI |
| #elif (CLEVEL >= 2) |
| SI DI XI |
| #else |
| XI |
| #endif |
| } |
| |
| |
| assert(ii == ip); |
| |
| |
| |
| |
| |