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

Function read_colors

libavcodec/bink.c:458–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458static int read_colors(GetBitContext *gb, Bundle *b, BinkContext *c)
459{
460 int t, sign, v;
461 const uint8_t *dec_end;
462
463 CHECK_READ_VAL(gb, b, t);
464 dec_end = b->cur_dec + t;
465 if (dec_end > b->data_end) {
466 av_log(c->avctx, AV_LOG_ERROR, "Too many color values\n");
467 return AVERROR_INVALIDDATA;
468 }
469 if (get_bits_left(gb) < 1)
470 return AVERROR_INVALIDDATA;
471 if (get_bits1(gb)) {
472 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
473 v = GET_HUFF(gb, b->tree);
474 v = (c->col_lastval << 4) | v;
475 if (c->version < 'i') {
476 sign = ((int8_t) v) >> 7;
477 v = ((v & 0x7F) ^ sign) - sign;
478 v += 0x80;
479 }
480 memset(b->cur_dec, v, t);
481 b->cur_dec += t;
482 } else {
483 while (b->cur_dec < dec_end) {
484 if (get_bits_left(gb) < 2)
485 return AVERROR_INVALIDDATA;
486 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
487 v = GET_HUFF(gb, b->tree);
488 v = (c->col_lastval << 4) | v;
489 if (c->version < 'i') {
490 sign = ((int8_t) v) >> 7;
491 v = ((v & 0x7F) ^ sign) - sign;
492 v += 0x80;
493 }
494 *b->cur_dec++ = v;
495 }
496 }
497 return 0;
498}
499
500/** number of bits used to store first DC value in bundle */
501#define DC_START_BITS 11

Callers 1

bink_decode_planeFunction · 0.85

Calls 3

av_logFunction · 0.85
get_bits_leftFunction · 0.85
get_bits1Function · 0.85

Tested by

no test coverage detected