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

Function read_dcs

libavcodec/bink.c:503–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501#define DC_START_BITS 11
502
503static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,
504 int start_bits, int has_sign)
505{
506 int i, j, len, len2, bsize, sign, v, v2;
507 int16_t *dst = (int16_t*)b->cur_dec;
508 int16_t *dst_end = (int16_t*)b->data_end;
509
510 CHECK_READ_VAL(gb, b, len);
511 if (get_bits_left(gb) < start_bits - has_sign)
512 return AVERROR_INVALIDDATA;
513 v = get_bits(gb, start_bits - has_sign);
514 if (v && has_sign) {
515 sign = -get_bits1(gb);
516 v = (v ^ sign) - sign;
517 }
518 if (dst_end - dst < 1)
519 return AVERROR_INVALIDDATA;
520 *dst++ = v;
521 len--;
522 for (i = 0; i < len; i += 8) {
523 len2 = FFMIN(len - i, 8);
524 if (dst_end - dst < len2)
525 return AVERROR_INVALIDDATA;
526 bsize = get_bits(gb, 4);
527 if (bsize) {
528 for (j = 0; j < len2; j++) {
529 v2 = get_bits(gb, bsize);
530 if (v2) {
531 sign = -get_bits1(gb);
532 v2 = (v2 ^ sign) - sign;
533 }
534 v += v2;
535 *dst++ = v;
536 if (v < -32768 || v > 32767) {
537 av_log(avctx, AV_LOG_ERROR, "DC value went out of bounds: %d\n", v);
538 return AVERROR_INVALIDDATA;
539 }
540 }
541 } else {
542 for (j = 0; j < len2; j++)
543 *dst++ = v;
544 }
545 }
546
547 b->cur_dec = (uint8_t*)dst;
548 return 0;
549}
550
551/**
552 * Retrieve next value from bundle.

Callers 1

bink_decode_planeFunction · 0.85

Calls 4

get_bits_leftFunction · 0.85
get_bits1Function · 0.85
av_logFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected