RShiftC
Shifts the vector rightwards. There are four data types: 8u, 16u, 16s, and 32s. Right shift preserves the sign bit of a signed integer and fills the sign bit from the left.
The function interface is declared as follows:
Left shift operations on integers:
HmppResult HMPPS_RShiftC_8u(const uint8_t* src, int32_t val, uint8_t* dst, int32_t len);
HmppResult HMPPS_RShiftC_16u(const uint16_t* src, int32_t val, uint16_t* dst, int32_t len);
HmppResult HMPPS_RShiftC_16s(const int16_t* src, int32_t val, int16_t* dst, int32_t len);
HmppResult HMPPS_RShiftC_32s(const int32_t* src, int32_t val, int32_t* dst, int32_t len);
HmppResult HMPPS_RShiftC_8u_I(int32_t val, uint8_t* srcDst, int32_t len);
HmppResult HMPPS_RShiftC_16u_I(int32_t val, uint16_t* srcDst, int32_t len);
HmppResult HMPPS_RShiftC_16s_I(int32_t val, int16_t* srcDst, int32_t len);
HmppResult HMPPS_RShiftC_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 RShiftCExample()
{
uint8_t src[BUFFER_SIZE_T] = {0, 1, 2, 3, 4, 5, 6, 7, 255};
uint8_t dst[BUFFER_SIZE_T] = {};
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