MCPcopy Create free account
hub / github.com/LASzip/LASzip / done

Method done

src/arithmeticencoder.cpp:133–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void ArithmeticEncoder::done()
134{
135 if (outstream == 0) return;
136
137 U32 init_base = base; // done encoding: set final data bytes
138 BOOL another_byte = TRUE;
139
140 if (length > 2 * AC__MinLength) {
141 base += AC__MinLength; // base offset
142 length = AC__MinLength >> 1; // set new length for 1 more byte
143 }
144 else {
145 base += AC__MinLength >> 1; // base offset
146 length = AC__MinLength >> 9; // set new length for 2 more bytes
147 another_byte = FALSE;
148 }
149
150 if (init_base > base) propagate_carry(); // overflow = carry
151 renorm_enc_interval(); // renormalization = output last bytes
152
153 if (endbyte != endbuffer)
154 {
155 assert(outbyte < outbuffer + AC_BUFFER_SIZE);
156 outstream->putBytes(outbuffer + AC_BUFFER_SIZE, AC_BUFFER_SIZE);
157 }
158 U32 buffer_size = (U32)(outbyte - outbuffer);
159 if (buffer_size) outstream->putBytes(outbuffer, buffer_size);
160
161 // write two or three zero bytes to be in sync with the decoder's byte reads
162 outstream->putByte(0);
163 outstream->putByte(0);
164 if (another_byte) outstream->putByte(0);
165
166 outstream = 0;
167}
168
169ArithmeticBitModel* ArithmeticEncoder::createBitModel()
170{

Callers

nothing calls this directly

Calls 2

putBytesMethod · 0.45
putByteMethod · 0.45

Tested by

no test coverage detected