我要评分
获取效率
正确性
完整性
易理解

AndC

Performs bitwise AND between a constant and each element of a vector.

The function interface is declared as follows:

  • Operations on integers:

    HmppResult HMPPS_AndC_8u(const uint8_t* src, uint8_t val, uint8_t* dst, int32_t len);

    HmppResult HMPPS_AndC_16u(const uint16_t* src, uint16_t val, uint16_t* dst, int32_t len);

    HmppResult HMPPS_AndC_32u(const uint32_t* src, uint32_t val, uint32_t* dst, int32_t len);

  • In-place operations on integers:

    HmppResult HMPPS_AndC_8u_I(uint8_t val, uint8_t* srcDst, int32_t len);

    HmppResult HMPPS_AndC_16u_I(uint16_t val, uint16_t* srcDst, int32_t len);

    HmppResult HMPPS_AndC_32u_I(uint32_t val, uint32_t* srcDst, int32_t len)

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

val

Fixed value

Not limited, depending on the type

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

srcDst

Pointer to the source vector for in-place operations

The value cannot be NULL.

Input/Output

len

Vector length

(0, INT_MAX]

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of src1, src2, dst, or srcDst is NULL.

HMPP_STS_SIZE_ERR

The value of len is less than or equal to 0.

Example

#define BUFFER_SIZE_T 10

void AndCExample(void)
{
    uint16_t src[BUFFER_SIZE_T] = {55102, 65510, 45878, 34567, 55102, 65510, 45878, 34567, 55102, 65510};
    uint16_t dst[BUFFER_SIZE_T] = {};
    uint16_t val = 32574;
    int32_t i, result;
    result = HMPPS_AndC_16u(src, val, dst, BUFFER_SIZE_T);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("result = %d \n dst =", result);
    for (i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %d ", dst[i]);
    }
}

Output:

result = 0
dst = 22334 32550 13110 1798 22334 32550 13110 1798 22334 32550