Nikon Coolpix P330 - wrong black and white levels

Hi guys,

There seems to be a bug in LibRaw 0.19-Snapshot-20170212. To reproduce:

1. Download a Nikon Coolpix P330 raw sample. Here is one website to download from:

http://www.photographyblog.com/reviews/nikon_coolpix_p330_review/sample_...

2. Use dcraw_emu to convert the raw file to TIFF (or some other format). The TIFF image will appear almost completely white.

On one image, LibRaw 0.19 says that the black level is 205 and white level is 4095. But if you convert the image to a DNG (using Adobe tools), the black and white levels encoded in the DNG are 3067 and 65000.

LibRaw 0.18.2 seems to be working fine.

Forums: 

> LibRaw 0.19 says that the

> LibRaw 0.19 says that the black level is 205 and white level is 4095

This part is as it should be, the camera is 12-bit.

--
Iliah Borg

Here is the patch:

Here is the patch:

diff --git a/dcraw/dcraw.c b/dcraw/dcraw.c
index fb78663..87915d9 100644
--- a/dcraw/dcraw.c
+++ b/dcraw/dcraw.c
@@ -2768,7 +2768,7 @@ void CLASS unpacked_load_raw()
while (1 << ++bits < maximum)
;
read_shorts(raw_image, raw_width * raw_height);
- if (maximum < 0xffff)
+ if (maximum < 0xffff || load_flags)
for (row = 0; row < raw_height; row++)
{
#ifdef LIBRAW_LIBRARY_BUILD
diff --git a/internal/dcraw_common.cpp b/internal/dcraw_common.cpp
index 168a095..d8e22e6 100644
--- a/internal/dcraw_common.cpp
+++ b/internal/dcraw_common.cpp
@@ -2472,7 +2472,7 @@ void CLASS unpacked_load_raw()
while (1 << ++bits < maximum)
;
read_shorts(raw_image, raw_width * raw_height);
- if (maximum < 0xffff)
+ if (maximum < 0xffff || load_flags)
for (row = 0; row < raw_height; row++)
{
#ifdef LIBRAW_LIBRARY_BUILD

-- Alex Tutubalin @LibRaw LLC