LShiftC
Shifts a vector leftwards with no saturation, including the 8u, 16u, 16s, and 32s data types. In this function, saturation is not performed on the data after the shift, and the sign bits are not retained for signed numbers.
The function interface declaration is as follows:
Left shift operations on integers:
HmppResult HMPPS_LShiftC_8u(const uint8_t* src, int32_t val, uint8_t* dst, int32_t len);
HmppResult HMPPS_LShiftC_16u(const uint16_t* src, int32_t val, uint16_t* dst, int32_t len);
HmppResult HMPPS_LShiftC_16s(const int16_t* src, int32_t val, int16_t* dst, int32_t len);
HmppResult HMPPS_LShiftC_32s(const int32_t* src, int32_t val, int32_t* dst, int32_t len);
HmppResult HMPPS_LShiftC_8u_I(int32_t val, uint8_t* srcDst, int32_t len);
HmppResult HMPPS_LShiftC_16u_I(int32_t val, uint16_t* srcDst, int32_t len);
HmppResult HMPPS_LShiftC_16s_I(int32_t val, int16_t* srcDst, int32_t len);
HmppResult HMPPS_LShiftC_32s_I(int32_t val, int32_t* srcDst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the input vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the output vector after left shift |
The value cannot be NULL. |
Output |
srcDst |
Pointer to the source vector for in-place operations |
The value cannot be NULL. |
Input/Output |
val |
Number of left shift bits |
Non-negative |
Input |
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 src, dst, or srcDst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
HMPP_STS_SHIFT_ERR |
The value of val is less than 0. |
Example
#define BUFFER_SIZE_T 9
void LShiftCExample()
{
uint8_t src[BUFFER_SIZE_T] = {0, 1, 2, 3, 4, 5, 6, 7, 255};
uint8_t dst[BUFFER_SIZE_T] = {0};
int32_t i;
HmppResult result = HMPPS_LShiftC_8u(src, 1, dst, BUFFER_SIZE_T);
printf("result = %d \ndst =", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (i = 0; i < BUFFER_SIZE_T; i++) {
printf("%d ", dst[i]);
}
}
Output:
result = 0 dst = 0 2 4 6 8 10 12 14 254