rate_distortion.txt 2.1 KB

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