Lines Matching refs:p
147 MpiEncMtTestData *p = &info->ctx; in mt_test_ctx_init() local
151 p->width = cmd->width; in mt_test_ctx_init()
152 p->height = cmd->height; in mt_test_ctx_init()
153 p->hor_stride = (cmd->hor_stride) ? (cmd->hor_stride) : in mt_test_ctx_init()
155 p->ver_stride = (cmd->ver_stride) ? (cmd->ver_stride) : in mt_test_ctx_init()
157 p->fmt = cmd->format; in mt_test_ctx_init()
158 p->type = cmd->type; in mt_test_ctx_init()
159 p->bps = cmd->bps_target; in mt_test_ctx_init()
160 p->bps_min = cmd->bps_min; in mt_test_ctx_init()
161 p->bps_max = cmd->bps_max; in mt_test_ctx_init()
162 p->rc_mode = cmd->rc_mode; in mt_test_ctx_init()
163 p->frame_num = cmd->frame_num; in mt_test_ctx_init()
164 if (cmd->type == MPP_VIDEO_CodingMJPEG && p->frame_num == 0) { in mt_test_ctx_init()
166 p->frame_num = 1; in mt_test_ctx_init()
169 p->frm_step = cmd->frm_step; in mt_test_ctx_init()
170 p->gop_mode = cmd->gop_mode; in mt_test_ctx_init()
171 p->gop_len = cmd->gop_len; in mt_test_ctx_init()
172 p->vi_len = cmd->vi_len; in mt_test_ctx_init()
174 p->fps_in_flex = cmd->fps_in_flex; in mt_test_ctx_init()
175 p->fps_in_den = cmd->fps_in_den; in mt_test_ctx_init()
176 p->fps_in_num = cmd->fps_in_num; in mt_test_ctx_init()
177 p->fps_out_flex = cmd->fps_out_flex; in mt_test_ctx_init()
178 p->fps_out_den = cmd->fps_out_den; in mt_test_ctx_init()
179 p->fps_out_num = cmd->fps_out_num; in mt_test_ctx_init()
184 p->cam_ctx = camera_source_init(cmd->file_input, 4, p->width, p->height, p->fmt); in mt_test_ctx_init()
186 if (p->cam_ctx == NULL) in mt_test_ctx_init()
189 p->fp_input = fopen(cmd->file_input, "rb"); in mt_test_ctx_init()
190 if (NULL == p->fp_input) { in mt_test_ctx_init()
198 p->fp_output = fopen(cmd->file_output, "w+b"); in mt_test_ctx_init()
199 if (NULL == p->fp_output) { in mt_test_ctx_init()
206 p->fp_verify = fopen(cmd->file_slt, "wt"); in mt_test_ctx_init()
207 if (!p->fp_verify) in mt_test_ctx_init()
212 switch (p->fmt & MPP_FRAME_FMT_MASK) { in mt_test_ctx_init()
215 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 3 / 2; in mt_test_ctx_init()
224 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 2; in mt_test_ctx_init()
241 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64); in mt_test_ctx_init()
245 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 4; in mt_test_ctx_init()
249 if (MPP_FRAME_FMT_IS_FBC(p->fmt)) in mt_test_ctx_init()
250 p->header_size = MPP_ALIGN(MPP_ALIGN(p->width, 16) * MPP_ALIGN(p->height, 16) / 16, SZ_4K); in mt_test_ctx_init()
252 p->header_size = 0; in mt_test_ctx_init()
259 MpiEncMtTestData *p = NULL; in mt_test_ctx_deinit() local
264 p = &info->ctx; in mt_test_ctx_deinit()
266 if (p->cam_ctx) { in mt_test_ctx_deinit()
267 camera_source_deinit(p->cam_ctx); in mt_test_ctx_deinit()
268 p->cam_ctx = NULL; in mt_test_ctx_deinit()
270 if (p->fp_input) { in mt_test_ctx_deinit()
271 fclose(p->fp_input); in mt_test_ctx_deinit()
272 p->fp_input = NULL; in mt_test_ctx_deinit()
274 if (p->fp_output) { in mt_test_ctx_deinit()
275 fclose(p->fp_output); in mt_test_ctx_deinit()
276 p->fp_output = NULL; in mt_test_ctx_deinit()
278 if (p->fp_verify) { in mt_test_ctx_deinit()
279 fclose(p->fp_verify); in mt_test_ctx_deinit()
280 p->fp_verify = NULL; in mt_test_ctx_deinit()
289 MpiEncMtTestData *p = &info->ctx; in test_mt_cfg_setup() local
290 MppApi *mpi = p->mpi; in test_mt_cfg_setup()
291 MppCtx ctx = p->ctx; in test_mt_cfg_setup()
292 MppEncCfg cfg = p->cfg; in test_mt_cfg_setup()
293 RK_U32 gop_mode = p->gop_mode; in test_mt_cfg_setup()
299 if (p->fps_in_den == 0) in test_mt_cfg_setup()
300 p->fps_in_den = 1; in test_mt_cfg_setup()
301 if (p->fps_in_num == 0) in test_mt_cfg_setup()
302 p->fps_in_num = 30; in test_mt_cfg_setup()
303 if (p->fps_out_den == 0) in test_mt_cfg_setup()
304 p->fps_out_den = 1; in test_mt_cfg_setup()
305 if (p->fps_out_num == 0) in test_mt_cfg_setup()
306 p->fps_out_num = 30; in test_mt_cfg_setup()
308 if (!p->bps) in test_mt_cfg_setup()
309 p->bps = p->width * p->height / 8 * (p->fps_out_num / p->fps_out_den); in test_mt_cfg_setup()
311 mpp_enc_cfg_set_s32(cfg, "codec:type", p->type); in test_mt_cfg_setup()
313 mpp_enc_cfg_set_s32(cfg, "prep:width", p->width); in test_mt_cfg_setup()
314 mpp_enc_cfg_set_s32(cfg, "prep:height", p->height); in test_mt_cfg_setup()
315 mpp_enc_cfg_set_s32(cfg, "prep:hor_stride", p->hor_stride); in test_mt_cfg_setup()
316 mpp_enc_cfg_set_s32(cfg, "prep:ver_stride", p->ver_stride); in test_mt_cfg_setup()
317 mpp_enc_cfg_set_s32(cfg, "prep:format", p->fmt); in test_mt_cfg_setup()
319 mpp_enc_cfg_set_s32(cfg, "rc:mode", p->rc_mode); in test_mt_cfg_setup()
322 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_flex", p->fps_in_flex); in test_mt_cfg_setup()
323 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_num", p->fps_in_num); in test_mt_cfg_setup()
324 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_denom", p->fps_in_den); in test_mt_cfg_setup()
325 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_flex", p->fps_out_flex); in test_mt_cfg_setup()
326 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_num", p->fps_out_num); in test_mt_cfg_setup()
327 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_denom", p->fps_out_den); in test_mt_cfg_setup()
335 mpp_enc_cfg_set_s32(cfg, "rc:bps_target", p->bps); in test_mt_cfg_setup()
336 switch (p->rc_mode) { in test_mt_cfg_setup()
342 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mt_cfg_setup()
343 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); 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 * 1 / 16); in test_mt_cfg_setup()
353 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mt_cfg_setup()
354 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); in test_mt_cfg_setup()
359 switch (p->type) { in test_mt_cfg_setup()
362 switch (p->rc_mode) { in test_mt_cfg_setup()
384 mpp_err_f("unsupport encoder rc mode %d\n", p->rc_mode); in test_mt_cfg_setup()
408 mpp_enc_cfg_set_s32(cfg, "codec:type", p->type); in test_mt_cfg_setup()
409 switch (p->type) { in test_mt_cfg_setup()
436 mpp_err_f("unsupport encoder coding type %d\n", p->type); in test_mt_cfg_setup()
440 p->split_mode = 0; in test_mt_cfg_setup()
441 p->split_arg = 0; in test_mt_cfg_setup()
442 p->split_out = 0; in test_mt_cfg_setup()
444 mpp_env_get_u32("split_mode", &p->split_mode, MPP_ENC_SPLIT_NONE); in test_mt_cfg_setup()
445 mpp_env_get_u32("split_arg", &p->split_arg, 0); in test_mt_cfg_setup()
446 mpp_env_get_u32("split_out", &p->split_out, 0); in test_mt_cfg_setup()
448 if (p->split_mode) { in test_mt_cfg_setup()
450 p->split_mode, p->split_arg, p->split_out); in test_mt_cfg_setup()
451 mpp_enc_cfg_set_s32(cfg, "split:mode", p->split_mode); in test_mt_cfg_setup()
452 mpp_enc_cfg_set_s32(cfg, "split:arg", p->split_arg); in test_mt_cfg_setup()
453 mpp_enc_cfg_set_s32(cfg, "split:out", p->split_out); in test_mt_cfg_setup()
457 mpp_enc_cfg_set_s32(cfg, "rc:gop", p->gop_len ? p->gop_len : p->fps_out_num * 2); in test_mt_cfg_setup()
464 if (p->gop_mode < 4) in test_mt_cfg_setup()
467 mpi_enc_gen_smart_gop_ref_cfg(ref, p->gop_len, p->vi_len); in test_mt_cfg_setup()
482 p->sei_mode = MPP_ENC_SEI_MODE_ONE_FRAME; in test_mt_cfg_setup()
483 ret = mpi->control(ctx, MPP_ENC_SET_SEI_CFG, &p->sei_mode); in test_mt_cfg_setup()
489 if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) { in test_mt_cfg_setup()
490 p->header_mode = MPP_ENC_HEADER_MODE_EACH_IDR; in test_mt_cfg_setup()
491 ret = mpi->control(ctx, MPP_ENC_SET_HEADER_MODE, &p->header_mode); in test_mt_cfg_setup()
499 mpp_env_get_u32("osd_enable", &p->osd_enable, 0); in test_mt_cfg_setup()
500 mpp_env_get_u32("osd_mode", &p->osd_mode, MPP_ENC_OSD_PLT_TYPE_DEFAULT); in test_mt_cfg_setup()
501 mpp_env_get_u32("roi_enable", &p->roi_enable, 0); in test_mt_cfg_setup()
502 mpp_env_get_u32("user_data_enable", &p->user_data_enable, 0); in test_mt_cfg_setup()
504 if (p->roi_enable) { in test_mt_cfg_setup()
505 mpp_enc_roi_init(&p->roi_ctx, p->width, p->height, p->type, 4); in test_mt_cfg_setup()
506 mpp_assert(p->roi_ctx); in test_mt_cfg_setup()
516 MpiEncMtTestData *p = &info->ctx; in mt_test_res_init() local
524 p->list_buf = mpp_list_create(NULL); in mt_test_res_init()
525 if (NULL == p->list_buf) { in mt_test_res_init()
530 ret = mpp_buffer_group_get_internal(&p->buf_grp, MPP_BUFFER_TYPE_DRM); in mt_test_res_init()
537 ret = mpp_buffer_get(p->buf_grp, &p->frm_buf[i], p->frame_size + p->header_size); in mt_test_res_init()
543 ret = mpp_buffer_get(p->buf_grp, &p->pkt_buf[i], p->frame_size); in mt_test_res_init()
549 mpp_list_add_at_tail(p->list_buf, &p->frm_buf[i], sizeof(p->frm_buf[i])); in mt_test_res_init()
553 ret = mpp_create(&p->ctx, &p->mpi); in mt_test_res_init()
560 p->ctx, p->width, p->height, p->type); in mt_test_res_init()
562 ret = p->mpi->control(p->ctx, MPP_SET_INPUT_TIMEOUT, &timeout); in mt_test_res_init()
570 ret = p->mpi->control(p->ctx, MPP_SET_OUTPUT_TIMEOUT, &timeout); in mt_test_res_init()
576 ret = mpp_init(p->ctx, MPP_CTX_ENC, p->type); in mt_test_res_init()
582 ret = mpp_enc_cfg_init(&p->cfg); in mt_test_res_init()
588 ret = p->mpi->control(p->ctx, MPP_ENC_GET_CFG, p->cfg); in mt_test_res_init()
604 MpiEncMtTestData *p = &info->ctx; in mt_test_res_deinit() local
608 p->mpi->reset(p->ctx); in mt_test_res_deinit()
614 if (p->ctx) { in mt_test_res_deinit()
615 mpp_destroy(p->ctx); in mt_test_res_deinit()
616 p->ctx = NULL; in mt_test_res_deinit()
619 if (p->cfg) { in mt_test_res_deinit()
620 mpp_enc_cfg_deinit(p->cfg); in mt_test_res_deinit()
621 p->cfg = NULL; in mt_test_res_deinit()
625 if (p->frm_buf[i]) { in mt_test_res_deinit()
626 mpp_buffer_put(p->frm_buf[i]); in mt_test_res_deinit()
627 p->frm_buf[i] = NULL; in mt_test_res_deinit()
630 if (p->pkt_buf[i]) { in mt_test_res_deinit()
631 mpp_buffer_put(p->pkt_buf[i]); in mt_test_res_deinit()
632 p->pkt_buf[i] = NULL; in mt_test_res_deinit()
636 if (p->osd_data.buf) { in mt_test_res_deinit()
637 mpp_buffer_put(p->osd_data.buf); in mt_test_res_deinit()
638 p->osd_data.buf = NULL; in mt_test_res_deinit()
641 if (p->buf_grp) { in mt_test_res_deinit()
642 mpp_buffer_group_put(p->buf_grp); in mt_test_res_deinit()
643 p->buf_grp = NULL; in mt_test_res_deinit()
646 if (p->list_buf) { in mt_test_res_deinit()
647 mpp_list_destroy(p->list_buf); in mt_test_res_deinit()
648 p->list_buf = NULL; in mt_test_res_deinit()
651 if (p->roi_ctx) { in mt_test_res_deinit()
652 mpp_enc_roi_deinit(p->roi_ctx); in mt_test_res_deinit()
653 p->roi_ctx = NULL; in mt_test_res_deinit()
663 MpiEncMtTestData *p = &info->ctx; in enc_test_input() local
665 MppApi *mpi = p->mpi; in enc_test_input()
666 MppCtx ctx = p->ctx; in enc_test_input()
667 MppList *list_buf = p->list_buf; in enc_test_input()
696 if (p->fp_input) { in enc_test_input()
697 ret = read_image((RK_U8 *)buf, p->fp_input, p->width, p->height, in enc_test_input()
698 p->hor_stride, p->ver_stride, p->fmt); in enc_test_input()
699 if (ret == MPP_NOK || feof(p->fp_input)) { in enc_test_input()
700 p->frm_eos = 1; in enc_test_input()
702 if (p->frame_num < 0 || p->frm_cnt_in < p->frame_num) { in enc_test_input()
703 clearerr(p->fp_input); in enc_test_input()
704 rewind(p->fp_input); in enc_test_input()
705 p->frm_eos = 0; in enc_test_input()
706 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 * p->frm_step); 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 MppList *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()
978 p->stream_size += len; in enc_test_output()
979 p->frm_cnt_out += eoi; in enc_test_output()
981 if (p->frm_cnt_out != p->frm_cnt_in) in enc_test_output()
984 if (p->frame_num > 0 && p->frm_cnt_out >= p->frame_num) { in enc_test_output()
985 p->pkt_eos = 1; in enc_test_output()
989 if (p->frm_eos) { in enc_test_output()
990 p->pkt_eos = 1; in enc_test_output()
994 if (p->pkt_eos) { in enc_test_output()
996 mpp_assert(p->frm_eos); in enc_test_output()
1001 enc_ret->elapsed_time = p->last_pkt - p->first_frm; in enc_test_output()
1002 enc_ret->frame_count = p->frm_cnt_out; in enc_test_output()
1003 enc_ret->stream_size = p->stream_size; in enc_test_output()
1004 enc_ret->frame_rate = (float)p->frm_cnt_out * 1000000 / enc_ret->elapsed_time; in enc_test_output()
1005 enc_ret->bit_rate = (p->stream_size * 8 * (p->fps_out_num / p->fps_out_den)) / p->frm_cnt_out; in enc_test_output()
1006 enc_ret->delay = p->first_pkt - p->first_frm; in enc_test_output()