| 519 | } |
| 520 | |
| 521 | static int decode_frame_header(AVCodecContext *avctx, |
| 522 | const uint8_t *data, int size, int *ref) |
| 523 | { |
| 524 | VP9Context *s = avctx->priv_data; |
| 525 | int c, i, j, k, l, m, n, w, h, max, size2, ret, sharp; |
| 526 | int last_invisible; |
| 527 | const uint8_t *data2; |
| 528 | int changed; |
| 529 | |
| 530 | /* general header */ |
| 531 | if ((ret = init_get_bits8(&s->gb, data, size)) < 0) { |
| 532 | av_log(avctx, AV_LOG_ERROR, "Failed to initialize bitstream reader\n"); |
| 533 | return ret; |
| 534 | } |
| 535 | if (get_bits(&s->gb, 2) != 0x2) { // frame marker |
| 536 | av_log(avctx, AV_LOG_ERROR, "Invalid frame marker\n"); |
| 537 | return AVERROR_INVALIDDATA; |
| 538 | } |
| 539 | avctx->profile = get_bits1(&s->gb); |
| 540 | avctx->profile |= get_bits1(&s->gb) << 1; |
| 541 | if (avctx->profile == 3) avctx->profile += get_bits1(&s->gb); |
| 542 | if (avctx->profile > 3) { |
| 543 | av_log(avctx, AV_LOG_ERROR, "Profile %d is not yet supported\n", avctx->profile); |
| 544 | return AVERROR_INVALIDDATA; |
| 545 | } |
| 546 | s->s.h.profile = avctx->profile; |
| 547 | if (get_bits1(&s->gb)) { |
| 548 | *ref = get_bits(&s->gb, 3); |
| 549 | return 0; |
| 550 | } |
| 551 | |
| 552 | s->last_keyframe = s->s.h.keyframe; |
| 553 | s->s.h.keyframe = !get_bits1(&s->gb); |
| 554 | |
| 555 | last_invisible = s->s.h.invisible; |
| 556 | s->s.h.invisible = !get_bits1(&s->gb); |
| 557 | s->s.h.errorres = get_bits1(&s->gb); |
| 558 | s->s.h.use_last_frame_mvs = !s->s.h.errorres && !last_invisible; |
| 559 | |
| 560 | if (s->s.h.keyframe) { |
| 561 | if (get_bits(&s->gb, 24) != VP9_SYNCCODE) { // synccode |
| 562 | av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n"); |
| 563 | return AVERROR_INVALIDDATA; |
| 564 | } |
| 565 | if ((ret = read_colorspace_details(avctx)) < 0) |
| 566 | return ret; |
| 567 | // for profile 1, here follows the subsampling bits |
| 568 | s->s.h.refreshrefmask = 0xff; |
| 569 | w = get_bits(&s->gb, 16) + 1; |
| 570 | h = get_bits(&s->gb, 16) + 1; |
| 571 | if (get_bits1(&s->gb)) // display size |
| 572 | skip_bits(&s->gb, 32); |
| 573 | } else { |
| 574 | s->s.h.intraonly = s->s.h.invisible ? get_bits1(&s->gb) : 0; |
| 575 | s->s.h.resetctx = s->s.h.errorres ? 0 : get_bits(&s->gb, 2); |
| 576 | if (s->s.h.intraonly) { |
| 577 | if (get_bits(&s->gb, 24) != VP9_SYNCCODE) { // synccode |
| 578 | av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n"); |
no test coverage detected