ESE532: System-on-a-Chip Architecture. Today. Message. Project. Expect. Why MPEG Encode? MPEG Encoding Project Motion Estimation DCT Entropy Encoding

Similar documents
ECE 417 Guest Lecture Video Compression in MPEG-1/2/4. Min-Hsuan Tsai Apr 02, 2013

Perceptual Coding. Lossless vs. lossy compression Perceptual models Selecting info to eliminate Quantization and entropy encoding

Video Compression An Introduction

Lecture 8 JPEG Compression (Part 3)

Index. 1. Motivation 2. Background 3. JPEG Compression The Discrete Cosine Transformation Quantization Coding 4. MPEG 5.

Digital Image Representation Image Compression

TKT-2431 SoC design. Introduction to exercises

Lecture 8 JPEG Compression (Part 3)

Video Compression MPEG-4. Market s requirements for Video compression standard

IMAGE COMPRESSION. Image Compression. Why? Reducing transportation times Reducing file size. A two way event - compression and decompression

TKT-2431 SoC design. Introduction to exercises. SoC design / September 10

Professor Laurence S. Dooley. School of Computing and Communications Milton Keynes, UK

Digital Video Processing

DigiPoints Volume 1. Student Workbook. Module 8 Digital Compression

What is multimedia? Multimedia. Continuous media. Most common media types. Continuous media processing. Interactivity. What is multimedia?

ESE532 Spring University of Pennsylvania Department of Electrical and System Engineering System-on-a-Chip Architecture

Image, video and audio coding concepts. Roadmap. Rationale. Stefan Alfredsson. (based on material by Johan Garcia)

Lecture 6: Compression II. This Week s Schedule

Multimedia. What is multimedia? Media types. Interchange formats. + Text +Graphics +Audio +Image +Video. Petri Vuorimaa 1

Introduction ti to JPEG

VC 12/13 T16 Video Compression

15 Data Compression 2014/9/21. Objectives After studying this chapter, the student should be able to: 15-1 LOSSLESS COMPRESSION

The Basics of Video Compression

CS 335 Graphics and Multimedia. Image Compression

CISC 7610 Lecture 3 Multimedia data and data formats

Outline Introduction MPEG-2 MPEG-4. Video Compression. Introduction to MPEG. Prof. Pratikgiri Goswami

7.5 Dictionary-based Coding

Chapter 11.3 MPEG-2. MPEG-2: For higher quality video at a bit-rate of more than 4 Mbps Defined seven profiles aimed at different applications:

Multimedia Systems Image III (Image Compression, JPEG) Mahdi Amiri April 2011 Sharif University of Technology

ESE532: System-on-a-Chip Architecture. Today. Message. Fixed Point. Operator Sizes. Observe. Fixed Point

Lossy compression CSCI 470: Web Science Keith Vertanen Copyright 2013

Interframe coding A video scene captured as a sequence of frames can be efficiently coded by estimating and compensating for motion between frames pri

AN ANALYTICAL STUDY OF LOSSY COMPRESSION TECHINIQUES ON CONTINUOUS TONE GRAPHICAL IMAGES

2014 Summer School on MPEG/VCEG Video. Video Coding Concept

Image Compression Algorithm and JPEG Standard

CMPT 365 Multimedia Systems. Media Compression - Image

Lecture 5: Compression I. This Week s Schedule

ESE532: System-on-a-Chip Architecture. Today. Message. Preclass 1. Computing Forms. Preclass 1

Lecture 3 Image and Video (MPEG) Coding

Lossy compression. CSCI 470: Web Science Keith Vertanen

Overview. Videos are everywhere. But can take up large amounts of resources. Exploit redundancy to reduce file size

Compression; Error detection & correction

ESE532: System-on-a-Chip Architecture. Today. Message. Clock Cycle BRAM

Digital Image Processing

Using Streaming SIMD Extensions in a Fast DCT Algorithm for MPEG Encoding

5: Music Compression. Music Coding. Mark Handley

Compression; Error detection & correction

Computer and Machine Vision

JPEG. Wikipedia: Felis_silvestris_silvestris.jpg, Michael Gäbler CC BY 3.0

Data Representation. Reminders. Sound What is sound? Interpreting bits to give them meaning. Part 4: Media - Sound, Video, Compression

Introduction to Video Compression

The PackBits program on the Macintosh used a generalized RLE scheme for data compression.

Image Compression. CS 6640 School of Computing University of Utah

Compression Part 2 Lossy Image Compression (JPEG) Norm Zeck

Review and Implementation of DWT based Scalable Video Coding with Scalable Motion Coding.

Lecture 12: Compression

Comparative Study of Partial Closed-loop Versus Open-loop Motion Estimation for Coding of HDTV

CSCD 443/533 Advanced Networks Fall 2017

Source Coding Techniques

Review for the Final

FPGA Implementation of Low Complexity Video Encoder using Optimized 3D-DCT

Chapter 1. Digital Data Representation and Communication. Part 2

Week 14. Video Compression. Ref: Fundamentals of Multimedia

Topic 5 Image Compression

IMAGE COMPRESSION. Chapter - 5 : (Basic)

In the name of Allah. the compassionate, the merciful

Wireless Communication

Part 1 of 4. MARCH

VIDEO AND IMAGE PROCESSING USING DSP AND PFGA. Chapter 3: Video Processing

Image Transformation Techniques Dr. Rajeev Srivastava Dept. of Computer Engineering, ITBHU, Varanasi

Introduction to Video Encoding

CS 260: Seminar in Computer Science: Multimedia Networking

Using animation to motivate motion

3. (a) Prove any four properties of 2D Fourier Transform. (b) Determine the kernel coefficients of 2D Hadamard transforms for N=8.

University of Pennsylvania Department of Electrical and Systems Engineering Digital Audio Basics

IMAGE COMPRESSION USING HYBRID QUANTIZATION METHOD IN JPEG

Features. Sequential encoding. Progressive encoding. Hierarchical encoding. Lossless encoding using a different strategy

IMAGE COMPRESSION USING FOURIER TRANSFORMS

A Parallel Reconfigurable Architecture for DCT of Lengths N=32/16/8

DIGITAL TELEVISION 1. DIGITAL VIDEO FUNDAMENTALS

Multimedia Signals and Systems Motion Picture Compression - MPEG

COMP 249 Advanced Distributed Systems Multimedia Networking. The Video Data Type Coding & Compression Basics

CSEP 521 Applied Algorithms Spring Lossy Image Compression

Tutorial on Image Compression

Compression II: Images (JPEG)

2.2: Images and Graphics Digital image representation Image formats and color models JPEG, JPEG2000 Image synthesis and graphics systems

JPEG: An Image Compression System. Nimrod Peleg update: Nov. 2003

Digital Image Representation. Image Representation. Color Models

Module 7 VIDEO CODING AND MOTION ESTIMATION

Audio Compression. Audio Compression. Absolute Threshold. CD quality audio:

Image Coding and Data Compression

Anatomy of a Video Codec

DIGITAL IMAGE PROCESSING WRITTEN REPORT ADAPTIVE IMAGE COMPRESSION TECHNIQUES FOR WIRELESS MULTIMEDIA APPLICATIONS

SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road UNIT I

Multimedia Communications. Transform Coding

LECTURE VIII: BASIC VIDEO COMPRESSION TECHNIQUE DR. OUIEM BCHIR

ELL 788 Computational Perception & Cognition July November 2015

Multimedia Systems Video II (Video Coding) Mahdi Amiri April 2012 Sharif University of Technology

ESE532: System-on-a-Chip Architecture. Today. Message. Graph Cycles. Preclass 1. Reminder

Lecture 13 Video Coding H.264 / MPEG4 AVC

Transcription:

ESE532: System-on-a-Chip Architecture Day 16: March 20, 2017 MPEG Encoding MPEG Encoding Project Motion Estimation DCT Entropy Encoding Today Penn ESE532 Spring 2017 -- DeHon 1 Penn ESE532 Spring 2017 -- DeHon 2 Message Compression is about exploiting (eliminating) Redundancy (lossless) Things humans don t notice much (lossy) Redundancy in video Temporal: data repeated frame-to-frame Spatial: frequency patterns Quantize: high frequencies Entropy encode values (e.g. frequencies) Penn ESE532 Spring 2017 -- DeHon 3 Project Continue to work with Speed up as much as possible on Zynq Estimate custom design to achieve realtime for 1080p30: 1920x1080 at 30 fps Groups of 2 you select partners Next 5 weeks: project report 4/21 Weekly milestones Penn ESE532 Spring 2017 -- DeHon 4 Why MPEG Encode? Original intent: different problem Experience: MPEG harder than intended for first half warmup Probably right complexity for project Avoid giving you a project too complex Want you to succeed at accelerating Expect You will need to rewrite more of the code than you have so far C written for reference not organized or written correctly for acceleration Penn ESE532 Spring 2017 -- DeHon 5 Penn ESE532 Spring 2017 -- DeHon 6 1

Why not do this before? Expected wouldn t need to get this deep into it for the homework series. Could focus on bottleneck pieces and small snippets as we did for HW3 was familiar MPEG Encode Penn ESE532 Spring 2017 -- DeHon 7 Penn ESE532 Spring 2017 -- DeHon 8 Penn ESE532 Spring 2017 -- DeHon 9 Penn ESE532 Spring 2017 -- DeHon 10 Frame-to-Frame Temporal Redundancy How are two immediately adjacent video frames likely to be related? Common cases Fixed camera (e.g. security camera) Panning camera Object moving left to right Penn ESE532 Spring 2017 -- DeHon 11 Penn ESE532 Spring 2017 -- DeHon 12 2

Idea: Temporal Coding If part of frame not change Avoid resending If something moves in frame Avoid resending Identify where to find in previous frame MPEG Simplification Break image into 16x16 macroblocks Try to find macroblock in previous frame (or subsequent frame) Ideal Find perfect match Only send location of match Penn ESE532 Spring 2017 -- DeHon 13 Penn ESE532 Spring 2017 -- DeHon 14 Preclass 1 How big is pointer for 1920x1080 frame? How much cheaper than sending 16x16 macroblock with 8b pixels? Macroblock Match Finding identical macroblock: Where is this likely to work? What complicates? Penn ESE532 Spring 2017 -- DeHon 15 Penn ESE532 Spring 2017 -- DeHon 16 Challenge May not be exactly identical Shadows change Something moves over part of macroblock Thing in macroblock distorts Person talks, turns, rotates Object moves toward/away from camera Not Identical Send difference Maybe less information than new macroblock E.g. background occluded (exposed) on side Eye opens (closes) Penn ESE532 Spring 2017 -- DeHon 17 Penn ESE532 Spring 2017 -- DeHon 18 3

Finding Find matching macroblock Or best matching (hence dist) How go about finding? Local Search Hypothesize that the macroblock is nearby in previous image. Why might be good hypothesis? Simple Exhaustively search within some distance Why expensive? Penn ESE532 Spring 2017 -- DeHon 19 Penn ESE532 Spring 2017 -- DeHon 20 Limited Motion After a number of frames, less likely to find in previous frame New objects, turns, rotation, scale Send new, non-motion coded reference MPEG Frames Interleave I, P, and B frames I not motion coded P forward prediction frames Predict from previous frame B backward prediction frames Predict from future frames E.g. (IBBPBBPBBPBB)* Penn ESE532 Spring 2017 -- DeHon 21 Penn ESE532 Spring 2017 -- DeHon 22 Spatial Redundancy Can code more efficiently in frequency domain Humans notice low frequency components more than high frequency Can use fewer bits for high frequency components Penn ESE532 Spring 2017 -- DeHon 23 Penn ESE532 Spring 2017 -- DeHon 24 4

Day 14 Fourier Transform Discrete Cosine Transform Identify spectral components Convert between Time-domain to Frequency-domain E.g. tones from data samples Central to audio coding e.g. MP3 audio Similar to FFT Only uses Cosine (real part) (boundary condition) Y[k] = n 1 j =0 x[ j] cos π k N ( j + 0.5) Penn ESE532 Spring 2017 -- DeHon 25 Penn ESE532 Spring 2017 -- DeHon 26 2D-DCT Basis Actually compute 2D-DCT DCT in each spatial dimension On 8x8 blocks Can be viewed as a basis transform Re-expressing the 8x8 block in terms of 8x8 selection of x and y frequencies 2D-DCT Basis Basis vectors, so all 64 components are orthogonal Any 8x8 spatial is a weighted sum of these 64 components Penn ESE532 Spring 2017 -- DeHon 27 Penn ESE532 Spring 2017 -- DeHon 28 Preclass 2 Represent all 23 pixel block? Non-zeros for horizontal stripes? Non-zeros for vertical stripes? DCT Benefits 1. Concentrates weight in low frequency components (upper left) 2. High frequency components can be dropped or represented with few bits Not matter so much to human perception Penn ESE532 Spring 2017 -- DeHon 29 Penn ESE532 Spring 2017 -- DeHon 30 5

DCT Example 2D DCT Calculation Brute force like this O(n 4 ) n 2 entries Each require n 2 terms Source: http://img.tomshardware.com/us/1999/09/24/video_guide_part_3/dct.gif Penn ESE532 Spring 2017 -- DeHon 31 Y[k,m] = n 1 n 1 i=0 j =0 x[i, j] cos π m ( i + 0.5) cos π k ( j + 0.5) Penn ESE532 Spring 2017 -- DeHon 32 2D DCT Calculation fdct Decompose, like FFT Perform 1D DCT across rows O(n 3 ) n 2 results, each O(n) Perform 1D DCT across columns O(n 3 ) n 1 Y[k] = x[ j] cos π k ( j + 0.5) Y[k,m] = n 1 n 1 i=0 j =0 j =0 x[i, j] cos π m ( i + 0.5) cos π k ( j + 0.5) Penn ESE532 Spring 2017 -- DeHon 33 Penn ESE532 Spring 2017 -- DeHon 34 Quantize EXTERN unsigned char default_intra_quantizer_matrix[64] #ifdef GLOBAL = 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37, 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40, 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58, 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83 #endif Penn ESE532 Spring 2017 -- DeHon 35 Quantize EXTERN unsigned char default_intra_quantizer_matrix[64] #ifdef GLOBAL = 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37, 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40, 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58, 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83 #endif Divide by entry in quantizer matrix before change to integer Most bits to upper left Few bits to lower right More things threshold to zero Penn ESE532 Spring 2017 -- DeHon 36 6

Quantize and Precision EXTERN unsigned char default_intra_quantizer_matrix[64] #ifdef GLOBAL = 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37, 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40, 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58, 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83 #endif What does quantization mean for DCT precisions? Penn ESE532 Spring 2017 -- DeHon 37 Penn ESE532 Spring 2017 -- DeHon 38 Value Diminish to Lower Right Zig-Zag Order Groups zeros (and small constants) together at end Source: http://img.tomshardware.com/us/1999/09/24/video_guide_part_3/dct.gif Penn ESE532 Spring 2017 -- DeHon 39 Source: https://en.wikipedia.org/wiki/jpeg#/media/file:jpeg_zigzag.svg Penn ESE532 Spring 2017 -- DeHon 40 Value Diminish to Lower Right Value Diminish to Lower Right Source: http://img.tomshardware.com/us/1999/09/24/video_guide_part_3/dct.gif Source: https://en.wikipedia.org/wiki/jpeg#/media/file:jpeg_zigzag.svg Penn ESE532 Spring 2017 -- DeHon 41 45-5 12 0 0 0-4 -3 0 0 0 0 0 0 0-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0. Source: http://img.tomshardware.com/us/1999/09/24/video_guide_part_3/dct.gif Source: https://en.wikipedia.org/wiki/jpeg#/media/file:jpeg_zigzag.svg Penn ESE532 Spring 2017 -- DeHon 42 7

Preclass 3 How many numbers in the Run-Length encoding? 45-5 12 0 0 0-4 -3 0 0 0 0 0 0 0-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0. Penn ESE532 Spring 2017 -- DeHon 43 Penn ESE532 Spring 2017 -- DeHon 44 Preclass 4 How many bits to Huffman encode? Compare to 8b encoding of RLE? Penn ESE532 Spring 2017 -- DeHon 45 Penn ESE532 Spring 2017 -- DeHon 46 void putbits(val,n) Huffman mask = 1 << (n-1); /* select for (i=0; i<n; i++) Bit twiddling for outbfr <<= 1; Huffman coding if (val & mask) outbfr = 1; inefficient on wordwide processor outcnt--; mask >>= 1; /* select next if (outcnt==0) /* 8 bit bu output_buf[bytecnt] = ou outcnt = 8; bytecnt++; if (bytecnt == OUTPUT_BU error("output buffer t Penn ESE532 Spring 2017 -- DeHon 47 Penn ESE532 Spring 2017 -- DeHon 48 8

Penn ESE532 Spring 2017 -- DeHon 49 Big Ideas Compression is about exploiting (eliminating) Redundancy (lossless) Things humans don t notice much (lossy) Redundancy in video Temporal: data repeat frame-to-frame Spatial: frequency patterns Quantize: high frequencies Entropy encode values (e.g. frequencies) Penn ESE532 Spring 2017 -- DeHon 50 Admin Project and Project Analysis Milestone out Project Analysis Milestone due Friday Including teaming Penn ESE532 Spring 2017 -- DeHon 51 9