TechSmith Screen Capture Codec 2

From MultimediaWiki
Jump to: navigation, search

This codec was developed by TechSmith and used in their screen capturing products.

Frame format

This codec operates on 16x8 macroblocks.

 0 - frame type (1- coded, 0 - skip frame)
 1 - quantiser1 (0-12)
 2 - quantiser2 (0-12)
 3 - ???
 [macroblock properties]
 [macroblock slices]

Macroblock properties:

 4 bytes LE - chunk size
 rest       - RLE-coded mode in bytes in form (val << 6) | (count)

Macroblock slices begin with slice size. If the first byte is odd, then it's the full size. Otherwise read whole 32-bit word and divide it by two in order to obtain real macroblock data size.

Mode meaning: 0/3 - skip block, 1 - select quantiser1, 2 - select quantiser2

Macroblocks encode series of 4x4 DCT blocks (4x2), one component after another.

Block format:

 DC - 8 bits for the first block, or VLC (for the difference from the previous DC)
 number of AC coefficients - VLC
 [AC coefficients] - VLC, bottom 4 bits - skip value, top 8 bits - AC value

Scan order is zigzag:

 0  2  3  9
 1  4  8 10
 5  7 11 14
 6 12 13 15

Quantisation:

 Q0 Q1 Q0 Q1
 Q1 Q2 Q1 Q2
 Q0 Q1 Q0 Q1
 Q1 Q2 Q1 Q2

where

 Q0 = 4 * round(quant * 327.68)
 Q1 = 4 * round(quant / 5 * 16384 * 0.1313064328597225) // about 4 * round(quant * 430.265)
 Q2 = 4 * round(quant * 32768 * 0.1313064328597225^2 ) // about 4 * round(quant * 564.966)

Unquantising:

 val = (quant * (qval << 6) + 0x10000) >> 17

IDCT matrix:

 5  5  5  2
 5  2 -5 -5
 5 -2 -5  5
 5 -5  5 -2