Loading...
Searching...
No Matches
decenc_aec.c
Go to the documentation of this file.
#include "grib2_int.h"
#include <libaec.h>
#include <stdint.h>
#include <stdio.h>
int
dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
{
struct aec_stream strm;
int ret = 0;
/* Define bits per sample */
strm.bits_per_sample = nbits;
LOG((3, "dec_aec: bits_per_sample = %d", strm.bits_per_sample));
/* Define a block size */
LOG((3, "dec_aec: block_size = %d", block_size));
strm.block_size = block_size;
/* Define the reference sample interval */
LOG((3, "dec_aec: rsi = %d", rsi));
strm.rsi = rsi;
/* Define the AEC compression flags. */
strm.flags = flags;
LOG((3, "dec_aec: flags = %d", strm.flags));
/* Pointer to input */
strm.next_in = cpack;
/* Length of input in bytes */
strm.avail_in = len;
LOG((3, "dec_aec: avail_in = %d", strm.avail_in));
/* Pointer to output buffer */
strm.next_out = cfld;
/* Length of output buffer in bytes */
strm.avail_out = (size_t)cfldlen;
/* Decode. */
ret = aec_buffer_decode(&strm);
LOG((3, "dec_aec: return from aec_buffer_encode = %d", ret));
if (ret == AEC_OK)
ret = strm.total_out;
return ret;
}
int
enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
{
struct aec_stream strm;
int ret = 0;
/* Define bits per sample */
strm.bits_per_sample = nbits;
LOG((3, "enc_aec: bits_per_sample = %d", strm.bits_per_sample));
/* Define a block size */
LOG((3, "enc_aec: block_size = %d", block_size));
strm.block_size = block_size;
/* Define the reference sample interval */
LOG((3, "enc_aec: rsi = %d", rsi));
strm.rsi = rsi;
/* Define the AEC compression flags. */
strm.flags = flags;
LOG((3, "enc_aec: flags = %d", strm.flags));
/* Pointer to input */
strm.next_in = data;
/* Length of input in bytes */
strm.avail_in = ctemplen;
LOG((3, "enc_aec: avail_in = %d", strm.avail_in));
/* Pointer to output buffer */
strm.next_out = aecbuf;
/* Length of output buffer in bytes */
strm.avail_out = (size_t)aecbuflen;
/* Encode into AEC. */
ret = aec_buffer_encode(&strm);
LOG((3, "enc_aec: return from aec_buffer_encode = %d", ret));
if (ret == AEC_OK)
ret = strm.total_out;
return ret;
}
enc_aec
int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
Encode data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:108
dec_aec
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
Decode an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:38
g2int
int64_t g2int
Long integer type.
Definition grib2.h:32
grib2_int.h
Header file with internal function prototypes NCEPLIBS-g2c library.
LOG
#define LOG(e)
Ignore logging to stdout.
Definition grib2_int.h:428