Deleted Added
full compact
lzma2_encoder.c (213700) lzma2_encoder.c (223935)
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file lzma2_encoder.c
4/// \brief LZMA2 encoder
5///
6// Authors: Igor Pavlov
7// Lasse Collin
8//

--- 360 unchanged lines hidden (view full) ---

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 = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);
376
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file lzma2_encoder.c
4/// \brief LZMA2 encoder
5///
6// Authors: Igor Pavlov
7// Lasse Collin
8//

--- 360 unchanged lines hidden (view full) ---

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 = 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
377 // Round up 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}
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}