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

Function mss2_decode_frame

libavcodec/mss2.c:506–808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504#define ARITH2_PADDING 2
505
506static int mss2_decode_frame(AVCodecContext *avctx, AVFrame *frame,
507 int *got_frame, AVPacket *avpkt)
508{
509 const uint8_t *buf = avpkt->data;
510 int buf_size = avpkt->size;
511 MSS2Context *ctx = avctx->priv_data;
512 MSS12Context *c = &ctx->c;
513 GetBitContext gb;
514 GetByteContext gB;
515 ArithCoder acoder;
516
517 int keyframe, has_wmv9, has_mv, is_rle, is_555, ret;
518
519 struct Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;
520 struct Rectangle2 draw;
521 int used_rects = 0, i, implicit_rect = 0, wmv9_mask = -1;
522
523 if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
524 return ret;
525
526 if (keyframe = get_bits1(&gb))
527 skip_bits(&gb, 7);
528 has_wmv9 = get_bits1(&gb);
529 has_mv = keyframe ? 0 : get_bits1(&gb);
530 is_rle = get_bits1(&gb);
531 is_555 = is_rle && get_bits1(&gb);
532 if (c->slice_split > 0)
533 ctx->split_position = c->slice_split;
534 else if (c->slice_split < 0) {
535 if (get_bits1(&gb)) {
536 if (get_bits1(&gb)) {
537 if (get_bits1(&gb))
538 ctx->split_position = get_bits(&gb, 16);
539 else
540 ctx->split_position = get_bits(&gb, 12);
541 } else
542 ctx->split_position = get_bits(&gb, 8) << 4;
543 } else {
544 if (keyframe)
545 ctx->split_position = avctx->height / 2;
546 }
547 } else
548 ctx->split_position = avctx->height;
549
550 if (c->slice_split && (ctx->split_position < 1 - is_555 ||
551 ctx->split_position > avctx->height - 1))
552 return AVERROR_INVALIDDATA;
553
554 align_get_bits(&gb);
555 buf += get_bits_count(&gb) >> 3;
556 buf_size -= get_bits_count(&gb) >> 3;
557
558 if (buf_size < 1)
559 return AVERROR_INVALIDDATA;
560
561 if (is_555 && (has_wmv9 || has_mv || c->slice_split && ctx->split_position))
562 return AVERROR_INVALIDDATA;
563

Callers

nothing calls this directly

Calls 15

init_get_bits8Function · 0.85
get_bits1Function · 0.85
skip_bitsFunction · 0.85
align_get_bitsFunction · 0.85
get_bits_countFunction · 0.85
av_frame_unrefFunction · 0.85
bytestream2_initFunction · 0.85
arith2_initFunction · 0.85
arith2_get_numberFunction · 0.85
av_logFunction · 0.85
decode_pal_v2Function · 0.85

Tested by

no test coverage detected