ImProcCoordinator::updateVectorscope(): parallelize loops
This commit is contained in:
parent
3af822b6f7
commit
9e040b3bc2
@ -211,6 +211,24 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
array2D<T>& operator+=(const array2D<T>& rhs)
|
||||||
|
{
|
||||||
|
if (rhs.getWidth() == this->getWidth() && rhs.getHeight() == this->getHeight()) {
|
||||||
|
for (int i = 0; i < getHeight(); ++i) {
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp simd
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int j = 0; j < getWidth(); ++j) {
|
||||||
|
rows[i][j] += rhs[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int getWidth() const
|
int getWidth() const
|
||||||
{
|
{
|
||||||
return width;
|
return width;
|
||||||
|
@ -1863,35 +1863,65 @@ BENCHFUN
|
|||||||
|
|
||||||
vectorscopeScale = (x2 - x1) * (y2 - y1);
|
vectorscopeScale = (x2 - x1) * (y2 - y1);
|
||||||
if (hListener->vectorscopeType() == 0) { // HS
|
if (hListener->vectorscopeType() == 0) { // HS
|
||||||
for (int i = y1; i < y2; ++i) {
|
#ifdef _OPENMP
|
||||||
int ofs = (i * pW + x1) * 3;
|
#pragma omp parallel
|
||||||
for (int j = x1; j < x2; ++j) {
|
#endif
|
||||||
const float red = 257.f * workimg->data[ofs++];
|
{
|
||||||
const float green = 257.f * workimg->data[ofs++];
|
array2D<int> vectorscopeThr(size, size, ARRAY2D_CLEAR_DATA);
|
||||||
const float blue = 257.f * workimg->data[ofs++];
|
#ifdef _OPENMP
|
||||||
float h, s, l;
|
#pragma omp for nowait
|
||||||
Color::rgb2hslfloat(red, green, blue, h, s, l);
|
#endif
|
||||||
const auto sincosval = xsincosf(2.f * RT_PI_F * h);
|
for (int i = y1; i < y2; ++i) {
|
||||||
const int col = s * sincosval.y * (size / 2) + size / 2;
|
int ofs = (i * pW + x1) * 3;
|
||||||
const int row = s * sincosval.x * (size / 2) + size / 2;
|
for (int j = x1; j < x2; ++j) {
|
||||||
if (col >= 0 && col < size && row >= 0 && row < size) {
|
const float red = 257.f * workimg->data[ofs++];
|
||||||
vectorscope[row][col]++;
|
const float green = 257.f * workimg->data[ofs++];
|
||||||
|
const float blue = 257.f * workimg->data[ofs++];
|
||||||
|
float h, s, l;
|
||||||
|
Color::rgb2hslfloat(red, green, blue, h, s, l);
|
||||||
|
const auto sincosval = xsincosf(2.f * RT_PI_F * h);
|
||||||
|
const int col = s * sincosval.y * (size / 2) + size / 2;
|
||||||
|
const int row = s * sincosval.x * (size / 2) + size / 2;
|
||||||
|
if (col >= 0 && col < size && row >= 0 && row < size) {
|
||||||
|
vectorscopeThr[row][col]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp critical
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vectorscope += vectorscopeThr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (hListener->vectorscopeType() == 1) { // CH
|
} else if (hListener->vectorscopeType() == 1) { // CH
|
||||||
const std::unique_ptr<float[]> a(new float[vectorscopeScale]);
|
const std::unique_ptr<float[]> a(new float[vectorscopeScale]);
|
||||||
const std::unique_ptr<float[]> b(new float[vectorscopeScale]);
|
const std::unique_ptr<float[]> b(new float[vectorscopeScale]);
|
||||||
const std::unique_ptr<float[]> L(new float[vectorscopeScale]);
|
const std::unique_ptr<float[]> L(new float[vectorscopeScale]);
|
||||||
ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm);
|
ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm);
|
||||||
for (int i = y1; i < y2; ++i) {
|
#ifdef _OPENMP
|
||||||
for (int j = x1, ofs_lab = (i - y1) * (x2 - x1); j < x2; ++j, ++ofs_lab) {
|
#pragma omp parallel
|
||||||
const int col = (size / 96000.f) * a[ofs_lab] + size / 2;
|
#endif
|
||||||
const int row = (size / 96000.f) * b[ofs_lab] + size / 2;
|
{
|
||||||
if (col >= 0 && col < size && row >= 0 && row < size) {
|
array2D<int> vectorscopeThr(size, size, ARRAY2D_CLEAR_DATA);
|
||||||
vectorscope[row][col]++;
|
#ifdef _OPENMP
|
||||||
|
#pragma omp for nowait
|
||||||
|
#endif
|
||||||
|
for (int i = y1; i < y2; ++i) {
|
||||||
|
for (int j = x1, ofs_lab = (i - y1) * (x2 - x1); j < x2; ++j, ++ofs_lab) {
|
||||||
|
const int col = (size / 96000.f) * a[ofs_lab] + size / 2;
|
||||||
|
const int row = (size / 96000.f) * b[ofs_lab] + size / 2;
|
||||||
|
if (col >= 0 && col < size && row >= 0 && row < size) {
|
||||||
|
vectorscopeThr[row][col]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp critical
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vectorscope += vectorscopeThr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user