Skip to content

Commit dceacb5

Browse files
committed
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
1 parent ac64098 commit dceacb5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

media/img_utils/src/DngUtils.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth,
173173

174174
status_t err = addGainMap(/*top*/redTop,
175175
/*left*/redLeft,
176-
/*bottom*/activeAreaHeight - 1,
177-
/*right*/activeAreaWidth - 1,
176+
/*bottom*/activeAreaHeight,
177+
/*right*/activeAreaWidth,
178178
/*plane*/0,
179179
/*planes*/1,
180180
/*rowPitch*/2,
@@ -191,8 +191,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth,
191191

192192
err = addGainMap(/*top*/greenEvenTop,
193193
/*left*/greenEvenLeft,
194-
/*bottom*/activeAreaHeight - 1,
195-
/*right*/activeAreaWidth - 1,
194+
/*bottom*/activeAreaHeight,
195+
/*right*/activeAreaWidth,
196196
/*plane*/0,
197197
/*planes*/1,
198198
/*rowPitch*/2,
@@ -209,8 +209,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth,
209209

210210
err = addGainMap(/*top*/greenOddTop,
211211
/*left*/greenOddLeft,
212-
/*bottom*/activeAreaHeight - 1,
213-
/*right*/activeAreaWidth - 1,
212+
/*bottom*/activeAreaHeight,
213+
/*right*/activeAreaWidth,
214214
/*plane*/0,
215215
/*planes*/1,
216216
/*rowPitch*/2,
@@ -227,8 +227,8 @@ status_t OpcodeListBuilder::addBayerGainMapsForMetadata(uint32_t lsmWidth,
227227

228228
err = addGainMap(/*top*/blueTop,
229229
/*left*/blueLeft,
230-
/*bottom*/activeAreaHeight - 1,
231-
/*right*/activeAreaWidth - 1,
230+
/*bottom*/activeAreaHeight,
231+
/*right*/activeAreaWidth,
232232
/*plane*/0,
233233
/*planes*/1,
234234
/*rowPitch*/2,
@@ -265,8 +265,8 @@ status_t OpcodeListBuilder::addMonochromeGainMapsForMetadata(uint32_t lsmWidth,
265265

266266
status_t err = addGainMap(/*top*/0,
267267
/*left*/0,
268-
/*bottom*/activeAreaHeight - 1,
269-
/*right*/activeAreaWidth - 1,
268+
/*bottom*/activeAreaHeight,
269+
/*right*/activeAreaWidth,
270270
/*plane*/0,
271271
/*planes*/1,
272272
/*rowPitch*/1,
@@ -364,8 +364,8 @@ status_t OpcodeListBuilder::addWarpRectilinearForMetadata(const float* kCoeffs,
364364
return BAD_VALUE;
365365
}
366366

367-
double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth - 1);
368-
double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight - 1);
367+
double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth);
368+
double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight);
369369

370370
normalizedOCX = CLAMP(normalizedOCX, 0, 1);
371371
normalizedOCY = CLAMP(normalizedOCY, 0, 1);

0 commit comments

Comments
 (0)