Very happy that you are interested by optimizing the dng generation process.
From 1054 release, I worked hard, with my limited knowledge, to optimize this process, well before modularity.
I would suggest something that could interest you
You are creating a spooler-like task to chunk write dng file infos. That a good idea.
Pros: optimize reversal bytes and writing concurrency
Cons: starting the task after creating the thumbnail info
Here is my suggestion, a dng init buffer task and a byte reversal task.
-------------------------
1) at startup, if dng is enabled (upon config), or when user activate dng, launch DNG buffer init task which fill dng buffer with static data
2) when user disabled dng, free dng buffer
3) on "write_dng",
... patch bad pixels (if ...)
... launch byte reversal task
... fill dng ifds with dynamic data (about 25 tags)
... write dng ifds to file (chunk write?)
... fill thumbnail section with YCbCr viewport data !!! not raw data
... write thumbnail section to file (chunk write?)
... ... write already reversed raw data in chunk
... ... if necessary, dereverse written data
... until all raw data written
-------------------------------------------------
Here is my DNG file structure is: (at this time)
- IFH : information file header
- IFD0 : thumbnail IFD's tags
- IFD0 data : more-than-4-bytes IFD0 data
- IFD1 : full-res IFD's tags
- IFD1 data : more-than-4-bytes IFD1 data
- ExifIFD : exif IFD's tags
- ExifIFD data : more-than-4-bytes exif IFD data
- Thumbnail Data
- Raw Image Data
I attached my 1054 DNG.c version FYI and for inspirations.
I hope this would help you. If you need more info, I would be pleased