__m64_pavg2_nraz
Microsoft Specific
Emits the 2-byte form of the IPF Parallel Average (pavg2) instruction, which computes the average of the two unsigned short integers in each 16-bit block of the input arguments and puts that average in the corresponding 16-bit block of the result.
__m64 __m64_pavg2_nraz(
__m64 a,
__m64 b
);
Parameters
[in] a
An __m64 union containing an array of four unsigned 16-bit integers.[in] b
An __m64 union containing an array of four unsigned 16-bit integers.
Return Value
An __m64 union containing the array of four unsigned 16-bit integers, each element of which is the average of the corresponding integers in the source arrays.
Requirements
Intrinsic |
Architecture |
---|---|
__m64_pavg2_nraz |
IPF |
Header file <intrin.h>
Remarks
If fractional, the result of each average is rounded to the nearest odd integer. The suffix nraz means "not rounding away from zero."
Example
// pavg2_nraz.cpp
// processor: IPF
#include <stdio.h>
#include <intrin.h>
#pragma intrinsic(__m64_pavg2_nraz)
void print4u(unsigned __int16* ia)
{
printf_s("{ %8u, %8u, %8u, %8u }\n", ia[0], ia[1], ia[2], ia[3] );
}
int main()
{
__m64 m, n, result;
unsigned __int16 ra[4], i;
unsigned __int16 ma[4] = { 10, 100, 70, 10000 };
unsigned __int16 na[4] = { 1, 95, 50, 5000 };
for (i = 0; i < 4; i++)
{
m.m64_u16[i] = ma[i];
n.m64_u16[i] = na[i];
}
printf_s("a: \n");
print4u(ma);
printf_s("b: \n");
print4u(na);
printf_s("\n");
result = __m64_pavg2_nraz(m, n);
printf_s("Parallel Average (a[]+b[])/2 : \n");
print4u(result.m64_u16);
printf_s("\n");
// This operation is commutative.
result = __m64_pavg2_nraz(n, m);
printf_s("Parallel Average (b[]+a[])/2 : \n");
print4u(result.m64_u16);
printf_s("\n");
}
a: { 10, 100, 70, 10000 } b: { 1, 95, 50, 5000 } Parallel Average (a[]+b[])/2 : { 5, 97, 60, 7500 } Parallel Average (b[]+a[])/2 : { 5, 97, 60, 7500 }