Case Study ARM Platform-based JPEG Code HW/SW Co-design Teahing Assistant : u-ju Cho Advisor : Prof. An-eu Wu
Outline Introdution to JPEG Code Lab Case study Referene
ISO/IEC 098- JPEG JPEG: Joint Photographi Eperts Group JPEG voted as international standard in 99 JPEG standard has four ompression method Baseline sequential DCT-based oding Progressive DCT-based oding Lossless oding method Sampling and Quantization are not onsidered at loss-less oding sheme Hierarhial oding method
Color Model in Video CrCb CbCr olor mode is used in JPEG and MPEG CCIR-0 transform formula = 0.99R + 0.8G + 0.B Cb = 0.8R 0.G + 0.99B Cr = 0.R 0.9G 0.08B The hrominane values in CbCr are always in the range of 0 to Color spae transform is loss-less
Chroma Sub-sampling : : : : piel with, Cr and Cb value piel with only value piel with only Cr and Cb value : : : : 0 :: and ::0 are mostly used in JPEG and MPEG
Blok Diagram of JPEG Enoder Header f(i,j) 88 DCT Coding Tables F(u,v) Quantization Quantization Table Fq(u,v) 00000 Tables Data Entropy Coding DPCM RLC DC AC zig zag san
Blok Diagram of JPEG Deoder 00000 Header Tables Coding Tables Quantization Table Data Entropy Deoder Fq(u,v) Inverse Quantization F(u,v) IDCT f(i,j) 88
8 -D DCT (Disrete Cosine Transform) ( ) ( ) 0 ) ( (0), 0,,,,, ; os os ) ( ) ( 0 0,, = = = + + = = = n for n and where N k k n n N k n N k n k k N X N n N n n n k k Λ π π
Basis Image of -D DCT 9
Frequeny Distribution of -D DCT DC low frequeny medium frequeny DC Diagonal edges Vertial edges high frequeny Horizontal edges High frequeny 0
8 point -D DCT Algorithm (/) k, l for L = i= 0 i C k os ( i + ) L kπ ; k = 0,, Λ, L ; where C k, l = k = 0 otherwise
8 point -D DCT Algorithm (/) ( ) = = = + = = otherwise k C where L k for L k i C l k L i k i l k 0 ;, 0,, ; os, 0, Λ π [ ] [ ][ ] ( ) = + + + + = = = = 0 0 0 0 0 ; os i where X C i θ
Implementation -D DCT Eample: row-olumn deomposition Separable, row-olumn deomposition Z = AXA T ( i + ) L = kπ k, l i Ck os ; for k = 0,, Λ L i= 0 X D DCT Unit =AX Transport Memory (), L ; where C k, l D DCT Unit Z=A T k = 0 = otherwise Z
Quantization Table for Luminane 0 0 9 8 0 0 9 9 8 80 8 8 09 0 8 0 9 9 8 8 0 0 0 9 9 98 00 0 99
Quantization Table for Chrominane 8 99 99 99 99 8 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
Preditive Coding of DC Coeffiients DC i DC i bloki bloki sample DCi Differene Previous sample DC i DC i DCi
Zig-zag San (AC Coeffiients) DC
Run-Length Coding DC 0 - - 0 0 0 0 0 - - 0 0 0 0 0 0 - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (R,L) => (0,-)(0,-)(0,-)(0,-)(,-)(EOB) 8
Huffman Coding for DC Coeffiient Category AC Coeffiient Range -, SSSS 0 Value 0 -, -,-,, -,,-,,, -,,-8,8,, -,,-,,, -,-,, -,,-,,, -,,-8,8,, -,,-,,, -,,-,,, -,,-,,, 8 -,,-8,8,, 9 -,,-,,, 0-0,,-,,,0-0,,-0,0,,0 9
An Eample of Baseline DCT-based Coding 0 0 0 9 9 0 0 8 9 8 0 0 8 8 0 0 0 0 8-0 0 0 - - 0 0 0 0 0 - - 0 0-0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0-0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 9 9 9 9-8 Zig-Zag Run-length Q Table 9 9 0 9 8 9 0 8 8 0 8 0 8 9 9 9 8 8-9 9 0 8 9 9 8 ()(),(0,)(-), (0,)(),(0,)(-), (0,)(-),(0,)(), (,)(),(0,)(-), (0,)(-),(,)(), (,)(),(,)(-), (,)(-),(,)(- ), (,)(-),(0,0) Huffman FDCT 8 - -8-9 - -8 0 - -9-0 0-0 - - -8-0 0-8 - - -8 - - 8-9 - 8 - -8 8 8-0 - 8 0 - - - - - 0 - - - 0 (0)(0)(0)(00)(00) (00)(00)(0)(00)(00)(0) (0)(0)(0)(0)(0)(0) (0)(0)(0)(00) ()(0)(0)(00)(0) (0)(0)(00)(0)(00) total 98 bits Q 0
JPEG Bitstream Start_of_image Frame End_of_image Tables, et. header san... san Tables, et. header segment Restart segment Restart... blok blok blok... blok
Outline Introdution to JPEG Code Lab Lab Case study Case study Referene
File Struture Final_projet --------- sw.bat - 純軟體執行之批次檔 ---- hw.bat - 軟硬體共同執行之批次檔 ---- Download.brd - 燒錄 bit 檔至 LM 模組之檔案 ---- sw -------- _dt.pp - 硬體之 DCT 程式碼 ---- bmp.pp - 讀取 *.bmp 檔 ---- jpeg.pp - JPEG 之區塊編解碼引擎 ---- jpeg.h - jpeg.pp 之宣告 ---- main.pp - JPEG Code 程式主體 ---- marker.h - JPEG 圖檔之標籤 ---- piture.pp - 存取靜態影像 ---- stream.pp - 讀取 bitstream ---- stream.h - stream.pp 之宣告 ---- type.h - 基本型別的宣告 ---- hw -------- ahbapb.v ---- ahbahbtop.bit - IP 的 Xilin 燒錄檔 ---- ahbahbtop.v ---- ahbapbsys.v ---- ahbdeoder.v ---- ahbmusm.v ---- ahbzbtram.v ---- apbinton.v ---- apbregs.v ---- dt.v - Chen's DCT/IDCT 核心電路 ---- LM_flash_load.bit ---- map.uf ---- myip.v - DCT/IDCT 之 IP
Read & Write Address 0F0000000 0E0000000 0D0000000 0C0000000 Logi module Logi module Logi module Logi module 0 Core module alias memory Bus Error response test_register SSRAM Interrupt LM registers 0CFFFFFFF 0C0000 0C00000 0C000000 0C000000 0C0000000 Write_head 0000000 000000 0000008 000000 000000 00000 000008 00000 Read_head FDCT Write_head 000000 00000 000008 00000 000000 00000 000008 00000 Read_head IDCT PCI 000000 000000 00000 00000 000008 000008 Core Module / Motherboard memory and peripherals 00000 000000 00000 000008 00000 000000 00000 000008 00000 00000
Result for SW Simulation Original Enoder Deoder
Result for HW Simulation Original Enoder Deoder
Profiling Result of SW Simulation
Lab Case Study Goal Implement the JPEG ode system using ARM platform Priniples Implement the ARM platform-based JPEG ode HW/SW o-design Requirement Analysis the profiling of pure software simulation Eplain how to partition the HW/SW of JPEG ode Implement the JPEG ode with HW/SW o-design Disussion Eplain where is the stak and heap? And who initialize them 8
Outline Introdution to JPEG Code Lab Case study Referene 9
Referene Wen-Hsiung Chen, C. Harrison Smith, and S. C. Fralik, "A Fast Computational Algorithm for the Disrete Cosine Transform," IEEE Trans. Commun., vol. COM-, pp. 00-009, Sept 9. JPEG: Still Image Data Compression Standard by William B. Pennebaker and Joan L. Mithell, Kluwer Aademi Publishers, ISBN: 00 0