290 likes | 456 Views
Multimedia Communications EG 371 and EG 348. Dr Matthew Roach Lecture 4 JPEG compression / format. JPEG. Joint Photographic Experts Group Standards for saving digital images Many compression modes Lossy sequential mode Baseline mode. JPEG. Image / block preparation
E N D
Multimedia CommunicationsEG 371 and EG 348 Dr Matthew Roach Lecture 4 JPEG compression / format Multimedia communications EG-371 Dr Matt Roach
JPEG • Joint Photographic Experts Group • Standards for saving digital images • Many compression modes • Lossy sequential mode • Baseline mode Multimedia communications EG-371 Dr Matt Roach
JPEG • Image / block preparation • Forward DCT (discrete cosine transform) • Quantisation • Entropy encoding • Frame building Multimedia communications EG-371 Dr Matt Roach
Image / block preparation Multimedia communications EG-371 Dr Matt Roach
Image / block preparation Cr Y Cb Multimedia communications EG-371 Dr Matt Roach
Image / block preparation R B G Multimedia communications EG-371 Dr Matt Roach
Image / block preparation • Each matrix compressed separately • Using DCT • Spit into blocks for speed Multimedia communications EG-371 Dr Matt Roach
Forward DCT • Not concerned with how • What • Transform into frequency components • Why • Spatial frequency sensitivity of the HVS • Benefit • Creates higher redundancy for encoding Multimedia communications EG-371 Dr Matt Roach
DCT Increasing fH Coefficients DCT Increasing fV Coefficients P[x,y] F[i,j] DC coefficient AC coefficient Multimedia communications EG-371 Dr Matt Roach
DCT • Typical DCT coefficients after transform Multimedia communications EG-371 Dr Matt Roach
Quantisation • Quantisation table Multimedia communications EG-371 Dr Matt Roach
Quantisation • DCT coefficients Multimedia communications EG-371 Dr Matt Roach
Quantisation • DCT coefficients Quantisation table Multimedia communications EG-371 Dr Matt Roach
Quantisation • DCT coefficients Quantized DCT coefficients Multimedia communications EG-371 Dr Matt Roach
Quantisation • Computation involves rounding to nearest integer value • Threshold value increase with spatial frequency • The DC component in transformed matrix is largest • Many high frequency coefficient are 0 Multimedia communications EG-371 Dr Matt Roach
Entropy encoding • Vectoring • Differential encoding • Run length encoding • Huffman encoding Multimedia communications EG-371 Dr Matt Roach
Vectoring • 2-D matrix into string of values • Linearized vector 63 2 1 0 AC confidents increasing in order of frequency DC coefficient Multimedia communications EG-371 Dr Matt Roach
Vectoring example 63 ………………. 5 4 3 2 1 0 Multimedia communications EG-371 Dr Matt Roach
Differential encoding • Encoded the difference • Across blocks for the DC coefficient • Largest absolute value • Coded (SSS, value) • SSS number of bits needed to code value • Value, actual bits that represent the value • Uses complement for negative values • 12,13,11,11,10 …> 12,1,-2,0,-1 • (4,1100)(1,1)(2,01)(0, )(1,0) • (sss, value) Multimedia communications EG-371 Dr Matt Roach
Frame building • Top level • Start of frame delimiter • End of frame delimiter • Frame header • Width height of frame • Number of components (R,G,B etc) • Digitisation format used (4:2:2, 4:2:0 etc.) • Frame contents Multimedia communications EG-371 Dr Matt Roach
Frame building • Frame Contents • Scan • Segment • Segment header • Huffman table used to encode each block • Scan header • Identity of components (R,G,B etc) • Number of bits used to digitise components • Quantisation table used to encode components Multimedia communications EG-371 Dr Matt Roach
Scream resolution 813 x 1012 Image 1 Size 56k Download time 10 sec (56k) 0.8 sec (720k) Image 2 Size 14k Download time 2.5 sec (56k) 0.2 (720k) Example images – Image 1 Multimedia communications EG-371 Dr Matt Roach
Scream resolution 813 x 1012 Image 1 Size 56k Download time 10 sec (56k) 0.8 sec (720k) Image 2 Size 14k Download time 2.5 sec (56k) 0.2 (720k) Example images – Image 2 Multimedia communications EG-371 Dr Matt Roach
Frame types • Intracoded frames I-frames • Encoded with no reference to other frames • Y Cr Cb matrices encoded independently JPEG • Predictive frames P-frames • Encoding based on preceding I or P frame • Motion estimation, motion compensation • Error propagation • Bi-directional frames B-frames • Intercoded , interpolation frames • Used to combat fast moving objects Multimedia communications EG-371 Dr Matt Roach
I, P and B frame sequencing • Sequencing • M = Prediction span • 1-3 • N= GOP • Group of pictures • 3-12 I P P I P P I M = 1 N = 3 I B B P B B I M = 3 N = 6 Multimedia communications EG-371 Dr Matt Roach
Altering the sequence • Uncoded frame sequence • IBBPBBPBBI • The recorded sequence would be • IPBBPBBIBB Multimedia communications EG-371 Dr Matt Roach
Motion estimation and compensation 8 • 1 Macroblock • 4 blocks Y • 1 block Cr • 1 block Cb • Block (8x8) • Digitisation format • 4:1:1 8 8 8 Cr 8 Y 8 8 Cb 8 Multimedia communications EG-371 Dr Matt Roach
Encode P frame • Macroblock • Address • Target frame • Frame to be encoded • Reference frame • preceding I or P frame • Motion vector Multimedia communications EG-371 Dr Matt Roach
Example motion vector estimation Multimedia communications EG-371 Dr Matt Roach