找回密码
 欢迎注册
查看: 10397|回复: 9

[分享] 数据压缩:完全参考

[复制链接]
发表于 2011-2-23 21:55:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
4er.jpg
http://www.davidsalomon.name/DC4advertis/DComp4Ad.html
http://download.csdn.net/source/2082674
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-2-26 10:47:15 | 显示全部楼层
1# G-Spider

http://library.nu 里搜到了该书的链接,不用注册即可下载:

http://ifile.it/ihk7pbj/_eIhbVGtED68.7z
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2011-2-26 11:22:25 | 显示全部楼层
上书也提到了一点关于LZMA,(Lempel-Ziv-Markov chain-Algorithm的缩写),是一个Deflate和LZ77算法改良和优化后的压缩算法,开发者是Igor Pavlov
可以到http://www.7-zip.org/ 下载到SDK。
可以在LzmaLib.h找到压缩LzmaCompress与解压缩LzmaUncompress的接口说明。
LZMA格式的解压,依赖Alloc.c   , LzmaDec.c,  LzmaLib.c, LzmaLib.h ,Types.h ,LzmaDec.h ,Alloc.h这7个文件再加上自己写的main函数就可以集成解压。
  1. /*
  2. LzmaCompress
  3. ------------

  4. outPropsSize -
  5.      In:  the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
  6.      Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.

  7.   LZMA Encoder will use defult values for any parameter, if it is
  8.   -1  for any from: level, loc, lp, pb, fb, numThreads
  9.    0  for dictSize
  10.   
  11. level - compression level: 0 <= level <= 9;

  12.   level dictSize algo  fb
  13.     0:    16 KB   0    32
  14.     1:    64 KB   0    32
  15.     2:   256 KB   0    32
  16.     3:     1 MB   0    32
  17.     4:     4 MB   0    32
  18.     5:    16 MB   1    32
  19.     6:    32 MB   1    32
  20.     7+:   64 MB   1    64

  21.   The default value for "level" is 5.

  22.   algo = 0 means fast method
  23.   algo = 1 means normal method

  24. dictSize - The dictionary size in bytes. The maximum value is
  25.         128 MB = (1 << 27) bytes for 32-bit version
  26.           1 GB = (1 << 30) bytes for 64-bit version
  27.      The default value is 16 MB = (1 << 24) bytes.
  28.      It's recommended to use the dictionary that is larger than 4 KB and
  29.      that can be calculated as (1 << N) or (3 << N) sizes.

  30. lc - The number of literal context bits (high bits of previous literal).
  31.      It can be in the range from 0 to 8. The default value is 3.
  32.      Sometimes lc=4 gives the gain for big files.

  33. lp - The number of literal pos bits (low bits of current position for literals).
  34.      It can be in the range from 0 to 4. The default value is 0.
  35.      The lp switch is intended for periodical data when the period is equal to 2^lp.
  36.      For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's
  37.      better to set lc=0, if you change lp switch.

  38. pb - The number of pos bits (low bits of current position).
  39.      It can be in the range from 0 to 4. The default value is 2.
  40.      The pb switch is intended for periodical data when the period is equal 2^pb.

  41. fb - Word size (the number of fast bytes).
  42.      It can be in the range from 5 to 273. The default value is 32.
  43.      Usually, a big number gives a little bit better compression ratio and
  44.      slower compression process.

  45. numThreads - The number of thereads. 1 or 2. The default value is 2.
  46.      Fast mode (algo = 0) can use only 1 thread.

  47. Out:
  48.   destLen  - processed output size
  49. Returns:
  50.   SZ_OK               - OK
  51.   SZ_ERROR_MEM        - Memory allocation error
  52.   SZ_ERROR_PARAM      - Incorrect paramater
  53.   SZ_ERROR_OUTPUT_EOF - output buffer overflow
  54.   SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
  55. */

  56. MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,
  57.   unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */
  58.   int level,      /* 0 <= level <= 9, default = 5 */
  59.   unsigned dictSize,  /* default = (1 << 24) */
  60.   int lc,        /* 0 <= lc <= 8, default = 3  */
  61.   int lp,        /* 0 <= lp <= 4, default = 0  */
  62.   int pb,        /* 0 <= pb <= 4, default = 2  */
  63.   int fb,        /* 5 <= fb <= 273, default = 32 */
  64.   int numThreads /* 1 or 2, default = 2 */
  65.   );

  66. /*
  67. LzmaUncompress
  68. --------------
  69. In:
  70.   dest     - output data
  71.   destLen  - output data size
  72.   src      - input data
  73.   srcLen   - input data size
  74. Out:
  75.   destLen  - processed output size
  76.   srcLen   - processed input size
  77. Returns:
  78.   SZ_OK                - OK
  79.   SZ_ERROR_DATA        - Data error
  80.   SZ_ERROR_MEM         - Memory allocation arror
  81.   SZ_ERROR_UNSUPPORTED - Unsupported properties
  82.   SZ_ERROR_INPUT_EOF   - it needs more bytes in input buffer (src)
  83. */

  84. MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,
  85.   const unsigned char *props, size_t propsSize);
复制代码
上面两个函数的src串的长度是确定的,而dest串的长度是通过返回得到的。

压缩与解压缩.zip (380.64 KB, 下载次数: 16)
解压集成.zip (245.27 KB, 下载次数: 3)
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-2-26 11:35:05 | 显示全部楼层
本帖最后由 qianyb 于 2011-2-26 11:57 编辑

2#的需要解压密码,请问解压密码是多少?

默认都是  library.nu 的

不是啊
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-2-26 11:36:45 | 显示全部楼层
3# G-Spider
我只知道rle 压缩
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-2-26 11:37:18 | 显示全部楼层
4# qianyb
默认都是  library.nu 的
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-3-14 09:58:29 | 显示全部楼层
除了PAQ,现在别的我都不感兴趣了...
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2011-3-14 12:51:52 | 显示全部楼层
7# 仙剑魔
我想PAQ“高压缩”背后的时间代价是最大的隐痛,以前我试过很多PAQ系列,深有体会。当前,从资源角度,相对的高压缩率和用时极少才是热捧的对象。
当然,如果LS的能够解决时间效率问题,你会出名的。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-3-15 08:03:07 | 显示全部楼层
4# qianyb

无意间发现你这个帖子更新了。
才意识到我没有回复你,莫怪啊
现给出一个无需密码的链接
http://ifile.it/jsn5bh/ebooksclu ... _Fourth_Edition.pdf
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-3-15 08:50:08 | 显示全部楼层
没注意到正常的,谢谢你了
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-3-29 14:55 , Processed in 0.065866 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表