普希金的笔

普希金的笔

0个粉丝

5

问答

0

专栏

0

资料

普希金的笔  发布于  2025-08-20 11:10:22
采纳率 0%
5个问答
328

hi3615dv500 sensor:os04a10 测量从 VPSS(视频处理子系统)获取一帧 YUV 数据的耗时

我把咱们示例的smple_vio裁剪了一下,变成了单摄像头 VI → VPSS → VENC/VO 链路。可以正常运行,可以查看到相关信息和摄像头画面。
我后边想要测量从 VPSS(视频处理子系统)获取一帧 YUV 数据的耗时:
使用了一个性能测试线程函数
将其放在sample_vio_start_route中
static td_s32 sample_vio_start_route(sample_vi_cfg vi_cfg, sample_vpss_cfg vpss_cfg, td_s32 route_num)
{
td_s32 i, j, ret;
ot_vpss_grp vpss_grp[SAMPLE_VIO_MAX_ROUTE_NUM] = {0, 1, 2, 3};

sample_comm_vi_get_size_by_sns_type(SENSOR0_TYPE, &g_vb_param.vb_size);
if (sample_vio_sys_init() != TD_SUCCESS) {
    return TD_FAILURE;
}

// 启动VI
for (i = 0; i < route_num; i++) {
    ret = sample_comm_vi_start_vi(&vi_cfg[i]);
    if (ret != TD_SUCCESS) {
        goto start_vi_failed;
    }
}

// 绑定VI和VPSS并使能通道
for (i = 0; i < route_num; i++) {
    sample_comm_vi_bind_vpss(i, 0, vpss_grp[i], 0);
    if (ss_mpi_vi_enable_chn(i, 0) != TD_SUCCESS) {
        goto start_vi_failed;
    }
}

// 启动VPSS
for (i = 0; i < route_num; i++) {
    ret = sample_vio_start_vpss(vpss_grp[i], vpss_cfg);
    if (ret != TD_SUCCESS) {
        goto start_vpss_failed;
    }
    if (ss_mpi_vpss_enable_chn(vpss_grp[i], 0) != TD_SUCCESS) {
        goto start_vpss_failed;
    }
}

// 启动VENC和VO(链路完全建立)
ret = sample_vio_start_venc_and_vo(vpss_grp, SAMPLE_VIO_MAX_ROUTE_NUM, route_num);
if (ret != TD_SUCCESS) {
    goto start_venc_and_vo_failed;
}

// 链路启动成功后,启动计时线程
pthread_t tid;
if (pthread_create(&tid, NULL, perf_thread, (void*)&vpss_grp[0]) != 0) {
    printf("创建计时线程失败!\n");
} else {
    pthread_detach(tid); // 分离线程,独立运行
}

return TD_SUCCESS;

// 错误处理部分(保持不变)

start_venc_and_vo_failed:
start_vpss_failed:
for (j = i - 1; j >= 0; j—) {
sample_vio_stop_vpss(vpss_grp[j]);
}
for (i = 0; i < route_num; i++) {
sample_comm_vi_un_bind_vpss(i, 0, vpss_grp[i], 0);
}
start_vi_failed:
for (j = i - 1; j >= 0; j—) {
sample_comm_vi_stop_vi(&vi_cfg[j]);
}
sample_comm_sys_exit();
return TD_FAILURE;
}
这是线程函数的代码:
static void perf_thread(void arg)
{
ot_vpss_grp grp = (ot_vpss_grp)arg;
ot_vpss_chn chn = 0;
int cnt = 0;
double total = 0, min = 1e9, max = 0;

printf("\n=== VI->VPSS->VENC/VO 链路性能计时开始 ===\n");
printf("从 VPSS GRP%d CH%d 拿 YUV 帧(链路出口)\n", grp, chn);

while (cnt < 100 && !g_sig_flag) {
    ot_video_frame_info frame= {0};
    double t0 = now_ms();
    td_s32 ret = ss_mpi_vpss_get_chn_frame(grp, chn, &frame, 100);

    if (ret != TD_SUCCESS) {
        // 修正:使用OT_ERR_TIMEOUT替代TD_TIMEOUT
        if (ret == OT_ERR_TIMEOUT) {
            printf("获取帧超时(%d次)\n", cnt);
        } else {
            printf("获取帧失败(错误码:0x%x)\n", ret);
        }
        usleep(10000);
        continue;
    }


    double t1 = now_ms();
    double delta = t1 - t0;
    total += delta;
    min = (delta < min) ? delta : min;
    max = (delta > max) ? delta : max;
    cnt++;

    ss_mpi_vpss_release_chn_frame(grp, chn, &frame);

    if (cnt % 10 == 0) {
        printf("已获取 %03d 帧,当前帧耗时: %.2f ms\n", cnt, delta);
    }
}


if (cnt > 0) {
    printf("=== 计时结束 ===\n");
    printf("总帧数: %d\n", cnt);
    printf("平均耗时: %.2f ms\n", total / cnt);
    printf("最小耗时: %.2f ms\n", min);
    printf("最大耗时: %.2f ms\n", max);
} else {
    printf("=== 计时结束:未获取到有效帧 ===\n");
}
return NULL;

}
```
目前的情况是开发板打印信息:
~ # ./mpp_enc 1
Sample VIO Start!
vi vpss mode list:
(0) VI_ONLINE_VPSS_ONLINE, FMU OFF
(1) VI_ONLINE_VPSS_OFFLINE, FMU OFF
(2) VI_OFFLINE_VPSS_OFFLINE, FMU DIRECT
(3) VI_OFFLINE_VPSS_OFFLINE, FMU OFF
please select mode:
3

[MPP] Version: [HI3519DV500_MPP_V2.0.2.0 B050 Release], Build Time[Dec 20 2024, 16:23:07]

bus_id:3

linear mode

vi_pipe:0,== os04a10 24Mclk 4M30fps(MIPI) 12bit linear init success! ==

ISP Dev 0 running !
start vo dhd0.
mipi intf sync = 23
———————-press enter key to exit!———————-

=== VI->VPSS->VENC/VO 链路性能计时开始 ===
从 VPSS GRP0 CH0 拿 YUV 帧(链路出口)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
获取帧失败(错误码:0xa0078016)
^C[sample_signal_handler]-638: catch signal 2, stop…
=== 计时结束:未获取到有效帧 ===
exit
[sample_comm_venc_get_venc_stream_proc]-2463: get venc stream time out, exit thread
Sample VIO Exit!
~ # ls
通过hdmi接口仍可看到相关画面vi正常
cat /proc/umap/vi

[VI] Version: [HI3519DV500_MPP_V2.0.2.0 B050 Release], Build Time[Dec 20 2024, 16:23:07]

————————————————————vi module param————————————————————————————————-
max_out_width max_out_height detect_err_frame drop_err_frame
8192 8192 0 0

————————————————————vi vpss mode & vi aiisp mode & fmu mode————————————————————-
pipe_id vi_vpss_mode vi_aiisp_mode fmu_mode
0 vi_online_vpss_offline default off
1 vi_offline_vpss_offline default off
2 vi_offline_vpss_offline default off
3 vi_offline_vpss_offline default off
4 vi_offline_vpss_offline default off
5 vi_offline_vpss_offline default off
6 vi_offline_vpss_offline default off
7 vi_offline_vpss_offline default off
8 vi_offline_vpss_offline default off
9 vi_offline_vpss_offline default off
10 vi_offline_vpss_offline default off
11 vi_offline_vpss_offline default off
12 vi_offline_vpss_offline default off
13 vi_offline_vpss_offline default off
14 vi_offline_vpss_offline default off

————————————————————vi dev attr1——————————————————————————————————
dev_id dev_status intf_mode work_mode comp_mask0 comp_mask1 scan_mode
0 enable mipi 1mux fff00000 0 progressive

————————————————————vi dev attr2——————————————————————————————————
dev_id data_seq data_type data_reverse width height data_rate irq_affinity
0 yvyu raw N 2688 1520 x1 0

————————————————————vi thermo sns attr———————————————————————————————
dev_id work_mode ooc_width ooc_height ooc_bitwidth cfg_num frame_rate sd_mux0 sd_mux1 sd_mux2 sd_mux3

————————————————————vi dev detect info———————————————————————————————
dev_id valid_width valid_height em_data_size total_width vfb_height vbb_height
0 2688 1520 0 9738 0 107

————————————————————vi stitch grp attr———————————————————————————————
grp_id stitch_en cfg_mode max_pts_gap pipe_num pipe_id

————————————————————vi bind attr——————————————————————————————————
dev_id pipe_num pipe_id
0 1 0

————————————————————vi wdr fusion grp attr—————————————————————————————
grp_id wdr_mode cache_line pipe_num pipe_id pipe_reverse
0 none 1520 1 0 N

————————————————————vi pipe attr1—————————————————————————————————-
pipe_id bypass_mode isp_bypass width height pixel_format compress_mode
0 bypass_none N 2688 1520 raw12 line

————————————————————vi pipe attr2—————————————————————————————————-
pipe_id bit_align_mode src_rate dst_rate frame_source vc_num vb_src vb_pool
0 high -1 -1 src_fe 0 common -1

————————————————————vi pipe psfm attr———————————————————————————————-
pipe_id enable rect_x rect_y rect_width rect_height
0 N 0 0 0 0

————————————————————vi aiisp pool attr———————————————————————————————
pipe_id aiisp_type in_pool_id out_pool_id net_type

————————————————————vi pipe param—————————————————————————————————-
pipe_id discard_pro_pic_en out_mode data_rate yuv_skip_en signed_bit_extend_en bnr_info_en nr_effect_mode
0 N norm x1 Y N N advance

————————————————————vi pipe bnr buf num——————————————————————————————-
pipe_id bnr_buf_num
0 2

————————————————————vi pipe mcf info————————————————————————————————
pipe_id mcf_vi_en queue_full ref_ok last_pts ref_pts

————————————————————vi pipe pre crop attr—————————————————————————————-
pipe_id enable rect_x rect_y rect_width rect_height
0 N 0 0 0 0

————————————————————vi pipe post crop attr—————————————————————————————
pipe_id enable rect_x rect_y rect_width rect_height
0 N 0 0 0 0

————————————————————vi pipe 3dnr attr———————————————————————————————-
pipe_id enable nr_type compress_mode nr_motion_mode
0 Y NORM frame NORM

————————————————————vi pipe 3dnr param———————————————————————————————

————————————————————vi pipe0 3dnr param——————————————————————————————-
pipe version opt_mode iso ref1_en
0 VER_1 MANUAL 0 1
nry0_en nry1_en nry2_en nry3_en nrc0_en nrc1_en limit_range_en
0 1 1 1 1 1 0
sfs1_0 sfs2_1 sfs2_2 sfs2_3 sfc sfs2_c
3 0 30 0 10 10
sfs1_1 sfs4_1 sfs4_2 sfs4_3 trc
8 0 30 0 20
tfs0_1 tfs0_2
0 12
tfs1_1 tfs1_2 adv_math
0 12 0
sfn_1 sfn_2 sfn_3
0_2_4_0 4_2_4_0 0_2_4_0
sfn_4
0_2_4_0
math_0 math0_1 math0_2
128 200 400
math1_1 math1_2
200 999

————————————————————vi pipe frame dump attr————————————————————————————-
pipe_id enable depth
0 N 0

————————————————————vi pipe private data dump attr—————————————————————————
pipe_id enable data_mode depth data_size
0 N back 0 0

————————————————————vi pipe low delay attr—————————————————————————————
pipe_id enable line_cnt one_buf
0 N 0 N

————————————————————vi pipe frame interrupt attr——————————————————————————
pipe_id interrupt_type early_line
0 start 0

————————————————————vi pipe user pic attr—————————————————————————————-
pipe_id enable width height stride pixel_format pool_id phy_addr
0 N 0 0 0 n/a 0 0

————————————————————vi pipe snap attr———————————————————————————————-
pipe_id snap_type load_ccm_en frame_cnt repeat_send_times zsl_en frame_depth rollback_ms interval op_mode

————————————————————vi pipe status—————————————————————————————————
pipe_id enable int_en width height int_cnt send_cnt lost_cnt vb_fail_cnt frame_rate
0 Y Y 2688 1520 738 0 0 0 0

————————————————————vi pipe offline task statistics————————————————————————-
pipe_id receive_pic_cnt busy_num task_submit_cnt task_fail_cnt task_cost_time max_cost_time
0 0 0 0 0 0 0

————————————————————vi phys chn attr1———————————————————————————————-
pipe_id chn_id width height pixel_format dynamic_range video_format compress_mode mirror flip
0 0 2688 1520 yvu-sp420 sdr8 linear seg N N

————————————————————vi phys chn attr2———————————————————————————————-
pipe_id chn_id depth src_rate dst_rate vb_src vb_pool align
0 0 0 -1 -1 common -1 0

————————————————————vi phys chn motion_denoise status———————————————————————-
pipe_id chn_id motion_denoise

————————————————————vi phys chn dis config—————————————————————————————
pipe_id chn_id mode motion_level pdt_type buf_num crop_ratio frame_rate camera_steady scale ref_num
0 0 4_DOF_GME Low RECORDER 0 0 0 0 0 0

————————————————————vi phys chn dis attr1—————————————————————————————-
pipe_id chn_id enable gdc_bypass mov_sub roef timelag hor_limit ver_limit still_crop strength ref_slope
0 0 N N 0 0 0 0 0 N 0 0

————————————————————vi phys chn dis attr2—————————————————————————————-
pipe_id chn_id dis_ldc_en focal_len_x focal_len_y coord_shift_x coord_shift_y max_du
0 0 N 0 0 0 0 0

————————————————————vi phys chn dis attr3—————————————————————————————-
pipe_id chn_id rotation_compensation_en max_roll_delta final_roll
0 0 N 0 0

————————————————————vi phys chn dis param—————————————————————————————-
pipe_id chn_id large_motion_stable_coef low_freq_motion_preserve low_freq_motion_freq
0 0 100 10 100

————————————————————vi phys chn dis wdr_attr————————————————————————————
pipe_id chn_id match_frame
0 0 0

————————————————————vi chn low delay attr—————————————————————————————-
pipe_id chn_id enable line_cnt one_buf
0 0 N 0 N

————————————————————vi chn crop info————————————————————————————————
pipe_id chn_id crop_en coord x y width height trim_x trim_y trim_width trim_height
0 0 N ABS 0 0 0 0

————————————————————vi chn status—————————————————————————————————-
pipe_id chn_id enable width height send_cnt vb_fail_cnt lost_frame_cnt frame_rate
0 0 Y 2688 1520 737 0 0 30

————————————————————vi chn out frame info—————————————————————————————-
pipe_id chn_id width height compress_mode low_delay_frame delay
0 0 2688 1520 seg N 33883

————————————————————vi interrupt cost time statistics———————————————————————-
isp_time isp_max_time vicap_time vicap_max_time viproc_time viproc_max_time int_time_per_sec load_ratio_0
62 295 66 353 719 766 34642 NA

我来回答
回答3个
时间排序
认可量排序

UncleRoderick

59个粉丝

16

问答

4

专栏

20

资料

UncleRoderick 2025-08-20 14:29:27
认可0

看下vpss的proc信息,应该是你的vpss通道深度参数为0,这个参数必须大于0才支持get_frame操作

普希金的笔
普希金的笔   回复   UncleRoderick  2025-08-20 18:52:17
0

换思路和重新写代码解决了,后边我看看,直接这个思路是啥原因

UncleRoderick
UncleRoderick   回复   普希金的笔  2025-08-20 19:13:29
0

看不到你的VPSS信息,没办法分析具体原因

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区