MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ls_get_code_runterm

Function ls_get_code_runterm

libavcodec/jpeglsdec.c:184–227  ·  view source on GitHub ↗

* Get Golomb code, decode it and update state for run termination */

Source from the content-addressed store, hash-verified

182 * Get Golomb code, decode it and update state for run termination
183 */
184static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
185 int RItype, int limit_add)
186{
187 int k, ret, temp, map;
188 int Q = 365 + RItype;
189
190 temp = state->A[Q];
191 if (RItype)
192 temp += state->N[Q] >> 1;
193
194 for (k = 0; ((unsigned)state->N[Q] << k) < temp; k++)
195 ;
196
197#ifdef JLS_BROKEN
198 if (!show_bits_long(gb, 32))
199 return -1;
200#endif
201 ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
202 state->qbpp);
203 if (ret < 0)
204 return -0x10000;
205
206 /* decode mapped error */
207 map = 0;
208 if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
209 map = 1;
210 ret += RItype + map;
211
212 if (ret & 1) {
213 ret = map - (ret + 1 >> 1);
214 state->B[Q]++;
215 } else {
216 ret = ret >> 1;
217 }
218
219 if (FFABS(ret) > 0xFFFF)
220 return -0x10000;
221 /* update state */
222 state->A[Q] += FFABS(ret) - RItype;
223 ret *= state->twonear;
224 ff_jpegls_downscale_state(state, Q);
225
226 return ret;
227}
228
229/**
230 * Decode one line of image

Callers 1

ls_decode_lineFunction · 0.85

Calls 3

show_bits_longFunction · 0.85
get_ur_golomb_jpeglsFunction · 0.85

Tested by

no test coverage detected