sz_compat.c 1.38 KB
Newer Older
1
#include <stdio.h>
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
2 3
#include <stddef.h>
#include "szlib.h"
4
#include "libaec.h"
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
5

6 7 8
int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
                          const void *source, size_t sourceLen,
                          SZ_com_t *param)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
9 10
{
    int status;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
11
    struct aec_stream strm;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
12 13 14

    strm.bit_per_sample = param->bits_per_pixel;
    strm.block_size = param->pixels_per_block;
15
    strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
16
    strm.flags = param->options_mask;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
17 18 19 20 21
    strm.avail_in = sourceLen;
    strm.avail_out = *destLen;
    strm.next_out = dest;
    strm.next_in = source;

22 23
    status = aec_buf_encode(&strm);
    if (status != AEC_OK)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
24 25
        return status;

26
    *destLen = strm.total_out;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
27 28 29
    return SZ_OK;
}

30 31 32
int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
                            const void *source, size_t sourceLen,
                            SZ_com_t *param)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
33 34
{
    int status;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
35
    struct aec_stream strm;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
36 37 38

    strm.bit_per_sample = param->bits_per_pixel;
    strm.block_size = param->pixels_per_block;
39
    strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
40 41 42 43 44 45
    strm.flags = param->options_mask;
    strm.avail_in = sourceLen;
    strm.avail_out = *destLen;
    strm.next_out = dest;
    strm.next_in = source;

46 47
    status = aec_buf_decode(&strm);
    if (status != AEC_OK)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
48 49
        return status;

50
    *destLen = strm.total_out;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
51 52
    return SZ_OK;
}