Lines Matching refs:ctx

139 static MPP_RET m2vd_parser_init_ctx(M2VDParserContext *ctx, ParserCfg *cfg)  in m2vd_parser_init_ctx()  argument
145 M2VD_CHK_I(ctx); in m2vd_parser_init_ctx()
146 memset(ctx, 0, sizeof(*ctx)); in m2vd_parser_init_ctx()
148 ctx->cfg = cfg->cfg; in m2vd_parser_init_ctx()
149 ctx->dxva_ctx = mpp_calloc(M2VDDxvaParam, 1); in m2vd_parser_init_ctx()
150 ctx->bitread_ctx = mpp_calloc(BitReadCtx_t, 1); in m2vd_parser_init_ctx()
152 ctx->packet_slots = cfg->packet_slots; in m2vd_parser_init_ctx()
153 ctx->frame_slots = cfg->frame_slots; in m2vd_parser_init_ctx()
155 mpp_buf_slot_setup(ctx->frame_slots, 16); in m2vd_parser_init_ctx()
157 ctx->initFlag = 0; in m2vd_parser_init_ctx()
158 ctx->info_changed = 0; in m2vd_parser_init_ctx()
161 memset(&ctx->Framehead, 0, 3 * sizeof(M2VDFrameHead)); in m2vd_parser_init_ctx()
163 ctx->frame_ref0 = &ctx->Framehead[0]; in m2vd_parser_init_ctx()
164 ctx->frame_ref1 = &ctx->Framehead[1]; in m2vd_parser_init_ctx()
165 ctx->frame_cur = &ctx->Framehead[2]; in m2vd_parser_init_ctx()
167 mpp_frame_init(&ctx->Framehead[i].f); in m2vd_parser_init_ctx()
168 if (!ctx->Framehead[i].f) { in m2vd_parser_init_ctx()
172 ctx->Framehead[i].picCodingType = 0xffffffff; in m2vd_parser_init_ctx()
173 ctx->Framehead[i].slot_index = -1; in m2vd_parser_init_ctx()
176 ctx->mHwDecStatus = MPP_OK; in m2vd_parser_init_ctx()
178 ctx->resetFlag = 0; in m2vd_parser_init_ctx()
179 ctx->flush_dpb_eos = 0; in m2vd_parser_init_ctx()
180 ctx->pic_head.pre_temporal_reference = 0; in m2vd_parser_init_ctx()
181 ctx->pic_head.pre_picture_coding_type = 0; in m2vd_parser_init_ctx()
182 ctx->pic_head.picture_coding_type = 0; in m2vd_parser_init_ctx()
186 ctx->bitstream_sw_buf = mpp_calloc(RK_U8, M2VD_BUF_SIZE_BITMEM); in m2vd_parser_init_ctx()
187 mpp_packet_init(&ctx->input_packet, ctx->bitstream_sw_buf, M2VD_BUF_SIZE_BITMEM); in m2vd_parser_init_ctx()
189 ctx->qp_tab_sw_buf = mpp_calloc(RK_U8, M2VD_BUF_SIZE_QPTAB); in m2vd_parser_init_ctx()
190 ctx->seq_head.pIntra_table = ctx->qp_tab_sw_buf; in m2vd_parser_init_ctx()
191 ctx->seq_head.pInter_table = ctx->seq_head.pIntra_table + 64; in m2vd_parser_init_ctx()
193 ctx->MPEG2_Flag = 0; in m2vd_parser_init_ctx()
194 ctx->seq_ext_head.progressive_sequence = 1; in m2vd_parser_init_ctx()
195 ctx->pic_code_ext_head.progressive_frame = 1; in m2vd_parser_init_ctx()
196 ctx->pic_code_ext_head.picture_structure = M2VD_PIC_STRUCT_FRAME; in m2vd_parser_init_ctx()
197 ctx->pic_head.pre_picture_coding_type = M2VD_CODING_TYPE_D; in m2vd_parser_init_ctx()
198 ctx->top_first_cnt = 0; in m2vd_parser_init_ctx()
199 ctx->bottom_first_cnt = 0; in m2vd_parser_init_ctx()
200 ctx->pic_code_ext_head.frame_pred_frame_dct = 1; in m2vd_parser_init_ctx()
201 ctx->seq_ext_head.chroma_format = 1; in m2vd_parser_init_ctx()
202 ctx->seq_disp_ext_head.matrix_coefficients = 5; in m2vd_parser_init_ctx()
203 ctx->pre_pts_27M = 0; in m2vd_parser_init_ctx()
204 ctx->maxFrame_inGOP = 0; in m2vd_parser_init_ctx()
205 ctx->preframe_period = 0; in m2vd_parser_init_ctx()
206 ctx->mHeaderDecFlag = 0; in m2vd_parser_init_ctx()
207 ctx->mExtraHeaderDecFlag = 0; in m2vd_parser_init_ctx()
208 ctx->max_stream_size = M2VD_BUF_SIZE_BITMEM; in m2vd_parser_init_ctx()
209 ctx->ref_frame_cnt = 0; in m2vd_parser_init_ctx()
210 ctx->left_length = 0; in m2vd_parser_init_ctx()
211 ctx->vop_header_found = 0; in m2vd_parser_init_ctx()
216 ctx->fp_dbg_file[k] = NULL; in m2vd_parser_init_ctx()
218 ctx->fp_dbg_file[0] = fopen("/sdcard/m2vd_dbg_stream.txt", "wb"); in m2vd_parser_init_ctx()
219 if (!ctx->fp_dbg_file[0]) in m2vd_parser_init_ctx()
222 ctx->fp_dbg_yuv = fopen("/sdcard/m2vd_dbg_yuv_out.txt", "wb"); in m2vd_parser_init_ctx()
223 if (!ctx->fp_dbg_yuv) in m2vd_parser_init_ctx()
228 ctx->fp_dbg_file[k] = NULL; in m2vd_parser_init_ctx()
238 MPP_RET m2vd_parser_init(void *ctx, ParserCfg *parser_cfg) in m2vd_parser_init() argument
241 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_init()
258 MPP_RET m2vd_parser_deinit(void *ctx) in m2vd_parser_deinit() argument
262 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_deinit()
312 MPP_RET m2vd_parser_reset(void *ctx) in m2vd_parser_reset() argument
315 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_reset()
360 MPP_RET m2vd_parser_flush(void *ctx) in m2vd_parser_flush() argument
363 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_flush()
385 MPP_RET m2vd_parser_control(void *ctx, MpiCmd cmd_type, void *param) in m2vd_parser_control() argument
389 (void)ctx; in m2vd_parser_control()
402 MPP_RET mpp_m2vd_parser_split(M2VDParserContext *ctx, MppPacket dst, MppPacket src) in mpp_m2vd_parser_split() argument
405 M2VDParserContext *p = ctx; in mpp_m2vd_parser_split()
467 MPP_RET m2vd_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task) in m2vd_parser_prepare() argument
469 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_prepare()
475 if (ctx == NULL || pkt == NULL || task == NULL) { in m2vd_parser_prepare()
476 mpp_err_f("found NULL input ctx %p pkt %p task %p\n", ctx, pkt, task); in m2vd_parser_prepare()
487 m2vd_parser_flush(ctx); in m2vd_parser_prepare()
582 static int m2vd_decode_seq_ext_header(M2VDParserContext *ctx) in m2vd_decode_seq_ext_header() argument
584 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_seq_ext_header()
586 ctx->MPEG2_Flag = 1; in m2vd_decode_seq_ext_header()
587 ctx->seq_ext_head.profile_and_level_indication = m2vd_read_bits(bx, 8); in m2vd_decode_seq_ext_header()
588 ctx->seq_ext_head.progressive_sequence = m2vd_read_bits(bx, 1); in m2vd_decode_seq_ext_header()
589 ctx->seq_ext_head.chroma_format = m2vd_read_bits(bx, 2); in m2vd_decode_seq_ext_header()
590 if (ctx->seq_ext_head.chroma_format != 1) in m2vd_decode_seq_ext_header()
592 ctx->seq_ext_head.horizontal_size_extension = m2vd_read_bits(bx, 2); in m2vd_decode_seq_ext_header()
593 ctx->seq_ext_head.vertical_size_extension = m2vd_read_bits(bx, 2); in m2vd_decode_seq_ext_header()
594 ctx->seq_ext_head.bit_rate_extension = m2vd_read_bits(bx, 12); in m2vd_decode_seq_ext_header()
596 ctx->seq_ext_head.vbv_buffer_size_extension = m2vd_read_bits(bx, 8); in m2vd_decode_seq_ext_header()
597 ctx->seq_ext_head.low_delay = m2vd_read_bits(bx, 1); in m2vd_decode_seq_ext_header()
598 ctx->seq_ext_head.frame_rate_extension_n = m2vd_read_bits(bx, 2); in m2vd_decode_seq_ext_header()
599 ctx->seq_ext_head.frame_rate_extension_d = m2vd_read_bits(bx, 5); in m2vd_decode_seq_ext_header()
601 ctx->seq_head.bit_rate_value |= (ctx->seq_ext_head.bit_rate_extension << 18); in m2vd_decode_seq_ext_header()
602 ctx->seq_head.vbv_buffer_size += (ctx->seq_ext_head.vbv_buffer_size_extension << 10); in m2vd_decode_seq_ext_header()
608 static int m2vd_decode_seqdisp_ext_header(M2VDParserContext *ctx) in m2vd_decode_seqdisp_ext_header() argument
610 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_seqdisp_ext_header()
611 ctx->seq_disp_ext_head.video_format = m2vd_read_bits(bx, 3); in m2vd_decode_seqdisp_ext_header()
612 ctx->seq_disp_ext_head.color_description = m2vd_read_bits(bx, 1); in m2vd_decode_seqdisp_ext_header()
614 if (ctx->seq_disp_ext_head.color_description) { in m2vd_decode_seqdisp_ext_header()
615 ctx->seq_disp_ext_head.color_primaries = m2vd_read_bits(bx, 8); in m2vd_decode_seqdisp_ext_header()
616 ctx->seq_disp_ext_head.transfer_characteristics = m2vd_read_bits(bx, 8); in m2vd_decode_seqdisp_ext_header()
617 ctx->seq_disp_ext_head.matrix_coefficients = m2vd_read_bits(bx, 8); in m2vd_decode_seqdisp_ext_header()
626 static int m2vd_decode_matrix_ext_header(M2VDParserContext *ctx) in m2vd_decode_matrix_ext_header() argument
633 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_matrix_ext_header()
638 ctx->seq_head.pIntra_table[scanOrder[0][i]] = (unsigned char)m2vd_read_bits(bx, 8); in m2vd_decode_matrix_ext_header()
644 ctx->seq_head.pInter_table[scanOrder[0][i]] = (unsigned char)m2vd_read_bits(bx, 8); in m2vd_decode_matrix_ext_header()
657 static int m2vd_decode_scalable_ext_header(M2VDParserContext *ctx) in m2vd_decode_scalable_ext_header() argument
668 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_scalable_ext_header()
706 static int m2vd_decode_picdisp_ext_header(M2VDParserContext *ctx) in m2vd_decode_picdisp_ext_header() argument
710 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_picdisp_ext_header()
715 if (ctx->seq_ext_head.progressive_sequence) { in m2vd_decode_picdisp_ext_header()
716 if (ctx->pic_code_ext_head.repeat_first_field) { in m2vd_decode_picdisp_ext_header()
717 if (ctx->pic_code_ext_head.top_field_first) in m2vd_decode_picdisp_ext_header()
725 if (ctx->pic_code_ext_head.picture_structure != M2VD_PIC_STRUCT_FRAME) { in m2vd_decode_picdisp_ext_header()
728 if (ctx->pic_code_ext_head.repeat_first_field) in m2vd_decode_picdisp_ext_header()
737 ctx->pic_disp_ext_head.frame_center_horizontal_offset[i] = m2vd_read_bits(bx, 16); in m2vd_decode_picdisp_ext_header()
740 ctx->pic_disp_ext_head.frame_center_vertical_offset[i] = m2vd_read_bits(bx, 16); in m2vd_decode_picdisp_ext_header()
746 static int m2vd_decode_spatial_ext_header(M2VDParserContext *ctx) in m2vd_decode_spatial_ext_header() argument
755 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_spatial_ext_header()
779 static int m2vd_decode_pic_ext_header(M2VDParserContext *ctx) in m2vd_decode_pic_ext_header() argument
781 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_pic_ext_header()
782 ctx->pic_code_ext_head.f_code[0][0] = m2vd_read_bits(bx, 4); in m2vd_decode_pic_ext_header()
783 ctx->pic_code_ext_head.f_code[0][1] = m2vd_read_bits(bx, 4); in m2vd_decode_pic_ext_header()
784 ctx->pic_code_ext_head.f_code[1][0] = m2vd_read_bits(bx, 4); in m2vd_decode_pic_ext_header()
785 ctx->pic_code_ext_head.f_code[1][1] = m2vd_read_bits(bx, 4); in m2vd_decode_pic_ext_header()
786 if (ctx->MPEG2_Flag) { in m2vd_decode_pic_ext_header()
787 ctx->pic_head.full_pel_forward_vector = ctx->pic_code_ext_head.f_code[0][0]; in m2vd_decode_pic_ext_header()
788 ctx->pic_head.forward_f_code = ctx->pic_code_ext_head.f_code[0][1]; in m2vd_decode_pic_ext_header()
789 ctx->pic_head.full_pel_backward_vector = ctx->pic_code_ext_head.f_code[1][0]; in m2vd_decode_pic_ext_header()
790 ctx->pic_head.backward_f_code = ctx->pic_code_ext_head.f_code[1][1]; in m2vd_decode_pic_ext_header()
793 ctx->pic_code_ext_head.intra_dc_precision = m2vd_read_bits(bx, 2); in m2vd_decode_pic_ext_header()
794 ctx->pic_code_ext_head.picture_structure = m2vd_read_bits(bx, 2); in m2vd_decode_pic_ext_header()
795 if (ctx->pic_code_ext_head.picture_structure == M2VD_PIC_STRUCT_FRAME) in m2vd_decode_pic_ext_header()
796 ctx->pic_code_ext_head.top_field_first = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
799 if ((ctx->pic_head.pre_picture_coding_type != ctx->pic_head.picture_coding_type) && in m2vd_decode_pic_ext_header()
800 (ctx->pic_head.pre_picture_coding_type != M2VD_CODING_TYPE_I)) { in m2vd_decode_pic_ext_header()
801 if (ctx->pic_code_ext_head.picture_structure == M2VD_PIC_STRUCT_TOP_FIELD) in m2vd_decode_pic_ext_header()
802 ctx->top_first_cnt++; in m2vd_decode_pic_ext_header()
804 ctx->bottom_first_cnt++; in m2vd_decode_pic_ext_header()
806 if (ctx->top_first_cnt >= ctx->bottom_first_cnt) in m2vd_decode_pic_ext_header()
807 ctx->pic_code_ext_head.top_field_first = 1; in m2vd_decode_pic_ext_header()
809 ctx->pic_code_ext_head.top_field_first = 0; in m2vd_decode_pic_ext_header()
811 ctx->pic_code_ext_head.frame_pred_frame_dct = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
812 ctx->pic_code_ext_head.concealment_motion_vectors = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
813 ctx->pic_code_ext_head.q_scale_type = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
814 ctx->pic_code_ext_head.intra_vlc_format = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
815 ctx->pic_code_ext_head.alternate_scan = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
816 ctx->pic_code_ext_head.repeat_first_field = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
817 ctx->pic_code_ext_head.chroma_420_type = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
818 ctx->pic_code_ext_head.progressive_frame = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
819 ctx->pic_code_ext_head.composite_display_flag = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
820 if (ctx->pic_code_ext_head.composite_display_flag) { in m2vd_decode_pic_ext_header()
821 ctx->pic_code_ext_head.v_axis = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
822 ctx->pic_code_ext_head.field_sequence = m2vd_read_bits(bx, 3); in m2vd_decode_pic_ext_header()
823 ctx->pic_code_ext_head.sub_carrier = m2vd_read_bits(bx, 1); in m2vd_decode_pic_ext_header()
824 ctx->pic_code_ext_head.burst_amplitude = m2vd_read_bits(bx, 7); in m2vd_decode_pic_ext_header()
825 ctx->pic_code_ext_head.sub_carrier_phase = m2vd_read_bits(bx, 8); in m2vd_decode_pic_ext_header()
835 static int m2vd_decode_copyright_ext_header(M2VDParserContext *ctx) in m2vd_decode_copyright_ext_header() argument
844 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_copyright_ext_header()
871 static int m2vd_decode_ext_header(M2VDParserContext *ctx) in m2vd_decode_ext_header() argument
876 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_ext_header()
892 result = m2vd_decode_seq_ext_header(ctx); in m2vd_decode_ext_header()
895 result = m2vd_decode_seqdisp_ext_header(ctx); in m2vd_decode_ext_header()
898 result = m2vd_decode_matrix_ext_header(ctx); in m2vd_decode_ext_header()
901 result = m2vd_decode_scalable_ext_header(ctx); in m2vd_decode_ext_header()
904 result = m2vd_decode_picdisp_ext_header(ctx); in m2vd_decode_ext_header()
907 result = m2vd_decode_pic_ext_header(ctx); in m2vd_decode_ext_header()
910 result = m2vd_decode_spatial_ext_header(ctx); in m2vd_decode_ext_header()
916 result = m2vd_decode_copyright_ext_header(ctx); in m2vd_decode_ext_header()
938 static int m2vd_decode_gop_header(M2VDParserContext *ctx) in m2vd_decode_gop_header() argument
940 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_gop_header()
942 ctx->gop_head.drop_flag = m2vd_read_bits(bx, 1); in m2vd_decode_gop_header()
943 ctx->gop_head.hour = m2vd_read_bits(bx, 5); in m2vd_decode_gop_header()
944 ctx->gop_head.minute = m2vd_read_bits(bx, 6); in m2vd_decode_gop_header()
948 ctx->gop_head.sec = m2vd_read_bits(bx, 6); in m2vd_decode_gop_header()
949 ctx->gop_head.frame = m2vd_read_bits(bx, 6); in m2vd_decode_gop_header()
950 ctx->gop_head.closed_gop = m2vd_read_bits(bx, 1); in m2vd_decode_gop_header()
951 ctx->gop_head.broken_link = m2vd_read_bits(bx, 1); in m2vd_decode_gop_header()
953 return m2vd_decode_ext_header(ctx); in m2vd_decode_gop_header()
956 static int m2vd_decode_seq_header(M2VDParserContext *ctx) in m2vd_decode_seq_header() argument
959 RK_S32 pre_frame_rate_code = ctx->seq_head.frame_rate_code; in m2vd_decode_seq_header()
960 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_seq_header()
964 ctx->display_width = width; in m2vd_decode_seq_header()
965 ctx->display_height = height; in m2vd_decode_seq_header()
970 if (ctx->seq_head.decode_width && ctx->seq_head.decode_height) { in m2vd_decode_seq_header()
971 if (width != ctx->seq_head.decode_width || in m2vd_decode_seq_header()
972 height != ctx->seq_head.decode_height) in m2vd_decode_seq_header()
973 ctx->info_changed = 1; in m2vd_decode_seq_header()
976 ctx->seq_head.decode_width = width; in m2vd_decode_seq_header()
977 ctx->seq_head.decode_height = height; in m2vd_decode_seq_header()
978 ctx->seq_head.aspect_ratio_information = m2vd_read_bits(bx, 4); in m2vd_decode_seq_header()
979 ctx->seq_head.frame_rate_code = m2vd_read_bits(bx, 4); in m2vd_decode_seq_header()
980 if (!ctx->frame_period || pre_frame_rate_code != ctx->seq_head.frame_rate_code) in m2vd_decode_seq_header()
981 ctx->frame_period = frame_period_Table_27M[ctx->seq_head.frame_rate_code]; in m2vd_decode_seq_header()
982 ctx->seq_head.bit_rate_value = m2vd_read_bits(bx, 18); in m2vd_decode_seq_header()
984 ctx->seq_head.vbv_buffer_size = m2vd_read_bits(bx, 10); in m2vd_decode_seq_header()
985 ctx->seq_head.constrained_parameters_flag = m2vd_read_bits(bx, 1); in m2vd_decode_seq_header()
986 ctx->seq_head.load_intra_quantizer_matrix = m2vd_read_bits(bx, 1); in m2vd_decode_seq_header()
987 if (ctx->seq_head.load_intra_quantizer_matrix) { in m2vd_decode_seq_header()
989 ctx->seq_head.pIntra_table[scanOrder[0][i]] = (unsigned char)m2vd_read_bits(bx, 8); in m2vd_decode_seq_header()
992 ctx->seq_head.pIntra_table[i] = intraDefaultQMatrix[i]; in m2vd_decode_seq_header()
995 ctx->seq_head.load_non_intra_quantizer_matrix = m2vd_read_bits(bx, 1); in m2vd_decode_seq_header()
996 if (ctx->seq_head.load_non_intra_quantizer_matrix) { in m2vd_decode_seq_header()
998 ctx->seq_head.pInter_table[scanOrder[0][i]] = (unsigned char)m2vd_read_bits(bx, 8); in m2vd_decode_seq_header()
1001 ctx->seq_head.pInter_table[i] = 16; in m2vd_decode_seq_header()
1004 return m2vd_decode_ext_header(ctx); in m2vd_decode_seq_header()
1007 static int m2vd_extra_bit_information(M2VDParserContext *ctx) in m2vd_extra_bit_information() argument
1009 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_extra_bit_information()
1016 static int m2vd_decode_pic_header(M2VDParserContext *ctx) in m2vd_decode_pic_header() argument
1018 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_pic_header()
1019 ctx->pic_head.temporal_reference = m2vd_read_bits(bx, 10); in m2vd_decode_pic_header()
1020 ctx->pic_head.picture_coding_type = m2vd_read_bits(bx, 3); in m2vd_decode_pic_header()
1021 ctx->pic_head.vbv_delay = m2vd_read_bits(bx, 16); in m2vd_decode_pic_header()
1022 if (ctx->pic_head.temporal_reference > 50) { in m2vd_decode_pic_header()
1023 ctx->pic_head.temporal_reference = ctx->pretemporal_reference; in m2vd_decode_pic_header()
1027 …if (((RK_S32)ctx->maxFrame_inGOP < ctx->pic_head.temporal_reference) && (ctx->pic_head.temporal_re… in m2vd_decode_pic_header()
1028 ctx->maxFrame_inGOP = ctx->pic_head.temporal_reference; in m2vd_decode_pic_header()
1031 if (ctx->pic_head.picture_coding_type == M2VD_CODING_TYPE_P || in m2vd_decode_pic_header()
1032 ctx->pic_head.picture_coding_type == M2VD_CODING_TYPE_B) { in m2vd_decode_pic_header()
1033 ctx->pic_head.full_pel_forward_vector = m2vd_read_bits(bx, 1); in m2vd_decode_pic_header()
1034 ctx->pic_head.forward_f_code = m2vd_read_bits(bx, 3); in m2vd_decode_pic_header()
1036 if (ctx->pic_head.picture_coding_type == M2VD_CODING_TYPE_B) { in m2vd_decode_pic_header()
1037 ctx->pic_head.full_pel_backward_vector = m2vd_read_bits(bx, 1); in m2vd_decode_pic_header()
1038 ctx->pic_head.backward_f_code = m2vd_read_bits(bx, 3); in m2vd_decode_pic_header()
1041 m2vd_extra_bit_information(ctx); in m2vd_decode_pic_header()
1043 return m2vd_decode_ext_header(ctx); in m2vd_decode_pic_header()
1046 static MPP_RET m2vd_decode_head(M2VDParserContext *ctx) in m2vd_decode_head() argument
1050 BitReadCtx_t *bx = ctx->bitread_ctx; in m2vd_decode_head()
1064 ret = m2vd_decode_seq_header(ctx); in m2vd_decode_head()
1066 MppPacket pkt = ctx->input_packet; in m2vd_decode_head()
1068 ctx->mExtraHeaderDecFlag = 1; in m2vd_decode_head()
1070 ctx->mHeaderDecFlag = 1; in m2vd_decode_head()
1075 ret = m2vd_decode_gop_header(ctx); in m2vd_decode_head()
1078 ret = m2vd_decode_pic_header(ctx); in m2vd_decode_head()
1140 static MPP_RET m2vd_alloc_frame(M2VDParserContext *ctx) in m2vd_alloc_frame() argument
1142 M2VDHeadPic *pic_head = &ctx->pic_head; in m2vd_alloc_frame()
1143 M2VDHeadPicCodeExt *pic_code_ext_head = &ctx->pic_code_ext_head; in m2vd_alloc_frame()
1144 RK_U64 pts_27M = ctx->pts; in m2vd_alloc_frame()
1146 if (ctx->resetFlag && pic_head->picture_coding_type != M2VD_CODING_TYPE_I) { in m2vd_alloc_frame()
1147 …mpp_log("[m2v]: resetFlag[%d] && picture_coding_type[%d] != I_TYPE", ctx->resetFlag, pic_head->pic… in m2vd_alloc_frame()
1151 ctx->resetFlag = 0; in m2vd_alloc_frame()
1153 if ((ctx->ref_frame_cnt < 2) && (pic_head->picture_coding_type == M2VD_CODING_TYPE_B)) { in m2vd_alloc_frame()
1155 ctx->ref_frame_cnt, pic_head->picture_coding_type); in m2vd_alloc_frame()
1165 if (ctx->pts_is_90K) { in m2vd_alloc_frame()
1166 pts_27M = ctx->pts * 300; in m2vd_alloc_frame()
1168 pts_27M = ctx->pts * 27; in m2vd_alloc_frame()
1171 if (ctx->frame_cur->slot_index >= 0) { in m2vd_alloc_frame()
1174 … mpp_buf_slot_get_prop(ctx->frame_slots, ctx->frame_cur->slot_index, SLOT_FRAME_PTR, &frame); in m2vd_alloc_frame()
1175 if (ctx->cfg->base.disable_error) in m2vd_alloc_frame()
1181ctx->ref_frame_cnt, pic_head->picture_coding_type, pic_code_ext_head->top_field_first); in m2vd_alloc_frame()
1183 m2v_update_ref_frame(ctx, 1); in m2vd_alloc_frame()
1186 if (ctx->pre_pts_27M != pts_27M) { in m2vd_alloc_frame()
1189 if (ctx->group_frm_cnt) { in m2vd_alloc_frame()
1190 ctx->group_frm_cnt = ctx->group_frm_cnt + pic_head->temporal_reference; in m2vd_alloc_frame()
1191 } else if (pic_head->temporal_reference == (RK_S32)ctx->prechange_temporal_ref) in m2vd_alloc_frame()
1192 ctx->group_frm_cnt = ctx->max_temporal_reference + 1; in m2vd_alloc_frame()
1194 ctx->group_frm_cnt = pic_head->temporal_reference - ctx->prechange_temporal_ref; in m2vd_alloc_frame()
1196 ctx->group_frm_cnt = ctx->max_temporal_reference - ctx->prechange_temporal_ref + 1; in m2vd_alloc_frame()
1198 tmp_frame_period = pts_27M - ctx->pre_pts_27M; in m2vd_alloc_frame()
1200 if ((pts_27M > ctx->pre_pts_27M) in m2vd_alloc_frame()
1201 && (pic_head->temporal_reference > (RK_S32)ctx->prechange_temporal_ref)) { in m2vd_alloc_frame()
1203 … RK_S32 last_frame_period = ctx->preframe_period ? ctx->preframe_period : ctx->frame_period; in m2vd_alloc_frame()
1205 … (pic_head->temporal_reference - ctx->prechange_temporal_ref) * last_frame_period; in m2vd_alloc_frame()
1210 if (!ctx->pts_is_90K && llabs(diff_90K_frame_period) <= 300) { in m2vd_alloc_frame()
1212 ctx->pts_is_90K = 1; in m2vd_alloc_frame()
1214 pts_27M = ctx->pre_pts_27M * 1000 / 90 + predict_frame_period; in m2vd_alloc_frame()
1216 pts_27M = ctx->pre_pts_27M + predict_frame_period; in m2vd_alloc_frame()
1222 if ((pts_27M > ctx->pre_pts_27M) && (ctx->group_frm_cnt > 0)) { in m2vd_alloc_frame()
1223 tmp_frame_period = tmp_frame_period / ctx->group_frm_cnt; in m2vd_alloc_frame()
1227 (llabs(ctx->frame_period - tmp_frame_period) > MAX_FRAME_PERIOD_DIFF)) { in m2vd_alloc_frame()
1228 if (llabs(ctx->preframe_period - tmp_frame_period) > MAX_FRAME_PERIOD_DIFF) { in m2vd_alloc_frame()
1229 ctx->preframe_period = tmp_frame_period; in m2vd_alloc_frame()
1231 ctx->frame_period = tmp_frame_period; in m2vd_alloc_frame()
1232 ctx->preframe_period = 0; in m2vd_alloc_frame()
1235 ctx->preframe_period = 0; in m2vd_alloc_frame()
1239 ctx->group_start_time_27M = pts_27M - pic_head->temporal_reference * ctx->frame_period; in m2vd_alloc_frame()
1240 if (ctx->group_start_time_27M <= -ctx->frame_period) in m2vd_alloc_frame()
1241 ctx->group_start_time_27M = 0; in m2vd_alloc_frame()
1242 ctx->pre_pts_27M = pts_27M; in m2vd_alloc_frame()
1243 ctx->prechange_temporal_ref = pic_head->temporal_reference; in m2vd_alloc_frame()
1244 ctx->group_frm_cnt = 0; in m2vd_alloc_frame()
1245 } else if ((RK_S32)ctx->pretemporal_reference > pic_head->temporal_reference + 5) { in m2vd_alloc_frame()
1246 ctx->group_start_time_27M += (ctx->max_temporal_reference + 1) * ctx->frame_period; in m2vd_alloc_frame()
1247 ctx->group_frm_cnt = ctx->max_temporal_reference - ctx->prechange_temporal_ref + 1; in m2vd_alloc_frame()
1248 ctx->max_temporal_reference = 0; in m2vd_alloc_frame()
1250 if ((RK_S32)ctx->pretemporal_reference > pic_head->temporal_reference + 5) in m2vd_alloc_frame()
1251 ctx->max_temporal_reference = 0; in m2vd_alloc_frame()
1252 if (pic_head->temporal_reference > (RK_S32)ctx->max_temporal_reference) in m2vd_alloc_frame()
1253 ctx->max_temporal_reference = pic_head->temporal_reference; in m2vd_alloc_frame()
1254 ctx->pretemporal_reference = pic_head->temporal_reference; in m2vd_alloc_frame()
1255 frm_pts = ctx->group_start_time_27M; in m2vd_alloc_frame()
1256 frm_pts += pic_head->temporal_reference * ctx->frame_period; in m2vd_alloc_frame()
1260 if (ctx->pts_is_90K) { in m2vd_alloc_frame()
1278 mpp_frame_set_errinfo(ctx->frame_cur->f, 1); in m2vd_alloc_frame()
1280 mpp_frame_set_errinfo(ctx->frame_cur->f, 0); in m2vd_alloc_frame()
1285 ctx->frame_cur->picCodingType = pic_head->picture_coding_type; in m2vd_alloc_frame()
1287 mpp_frame_set_width(ctx->frame_cur->f, ctx->display_width); in m2vd_alloc_frame()
1288 mpp_frame_set_height(ctx->frame_cur->f, ctx->display_height); in m2vd_alloc_frame()
1289 mpp_frame_set_hor_stride(ctx->frame_cur->f, 0); in m2vd_alloc_frame()
1290 mpp_frame_set_ver_stride(ctx->frame_cur->f, 0); in m2vd_alloc_frame()
1291 mpp_frame_set_errinfo(ctx->frame_cur->f, 0); in m2vd_alloc_frame()
1292 mpp_frame_set_pts(ctx->frame_cur->f, frm_pts); in m2vd_alloc_frame()
1293 mpp_frame_set_dts(ctx->frame_cur->f, ctx->dts); in m2vd_alloc_frame()
1294 ctx->frame_cur->flags = M2V_OUT_FLAG; in m2vd_alloc_frame()
1296 if (ctx->seq_ext_head.progressive_sequence) { in m2vd_alloc_frame()
1305 if ((ctx->cfg->base.enable_vproc & MPP_VPROC_MODE_DETECTION) && in m2vd_alloc_frame()
1309 mpp_frame_set_mode(ctx->frame_cur->f, frametype); in m2vd_alloc_frame()
1311 … if (ctx->seq_head.aspect_ratio_information >= 0 && ctx->seq_head.aspect_ratio_information < 16) in m2vd_alloc_frame()
1312 … mpp_frame_set_sar(ctx->frame_cur->f, mpeg2_aspect[ctx->seq_head.aspect_ratio_information]); in m2vd_alloc_frame()
1315 mpp_buf_slot_get_unused(ctx->frame_slots, &ctx->frame_cur->slot_index); in m2vd_alloc_frame()
1316 …mpp_buf_slot_set_prop(ctx->frame_slots, ctx->frame_cur->slot_index, SLOT_FRAME, ctx->frame_cur->f); in m2vd_alloc_frame()
1317 mpp_buf_slot_set_flag(ctx->frame_slots, ctx->frame_cur->slot_index, SLOT_CODEC_USE); in m2vd_alloc_frame()
1318 mpp_buf_slot_set_flag(ctx->frame_slots, ctx->frame_cur->slot_index, SLOT_HAL_OUTPUT); in m2vd_alloc_frame()
1320 if (ctx->frame_cur->slot_index >= 0) in m2vd_alloc_frame()
1321 mpp_buf_slot_set_flag(ctx->frame_slots, ctx->frame_cur->slot_index, SLOT_HAL_OUTPUT); in m2vd_alloc_frame()
1330 ctx->resetFlag = 1; in m2vd_alloc_frame()
1474 MPP_RET m2vd_parser_parse(void *ctx, HalDecTask *in_task) in m2vd_parser_parse() argument
1478 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_parse()
1563 m2vd_parser_flush(ctx); in m2vd_parser_parse()
1570 MPP_RET m2vd_parser_callback(void *ctx, void *errinfo) in m2vd_parser_callback() argument
1573 M2VDContext *c = (M2VDContext *)ctx; in m2vd_parser_callback()