pvq_encoding.lyx 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. #LyX 2.0 created this file. For more info see http://www.lyx.org/
  2. \lyxformat 413
  3. \begin_document
  4. \begin_header
  5. \textclass article
  6. \use_default_options true
  7. \maintain_unincluded_children false
  8. \language english
  9. \language_package default
  10. \inputencoding auto
  11. \fontencoding global
  12. \font_roman default
  13. \font_sans default
  14. \font_typewriter default
  15. \font_default_family default
  16. \use_non_tex_fonts false
  17. \font_sc false
  18. \font_osf false
  19. \font_sf_scale 100
  20. \font_tt_scale 100
  21. \graphics default
  22. \default_output_format default
  23. \output_sync 0
  24. \bibtex_command default
  25. \index_command default
  26. \paperfontsize default
  27. \use_hyperref false
  28. \papersize default
  29. \use_geometry false
  30. \use_amsmath 1
  31. \use_esint 1
  32. \use_mhchem 1
  33. \use_mathdots 1
  34. \cite_engine basic
  35. \use_bibtopic false
  36. \use_indices false
  37. \paperorientation portrait
  38. \suppress_date false
  39. \use_refstyle 1
  40. \index Index
  41. \shortcut idx
  42. \color #008000
  43. \end_index
  44. \secnumdepth 3
  45. \tocdepth 3
  46. \paragraph_separation indent
  47. \paragraph_indentation default
  48. \quotes_language english
  49. \papercolumns 1
  50. \papersides 1
  51. \paperpagestyle default
  52. \tracking_changes false
  53. \output_changes false
  54. \html_math_output 0
  55. \html_css_as_file 0
  56. \html_be_strict false
  57. \end_header
  58. \begin_body
  59. \begin_layout Title
  60. PVQ Encoding with Non-Uniform Distribution
  61. \end_layout
  62. \begin_layout Section
  63. Introduction
  64. \end_layout
  65. \begin_layout Section
  66. PVQ Codebook
  67. \end_layout
  68. \begin_layout Standard
  69. The PVQ codebook is defined
  70. \end_layout
  71. \begin_layout Standard
  72. \begin_inset Formula
  73. \[
  74. S\left(N,K\right)=\left\{ \mathbf{y}\in\mathbb{Z^{N}}:\sum_{i=0}^{N-1}\left|y_{i}\right|=K\right\} \ ,
  75. \]
  76. \end_inset
  77. the set of all integer vectors in
  78. \begin_inset Formula $N$
  79. \end_inset
  80. dimensions for which the sum of absolute values equals
  81. \begin_inset Formula $K$
  82. \end_inset
  83. .
  84. When all codevectors are considered to have equal probability, several
  85. methods
  86. \begin_inset CommandInset citation
  87. LatexCommand cite
  88. key "Fischer,FPC"
  89. \end_inset
  90. exist to convert between any codevector and an index
  91. \begin_inset Formula $J$
  92. \end_inset
  93. in the range
  94. \begin_inset Formula $[0,\, V(N,K)-1]$
  95. \end_inset
  96. , where
  97. \begin_inset Formula $V(N,K)$
  98. \end_inset
  99. is the number of elements in
  100. \begin_inset Formula $S(N,K)$
  101. \end_inset
  102. .
  103. The index is then easily coded in a bit-stream, possibly with the use of
  104. a range coder
  105. \begin_inset CommandInset citation
  106. LatexCommand cite
  107. key "RFC6716"
  108. \end_inset
  109. to allow for fractional bits since
  110. \begin_inset Formula $V(N,K)$
  111. \end_inset
  112. is generally not a power of two.
  113. \end_layout
  114. \begin_layout Section
  115. Non-Uniform Distribution
  116. \end_layout
  117. \begin_layout Standard
  118. When the codevectors do not have a uniform probability distribution, it
  119. becomes necessary to build a probability model.
  120. For any codebook of reasonable size, modelling the distribution of
  121. \begin_inset Formula $J$
  122. \end_inset
  123. itself is impractical.
  124. Instead, we parametric models for the distribution of
  125. \begin_inset Formula $\left|y_{i}\right|$
  126. \end_inset
  127. as a function of
  128. \begin_inset Formula $i$
  129. \end_inset
  130. .
  131. \end_layout
  132. \begin_layout Subsection
  133. Coefficient Model
  134. \end_layout
  135. \begin_layout Standard
  136. \begin_inset CommandInset label
  137. LatexCommand label
  138. name "sub:Coefficient-model"
  139. \end_inset
  140. A first model is based on the expected absolute value of the coefficient
  141. \begin_inset Formula $i$
  142. \end_inset
  143. \end_layout
  144. \begin_layout Standard
  145. \begin_inset Formula
  146. \[
  147. \sigma_{i}=E\left\{ \left|y_{i}\right|\right\} =\sum_{k=0}^{\infty}p_{i}(k)\ ,
  148. \]
  149. \end_inset
  150. where
  151. \begin_inset Formula $p_{i}\left(k\right)$
  152. \end_inset
  153. is the probability that
  154. \begin_inset Formula $\left|y_{i}\right|=k$
  155. \end_inset
  156. .
  157. We assume that
  158. \begin_inset Formula $y$
  159. \end_inset
  160. is the result of quantizing
  161. \begin_inset Formula $x$
  162. \end_inset
  163. to the nearest integer, where
  164. \begin_inset Formula $x$
  165. \end_inset
  166. follows a Laplace distribution
  167. \begin_inset Formula
  168. \[
  169. p\left(x\right)=r^{-\left|x\right|}\ .
  170. \]
  171. \end_inset
  172. Assuming the positive quantization thresholds are
  173. \begin_inset Formula $\theta+k,\, k\in\mathbb{N}$
  174. \end_inset
  175. , we have
  176. \begin_inset Formula
  177. \[
  178. p\left(k\right)=\left\{ \begin{array}{ll}
  179. 1-r^{\theta} & ,k=0\\
  180. r^{\theta}\left(1-r\right)r^{k-1}\quad & ,k\neq0
  181. \end{array}\right.\ .
  182. \]
  183. \end_inset
  184. The value of
  185. \begin_inset Formula $r$
  186. \end_inset
  187. is obtained by modelling
  188. \begin_inset Formula $\sigma_{i}$
  189. \end_inset
  190. .
  191. By assuming
  192. \begin_inset Formula $\theta=1$
  193. \end_inset
  194. , we can have a simple relation for
  195. \begin_inset Formula $r$
  196. \end_inset
  197. \begin_inset Formula
  198. \begin{equation}
  199. r=\frac{\sigma_{i}}{1+\sigma_{i}}\ .\label{eq:r-vs-sigma}
  200. \end{equation}
  201. \end_inset
  202. We can still use a more typical
  203. \begin_inset Formula $\theta=1/2$
  204. \end_inset
  205. to model
  206. \begin_inset Formula $p\left(k\right)$
  207. \end_inset
  208. itself, in which case
  209. \begin_inset CommandInset ref
  210. LatexCommand eqref
  211. reference "eq:r-vs-sigma"
  212. \end_inset
  213. becomes an approximation.
  214. \end_layout
  215. \begin_layout Standard
  216. If all values
  217. \begin_inset Formula $y_{i}$
  218. \end_inset
  219. are identically distributed, then all expectiations
  220. \begin_inset Formula $\sigma_{i}$
  221. \end_inset
  222. are equal and simply
  223. \begin_inset Formula $\sigma_{i}=K/N$
  224. \end_inset
  225. .
  226. In practice, we assume that the values
  227. \begin_inset Formula $y_{i}$
  228. \end_inset
  229. are in decreasing order of expected value and make the approximation
  230. \begin_inset Formula
  231. \[
  232. \sigma_{0}=\alpha K/N
  233. \]
  234. \end_inset
  235. where
  236. \begin_inset Formula $\alpha$
  237. \end_inset
  238. represents how uneven the distributions are (
  239. \begin_inset Formula $\alpha=1$
  240. \end_inset
  241. corresponds to ideical distributions).
  242. Knowing
  243. \begin_inset Formula $\alpha$
  244. \end_inset
  245. , we can obtain
  246. \begin_inset Formula $\sigma_{0}$
  247. \end_inset
  248. ,
  249. \begin_inset Formula $r_{0}$
  250. \end_inset
  251. and thus
  252. \begin_inset Formula $p_{0}\left(k\right)$
  253. \end_inset
  254. , making it possible to encode (and decode using the same process)
  255. \begin_inset Formula $y_{0}$
  256. \end_inset
  257. .
  258. Knowing the value of
  259. \begin_inset Formula $y_{0}$
  260. \end_inset
  261. , we can encode
  262. \begin_inset Formula $y_{1}$
  263. \end_inset
  264. using
  265. \begin_inset Formula
  266. \begin{align*}
  267. N^{\left(1\right)} & =N-1\\
  268. K^{\left(1\right)} & =K-\left|y_{0}\right|\ .
  269. \end{align*}
  270. \end_inset
  271. The process can be applied recursively until
  272. \begin_inset Formula $K=0$
  273. \end_inset
  274. or
  275. \begin_inset Formula $N=1$
  276. \end_inset
  277. .
  278. The coefficient
  279. \begin_inset Formula $\alpha$
  280. \end_inset
  281. is assumed constant and adapted based on the data being encoded.
  282. \end_layout
  283. \begin_layout Standard
  284. The total number of symbols coded with this approach is equal to the position
  285. \begin_inset Formula $i_{last}$
  286. \end_inset
  287. of the last non-zero component of
  288. \begin_inset Formula $\mathbf{y}$
  289. \end_inset
  290. .
  291. \end_layout
  292. \begin_layout Subsection
  293. Run-Length Model
  294. \end_layout
  295. \begin_layout Standard
  296. For long sparse vectors, the method in Section
  297. \begin_inset CommandInset ref
  298. LatexCommand ref
  299. reference "sub:Coefficient-model"
  300. \end_inset
  301. is inefficient in terms of symbols coded.
  302. In those cases we propose modelling
  303. \begin_inset Formula $q(n)$
  304. \end_inset
  305. , the probability of
  306. \begin_inset Formula $y_{n}$
  307. \end_inset
  308. being the first non-zero coefficient in
  309. \begin_inset Formula $\mathbf{y}$
  310. \end_inset
  311. , as an exponential distribution
  312. \begin_inset Formula
  313. \[
  314. q(n)=r^{-n}\ .
  315. \]
  316. \end_inset
  317. We then model the expected value of
  318. \begin_inset Formula $q(n)$
  319. \end_inset
  320. as
  321. \begin_inset Formula
  322. \[
  323. E\left[q\left(n\right)\right]=\beta\cdot\frac{N}{K}\ ,
  324. \]
  325. \end_inset
  326. where
  327. \begin_inset Formula $\beta=1$
  328. \end_inset
  329. represents the case where non-zero coefficients are distributed evenly
  330. in the vector (typically,
  331. \begin_inset Formula $\beta<1$
  332. \end_inset
  333. ).
  334. Once the position
  335. \begin_inset Formula $n$
  336. \end_inset
  337. of the first non-zero coefficient is coded, one pulse is subtracted from
  338. that position and the process is restarted with
  339. \begin_inset Formula
  340. \begin{align*}
  341. N^{(1)} & =N-n\\
  342. K^{(1)} & =K-1\ .
  343. \end{align*}
  344. \end_inset
  345. If multiple pulses are present at a certain position, then we encode a position
  346. of zero for each pulse that follows the first pulse.
  347. \end_layout
  348. \begin_layout Standard
  349. Because the sign is fixed once a pulse is already present at a certain
  350. position, the probability of adding a pulse is divided by two.
  351. The distribution then becomes
  352. \begin_inset Formula
  353. \[
  354. q(n)=\left\{ \begin{array}{ll}
  355. 1/2\quad & ,\ n=0\\
  356. r^{-n} & ,\ n\neq0
  357. \end{array}\right..
  358. \]
  359. \end_inset
  360. \end_layout
  361. \begin_layout Subsection
  362. Coding K
  363. \end_layout
  364. \begin_layout Standard
  365. In soem contexts, the value of
  366. \begin_inset Formula $K$
  367. \end_inset
  368. will already be known
  369. \end_layout
  370. \begin_layout Section
  371. Conclusion
  372. \end_layout
  373. \begin_layout Bibliography
  374. \begin_inset CommandInset bibitem
  375. LatexCommand bibitem
  376. key "Fischer"
  377. \end_inset
  378. Fischer
  379. \end_layout
  380. \begin_layout Bibliography
  381. \begin_inset CommandInset bibitem
  382. LatexCommand bibitem
  383. key "FPC"
  384. \end_inset
  385. Factorial pulse coding
  386. \end_layout
  387. \begin_layout Bibliography
  388. \begin_inset CommandInset bibitem
  389. LatexCommand bibitem
  390. key "RFC6716"
  391. \end_inset
  392. Valin, J.-M., Vos.
  393. K., Terriberry, T.B., Definition of the Opus codec, RFC 6716, Internet Engineering
  394. Task Force, 2012.
  395. \end_layout
  396. \end_body
  397. \end_document