lzma2_encoder.c (207842) | lzma2_encoder.c (213700) |
---|---|
1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file lzma2_encoder.c 4/// \brief LZMA2 encoder 5/// 6// Authors: Igor Pavlov 7// Lasse Collin 8// --- 358 unchanged lines hidden (view full) --- 367 return sizeof(lzma_coder) + lzma_mem; 368} 369 370 371extern lzma_ret 372lzma_lzma2_props_encode(const void *options, uint8_t *out) 373{ 374 const lzma_options_lzma *const opt = options; | 1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file lzma2_encoder.c 4/// \brief LZMA2 encoder 5/// 6// Authors: Igor Pavlov 7// Lasse Collin 8// --- 358 unchanged lines hidden (view full) --- 367 return sizeof(lzma_coder) + lzma_mem; 368} 369 370 371extern lzma_ret 372lzma_lzma2_props_encode(const void *options, uint8_t *out) 373{ 374 const lzma_options_lzma *const opt = options; |
375 uint32_t d = MAX(opt->dict_size, LZMA_DICT_SIZE_MIN); | 375 uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN); |
376 377 // Round up to to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending 378 // on which one is the next: 379 --d; 380 d |= d >> 2; 381 d |= d >> 3; 382 d |= d >> 4; 383 d |= d >> 8; 384 d |= d >> 16; 385 386 // Get the highest two bits using the proper encoding: 387 if (d == UINT32_MAX) 388 out[0] = 40; 389 else 390 out[0] = get_pos_slot(d + 1) - 24; 391 392 return LZMA_OK; 393} | 376 377 // Round up to to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending 378 // on which one is the next: 379 --d; 380 d |= d >> 2; 381 d |= d >> 3; 382 d |= d >> 4; 383 d |= d >> 8; 384 d |= d >> 16; 385 386 // Get the highest two bits using the proper encoding: 387 if (d == UINT32_MAX) 388 out[0] = 40; 389 else 390 out[0] = get_pos_slot(d + 1) - 24; 391 392 return LZMA_OK; 393} |