How to pack samples with respect to file endianess and FillOrder?

The DNG-specification says: "If BitsPerSample is not equal to 8 or 16 or 32, then the bits must be packed into bytes using the TIFF default FillOrder of 1 (big-endian), even if the TIFF file itself uses little-endian byte order."

Assume I want to encode two 12-bits values r and g (where r11 is the MSB of r and r00 is the LSB). How would the bytes look like? (in my example the bits of each byte are listed as usual from MSB (#7) to LSB (#0))

Big endian file ('MM') and FillOrder = 1

0x0000: r11 r10 r09 r08 r07 r06 r05 r04

0x0001: r03 r02 r01 r00 g11 g10 g09 g08

0x0002: g07 g06 g05 g04 g03 g02 g01 g00

Little endian file ('II') and FillOrder = 1

0x0000: r07 r06 r05 r04 r03 r02 r01 r00

0x0001: r11 r10 r09 r08 g03 g02 g01 g00

0x0002: g11 g10 g09 g08 g07 g06 g05 g04

In previous specifications (TIFF 4.0 - 6.0) FillOrder itself has never been described very well for images with more than 1 bits per sample. So just for my understanding: If FillOrder = 2 would have been allowed in DNG, I'd assume the following layouts:

Big endian file ('MM') and FillOrder = 2

0x0000: r11 r10 r09 r08 r07 r06 r05 r04

0x0001: g11 g10 g09 g08 r03 r02 r01 r00

0x0002: g07 g06 g05 g04 g03 g02 g01 g00

Little endian file ('II') and FillOrder = 2

0x0000: r07 r06 r05 r04 r03 r02 r01 r00

0x0001: g03 g02 g01 g00 r11 r10 r09 r08

0x0002: g11 g10 g09 g08 g07 g06 g05 g04

To put it short (writer's perspective):

- The file endianess describes how to cut values into octets (bytes) and how to order them.

- The FillOrder describes the order in which fragments of consecutive values are to be joined into a single octet.

Is my interpretation correct?

Bonus question: Is the FillOrder-Field forbidden in DNG? What is a compatibility-oriented reader assumed to do, when it encounters a FillOrder=2 - use it as given or ignore it and enforce FillOrder=1?

Topics

DNG
View all replies

Views

294

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

How to pack samples with respect to file endianess and FillOrder?

The DNG-specification says: "If BitsPerSample is not equal to 8 or 16 or 32, then the bits must be packed into bytes using the TIFF default FillOrder of 1 (big-endian), even if the TIFF file itself uses little-endian byte order."

Assume I want to encode two 12-bits values r and g (where r11 is the MSB of r and r00 is the LSB). How would the bytes look like? (in my example the bits of each byte are listed as usual from MSB (#7) to LSB (#0))

Big endian file ('MM') and FillOrder = 1

0x0000: r11 r10 r09 r08 r07 r06 r05 r04

0x0001: r03 r02 r01 r00 g11 g10 g09 g08

0x0002: g07 g06 g05 g04 g03 g02 g01 g00

Little endian file ('II') and FillOrder = 1

0x0000: r07 r06 r05 r04 r03 r02 r01 r00

0x0001: r11 r10 r09 r08 g03 g02 g01 g00

0x0002: g11 g10 g09 g08 g07 g06 g05 g04

In previous specifications (TIFF 4.0 - 6.0) FillOrder itself has never been described very well for images with more than 1 bits per sample. So just for my understanding: If FillOrder = 2 would have been allowed in DNG, I'd assume the following layouts:

Big endian file ('MM') and FillOrder = 2

0x0000: r11 r10 r09 r08 r07 r06 r05 r04

0x0001: g11 g10 g09 g08 r03 r02 r01 r00

0x0002: g07 g06 g05 g04 g03 g02 g01 g00

Little endian file ('II') and FillOrder = 2

0x0000: r07 r06 r05 r04 r03 r02 r01 r00

0x0001: g03 g02 g01 g00 r11 r10 r09 r08

0x0002: g11 g10 g09 g08 g07 g06 g05 g04

To put it short (writer's perspective):

- The file endianess describes how to cut values into octets (bytes) and how to order them.

- The FillOrder describes the order in which fragments of consecutive values are to be joined into a single octet.

Is my interpretation correct?

Bonus question: Is the FillOrder-Field forbidden in DNG? What is a compatibility-oriented reader assumed to do, when it encounters a FillOrder=2 - use it as given or ignore it and enforce FillOrder=1?

Topics

DNG
View all replies

Views

295

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

Have something to add?

Join the conversation