Lines Matching full:p

147     MpiEncTestData *p = &info->ctx;  in test_ctx_init()  local
151 p->width = cmd->width; in test_ctx_init()
152 p->height = cmd->height; in test_ctx_init()
153 p->hor_stride = (cmd->hor_stride) ? (cmd->hor_stride) : in test_ctx_init()
155 p->ver_stride = (cmd->ver_stride) ? (cmd->ver_stride) : in test_ctx_init()
157 p->fmt = cmd->format; in test_ctx_init()
158 p->type = cmd->type; in test_ctx_init()
159 p->bps = cmd->bps_target; in test_ctx_init()
160 p->bps_min = cmd->bps_min; in test_ctx_init()
161 p->bps_max = cmd->bps_max; in test_ctx_init()
162 p->rc_mode = cmd->rc_mode; in test_ctx_init()
163 p->frame_num = cmd->frame_num; in test_ctx_init()
164 if (cmd->type == MPP_VIDEO_CodingMJPEG && p->frame_num == 0) { in test_ctx_init()
166 p->frame_num = 1; in test_ctx_init()
168 p->gop_mode = cmd->gop_mode; in test_ctx_init()
169 p->gop_len = cmd->gop_len; in test_ctx_init()
170 p->vi_len = cmd->vi_len; in test_ctx_init()
172 p->fps_in_flex = cmd->fps_in_flex; in test_ctx_init()
173 p->fps_in_den = cmd->fps_in_den; in test_ctx_init()
174 p->fps_in_num = cmd->fps_in_num; in test_ctx_init()
175 p->fps_out_flex = cmd->fps_out_flex; in test_ctx_init()
176 p->fps_out_den = cmd->fps_out_den; in test_ctx_init()
177 p->fps_out_num = cmd->fps_out_num; in test_ctx_init()
178 p->mdinfo_size = (MPP_VIDEO_CodingHEVC == cmd->type) ? in test_ctx_init()
179 (MPP_ALIGN(p->hor_stride, 32) >> 5) * in test_ctx_init()
180 (MPP_ALIGN(p->ver_stride, 32) >> 5) * 16 : in test_ctx_init()
181 (MPP_ALIGN(p->hor_stride, 64) >> 6) * in test_ctx_init()
182 (MPP_ALIGN(p->ver_stride, 16) >> 4) * 16; in test_ctx_init()
187 p->cam_ctx = camera_source_init(cmd->file_input, 4, p->width, p->height, p->fmt); in test_ctx_init()
189 if (p->cam_ctx == NULL) in test_ctx_init()
192 p->fp_input = fopen(cmd->file_input, "rb"); in test_ctx_init()
193 if (NULL == p->fp_input) { in test_ctx_init()
201 p->fp_output = fopen(cmd->file_output, "w+b"); in test_ctx_init()
202 if (NULL == p->fp_output) { in test_ctx_init()
209 p->fp_verify = fopen(cmd->file_slt, "wt"); in test_ctx_init()
210 if (!p->fp_verify) in test_ctx_init()
215 switch (p->fmt & MPP_FRAME_FMT_MASK) { in test_ctx_init()
218 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 3 / 2; in test_ctx_init()
227 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 2; in test_ctx_init()
243 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64); in test_ctx_init()
247 p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 4; in test_ctx_init()
251 if (MPP_FRAME_FMT_IS_FBC(p->fmt)) { in test_ctx_init()
252 if ((p->fmt & MPP_FRAME_FBC_MASK) == MPP_FRAME_FBC_AFBC_V1) in test_ctx_init()
253p->header_size = MPP_ALIGN(MPP_ALIGN(p->width, 16) * MPP_ALIGN(p->height, 16) / 16, SZ_4K); in test_ctx_init()
255 p->header_size = MPP_ALIGN(p->width, 16) * MPP_ALIGN(p->height, 16) / 16; in test_ctx_init()
257 p->header_size = 0; in test_ctx_init()
263 MPP_RET test_ctx_deinit(MpiEncTestData *p) in test_ctx_deinit() argument
265 if (p) { in test_ctx_deinit()
266 if (p->cam_ctx) { in test_ctx_deinit()
267 camera_source_deinit(p->cam_ctx); in test_ctx_deinit()
268 p->cam_ctx = NULL; in test_ctx_deinit()
270 if (p->fp_input) { in test_ctx_deinit()
271 fclose(p->fp_input); in test_ctx_deinit()
272 p->fp_input = NULL; in test_ctx_deinit()
274 if (p->fp_output) { in test_ctx_deinit()
275 fclose(p->fp_output); in test_ctx_deinit()
276 p->fp_output = NULL; in test_ctx_deinit()
278 if (p->fp_verify) { in test_ctx_deinit()
279 fclose(p->fp_verify); in test_ctx_deinit()
280 p->fp_verify = NULL; in test_ctx_deinit()
289 MpiEncTestData *p = &info->ctx; in test_mpp_enc_cfg_setup() local
290 MppApi *mpi = p->mpi; in test_mpp_enc_cfg_setup()
291 MppCtx ctx = p->ctx; in test_mpp_enc_cfg_setup()
292 MppEncCfg cfg = p->cfg; in test_mpp_enc_cfg_setup()
298 RK_U32 gop_mode = p->gop_mode; in test_mpp_enc_cfg_setup()
302 if (p->fps_in_den == 0) in test_mpp_enc_cfg_setup()
303 p->fps_in_den = 1; in test_mpp_enc_cfg_setup()
304 if (p->fps_in_num == 0) in test_mpp_enc_cfg_setup()
305 p->fps_in_num = 30; in test_mpp_enc_cfg_setup()
306 if (p->fps_out_den == 0) in test_mpp_enc_cfg_setup()
307 p->fps_out_den = 1; in test_mpp_enc_cfg_setup()
308 if (p->fps_out_num == 0) in test_mpp_enc_cfg_setup()
309 p->fps_out_num = 30; in test_mpp_enc_cfg_setup()
311 if (!p->bps) in test_mpp_enc_cfg_setup()
312 p->bps = p->width * p->height / 8 * (p->fps_out_num / p->fps_out_den); in test_mpp_enc_cfg_setup()
314 mpp_enc_cfg_set_s32(cfg, "prep:width", p->width); in test_mpp_enc_cfg_setup()
315 mpp_enc_cfg_set_s32(cfg, "prep:height", p->height); in test_mpp_enc_cfg_setup()
316 mpp_enc_cfg_set_s32(cfg, "prep:hor_stride", p->hor_stride); in test_mpp_enc_cfg_setup()
317 mpp_enc_cfg_set_s32(cfg, "prep:ver_stride", p->ver_stride); in test_mpp_enc_cfg_setup()
318 mpp_enc_cfg_set_s32(cfg, "prep:format", p->fmt); in test_mpp_enc_cfg_setup()
320 mpp_enc_cfg_set_s32(cfg, "rc:mode", p->rc_mode); in test_mpp_enc_cfg_setup()
323 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_flex", p->fps_in_flex); in test_mpp_enc_cfg_setup()
324 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_num", p->fps_in_num); in test_mpp_enc_cfg_setup()
325 mpp_enc_cfg_set_s32(cfg, "rc:fps_in_denorm", p->fps_in_den); in test_mpp_enc_cfg_setup()
326 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_flex", p->fps_out_flex); in test_mpp_enc_cfg_setup()
327 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_num", p->fps_out_num); in test_mpp_enc_cfg_setup()
328 mpp_enc_cfg_set_s32(cfg, "rc:fps_out_denorm", p->fps_out_den); in test_mpp_enc_cfg_setup()
336 mpp_enc_cfg_set_s32(cfg, "rc:bps_target", p->bps); in test_mpp_enc_cfg_setup()
337 switch (p->rc_mode) { in test_mpp_enc_cfg_setup()
343 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mpp_enc_cfg_setup()
344 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); in test_mpp_enc_cfg_setup()
349 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mpp_enc_cfg_setup()
350 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 1 / 16); in test_mpp_enc_cfg_setup()
354 mpp_enc_cfg_set_s32(cfg, "rc:bps_max", p->bps_max ? p->bps_max : p->bps * 17 / 16); in test_mpp_enc_cfg_setup()
355 mpp_enc_cfg_set_s32(cfg, "rc:bps_min", p->bps_min ? p->bps_min : p->bps * 15 / 16); in test_mpp_enc_cfg_setup()
360 switch (p->type) { in test_mpp_enc_cfg_setup()
363 switch (p->rc_mode) { in test_mpp_enc_cfg_setup()
385 mpp_err_f("unsupport encoder rc mode %d\n", p->rc_mode); in test_mpp_enc_cfg_setup()
409 mpp_enc_cfg_set_s32(cfg, "codec:type", p->type); in test_mpp_enc_cfg_setup()
410 switch (p->type) { in test_mpp_enc_cfg_setup()
425 * 30 / 31 / 32 - D1@25fps / 720p@30fps / 720p@60fps in test_mpp_enc_cfg_setup()
426 * 40 / 41 / 42 - 1080p@30fps / 1080p@30fps / 1080p@60fps in test_mpp_enc_cfg_setup()
443 mpp_err_f("unsupport encoder coding type %d\n", p->type); in test_mpp_enc_cfg_setup()
447 p->split_mode = 0; in test_mpp_enc_cfg_setup()
448 p->split_arg = 0; in test_mpp_enc_cfg_setup()
449 p->split_out = 0; in test_mpp_enc_cfg_setup()
451 mpp_env_get_u32("split_mode", &p->split_mode, MPP_ENC_SPLIT_NONE); in test_mpp_enc_cfg_setup()
452 mpp_env_get_u32("split_arg", &p->split_arg, 0); in test_mpp_enc_cfg_setup()
453 mpp_env_get_u32("split_out", &p->split_out, 0); in test_mpp_enc_cfg_setup()
455 if (p->split_mode) { in test_mpp_enc_cfg_setup()
456 mpp_log_q(quiet, "%p split mode %d arg %d out %d\n", ctx, in test_mpp_enc_cfg_setup()
457 p->split_mode, p->split_arg, p->split_out); in test_mpp_enc_cfg_setup()
458 mpp_enc_cfg_set_s32(cfg, "split:mode", p->split_mode); in test_mpp_enc_cfg_setup()
459 mpp_enc_cfg_set_s32(cfg, "split:arg", p->split_arg); in test_mpp_enc_cfg_setup()
460 mpp_enc_cfg_set_s32(cfg, "split:out", p->split_out); in test_mpp_enc_cfg_setup()
472 mpp_enc_cfg_set_s32(cfg, "rc:gop", p->gop_len ? p->gop_len : p->fps_out_num * 2); in test_mpp_enc_cfg_setup()
479 if (p->gop_mode < 4) in test_mpp_enc_cfg_setup()
482 mpi_enc_gen_smart_gop_ref_cfg(ref, p->gop_len, p->vi_len); in test_mpp_enc_cfg_setup()
501 p->sei_mode = sei_mode; in test_mpp_enc_cfg_setup()
502 ret = mpi->control(ctx, MPP_ENC_SET_SEI_CFG, &p->sei_mode); in test_mpp_enc_cfg_setup()
509 if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) { in test_mpp_enc_cfg_setup()
510 p->header_mode = MPP_ENC_HEADER_MODE_EACH_IDR; in test_mpp_enc_cfg_setup()
511 ret = mpi->control(ctx, MPP_ENC_SET_HEADER_MODE, &p->header_mode); in test_mpp_enc_cfg_setup()
519 mpp_env_get_u32("osd_enable", &p->osd_enable, 0); in test_mpp_enc_cfg_setup()
520 mpp_env_get_u32("osd_mode", &p->osd_mode, MPP_ENC_OSD_PLT_TYPE_DEFAULT); in test_mpp_enc_cfg_setup()
521 mpp_env_get_u32("roi_enable", &p->roi_enable, 0); in test_mpp_enc_cfg_setup()
522 mpp_env_get_u32("user_data_enable", &p->user_data_enable, 0); in test_mpp_enc_cfg_setup()
524 if (p->roi_enable) { in test_mpp_enc_cfg_setup()
525 mpp_enc_roi_init(&p->roi_ctx, p->width, p->height, p->type, 4); in test_mpp_enc_cfg_setup()
526 mpp_assert(p->roi_ctx); in test_mpp_enc_cfg_setup()
536 MpiEncTestData *p = &info->ctx; in test_mpp_run() local
537 MppApi *mpi = p->mpi; in test_mpp_run()
538 MppCtx ctx = p->ctx; in test_mpp_run()
548 if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) { in test_mpp_run()
556 mpp_packet_init_with_buffer(&packet, p->pkt_buf); in test_mpp_run()
570 if (p->fp_output) in test_mpp_run()
571 fwrite(ptr, 1, len, p->fp_output); in test_mpp_run()
576 while (!p->pkt_eos) { in test_mpp_run()
580 void *buf = mpp_buffer_get_ptr(p->frm_buf); in test_mpp_run()
585 if (p->fp_input) { in test_mpp_run()
586 ret = read_image(buf, p->fp_input, p->width, p->height, in test_mpp_run()
587 p->hor_stride, p->ver_stride, p->fmt); in test_mpp_run()
588 if (ret == MPP_NOK || feof(p->fp_input)) { in test_mpp_run()
589 p->frm_eos = 1; in test_mpp_run()
591 if (p->frame_num < 0 || p->frame_count < p->frame_num) { in test_mpp_run()
592 clearerr(p->fp_input); in test_mpp_run()
593 rewind(p->fp_input); in test_mpp_run()
594 p->frm_eos = 0; in test_mpp_run()
595 mpp_log_q(quiet, "chn %d loop times %d\n", chn, ++p->loop_times); in test_mpp_run()
598 mpp_log_q(quiet, "chn %d found last frame. feof %d\n", chn, feof(p->fp_input)); in test_mpp_run()
602 if (p->cam_ctx == NULL) { in test_mpp_run()
603 ret = fill_image(buf, p->width, p->height, p->hor_stride, in test_mpp_run()
604 p->ver_stride, p->fmt, p->frame_count); in test_mpp_run()
608 cam_frm_idx = camera_source_get_frame(p->cam_ctx); in test_mpp_run()
613 camera_source_put_frame(p->cam_ctx, cam_frm_idx); in test_mpp_run()
617 cam_buf = camera_frame_to_buf(p->cam_ctx, cam_frm_idx); in test_mpp_run()
628 mpp_frame_set_width(frame, p->width); in test_mpp_run()
629 mpp_frame_set_height(frame, p->height); in test_mpp_run()
630 mpp_frame_set_hor_stride(frame, p->hor_stride); in test_mpp_run()
631 mpp_frame_set_ver_stride(frame, p->ver_stride); in test_mpp_run()
632 mpp_frame_set_fmt(frame, p->fmt); in test_mpp_run()
633 mpp_frame_set_eos(frame, p->frm_eos); in test_mpp_run()
635 if (p->fp_input && feof(p->fp_input)) in test_mpp_run()
640 mpp_frame_set_buffer(frame, p->frm_buf); in test_mpp_run()
643 mpp_packet_init_with_buffer(&packet, p->pkt_buf); in test_mpp_run()
647 mpp_meta_set_buffer(meta, KEY_MOTION_INFO, p->md_info); in test_mpp_run()
649 if (p->osd_enable || p->user_data_enable || p->roi_enable) { in test_mpp_run()
650 if (p->user_data_enable) { in test_mpp_run()
654 if ((p->frame_count & 10) == 0) { in test_mpp_run()
682 if (p->osd_enable) { in test_mpp_run()
684 mpi_enc_gen_osd_plt(&p->osd_plt, p->frame_count); in test_mpp_run()
686 p->osd_plt_cfg.change = MPP_ENC_OSD_PLT_CFG_CHANGE_ALL; in test_mpp_run()
687 p->osd_plt_cfg.type = MPP_ENC_OSD_PLT_TYPE_USERDEF; in test_mpp_run()
688 p->osd_plt_cfg.plt = &p->osd_plt; in test_mpp_run()
690 ret = mpi->control(ctx, MPP_ENC_SET_OSD_PLT_CFG, &p->osd_plt_cfg); in test_mpp_run()
697 mpi_enc_gen_osd_data(&p->osd_data, p->buf_grp, p->width, in test_mpp_run()
698 p->height, p->frame_count); in test_mpp_run()
699 mpp_meta_set_ptr(meta, KEY_OSD_DATA, (void*)&p->osd_data); in test_mpp_run()
702 if (p->roi_enable) { in test_mpp_run()
703 RoiRegionCfg *region = &p->roi_region; in test_mpp_run()
706 region->x = MPP_ALIGN(p->width / 8, 16); in test_mpp_run()
707 region->y = MPP_ALIGN(p->height / 8, 16); in test_mpp_run()
714 mpp_enc_roi_add_region(p->roi_ctx, region); in test_mpp_run()
716 region->x = MPP_ALIGN(p->width / 2, 16); in test_mpp_run()
717 region->y = MPP_ALIGN(p->height / 4, 16); in test_mpp_run()
724 mpp_enc_roi_add_region(p->roi_ctx, region); in test_mpp_run()
727 mpp_enc_roi_setup_meta(p->roi_ctx, meta); in test_mpp_run()
731 if (!p->first_frm) in test_mpp_run()
732 p->first_frm = mpp_time(); in test_mpp_run()
766 if (!p->first_pkt) in test_mpp_run()
767 p->first_pkt = mpp_time(); in test_mpp_run()
769 p->pkt_eos = mpp_packet_get_eos(packet); in test_mpp_run()
771 if (p->fp_output) in test_mpp_run()
772 fwrite(ptr, 1, len, p->fp_output); in test_mpp_run()
774 if (p->fp_verify && !p->pkt_eos) { in test_mpp_run()
776 mpp_log("p->frame_count=%d, len=%d\n", p->frame_count, len); in test_mpp_run()
777 write_data_crc(p->fp_verify, &checkcrc); in test_mpp_run()
781 "encoded frame %-4d", p->frame_count); in test_mpp_run()
788 " pkt %d", p->frm_pkt_cnt); in test_mpp_run()
789 p->frm_pkt_cnt = (eoi) ? (0) : (p->frm_pkt_cnt + 1); in test_mpp_run()
819 p->stream_size += len; in test_mpp_run()
820 p->frame_count += eoi; in test_mpp_run()
822 if (p->pkt_eos) { in test_mpp_run()
824 mpp_assert(p->frm_eos); in test_mpp_run()
830 camera_source_put_frame(p->cam_ctx, cam_frm_idx); in test_mpp_run()
832 if (p->frame_num > 0 && p->frame_count >= p->frame_num) in test_mpp_run()
835 if (p->loop_end) in test_mpp_run()
838 if (p->frm_eos && p->pkt_eos) in test_mpp_run()
851 MpiEncTestData *p = &info->ctx; in enc_test() local
867 ret = mpp_buffer_group_get_internal(&p->buf_grp, MPP_BUFFER_TYPE_DRM); in enc_test()
873 ret = mpp_buffer_get(p->buf_grp, &p->frm_buf, p->frame_size + p->header_size); in enc_test()
879 ret = mpp_buffer_get(p->buf_grp, &p->pkt_buf, p->frame_size); in enc_test()
885 ret = mpp_buffer_get(p->buf_grp, &p->md_info, p->mdinfo_size); in enc_test()
892 ret = mpp_create(&p->ctx, &p->mpi); in enc_test()
898 mpp_log_q(quiet, "%p encoder test start w %d h %d type %d\n", in enc_test()
899 p->ctx, p->width, p->height, p->type); in enc_test()
901 ret = p->mpi->control(p->ctx, MPP_SET_OUTPUT_TIMEOUT, &timeout); in enc_test()
907 ret = mpp_init(p->ctx, MPP_CTX_ENC, p->type); in enc_test()
913 ret = mpp_enc_cfg_init(&p->cfg); in enc_test()
919 ret = p->mpi->control(p->ctx, MPP_ENC_GET_CFG, p->cfg); in enc_test()
939 ret = p->mpi->reset(p->ctx); in enc_test()
946 enc_ret->frame_count = p->frame_count; in enc_test()
947 enc_ret->stream_size = p->stream_size; in enc_test()
948 enc_ret->frame_rate = (float)p->frame_count * 1000000 / enc_ret->elapsed_time; in enc_test()
949 enc_ret->bit_rate = (p->stream_size * 8 * (p->fps_out_num / p->fps_out_den)) / p->frame_count; in enc_test()
950 enc_ret->delay = p->first_pkt - p->first_frm; in enc_test()
953 if (p->ctx) { in enc_test()
954 mpp_destroy(p->ctx); in enc_test()
955 p->ctx = NULL; in enc_test()
958 if (p->cfg) { in enc_test()
959 mpp_enc_cfg_deinit(p->cfg); in enc_test()
960 p->cfg = NULL; in enc_test()
963 if (p->frm_buf) { in enc_test()
964 mpp_buffer_put(p->frm_buf); in enc_test()
965 p->frm_buf = NULL; in enc_test()
968 if (p->pkt_buf) { in enc_test()
969 mpp_buffer_put(p->pkt_buf); in enc_test()
970 p->pkt_buf = NULL; in enc_test()
973 if (p->md_info) { in enc_test()
974 mpp_buffer_put(p->md_info); in enc_test()
975 p->md_info = NULL; in enc_test()
978 if (p->osd_data.buf) { in enc_test()
979 mpp_buffer_put(p->osd_data.buf); in enc_test()
980 p->osd_data.buf = NULL; in enc_test()
983 if (p->buf_grp) { in enc_test()
984 mpp_buffer_group_put(p->buf_grp); in enc_test()
985 p->buf_grp = NULL; in enc_test()
988 if (p->roi_ctx) { in enc_test()
989 mpp_enc_roi_deinit(p->roi_ctx); in enc_test()
990 p->roi_ctx = NULL; in enc_test()
993 test_ctx_deinit(p); in enc_test()