Lines Matching full:p
158 MpiEncMtTestData *p = &info->ctx; in mt_test_ctx_init() local
162 p->width = cmd->width; in mt_test_ctx_init()
163 p->height = cmd->height; in mt_test_ctx_init()
164 p->hor_stride = (cmd->hor_stride) ? (cmd->hor_stride) : in mt_test_ctx_init()
166 p->ver_stride = (cmd->ver_stride) ? (cmd->ver_stride) : in mt_test_ctx_init()
168 p->fmt = cmd->format; in mt_test_ctx_init()
169 p->type = cmd->type; in mt_test_ctx_init()
170 p->bps = cmd->bps_target; in mt_test_ctx_init()
171 p->bps_min = cmd->bps_min; in mt_test_ctx_init()
172 p->bps_max = cmd->bps_max; in mt_test_ctx_init()
173 p->rc_mode = cmd->rc_mode; in mt_test_ctx_init()
174 p->frame_num = cmd->frame_num; in mt_test_ctx_init()
175 if (cmd->type == MPP_VIDEO_CodingMJPEG && p->frame_num == 0) { in mt_test_ctx_init()
177 p->frame_num = 1; in mt_test_ctx_init()
179 p->gop_mode = cmd->gop_mode; in mt_test_ctx_init()
180 p->gop_len = cmd->gop_len; in mt_test_ctx_init()
181 p->vi_len = cmd->vi_len; in mt_test_ctx_init()
183 p->fps_in_flex = cmd->fps_in_flex; in mt_test_ctx_init()
184 p->fps_in_den = cmd->fps_in_den; in mt_test_ctx_init()
185 p->fps_in_num = cmd->fps_in_num; in mt_test_ctx_init()
186 p->fps_out_flex = cmd->fps_out_flex; in mt_test_ctx_init()
187 p->fps_out_den = cmd->fps_out_den; in mt_test_ctx_init()
188 p->fps_out_num = cmd->fps_out_num; in mt_test_ctx_init()
193 p->cam_ctx = camera_source_init(cmd->file_input, 4, p->width, p->height, p->fmt); in mt_test_ctx_init()
195 if (p->cam_ctx == NULL) in mt_test_ctx_init()
198 p->fp_input = fopen(cmd->file_input, "rb"); in mt_test_ctx_init()
199 if (NULL == p->fp_input) { in mt_test_ctx_init()
207 p->fp_output = fopen(cmd->file_output, "w+b"); in mt_test_ctx_init()
208 if (NULL == p->fp_output) { in mt_test_ctx_init()
215 p->fp_verify = fopen(cmd->file_slt, "wt"); in mt_test_ctx_init()
216 if (!p->fp_verify) in mt_test_ctx_init()
221 switch (p->fmt & MPP_FRAME_FMT_MASK) { in mt_test_ctx_init()
224 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 3 / 2; in mt_test_ctx_init()
233 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 2; in mt_test_ctx_init()
249 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64); in mt_test_ctx_init()
253 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 4; in mt_test_ctx_init()
257 if (MPP_FRAME_FMT_IS_FBC(p->fmt)) in mt_test_ctx_init()
258 p->header_size = MPP_ALIGN(MPP_ALIGN(p->width, 16) * MPP_ALIGN(p->height, 16) / 16, SZ_4K); in mt_test_ctx_init()
260 p->header_size = 0; in mt_test_ctx_init()
267 MpiEncMtTestData *p = NULL; in mt_test_ctx_deinit() local
272 p = &info->ctx; in mt_test_ctx_deinit()
274 if (p->cam_ctx) { in mt_test_ctx_deinit()
275 camera_source_deinit(p->cam_ctx); in mt_test_ctx_deinit()
276 p->cam_ctx = NULL; in mt_test_ctx_deinit()
278 if (p->fp_input) { in mt_test_ctx_deinit()
279 fclose(p->fp_input); in mt_test_ctx_deinit()
280 p->fp_input = NULL; in mt_test_ctx_deinit()
282 if (p->fp_output) { in mt_test_ctx_deinit()
283 fclose(p->fp_output); in mt_test_ctx_deinit()
284 p->fp_output = NULL; in mt_test_ctx_deinit()
286 if (p->fp_verify) { in mt_test_ctx_deinit()
287 fclose(p->fp_verify); in mt_test_ctx_deinit()
288 p->fp_verify = NULL; in mt_test_ctx_deinit()
297 MpiEncMtTestData *p = &info->ctx; in test_mt_cfg_setup() local
298 MppApi *mpi = p->mpi; in test_mt_cfg_setup()
299 MppCtx ctx = p->ctx; in test_mt_cfg_setup()
300 MppEncCfg cfg = p->cfg; in test_mt_cfg_setup()
301 RK_U32 gop_mode = p->gop_mode; in test_mt_cfg_setup()
307 if (p->fps_in_den == 0) in test_mt_cfg_setup()
308 p->fps_in_den = 1; in test_mt_cfg_setup()
309 if (p->fps_in_num == 0) in test_mt_cfg_setup()
310 p->fps_in_num = 30; in test_mt_cfg_setup()
311 if (p->fps_out_den == 0) in test_mt_cfg_setup()
312 p->fps_out_den = 1; in test_mt_cfg_setup()
313 if (p->fps_out_num == 0) in test_mt_cfg_setup()
314 p->fps_out_num = 30; in test_mt_cfg_setup()
316 if (!p->bps) in test_mt_cfg_setup()
317 p->bps = p->width * p->height / 8 * (p->fps_out_num / p->fps_out_den); in test_mt_cfg_setup()
319 mpp_enc_cfg_set_s32(cfg, "prep:width", p->width); in test_mt_cfg_setup()
320 mpp_enc_cfg_set_s32(cfg, "prep:height", p->height); in test_mt_cfg_setup()
321 mpp_enc_cfg_set_s32(cfg, "prep:hor_stride", p->hor_stride); in test_mt_cfg_setup()
322 mpp_enc_cfg_set_s32(cfg, "prep:ver_stride", p->ver_stride); in test_mt_cfg_setup()
323 mpp_enc_cfg_set_s32(cfg, "prep:format", p->fmt); in test_mt_cfg_setup()
325 mpp_enc_cfg_set_s32(cfg, "rc:mode", p->rc_mode); in test_mt_cfg_setup()
328 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_flex", p->fps_in_flex); in test_mt_cfg_setup()
329 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_num", p->fps_in_num); in test_mt_cfg_setup()
330 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_denorm", p->fps_in_den); in test_mt_cfg_setup()
331 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_flex", p->fps_out_flex); in test_mt_cfg_setup()
332 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_num", p->fps_out_num); in test_mt_cfg_setup()
333 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_denorm", p->fps_out_den); in test_mt_cfg_setup()
341 mpp_enc_cfg_set_s32(cfg, "rc:bps_target", p->bps); in test_mt_cfg_setup()
342 switch (p->rc_mode) { in test_mt_cfg_setup()
348 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mt_cfg_setup()
349 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); in test_mt_cfg_setup()
354 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mt_cfg_setup()
355 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 1 / 16); in test_mt_cfg_setup()
359 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mt_cfg_setup()
360 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); in test_mt_cfg_setup()
365 switch (p->type) { in test_mt_cfg_setup()
368 switch (p->rc_mode) { in test_mt_cfg_setup()
390 mpp_err_f("unsupport encoder rc mode %d\n", p->rc_mode); in test_mt_cfg_setup()
414 mpp_enc_cfg_set_s32(cfg, "codec:type", p->type); in test_mt_cfg_setup()
415 switch (p->type) { in test_mt_cfg_setup()
428 * 30 / 31 / 32 - D1@25fps / 720p@30fps / 720p@60fps in test_mt_cfg_setup()
429 * 40 / 41 / 42 - 1080p@30fps / 1080p@30fps / 1080p@60fps in test_mt_cfg_setup()
442 mpp_err_f("unsupport encoder coding type %d\n", p->type); in test_mt_cfg_setup()
446 p->split_mode = 0; in test_mt_cfg_setup()
447 p->split_arg = 0; in test_mt_cfg_setup()
448 p->split_out = 0; in test_mt_cfg_setup()
450 mpp_env_get_u32("split_mode", &p->split_mode, MPP_ENC_SPLIT_NONE); in test_mt_cfg_setup()
451 mpp_env_get_u32("split_arg", &p->split_arg, 0); in test_mt_cfg_setup()
452 mpp_env_get_u32("split_out", &p->split_out, 0); in test_mt_cfg_setup()
454 if (p->split_mode) { in test_mt_cfg_setup()
455 mpp_log_q(quiet, "%p split mode %d arg %d out %d\n", ctx, in test_mt_cfg_setup()
456 p->split_mode, p->split_arg, p->split_out); in test_mt_cfg_setup()
457 mpp_enc_cfg_set_s32(cfg, "split:mode", p->split_mode); in test_mt_cfg_setup()
458 mpp_enc_cfg_set_s32(cfg, "split:arg", p->split_arg); in test_mt_cfg_setup()
459 mpp_enc_cfg_set_s32(cfg, "split:out", p->split_out); in test_mt_cfg_setup()
463 mpp_enc_cfg_set_s32(cfg, "rc:gop", p->gop_len ? p->gop_len : p->fps_out_num * 2); in test_mt_cfg_setup()
470 if (p->gop_mode < 4) in test_mt_cfg_setup()
473 mpi_enc_gen_smart_gop_ref_cfg(ref, p->gop_len, p->vi_len); in test_mt_cfg_setup()
488 p->sei_mode = MPP_ENC_SEI_MODE_ONE_FRAME; in test_mt_cfg_setup()
489 ret = mpi->control(ctx, MPP_ENC_SET_SEI_CFG, &p->sei_mode); in test_mt_cfg_setup()
495 if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) { in test_mt_cfg_setup()
496 p->header_mode = MPP_ENC_HEADER_MODE_EACH_IDR; in test_mt_cfg_setup()
497 ret = mpi->control(ctx, MPP_ENC_SET_HEADER_MODE, &p->header_mode); in test_mt_cfg_setup()
505 mpp_env_get_u32("osd_enable", &p->osd_enable, 0); in test_mt_cfg_setup()
506 mpp_env_get_u32("osd_mode", &p->osd_mode, MPP_ENC_OSD_PLT_TYPE_DEFAULT); in test_mt_cfg_setup()
507 mpp_env_get_u32("roi_enable", &p->roi_enable, 0); in test_mt_cfg_setup()
508 mpp_env_get_u32("user_data_enable", &p->user_data_enable, 0); in test_mt_cfg_setup()
510 if (p->roi_enable) { in test_mt_cfg_setup()
511 mpp_enc_roi_init(&p->roi_ctx, p->width, p->height, p->type, 4); in test_mt_cfg_setup()
512 mpp_assert(p->roi_ctx); in test_mt_cfg_setup()
522 MpiEncMtTestData *p = &info->ctx; in mt_test_res_init() local
530 p->list_buf = new mpp_list(NULL); in mt_test_res_init()
531 if (NULL == p->list_buf) { in mt_test_res_init()
536 ret = mpp_buffer_group_get_internal(&p->buf_grp, MPP_BUFFER_TYPE_DRM); in mt_test_res_init()
543 ret = mpp_buffer_get(p->buf_grp, &p->frm_buf[i], p->frame_size + p->header_size); in mt_test_res_init()
549 ret = mpp_buffer_get(p->buf_grp, &p->pkt_buf[i], p->frame_size); in mt_test_res_init()
555 p->list_buf->add_at_tail(&p->frm_buf[i], sizeof(p->frm_buf[i])); in mt_test_res_init()
559 ret = mpp_create(&p->ctx, &p->mpi); in mt_test_res_init()
565 mpp_log_q(quiet, "%p encoder test start w %d h %d type %d\n", in mt_test_res_init()
566 p->ctx, p->width, p->height, p->type); in mt_test_res_init()
568 ret = p->mpi->control(p->ctx, MPP_SET_INPUT_TIMEOUT, &timeout); in mt_test_res_init()
576 ret = p->mpi->control(p->ctx, MPP_SET_OUTPUT_TIMEOUT, &timeout); in mt_test_res_init()
582 ret = mpp_init(p->ctx, MPP_CTX_ENC, p->type); in mt_test_res_init()
588 ret = mpp_enc_cfg_init(&p->cfg); in mt_test_res_init()
594 ret = p->mpi->control(p->ctx, MPP_ENC_GET_CFG, p->cfg); in mt_test_res_init()
610 MpiEncMtTestData *p = &info->ctx; in mt_test_res_deinit() local
614 p->mpi->reset(p->ctx); in mt_test_res_deinit()
620 if (p->ctx) { in mt_test_res_deinit()
621 mpp_destroy(p->ctx); in mt_test_res_deinit()
622 p->ctx = NULL; in mt_test_res_deinit()
625 if (p->cfg) { in mt_test_res_deinit()
626 mpp_enc_cfg_deinit(p->cfg); in mt_test_res_deinit()
627 p->cfg = NULL; in mt_test_res_deinit()
631 if (p->frm_buf[i]) { in mt_test_res_deinit()
632 mpp_buffer_put(p->frm_buf[i]); in mt_test_res_deinit()
633 p->frm_buf[i] = NULL; in mt_test_res_deinit()
636 if (p->pkt_buf[i]) { in mt_test_res_deinit()
637 mpp_buffer_put(p->pkt_buf[i]); in mt_test_res_deinit()
638 p->pkt_buf[i] = NULL; in mt_test_res_deinit()
642 if (p->osd_data.buf) { in mt_test_res_deinit()
643 mpp_buffer_put(p->osd_data.buf); in mt_test_res_deinit()
644 p->osd_data.buf = NULL; in mt_test_res_deinit()
647 if (p->buf_grp) { in mt_test_res_deinit()
648 mpp_buffer_group_put(p->buf_grp); in mt_test_res_deinit()
649 p->buf_grp = NULL; in mt_test_res_deinit()
652 if (p->list_buf) { in mt_test_res_deinit()
653 delete p->list_buf; in mt_test_res_deinit()
654 p->list_buf = NULL; in mt_test_res_deinit()
657 if (p->roi_ctx) { in mt_test_res_deinit()
658 mpp_enc_roi_deinit(p->roi_ctx); in mt_test_res_deinit()
659 p->roi_ctx = NULL; in mt_test_res_deinit()
669 MpiEncMtTestData *p = &info->ctx; in enc_test_input() local
671 MppApi *mpi = p->mpi; in enc_test_input()
672 MppCtx ctx = p->ctx; in enc_test_input()
673 mpp_list *list_buf = p->list_buf; in enc_test_input()
701 if (p->fp_input) { in enc_test_input()
702 ret = read_image((RK_U8 *)buf, p->fp_input, p->width, p->height, in enc_test_input()
703 p->hor_stride, p->ver_stride, p->fmt); in enc_test_input()
704 if (ret == MPP_NOK || feof(p->fp_input)) { in enc_test_input()
705 p->frm_eos = 1; in enc_test_input()
707 if (p->frame_num < 0 || p->frm_cnt_in < p->frame_num) { in enc_test_input()
708 clearerr(p->fp_input); in enc_test_input()
709 rewind(p->fp_input); in enc_test_input()
710 p->frm_eos = 0; in enc_test_input()
711 mpp_log_q(quiet, "chn %d loop times %d\n", chn, ++p->loop_times); in enc_test_input()
714 mpp_log_q(quiet, "chn %d found last frame. feof %d\n", chn, feof(p->fp_input)); in enc_test_input()
718 if (p->cam_ctx == NULL) { in enc_test_input()
719 ret = fill_image((RK_U8 *)buf, p->width, p->height, p->hor_stride, in enc_test_input()
720 p->ver_stride, p->fmt, p->frm_cnt_in); in enc_test_input()
724 cam_frm_idx = camera_source_get_frame(p->cam_ctx); in enc_test_input()
729 camera_source_put_frame(p->cam_ctx, cam_frm_idx); in enc_test_input()
733 cam_buf = camera_frame_to_buf(p->cam_ctx, cam_frm_idx); in enc_test_input()
744 mpp_frame_set_width(frame, p->width); in enc_test_input()
745 mpp_frame_set_height(frame, p->height); in enc_test_input()
746 mpp_frame_set_hor_stride(frame, p->hor_stride); in enc_test_input()
747 mpp_frame_set_ver_stride(frame, p->ver_stride); in enc_test_input()
748 mpp_frame_set_fmt(frame, p->fmt); in enc_test_input()
749 mpp_frame_set_eos(frame, p->frm_eos); in enc_test_input()
751 if (p->fp_input && feof(p->fp_input)) in enc_test_input()
760 if (p->osd_enable || p->user_data_enable || p->roi_enable) { in enc_test_input()
761 if (p->user_data_enable) { in enc_test_input()
765 if ((p->frm_cnt_in & 10) == 0) { in enc_test_input()
793 if (p->osd_enable) { in enc_test_input()
795 mpi_enc_gen_osd_plt(&p->osd_plt, p->frm_cnt_in); in enc_test_input()
797 p->osd_plt_cfg.change = MPP_ENC_OSD_PLT_CFG_CHANGE_ALL; in enc_test_input()
798 p->osd_plt_cfg.type = MPP_ENC_OSD_PLT_TYPE_USERDEF; in enc_test_input()
799 p->osd_plt_cfg.plt = &p->osd_plt; in enc_test_input()
801 ret = mpi->control(ctx, MPP_ENC_SET_OSD_PLT_CFG, &p->osd_plt_cfg); in enc_test_input()
808 mpi_enc_gen_osd_data(&p->osd_data, p->buf_grp, p->width, in enc_test_input()
809 p->height, p->frm_cnt_in); in enc_test_input()
810 mpp_meta_set_ptr(meta, KEY_OSD_DATA, (void*)&p->osd_data); in enc_test_input()
813 if (p->roi_enable) { in enc_test_input()
814 RoiRegionCfg *region = &p->roi_region; in enc_test_input()
817 region->x = MPP_ALIGN(p->width / 8, 16); in enc_test_input()
818 region->y = MPP_ALIGN(p->height / 8, 16); in enc_test_input()
825 mpp_enc_roi_add_region(p->roi_ctx, region); in enc_test_input()
827 region->x = MPP_ALIGN(p->width / 2, 16); in enc_test_input()
828 region->y = MPP_ALIGN(p->height / 4, 16); in enc_test_input()
835 mpp_enc_roi_add_region(p->roi_ctx, region); in enc_test_input()
838 mpp_enc_roi_setup_meta(p->roi_ctx, meta); in enc_test_input()
842 if (!p->first_frm) in enc_test_input()
843 p->first_frm = mpp_time(); in enc_test_input()
851 p->frm_cnt_in++; in enc_test_input()
859 camera_source_put_frame(p->cam_ctx, cam_frm_idx); in enc_test_input()
861 if (p->frame_num > 0 && p->frm_cnt_in >= p->frame_num) { in enc_test_input()
862 p->frm_eos = 1; in enc_test_input()
866 if (p->loop_end) { in enc_test_input()
867 p->frm_eos = 1; in enc_test_input()
871 if (p->frm_eos) in enc_test_input()
882 MpiEncMtTestData *p = &info->ctx; in enc_test_output() local
884 mpp_list *list_buf = p->list_buf; in enc_test_output()
886 MppApi *mpi = p->mpi; in enc_test_output()
887 MppCtx ctx = p->ctx; in enc_test_output()
906 p->last_pkt = mpp_time(); in enc_test_output()
914 if (!p->first_pkt) in enc_test_output()
915 p->first_pkt = mpp_time(); in enc_test_output()
917 p->pkt_eos = mpp_packet_get_eos(packet); in enc_test_output()
919 if (p->fp_output) in enc_test_output()
920 fwrite(ptr, 1, len, p->fp_output); in enc_test_output()
923 "encoded frame %-4d", p->frm_cnt_out); in enc_test_output()
930 " pkt %d", p->frm_pkt_cnt); in enc_test_output()
931 p->frm_pkt_cnt = (eoi) ? (0) : (p->frm_pkt_cnt + 1); in enc_test_output()
977 p->stream_size += len; in enc_test_output()
978 p->frm_cnt_out += eoi; in enc_test_output()
980 if (p->frm_cnt_out != p->frm_cnt_in) in enc_test_output()
983 if (p->frame_num > 0 && p->frm_cnt_out >= p->frame_num) { in enc_test_output()
984 p->pkt_eos = 1; in enc_test_output()
988 if (p->frm_eos) { in enc_test_output()
989 p->pkt_eos = 1; in enc_test_output()
993 if (p->pkt_eos) { in enc_test_output()
995 mpp_assert(p->frm_eos); in enc_test_output()
1000 enc_ret->elapsed_time = p->last_pkt - p->first_frm; in enc_test_output()
1001 enc_ret->frame_count = p->frm_cnt_out; in enc_test_output()
1002 enc_ret->stream_size = p->stream_size; in enc_test_output()
1003 enc_ret->frame_rate = (float)p->frm_cnt_out * 1000000 / enc_ret->elapsed_time; in enc_test_output()
1004 enc_ret->bit_rate = (p->stream_size * 8 * (p->fps_out_num / p->fps_out_den)) / p->frm_cnt_out; in enc_test_output()
1005 enc_ret->delay = p->first_pkt - p->first_frm; in enc_test_output()