3.4. sample_vse 使用说明

3.4.1. 功能概述

  • sample_vse 完成 VSE 模块初始化,配置输入输出通道参数,实现1路图像输入,6路图像经过缩放、crop 后输出功能。

  • sample_vse 还展示如何通过异步接口 hbn_vnode_sendframe_async 向 VSE 发送视频帧。

3.4.1.1. 软件架构说明

sample_vse 主要依赖 libcam.so libvpf.so libhbmem.so,将 YUV 文件读入 hbm 申请内存,并传入 VSE 通道缩小放大处理,最后处理的 YUV 数据 dump 到文件系统中。

sample_vse_software_arch.png

3.4.1.2. 数据流说明

示例程序 pipeline 如下所示,仅创建一个 vflow,vflow 仅包含一个 VSE vnode。通过 VSE vnode 内部6个 Channel 实现不同分辨率缩放。

sample_vse_pipeline.png

3.4.1.3. 代码位置目录结构

  • 代码位置 app/samples/platform_samples/sample_vse

  • 目录结构

sample_vse/
├── Makefile
└── sample_vse.c

3.4.1.4. API流程说明

sample_vse_code_flow.png

3.4.2. 编译部署

3.4.2.1. 编译

  • 进入 sample_vse 目录,执行make编译

  • 输出成果物是 sample_vse 源码目录sample_vse

  • 详细程序编译方式查阅 编译方法 章节

3.4.2.2. 程序部署

sample_vse/sample_vse传到开发板之后,运行chmod +x sample_vse命令程序赋予执行权限。

3.4.3. 运行

3.4.3.1. 程序运行方法

直接执行程序 ./sample_vse 可以获得帮助信息:

3.4.3.2. 程序参数选项说明

./sample_vse
Usage: sample_vse [OPTIONS]
Options:
  -i, --input_file FILE   Input NV12 file path
  -w, --input_width W     Input width in pixels
  -h, --input_height H    Input height in pixels
  -f, --feedback          Feedback mode (hbn_vnode_start)
  -V, --verbose           Verbose dump of frame structures
  -a, --async             Use hbn_vnode_sendframe_async (default: sync sendframe)
  -b, --buf-num N         Ichn buffer index rotation count [1..16], default 1
  -n, --frames N          Send/Get frame loop iterations (default 1)
  -y, --save-yuv          Save ochn NV12 to ./vse_output_nv12_run*_chn*.yuv
  • i: 指定输入的YUV文件,测试程序默认使用 NV12 格式

  • w: 输入 YUV 图像宽度

  • h: 输入 YUV 图像高度

  • f: 以 feedback 模式运行 VSE 节点(不创建 vflow 流)

  • V: 打印一帧详细信息

  • a: 用异步接口给 VSE 送 YUV 图像

  • b: 输入通道 buffer 轮转数量,取值范围:1~16,默认:1,注意:用异步接口给 VSE 送 YUV 图像时,此参数必须大于等于 3

  • n: Send/Get 循环次数

  • y: 保存 NV12 图像,命名方式:./vse_output_nv12_run*_chn*.yuv

3.4.3.3. 运行效果

示例 1

输入分辨率为 1280 x 720 的 YUV 图片为例,执行 ./sample_vse -i 1280x720_NV12.yuv -w 1280 -h 720 -n 10 -y

一张 YUV 图像送入 VSE,并且初始化6个通道,0~4通道执行图像缩小,5通道执行图像放大,并且处理图像保存为 yuv 图像:

  • 0 通道输出输入图像分辨率:1280 x 720。

  • 1 通道输出16像素对齐常用算法图像使用分辨率:512 x 512。

  • 2 通道输出非16像素对齐常用算法图像使用分辨率:224 x 224。

  • 3 通道输出ROI为原图中心点不变,宽、高裁剪一半,输出图像宽、高等于ROI区域宽高,输出缩小支持最小分辨率:64 x 64。

  • 4 通道输出常用算法图像使用分辨率:672 x 672。

  • 5 通道输出放大支持最大分辨率(注意:图像只能最大放到4倍):2560 x 1440。

  • Send/Get 循环 10 次。

  • 添加 -y 参数保存图像。

输出 log 如下:

VSE work mode: vflow
sendframe: sync
ichn buffer rotation count (-b): 1
run loop count (-n): 10
save_yuv: yes (-y)
input: 1280x720_NV12.yuv, 1280x720
(read_yuvv_nv12_file):file read(1280x720_NV12.yuv), y-size(921600)
ichn input width = 1280
ichn input height = 720
hbn_vnode_set_ochn_attr: 0, 1280x720
hbn_vnode_set_ochn_attr: 1, 512x512
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 2560x1440
sample_vse: completed 10 send/get frame iteration(s)

示例 2

运行 Feedback 模式输入分辨率为 1920 x 1080 的 YUV 图片为例,执行 ./sample_vse -i 1920x1080_NV12.yuv -w 1920 -h 1080 -n 10 -f -y

  • Send/Get 循环 10 次。

  • 添加 -f 参数开启 Feedback 模式。

  • 添加 -y 参数保存图像。

输出 log 如下:

VSE work mode: feedback
sendframe: sync
ichn buffer rotation count (-b): 1
run loop count (-n): 10
save_yuv: yes (-y)
input: 1920x1080_NV12.yuv, 1920x1080
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
ichn input width = 1920
ichn input height = 1080
hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x512
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 3840x2160
sample_vse: completed 10 send/get frame iteration(s)

示例 3

运行异步接口给 VSE 发送 YUV 图像模式,以输入分辨率为 1920 x 1080 的 YUV 图片为例,执行 ./sample_vse -i 1920x1080_NV12.yuv -w 1920 -h 1080 -n 30 -a -b 6 -y

  • Send/Get 循环 30 次。

  • 添加 -a 参数开启异步接口。

  • 异步接口时,buffer 轮转数量最小为:3,本示例设置为:6。

  • 添加 -y 参数保存图像。

输出 log 如下:

VSE work mode: vflow
sendframe: async
ichn buffer rotation count (-b): 6
run loop count (-n): 30
save_yuv: yes (-y)
input: 1920x1080_NV12.yuv, 1920x1080
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
(read_yuvv_nv12_file):file read(1920x1080_NV12.yuv), y-size(2073600)
ichn input width = 1920
ichn input height = 1080
hbn_vnode_set_ochn_attr: 0, 1920x1080
hbn_vnode_set_ochn_attr: 1, 512x512
hbn_vnode_set_ochn_attr: 2, 224x224
hbn_vnode_set_ochn_attr: 3, 64x64
hbn_vnode_set_ochn_attr: 4, 672x672
hbn_vnode_set_ochn_attr: 5, 3840x2160
sample_vse: completed 30 send/get frame iteration(s)
  • 浏览YUV图

    参考Hobot player静态图片章节浏览图像,图像参数配置说明如下:​​ 按照如下所示步骤配置选项,其中 file config 里面关注 pic_type 、 yuv_type 、width 和 height 的配置,以 vse_output_nv12_run0_chn0_1280x720_stride_1280.yuv 为例, 配置为(PIC_YUV, YUV_NV12, 1280, 720)。 vse_hobot_use.png

3.4.4. 提示说明

VSE 通道 5 只支持放大,如果输入分辨率小于测试程序 VSE 通道0-4设置默认分辨率,将出现报错。 例如使用 64x64 图像作为输入,将提示报错信息如下:

[   51.037647] [L485]vse_ochn_attr_check: Invalid Param attr->target_w: 512, min: 64, max: 64
[   51.045960] vse_ochn_attr_check failed