blob: b61818a2853760f1fd691c42129471caf8df5ffd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include <stdio.h>
#include <stddef.h>
#include "szlib.h"
#include "libaec.h"
#define NOPTS 129
static int convert_options(int sz_opts)
{
int co[NOPTS];
int i;
int opts = 0;
memset(co, 0, sizeof(int) * NOPTS);
co[SZ_MSB_OPTION_MASK] = AEC_DATA_MSB;
co[SZ_NN_OPTION_MASK] = AEC_DATA_PREPROCESS;
for (i = 1; i < NOPTS; i <<= 1)
opts |= co[i];
return opts;
}
int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
const void *source, size_t sourceLen,
SZ_com_t *param)
{
int status;
struct aec_stream strm;
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
strm.flags = convert_options(param->options_mask);
strm.avail_in = sourceLen;
strm.avail_out = *destLen;
strm.next_out = dest;
strm.next_in = source;
status = aec_buffer_encode(&strm);
if (status != AEC_OK)
return status;
*destLen = strm.total_out;
return SZ_OK;
}
int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
const void *source, size_t sourceLen,
SZ_com_t *param)
{
int status;
struct aec_stream strm;
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
strm.flags = convert_options(param->options_mask);
strm.avail_in = sourceLen;
strm.avail_out = *destLen;
strm.next_out = dest;
strm.next_in = source;
status = aec_buffer_decode(&strm);
if (status != AEC_OK)
return status;
*destLen = strm.total_out;
return SZ_OK;
}
int SZ_encoder_enabled(void)
{
return 1;
}
|