Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
int shift = IF_INTERNAL_PREC - bitDepth;
   short offset = IF_INTERNAL_OFFS;
   offset += shift?(1 >> (shift - 1)):0;
   short maxVal = (1 >> bitDepth) - 1;
   short minVal = 0;
   //short val;
   for (row = 0; row < height; row++)
   {
     for (col = 0; col < width; col++)
     {
         
       short val = src[ col ];
       val = ( val + offset ) >> shift;
     
     
     
      if (val < minVal) val = minVal;
      if (val > maxVal) val = maxVal;
       dst[col] = val;
     }


I had written a intrinsics for the given c code
which is not correct. I am struck with If-else and assigning min val and max val to four short int and how to assisgn one short int value which is less or greater among the four short int as I am dealing with 16 bit values.

C++
int shift = IF_INTERNAL_PREC - bitDepth;
short offset = IF_INTERNAL_OFFS;
offset += shift?(1 << (shift - 1)):0;
short maxVal = (1 << bitDepth) - 1;
short minVal = 0;
short val;
for (row = 0; row < height; row++)
{
  for (col = 0; col < width; col++)
  {


      val = ( src[col] + offset ) >> shift;

      dst[col]= (val > minVal) ? (val>maxVal)? maxVal:val :minVal;

  }

  src += srcStride;
  dst += dstStride;



}

Please help me as I am new with mmx intrinsics.
Posted
Updated 24-Jul-13 0:54am
v2

1 solution

here is something strange:

C#
offset += shift?(1 << (shift - 1)):0;
  short maxVal = (1 << bitDepth) - 1;


work with the const keyword where possible
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900