Exercise 5a: First Prediction between Transform Blocks DC Prediction - - PowerPoint PPT Presentation

exercise 5a first prediction between transform blocks
SMART_READER_LITE
LIVE PREVIEW

Exercise 5a: First Prediction between Transform Blocks DC Prediction - - PowerPoint PPT Presentation

Exercise 5a: First Prediction between Transform Blocks DC Prediction ( Goal : utilization of dependencies between blocks) Predict mean value of block using already coded and reconstructed neighboring samples reconstructed border Generation of


slide-1
SLIDE 1

Exercise 5a: First Prediction between Transform Blocks

DC Prediction (Goal: utilization of dependencies between blocks) Predict mean value of block using already coded and reconstructed neighboring samples Generation of Prediction Signal Implement a class for intra prediction with DC prediction being one method (note: we will add more prediction modes later) DC prediction: Generate prediction signal for a current block, with all samples being set to mean of left and top border samples Special cases: Only one border available: Use mean of that border No border available: Use 128 as mean value

current block

reconstructed border

Integration into Codec Encoder: Subtract prediction signal (instead of 128) before forward transform Decoder: Add prediction signal (instead of 128) after inverse transform Run simulations to check whether DC prediction improves coding efficiency

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-2
SLIDE 2

Exercise 5b: Improved Coding of Zero Levels at High-Frequency Positions

Goal: Efficient representation of zero levels for high frequency components New Concept for Coding Block of Quantization Indexes

1 coded block flag (cbf): Single bit specifying whether block includes non-zero levels 2 last position:

x and y coordinate for last non-zero position in scanning order (use diagonal scan)

3 actual levels:

  • quant. indexes in scanning order (up to last position)

Coding Coded Block Flag and X/Y Coordinates of Last Position Restrict block size to integer powers of 2 (add check in encoder) Add methods for coding cbf and x/y to EntropyEncoder and EntropyDecoder Use following code for x and y coordinates (see examples):

first bit signaling whether the coordinate is zero modified Exp-Golomb code for remainder (prefix + suffix) last bit of unary prefix part is not transmitted if it can be inferred to be equal to one (we know the maximum value = block size - 1 !) code for 4 × 4 blocks value codeword 1 1 1 2 1 0 0 3 1 0 1 code for 8 × 8 blocks value codeword 1 1 1 2 1 01 0 3 1 01 1 4 1 00 00 5 1 00 01 6 1 00 10 7 1 00 11

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-3
SLIDE 3

Exercise 5c: Modified Coding of Quantization Indexes

Goal: Improve coding efficiency for quantization indexes Prepare the integration of adaptive arithmetic coding Modified Entropy Code Modify coding of levels in EntropyEncoder and EntropyDecoder

The modified code consists of the following parts: sig flag: (new) Indicating whether levels unequal to zero gt1 flag: (new) Indicating whether abs. value is greater than one remainder: Absolute values minus 2 using Exp-Golomb code (consisting of unary prefix and fixed-length suffix) sign flag: Indicating whether level is negative

Combination with Exercise 5b For last position (indicated by x, y) we know that sig flag = 1 Do not code sig flag for last position

modified code value codeword (s = sign) ±1 1 0 s ±2 1 1 1 s ±3 1 1 01 0 s ±4 1 1 01 1 s ±5 1 1 001 00 s ±6 1 1 001 01 s ±7 1 1 001 10 s ±8 1 1 001 11 s ±9 1 1 0001 000 s ±10 1 1 0001 001 s ±11 1 1 0001 010 s ±12 1 1 0001 011 s ±13 1 1 0001 100 s ±14 1 1 0001 101 s ±15 1 1 0001 110 s ±16 1 1 0001 111 s ±17 1 1 00001 0000 s ±18 1 1 00001 0001 s · · · · · ·

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-4
SLIDE 4

Exercise 5d: Integration and Testing

Integration DC prediction (exercise 5a) Modified entropy coding

coded block flag (exercise 5b) last position (exercise 5b) levels up to last position (exercise 5c)

Testing and Evaluation Select at least 3 different test images Generate rate-PSNR curves by running codec

with different QP values {8, 12, 16, 20, 24} measure rate and PSNR (using PSNR tool)

Use different block sizes {4, 8, 16, 32} Compare curves to JPEG (see git repository)

Encoder operation per block

1 Predict block (DC) (ex. 5a) 2 Subtract prediction signal (ex. 5a) 3 Transform + Quantization 4 Entropy coding (ex. 5b, 5c)

Decoder operation per block

1 Predict block (DC) (ex. 5a) 2 Entropy decoding (ex. 5b, 5c) 3 Dequantization + Inverse transform 4 Add prediction signal (ex. 5a) 5 Clip to 8-bit range [ 0; 255 ]

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-5
SLIDE 5

Next Exercise (Outlook): Integration of Binary Arithmetic Coding

binary arithmetic encoding engine entropy encoder (codeword tables) syntax elements bins probability model index bits bitstream

Main Changes Bits of codewords are not directly written to bitstream Bins are processed by binary arithmetic coding engine (which writes final codeword) Adaptive Binary Arithmetic Coding Efficient coding of binary decisions (bins) based on associated probability models {p0, 1 − p0} Use adaptive probability models Probability p0 is updated after each coding of a bin

Need to associate each bin (bit of a codeword) with a probability model Need to maintain set of adaptive probability models (in EntropyEncoder and EntropyDecoder)

Arithmetic coder includes non-adaptive bypass mode (using probabilities p0 = p1 = 0.5)

Sufficient for rarely coded bins

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-6
SLIDE 6

Next Exercise (Outlook): Basic Interfaces of Arithmetic Encoder/Decoder

# ----- binary arithmetic encoding

  • class

ArithEncoder : # constructor : #

  • uses

class OBitstream for

  • utput

def __init__( self , bitstream ): # adaptive coding: #

  • encodes

binary decision (bin) # using specified probability model #

  • updates

probability model # based on value of bin def encode( self , bin , probModel ): # bypass coding: # (1) encodes bin in bypass mode # (2) multiple bins in bypass mode def encodeEP( self , bin ): def encodeEPs( self , pattern , numBins ): # finalization

  • f

arithmetic codeword: #

  • finalization
  • f

codeword #

  • write

remaining bits to bitstream def finalize( self ): # ----- binary arithmetic encoding

  • class

ArithDecoder : # constructor : #

  • uses

class IBitstream for input def __init__( self , bitstream ): # adaptive coding: #

  • decodes

binary decision (bin) # using specified probability model #

  • updates

probability model # based on value of decoded bin #

  • returns

value of decoded bin def decode( self , probModel ): # bypass coding: # (1) decodes bin in bypass mode #

  • returns

bin # (2) multiple bins in bypass mode #

  • returns

bin pattern def decodeEP( self ): def decodeEPs( self , numBins ):

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding

slide-7
SLIDE 7

Next Exercise (Outlook): Assignment of Probability Models

Adaptive Probability Models (8 in total)

1 coded block flag

X coordinate of last position

2 first bin (indicating whether x > 0) 3 all bins of prefix part of mod. Exp-Golomb code

Y coordinate of last position

4 first bin (indicating whether y > 0) 5 all bins of prefix part of mod. Exp-Golomb code

Values of quantization indexes

6 significance bin (indicating whether |q| > 0) 7 greater-than-1 bin (indicating whether |q| > 1) 8 all bins of prefix part of Exp-Golomb code

All other bins (suffix parts, sign) are coded in bypass mode

x/y for 4×4 blocks value codeword 1 1 1 2 1 0 0 3 1 0 1 x/y for 8×8 blocks value codeword 1 1 1 2 1 01 0 3 1 01 1 4 1 00 00 5 1 00 01 6 1 00 10 7 1 00 11 code for levels value codeword (s = sign) ±1 1 0 s ±2 1 1 1 s ±3 1 1 01 0 s ±4 1 1 01 1 s ±5 1 1 001 00 s ±6 1 1 001 01 s ±7 1 1 001 10 s ±8 1 1 001 11 s ±9 1 1 0001 000 s ±10 1 1 0001 001 s ±11 1 1 0001 010 s ±12 1 1 0001 011 s ±13 1 1 0001 100 s ±14 1 1 0001 101 s ±15 1 1 0001 110 s ±16 1 1 0001 111 s ±17 1 1 00001 0000 s ±18 1 1 00001 0001 s · · · · · ·

Heiko Schwarz (Freie Universität Berlin) — Image and Video Coding