# AVF 压缩格式 V1.4.2 (Python 实现)
## 使用说明
```python
from avfcomp import AVFComp, AVFDecomp, CompHandler
# compress
path = "your/path/raw.avf"
# choose from plain, gzip, bzip2, lzma(default)
Compressor = AVFComp(handler=CompHandler.LZMA)
Compressor.process_in(path)
Compressor.process_out("comp.cvf")
# decompress
path = "your/path/comp.cvf"
# choose from plain, gzip, bzip2, lzma(default)
Decompressor = AVFDecomp(handler=CompHandler.LZMA)
Decompressor.process_in(path)
Decompressor.process_out("raw.avf")
```
## 格式说明 (目前支持 Arbiter 0.52+)
- 对录像先进行一轮预压缩(此时压缩率能够达到15%左右)
- 可选 gzip, bzip2, lzma 二次压缩,默认采用 lzma 进行二次压缩(此时压缩率接近8%)
- 1字节: 大版本号
- 4字节: `prefix`
- 1字节: 模式
- 对于自定义, 用额外的字节存储参数
- 1字节: 宽w
- 1字节: 高h
- 雷的排布
- 01串表示, 长度可以通过长宽推出来。通过排布可以推出雷数和3BV。
- `prestamp`
- 由 `[]`标志的录像信息
- `preevent`
- 2字节: `\x00\x01`表示 `preevent` 结束
- 事件列, 目前除了按键列其他都存的差分序列, 坐标序列差分后采取zigzag编码, 如果是某些时间段移动距离小的事件, 会把整个事件全部压缩到事件列表上面, 然后根据事件出现的频率进行了从小到大的编码 ~~(压缩什么的交给lzma)~~
- 3个字节的预压缩数据总量(~~应该够了吧~~)
- 按键序列(1-2个变长字节, 一般是一个字节)
- 1字节 `\xff`表示按键序列结束(用来得出事件数量)
- 时间戳差分序列(1-2个变长字节)
- x坐标差分序列(1-2个变长字节)
- y坐标差分序列(1-2个变长字节)
- `presuffix`
- 文件结尾的字符串录像信息, 只保留数据信息, 不保留文字说明信息
Raw data
{
"_id": null,
"home_page": "",
"name": "avfcomp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "minesweeper compression decompression",
"author": "Cai Li, Tony Xiang",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/20/07/8c616e93d7fe8a98afb5034fcc806e7a2e00155f059d8c6b860198a1792d/avfcomp-1.4.3.tar.gz",
"platform": null,
"description": "# AVF \u538b\u7f29\u683c\u5f0f V1.4.2 (Python \u5b9e\u73b0)\n\n## \u4f7f\u7528\u8bf4\u660e\n\n```python\nfrom avfcomp import AVFComp, AVFDecomp, CompHandler\n\n# compress\npath = \"your/path/raw.avf\"\n# choose from plain, gzip, bzip2, lzma(default)\nCompressor = AVFComp(handler=CompHandler.LZMA)\nCompressor.process_in(path)\nCompressor.process_out(\"comp.cvf\")\n\n# decompress\npath = \"your/path/comp.cvf\"\n# choose from plain, gzip, bzip2, lzma(default)\nDecompressor = AVFDecomp(handler=CompHandler.LZMA)\nDecompressor.process_in(path)\nDecompressor.process_out(\"raw.avf\")\n```\n\n## \u683c\u5f0f\u8bf4\u660e (\u76ee\u524d\u652f\u6301 Arbiter 0.52+)\n\n- \u5bf9\u5f55\u50cf\u5148\u8fdb\u884c\u4e00\u8f6e\u9884\u538b\u7f29\uff08\u6b64\u65f6\u538b\u7f29\u7387\u80fd\u591f\u8fbe\u523015%\u5de6\u53f3\uff09\n- \u53ef\u9009 gzip, bzip2, lzma \u4e8c\u6b21\u538b\u7f29\uff0c\u9ed8\u8ba4\u91c7\u7528 lzma \u8fdb\u884c\u4e8c\u6b21\u538b\u7f29\uff08\u6b64\u65f6\u538b\u7f29\u7387\u63a5\u8fd18%\uff09\n- 1\u5b57\u8282: \u5927\u7248\u672c\u53f7\n- 4\u5b57\u8282: `prefix`\n- 1\u5b57\u8282: \u6a21\u5f0f\n- \u5bf9\u4e8e\u81ea\u5b9a\u4e49, \u7528\u989d\u5916\u7684\u5b57\u8282\u5b58\u50a8\u53c2\u6570\n\n - 1\u5b57\u8282: \u5bbdw\n - 1\u5b57\u8282: \u9ad8h\n- \u96f7\u7684\u6392\u5e03\n\n - 01\u4e32\u8868\u793a, \u957f\u5ea6\u53ef\u4ee5\u901a\u8fc7\u957f\u5bbd\u63a8\u51fa\u6765\u3002\u901a\u8fc7\u6392\u5e03\u53ef\u4ee5\u63a8\u51fa\u96f7\u6570\u548c3BV\u3002\n- `prestamp`\n\n - \u7531 `[]`\u6807\u5fd7\u7684\u5f55\u50cf\u4fe1\u606f\n- `preevent`\n\n - 2\u5b57\u8282: `\\x00\\x01`\u8868\u793a `preevent` \u7ed3\u675f\n- \u4e8b\u4ef6\u5217, \u76ee\u524d\u9664\u4e86\u6309\u952e\u5217\u5176\u4ed6\u90fd\u5b58\u7684\u5dee\u5206\u5e8f\u5217, \u5750\u6807\u5e8f\u5217\u5dee\u5206\u540e\u91c7\u53d6zigzag\u7f16\u7801, \u5982\u679c\u662f\u67d0\u4e9b\u65f6\u95f4\u6bb5\u79fb\u52a8\u8ddd\u79bb\u5c0f\u7684\u4e8b\u4ef6, \u4f1a\u628a\u6574\u4e2a\u4e8b\u4ef6\u5168\u90e8\u538b\u7f29\u5230\u4e8b\u4ef6\u5217\u8868\u4e0a\u9762, \u7136\u540e\u6839\u636e\u4e8b\u4ef6\u51fa\u73b0\u7684\u9891\u7387\u8fdb\u884c\u4e86\u4ece\u5c0f\u5230\u5927\u7684\u7f16\u7801 ~~\uff08\u538b\u7f29\u4ec0\u4e48\u7684\u4ea4\u7ed9lzma\uff09~~\n\n - 3\u4e2a\u5b57\u8282\u7684\u9884\u538b\u7f29\u6570\u636e\u603b\u91cf\uff08~~\u5e94\u8be5\u591f\u4e86\u5427~~\uff09\n - \u6309\u952e\u5e8f\u5217\uff081-2\u4e2a\u53d8\u957f\u5b57\u8282, \u4e00\u822c\u662f\u4e00\u4e2a\u5b57\u8282\uff09\n - 1\u5b57\u8282 `\\xff`\u8868\u793a\u6309\u952e\u5e8f\u5217\u7ed3\u675f\uff08\u7528\u6765\u5f97\u51fa\u4e8b\u4ef6\u6570\u91cf\uff09\n - \u65f6\u95f4\u6233\u5dee\u5206\u5e8f\u5217\uff081-2\u4e2a\u53d8\u957f\u5b57\u8282\uff09\n - x\u5750\u6807\u5dee\u5206\u5e8f\u5217\uff081-2\u4e2a\u53d8\u957f\u5b57\u8282\uff09\n - y\u5750\u6807\u5dee\u5206\u5e8f\u5217\uff081-2\u4e2a\u53d8\u957f\u5b57\u8282\uff09\n- `presuffix`\n- \u6587\u4ef6\u7ed3\u5c3e\u7684\u5b57\u7b26\u4e32\u5f55\u50cf\u4fe1\u606f, \u53ea\u4fdd\u7559\u6570\u636e\u4fe1\u606f, \u4e0d\u4fdd\u7559\u6587\u5b57\u8bf4\u660e\u4fe1\u606f\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A compression/decompression library for AVF files.",
"version": "1.4.3",
"project_urls": null,
"split_keywords": [
"minesweeper",
"compression",
"decompression"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "98c62deb9931d914ecccd32cbaf1ba9748b82eede5952724732e3823a6810577",
"md5": "d5af5daf2f98e3e3bf80ff092de984a1",
"sha256": "18904e5a5150ba5905ac6252c8bf80a73ec447ec2f441aaa6001b3ff2a858fcc"
},
"downloads": -1,
"filename": "avfcomp-1.4.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d5af5daf2f98e3e3bf80ff092de984a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12408,
"upload_time": "2023-12-27T12:38:13",
"upload_time_iso_8601": "2023-12-27T12:38:13.375497Z",
"url": "https://files.pythonhosted.org/packages/98/c6/2deb9931d914ecccd32cbaf1ba9748b82eede5952724732e3823a6810577/avfcomp-1.4.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "20078c616e93d7fe8a98afb5034fcc806e7a2e00155f059d8c6b860198a1792d",
"md5": "110e29bd0010e93ce2ea53a80c545ff0",
"sha256": "4d1ef22f01b0c4601a9f104ac3520936ace779a55446d2c4e50991b475e273b6"
},
"downloads": -1,
"filename": "avfcomp-1.4.3.tar.gz",
"has_sig": false,
"md5_digest": "110e29bd0010e93ce2ea53a80c545ff0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11520,
"upload_time": "2023-12-27T12:38:15",
"upload_time_iso_8601": "2023-12-27T12:38:15.203474Z",
"url": "https://files.pythonhosted.org/packages/20/07/8c616e93d7fe8a98afb5034fcc806e7a2e00155f059d8c6b860198a1792d/avfcomp-1.4.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-27 12:38:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "avfcomp"
}