User:Orlando/XINTRA8 Decoding: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 2: Line 2:


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


* Fill Top/Left vectors
* Fill Top/Left vectors
* Predict the meta-direction
* Predict the meta-direction
* Predict the extrapolation mode
* Predict the extrapolation mode and differential rank order
* Predict the minimum number of AC coefficient before table switch
* Predict the minimum number of AC coefficient before table switch
* Read DC  
* Read DC  
Line 15: Line 15:
* Eventually, perform inverse lifting
* Eventually, perform inverse lifting


== Fill Top/Left vectors ==  
=== Fill Top/Left vectors ===


TBD
TBD


== Predict Meta Direction ==
=== Predict Meta Direction ===
   
 
There are three meta-directions:
There are three meta-directions:
        
        
Line 46: Line 46:
** In case of horizontal continuity, where left is HORIZONTAL and top is VERTICAL, the returned prediction is HORIZONTAL which overrides 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:
** If the left meta-direction is VERTICAL and top is HORIZONTAL:
*** For Low bitrate (QP > 12), use always the top block meta-direction.
*** For low bitrate (QP > 12), use always the top block meta-direction.
*** Get the previously predicted top-left block meta-direction.
*** For high bitrate, 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 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.
**** If, instead, the meta-direction is equal to the left meta-direction, then predict from top.
Line 53: Line 53:
** In any other case, the predicted meta-direction is NULL.
** In any other case, the predicted meta-direction is NULL.


== Reading DC ==
=== Predict Extrapolation Mode and Differential Rank Order ===
 
There are 13 different extrapolation modes (or orientations
if you prefer), the known ones are:
 
  0 - NULL
  4 - VERTICAL
  8 - HORIZONTAL
10 - BLENDED HORIZONTALLY
11 - BLENDED VERTICALLY
    - FLAT


Once you have finished all the required predictions, you can
Modes 1-3,5-7,9 are diagonals of ~22.5 degrees, while
FLAT mode has no mode index associated, and is signalled
when certain conditions are met.
 
Algorithm:
 
* Initially, the predicted extrapolation mode is set to NULL, likewise the differential rank order.
* If the ''pixel range'' is less than the QP or less than 3, consider the predicted meta-direction as NULL and if range is less than 3, the FLAT mode is signalled.
 
* For Chroma blocks:
** The meta-direction needs to be mapped to its extrapolation mode counter part.
 
* For Luma blocks:
** If the aforementioned range is smaller than 2QP:
*** If block is at the edge for non-FLAT mode, extrapolation mode is predicted to NULL.
*** If the block is not at the edge of the picture, then HORIZONTAL meta-direction maps into BLENDED HORIZONTALLY, while for VERTICAL meta-direction maps into BLENDED VERTICALLY.
*** In any other case the meta-direction is the predicted extrapolation mode.
** Otherwise:
*** Read the differential rank order, which happens to be also the rank order index.
*** The predicted extrapolation mode is taken from the Rank Order table for the known meta-direction.
 
=== Reading DC ===
 
Once finished all the required predictions, you can
perform the selection of the DC mode based on the number of
perform the selection of the DC mode based on the number of
the predicted AC coefficients, there are 3 DC modes:
the predicted AC coefficients, there are 3 DC modes:
Line 71: Line 104:
for the current mode. The table index is 3 bits long.
for the current mode. The table index is 3 bits long.


Initially, 'last', a flag that determines if there
* The DC value is read from the VLC reader.
are AC coefficients following, is set to false.
* Values greater than 16 signals that there are no AC coefficients encoded, subtract 17 to obtain the correct index.
 
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.
* 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.
* Get the number of DC level extra bits for the given index.
* Set dc_level to zero.
* Set DC level to zero.
* If there are extra bits, read them into dc_level.
* If there are extra bits, read them as the DC level.
* Add the DC level bias for the given index to dc_level.
* Add the DC level bias for the given index to the DC level.
* Read sign-bit.
* Read sign bit.

Revision as of 22:20, 1 November 2009

Reading Residual Coefficients

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

  • Fill Top/Left vectors
  • Predict the meta-direction
  • Predict the extrapolation mode and differential rank order
  • 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.
      • For high bitrate, 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.

Predict Extrapolation Mode and Differential Rank Order

There are 13 different extrapolation modes (or orientations if you prefer), the known ones are:

 0 - NULL
 4 - VERTICAL
 8 - HORIZONTAL
10 - BLENDED HORIZONTALLY
11 - BLENDED VERTICALLY
   - FLAT

Modes 1-3,5-7,9 are diagonals of ~22.5 degrees, while FLAT mode has no mode index associated, and is signalled when certain conditions are met.

Algorithm:

  • Initially, the predicted extrapolation mode is set to NULL, likewise the differential rank order.
  • If the pixel range is less than the QP or less than 3, consider the predicted meta-direction as NULL and if range is less than 3, the FLAT mode is signalled.
  • For Chroma blocks:
    • The meta-direction needs to be mapped to its extrapolation mode counter part.
  • For Luma blocks:
    • If the aforementioned range is smaller than 2QP:
      • If block is at the edge for non-FLAT mode, extrapolation mode is predicted to NULL.
      • If the block is not at the edge of the picture, then HORIZONTAL meta-direction maps into BLENDED HORIZONTALLY, while for VERTICAL meta-direction maps into BLENDED VERTICALLY.
      • In any other case the meta-direction is the predicted extrapolation mode.
    • Otherwise:
      • Read the differential rank order, which happens to be also the rank order index.
      • The predicted extrapolation mode is taken from the Rank Order table for the known meta-direction.

Reading DC

Once 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.

  • The DC value is read from the VLC reader.
  • Values greater than 16 signals that there are no AC coefficients encoded, 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 as the DC level.
  • Add the DC level bias for the given index to the DC level.
  • Read sign bit.