1 Reply Latest reply on Oct 1, 2008 7:40 PM by MadManChan2000

    DNG OriginalRawFileData tag data encoding not clear in DNG specification...

      Hi all,<br /><br />I'm working on a DNG writer for Linux using DNG sdk. Currently i try to add a new option to embed original RAW file data in dedicated tag OriginalRawFileData.<br /><br />Reading DNG specification (page 40 & 41) about this subject do not help me very well, especially how to encode all data in this tag exactly. These words:<br /><br />//------------------------------------------------------------------------------------- ------------------------------------<br />" Each fork (data or Mac OS resource) is compressed and encoded as:<br />   ForkLength = first four bytes. This is the uncompressed length of this fork. If this value is<br />   zero, then no more data is stored for this fork.<br /><br />From ForkLength, compute the number of 64K compression blocks used for this data (the last<br />block is usually smaller than 64K):<br />    ForkBlocks = Floor ((ForkLength + 65535) / 65536)<br /><br />The next (ForkBlocks + 1) 4-byte values are an index into the compressed data. The first<br />ForkBlock values are offsets from the start of the data for this fork to the start of the<br />compressed data for the corresponding compression block. The last value is an offset from the<br />start of the data for this fork to the end of the data for this fork.<br /><br />Following this index is the ZIP compressed data for each 64K compression block. "<br />//------------------------------------------------------------------------------------- ------------------------------------<br /><br />.. are clearly unreadable for me, and i'm not alone in this case. A draft is missing in this spec to explain exactly how are encoded data and in which order. Why not to add a data layout like in PNG specification from  W3C:<br /><br />http://www.w3.org/TR/PNG/#5Chunk-layout<br /><br />Another question is about dng_negative::SetOriginalRawFileData(AutoPtr<dng_memory_block> &data). <br />What i must set with data block exactly ? All original raw file data compressed by zlib as well ?<br /><br />Thanks in advance for your help<br /><br />Gilles Caulier
        • 1. Re: DNG OriginalRawFileData tag data encoding not clear in DNG specification...
          MadManChan2000 Adobe Employee
          Gilles, each data block is encoded in the order specified in the spec on that same page (see items 1 through 8 ). If a specific fork doesn't exist, then it's encoded simply as a zero-length fork. Every fork is zip compressed (actually a set of 64k blocks).

          As for the dng_negative::SetOriginalRawFileData () method, this is basically a set routine. You are basically passing the entire block of compressed original raw data as described for the OriginalRawFileData tag. See dng_negative::Parse () in dng_negative.cpp for an example of it in use.