From dceacb5304184a14fd80190ad61bfa886fbe8d6a Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Tue, 16 Apr 2019 11:28:08 -0700 Subject: [PATCH] DngCreator: Handle off-by-1 issue for DNG rects In DNG sdk, rectangle's bottom and right are exclusive. Update DngUtils to be consistent with that. Also fixed normalized optical center calculation given pixel [0, 0] is a square centered at (0.5, 0.5). Test: DngCreatorTest, and visually inspect DNG images taken Bug: 119566614 Change-Id: I73ab9327f75c24282ae14ef798fef797bb700bae --- media/img_utils/src/DngUtils.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/media/img_utils/src/DngUtils.cpp b/media/img_utils/src/DngUtils.cpp index 9304f5347c..791403029a 100644 --- a/media/img_utils/src/DngUtils.cpp +++ b/media/img_utils/src/DngUtils.cpp @@ -173,8 +173,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth, status_t err = addGainMap(/*top*/redTop, /*left*/redLeft, - /*bottom*/activeAreaHeight - 1, - /*right*/activeAreaWidth - 1, + /*bottom*/activeAreaHeight, + /*right*/activeAreaWidth, /*plane*/0, /*planes*/1, /*rowPitch*/2, @@ -191,8 +191,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth, err = addGainMap(/*top*/greenEvenTop, /*left*/greenEvenLeft, - /*bottom*/activeAreaHeight - 1, - /*right*/activeAreaWidth - 1, + /*bottom*/activeAreaHeight, + /*right*/activeAreaWidth, /*plane*/0, /*planes*/1, /*rowPitch*/2, @@ -209,8 +209,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth, err = addGainMap(/*top*/greenOddTop, /*left*/greenOddLeft, - /*bottom*/activeAreaHeight - 1, - /*right*/activeAreaWidth - 1, + /*bottom*/activeAreaHeight, + /*right*/activeAreaWidth, /*plane*/0, /*planes*/1, /*rowPitch*/2, @@ -227,8 +227,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth, err = addGainMap(/*top*/blueTop, /*left*/blueLeft, - /*bottom*/activeAreaHeight - 1, - /*right*/activeAreaWidth - 1, + /*bottom*/activeAreaHeight, + /*right*/activeAreaWidth, /*plane*/0, /*planes*/1, /*rowPitch*/2, @@ -265,8 +265,8 @@ status_t OpcodeListBuilder::addMonochromeGainMapsForMetadata(uint32_t lsmWidth, status_t err = addGainMap(/*top*/0, /*left*/0, - /*bottom*/activeAreaHeight - 1, - /*right*/activeAreaWidth - 1, + /*bottom*/activeAreaHeight, + /*right*/activeAreaWidth, /*plane*/0, /*planes*/1, /*rowPitch*/1, @@ -364,8 +364,8 @@ status_t OpcodeListBuilder::addWarpRectilinearForMetadata(const float* kCoeffs, return BAD_VALUE; } - double normalizedOCX = opticalCenterX / static_cast(activeArrayWidth - 1); - double normalizedOCY = opticalCenterY / static_cast(activeArrayHeight - 1); + double normalizedOCX = opticalCenterX / static_cast(activeArrayWidth); + double normalizedOCY = opticalCenterY / static_cast(activeArrayHeight); normalizedOCX = CLAMP(normalizedOCX, 0, 1); normalizedOCY = CLAMP(normalizedOCY, 0, 1);