{"action":"created","issue":{"url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/3429","repository_url":"https://api.github.com/repos/Beep6581/RawTherapee","labels_url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/3429/labels{/name}","comments_url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/3429/comments","events_url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/3429/events","html_url":"https://github.com/Beep6581/RawTherapee/issues/3429","id":176704956,"number":3429,"title":"Navigator values for pure white jpeg are not 100%","user":{"login":"mmmtok","id":19221195,"avatar_url":"https://avatars.githubusercontent.com/u/19221195?v=3","gravatar_id":"","url":"https://api.github.com/users/mmmtok","html_url":"https://github.com/mmmtok","followers_url":"https://api.github.com/users/mmmtok/followers","following_url":"https://api.github.com/users/mmmtok/following{/other_user}","gists_url":"https://api.github.com/users/mmmtok/gists{/gist_id}","starred_url":"https://api.github.com/users/mmmtok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmmtok/subscriptions","organizations_url":"https://api.github.com/users/mmmtok/orgs","repos_url":"https://api.github.com/users/mmmtok/repos","events_url":"https://api.github.com/users/mmmtok/events{/privacy}","received_events_url":"https://api.github.com/users/mmmtok/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-13T17:45:23Z","updated_at":"2016-09-15T11:29:44Z","closed_at":null,"body":"[Reproduction procedure]\r\n1. Prepare pure white jpeg file whose pixel values are all 255.\r\n2. Open the file.\r\n3. See Navigator values.\r\n   R, G, B are 99.6%\r\n   V of HSV is 99.6%\r\n   L of Lab is 99.7%\r\n\r\nI think all should be 100%.\r\n\r\n[Versions]\r\nI see this with\r\nRT 4.2.1004\r\nOSX 10.11.6\r\nbut I believe it is platform independent.\r\n\r\n[Candidate fix]\r\nWhile 8bit image is loaded, pixel values, 0-255, are not fully mapped into the full range of internal values, 0-65535.  The changes below fixes this problem in my own build.  Theoretically, this change may degrade the performance upon the conversions, but I don't feel the difference while doing actual operations with the fixed build.\r\n\r\n\r\n```\r\n--- iimage.h.orig       2016-09-14 00:20:20.000000000 +0900\r\n+++ iimage.h    2016-09-14 00:36:07.000000000 +0900\r\n@@ -103,27 +103,27 @@\r\n template <>\r\n inline void ImageDatas::convertTo<unsigned short, unsigned char> (const unsigned short srcValue, unsigned char &dstValue)\r\n {\r\n-    dstValue = (unsigned char)(srcValue >> 8);\r\n+    dstValue = (unsigned char)(srcValue / 257 );\r\n }\r\n template <>\r\n inline void ImageDatas::convertTo<unsigned char, int> (const unsigned char srcValue, int &dstValue)\r\n {\r\n-    dstValue = (int)(srcValue) << 8;\r\n+    dstValue = (int)(srcValue) * 257;\r\n }\r\n template <>\r\n inline void ImageDatas::convertTo<unsigned char, unsigned short> (const unsigned char srcValue, unsigned short &dstValue)\r\n {\r\n-    dstValue = (unsigned short)(srcValue) << 8;\r\n+    dstValue = (unsigned short)(srcValue) * 257;\r\n }\r\n template <>\r\n inline void ImageDatas::convertTo<float, unsigned char> (const float srcValue, unsigned char &dstValue)\r\n {\r\n-    dstValue = (unsigned char)( (unsigned short)(srcValue) >> 8 );\r\n+    dstValue = (unsigned char)( (unsigned short)(srcValue) / 257 );\r\n }\r\n template <>\r\n inline void ImageDatas::convertTo<unsigned char, float> (const unsigned char srcValue, float &dstValue)\r\n {\r\n-    dstValue = float( (unsigned short)(srcValue) << 8 );\r\n+    dstValue = float( (unsigned short)(srcValue) * 257 );\r\n }\r\n\r\n // --------------------------------------------------------------------\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/comments/247303331","html_url":"https://github.com/Beep6581/RawTherapee/issues/3429#issuecomment-247303331","issue_url":"https://api.github.com/repos/Beep6581/RawTherapee/issues/3429","id":247303331,"user":{"login":"Floessie","id":10133457,"avatar_url":"https://avatars.githubusercontent.com/u/10133457?v=3","gravatar_id":"","url":"https://api.github.com/users/Floessie","html_url":"https://github.com/Floessie","followers_url":"https://api.github.com/users/Floessie/followers","following_url":"https://api.github.com/users/Floessie/following{/other_user}","gists_url":"https://api.github.com/users/Floessie/gists{/gist_id}","starred_url":"https://api.github.com/users/Floessie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Floessie/subscriptions","organizations_url":"https://api.github.com/users/Floessie/orgs","repos_url":"https://api.github.com/users/Floessie/repos","events_url":"https://api.github.com/users/Floessie/events{/privacy}","received_events_url":"https://api.github.com/users/Floessie/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T11:29:43Z","updated_at":"2016-09-15T11:29:43Z","body":"@mmmtok @iliasg I was curious and had a look at the assembly. GCC is really smart (even at `-O0`) and converts\r\n```c++\r\nunsigned char res = val / 257;\r\n```\r\nto\r\n```c++\r\nunsigned char res = static_cast<unsigned long>(val * 0xFF01) >> 24;\r\n```\r\nSo no division involved, which will also make @heckflosse happy. :)"}}
{"actor":{"display_login":"Floessie"}}