---
title: acl.himpi.venc_set_cu_pred
description: "| c函数原型 | hi\\_s32 hi\\_mpi\\_venc\\_set\\_cu\\_pred(hi\\_venc\\_chn chn, const hi\\_venc\\_cu\\_prediction \\*cu\\_pred) |"
url: "https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application%20Development%20Guide/aadgp/aclpythondevg_01_0521.html"
---

# acl.himpi.venc_set_cu_pred

| c函数原型 | hi\_s32 hi\_mpi\_venc\_set\_cu\_pred(hi\_venc\_chn chn, const hi\_venc\_cu\_prediction \*cu\_pred) |
| --- | --- |
| Python函数 | ret = acl.himpi.venc\_set\_cu\_pred(chn, cu\_pred) |
| 函数功能 | 本接口用于调节通道CU/MB的模式选择的倾向性，支持调节帧间预测（Inter）和帧内预测（Intra）的倾向性配置以及编码块大小的倾向性配置。 编码协议以像素块作为基本处理单元，H.265/H.264中分别称为CU(Coding Unit)/MB(MacroBlock)。本接口中的CU模式指Inter/Intra预测模式中对不同尺寸像素块的选择。 |
| 输入说明 | chn：int，编码通道号。 Atlas 200/500 A2推理产品，编码通道号的取值范围：[0, 128)，JPEGE功能和VENC功能共用通道，且通道总数最多128。 cu\_pred：CU模式选择的倾向性参数字典。具体参见hi\_venc\_cu\_prediction。 该字典内需包含以下参数： 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设置越大意味着选择该模式的倾向性越小。 |
| 返回值说明 | ret：int，错误码。 返回0表示成功。 返回非0表示失败，参见VENC视频/JPEGE图像编码返回码。 |
| 约束说明 | 仅H.265/H.264编码通道支持。 建议用户在创建通道之后，启动编码之前调用本接口，减少编码过程中调用本接口的次数。若在编码过程中调用本接口，则下一帧编码时配置生效。 建议用户在调用此接口之前先调用acl.himpi.venc\_get\_cu\_pred接口，获取CU模式选择的倾向性配置，然后再进行设置。 注意某些场景下特定模式不使能（例如，H.264中最大MB尺寸为16\*16，且baseline和main profile下inter16\_cost不使能，high profile下inter8\_cost不使能），即使用户设置了这些特定模式的倾向性参数也不生效。 |
| 参考资源 | 无 |
