| OLD | NEW |
| 1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 // | 2 // |
| 3 /// \file lzma2_encoder.c | 3 /// \file lzma2_encoder.c |
| 4 /// \brief LZMA2 encoder | 4 /// \brief LZMA2 encoder |
| 5 /// | 5 /// |
| 6 // Authors: Igor Pavlov | 6 // Authors: Igor Pavlov |
| 7 // Lasse Collin | 7 // Lasse Collin |
| 8 // | 8 // |
| 9 // This file has been put into the public domain. | 9 // This file has been put into the public domain. |
| 10 // You can do whatever you want with this file. | 10 // You can do whatever you want with this file. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return sizeof(lzma_coder) + lzma_mem; | 367 return sizeof(lzma_coder) + lzma_mem; |
| 368 } | 368 } |
| 369 | 369 |
| 370 | 370 |
| 371 extern lzma_ret | 371 extern lzma_ret |
| 372 lzma_lzma2_props_encode(const void *options, uint8_t *out) | 372 lzma_lzma2_props_encode(const void *options, uint8_t *out) |
| 373 { | 373 { |
| 374 const lzma_options_lzma *const opt = options; | 374 const lzma_options_lzma *const opt = options; |
| 375 uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN); | 375 uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN); |
| 376 | 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: | 378 // on which one is the next: |
| 379 --d; | 379 --d; |
| 380 d |= d >> 2; | 380 d |= d >> 2; |
| 381 d |= d >> 3; | 381 d |= d >> 3; |
| 382 d |= d >> 4; | 382 d |= d >> 4; |
| 383 d |= d >> 8; | 383 d |= d >> 8; |
| 384 d |= d >> 16; | 384 d |= d >> 16; |
| 385 | 385 |
| 386 // Get the highest two bits using the proper encoding: | 386 // Get the highest two bits using the proper encoding: |
| 387 if (d == UINT32_MAX) | 387 if (d == UINT32_MAX) |
| 388 out[0] = 40; | 388 out[0] = 40; |
| 389 else | 389 else |
| 390 out[0] = get_pos_slot(d + 1) - 24; | 390 out[0] = get_pos_slot(d + 1) - 24; |
| 391 | 391 |
| 392 return LZMA_OK; | 392 return LZMA_OK; |
| 393 } | 393 } |
| OLD | NEW |