Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Differential Encoding
C.M. LiuPerceptual Signal Processing Lab College of Computer ScienceNational Chiao-Tung University
Office: EC538(03)5731877
http://www.csie.nctu.edu.tw/~cmliu/Courses/Compression/
Idea2
Reducing the dynamic range/variance of coded sequence by encoding sample differences
Example Image Histogram3
99% ∈ [-31, 31] 5 bits/pixel (or less)
Basic Algorithm4
Consider sequence:6.2 9.7 13.2 5.9 8 7.4 4.2 1.8
Differences:6.2 3.5 3.5 −7.3 2.1 −0.6 −3.2 −2.4
Lossless encodingSimply coding the difference is sufficient to recover original
Lossy encodingQuantizer: −6 -4 -2 0 2 4 6
Quantized sequence: 6 4 4 −6 2 0 −4 −2
‘Lossless’ reconstruction: 6 10 14 8 10 10 6 4
QE: 0.2 −0.3 −0.8 −2.1 −2 −2.6 −1.8 −2.2Observation:
QE seems to grow over time—is it a coincidence?
Basic Algorithm (2)5
Consider: {xn} and dn = xn – xn-1
nnnn qddQd +== ][ˆ
001 ˆ,ˆˆˆ xxdxx nnn =+= −
011 xxd −=
1111 ][ˆ qddQd +==
11110001ˆˆ qxqdxdxx +=++=+=
122 xxd −=
2222 ][ˆ qddQd +==
212
2111212ˆˆ
qqxqdqxdxx
++=+++=+=
∑ =+=⇒
n
k knn qxx1
ˆ
Basic Algorithm (3)6
Alternative coding: 1ˆ −−= nnn xxd
011 xxd −=
1111 ][ˆ qddQd +==
11110001ˆˆ qxqdxdxx +=++=+=
122 x̂xd −=
2222 ][ˆ qddQd +==
22221212 ˆˆˆˆ qxqdxdxx +=++=+=
nnn qxx +=⇒ ˆ
Basic Algorithm: Example7
Differential Encoding Scheme8
Differential Pulse Code Modulation (DPCM)9
( )021 ˆ,,ˆ,ˆ xxxfp nnn K−−=
Prediction in DPCM10
Choice of f (·) affects σd, however
( )[ ]22nnd pxE −=σ
nnn qxx +=ˆ where qn depends on the variance of dn
Dependencies:
( ) ( )⋅→→→⋅ fxf nd ˆ2σ
Fine Quantization Assumption:Granularity is fine enough so thatThus,
nn xx ≈ˆ
( )021 ,,, xxxfp nnn K−−=
Linear Predictor11
N is caller order of the predictor∑= −=N
i inin xap1
ˆ
( ) ⎥⎦⎤⎢⎣⎡ −= ∑ = −
2
12 N
i inind xaxEσFind {ai}: minimize
( )[ ]
( )[ ] 02
02
1
2
111
2
=−−=∂∂
=−−=∂∂
−= −
−= −
∑
∑
NnN
i ininN
d
nN
i inind
xxaxEa
xxaxEa
σ
σ
M
Linear Predictor (2)12
where Rxx is the autocorrelation function:
∑
∑∑
=
=
=
=−
=−
=−
N
i xxxxi
N
i xxxxi
N
i xxxxi
NRNiRa
RiRa
RiRa
1
1
1
)()(
)2()2(
)1()1(
M
( ) [ ]knnxx xxEkR +=
Linear Predictor (3)13
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
−−
−−
=
)0()2()1(
)2()0()1()1()1()0(
xxxxxx
xxxxxx
xxxxxx
RNRNR
NRRRNRRR
R
L
MOMM
L
L
)()()(
)1(1
kRkRNR
RP
a
aA xxxx
xx
xx
n
=−⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡=
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡= MM
.1PRAPRA −=⇒=
Linear Predictor Example: Speech14
Linear Predictor Example (2)15
N = 1 a1 = 0.66N = 2 a1 = 0.596, a2 = 0.096N = 3 a1 = 0.577, a2 = -0.025, a3 = 0.204
( ) ∑ −
= +−=
kM
i kiixx xxkM
kR1
1
Linear Predictor Example: Laplacian Quantization
16
Uniform Step sizes4-level: 1st order: 0.75, 2nd order: 0.59, 3rd order: 0.438-level: 1st order: 0.3, 2nd order: 0.4, 3rd order: 0.5
( )
( )∑∑
∑∑
=
=
=
=
−=
−=
M
i ii
M
i i
M
i ii
M
i i
px
x
xx
x
12
12
12
12
)dB(SPER
ˆ)dB(SNR
Prediction Error
Linear Predictor Example: Performance17
SNR increases a lot for order 1 to order 2.
Linear Predictor Example: Reconstruction18
Original Reconstruction:8-level quantizer
Laplacian pdf3rd-order predictor
Although the reconstructed sequence looks like the original, notice that there is significant distortion in areas where the source output values are small.
Adaptive DPCM19
MotivationEven after DPCM, a lot of structure remains in the signalStructure more compression is possible
Residuals for 3rd-order predictor
Approaches Adaptive DPCM20
Adaptation can be applied toQuantizationPrediction
ObservationQuantization adaptation is independent of predictionPrediction adaptation quantization adaptation
Good prediction depends on good quantization
Adaptive Quantization in DPCM21
Forward adaptationParameters are estimated for each blockTransmitted to receiverOverall, this is inconvenient in DPCM as parameters are not explicitly available (due to feedback loop)
Backward adaptationEssentially, a version of the Jayant quantizerExample:
8-level quantizer, 3rd-order predictorM0 = 0.9, M1 = 0.9, M2 = 1.25, M3 = 1.75
Example: Adaptive Jayant DPCM22
Original
Non-adaptive
Jayant
Forward Adaptive Prediction: DPCM-APF23
Speech coding8000 sample/sec, 128 samples/block (16ms)
Image coding8x8 blocks
Autocorrelation coefficientsAssuming samples are zero outside block. l means the lth block.
)()(
0for1)(
0for,1)(
)()(
1)1(
)(
1)1(
)(
kRkR
kxxkM
kR
kxxkM
kR
lxx
lxx
lM
Mlikii
lxx
klM
Mlikii
lxx
−=
<−
=
>−
=
∑
∑
+−=+
−
−−=+ Rxx(k) can be efficiently
encoded usingpartial correlation (parcor)
coefficients
Backward Adaptive Prediction: DPCM-APB24
1st-order predictor
Adapts with sample
Replacing by to have the consistent result with decoder
1)(
11
2)(
1)1(
1 ˆ2 −+ +=
∂∂
−= nnnnnn xda
adaa αα
Nth-order predictor
jnnnn
jnnn
jn
j
d
xdaa
−+
−+
+=
−=
XAA ˆˆˆˆ
)()1(
)()1(
α
α
A.k.a. Least Mean Squared (LMS)
1)(
1)1(
1 ˆˆ−
+ += nnnn xdaa α
nd nd̂
Delta Modulation (DM)25
DM = DPCM w/ 1-bit quantizerSampling frequency
At least twice the highest frequency signal componentUsually, much higher
Linear DM Reconstruction26
Constant Factor Adaptive DM (CFDM)27
⎩⎨⎧
<−>
=0ˆif10ˆif1
n
nn d
ds⎩⎨⎧
≠Δ=Δ
=Δ−−
−−
112
111
ifif
nnn
nnnn ssM
ssM
211 21 <==< MMM
Second-Order CFDM 28
Examples for 2 samples prediction
Speech Coding29
Autocorrelation function for speech sampleIndicates a period of 47 samples
Pitch period
Need a separate component to take advantage of it
DPCM with Pitch Predictor30
Also: Noise Feedback Coding (NFC)Shaping of QE such that most falls in high-amplitude periods
periodpitch,ˆ: =− ττnp xbP
DPCM with Pitch Predictor Performance31
DPCM Residuals DPCM w/ Pitch PredictorResiduals
G.72632
ITU recommendation for standard ADPCMSupersedes G.721 & G.723Rates: 40/32/24/16 kbits/secCompression w.r.t. 8-bit PCM:1.6:1, 2:1, 2.67:1, 4:1Quantizer levels: 2nb-1
midtread quantizer
Backward adaptive quantizationA version of the Jayant quantizerDescribed in terms of a scale factor αk
Q[dk/αk] * αk
G.726 24kb Quantizer I/O Map33
G.726: Quantizer Adaptation34
Based on y(k) = log2αk
Two factors:yu unlocked—to handle large fluctuations (e.g. speech)yl locked—for small ones like data transmission.
( ) )1()(1)1()()( 11 −−+−= kykakykaky lu
a1 depend on input variance: for speech it is close to 1
[ ] [ ] [ ] 51 2,logwhere,)1()1()( −− =⋅=⋅+−−= εεε MWIWkyky ku
62),()1()1()( −=+−−= γγγ kykyky ull
G.726: Predictor35
Backward adaptable based onlast 2 reconstructed values
last 6 quantized differences
∑∑ = −−
= −− +=
6
1)1(2
1)1( ˆˆ
i ikk
ii ikk
ik dbxap
Simplified LMS:
Differential Image Coding36
Consider the predictor
… in combination with 2-bit uniform quantizer & AC1 bit/pixel encoding—compare to JPEG at the same rate
Diff coded: SNR=22dB, PSNR=31dB JPEG: SNR=33dB, PSNR=42dB
Differential Image Coding (2)37
Improved schemeRecursively indexed quantizer
Improved predictor
Diff coded: SNR=29dB, PSNR=38dB JPEG: SNR=33dB, PSNR=42dB
Remarks38
Prediction in DPCMAdaptive DPCMDelta ModulationSpeech CodingImage Coding
Homeworks39
P. 352 3, 4, 6