Lines Matching refs:ctx
249 void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size)
255 ctx->x = AV_RB24(in);
258 ctx->x = AV_RB16(in);
261 ctx->x = *in;
265 ctx->in_buf = in + nbytes;
266 ctx->data_size = data_size - nbytes;
267 ctx->err = 0;
268 ctx->j = ELS_JOTS_PER_BYTE;
269 ctx->t = ELS_MAX;
270 ctx->diff = FFMIN(ELS_MAX - ctx->x,
279 static int els_import_byte(ElsDecCtx *ctx)
281 if (!ctx->data_size) {
282 ctx->err = AVERROR_EOF;
285 ctx->x = (ctx->x << 8) | *ctx->in_buf++;
286 ctx->data_size--;
287 ctx->j += ELS_JOTS_PER_BYTE;
288 ctx->t <<= 8;
293 int ff_els_decode_bit(ElsDecCtx *ctx, uint8_t *rung)
298 if (ctx->err)
301 z = pAllowable[ctx->j + Ladder[*rung].ALps];
302 ctx->t -= z;
303 ctx->diff -= z;
304 if (ctx->diff > 0)
307 if (ctx->t > ctx->x) { /* decode most probable symbol (MPS) */
308 ctx->j += Ladder[*rung].AMps;
309 while (ctx->t > pAllowable[ctx->j])
310 ctx->j++;
312 if (ctx->j <= 0) { /* MPS: import one byte from bytestream. */
313 ret = els_import_byte(ctx);
318 z = ctx->t;
322 ctx->x -= ctx->t;
323 ctx->t = z;
325 ctx->j += Ladder[*rung].ALps;
326 if (ctx->j <= 0) {
329 ret = els_import_byte(ctx);
332 if (ctx->j <= 0) {
335 ret = els_import_byte(ctx);
338 while (pAllowable[ctx->j - 1] >= z)
339 ctx->j--;
347 ctx->diff = FFMIN(z - ctx->x, z - pAllowable[ctx->j - 1]);
352 unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
357 if (ctx->err)
362 if (ff_els_decode_bit(ctx, &ur->prefix_rung[n]))
366 if (ctx->err || n >= ELS_EXPGOLOMB_LEN) {
367 ctx->err = AVERROR_INVALIDDATA;
379 ctx->err = AVERROR(ENOMEM);
396 ctx->err = av_reallocp(&ur->rem_rung_list,
399 if (ctx->err < 0) {
414 bit = ff_els_decode_bit(ctx, &rung_node->rung);
415 if (ctx->err)