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

Sony ILCE-1 camera support - JPEG compression? #8523

Closed
1900mcm opened this issue Mar 20, 2021 · 22 comments
Closed

Sony ILCE-1 camera support - JPEG compression? #8523

1900mcm opened this issue Mar 20, 2021 · 22 comments
Assignees
Labels
scope: camera support adding WB and raw support for new cameras

Comments

@1900mcm
Copy link

1900mcm commented Mar 20, 2021

Unable to open file in darktable ( maybe this needs to be in rawspeed )

[rawspeed] (ilce-1_DSC0735.ARW) virtual rawspeed::RawImage rawspeed::ArwDecoder::decodeRawInternal(), line 149: Unsupported compression

(darktable:3675): GLib-GObject-WARNING **: 17:08:02.938: invalid unclassed pointer in cast to 'GtkDarktableExpander'

** (darktable:3675): CRITICAL **: 17:08:02.938: dtgtk_expander_get_expanded: assertion 'DTGTK_IS_EXPANDER(expander)' failed

@1900mcm 1900mcm added the scope: camera support adding WB and raw support for new cameras label Mar 20, 2021
@LebedevRI LebedevRI changed the title ILCE-1 - Unable to open Sony ARW in darktable Sony ILCE-1 camera support Mar 20, 2021
@1900mcm
Copy link
Author

1900mcm commented Mar 20, 2021

I think the ARW is uploaded to raw.pixls.us - though I can't find it after uploading.

@LebedevRI LebedevRI changed the title Sony ILCE-1 camera support Sony ILCE-1 camera support - JPEG compression? Mar 21, 2021
LebedevRI added a commit to LebedevRI/darktable that referenced this issue Mar 21, 2021
EdgarLux pushed a commit to EdgarLux/darktable that referenced this issue Mar 22, 2021
lhietal pushed a commit to lhietal/darktable that referenced this issue Mar 29, 2021
@github-actions
Copy link

This issue did not get any activity in the past 30 days and will be closed in 365 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.

@kmilos
Copy link
Contributor

kmilos commented May 14, 2021

Btw, I found it a bit strange that this new compression mode has

Exif.SubImage1.ImageWidth                     8704
Exif.SubImage1.ImageLength                    6144

as opposed to 8672x5784 of the uncompressed or lossy compressed...

Even though 512x512 tiles are used, the TIFF writing/reading libraries should handle desired size and pad/crop tiles along the right and bottom borders automatically, right? I don't think there is a requirement to set the size to be an integer number of tiles, so not sure what Sony is doing here...

As a result, the generated info on RPU is a bit whacky as well (should still be 3:2, 50.16 MP and say "compressed"):

image

@github-actions
Copy link

This issue did not get any activity in the past 30 days and will be closed in 365 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.

@kmilos
Copy link
Contributor

kmilos commented Jul 23, 2021

Actually, this new ARW mode keeps getting weirder, I just noticed both strips and tiles related tags in SubImage1?! So one has to actually look at the JPEG bytestream to confirm what's the case here...

Edit:

Indeed, there are numerous tiles starting w/ FF D8 FF C3 00 14 0E 01 00 01 00 04: lossless JPEG SOF3 256x256 w/ 4 14-bit components to represent the 512x512 Bayer CFA tile.

I guess strip related tags should be ignored and are erroneous here (another WTH Sony?)

@feiwaltan
Copy link

@kmilos any updates available for this camera support issue? Are more raw lossless compressed samples needed?

@kmilos
Copy link
Contributor

kmilos commented Feb 8, 2022

Nope.

@cytrinox
Copy link
Contributor

Just found out how to decode this and implemented a PoC into dnglab (will publish a clean version next days).

  1. (First) TileOffsets and StripOffset is pointing to same location, so it's really a tiled image.
  2. The tile size of 512x512 is correct as reported by the file. It also fits the image width/height dimensions in this IFD (8704/512==17.0 etc.)
  3. Each tile is compressed with lossless jpeg with ncomp=4 and 256x256 dimension.
  4. The predictor mode is 1.
  5. After decompression you get a 1024x256 result image.
  6. Each cluster of 4 samples per line in result image produce a two-line CFA pattern which yields a 512x512 output tile.
  7. Reassemble the tiles like in good old DNG.

For step 6 pseudo code would look like:

// decompressed_line: RGGBRGGBRGGBRGGB....
out[0] = decompressed_line[0]; // R
out[1] = decompressed_line[1]; // G
out[img_width+0] = decompressed_line[2]; // G
out[img_width+1] = decompressed_line[3]; // B

out[2] = decompressed_line[4]; // R
....

@kmilos Hope this helps you.

grafik

@lclevy
Copy link

lclevy commented Jun 14, 2022

if that could help : https://github.com/lclevy/sony_raw

@kmilos
Copy link
Contributor

kmilos commented Sep 7, 2022

@LucasRueckert @lclevy @NickLplus

We don't really need other implementation details, thank you, here is already all the info we need - rawspeed already implements LJPEG92 w/ predictor 1 in https://github.com/darktable-org/rawspeed/blob/develop/src/librawspeed/decompressors/LJpegDecompressor.cpp

It "just" (famous last words) needs to be adapted to 4 (2x2 interleave, not 4x1 as currently assumed) components instead of DNG's 2 (2x1) in a way that keeps the rawspeed maintainer happy, and some glue code in https://github.com/darktable-org/rawspeed/blob/develop/src/librawspeed/decoders/ArwDecoder.cpp

(One can start maybe by looking at DngDecoder.)

@lclevy
Copy link

lclevy commented Sep 7, 2022

Canon implemented lossless jpeg in cr2 in ... 2004

@kmilos
Copy link
Contributor

kmilos commented Sep 7, 2022

Canon implemented lossless jpeg in cr2 in ... 2004

So perhaps they can update the rawspeed code for us? 😉

@lclevy
Copy link

lclevy commented Sep 7, 2022

@kmilos
Copy link
Contributor

kmilos commented Sep 7, 2022

I though I was clear: we have all the info we need, but thanks again.

What we don't have is a developer up for the job.

@artemist
Copy link

artemist commented Oct 3, 2022

I hacked something together in https://github.com/artemist/rawspeed/tree/sony-ljpeg though I haven't tested it much since I don't have any Sony cameras yet. I don't think it's upstream ready but it does work on some samples from https://raw.pixls.us/

@octaflop
Copy link

@artemist have you considered pushing a PR up to the rawspeed mainline with your changes?

@AchimDittrich
Copy link

Can you meanwhile say by when SONY A7R V uncompressed and lossless compressed RAW files will be supported?

@kmilos
Copy link
Contributor

kmilos commented Jan 11, 2023

Sony ILCE-7RM5 uncompressed and lossy is already supported in dt 4.2, as already explained in #13183

As for the lossless mode, I'm going to start repeating @MStraeten more and more: “Grass does not grow faster if you pull it”.

@AchimDittrich
Copy link

AchimDittrich commented Jan 11, 2023 via email

@1900mcm
Copy link
Author

1900mcm commented Jan 11, 2023

Uncompressed is supported ( A1 and A7R5 )
Compressed is supported ( A1 and A7R5 )
Lossless Compressed ( S, M, L ) do not seem to be supported in darkroom edit tab ( imbedded jpeg can be viewed in lighttable tab ) ( A1 and A7R5 - probably the A74 as well )

now i have to find the mstraeten ref - ( sounds like "never ask when!" )
may thanks for the support to date for these sony cameras

@AchimDittrich
Copy link

AchimDittrich commented Jan 12, 2023 via email

@LebedevRI
Copy link
Member

I think this was resolved by 1b707f3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: camera support adding WB and raw support for new cameras
Projects
Status: Resolved
Development

No branches or pull requests

10 participants