yading@10
|
1 A Quick Description Of Rate Distortion Theory.
|
yading@10
|
2
|
yading@10
|
3 We want to encode a video, picture or piece of music optimally. What does
|
yading@10
|
4 "optimally" really mean? It means that we want to get the best quality at a
|
yading@10
|
5 given filesize OR we want to get the smallest filesize at a given quality
|
yading@10
|
6 (in practice, these 2 goals are usually the same).
|
yading@10
|
7
|
yading@10
|
8 Solving this directly is not practical; trying all byte sequences 1
|
yading@10
|
9 megabyte in length and selecting the "best looking" sequence will yield
|
yading@10
|
10 256^1000000 cases to try.
|
yading@10
|
11
|
yading@10
|
12 But first, a word about quality, which is also called distortion.
|
yading@10
|
13 Distortion can be quantified by almost any quality measurement one chooses.
|
yading@10
|
14 Commonly, the sum of squared differences is used but more complex methods
|
yading@10
|
15 that consider psychovisual effects can be used as well. It makes no
|
yading@10
|
16 difference in this discussion.
|
yading@10
|
17
|
yading@10
|
18
|
yading@10
|
19 First step: that rate distortion factor called lambda...
|
yading@10
|
20 Let's consider the problem of minimizing:
|
yading@10
|
21
|
yading@10
|
22 distortion + lambda*rate
|
yading@10
|
23
|
yading@10
|
24 rate is the filesize
|
yading@10
|
25 distortion is the quality
|
yading@10
|
26 lambda is a fixed value chosen as a tradeoff between quality and filesize
|
yading@10
|
27 Is this equivalent to finding the best quality for a given max
|
yading@10
|
28 filesize? The answer is yes. For each filesize limit there is some lambda
|
yading@10
|
29 factor for which minimizing above will get you the best quality (using your
|
yading@10
|
30 chosen quality measurement) at the desired (or lower) filesize.
|
yading@10
|
31
|
yading@10
|
32
|
yading@10
|
33 Second step: splitting the problem.
|
yading@10
|
34 Directly splitting the problem of finding the best quality at a given
|
yading@10
|
35 filesize is hard because we do not know how many bits from the total
|
yading@10
|
36 filesize should be allocated to each of the subproblems. But the formula
|
yading@10
|
37 from above:
|
yading@10
|
38
|
yading@10
|
39 distortion + lambda*rate
|
yading@10
|
40
|
yading@10
|
41 can be trivially split. Consider:
|
yading@10
|
42
|
yading@10
|
43 (distortion0 + distortion1) + lambda*(rate0 + rate1)
|
yading@10
|
44
|
yading@10
|
45 This creates a problem made of 2 independent subproblems. The subproblems
|
yading@10
|
46 might be 2 16x16 macroblocks in a frame of 32x16 size. To minimize:
|
yading@10
|
47
|
yading@10
|
48 (distortion0 + distortion1) + lambda*(rate0 + rate1)
|
yading@10
|
49
|
yading@10
|
50 we just have to minimize:
|
yading@10
|
51
|
yading@10
|
52 distortion0 + lambda*rate0
|
yading@10
|
53
|
yading@10
|
54 and
|
yading@10
|
55
|
yading@10
|
56 distortion1 + lambda*rate1
|
yading@10
|
57
|
yading@10
|
58 I.e, the 2 problems can be solved independently.
|
yading@10
|
59
|
yading@10
|
60 Author: Michael Niedermayer
|
yading@10
|
61 Copyright: LGPL
|