Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

__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 
);

[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.

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.

Intrinsic

Architecture

__m64_pavg2_nraz

IPF

Header file <intrin.h>

If fractional, the result of each average is rounded to the nearest odd integer. The suffix nraz means "not rounding away from zero."

// 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 }

Community Additions

ADD
Show:
© 2015 Microsoft