User:Orlando/XINTRA8 Decoding

From MultimediaWiki
Revision as of 21:33, 1 November 2009 by Orlando (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Reading Residual Coefficients

In order to read residual coefficients from the bitstream, you need to perform the following steps first:

  • Fill Top/Left vectors
  • Predict the meta-direction
  • Predict the extrapolation mode
  • Predict the minimum number of AC coefficient before table switch
  • Read DC
  • Read AC coefficients
  • Update meta-direction prediction (Luma blocks only)
  • Update AC coefficient count prediction (Luma blocks only)
  • Perform dequantization of the DC
  • Eventually, perform inverse lifting

Fill Top/Left vectors

TBD

Predict Meta Direction

There are three meta-directions:

 0 - NULL 
 1 - VERTICAL
 2 - HORIZONTAL

If the block is at the edge, the predicted meta-direction is known a priori.

  • If block is at (0,0), meta-direction is NULL.
  • If block is at (0,y), meta-direction is VERTICAL.
  • If block is at (x,0), meta-direction is HORIZONTAL.

Now the prediction continues depending on the block plane.

  • For Chroma blocks:
    • Get the predicted meta-direction for the Luma block at the position (x * 2, y * 2), the prediction ends.
  • For Luma blocks:
    • Get the previously predicted meta-direction from top and left blocks.
    • If the left and top meta-directions are the same, then that's the predicted meta-direction.
    • If the left meta-direction is HORIZONTAL and the top is NULL, then it's HORIZONTAL.
    • If the left meta-direction is NULL and the top is VERTICAL, then it's VERTICAL.
    • In case of horizontal continuity, where left is HORIZONTAL and top is VERTICAL, the returned prediction is HORIZONTAL which overrides VERTICAL.
    • If the left meta-direction is VERTICAL and top is HORIZONTAL:
      • For Low bitrate (QP > 12), use always the top block meta-direction.
      • Get the previously predicted top-left block meta-direction.
        • If the top-left meta-direction is equal to the top meta-direction, then predict from left.
        • If, instead, the meta-direction is equal to the left meta-direction, then predict from top.
        • In any other case, predict from top-left.
    • In any other case, the predicted meta-direction is NULL.

Reading DC

Once you have finished all the required predictions, you can perform the selection of the DC mode based on the number of the predicted AC coefficients, there are 3 DC modes:

 0 - INTRAZ  - Luma, predicted AC coefficients == 0
 1 - INTRANZ - Luma, predicted AC coefficients > 0
 2 - INTRAC0 - Chroma

Depending on the QP value, there are two more submodes, one for Low bitrate and the other for High bitrate. There are in total six different modes and each one has eight VLC tables used to read the DC level.

The encoder will transmit just once the VLC table index for the current mode. The table index is 3 bits long.

Initially, 'last', a flag that determines if there are AC coefficients following, is set to false.

The DC value is read from the VLC.

  • Values greater than 16 sets 'last' to true, subtract 17 to obtain the correct index.
  • If index is 0 then the level is zero and the function ends.
  • Get the number of DC level extra bits for the given index.
  • Set dc_level to zero.
  • If there are extra bits, read them into dc_level.
  • Add the DC level bias for the given index to dc_level.
  • Read sign-bit.