pixelshift: speedup and new experimental ISO adaption
This commit is contained in:
@@ -169,18 +169,22 @@ void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, ar
|
|||||||
auto yUp = y - 1, yDown = y + 1;
|
auto yUp = y - 1, yDown = y + 1;
|
||||||
bool lastXUp = false, lastXDown = false, firstXUp = false, firstXDown = false;
|
bool lastXUp = false, lastXDown = false, firstXUp = false, firstXDown = false;
|
||||||
mask[y][x] = 0;
|
mask[y][x] = 0;
|
||||||
|
|
||||||
if(yUp >= yStart && mask[yUp][x] == 255) {
|
if(yUp >= yStart && mask[yUp][x] == 255) {
|
||||||
coordStack.emplace(x, yUp);
|
coordStack.emplace(x, yUp);
|
||||||
firstXUp = lastXUp = true;
|
firstXUp = lastXUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yDown < yEnd && mask[yDown][x] == 255) {
|
if(yDown < yEnd && mask[yDown][x] == 255) {
|
||||||
coordStack.emplace(x, yDown);
|
coordStack.emplace(x, yDown);
|
||||||
firstXDown = lastXDown = true;
|
firstXDown = lastXDown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto xr = x + 1;
|
auto xr = x + 1;
|
||||||
|
|
||||||
while(xr < xEnd && mask[y][xr] == 255) {
|
while(xr < xEnd && mask[y][xr] == 255) {
|
||||||
mask[y][xr] = 0;
|
mask[y][xr] = 0;
|
||||||
|
|
||||||
if(yUp >= yStart && mask[yUp][xr] == 255) {
|
if(yUp >= yStart && mask[yUp][xr] == 255) {
|
||||||
if(!lastXUp) {
|
if(!lastXUp) {
|
||||||
coordStack.emplace(xr, yUp);
|
coordStack.emplace(xr, yUp);
|
||||||
@@ -189,6 +193,7 @@ void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, ar
|
|||||||
} else {
|
} else {
|
||||||
lastXUp = false;
|
lastXUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yDown < yEnd && mask[yDown][xr] == 255) {
|
if(yDown < yEnd && mask[yDown][xr] == 255) {
|
||||||
if(!lastXDown) {
|
if(!lastXDown) {
|
||||||
coordStack.emplace(xr, yDown);
|
coordStack.emplace(xr, yDown);
|
||||||
@@ -197,14 +202,17 @@ void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, ar
|
|||||||
} else {
|
} else {
|
||||||
lastXDown = false;
|
lastXDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xr++;
|
xr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto xl = x - 1;
|
auto xl = x - 1;
|
||||||
lastXUp = firstXUp;
|
lastXUp = firstXUp;
|
||||||
lastXDown = firstXDown;
|
lastXDown = firstXDown;
|
||||||
|
|
||||||
while(xl >= xStart && mask[y][xl] == 255) {
|
while(xl >= xStart && mask[y][xl] == 255) {
|
||||||
mask[y][xl] = 0;
|
mask[y][xl] = 0;
|
||||||
|
|
||||||
if(yUp >= yStart && mask[yUp][xl] == 255) {
|
if(yUp >= yStart && mask[yUp][xl] == 255) {
|
||||||
if(!lastXUp) {
|
if(!lastXUp) {
|
||||||
coordStack.emplace(xl, yUp);
|
coordStack.emplace(xl, yUp);
|
||||||
@@ -213,6 +221,7 @@ void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, ar
|
|||||||
} else {
|
} else {
|
||||||
lastXUp = false;
|
lastXUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yDown < yEnd && mask[yDown][xl] == 255) {
|
if(yDown < yEnd && mask[yDown][xl] == 255) {
|
||||||
if(!lastXDown) {
|
if(!lastXDown) {
|
||||||
coordStack.emplace(xl, yDown);
|
coordStack.emplace(xl, yDown);
|
||||||
@@ -221,8 +230,10 @@ void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, ar
|
|||||||
} else {
|
} else {
|
||||||
lastXDown = false;
|
lastXDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xl--;
|
xl--;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask[y][x] = 0;
|
mask[y][x] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,12 +246,18 @@ void floodFill4(int xStart, int xEnd, int yStart, int yEnd, array2D<uint8_t> &ma
|
|||||||
std::stack<std::pair<uint16_t, uint16_t>, std::vector<std::pair<uint16_t, uint16_t>>> coordStack;
|
std::stack<std::pair<uint16_t, uint16_t>, std::vector<std::pair<uint16_t, uint16_t>>> coordStack;
|
||||||
|
|
||||||
#pragma omp for schedule(dynamic,128) nowait
|
#pragma omp for schedule(dynamic,128) nowait
|
||||||
for(uint16_t i = yStart;i<yEnd;i++)
|
|
||||||
|
for(uint16_t i = yStart; i < yEnd; i++)
|
||||||
|
{
|
||||||
floodFill4Impl(i, xStart, xStart, xEnd, yStart, yEnd, mask, coordStack);
|
floodFill4Impl(i, xStart, xStart, xEnd, yStart, yEnd, mask, coordStack);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma omp for schedule(dynamic,128) nowait
|
#pragma omp for schedule(dynamic,128) nowait
|
||||||
for(int16_t i = yEnd-1; i >= 0 ;i--)
|
|
||||||
|
for(int16_t i = yEnd - 1; i >= 0 ; i--)
|
||||||
|
{
|
||||||
floodFill4Impl(i, xEnd - 1, xStart, xEnd, yStart, yEnd, mask, coordStack);
|
floodFill4Impl(i, xEnd - 1, xStart, xEnd, yStart, yEnd, mask, coordStack);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma omp sections nowait
|
#pragma omp sections nowait
|
||||||
{
|
{
|
||||||
@@ -900,7 +917,8 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
const bool checkNonGreenAmaze = bayerParams.pixelShiftNonGreenAmaze;
|
const bool checkNonGreenAmaze = bayerParams.pixelShiftNonGreenAmaze;
|
||||||
const bool checkNonGreenCross2 = bayerParams.pixelShiftNonGreenCross2;
|
const bool checkNonGreenCross2 = bayerParams.pixelShiftNonGreenCross2;
|
||||||
const bool checkGreen = bayerParams.pixelShiftGreen;
|
const bool checkGreen = bayerParams.pixelShiftGreen;
|
||||||
const float redBlueWeight = bayerParams.pixelShiftRedBlueWeight;
|
const float greenWeight = 2.f;
|
||||||
|
const float redBlueWeight = bayerParams.pixelShiftRedBlueWeight + 1.f;
|
||||||
const bool blurMap = bayerParams.pixelShiftBlur;
|
const bool blurMap = bayerParams.pixelShiftBlur;
|
||||||
const float sigma = bayerParams.pixelShiftSigma;
|
const float sigma = bayerParams.pixelShiftSigma;
|
||||||
const float threshold = bayerParams.pixelShiftSum;
|
const float threshold = bayerParams.pixelShiftSum;
|
||||||
@@ -1077,8 +1095,13 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
nRead *= pow(2.f, nreadIso);
|
nRead *= pow(2.f, nreadIso);
|
||||||
eperIsoModel *= pow(2.f, eperIso);
|
eperIsoModel *= pow(2.f, eperIso * 0.5f);
|
||||||
|
|
||||||
|
if(adaptive && experimental0) {
|
||||||
|
eperIso = eperIsoModel * sqrtf(100.f / (rawWpCorrection * idata->getISOSpeed()));
|
||||||
|
} else {
|
||||||
eperIso = eperIsoModel * (100.f / (rawWpCorrection * idata->getISOSpeed()));
|
eperIso = eperIsoModel * (100.f / (rawWpCorrection * idata->getISOSpeed()));
|
||||||
|
}
|
||||||
|
|
||||||
float eperIsoRed = eperIso / scale_mul[0];
|
float eperIsoRed = eperIso / scale_mul[0];
|
||||||
float eperIsoGreen = eperIso * scaleGreen;
|
float eperIsoGreen = eperIso * scaleGreen;
|
||||||
@@ -1128,8 +1151,16 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
array2D<float> psG1(winw + 32, winh);
|
array2D<float> psG1(winw + 32, winh);
|
||||||
array2D<float> psG2(winw + 32, winh);
|
array2D<float> psG2(winw + 32, winh);
|
||||||
array2D<float> psBlue(winw + 32, winh);
|
array2D<float> psBlue(winw + 32, winh);
|
||||||
|
array2D<float> psMask(winw, winh);
|
||||||
|
|
||||||
|
// Fill the mask with value 1.0
|
||||||
|
// We work in 1.0 to 2.0 range to avoid performance issues caused by denormal numbers in gaussian blur
|
||||||
|
for(int i = 0; i < winh; ++i) {
|
||||||
|
for(int j = 0; j < winw; ++j) {
|
||||||
|
psMask[i][j] = 1.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
array2D<float> psMask(winw, winh, ARRAY2D_CLEAR_DATA);
|
|
||||||
// fill channels psRed, psG1, psG2 and psBlue
|
// fill channels psRed, psG1, psG2 and psBlue
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for schedule(dynamic,16)
|
#pragma omp parallel for schedule(dynamic,16)
|
||||||
@@ -1165,11 +1196,17 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now that the temporary planes are filled for easy access we do the motion detection
|
// now that the temporary planes are filled for easy access we do the motion detection
|
||||||
int sum0 = 0;
|
int sum[2] = {0};
|
||||||
int sum1 = 0;
|
|
||||||
float pixelcount = ((winh - (border + offsY) - (winy + border - offsY)) * (winw - (border + offsX) - (winx + border - offsX))) / 2.f;
|
float pixelcount = ((winh - (border + offsY) - (winy + border - offsY)) * (winw - (border + offsX) - (winx + border - offsX))) / 2.f;
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(+:sum0,sum1) schedule(dynamic,16)
|
#pragma omp parallel
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int sumThr[2] = {0};
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp for schedule(dynamic,16) nowait
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(int i = winy + border - offsY; i < winh - (border + offsY); ++i) {
|
for(int i = winy + border - offsY; i < winh - (border + offsY); ++i) {
|
||||||
@@ -1337,20 +1374,16 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
lastIndex ++;
|
lastIndex ++;
|
||||||
lastIndex = lastIndex == gridSize ? 0 : lastIndex;
|
lastIndex = lastIndex == gridSize ? 0 : lastIndex;
|
||||||
|
|
||||||
// increase motion detection dependent on brightness
|
|
||||||
if(!adaptive) {
|
if(!adaptive) {
|
||||||
|
// increase motion detection dependent on brightness
|
||||||
korr = log2Lut[((int)(psG1[i][j] * scaleGreen)) >> 1];
|
korr = log2Lut[((int)(psG1[i][j] * scaleGreen)) >> 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gridMax > thresh - korr) {
|
if (gridMax > thresh - korr) {
|
||||||
if(offset == 0) {
|
sumThr[offset] ++;
|
||||||
sum0 ++;
|
|
||||||
} else {
|
|
||||||
sum1 ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nOf3x3) {
|
if(nOf3x3) {
|
||||||
psMask[i][j] = 1.f;
|
psMask[i][j] = greenWeight;
|
||||||
} else if((offset == (frame & 1)) && checkNonGreenVertical) {
|
} else if((offset == (frame & 1)) && checkNonGreenVertical) {
|
||||||
if(frame > 1) {
|
if(frame > 1) {
|
||||||
green[i + offsY][j + offsX] = blueRow ? psG1[i][j] : psG2[i][j];
|
green[i + offsY][j + offsX] = blueRow ? psG1[i][j] : psG2[i][j];
|
||||||
@@ -1368,13 +1401,15 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
j++;
|
j++;
|
||||||
paintMotionMask(j + offsX, showMotion, (gridMax - thresh + korr) * blendFactor, showOnlyMask, greenDest, redDest, blueDest);
|
paintMotionMask(j + offsX, showMotion, (gridMax - thresh + korr) * blendFactor, showOnlyMask, greenDest, redDest, blueDest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not set the motion pixel values. They have already been set by demosaicer or showMotion
|
// do not set the motion pixel values. They have already been set by demosaicer or showMotion
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenCross) {
|
if(adaptive) {
|
||||||
|
if(checkNonGreenCross) {
|
||||||
// check red cross
|
// check red cross
|
||||||
float redTop = psRed[i - 1][ j ];
|
float redTop = psRed[i - 1][ j ];
|
||||||
float redLeft = psRed[ i ][j - 1];
|
float redLeft = psRed[ i ][j - 1];
|
||||||
@@ -1413,7 +1448,7 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenHorizontal) {
|
if(checkNonGreenHorizontal) {
|
||||||
float redLeft = psRed[ i ][j - 1];
|
float redLeft = psRed[ i ][j - 1];
|
||||||
float redCentre = psRed[ i ][ j ];
|
float redCentre = psRed[ i ][ j ];
|
||||||
float redRight = psRed[ i ][j + 1];
|
float redRight = psRed[ i ][j + 1];
|
||||||
@@ -1459,7 +1494,7 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenVertical) {
|
if(checkNonGreenVertical) {
|
||||||
// check red vertically
|
// check red vertically
|
||||||
float redTop = psRed[i - 1][ j ];
|
float redTop = psRed[i - 1][ j ];
|
||||||
float redCentre = psRed[ i ][ j ];
|
float redCentre = psRed[ i ][ j ];
|
||||||
@@ -1507,7 +1542,7 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenAmaze) {
|
if(checkNonGreenAmaze) {
|
||||||
// check current pixel against amaze
|
// check current pixel against amaze
|
||||||
float redCentre = psRed[ i ][ j ];
|
float redCentre = psRed[ i ][ j ];
|
||||||
float redAmaze = red[i + offsY][j + offsX];
|
float redAmaze = red[i + offsY][j + offsX];
|
||||||
@@ -1540,14 +1575,14 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && checkNonGreenCross2) { // for green amaze
|
if(checkNonGreenCross2) { // for green amaze
|
||||||
float greenCentre = (psG1[ i ][ j ] + psG2[ i ][ j ]) / 2.f;
|
float greenCentre = (psG1[ i ][ j ] + psG2[ i ][ j ]) / 2.f;
|
||||||
float greenAmaze = green[i + offsY][j + offsX];
|
float greenAmaze = green[i + offsY][j + offsX];
|
||||||
float greenDiffAmaze = nonGreenDiff(greenCentre, greenAmaze, stddevFactorGreen, eperIsoGreen, nRead, prnu, showMotion);
|
float greenDiffAmaze = nonGreenDiff(greenCentre, greenAmaze, stddevFactorGreen, eperIsoGreen, nRead, prnu, showMotion);
|
||||||
|
|
||||||
if(greenDiffAmaze > 0.f) {
|
if(greenDiffAmaze > 0.f) {
|
||||||
if(nOf3x3) {
|
if(nOf3x3) {
|
||||||
psMask[i][j] = 1.f;
|
psMask[i][j] = greenWeight;
|
||||||
} else {
|
} else {
|
||||||
paintMotionMask(j + offsX, showMotion, greenDiffAmaze, showOnlyMask, greenDest, redDest, blueDest);
|
paintMotionMask(j + offsX, showMotion, greenDiffAmaze, showOnlyMask, greenDest, redDest, blueDest);
|
||||||
}
|
}
|
||||||
@@ -1556,23 +1591,24 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adaptive && experimental0) { // for experiments
|
if(experimental0) { // for experiments
|
||||||
// float green1Median, green2Median;
|
// float green1Median, green2Median;
|
||||||
// green1Median = median(psG1[ i - 1 ][ j - 1 ],psG1[ i - 1 ][ j + 1 ],psG1[ i ][ j ],psG1[ i + 1 ][ j -1 ],psG1[ i + 1 ][ j + 1 ]);
|
// green1Median = median(psG1[ i - 1 ][ j - 1 ],psG1[ i - 1 ][ j + 1 ],psG1[ i ][ j ],psG1[ i + 1 ][ j -1 ],psG1[ i + 1 ][ j + 1 ]);
|
||||||
// green2Median = median(psG2[ i - 1 ][ j - 1 ],psG2[ i - 1 ][ j + 1 ],psG2[ i ][ j ],psG2[ i + 1 ][ j -1 ],psG2[ i + 1 ][ j + 1 ]);
|
// green2Median = median(psG2[ i - 1 ][ j - 1 ],psG2[ i - 1 ][ j + 1 ],psG2[ i ][ j ],psG2[ i + 1 ][ j -1 ],psG2[ i + 1 ][ j + 1 ]);
|
||||||
// float greenDiffMedian = nonGreenDiff(green1Median, green2Median, stddevFactorGreen * 0.36f, eperIsoGreen, nRead, prnu, showMotion);
|
// float greenDiffMedian = nonGreenDiff(green1Median, green2Median, stddevFactorGreen * 0.36f, eperIsoGreen, nRead, prnu, showMotion);
|
||||||
//
|
//
|
||||||
// if(greenDiffMedian > 0.f) {
|
// if(greenDiffMedian > 0.f) {
|
||||||
// if(nOf3x3) {
|
// if(nOf3x3) {
|
||||||
// psMask[i][j] = 1.f;
|
// psMask[i][j] = 1.f;
|
||||||
// } else {
|
// } else {
|
||||||
// paintMotionMask(j + offsX, showMotion, greenDiffMedian, showOnlyMask, greenDest, redDest, blueDest);
|
// paintMotionMask(j + offsX, showMotion, greenDiffMedian, showOnlyMask, greenDest, redDest, blueDest);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(showMotion && showOnlyMask) { // we want only motion mask => paint areas without motion in pure black
|
if(showMotion && showOnlyMask) { // we want only motion mask => paint areas without motion in pure black
|
||||||
red[i + offsY][j + offsX] = green[i + offsY][j + offsX] = blue[i + offsY][j + offsX] = 0.f;
|
red[i + offsY][j + offsX] = green[i + offsY][j + offsX] = blue[i + offsY][j + offsX] = 0.f;
|
||||||
@@ -1585,13 +1621,22 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float percent0 = 100.f * sum0 / pixelcount;
|
#ifdef _OPENMP
|
||||||
float percent1 = 100.f * sum1 / pixelcount;
|
#pragma omp critical
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
sum[0] += sumThr[0];
|
||||||
|
sum[1] += sumThr[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float percent0 = 100.f * sum[0] / pixelcount;
|
||||||
|
float percent1 = 100.f * sum[1] / pixelcount;
|
||||||
|
|
||||||
std::cout << fileName << " : Green detections at stddev " << std::setprecision( 2 ) << bayerParams.pixelShiftStddevFactorGreen << " : Frame 1/3 : " << std::setprecision( 6 ) << sum0 << " (" << percent0 << "%)" << " Frame 2/4 : " << sum1 << " (" << percent1 << "%)" << std::endl;
|
std::cout << fileName << " : Green detections at stddev " << std::setprecision( 2 ) << bayerParams.pixelShiftStddevFactorGreen << " : Frame 1/3 : " << std::setprecision( 6 ) << sum[0] << " (" << percent0 << "%)" << " Frame 2/4 : " << sum[1] << " (" << percent1 << "%)" << std::endl;
|
||||||
|
|
||||||
if(adaptive && nOf3x3) {
|
if(adaptive && nOf3x3) {
|
||||||
if(blurMap) {
|
if(blurMap) {
|
||||||
|
StopWatch Stop1("Blur");
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
gaussianBlur(psMask, psMask, winw, winh, sigma);
|
gaussianBlur(psMask, psMask, winw, winh, sigma);
|
||||||
@@ -1611,14 +1656,14 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
|
|
||||||
for(int v = -1; v <= 1; v++) {
|
for(int v = -1; v <= 1; v++) {
|
||||||
for(int h = -1; h < 1; h++) {
|
for(int h = -1; h < 1; h++) {
|
||||||
v3sum[1 + h] += psMask[i + v][j + h];
|
v3sum[1 + h] += (psMask[i + v][j + h] - 1.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float blocksum = v3sum[0] + v3sum[1];
|
float blocksum = v3sum[0] + v3sum[1];
|
||||||
|
|
||||||
for(int voffset = 2; j < winw - (border + offsX); ++j, ++voffset) {
|
for(int voffset = 2; j < winw - (border + offsX); ++j, ++voffset) {
|
||||||
float colSum = psMask[i - 1][j + 1] + psMask[i][j + 1] + psMask[i + 1][j + 1];
|
float colSum = psMask[i - 1][j + 1] + psMask[i][j + 1] + psMask[i + 1][j + 1] - 3.f;
|
||||||
voffset = voffset == 3 ? 0 : voffset; // faster than voffset %= 3;
|
voffset = voffset == 3 ? 0 : voffset; // faster than voffset %= 3;
|
||||||
blocksum -= v3sum[voffset];
|
blocksum -= v3sum[voffset];
|
||||||
blocksum += colSum;
|
blocksum += colSum;
|
||||||
@@ -1640,26 +1685,31 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
|
|
||||||
for(int i = winy + border - offsY; i < winh - (border + offsY); ++i) {
|
for(int i = winy + border - offsY; i < winh - (border + offsY); ++i) {
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
|
|
||||||
if(!(showMotion && showOnlyMask) && smoothTransitions) {
|
if(!(showMotion && showOnlyMask) && smoothTransitions) {
|
||||||
if(smoothFactor == 0.f) {
|
if(smoothFactor == 0.f) {
|
||||||
for(int j = winx + border - offsX; j < winw - (border + offsX); ++j) {
|
for(int j = winx + border - offsX; j < winw - (border + offsX); ++j) {
|
||||||
psMask[i][j] = 1.f;
|
psMask[i][j] = greenWeight - 1.f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vfloat zerov = F2V(0.f);
|
vfloat zerov = F2V(0.f);
|
||||||
|
vfloat onev = F2V(1.f);
|
||||||
vfloat smoothv = F2V(smoothFactor);
|
vfloat smoothv = F2V(smoothFactor);
|
||||||
int j = winx + border - offsX;
|
int j = winx + border - offsX;
|
||||||
for(; j < winw - (border + offsX)- 3; j += 4) {
|
|
||||||
vfloat blendv = LVFU(psMask[i][j]);
|
for(; j < winw - (border + offsX) - 3; j += 4) {
|
||||||
|
vfloat blendv = LVFU(psMask[i][j]) - onev;
|
||||||
blendv = vmaxf(blendv, zerov);
|
blendv = vmaxf(blendv, zerov);
|
||||||
blendv = pow_F(blendv, smoothv);
|
blendv = pow_F(blendv, smoothv);
|
||||||
STVFU(psMask[i][j], blendv);
|
STVFU(psMask[i][j], blendv);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(; j < winw - (border + offsX); ++j) {
|
for(; j < winw - (border + offsX); ++j) {
|
||||||
psMask[i][j] = pow_F(std::max(psMask[i][j],0.f),smoothFactor);
|
psMask[i][j] = pow_F(std::max(psMask[i][j] - 1.f, 0.f), smoothFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
float *greenDest = green[i + offsY];
|
float *greenDest = green[i + offsY];
|
||||||
float *redDest = red[i + offsY];
|
float *redDest = red[i + offsY];
|
||||||
@@ -1678,10 +1728,10 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA
|
|||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
float blend = psMask[i][j];
|
float blend = psMask[i][j];
|
||||||
#else
|
#else
|
||||||
float blend = pow_F(std::max(psMask[i][j],0.f),smoothFactor);
|
float blend = pow_F(std::max(psMask[i][j] - 1.f, 0.f), smoothFactor);
|
||||||
#endif
|
#endif
|
||||||
red[i + offsY][j + offsX] = intp(blend, red[i + offsY][j + offsX], psRed[i][j] );
|
red[i + offsY][j + offsX] = intp(blend, red[i + offsY][j + offsX], psRed[i][j] );
|
||||||
green[i + offsY][j + offsX] = intp(blend, green[i + offsY][j + offsX],(psG1[i][j] + psG2[i][j]) / 2.f);
|
green[i + offsY][j + offsX] = intp(blend, green[i + offsY][j + offsX], (psG1[i][j] + psG2[i][j]) / 2.f);
|
||||||
blue[i + offsY][j + offsX] = intp(blend, blue[i + offsY][j + offsX], psBlue[i][j]);
|
blue[i + offsY][j + offsX] = intp(blend, blue[i + offsY][j + offsX], psBlue[i][j]);
|
||||||
} else {
|
} else {
|
||||||
red[i + offsY][j + offsX] = psRed[i][j];
|
red[i + offsY][j + offsX] = psRed[i][j];
|
||||||
|
Reference in New Issue
Block a user