Fix dcraw reading of black level for Sony

Don't set black level from tiff_bps if a black level is in the metadata.

Remove the Sony ILCE-7M3 black level from camconst.json. The black level
is in the metadata (512 for ISOs < 128000, 1024 for ISOs >= 128000).
This commit is contained in:
Lawrence Lee 2024-11-16 10:51:00 -08:00
parent bc2fbfad66
commit 31076f0a62
No known key found for this signature in database
GPG Key ID: 048FF2B76A63895F
3 changed files with 13 additions and 3 deletions

View File

@ -3091,7 +3091,6 @@ Camera constants:
// "raw_crop": [ 8, 8, 6008, 4008 ], // full raw frame 6048x4024 Dcraw auto identify 6024x4024, jpeg 12,12,6000x4000 // "raw_crop": [ 8, 8, 6008, 4008 ], // full raw frame 6048x4024 Dcraw auto identify 6024x4024, jpeg 12,12,6000x4000
// "ranges": { "black": 512, "white": 16300 } // "ranges": { "black": 512, "white": 16300 }
"ranges": { "ranges": {
"black": 512,
"white": [ "white": [
{ "iso": [ 50, 64 ], "levels": 16100 }, // typical compressed 16372, non compressed 16383, LongEx iso50,16150 , 16275 { "iso": [ 50, 64 ], "levels": 16100 }, // typical compressed 16372, non compressed 16383, LongEx iso50,16150 , 16275
{ "iso": [ 80, 100, 125, 160 ], "levels": 16200 }, // typical compressed 16372, non compressed 16383, LongEx iso50,16150 , 16275 { "iso": [ 80, 100, 125, 160 ], "levels": 16200 }, // typical compressed 16372, non compressed 16383, LongEx iso50,16150 , 16275

View File

@ -6741,6 +6741,7 @@ int CLASS parse_tiff_ifd (int base)
FORC3 if (i > (int)cblack[c]) i = cblack[c]; FORC3 if (i > (int)cblack[c]) i = cblack[c];
FORC4 cblack[c] -= i; FORC4 cblack[c] -= i;
black = i; black = i;
sony_meta.sr2subifd_black2 = true;
break; break;
case 29459: case 29459:
FORC4 cam_mul[c] = get2(); FORC4 cam_mul[c] = get2();
@ -9733,7 +9734,9 @@ void CLASS adobe_coeff (const char *make, const char *model)
break; break;
} }
if (load_raw == &CLASS sony_arw2_load_raw) { // RT: arw2 scale fix if (load_raw == &CLASS sony_arw2_load_raw) { // RT: arw2 scale fix
if (!sony_meta.sr2subifd_black2) {
black <<= 2; black <<= 2;
}
tiff_bps += 2; tiff_bps += 2;
} else if (load_raw == &CLASS panasonic_load_raw) { } else if (load_raw == &CLASS panasonic_load_raw) {
tiff_bps = RT_pana_info.bpp; tiff_bps = RT_pana_info.bpp;
@ -10468,7 +10471,8 @@ void CLASS identify()
top_margin = filters = 0; top_margin = filters = 0;
strcpy (model,"C603"); strcpy (model,"C603");
} }
if (!strcmp(make,"Sony") && raw_width > 3888) // From LibRaw: Do not set black if black or cblack is already set.
if (!strcmp(make,"Sony") && raw_width > 3888 && !black && !cblack[0])
black = 128 << (tiff_bps - 12); black = 128 << (tiff_bps - 12);
if (is_foveon) { if (is_foveon) {
if (height*2 < width) pixel_aspect = 0.5; if (height*2 < width) pixel_aspect = 0.5;

View File

@ -174,6 +174,12 @@ protected:
unsigned sub_frame_shot_select; unsigned sub_frame_shot_select;
}; };
struct SonyMeta
{
/// SR2SubIFD black levels tag 0x7310 exists.
bool sr2subifd_black2 = false;
};
int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits, fuji_raw_type, fuji_lossless; int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits, fuji_raw_type, fuji_lossless;
ushort raw_height, raw_width, height, width, top_margin, left_margin; ushort raw_height, raw_width, height, width, top_margin, left_margin;
@ -201,6 +207,7 @@ protected:
std::string RT_software; std::string RT_software;
double RT_baseline_exposure; double RT_baseline_exposure;
struct MergedPixelshift merged_pixelshift; struct MergedPixelshift merged_pixelshift;
struct SonyMeta sony_meta;
public: public:
struct CanonCR3Data { struct CanonCR3Data {