�������� �
��
��
������
��
��
���
����������������
�������� �
��������
�
� ����� � � � � � �
� ��� �� �
�
�
� � � �
� � ���!�� �
� � � � "
� ��������
��
���
� �
!�"�� � � � � � ���� � � � � � �
� ! � � � � ���
!�"�" # $ % & '( ) � � �� � " #
* + � �
!�" ! $ % & '( ) � � �� � !
, - . �
�������� �
���������
�����
���
� ��
#�����
��$�
�%��&$��� '&(�
��
��)&
� ��
�*�
(�������
(���
����+��
����������
�,,�
� ��
��
�������$�����)�����&�(������
�(
$��
� -��(+��(��(.)(�
��+�/� ����(�������%
� ���%�(���*(�/� ����(�������%
� 0���+(��������%��(
$���
� 1�(����$���+������%��(
$��
� ���&+��%�����2)��
�3�
�����(�
��
�������(�(���
�+����+(��
�����%���$(�(
�������� 4
��
����
� ��������
�
� �
� ���� � � � � �� ��� � � �� � /� � �
���� � � ! " 8#/ $ /%�& ' ( ) �� � Huffman*
+ ,
� -
�
. /
� ���0 1 2 3 4 5 6 7 � � � 8 9 : � �; < =
> ? @ A = > ? B C D E F D � � � �� � � ! " 12#/ $
/%�G E ( ) � � � Huffman*+ ,
� -
�
H I
� ���� � J � ��� � � �� � J � K L ���
� � � ! " ����#5 $ 5%�' M ( ) �� � N O P *+ ,
� �
� Q R S T *��U V W X Y � � ��� Z [ �
����
����
�������� �
���%�(���*(������%
� ���%�(���*(������%
� $������(����)�(�)+����+�6��&((��
�(
6��7�(�*�����(�
�
�������� �
1�(����$���+������%
� $�((��
(&�#��(�)�
���8�('&������8�����
�����%�
�������� 9
-��(+��(�*��� '
(��(�
�������� :
������
� � � � � � � � �
� � � � � � �� � � ���
����
� � � � ! �� � � �;�
�������� ,
� � � �
� �
� ���
�
� ��
� � " #
� ��
� � $ %
� ��
� � & '( ) *
� + , -
� . / , -
� 0 1 2 3
� 4 5 6 7 -
� 8 9 : �
�������� ��
� � � �
� ��� � � �
� ���5� ����,�:�/ ��“0 1 2 ! ) 3 " 4 �
� � � 5 6 ”7��
��8 � 9 : " 4 � �
� �
��; < = >
� ��
�? @ A B ���C� �D A ��E F ���
G
H I ��
" 4 J K � � J L � � 5 6 �
�MN O G : P Q R S T
��MU V : ��
�
�>
� ��
? @ A W T X Y Z [
" 4 � � J L � � �
�M\ ] T ^ 1 2 � � U ] T ^ ( ) � � >
�������� ��
��
� � � ��
� ; < = > ( � � & '
� = ? @ A B C , - /� ( D E � � &
'FG H I J ( K L M N OP25:1( � �
Q R S T U ( � � V : �W � � X Y Z
P[ \ ]
� = ? ^ _ ` N a b c d DPCM( e E � �
& 'Of < 2 3 g h i j ) * Ok l �
� V : U Om � � Q n o �p q 2:1 ]
�������� ��
-+��7�/��%���������
� ����(�
�������� ��
-+��7�/��%���������
���
Color
Converter
YCbCr
R
G
B
8 × 8
Image Block
Quantization
Table Coding Table
Quantization Entropy CodingDCT
Lossless Lossy
Lossless Lossy Lossless
Sampling
Output File
Head
Data
�������� �4
-+��7�/��%���������
�/(���(�
�������� ��
� � /� � � �
������
��������
� �
8x8
�� ����
� �
8x8
� � ����
���� ��� � � �
����
� � �
����
�������� ��
��
������%�<+%���
$���*(�*�(6
�������� �9
!"
�#$%&'
� rs@ABC,-(Forward Discrete Cosine
TransformOFDCT)t ^ _ / u v ( � � ,-
w . x / u v ( � � ]
� y z { 9 | DCT 8 9 } ~ : � Of y z {
9 | ? J ( K L 8 ( ]
�
, 23 | : � 8 9 } ~ 2
3]
��������
��
� ��������������
��
� ��������������
��
� ��������������
��
� ����������
�������� �:
��&(+��(�����&�(������/(��%�
Read
Values
From
SRAM
And
store
in a
8x8
matrix
FDCT Quantization
Run
Length
Encoding
To SRAM
�������� �,
��
( )
� ��
<=_()`abcd
� ��
<=e f
()� �? * g
()h i �
�d
� ] j � � k l m n ()`a
J L >
� o � p !+����"
� q r !���&+��%"
� i ; !.)��
�3�
���"
�������� ��
��
�&'
������������
� � � �������
�./,-
� 4 5 6 7-
� 8 9 : �
� 0 1 2 3
�������� ��
*+,��
� � � q ::( O| !
} ~ /� ,-]
8x8
� J | 1 Q |
1 y ( M
NO� : q ::(
O�
� : q
����(]�
� : (
¡ ¢ �5�( £ ¤ ¥
w ::( ]
�������� ��
Block-based Example
JI
note that white lines are artificially added to
the border of each 8-by-8 block to denote
that each block is processed independently
�������� ��
-�)������������%
padded regions
Example
12
13
14
15
16
17
18
19
12
13
14
15
16
17
18
19
12
13
14
15
16
17
18
19
12
13
14
15
16
17
18
19
When the width/height of an image is not the multiple of 8, the boundary is
artificially padded with repeated columns/rows to make them multiple of 8
�������� �4
- � . / 0 1 =
-0 2 >����
� J | O¦ § M ¨ O=
-7
-q >����© ª O2 3« | ¬ I M 2
3®
>��?������,,=���@����:9�
��@�����4�-
�� ?�–���9:9=�– ������
��@������-��@���:
�� ?�������=���– ��4�:9
���– ���:��-�@����:
�����
=�?�>�@���4����!�� – ��:"
�?�>�– ���44�4!�� – ��:"�– ��9�4�4!�� – ��:"
-�?�>�@���99���!�� –��:"
�������� ��
=
-3>AB- � . / # 0 1
� >AB
K 8 ¯ ¬ I (+ © ° ]�
1 O�
� 1 ]
� 7-± ° #
�
�
�
�
�
��
���
�������
���
�
������
�������
���
�������
������
�
��
�������� ��
2010-3-5 LIST 26
YUV (YCbCr) Subsampling
4:4:4
[Y0(dc), Y0(ac)],
[Cb(dc), Cb(ac)],
[Cr(dc), Cr(ac)]
4:2:2
[Y0(dc), Y0(ac)]
[Y1(dc), Y1(ac)],
[Cb(dc), Cb(ac)],
[Cr(dc), Cr(ac)]
�������� �9
C$��/� ���
�DD �E
� DCT is like FFT, but can approximate linear signals well
with few coefficients.
�������� �:
/� 4 1
� �����
� /� � � �
� �
� � �� � � � �� � � � � � �� � �
� � �� � ! " /� � � �# $ % �& ' ( � ) * + , - . / 0
1 2 3 4 5 67 8 * 9 : ; � < = /� � � �> 2 ? @ 6
� A B C D �/� � � �< = > 2 1 E F , G H I J K L
�M< = DD > 2 6N O P DD Q 5 R /� � � �< = > 2 6S
T�5RU�VWX�� Y > Z [ \ ] ^ 4 _ ` > 6a � /� �
� B b � c d �5 �C e f _ �g h �i j k ` > l �m n
o p q r � � k s t � � u 6
�MN O v 5 w x y /� < = �� 6g h �z I J 2 U{ � B |
I C D �Y > l } o p � u d � ~ � B 6
� � 8 �| � � I J 2 Q 5R/� �� � < = > 2 6
�������� �,
/� �!/����(
(������(� ��������"
2010-3-5 LIST 29
�
�
�
�
�
�
�
� +
=
=
n
n
u
N
n
nf
N
uF
nf
N
F
pi
2
)12(
cos)(2)(
)(1)0(
(u=1, …, N-1)
( )
� �
�
�
�
�
� +
+=
u
u
N
x
uF
N
F
N
nf pi
2
12
cos)(2)0(1)(
1DDCT
2DDCT ( ) ��=
x y
yxf
N
F ),(10,0
�� �
�
�
�
�
� +
=
x y
v
N
yyxf
N
vF pi
2
12
cos),(2),0(
�� �
�
�
�
�
� +
=
x y
u
N
xyxf
N
uF pi
2
12
cos),(2)0,(
�� �
�
�
�
�
� +
�
�
�
�
�
� +
= pipi v
N
y
u
N
xyxf
N
vuF
2
12
cos
2
12
cos),(2),(
(u,v = 1, …, N-1)
�������� ��
2010-3-5 LIST 30
(0,255) � (-128, 127)
�������� ��
/� ��
� DCT����������
��� �
����
� � ������ ���� � � �� �� � ��
�� � �� �� � �
� � �� � � ! �� � � �" � # $ % & ' ( �)
* + ,
- . A / � A
M0N - . 122DCT��
3 4
5
�� ��
�� ��
�������� ��
D�(.)(����/��
���)
���������/�/�
�������� ��
� � � �
� 6 ��+ �/� - . 78& * 9 : ;<= 3 �&
* - . % > 6 >% & ? A@B% & & * A �
� & * �B 1�C � D % <� ? @ � A B 1)������ �
�������� ��
=)��0(�%
$������%�!���
�"
Length of L
��+(����<���������
�������� ��
<��1)�����������%
�������� ��
<�� '��&+(����-��(+��(�/� �-��(�������%
�������� ��
/� ������
� 7 C ! D E � F G H
' I J � K L M N �
O P Q R S H �L T
O U )
� V � W X A U L M N
' Y Z [ � )
� � \ ] ^ I J �� U
L M N _ ` a G Y b
c I J d e )
�������� �4
� � � � � � � �
� � �
� 6 h 6450600�- . A
f G � D % � -
. �G � D % U
0F�L
� - . E
�:90 � & � B �
;�:90 A;�4�0���A?��N
������ � � �
������������� �����
������
�
���
������������� �����
������
�
���
�� �� ��
������������� �������
�
���
������
����
��������
�
���
�� �� ��
������
����
��������
�
���
�������� ��
��������������%�������%(�
� C$����
�
���������
$(�6$�+(����%(�
�%(
$(�E
� =(.)��(���+��%(��(�����
���
��(�
�����������
��'
� �
������
���%������(���������&�(�������)(�
���&�
��++��*�����%��
�
��
����6�
$������
���%(
� ��(�����&��
�
�����%�������%(���
��
�+��7�
� ��$��+��7����*�(6(����������++(�����%(�
����&���(��(�����(&(��(�
+�
� �
������
�����%��8��)
������&�����(
�������� ��
Work with a Toy Example
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
169130
173129
170181
170183
179181
182180
179180
179179
169132
171130
169183
164182
179180
176179
180179
178178
167131
167131
165179
170179
177179
182171
177177
168179
169130
165132
166187
163194
176116
15394
153183
160183
Any 8-by-8 block in an image is processed in a similar fashion
�������� �9
Encoding Stage I: Transform
• Step 1: DC level shifting
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
169130
173129
170181
170183
179181
182180
179180
179179
169132
171130
169183
164182
179180
176179
180179
178178
167131
167131
165179
170179
177179
182171
177177
168179
169130
165132
166187
163194
176116
15394
153183
160183
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−
412
451
4253
4255
5153
5452
5152
5151
414
432
4155
3654
5152
4851
5251
5050
393
393
3751
4251
4951
5443
4949
4051
412
374
3859
3566
4812
2534
2555
3655
128 (DC level)
_
�������� �:
• Step 2: 8-by-8 DCT
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−
412
451
4253
4255
5153
5452
5152
5151
414
432
4155
3654
5152
4851
5251
5050
393
393
3751
4251
4951
5443
4949
4051
412
374
3859
3566
4812
2534
2555
3655
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−−
−
−
−−
−
−−
−−
−
−
−
−−
−
−
−−
−−
−−
−
−
−−
−−
13
42
12
09
40
21
13
44
30
55
47
73
30
46
32
16
113
916
109
621
179
3310
810
1720
1024
2727
132
6078
4413
1827
2738
56313
Encoding Step 1: Transform (Con’t)
8×8
DCT
�������� �,
Encoding Stage II: Quantization
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
99103
101120
100112
121103
9895
8778
9272
6449
92113
77103
10481
10968
6455
5637
3524
2218
6280
5669
8751
5740
2922
2416
1714
1314
5560
6151
5826
4024
1914
1610
1212
1116
Q-table
8,1
ˆ:
:
1
≤≤
⋅=
�
�
�
�
�
=
−
ji
Qsxf
Q
x
sf
ijijij
ij
ij
ij
: specifies quantization stepsize
Notes: •Q-table can be specified by customer
•Q-table is scaled up/down by a chosen quality factor
•Quantization stepsize Qij is dependent on the coordinates (i,j) within the 8-by-8 block
• Quantization stepsize Qij increases from top-left to bottom-right
�������� ��
Encoding Stage II: Quantization (Con’t)
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−−
−
−
−−
−
−−
−−
−
−
−
−−
−
−
−−
−−
−−
−
−
−−
−−
13
42
12
09
40
21
13
44
30
55
47
73
30
46
32
16
113
916
109
621
179
3310
810
1720
1024
2727
132
6078
4413
1827
2738
56313
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−−
−−
−−
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
01
10
11
01
11
00
01
01
23
21
13
23
520
Example
f
xij sij
�������� ��
Encoding Stage III: Entropy Coding
Zigzag Scan
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−−
−−
−−
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
01
10
11
01
11
00
01
01
23
21
13
23
520
(20,5,-3,-1,-2,-3,1,1,-1,-1,
0,0,1,2,3,-2,1,1,0,0,0,0,0,
0,1,1,0,1,EOB)
zigzag scan
End Of the Block:
All following coefficients
are zero
�������� ��
Run-length Coding
(20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB)
DC
coefficient
AC
coefficient
- DC coefficient : DPCM coding
- AC coefficient : run-length coding (run, level)
(5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB)
(0,5),(0,-3),(0,-1),(0,-2),(0,-3),(0,1),(0,1),(0,-1),(0,-1),(2,1),
(0,2),(0,3),(0,-2),(0,1),(0,1),(6,1),(0,1),(1,1),EOB
Huffman coding
encoded bit stream
encoded bit stream
�������� ��
JPEG Decoding Stage I:
Entropy Decoding
(20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB)
Huffman decoding
encoded bit stream
AC
coefficients
DC
coefficient
DPCM decoding
!�8�"8!�8��"8!�8��"8!�8��"8!�8��"8!�8�"8!�8�"8!�8��"8!�8��"8!�8�"8
!�8�"8!�8�"8!�8��"8!�8�"8!�8�"8!�8�"8!�8�"8!�8�"8 �-
encoded bit stream
�������� �4
JPEG Decoding Stage II:
Inverse Quantization
(20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB)
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−−
−−
−−
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
01
10
11
01
11
00
01
01
23
21
13
23
520
zigzag
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−−
−−
−−
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
040
290
2416
014
1314
00
051
026
8072
3814
1630
2436
55320
f-1
�������� ��
JPEG Decoding Stage III:
Inverse Transform
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−−
−−
−−
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
040
290
2416
014
1314
00
051
026
8072
3814
1630
2436
55320
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
169130
185127
170181
162192
179181
181184
179180
178183
173128
161129
169191
175186
174181
168186
178181
182172
170131
177128
170185
166187
171187
168172
180169
169174
175124
170120
168193
171197
158143
148119
153186
140195
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
−
−
−−
412
571
4253
3464
5153
5356
5152
5055
450
331
4163
4758
4653
4058
5053
5444
423
490
4257
3859
4359
4044
5241
4146
474
438
4065
4369
3015
209
2558
1267
8×8
IDCT
128
(DC level)
+
�������� ��
2)��
�3�
����L���(
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
169130
173129
170181
170183
179181
182180
179180
179179
169132
171130
169183
164182
179180
176179
180179
178178
167131
167131
165179
170179
177179
182171
177177
168179
169130
165132
166187
163194
176116
15394
153183
160183
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
169130
185127
170181
162192
179181
181184
179180
178183
173128
161129
169191
175186
174181
168186
178181
182172
170131
177128
170185
166187
171187
168172
180169
169174
175124
170120
168193
171197
158143
148119
153186
140195
X X
^
MSE=||X-X||2^Distortion calculation:
Rate calculation: Rate=length of encoded bit stream/number of pixels (bps)
�������� �9
��
� '��&+(�
1000
90 (58k bytes)50 (21k bytes)10 (8k bytes)
best quality,
lowest compression
worst quality,
highest compression
�������� �:
C�*(+(
�*���/�
JPEG (CR=64) JPEG2000 (CR=64)
discrete cosine transform based wavelet transform based
�������� �,
���%(����&�(�������)�����
� ��
? @2@��!��������
�����('�(&
�
��(���(��6�*(+(
�
������������
(���
���/� "
� O(����(�#��&����
����
���������
��(�����(�
��!���
�
���������
��(�����(�
����(�.)��
�3(��
��3(��"
� ;����6(�7�(��#��+��7����
����
���
�
+�6���
���
(��!������(�+��7��%
�+%���
$���$�*(��((��&��&��(�����
$(�
+�
(��
)�("
�������� 9�
�(�(�(��(
� 0��P��
� 0(�
)�(���
(�� �4�����
���)�
����
��
/�%�
�+����%(�����(����%�
� ���
� ; �����P/A8�����
� ����&&