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