Repository navigation
RafDecoder, RawDecoder: don't use an unset blackLevelSeparate - #1001
alepacheco wants to merge 2 commits into
Conversation
Only an entry count of 4 or 36 sets blackLevelSeparate, but the averaging after it dereferences blackLevelSeparate unconditionally, so any other count dereferenced an empty Optional. Throw instead, like ArwDecoder and NefDecoder do for their black level tags.
The final_cfa_black hint writes all four values through blackLevelSeparate, which is unset unless the decoder or the camera's sensor entry already set it, so the hint could dereference an empty Optional. No camera in data/cameras.xml uses the hint today.
|
Reproducer? |
|
I don't have a camera file that hits the first one; the condition is in the source (lines at c48d5a6):
<Hints>
<Hint name="final_cfa_black" value="10,20,30,20"/>
</Hints>to the With this PR it decodes and writes the hash. |
RawImageData::blackLevelSeparateis anOptionalthat stays empty until something assigns it. Two places use it without assigning it first:RafDecoder::decodeMetaDataInternal(): theFUJI_BLACKLEVELblock fills it only when the tag has 4 or 36 entries, then averages it unconditionally. A RAF from a camera listed incameras.xmlwhose tag has any other count reachesOptional::operator->with no value: an assertion failure in a debug build, undefined behaviour in a release build. It now throws, asArwDecoderandNefDecoderdo for their black level tags.RawDecoder::setMetaData(): thefinal_cfa_blackhint writes all four values through it, but it is only set if the decoder or the camera's sensor entry already set it. No camera incameras.xmluses the hint today; it now sets the 2x2 view first, as the sensor branch above does.Testing:
ctestpasses.rstest -con raw.pixls.us samples (X100, X30, X-A5, X-Pro1, X-T3, GFX 50S, HS50EXR, S5Pro) gives identical hashes before and after.