842_compress.c (01b944fe1cd4e21a2a9ed51adbdbafe2d5e905ba) | 842_compress.c (ea0b3984c1cc8b28de27a3bec285102b4e366a4c) |
---|---|
1/* 2 * 842 Software Compression 3 * 4 * Copyright (C) 2015 Dan Streetman, IBM Corp 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 476 unchanged lines hidden (view full) --- 485 */ 486int sw842_compress(const u8 *in, unsigned int ilen, 487 u8 *out, unsigned int *olen, void *wmem) 488{ 489 struct sw842_param *p = (struct sw842_param *)wmem; 490 int ret; 491 u64 last, next, pad, total; 492 u8 repeat_count = 0; | 1/* 2 * 842 Software Compression 3 * 4 * Copyright (C) 2015 Dan Streetman, IBM Corp 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 476 unchanged lines hidden (view full) --- 485 */ 486int sw842_compress(const u8 *in, unsigned int ilen, 487 u8 *out, unsigned int *olen, void *wmem) 488{ 489 struct sw842_param *p = (struct sw842_param *)wmem; 490 int ret; 491 u64 last, next, pad, total; 492 u8 repeat_count = 0; |
493 u32 crc; |
|
493 494 BUILD_BUG_ON(sizeof(*p) > SW842_MEM_COMPRESS); 495 496 init_hashtable_nodes(p, 8); 497 init_hashtable_nodes(p, 4); 498 init_hashtable_nodes(p, 2); 499 500 p->in = (u8 *)in; --- 74 unchanged lines hidden (view full) --- 575 p->in += p->ilen; 576 p->ilen = 0; 577 } 578 579 ret = add_end_template(p); 580 if (ret) 581 return ret; 582 | 494 495 BUILD_BUG_ON(sizeof(*p) > SW842_MEM_COMPRESS); 496 497 init_hashtable_nodes(p, 8); 498 init_hashtable_nodes(p, 4); 499 init_hashtable_nodes(p, 2); 500 501 p->in = (u8 *)in; --- 74 unchanged lines hidden (view full) --- 576 p->in += p->ilen; 577 p->ilen = 0; 578 } 579 580 ret = add_end_template(p); 581 if (ret) 582 return ret; 583 |
584 /* 585 * crc(0:31) is appended to target data starting with the next 586 * bit after End of stream template. 587 * nx842 calculates CRC for data in big-endian format. So doing 588 * same here so that sw842 decompression can be used for both 589 * compressed data. 590 */ 591 crc = crc32_be(0, in, ilen); 592 ret = add_bits(p, crc, CRC_BITS); 593 if (ret) 594 return ret; 595 |
|
583 if (p->bit) { 584 p->out++; 585 p->olen--; 586 p->bit = 0; 587 } 588 589 /* pad compressed length to multiple of 8 */ 590 pad = (8 - ((total - p->olen) % 8)) % 8; --- 36 unchanged lines hidden --- | 596 if (p->bit) { 597 p->out++; 598 p->olen--; 599 p->bit = 0; 600 } 601 602 /* pad compressed length to multiple of 8 */ 603 pad = (8 - ((total - p->olen) % 8)) % 8; --- 36 unchanged lines hidden --- |