---
title: WinHann
description: "给指定向量加Hann窗。其具体公式为：。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2200/accel/kunpengaccel_hmpp_06_0138.html
sourcePath: /source/zh/kunpengboostkithistory/2200/accel/kunpengaccel_hmpp_06_0138.html
indexId: b86176b71df84f9adc143c7ded54943c59797ff231eff06b920db348ea2adfdd75
---
# WinHann

给指定向量加Hann窗。其具体公式为：。

函数接口声明如下：

- 整型数的操作：
  HmppResult HMPPS_WinHann_16s(const int16_t* src, int16_t* dst, int32_t len);

  HmppResult HMPPS_WinHann_16sc(const Hmpp16sc* src, Hmpp16sc* dst, int32_t len);

- 浮点数的操作：
  HmppResult HMPPS_WinHann_32f(const float* src, float* dst, int32_t len);

  HmppResult HMPPS_WinHann_64f(const double* src, double* dst, int32_t len);

  HmppResult HMPPS_WinHann_32fc(const Hmpp32fc* src, Hmpp32fc* dst, int32_t len);

  HmppResult HMPPS_WinHann_64fc(const Hmpp64fc* src, Hmpp64fc* dst, int32_t len);

- 整型数的原址操作：
  HmppResult HMPPS_WinHann_16s_I(int16_t* srcDst, int32_t len);

  HmppResult HMPPS_WinHann_16sc_I(Hmpp16sc* srcDst, int32_t len);

- 浮点数的原址操作：
  HmppResult HMPPS_WinHann_32f_I(float* srcDst, int32_t len);

  HmppResult HMPPS_WinHann_64f_I(double* srcDst, int32_t len);

  HmppResult HMPPS_WinHann_32fc_I(Hmpp32fc* srcDst, int32_t len);

  HmppResult HMPPS_WinHann_64fc_I(Hmpp64fc* srcDst, int32_t len);


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| src | 指向源向量的指针。 | 非空 | 输入 |
| dst | 指向目的向量的指针。 | 非空 | 输出 |
| srcDst | 指向原址操作向量的指针。 | 非空 | 输入/输出 |
| len | 向量长度。 | (0,INT\_MAX] | 输入 |


#### 返回值

- 成功：返回HMPP_STS_NO_ERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| HMPP\_STS\_NULL\_PTR\_ERR | src、dst、srcDst这几个入参中存在空指针。 |
| HMPP\_STS\_SIZE\_ERR | len小于3。 |


#### 示例

```
#define BUFFER_SIZE_T 10
int main()
{
int16_t src[BUFFER_SIZE_T] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int16_t dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_16s(dst, BUFFER_SIZE_T); // 数组初始化，将dst所有元素初始化为0.
HmppResult result = HMPPS_WinHann_16s(src, dst, BUFFER_SIZE_T);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return -1;
}
printf("dst =");
for (int32_t i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %d", dst[i]);
}
return 0;
}
```

运行结果：


```
result = 0
dst = 0 0 1 2 4 5 4 3 1 0
```
