---
title: hi_mpi_venc_set_cu_pred
description: "本接口用于调节通道CU/MB的模式选择的倾向性，支持调节帧间预测（Inter）和帧内预测（Intra）的倾向性配置以及编码块大小的倾向性配置。"
url: https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/latest/Application%20Development%20Guide/aadgc/aclcppdevg_03_1076.html
sourcePath: /source/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application Development Guide/aadgc/aclcppdevg_03_1076.html
indexId: 0889d923ece7575476d5eb83088016be084cf97fc70498b861458127de5cf77d105
---
# hi_mpi_venc_set_cu_pred

#### 函数功能

本接口用于调节通道CU/MB的模式选择的倾向性，支持调节帧间预测（Inter）和帧内预测（Intra）的倾向性配置以及编码块大小的倾向性配置。

编码协议以像素块作为基本处理单元，H.265/H.264中分别称为CU(Coding Unit)/MB(MacroBlock)。本接口中的CU模式指Inter/Intra预测模式中对不同尺寸像素块的选择。


#### 约束说明

- 仅H.265/H.264编码通道支持。
- 建议用户在创建通道之后，启动编码之前调用本接口，减少编码过程中调用本接口的次数。若在编码过程中调用本接口，则下一帧编码时配置生效。
- 建议用户在调用此接口之前先调用  hi_mpi_venc_get_cu_pred
接口，获取CU模式选择的倾向性配置，然后再进行设置。


- 注意某些场景下特定模式不使能（例如，H.264中最大MB尺寸为16*16，且baseline和main profile下inter16_cost不使能，high profile下inter8_cost不使能），即使用户设置了这些特定模式的倾向性参数也不生效。

#### 函数原型

hi_s32 hi_mpi_venc_set_cu_pred(hi_venc_chn chn, const hi_venc_cu_prediction *cu_pred)


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| chn | 输入 | 编码通道号。 Atlas 200/500 A2推理产品，编码通道号的取值范围：[0, 128)，JPEGE功能和VENC功能共用通道，且通道总数最多128。 |
| cu\_pred | 输入 | CU模式选择的倾向性参数。 该结构体内包含以下参数： pred\_mode：倾向性选择模式，支持auto和manual两种模式。auto模式下由驱动内部完成倾向性配置，即用户的配置参数不生效；manual模式允许用户根据实际场景完成自定义的倾向性配置。 intra32\_cost/intra16\_cost/intra8\_cost/intra4\_cost/inter64\_cost/inter32\_cost/inter16\_cost/inter8\_cost分别设置各自模式的倾向性大小。默认每个cost值为8，即不做倾向性配置。每个模式的cost设置越大意味着选择该模式的倾向性越小。 |


#### 返回值说明

- 0：成功
- 非0：失败，参见  VENC视频编码/JPEGE图片编码返回码
