# [BoW] r19 - trunk/video_coding/bink_video.tex

kostya subversion at mplayerhq.hu
Sun Dec 27 12:52:18 CET 2009

Author: kostya
Date: Sun Dec 27 12:52:17 2009
New Revision: 19

Log:
Since no work is done on this book, leave some notes about Bink video

trunk/video_coding/bink_video.tex

==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/video_coding/bink_video.tex	Sun Dec 27 12:52:17 2009	(r19)
@@ -0,0 +1,47 @@
+\subsection{Bink Video}
+
+ One of the most used (if not the most) game video codecs is Bink.
+
+ \subsubsection{Data coding}
+
+  Bink employs several coding techniques which are hard to find elsewhere:
+
+  \begin{itemize}
+
+   \item
+    Use of 16 static Huffman trees with symbol mapping coded similar to selection or merge sort.
+
+   \item
+    Byte values are represented by two nibbles, high nibble may be context-dependent, i.e. it is read with one of sixteen trees selected by value of the previous high nibble read.
+
+   \item
+    Storing data in bundles (some other game video codecs like Truemotion 2 also use that), each bundle contains data for one or several rows of blocks.
+
+  \end{itemize}
+
+ \subsubsection{Block coding}
+
+  Bink operates on 8x8 blocks in planar YUV420.
+  Block coding in Bink also shows several peculiarities, such as:
+
+  \begin{itemize}
+   \item
+    Unlike other codecs employing block partitioning, Bink may have 16x16 block placed on even and odd row.
+    Also this block is coded as an ordinary 8x8 intra or skip block with its contents scaled twice.
+
+   \item
+    While Smacker used plain vector quantisation, Bink employs three different techniques.
+    There is still vector quantisation employed, but now it's only for one or two colours.
+    Another technique is employing DCT (specially modified though and with custom quantisation matrices) for coding intra blocks and inter blocks residues.
+    Coefficient coding for DCT is non-trivial too and will be presented below.
+    Third method is the most interesting one --- there are 16 custom scan orders and block is filled with runs of colours in that order.
+% TODO: insert some Bink scan images
+
+  \end{itemize}
+
+  There are two other things worth mentioning, DCT coefficient coding method and simple block residue coding methods.
+  They are quite similar and differ by two things: DCT coefficients are read fully and iterations continue to the least significant bit, residue elements are coded as a set of masks (i.e. {\tt 0x80 $\pm$ 0x20 $\pm$ 0x01}) and iterations continue until given number of masks are decoded.
+  Decoding is performed from MSB to LSB.
+
+  Coding iteration may be represented as traversing through a list of {\tt (coeff;~action)} pairs with such actions possible: insert more entries into the list, change existing entry, delete current list entry or decode coefficient at list offset.
+  To skip certain list entries or alter action execution bits are used.