Advertisement
canezzy

clip

Apr 3rd, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include "Clip.h"
  2.  
  3.  
  4. extern concurrent_vector<short> highPass2ClipQueue;
  5. extern concurrent_vector<unsigned char> clip2CounterVector;
  6.  
  7.  
  8. struct ClipClass {
  9.     concurrent_vector<short>& myhighPass2ClipQueue;
  10.     concurrent_vector<unsigned char>& myclip2CounterVector;
  11.     char myLowerValue, myUpperValue;
  12.     ClipClass(concurrent_vector<short>& q, concurrent_vector<unsigned char>& v, char& c1, char& c2) : myhighPass2ClipQueue{ q }, myclip2CounterVector{ v }, myLowerValue{ c1 }, myUpperValue{ c2 } {}
  13.     void operator()(const blocked_range<unsigned int> range) const {
  14.         for (int p = range.begin(); p != range.end(); ++p){
  15.             short data = highPass2ClipQueue.at(p);
  16.             if (data < myLowerValue)
  17.             {
  18.                 data = myLowerValue;
  19.             }
  20.             else if (data > myUpperValue)
  21.             {
  22.                 data = myUpperValue;
  23.             }
  24.             myclip2CounterVector.push_back((unsigned char)data);
  25.         }
  26.     }
  27.  
  28.  
  29. };
  30. RetVal Clip(char lowerValue, char upperValue)
  31. {
  32.  
  33.     // clipping loop
  34.     parallel_for(blocked_range<unsigned int>(0, highPass2ClipQueue.size()), ClipClass(highPass2ClipQueue, clip2CounterVector, lowerValue, upperValue));
  35.     return RET_OK;
  36. }
  37.  
  38.  
  39.  
  40. ----------------------------------------------------------------------------------------------
  41.  
  42. #ifndef _CLIP_H_
  43. #define _CLIP_H_
  44.  
  45. #include <queue>
  46. #include <vector>
  47. #include "tbb/concurrent_vector.h"
  48. #include "tbb/parallel_for.h"
  49. #include "defines.h"
  50.  
  51. #include "tbb/blocked_range.h"
  52.  
  53. using namespace std;
  54. using namespace tbb;
  55.  
  56. RetVal Clip(char lowerValue, char upperValue);
  57.  
  58. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement