将这段C代码更改为内在函数 [英] changing this piece of c code to intrinsics

查看:74
本文介绍了将这段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;
     }





我为给定的c代码编写了内在函数

这是不正确的。我对If-else感到震惊,并将最小值和最大值分配给四个短整数,以及如何在四个短整数中分配一个短的int值,因为我正在处理16位值。





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.

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;



}



请帮助我,因为我是mmx intrinsics的新手。


Please help me as I am new with mmx intrinsics.

推荐答案

这里有些奇怪:



here is something strange:

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





在可能的情况下使用const关键字



work with the const keyword where possible


这篇关于将这段C代码更改为内在函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆