Partilhar via


__m64_pavg1_nraz

Microsoft Specific

Emits the 1-byte form of the IPF Parallel Average (pavg1) instruction, which computes the average of the two unsigned 8-bit integers in each byte of the input arguments and puts that average in the corresponding byte of the result.

__m64 __m64_pavg1_nraz( 
   __m64 a, 
   __m64 b 
);

Parameters

  • [in] a
    An __m64 union containing an array of eight unsigned 8-bit integers.

  • [in] b
    An __m64 union containing an array of eight unsigned 8-bit integers.

Return Value

An __m64 union containing the array of eight unsigned 8-bit integers, each position of which is the average of the corresponding integers in the source arrays.

Requirements

Intrinsic

Architecture

__m64_pavg1_nraz

IPF

Header file <intrin.h>

Remarks

If fractional, the result in each byte is rounded off to the nearest odd number. The suffix nraz means "not rounding away from zero."

Example

// pavg1_nraz.cpp
// processor: IPF
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(__m64_pavg1_nraz)

void print8u(unsigned __int8* ia)
{
    printf_s("{ %4u, %4u, %4u, %4u, %4u, %4u, %4u, %4u }\n",
             ia[0], ia[1], ia[2], ia[3], ia[4], ia[5], ia[6], ia[7] );
}


int main()
{
    __m64 m, n, result;
    unsigned __int8 ra[8], i;
    unsigned __int8 ma[8] = { 10, 10, 10, 10, 10, 10, 10, 10 };
    unsigned __int8 na[8] = { 1, 3, 5,   7,   9, 11, 15, 1 }; 

    for (i = 0; i < 8; i++)
    {
       m.m64_u8[i] = ma[i];
       n.m64_u8[i] = na[i];
    }
    
    printf_s("a: \n");
    print8u(ma);
    printf_s("b: \n");
    print8u(na);
    printf_s("\n");

    result = __m64_pavg1_nraz(m, n);    
    printf_s("Parallel Average (a[]+b[])/2 : \n");
    print8u(result.m64_u8);
    printf_s("\n");
       
    // This operation is commutative.
    result = __m64_pavg1_nraz(n, m); 
    printf_s("Parallel Average (b[]+a[])/2 : \n");
    print8u(result.m64_u8);
    printf_s("\n");

}
a: 
{   10,   10,   10,   10,   10,   10,   10,   10 }
b: 
{    1,    3,    5,    7,    9,   11,   15,    1 }

Parallel Average (a[]+b[])/2 : 
{    5,    7,    7,    9,    9,   11,   13,    5 }

Parallel Average (b[]+a[])/2 : 
{    5,    7,    7,    9,    9,   11,   13,    5 }

See Also

Reference

__m64

Compiler Intrinsics