5 * Copyright 2012 - 2016
7 * Mathis Rosenhauer, Moritz Hanke, Joerg Behrens
8 * Deutsches Klimarechenzentrum GmbH
10 * 20146 Hamburg Germany
13 * Max-Planck-Institut fuer Meteorologie
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above
27 * copyright notice, this list of conditions and the following
28 * disclaimer in the documentation and/or other materials provided
29 * with the distribution.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42 * OF THE POSSIBILITY OF SUCH DAMAGE.
44 * @section DESCRIPTION
46 * Adaptive Entropy Encoder
47 * Based on CCSDS documents 121.0-B-2 and 120.0-G-3
62 #define MIN(a, b) (((a) < (b))? (a): (b))
64 /* Maximum CDS length in bytes: 5 bits ID, 64 * 32 bits samples, 7
65 * bits carry from previous CDS */
66 #define CDSLEN ((5 + 64 * 32 + 7 + 7) / 8)
68 /* Marker for Remainder Of Segment condition in zero block encoding */
71 struct internal_state {
72 int (*mode)(struct aec_stream *);
73 uint32_t (*get_sample)(struct aec_stream *);
74 void (*get_rsi)(struct aec_stream *);
75 void (*preprocess)(struct aec_stream *);
77 /* bit length of code option identification key */
80 /* minimum integer for preprocessing */
83 /* maximum integer for preprocessing */
88 /* RSI blocks of preprocessed input */
91 /* RSI blocks of input */
94 /* remaining blocks in buffer */
97 /* current (preprocessed) input block */
100 /* reference sample interval in byte */
103 /* current Coded Data Set output */
106 /* buffer for one CDS (only used if strm->next_out cannot hold
108 uint8_t cds_buf[CDSLEN];
110 /* cds points to strm->next_out (1) or cds_buf (0) */
113 /* Free bits (LSB) in output buffer or accumulator */
116 /* length of reference sample in current block i.e. 0 or 1
117 * depending on whether the block has a reference sample or not */
120 /* reference sample stored here for performance reasons */
123 /* current zero block has a reference sample */
126 /* reference sample of zero block */
127 uint32_t zero_ref_sample;
129 /* storage size of samples in bytes */
130 uint32_t bytes_per_sample;
132 /* number of contiguous zero blocks */
135 /* 1 if this is the first non-zero block after one or more zero
139 /* splitting position */
142 /* maximum number for k depending on id_len */
145 /* flush option copied from argument */
148 /* 1 if flushing was successful */
151 /* length of uncompressed CDS */
155 #endif /* ENCODE_H */