Maker data

Pavel Zlatovratskii <[email protected]> Mon, 20 Feb 2017 17:04:33 +0300
Newsgroups gmane.comp.graphics.png.general
Organization TB.Budget
Message-ID <[email protected]>
I wrote before that save EXIF data to separate chunks is better than 
save eXIf.

Embedded EXIF data may be safe-to-copy or unsafe-to-copy, but it's also 
could be unsafe-to-modify. It's possible that MakerNote data use offset 
relative to the start of EXIF header, so read-and-write could break it. 
See http://www.exiv2.org/makernote.html

Here goes simple solution with separate chunk for Maker data:

mKRd chunk

          Maker: 1-79 byte
		ASCII string.
		Used as hint to determine data format.
		Typically contain actual maker of image source
		device, but may differ. (e.g. if little known maker
		use other maker's format or if data constructed
		by software)

	 Zero byte: 1 byte.

	 Original offset: 4 bytes
    		offset of this data in original TIFF(EXIF),
		relative to TIFF header, expressed as a 32-bit
		unsigned integer in network byte order.
		This is supposed to match original value field
		of MakerNote tag.
  
          Uncompressed length: 4 bytes
                 the length of the Maker data when uncompressed,
		expressed as a 32-bit unsigned integer in network
		byteorder.
		This is supposed to match original length field
		of MakerNote tag.
  
          Mode: 1 byte

                0: the remainder of the data segment
                   (chunk_length - 1 bytes) make up a 4-byte
                   uncompressed_length integer followed by a
                   zlib-encoded Exif profile written in accordance
                   with Chapter 5, "Deflate/Inflate Compression"
                   of the PNG specification version 1.2 (which is
                   Clause 10.1, "Compression method 0" of the
                   ISO PNG specification). When uncompressed, the
                   first two bytes are "II" or "MM", depending upon
                   the byte order used within the profile.

               73: the Mode byte (ASCII "I") plus the remainder
                   of the data segment, beginning with another "I",
                   make up a raw uncompressed Exif profile in
                   little-endian ("Intel", LSB first) byte order.

               77: the Mode byte (ASCII "M") plus the remainder
                   of the data segment, beginning with another "M",
                   make up a raw uncompressed Exif profile in
                   big-endian ("Motorola", MSB first) byte order.

               Other values of Mode are reserved for other
                   compression methods which might be defined
                   in a future version of this specification.

          Data (the remaining chunk_length): data, formatted
	      on makers specification, either uncompressed or
	      compressed, according to the Mode byte.


Reasons:
Raw data: MakerNote is specified only by source maker, so unlike EXIF 
it's not possible to make chunk for each of it's field - they could be 
maker-specific or even does not exist for now.

Safe-to-copy: MakerNote is described as safe to copy by CIPA DC-08-2016 
Annex E 3.4

Uncompressed length: In theory it's possible that next tag data will 
start farther than supposed by MakerNote offset/length. This may be 
caused by wrong length or unknown EXIF tag or something like this.
To handle such situation encoder may write MakerNote, including "extra" 
data and use "Uncompressed length" field to note decoder which data was 
originally marked as MakerNote.
It's possible to use this field to prevent "decompression bomb" same way 
as for eXIf tag.

Also, does anyone saw DNG with "PrivateData" tag? Is it same as 
MakerNote or may contain additional data?

-- 
Pavel Zlatovratskii scondo-JGs/[email protected]; [email protected]


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot