Commit 5dd4f6e
authored
feat(raw): add raw:ForceLoad hint (#4704)
The raw input plugin populates the attributes in the ImageSpec from the
libraw structures in the RawInput::open_raw() method. That is done
before the actual image data being decompressed on demand in
RawInput::read_native_scanline(). Libraw re-calculates some values after
the pixels get available, it is impossible to access those, as the
ImageBuf's spec does not get updated, and the updated ImageSpec is not
available from outside of RawInput when/after the pixels are being
processed.
An example: the initial values for the white balancing weights get
populated from the image file metadata, those get copied into the
ImageSpec. If the libraw was configured to white balance by averaging
the pixels of the whole image or a region, the white balancing weights
would get re-calculated by libraw after processing the pixels, but the
updated numbers are impossible to access from outside of the RawInput
plugin.
This change adds a hint "raw:ForceLoad", which, if set to 1, forces
libraw to decompress and process the image in RawInput::open_raw(), so
the image attributes returned from that method would contain the final
values.
I am not certain if this is the best way to achieve what I needed. I
have also looked into making the ImageBuf retain the ImageInput object
instead of spawning multiple transient objects, but that seemed too
complicated.
I have not added any unit tests, not sure how to approach that. I have
tested that the image does not get decompressed multiple times in a
bunch of scenarios.
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>1 parent e43fada commit 5dd4f6e
2 files changed
Lines changed: 36 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2228 | 2228 | | |
2229 | 2229 | | |
2230 | 2230 | | |
2231 | | - | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
2232 | 2237 | | |
2233 | 2238 | | |
2234 | 2239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
| |||
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
| 378 | + | |
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
382 | | - | |
| 384 | + | |
383 | 385 | | |
384 | 386 | | |
385 | 387 | | |
| |||
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
391 | | - | |
| 393 | + | |
392 | 394 | | |
393 | 395 | | |
394 | 396 | | |
| |||
517 | 519 | | |
518 | 520 | | |
519 | 521 | | |
520 | | - | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
526 | 528 | | |
527 | 529 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
545 | 547 | | |
546 | 548 | | |
547 | 549 | | |
| |||
938 | 940 | | |
939 | 941 | | |
940 | 942 | | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
941 | 946 | | |
942 | 947 | | |
943 | 948 | | |
| |||
1517 | 1522 | | |
1518 | 1523 | | |
1519 | 1524 | | |
1520 | | - | |
| 1525 | + | |
1521 | 1526 | | |
1522 | 1527 | | |
1523 | 1528 | | |
1524 | 1529 | | |
1525 | 1530 | | |
1526 | 1531 | | |
1527 | 1532 | | |
1528 | | - | |
| 1533 | + | |
1529 | 1534 | | |
1530 | 1535 | | |
1531 | 1536 | | |
| |||
1624 | 1629 | | |
1625 | 1630 | | |
1626 | 1631 | | |
1627 | | - | |
| 1632 | + | |
1628 | 1633 | | |
1629 | 1634 | | |
1630 | 1635 | | |
| |||
0 commit comments