sdk-hwV1.3/external/fast-user-adapter/rt_media/docs/ve编码参数xml配置使用指南.md

140 lines
4.3 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: ve编码参数xml配置使用指南
subtitle:
author: Allwinner
changelog:
- ver: 1.0
date: 2023.12.29
author: 陈亦斌
desc: |
初稿
---
# 概述
## 背景介绍
在一些场景下,如画质调节,存在编码方案在编码过程能够动态调整参数的需求。
### 编写目的
指导基于ve_param_x.xml文件如何进行参数的配置和使用。
## 适用范围
AW系列编码方案。
## 相关人员
编码相关产品的开发人员及技术支持人员。
# xml文件内容解释
举例有xml文件ve_param_0.xml配置内容如下
```xml
<demo>
<static ch_id = "0">
<frame_rate status = "off" value = "30"/>
<bit_rate status = "off" value = "6291456"/>
<vbv_size status = "on" value = "8388608"/>
<pixel_format status = "off"
pxl_format = "VENC_PIXEL_YUV420SP"
out_pxl_format = "1"
/>
</static>
<dynamic ch_id = "0">
<frame_rate status = "on" value = "30"/>
<bit_rate status = "off" value = "6291456"/>
<force_conf_win status = "off"
u8_en_force_conf = "0"
u32_lefet_offset = "0"
u32_right_offset = "0"
u32_top_offset = "0"
u32_bottom_offset = "0"
/>
</dynamic>
</demo>
```
## xml文件路径
1. xml文件默认路径是/etc目录默认文件名ve_param_[n].xmleg. /etc/ve_param_0.xml
2. 用户可以自己修改路径,方法如下:
- 在tmp目录下创建文件ve_param_file_path.confeg. touch ve_param_file_path.conf
- 把xml路径和前缀输入到conf文件中如 echo /tmp/ve_param_ > ve_param_file_path.conf。注意不需要输入完整的文件名只输入前缀这样是为了能够匹配到所有通道。
下次push xml文件就push到自己指定的路径中即可eg. adb push ve_param_0.xml /tmp
## 文件名中的数字后缀
快起和非快起区别如下:
1. 在长电方案即非快起表示第几通道只是简单的増序id(非vipp num)如ve_param_4.xml表示要设置第四个通道的参数
2. 在快起方案表示第几通道同时也代表了是哪个vipp num如ve_param_4.xml表示第4通道同时也表示vipp_num是4。
## tag中的status属性
1. on表示要设置该tag中的参数
2. off表示不需要设置
## tag中的static和dynamic属性
1. tag在static范围内的内容在编码初始化的时候才会进行解析会把用户设置的参数修改为xml中的内容
2. tag在dynamic范围内的内容在编码过程中进行解析解析完后会自动给文件名添加后缀_used表示已经解析过了eg: ve_param_0_used.xml。
如需再次设置请重新push xml文件到/etc目录或者自己修改的目录中或者直接mv ve_param_0_used.xml ve_param_0.xml后再次使用
## 如何在代码中自己添加参数设置
请搜索关键函数check_ve_param_file去查看例子简单概述如下
1. xml文件添加tag和键值对
```xml
<frame_rate status = "off" value = "30"/>
```
2. 代码start_parse_tag函数中添加相应的tag字符串比对并把值赋值给对应添加的参数成员同时设置参数到编码器中。
```c
if (strcmp(tag_name, "frame_rate") == 0) {
for (unsigned int i = 0; attr[i]; i += 2) {
parse_frame_rate_param(ve_param, attr, i);
}
VencSetParameter(pVideoEnc, VENC_IndexParamFramerate, &ve_param->fps);
}
```
    具体请查看对应函数代码
# 使用方式
以上面的ve_param_0.xml文件为例子另改变了xml文件路径到tmp目录。
1. 首先在tmp目录创建ve_param_file_path.conf并echo 文件路径进去,如下
```shell
root@TinaLinux:/tmp# touch ve_param_file_path.conf
root@TinaLinux:/tmp# echo /tmp/ve_param_ > ve_param_file_path.conf
root@TinaLinux:/tmp# cat ve_param_file_path.conf
/tmp/ve_param_
```
2. 确认好哪些参数需要配置的把status改为on然后把文件ve_param_0.xml用adb或者其他方式放置到tmp目录
```shell
adb push .\ve_param_0.xml tmp
```
3. 运行demo/app编码器初始化的时候会配置xml中tag 为static并status 为on的内容编码过程中会配置xml中tag 为dynamic并status 为on的内容。