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

Do not throw if DNG crop is undefined (DJI bug) #475

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kmilos
Copy link
Contributor

@kmilos kmilos commented May 25, 2023

The file is probably usable, so fall back to default values and log error instead.

This should address darktable-org/darktable#11949 and https://discuss.pixls.us/t/unable-to-import-drone-hyperlapse-images/37222

Asked for samples...

@kmilos kmilos requested a review from LebedevRI as a code owner May 25, 2023 10:18
@kmilos kmilos force-pushed the kmilos/fix_dng_undef_crop branch from 2af2cd0 to 9c3e400 Compare May 25, 2023 10:26
@LebedevRI
Copy link
Member

Yeah i do not know about this... I guess they expect us to treat
such "rational"s w/ zero denominator by pretending that denominator is 1?
But i really don't see why that is what the TIFF spec prescribes,
and as far as i can tell neither dcraw nor libTIFF does that.

This is quite an unfortunate situation.

@kmilos
Copy link
Contributor Author

kmilos commented May 25, 2023

Yeah i do not know about this... I guess they expect us to treat
such "rational"s w/ zero denominator by pretending that denominator is 1?

I don't think we can assume that. For example, DJI really put (0/0, 0/0) in there, so for DefaultCropSize we can't and should not pretend it is (0,0).

But i really don't see why that is what the TIFF spec prescribes,
and as far as i can tell neither dcraw nor libTIFF does that.

The Exif (or TIFF/EP) spec mentions for some fields that 0/0 means "undefined".

This is quite an unfortunate situation.

It is unfortunate, but I think falling back to default (entire image) is sensible in this specific case, instead of bailing out on the user. We do something similar already if the opcodes cannot be properly parsed (i.e. just ignore them, but not bail out)...

@kmilos
Copy link
Contributor Author

kmilos commented May 25, 2023

Yep, the Exif spec mentions in several places:

This value is invalid when 0/0 is recorded.

@kmilos kmilos marked this pull request as draft May 25, 2023 13:16
@kmilos
Copy link
Contributor Author

kmilos commented May 25, 2023

This doesn't work yet btw, because mRaw->dim is (0,0) at this point?!

@kmilos
Copy link
Contributor Author

kmilos commented May 25, 2023

Argh, they also put ActiveArea as 0 0 0 0. Wonderful!

@kmilos kmilos force-pushed the kmilos/fix_dng_undef_crop branch from 9c3e400 to c169765 Compare May 25, 2023 14:19
@kmilos kmilos marked this pull request as ready for review May 25, 2023 14:19
@kmilos kmilos force-pushed the kmilos/fix_dng_undef_crop branch from c169765 to 4af507a Compare May 25, 2023 14:34
@LebedevRI
Copy link
Member

Why do we care to support those invalid files?

@LibRaw
Copy link
Contributor

LibRaw commented May 25, 2023

To allow users to process files captured by their (invalid) equipment

@LebedevRI LebedevRI changed the title Do not throw if DNG crop is undefined Do not throw if DNG crop is undefined (DJI bug) May 25, 2023
@LebedevRI
Copy link
Member

Also, was the bug reported to the DJI? cc @dji-sdk @lanyusea

@kmilos kmilos force-pushed the kmilos/fix_dng_undef_crop branch from 4af507a to 227d516 Compare May 25, 2023 15:01
@kmilos
Copy link
Contributor Author

kmilos commented May 25, 2023

Also, was the bug reported to the DJI?

cc @mluckau @JooB1 @WiLars @MMCMA @da-phil @cdhodgdon @fran6t

The file is probably usable, so fall back to default values and log error instead
@kmilos kmilos force-pushed the kmilos/fix_dng_undef_crop branch from 227d516 to c44a6ad Compare May 25, 2023 15:35
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Patch coverage: 60.86% and project coverage change: -0.02 ⚠️

Comparison is base (834caca) 59.06% compared to head (c44a6ad) 59.04%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #475      +/-   ##
===========================================
- Coverage    59.06%   59.04%   -0.02%     
===========================================
  Files          232      232              
  Lines        13813    13824      +11     
  Branches      1932     1933       +1     
===========================================
+ Hits          8159     8163       +4     
- Misses        5521     5528       +7     
  Partials       133      133              
Flag Coverage Δ
benchmarks 8.29% <0.00%> (-0.01%) ⬇️
integration 47.35% <60.86%> (-0.01%) ⬇️
linux 56.85% <60.86%> (-0.02%) ⬇️
macOS 18.85% <0.00%> (-0.02%) ⬇️
rpu_u 47.35% <60.86%> (-0.01%) ⬇️
unittests 18.28% <0.00%> (-0.02%) ⬇️
windows ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/librawspeed/decoders/DngDecoder.cpp 52.96% <60.86%> (-0.39%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lanyusea
Copy link

Also, was the bug reported to the DJI? cc @lanyusea

let me check

@kmilos
Copy link
Contributor Author

kmilos commented Aug 11, 2023

Looks like both DefaultCropSize and ActiveArea are fixed in the recently launched DJI Air 3, but I guess there's still a need to support older invalid files.

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

Successfully merging this pull request may close these issues.

4 participants