For Programmers: Free Programming Magazines  


Home > Archive > Compression > November 2005 > JPEG decoding question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author JPEG decoding question
Dennis

2005-11-24, 6:55 pm

Here's a quick question about decoding JPEGS. When you have sampling
factors of:
HY =2, VY=2
HCb=1, VCb=1
HCr=1, VCr=1
and you're decoding the y component as 16*16 blocks... do you calculate
the dc coeffiecients
in order of

1 2 5 6 9 10 by the 2(8)*2(8) blocks or do you need to wait
and calculate them by:
3 4 7 8 11 12


1 2 3 4 5 6 7 8 9 10 as a line of 8*8 blocks and then go to
the next line and continue?
11 12 13 14 15 16 17 18

Dennis

2005-11-24, 6:55 pm

that should be :


1 2 5 6 9 10
3 4 7 8 11 12

or decode them by

1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18

Matt Mahoney

2005-11-25, 6:55 pm

Dennis wrote:
> Here's a quick question about decoding JPEGS. When you have sampling
> factors of:
> HY =2, VY=2
> HCb=1, VCb=1
> HCr=1, VCr=1
> and you're decoding the y component as 16*16 blocks... do you calculate
> the dc coeffiecients
> in order of
>
> 1 2 5 6 9 10 by the 2(8)*2(8) blocks or do you need to wait
> and calculate them by:
> 3 4 7 8 11 12
>
>
> 1 2 3 4 5 6 7 8 9 10 as a line of 8*8 blocks and then go to
> the next line and continue?
> 11 12 13 14 15 16 17 18


You decode the four 8x8 blocks of Y, then Cb and Cr. Then you expand
the Cb and Cr out to 16x16 by expanding each pixel to a 2x2 block. The
decode order is:

Y (upper left)
Y (upper right)
Y (lower left)
Y (lower right)
Cb
Cr
then repeat on the next 16x16 block, scanning left to right from the
upper left corner of the image.

See the JPEG spec for decode order, and the JFIF spec for mapping
components to colors and the alignment of pixels when rendering.

-- Matt Mahoney

Dennis

2005-11-26, 6:55 pm

Thanks for your reply.
BTW, are the DC coeffiecients always calculated by the order of
encoding or by a line of 8x8 block, left to right and then to the next
line left to right?

Matt Mahoney

2005-11-27, 9:55 pm


Dennis wrote:
> Thanks for your reply.
> BTW, are the DC coeffiecients always calculated by the order of
> encoding or by a line of 8x8 block, left to right and then to the next
> line left to right?


The DC component is calculated like the other 63 AC components (same
block order) except that instead of storing the value, the file stores
the difference from the previous DC component of the same color
(previous in the order that the blocks are stored). See the JPEG spec.

-- Matt Mahoney

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com