NCEPLIBS-g2c 2.0.0
Loading...
Searching...
No Matches
decenc_aec.c
Go to the documentation of this file.
1
6#include "grib2_int.h"
7#include <libaec.h>
8#include <stdint.h>
9#include <stdio.h>
10
37int
38dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
39 g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
40{
41 struct aec_stream strm;
42 int ret = 0;
43
44 /* Define bits per sample */
45 strm.bits_per_sample = nbits;
46 LOG((3, "dec_aec: bits_per_sample = %d", strm.bits_per_sample));
47
48 /* Define a block size */
49 LOG((3, "dec_aec: block_size = %d", block_size));
50 strm.block_size = block_size;
51
52 /* Define the reference sample interval */
53 LOG((3, "dec_aec: rsi = %d", rsi));
54 strm.rsi = rsi;
55
56 /* Define the AEC compression flags. */
57 strm.flags = flags;
58 LOG((3, "dec_aec: flags = %d", strm.flags));
59
60 /* Pointer to input */
61 strm.next_in = cpack;
62
63 /* Length of input in bytes */
64 strm.avail_in = len;
65 LOG((3, "dec_aec: avail_in = %d", strm.avail_in));
66
67 /* Pointer to output buffer */
68 strm.next_out = cfld;
69
70 /* Length of output buffer in bytes */
71 strm.avail_out = (size_t)cfldlen;
72
73 /* Decode. */
74 ret = aec_buffer_decode(&strm);
75 LOG((3, "dec_aec: return from aec_buffer_encode = %d", ret));
76 if (ret == AEC_OK)
77 ret = strm.total_out;
78
79 return ret;
80}
81
107int
108enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
109 g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
110{
111 struct aec_stream strm;
112 int ret = 0;
113
114 /* Define bits per sample */
115 strm.bits_per_sample = nbits;
116 LOG((3, "enc_aec: bits_per_sample = %d", strm.bits_per_sample));
117
118 /* Define a block size */
119 LOG((3, "enc_aec: block_size = %d", block_size));
120 strm.block_size = block_size;
121
122 /* Define the reference sample interval */
123 LOG((3, "enc_aec: rsi = %d", rsi));
124 strm.rsi = rsi;
125
126 /* Define the AEC compression flags. */
127 strm.flags = flags;
128 LOG((3, "enc_aec: flags = %d", strm.flags));
129
130 /* Pointer to input */
131 strm.next_in = data;
132
133 /* Length of input in bytes */
134 strm.avail_in = ctemplen;
135 LOG((3, "enc_aec: avail_in = %d", strm.avail_in));
136
137 /* Pointer to output buffer */
138 strm.next_out = aecbuf;
139
140 /* Length of output buffer in bytes */
141 strm.avail_out = (size_t)aecbuflen;
142
143 /* Encode into AEC. */
144 ret = aec_buffer_encode(&strm);
145 LOG((3, "enc_aec: return from aec_buffer_encode = %d", ret));
146 if (ret == AEC_OK)
147 ret = strm.total_out;
148
149 return ret;
150}
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
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
int64_t g2int
Long integer type.
Definition grib2.h:32
Header file with internal function prototypes NCEPLIBS-g2c library.
#define LOG(e)
Ignore logging to stdout.
Definition grib2_int.h:428