| OLD | NEW |
| 1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 // | 2 // |
| 3 /// \file lzma_decoder.c | 3 /// \file lzma_decoder.c |
| 4 /// \brief LZMA decoder | 4 /// \brief LZMA decoder |
| 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // found. It must not be | 649 // found. It must not be |
| 650 // present if uncompressed | 650 // present if uncompressed |
| 651 // size is known. | 651 // size is known. |
| 652 if (coder->uncompressed_size | 652 if (coder->uncompressed_size |
| 653 != LZMA_VLI_UNKNOWN) { | 653 != LZMA_VLI_UNKNOWN) { |
| 654 ret = LZMA_DATA_ERROR; | 654 ret = LZMA_DATA_ERROR; |
| 655 goto out; | 655 goto out; |
| 656 } | 656 } |
| 657 | 657 |
| 658 case SEQ_EOPM: | 658 case SEQ_EOPM: |
| 659 » » » » » » // TODO Comment | 659 » » » » » » // LZMA1 stream with |
| 660 » » » » » » // end-of-payload marker. |
| 660 rc_normalize(SEQ_EOPM); | 661 rc_normalize(SEQ_EOPM); |
| 661 ret = LZMA_STREAM_END; | 662 ret = LZMA_STREAM_END; |
| 662 goto out; | 663 goto out; |
| 663 } | 664 } |
| 664 } | 665 } |
| 665 } | 666 } |
| 666 | 667 |
| 667 // Validate the distance we just decoded. | 668 // Validate the distance we just decoded. |
| 668 if (unlikely(!dict_is_distance_valid(&dict, rep0))) { | 669 if (unlikely(!dict_is_distance_valid(&dict, rep0))) { |
| 669 ret = LZMA_DATA_ERROR; | 670 ret = LZMA_DATA_ERROR; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 } | 850 } |
| 850 */ | 851 */ |
| 851 | 852 |
| 852 static void | 853 static void |
| 853 lzma_decoder_reset(lzma_coder *coder, const void *opt) | 854 lzma_decoder_reset(lzma_coder *coder, const void *opt) |
| 854 { | 855 { |
| 855 const lzma_options_lzma *options = opt; | 856 const lzma_options_lzma *options = opt; |
| 856 | 857 |
| 857 // NOTE: We assume that lc/lp/pb are valid since they were | 858 // NOTE: We assume that lc/lp/pb are valid since they were |
| 858 // successfully decoded with lzma_lzma_decode_properties(). | 859 // successfully decoded with lzma_lzma_decode_properties(). |
| 859 // FIXME? | |
| 860 | 860 |
| 861 // Calculate pos_mask. We don't need pos_bits as is for anything. | 861 // Calculate pos_mask. We don't need pos_bits as is for anything. |
| 862 coder->pos_mask = (1U << options->pb) - 1; | 862 coder->pos_mask = (1U << options->pb) - 1; |
| 863 | 863 |
| 864 // Initialize the literal decoder. | 864 // Initialize the literal decoder. |
| 865 literal_init(coder->literal, options->lc, options->lp); | 865 literal_init(coder->literal, options->lc, options->lp); |
| 866 | 866 |
| 867 coder->literal_context_bits = options->lc; | 867 coder->literal_context_bits = options->lc; |
| 868 coder->literal_pos_mask = (1U << options->lp) - 1; | 868 coder->literal_pos_mask = (1U << options->lp) - 1; |
| 869 | 869 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 opt->preset_dict_size = 0; | 1048 opt->preset_dict_size = 0; |
| 1049 | 1049 |
| 1050 *options = opt; | 1050 *options = opt; |
| 1051 | 1051 |
| 1052 return LZMA_OK; | 1052 return LZMA_OK; |
| 1053 | 1053 |
| 1054 error: | 1054 error: |
| 1055 lzma_free(opt, allocator); | 1055 lzma_free(opt, allocator); |
| 1056 return LZMA_OPTIONS_ERROR; | 1056 return LZMA_OPTIONS_ERROR; |
| 1057 } | 1057 } |
| OLD | NEW |