最白目
最白目

Reputation: 3644

JPEG Encoding - DHT Segment Question -> Info-Byte

im writing the DHT Segment in a jpeg file. I write Bytes into a Byte Array.

byte[] huffman_Info = {
                        //Mark as DHT Segment
                        (byte)0xff, (byte) 0xc4,
                        //length (has to be calculated later)
                        (byte)0x00, (byte) 0x15,
                        /*
                         * Info Byte:
                         * - HT information (1 byte):
                                bit 0..3: number of HT (0..3, otherwise error)
                                bit 4   : type of HT, 0 = DC table, 1 = AC table
                                bit 5..7: not used, must be 0
                         */
                        (byte)0x08


                        };

Im writing (for testing) a 0x08 in the Info Byte. This is 0000 for the first 4 Bits. Here my first questions: What does this "bit 0..3: number of HT (0..3, otherwise error)" mean? I googled it but all I find is the same specification over and over again. the 5th Bit is a 1 for a DC table and the the 3 last bits have to be 0 0x08 = 00001000.

However, JPEGSnoop, a decoding tool, says my Destination ID is 15, this is wrong, so its aborting the progress. Why is my Info Byte wrong?

As Always, thanks a lot in advance for your help

regards, Daniel

Upvotes: 1

Views: 855

Answers (1)

onemasse
onemasse

Reputation: 6584

The first nibble should be either 0 or 1, the second should be a number between 0 and 3. Any other values are illegal. So the only legal values for that byte would be:

0x00 0x01 0x02 0x03 0x10 0x11 0x12 0x13

The best way to learn JPEG is to read the standard, it's actually not that hard to understand. Google for "itu-1150.pdf" and you'll find it.

Upvotes: 1

Related Questions