Introduction to Discrete Cosine Transform and Quantization

Post on 15-Jan-2016

104 views 1 download

description

Introduction to Discrete Cosine Transform and Quantization. DSP TA: Wei-Nien Chen 2007/05/09. Typical Transform coding scheme. Discrete cosine transform. Any signal= Σ cosine of various frequencise. Decompose signals into combinations of DCT basis vectors. 1-D DCT. 2-D DCT (8x8). Why DCT. - PowerPoint PPT Presentation

Transcript of Introduction to Discrete Cosine Transform and Quantization

DSP TA: Wei-Nien Chen2007/05/09

Any signal=Σcosine of various frequencise.

Decompose signals into combinations of DCT basis vectors

Energy compaction. (for further quantization)

original 1 coef. 3coef.

5 coef. 10 coef. 30coef.

Represent coefficients using less steps(fewer bits) to obtain compression.

Quantization Table: Each DCT coefficients uses different quantization step size obtained from psychophysical studies.

),(

2

),(),(),(

),(vuQ

vuQvuFsignvuF

vuFq

),(),(),( vuQvuFvuF qiq

9910310011298959272

10112012110387786449

921131048164553524

771031096856372218

6280875129221714

5669574024161314

5560582619141212

6151402416101116

),( vuQ

Quantization

Inverse Quantization

Adapted from W. J. Tsai, DTV chap2 classnote

DSP TA: Wei-Nien Chen2007/05/09

Source Efficiency Coding Effort

Compiler Optimizer

Assembly Optimizer

Hand OptimizerAssembly

Linear Assembly

C sourceFile

50-80%

90-100%

100%

Low

Med

High

Code Composer Studio (CCS)◦ Software pipeline is very important◦ Build option setting

Optimization level : File level (-o3)◦ Configurations

Release mode is faster than Debug mode (profile)

Fixed Point Operation◦ Fixed point : char, short, int, long◦ Floating point : float, double

Computation cycles with different data types

Char8-bit

Short16-bit

Int32-bit

Long40-bit

Float32-bit

Double64-bit

Add 1 1 1 2 77 146

Mul 2 2 6 8 54 69

Use Intrinsic Function (spru198i) Packet Data Processing Change int type to char, short type

◦ Put 2 “16-bit” data or 4 “8-bit” data in a 32-bit space

◦ Single instruction multiple data (SIMD) (intrinsic)

int

short

char

short

char char char

32 bitsA1 (short) A2 (short)

B1 (short) B2 (short)

+

=

A1+B1 A2+B2

SIMD

Loop unrolling◦ Break the branch barrier◦ Trade off between performance and code size◦ #pragma MUST_ITERATE(min, max, multiple), ◦ #pragma UNROLL(n)

Loop order#pragma MUST_ITERATE(10)For (i=0;i<N;i++){ ……..}

Slower

Faster

TI has provided several optimized function for programmer’s, such as FIR, IIR, FFT, DCT, etc. (spru023b)

Include libraries and use it!! Be ware of data type!!

Library location:\CCStudio3\c6400\dsplib\lib\dsp64x.lib\CCStudio3\c6400\imglib\lib\img64x.lib

Memory Management is important◦ Designer’s Responsibility

Memory Load/Store is critical◦ 80% time for load/store

Linker Command File (*.cmd)◦ Allocate memory

MEMORY{ ISRAM: o = 0x00000000 l = 0x00040000 SDRAM: o = 0x80000000 l = 0x08000000}SECTIONS{ .text > ISRAM //Code .cinit > ISRAM //Initial values for global/static variables .stack > ISRAM //Stack (local variables) .const > ISRAM //Global and static string literals .switch > ISRAM //Tables for switch instructions .cio > ISRAM //Buffers for studio functions .bss > ISRAM //Global and static variables .far > ISRAM //Global and static declared far .sysmem > SDRAM //Memory for malloc functions (heap) .mycode > ISRAM .mydata > ISRAM} -stack 0x1F74-heap 0x500000

#pragma CODE_SECTION(function_name,”mycode”)

#pragma DATA_SECTION(array_name,”mydata”)

Enhanced Direct Memory Access (EDMA) DSP/BIOS Cache

Tools that help you:Compiler consultantOptimization tools: cache tune/code size tune