|
1 | | -function varargout = zstddecode(varargin) |
| 1 | +function varargout = zstdencode(varargin) |
2 | 2 | % |
3 | | -% output = zstddecode(input) |
| 3 | +% output = zstdencode(input) |
4 | 4 | % or |
5 | | -% output = zstddecode(input,info) |
| 5 | +% [output, info] = zstdencode(input) |
| 6 | +% |
| 7 | +% Compress a string or a numerical array using Zstd-compression |
6 | 8 | % |
7 | | -% Decompressing an Zstd-compressed byte-stream to recover the original data |
8 | 9 | % This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat) |
9 | 10 | % |
10 | 11 | % authors:Qianqian Fang (q.fang <at> neu.edu) |
11 | 12 | % |
12 | 13 | % input: |
13 | | -% input: a string, int8/uint8 vector or numerical array to store Zstd-compressed data |
14 | | -% info (optional): a struct produced by the zmat/zstdencode function during |
15 | | -% compression; if not given, the inputs/outputs will be treated as a |
16 | | -% 1-D vector |
| 14 | +% input: the original data, can be a string, a numerical vector or array |
17 | 15 | % |
18 | 16 | % output: |
19 | | -% output: the decompressed byte stream stored in a uint8 vector; if info is |
20 | | -% given, output will restore the original data's type and dimensions |
| 17 | +% output: the compressed byte stream stored in a uint8 vector |
| 18 | +% info: (optional) a struct storing the metadata of the input, see "help zmat" for details |
21 | 19 | % |
22 | 20 | % examples: |
23 | 21 | % [bytes, info]=zstdencode(eye(10)); |
|
32 | 30 | if (nargin == 0) |
33 | 31 | error('you must provide at least 1 input'); |
34 | 32 | end |
| 33 | + |
35 | 34 | if (exist('zmat', 'file') == 2 || exist('zmat', 'file') == 3) |
36 | | - if (nargin > 1) |
37 | | - [varargout{1:nargout}] = zmat(varargin{1}, varargin{2:end}); |
38 | | - else |
39 | | - [varargout{1:nargout}] = zmat(varargin{1}, 0, 'zstd', varargin{2:end}); |
40 | | - end |
| 35 | + [varargout{1:nargout}] = zmat(varargin{1}, 1, 'zstd', varargin{2:end}); |
| 36 | + return |
41 | 37 | else |
42 | 38 | error('you must install ZMat toolbox to use this feature: http://github.com/NeuroJSON/zmat'); |
43 | 39 | end |
0 commit comments