Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fujifilm compressed RAF support. #107

Merged
merged 3 commits into from
Jun 23, 2017

Conversation

muessel
Copy link
Contributor

@muessel muessel commented Jun 23, 2017

Hello,

this pull request implements support for Fujifilm compressed RAF Files for the X-Pro2, X-T2 and X-T20. The code is based on LibRaw / rawtherapee.

@LebedevRI
Copy link
Member

Hi.
Nice to finally see that.
Are there any changes other than adapting to some of rs's infrastructure?

Copy link
Member

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make CI happy :)
The code is far from ideal, which is quite understandable, but it will be easier for me to fix it after merging as-is...

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.

Hmm, where did you get that?
LibRaw/LibRaw@aeab4d8#diff-03b018f1deeb8fc38d2c927f09465635R11 says:

+LibRaw is free software; you can redistribute it and/or modify
+it under the terms of the one of three licenses as you choose:
+
+1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
+   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
+
+2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
+

(2 vs 2.1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough to change the version from 2 to 2.1 or do I have to copy the whole LibRaw license header?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is enough just to change the version.

<ColorRow y="4">GGRGGB</ColorRow>
<ColorRow y="5">RBGBRG</ColorRow>
</CFA2>
<Crop x="0" y="6" width="-16" height="0"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, so they are even writing different raw image WxH in compressed vs. uncompressed formats..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, uncomressed and comressed files are totally different, eg.:

exiftool Fujifilm\ -\ X-T20\ -\ compressed\ (3-2).RAF
...
Raw Image Width : 6032
Raw Image Height : 4032
Raw Image Full Width : 6048
Raw Image Full Height : 4038

exiftool Fujifilm\ -\ X-T20\ -\ Uncompressed\ (3-2).RAF
...
Raw Image Width : 6032
Raw Image Height : 4032
Raw Image Full Width : 6160
Raw Image Full Height : 4032

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what i was talking about.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muessel
An entry for FUJIFILM X100F is missing.
Is there some problem with that camera, or it is a simple oversight?

info->cur_bit = (8 - (bits_left_in_byte & 7)) & 7;
}

int FujiDecompressor::bitDiff(int value1, int value2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int __attribute__(const) FujiDecompressor::bitDiff(int value1, int value2) {

auto id = mRootIFD->getID();
const Camera* cam = meta->getCamera(id.make, id.model, mRaw->metadata.mode);
if (!cam)
ThrowRDE("Couldn't find camera %s %s", id.make, id.model);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThrowRDE("Couldn't find camera %s %s", id.make.c_str(), id.model.c_str());

public:
FujiDecompressor(Buffer input, RawImage img, int offset);
~FujiDecompressor(void);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess you want to add

using ushort = ushort16;

right here for now.

@LebedevRI LebedevRI changed the base branch from develop to raf-compressed June 23, 2017 20:01
@LebedevRI
Copy link
Member

Ok, i see.
Ignore those windows clang-4.0 warnings, i'll handle them manually.

@LebedevRI LebedevRI merged commit c3c4b7d into darktable-org:raf-compressed Jun 23, 2017
@muessel
Copy link
Contributor Author

muessel commented Jun 23, 2017

Travis CI has problems with mac builds with std::abs. Do I have to change them to abs and then include "using std::abs;" ?

@LebedevRI
Copy link
Member

Will fix locally, thank you!

@muessel
Copy link
Contributor Author

muessel commented Jun 24, 2017 via email

@LebedevRI
Copy link
Member

Hello Roman,
I just forgot the the X100F also supports the compressed format.

Yeah, i checked, and X100F compressed works too, fixed in branch.
Also, while there, FUJIFILM GFX 50S uncompressed+compressed support added - the only fuji camera with bayer sensor and with this compresson scheme, i believe.

What i'm currently missing is some compressed .RAF with 12-bits data, so this branch is taken:

} else if (info->q_point[4] == 0xFFF) {
info->total_values = 4096;
info->raw_bits = 12;
info->max_bits = 48;
info->maxDiff = 64;

I think, it is produced in high-speed continuous shooting mode, 14/12/8/whaever fps.

@LebedevRI
Copy link
Member

I've seen you also implemented support for the GFX 50S. In the method
FujiDecompressor::copy_line_to_bayer
a static CFA is used. Maybe this should be converted into something
configurable like with the X-Trans sensors.

All that is very strange. If that is the actual code used in current libraw, then it may mean two things (both can be valid at the same time):

  1. All cameras which support compressed raw, have the exact same CFA filter pattern
  2. The CFA used in compression is static/the same for all cameras/does not necessarily match the actual camera's CFA pattern.

@muessel
Copy link
Contributor Author

muessel commented Jun 24, 2017 via email

@LebedevRI
Copy link
Member

@Floessie
Copy link

@muessel

Travis CI has problems with mac builds with std::abs. Do I have to change them to abs and then include "using std::abs;" ?

Uwe, just my 2¢ (I know Roman will fix or has already fixed it): Most often the abs() problem isn't about the namespace, but a change from the way this was defined for C++03 vs. C++11. There's an integer version in <cstdlib> and a float version in <cmath>. As the latter link notes:

Between C++11 and C++14, the standard erroneously required std::abs to have overloads for integer types returning double. This requirement was removed in C++17 by defect report 2735.

That causes trouble again and again, and that's most probably the case here also. The best solution usually is to use std::fabs() for floats and to make sure, you don't feed std::abs() with an unsigned.

HTH,
Flössie

@LebedevRI
Copy link
Member

Update: still no sign of that elusive 12bit sample, and no reply from @LibRaw.
I'll wait a few more days and proceed without it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Resolved
Development

Successfully merging this pull request may close these issues.

3 participants