Lines Matching refs:h
456 static inline void store_mvs(AVSContext *h) in store_mvs() argument
458 h->col_mv[h->mbidx * 4 + 0] = h->mv[MV_FWD_X0]; in store_mvs()
459 h->col_mv[h->mbidx * 4 + 1] = h->mv[MV_FWD_X1]; in store_mvs()
460 h->col_mv[h->mbidx * 4 + 2] = h->mv[MV_FWD_X2]; in store_mvs()
461 h->col_mv[h->mbidx * 4 + 3] = h->mv[MV_FWD_X3]; in store_mvs()
464 static inline void mv_pred_direct(AVSContext *h, cavs_vector *pmv_fw, in mv_pred_direct() argument
468 unsigned den = h->direct_den[col_mv->ref]; in mv_pred_direct()
471 pmv_fw->dist = h->dist[1]; in mv_pred_direct()
472 pmv_bw->dist = h->dist[0]; in mv_pred_direct()
483 static inline void mv_pred_sym(AVSContext *h, cavs_vector *src, in mv_pred_sym() argument
489 dst->x = -((src->x * h->sym_factor + 256) >> 9); in mv_pred_sym()
490 dst->y = -((src->y * h->sym_factor + 256) >> 9); in mv_pred_sym()
492 dst->dist = h->dist[0]; in mv_pred_sym()
516 static inline int dequant(AVSContext *h, int16_t *level_buf, uint8_t *run_buf, in dequant() argument
521 const uint8_t *scantab = h->scantable.permutated; in dequant()
527 av_log(h->avctx, AV_LOG_ERROR, in dequant()
529 h->cur.poc, h->mbx, h->mby); in dequant()
546 static int decode_residual_block(AVSContext *h, GetBitContext *gb, in decode_residual_block() argument
554 int16_t *block = h->block; in decode_residual_block()
561 av_log(h->avctx, AV_LOG_ERROR, "run %d is too large\n", run); in decode_residual_block()
566 av_log(h->avctx, AV_LOG_ERROR, "esc_code invalid\n"); in decode_residual_block()
585 if ((ret = dequant(h, level_buf, run_buf, block, dequant_mul[qp], in decode_residual_block()
588 h->cdsp.cavs_idct8_add(dst, block, stride); in decode_residual_block()
589 h->bdsp.clear_block(block); in decode_residual_block()
594 static inline int decode_residual_chroma(AVSContext *h) in decode_residual_chroma() argument
596 if (h->cbp & (1 << 4)) { in decode_residual_chroma()
597 int ret = decode_residual_block(h, &h->gb, chroma_dec, 0, in decode_residual_chroma()
598 ff_cavs_chroma_qp[h->qp], h->cu, h->c_stride); in decode_residual_chroma()
602 if (h->cbp & (1 << 5)) { in decode_residual_chroma()
603 int ret = decode_residual_block(h, &h->gb, chroma_dec, 0, in decode_residual_chroma()
604 ff_cavs_chroma_qp[h->qp], h->cv, h->c_stride); in decode_residual_chroma()
611 static inline int decode_residual_inter(AVSContext *h) in decode_residual_inter() argument
616 int cbp = get_ue_golomb(&h->gb); in decode_residual_inter()
618 av_log(h->avctx, AV_LOG_ERROR, "illegal inter cbp %d\n", cbp); in decode_residual_inter()
621 h->cbp = cbp_tab[cbp][1]; in decode_residual_inter()
624 if (h->cbp && !h->qp_fixed) in decode_residual_inter()
625 h->qp = (h->qp + (unsigned)get_se_golomb(&h->gb)) & 63; in decode_residual_inter()
627 if (h->cbp & (1 << block)) in decode_residual_inter()
628 decode_residual_block(h, &h->gb, inter_dec, 0, h->qp, in decode_residual_inter()
629 h->cy + h->luma_scan[block], h->l_stride); in decode_residual_inter()
630 decode_residual_chroma(h); in decode_residual_inter()
641 static inline void set_mv_intra(AVSContext *h) in set_mv_intra() argument
643 h->mv[MV_FWD_X0] = ff_cavs_intra_mv; in set_mv_intra()
644 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); in set_mv_intra()
645 h->mv[MV_BWD_X0] = ff_cavs_intra_mv; in set_mv_intra()
646 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); in set_mv_intra()
647 if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) in set_mv_intra()
648 h->col_type_base[h->mbidx] = I_8X8; in set_mv_intra()
651 static int decode_mb_i(AVSContext *h, int cbp_code) in decode_mb_i() argument
653 GetBitContext *gb = &h->gb; in decode_mb_i()
661 ff_cavs_init_mb(h); in decode_mb_i()
668 nA = h->pred_mode_Y[pos - 1]; in decode_mb_i()
669 nB = h->pred_mode_Y[pos - 3]; in decode_mb_i()
677 h->pred_mode_Y[pos] = predpred; in decode_mb_i()
681 av_log(h->avctx, AV_LOG_ERROR, "illegal intra chroma pred mode\n"); in decode_mb_i()
684 ff_cavs_modify_mb_i(h, &pred_mode_uv); in decode_mb_i()
687 if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) in decode_mb_i()
690 av_log(h->avctx, AV_LOG_ERROR, "illegal intra cbp\n"); in decode_mb_i()
693 h->cbp = cbp_tab[cbp_code][0]; in decode_mb_i()
694 if (h->cbp && !h->qp_fixed) in decode_mb_i()
695 h->qp = (h->qp + (unsigned)get_se_golomb(gb)) & 63; //qp_delta in decode_mb_i()
699 d = h->cy + h->luma_scan[block]; in decode_mb_i()
700 ff_cavs_load_intra_pred_luma(h, top, &left, block); in decode_mb_i()
701 h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]] in decode_mb_i()
702 (d, top, left, h->l_stride); in decode_mb_i()
703 if (h->cbp & (1<<block)) { in decode_mb_i()
704 ret = decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride); in decode_mb_i()
711 ff_cavs_load_intra_pred_chroma(h); in decode_mb_i()
712 h->intra_pred_c[pred_mode_uv](h->cu, &h->top_border_u[h->mbx * 10], in decode_mb_i()
713 h->left_border_u, h->c_stride); in decode_mb_i()
714 h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx * 10], in decode_mb_i()
715 h->left_border_v, h->c_stride); in decode_mb_i()
717 ret = decode_residual_chroma(h); in decode_mb_i()
720 ff_cavs_filter(h, I_8X8); in decode_mb_i()
721 set_mv_intra(h); in decode_mb_i()
725 static inline void set_intra_mode_default(AVSContext *h) in set_intra_mode_default() argument
727 if (h->stream_revision > 0) { in set_intra_mode_default()
728 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL; in set_intra_mode_default()
729 h->top_pred_Y[h->mbx * 2 + 0] = h->top_pred_Y[h->mbx * 2 + 1] = NOT_AVAIL; in set_intra_mode_default()
731 h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP; in set_intra_mode_default()
732 h->top_pred_Y[h->mbx * 2 + 0] = h->top_pred_Y[h->mbx * 2 + 1] = INTRA_L_LP; in set_intra_mode_default()
736 static void decode_mb_p(AVSContext *h, enum cavs_mb mb_type) in decode_mb_p() argument
738 GetBitContext *gb = &h->gb; in decode_mb_p()
741 ff_cavs_init_mb(h); in decode_mb_p()
744 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_PSKIP, BLK_16X16, 0); in decode_mb_p()
747 ref[0] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
748 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, ref[0]); in decode_mb_p()
751 ref[0] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
752 ref[2] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
753 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, ref[0]); in decode_mb_p()
754 ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, ref[2]); in decode_mb_p()
757 ref[0] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
758 ref[1] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
759 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, ref[0]); in decode_mb_p()
760 ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT, BLK_8X16, ref[1]); in decode_mb_p()
763 ref[0] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
764 ref[1] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
765 ref[2] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
766 ref[3] = h->ref_flag ? 0 : get_bits1(gb); in decode_mb_p()
767 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_MEDIAN, BLK_8X8, ref[0]); in decode_mb_p()
768 ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_MEDIAN, BLK_8X8, ref[1]); in decode_mb_p()
769 ff_cavs_mv(h, MV_FWD_X2, MV_FWD_X1, MV_PRED_MEDIAN, BLK_8X8, ref[2]); in decode_mb_p()
770 ff_cavs_mv(h, MV_FWD_X3, MV_FWD_X0, MV_PRED_MEDIAN, BLK_8X8, ref[3]); in decode_mb_p()
772 ff_cavs_inter(h, mb_type); in decode_mb_p()
773 set_intra_mode_default(h); in decode_mb_p()
774 store_mvs(h); in decode_mb_p()
776 decode_residual_inter(h); in decode_mb_p()
777 ff_cavs_filter(h, mb_type); in decode_mb_p()
778 h->col_type_base[h->mbidx] = mb_type; in decode_mb_p()
781 static int decode_mb_b(AVSContext *h, enum cavs_mb mb_type) in decode_mb_b() argument
787 ff_cavs_init_mb(h); in decode_mb_b()
790 h->mv[MV_FWD_X0] = ff_cavs_dir_mv; in decode_mb_b()
791 set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); in decode_mb_b()
792 h->mv[MV_BWD_X0] = ff_cavs_dir_mv; in decode_mb_b()
793 set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); in decode_mb_b()
797 if (!h->col_type_base[h->mbidx]) { in decode_mb_b()
799 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1); in decode_mb_b()
800 ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0); in decode_mb_b()
804 mv_pred_direct(h, &h->mv[mv_scan[block]], in decode_mb_b()
805 &h->col_mv[h->mbidx * 4 + block]); in decode_mb_b()
808 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); in decode_mb_b()
811 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); in decode_mb_b()
812 mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X16); in decode_mb_b()
815 ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0); in decode_mb_b()
821 sub_type[block] = get_bits(&h->gb, 2); in decode_mb_b()
825 if (!h->col_type_base[h->mbidx]) { in decode_mb_b()
831 h->mv[TMP_UNUSED_INX ] = h->mv[MV_FWD_X0 ]; in decode_mb_b()
832 h->mv[TMP_UNUSED_INX + MV_BWD_OFFS] = h->mv[MV_FWD_X0 + MV_BWD_OFFS]; in decode_mb_b()
834 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, in decode_mb_b()
836 ff_cavs_mv(h, MV_FWD_X0+MV_BWD_OFFS, in decode_mb_b()
841 h->mv[flags ] = h->mv[MV_FWD_X0 ]; in decode_mb_b()
842 h->mv[flags + MV_BWD_OFFS] = h->mv[MV_FWD_X0 + MV_BWD_OFFS]; in decode_mb_b()
843 h->mv[MV_FWD_X0 ] = h->mv[TMP_UNUSED_INX ]; in decode_mb_b()
844 h->mv[MV_FWD_X0 + MV_BWD_OFFS] = h->mv[TMP_UNUSED_INX + MV_BWD_OFFS]; in decode_mb_b()
848 h->mv[mv_scan[block] ] = h->mv[flags ]; in decode_mb_b()
849 h->mv[mv_scan[block] + MV_BWD_OFFS] = h->mv[flags + MV_BWD_OFFS]; in decode_mb_b()
852 mv_pred_direct(h, &h->mv[mv_scan[block]], in decode_mb_b()
853 &h->col_mv[h->mbidx * 4 + block]); in decode_mb_b()
856 ff_cavs_mv(h, mv_scan[block], mv_scan[block] - 3, in decode_mb_b()
860 ff_cavs_mv(h, mv_scan[block], mv_scan[block] - 3, in decode_mb_b()
862 mv_pred_sym(h, &h->mv[mv_scan[block]], BLK_8X8); in decode_mb_b()
869 ff_cavs_mv(h, mv_scan[block] + MV_BWD_OFFS, in decode_mb_b()
876 av_log(h->avctx, AV_LOG_ERROR, "Invalid mb_type %d in B frame\n", mb_type); in decode_mb_b()
883 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1); in decode_mb_b()
885 mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8); in decode_mb_b()
887 ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1); in decode_mb_b()
889 mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8); in decode_mb_b()
891 ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP, BLK_16X8, 0); in decode_mb_b()
893 ff_cavs_mv(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0); in decode_mb_b()
896 ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1); in decode_mb_b()
898 mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16); in decode_mb_b()
900 ff_cavs_mv(h, MV_FWD_X1, MV_FWD_C2, MV_PRED_TOPRIGHT, BLK_8X16, 1); in decode_mb_b()
902 mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16); in decode_mb_b()
904 ff_cavs_mv(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0); in decode_mb_b()
906 ff_cavs_mv(h, MV_BWD_X1, MV_BWD_C2, MV_PRED_TOPRIGHT, BLK_8X16, 0); in decode_mb_b()
909 ff_cavs_inter(h, mb_type); in decode_mb_b()
910 set_intra_mode_default(h); in decode_mb_b()
912 decode_residual_inter(h); in decode_mb_b()
913 ff_cavs_filter(h, mb_type); in decode_mb_b()
924 static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) in decode_slice_header() argument
926 if (h->stc > 0xAF) in decode_slice_header()
927 av_log(h->avctx, AV_LOG_ERROR, "unexpected start code 0x%02x\n", h->stc); in decode_slice_header()
929 if (h->stc >= h->mb_height) { in decode_slice_header()
930 av_log(h->avctx, AV_LOG_ERROR, "stc 0x%02x is too large\n", h->stc); in decode_slice_header()
934 h->mby = h->stc; in decode_slice_header()
935 h->mbidx = h->mby * h->mb_width; in decode_slice_header()
938 h->flags &= ~(B_AVAIL | C_AVAIL); in decode_slice_header()
939 if (!h->pic_qp_fixed) { in decode_slice_header()
940 h->qp_fixed = get_bits1(gb); in decode_slice_header()
941 h->qp = get_bits(gb, 6); in decode_slice_header()
944 if ((h->cur.f->pict_type != AV_PICTURE_TYPE_I) || in decode_slice_header()
945 (!h->pic_structure && h->mby >= h->mb_width / 2)) in decode_slice_header()
947 av_log(h->avctx, AV_LOG_ERROR, in decode_slice_header()
953 static inline int check_for_slice(AVSContext *h) in check_for_slice() argument
955 GetBitContext *gb = &h->gb; in check_for_slice()
958 if (h->mbx) in check_for_slice()
966 h->stc = get_bits(gb, 8); in check_for_slice()
967 if (h->stc >= h->mb_height) in check_for_slice()
969 decode_slice_header(h, gb); in check_for_slice()
981 static int decode_pic(AVSContext *h) in decode_pic() argument
987 if (!h->top_qp) { in decode_pic()
988 av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n"); in decode_pic()
992 av_frame_unref(h->cur.f); in decode_pic()
994 skip_bits(&h->gb, 16);//bbv_dwlay in decode_pic()
995 if (h->stc == PIC_PB_START_CODE) { in decode_pic()
996 h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I; in decode_pic()
997 if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) { in decode_pic()
998 av_log(h->avctx, AV_LOG_ERROR, "illegal picture type\n"); in decode_pic()
1002 if (!h->DPB[0].f->data[0] || in decode_pic()
1003 (!h->DPB[1].f->data[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B)) in decode_pic()
1006 h->cur.f->pict_type = AV_PICTURE_TYPE_I; in decode_pic()
1007 if (get_bits1(&h->gb)) in decode_pic()
1008 skip_bits(&h->gb, 24);//time_code in decode_pic()
1011 if (h->low_delay || !(show_bits(&h->gb, 9) & 1)) in decode_pic()
1012 h->stream_revision = 1; in decode_pic()
1014 else if (show_bits(&h->gb, 11) & 3) in decode_pic()
1015 h->stream_revision = 1; in decode_pic()
1016 if (h->stream_revision > 0) in decode_pic()
1017 skip_bits(&h->gb, 1); //marker_bit in decode_pic()
1020 ret = ff_get_buffer(h->avctx, h->cur.f, h->cur.f->pict_type == AV_PICTURE_TYPE_B ? in decode_pic()
1025 if (!h->edge_emu_buffer) { in decode_pic()
1026 int alloc_size = FFALIGN(FFABS(h->cur.f->linesize[0]) + 32, 32); in decode_pic()
1027 h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 24); in decode_pic()
1028 if (!h->edge_emu_buffer) in decode_pic()
1032 if ((ret = ff_cavs_init_pic(h)) < 0) in decode_pic()
1034 h->cur.poc = get_bits(&h->gb, 8) * 2; in decode_pic()
1037 if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) { in decode_pic()
1038 h->dist[0] = (h->cur.poc - h->DPB[0].poc) & 511; in decode_pic()
1040 h->dist[0] = (h->DPB[0].poc - h->cur.poc) & 511; in decode_pic()
1042 h->dist[1] = (h->cur.poc - h->DPB[1].poc) & 511; in decode_pic()
1043 h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0; in decode_pic()
1044 h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0; in decode_pic()
1045 if (h->cur.f->pict_type == AV_PICTURE_TYPE_B) { in decode_pic()
1046 h->sym_factor = h->dist[0] * h->scale_den[1]; in decode_pic()
1047 if (FFABS(h->sym_factor) > 32768) { in decode_pic()
1048 av_log(h->avctx, AV_LOG_ERROR, "sym_factor %d too large\n", h->sym_factor); in decode_pic()
1052 h->direct_den[0] = h->dist[0] ? 16384 / h->dist[0] : 0; in decode_pic()
1053 h->direct_den[1] = h->dist[1] ? 16384 / h->dist[1] : 0; in decode_pic()
1056 if (h->low_delay) in decode_pic()
1057 get_ue_golomb(&h->gb); //bbv_check_times in decode_pic()
1058 h->progressive = get_bits1(&h->gb); in decode_pic()
1059 h->pic_structure = 1; in decode_pic()
1060 if (!h->progressive) in decode_pic()
1061 h->pic_structure = get_bits1(&h->gb); in decode_pic()
1062 if (!h->pic_structure && h->stc == PIC_PB_START_CODE) in decode_pic()
1063 skip_bits1(&h->gb); //advanced_pred_mode_disable in decode_pic()
1064 skip_bits1(&h->gb); //top_field_first in decode_pic()
1065 skip_bits1(&h->gb); //repeat_first_field in decode_pic()
1066 h->pic_qp_fixed = in decode_pic()
1067 h->qp_fixed = get_bits1(&h->gb); in decode_pic()
1068 h->qp = get_bits(&h->gb, 6); in decode_pic()
1069 if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { in decode_pic()
1070 if (!h->progressive && !h->pic_structure) in decode_pic()
1071 skip_bits1(&h->gb);//what is this? in decode_pic()
1072 skip_bits(&h->gb, 4); //reserved bits in decode_pic()
1074 if (!(h->cur.f->pict_type == AV_PICTURE_TYPE_B && h->pic_structure == 1)) in decode_pic()
1075 h->ref_flag = get_bits1(&h->gb); in decode_pic()
1076 skip_bits(&h->gb, 4); //reserved bits in decode_pic()
1077 h->skip_mode_flag = get_bits1(&h->gb); in decode_pic()
1079 h->loop_filter_disable = get_bits1(&h->gb); in decode_pic()
1080 if (!h->loop_filter_disable && get_bits1(&h->gb)) { in decode_pic()
1081 h->alpha_offset = get_se_golomb(&h->gb); in decode_pic()
1082 h->beta_offset = get_se_golomb(&h->gb); in decode_pic()
1083 if ( h->alpha_offset < -64 || h->alpha_offset > 64 in decode_pic()
1084 || h-> beta_offset < -64 || h-> beta_offset > 64) { in decode_pic()
1085 h->alpha_offset = h->beta_offset = 0; in decode_pic()
1089 h->alpha_offset = h->beta_offset = 0; in decode_pic()
1093 if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { in decode_pic()
1095 check_for_slice(h); in decode_pic()
1096 ret = decode_mb_i(h, 0); in decode_pic()
1099 } while (ff_cavs_next_mb(h)); in decode_pic()
1100 } else if (h->cur.f->pict_type == AV_PICTURE_TYPE_P) { in decode_pic()
1102 if (check_for_slice(h)) in decode_pic()
1104 if (h->skip_mode_flag && (skip_count < 0)) { in decode_pic()
1105 if (get_bits_left(&h->gb) < 1) { in decode_pic()
1109 skip_count = get_ue_golomb(&h->gb); in decode_pic()
1111 if (h->skip_mode_flag && skip_count--) { in decode_pic()
1112 decode_mb_p(h, P_SKIP); in decode_pic()
1114 if (get_bits_left(&h->gb) < 1) { in decode_pic()
1118 mb_type = get_ue_golomb(&h->gb) + P_SKIP + h->skip_mode_flag; in decode_pic()
1120 ret = decode_mb_i(h, mb_type - P_8X8 - 1); in decode_pic()
1122 decode_mb_p(h, mb_type); in decode_pic()
1126 } while (ff_cavs_next_mb(h)); in decode_pic()
1129 if (check_for_slice(h)) in decode_pic()
1131 if (h->skip_mode_flag && (skip_count < 0)) { in decode_pic()
1132 if (get_bits_left(&h->gb) < 1) { in decode_pic()
1136 skip_count = get_ue_golomb(&h->gb); in decode_pic()
1138 if (h->skip_mode_flag && skip_count--) { in decode_pic()
1139 ret = decode_mb_b(h, B_SKIP); in decode_pic()
1141 if (get_bits_left(&h->gb) < 1) { in decode_pic()
1145 mb_type = get_ue_golomb(&h->gb) + B_SKIP + h->skip_mode_flag; in decode_pic()
1147 ret = decode_mb_i(h, mb_type - B_8X8 - 1); in decode_pic()
1149 ret = decode_mb_b(h, mb_type); in decode_pic()
1153 } while (ff_cavs_next_mb(h)); in decode_pic()
1156 if (ret >= 0 && h->cur.f->pict_type != AV_PICTURE_TYPE_B) { in decode_pic()
1157 av_frame_unref(h->DPB[1].f); in decode_pic()
1158 FFSWAP(AVSFrame, h->cur, h->DPB[1]); in decode_pic()
1159 FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]); in decode_pic()
1170 static int decode_seq_header(AVSContext *h) in decode_seq_header() argument
1176 h->profile = get_bits(&h->gb, 8); in decode_seq_header()
1177 h->level = get_bits(&h->gb, 8); in decode_seq_header()
1178 skip_bits1(&h->gb); //progressive sequence in decode_seq_header()
1180 width = get_bits(&h->gb, 14); in decode_seq_header()
1181 height = get_bits(&h->gb, 14); in decode_seq_header()
1182 if ((h->width || h->height) && (h->width != width || h->height != height)) { in decode_seq_header()
1183 avpriv_report_missing_feature(h->avctx, in decode_seq_header()
1188 av_log(h->avctx, AV_LOG_ERROR, "Dimensions invalid\n"); in decode_seq_header()
1191 skip_bits(&h->gb, 2); //chroma format in decode_seq_header()
1192 skip_bits(&h->gb, 3); //sample_precision in decode_seq_header()
1193 h->aspect_ratio = get_bits(&h->gb, 4); in decode_seq_header()
1194 frame_rate_code = get_bits(&h->gb, 4); in decode_seq_header()
1196 av_log(h->avctx, AV_LOG_WARNING, in decode_seq_header()
1201 skip_bits(&h->gb, 18); //bit_rate_lower in decode_seq_header()
1202 skip_bits1(&h->gb); //marker_bit in decode_seq_header()
1203 skip_bits(&h->gb, 12); //bit_rate_upper in decode_seq_header()
1204 h->low_delay = get_bits1(&h->gb); in decode_seq_header()
1206 ret = ff_set_dimensions(h->avctx, width, height); in decode_seq_header()
1210 h->width = width; in decode_seq_header()
1211 h->height = height; in decode_seq_header()
1212 h->mb_width = (h->width + 15) >> 4; in decode_seq_header()
1213 h->mb_height = (h->height + 15) >> 4; in decode_seq_header()
1214 h->avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_code]; in decode_seq_header()
1215 if (!h->top_qp) in decode_seq_header()
1216 return ff_cavs_init_top_lines(h); in decode_seq_header()
1222 AVSContext *h = avctx->priv_data; in cavs_flush() local
1223 h->got_keyframe = 0; in cavs_flush()
1229 AVSContext *h = avctx->priv_data; in cavs_decode_frame() local
1239 if (!h->low_delay && h->DPB[0].f->data[0]) { in cavs_decode_frame()
1241 av_frame_move_ref(data, h->DPB[0].f); in cavs_decode_frame()
1246 h->stc = 0; in cavs_decode_frame()
1253 if (!h->stc) in cavs_decode_frame()
1254 av_log(h->avctx, AV_LOG_WARNING, "no frame decoded\n"); in cavs_decode_frame()
1260 init_get_bits(&h->gb, buf_ptr, input_size); in cavs_decode_frame()
1261 decode_seq_header(h); in cavs_decode_frame()
1264 if (!h->got_keyframe) { in cavs_decode_frame()
1265 av_frame_unref(h->DPB[0].f); in cavs_decode_frame()
1266 av_frame_unref(h->DPB[1].f); in cavs_decode_frame()
1267 h->got_keyframe = 1; in cavs_decode_frame()
1276 if (!h->got_keyframe) in cavs_decode_frame()
1278 init_get_bits(&h->gb, buf_ptr, input_size); in cavs_decode_frame()
1279 h->stc = stc; in cavs_decode_frame()
1280 if (decode_pic(h)) in cavs_decode_frame()
1283 if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) { in cavs_decode_frame()
1284 if (h->DPB[!h->low_delay].f->data[0]) { in cavs_decode_frame()
1285 if ((ret = av_frame_ref(data, h->DPB[!h->low_delay].f)) < 0) in cavs_decode_frame()
1291 av_frame_move_ref(data, h->cur.f); in cavs_decode_frame()
1302 init_get_bits(&h->gb, buf_ptr, input_size); in cavs_decode_frame()
1303 decode_slice_header(h, &h->gb); in cavs_decode_frame()