NCEPLIBS-g2c  1.8.0
decenc_aec.c
Go to the documentation of this file.
1 
12 #include <stdio.h>
13 #include <stdint.h>
14 #include <libaec.h>
15 #include "grib2_int.h"
16 
43 int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
44  g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
45 {
46  struct aec_stream strm;
47  int ret = 0;
48 
49  /* Define bits per sample */
50  strm.bits_per_sample = nbits;
51  LOG((3, "dec_aec: bits_per_sample = %d",strm.bits_per_sample));
52 
53  /* Define a block size */
54  LOG((3, "dec_aec: block_size = %d",block_size));
55  strm.block_size = block_size;
56 
57  /* Define the reference sample interval */
58  LOG((3, "dec_aec: rsi = %d",rsi));
59  strm.rsi = rsi;
60 
61  /* Define the AEC compression flags. */
62  strm.flags = flags;
63  LOG((3, "dec_aec: flags = %d",strm.flags));
64 
65  /* Pointer to input */
66  strm.next_in = cpack;
67 
68  /* Length of input in bytes */
69  strm.avail_in = len;
70  LOG((3, "dec_aec: avail_in = %d",strm.avail_in));
71 
72  /* Pointer to output buffer */
73  strm.next_out = cfld;
74 
75  /* Length of output buffer in bytes */
76  strm.avail_out = (size_t) cfldlen;
77 
78  /* Decode. */
79  ret = aec_buffer_decode(&strm);
80  LOG((3, "dec_aec: return from aec_buffer_encode = %d", ret));
81  if (ret == AEC_OK) ret = strm.total_out;
82 
83  return ret;
84 }
85 
111 int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
112  g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
113 {
114  struct aec_stream strm;
115  int ret = 0;
116 
117  /* Define bits per sample */
118  strm.bits_per_sample = nbits;
119  LOG((3, "enc_aec: bits_per_sample = %d",strm.bits_per_sample));
120 
121  /* Define a block size */
122  LOG((3, "enc_aec: block_size = %d",block_size));
123  strm.block_size = block_size;
124 
125  /* Define the reference sample interval */
126  LOG((3, "enc_aec: rsi = %d",rsi));
127  strm.rsi = rsi;
128 
129  /* Define the AEC compression flags. */
130  strm.flags = flags;
131  LOG((3, "enc_aec: flags = %d",strm.flags));
132 
133  /* Pointer to input */
134  strm.next_in = data;
135 
136  /* Length of input in bytes */
137  strm.avail_in = ctemplen;
138  LOG((3, "enc_aec: avail_in = %d",strm.avail_in));
139 
140  /* Pointer to output buffer */
141  strm.next_out = aecbuf;
142 
143  /* Length of output buffer in bytes */
144  strm.avail_out = (size_t) aecbuflen;
145 
146  /* Encode into AEC. */
147  ret = aec_buffer_encode(&strm);
148  LOG((3, "enc_aec: return from aec_buffer_encode = %d", ret));
149  if (ret == AEC_OK) ret = strm.total_out;
150 
151  return ret;
152 }
int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
This Function encodes data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition: decenc_aec.c:111
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
This Function decodes an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition: decenc_aec.c:43
int64_t g2int
Long integer type.
Definition: grib2.h:33
Header file with internal function prototypes NCEPLIBS-g2c library.
#define LOG(e)
Ignore logging to stdout.
Definition: grib2_int.h:426