Some little cleanups to rtlensfun.*

- Sanitize `std::unique_ptr<>` handling
- Use `NonCopyable`
- Employ `explicit operator bool()`
- Correct use of `std::vector::emplace_back()`
- Cleanup includes
- Streamline implementation order
This commit is contained in:
Flössie
2017-09-12 20:58:20 +02:00
parent 2d1cca8cbb
commit f2853d8742
4 changed files with 89 additions and 65 deletions

View File

@@ -319,18 +319,21 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
float focusDist = metadata->getFocusDist();
double fNumber = metadata->getFNumber();
LensCorrection *pLCPMap = nullptr;
std::unique_ptr<const LensCorrection> pLCPMap;
if (needsLensfun()) {
pLCPMap = LFDatabase::findModifier(params->lensProf, metadata, oW, oH, params->coarse, rawRotationDeg);
pLCPMap = std::move(LFDatabase::findModifier(params->lensProf, metadata, oW, oH, params->coarse, rawRotationDeg));
} else if (needsLCP()) { // don't check focal length to allow distortion correction for lenses without chip
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile (params->lensProf.lcpFile);
if (pLCPProf) {
pLCPMap = new LCPMapper (pLCPProf, focalLen, focalLen35mm,
focusDist, fNumber, false,
params->lensProf.useDist,
oW, oH, params->coarse, rawRotationDeg);
pLCPMap.reset(
new LCPMapper (pLCPProf, focalLen, focalLen35mm,
focusDist, fNumber, false,
params->lensProf.useDist,
oW, oH, params->coarse, rawRotationDeg
)
);
}
}
@@ -345,11 +348,7 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
} else {
mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE;
}
transformGeneral(mode, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap);
}
if (pLCPMap) {
delete pLCPMap;
transformGeneral(mode, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get());
}
}