cabac.c File Reference

CABAC entropy coding routines. More...

#include "global.h"
#include "cabac.h"
#include "memalloc.h"
#include "elements.h"
#include "image.h"
#include "biaridecod.h"
#include "mb_access.h"
#include "vlc.h"

Include dependency graph for cabac.c:

Go to the source code of this file.

Functions

static unsigned int unary_bin_decode (DecodingEnvironmentPtr dep_dp, BiContextTypePtr ctx, int ctx_offset)
static unsigned int unary_bin_max_decode (DecodingEnvironmentPtr dep_dp, BiContextTypePtr ctx, int ctx_offset, unsigned int max_symbol)
static unsigned int unary_exp_golomb_level_decode (DecodingEnvironmentPtr dep_dp, BiContextTypePtr ctx)
static unsigned int unary_exp_golomb_mv_decode (DecodingEnvironmentPtr dep_dp, BiContextTypePtr ctx, unsigned int max_bin)
void CheckAvailabilityOfNeighborsCABAC (Macroblock *currMB)
void cabac_new_slice (Slice *currSlice)
MotionInfoContexts * create_contexts_MotionInfo (void)
TextureInfoContexts * create_contexts_TextureInfo (void)
void delete_contexts_MotionInfo (MotionInfoContexts *deco_ctx)
void delete_contexts_TextureInfo (TextureInfoContexts *deco_ctx)
void readFieldModeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
int check_next_mb_and_get_field_mode_CABAC (Slice *currSlice, SyntaxElement *se, DataPartition *act_dp)
void readMVD_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readB8_typeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readMB_skip_flagInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readMB_transform_size_flag_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readMB_typeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readIntraPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readRefFrame_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readDquant_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readCBP_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
void readCIPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
int read_and_store_CBP_block_bit_444 (Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int type)
int read_and_store_CBP_block_bit_normal (Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int type)
int read_significance_map (Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int type, int coeff[])
void read_significant_coefficients (DecodingEnvironmentPtr dep_dp, TextureInfoContexts *tex_ctx, int type, int coeff[])
void readRunLevel_CABAC (Macroblock *currMB, SyntaxElement *se, DecodingEnvironmentPtr dep_dp)
int readSyntaxElement_CABAC (SyntaxElement *se, ImageParameters *p_Img, DataPartition *this_dataPart)
int cabac_startcode_follows (Slice *currSlice, int eos_bit)
unsigned int exp_golomb_decode_eq_prob (DecodingEnvironmentPtr dep_dp, int k)
void readIPCM_CABAC (Slice *currSlice, struct datapartition *dP)

Variables

static const int maxpos [] = {15, 14, 63, 31, 31, 15, 3, 14, 7, 15, 15, 14, 63, 31, 31, 15, 15, 14, 63, 31, 31, 15}
static const int c1isdc [] = { 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1}
static const int type2ctx_bcbp [] = { 0, 1, 2, 3, 3, 4, 5, 6, 5, 5, 10, 11, 12, 13, 13, 14, 16, 17, 18, 19, 19, 20}
static const int type2ctx_map [] = { 0, 1, 2, 3, 4, 5, 6, 7, 6, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
static const int type2ctx_last [] = { 0, 1, 2, 3, 4, 5, 6, 7, 6, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
static const int type2ctx_one [] = { 0, 1, 2, 3, 3, 4, 5, 6, 5, 5, 10, 11, 12, 13, 13, 14, 16, 17, 18, 19, 19, 20}
static const int type2ctx_abs [] = { 0, 1, 2, 3, 3, 4, 5, 6, 5, 5, 10, 11, 12, 13, 13, 14, 16, 17, 18, 19, 19, 20}
static const int max_c2 [] = { 4, 4, 4, 4, 4, 4, 3, 4, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}
static const byte pos2ctx_map8x8 []
static const byte pos2ctx_map8x4 []
static const byte pos2ctx_map4x4 [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14}
static const byte pos2ctx_map2x4c [] = { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
static const byte pos2ctx_map4x4c [] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}
static const bytepos2ctx_map []
static const byte pos2ctx_map8x8i []
static const byte pos2ctx_map8x4i []
static const byte pos2ctx_map4x8i []
static const bytepos2ctx_map_int []
static const byte pos2ctx_last8x8 []
static const byte pos2ctx_last8x4 []
static const byte pos2ctx_last4x4 [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
static const byte pos2ctx_last2x4c [] = { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
static const byte pos2ctx_last4x4c [] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}
static const bytepos2ctx_last []


Detailed Description

CABAC entropy coding routines.

Author:
Main contributors (see contributors.h for copyright, address and affiliation details)

Definition in file cabac.c.


Function Documentation

int cabac_startcode_follows ( Slice currSlice,
int  eos_bit 
)

finding end of a slice in case this is not the end of a frame

Unsure whether the "correction" below actually solves an off-by-one problem or whether it introduces one in some cases :-( Anyway, with this change the bit stream format works with CABAC again. StW, 8.7.02

Definition at line 1756 of file cabac.c.

References assignSE2partition, biari_decode_final(), slice::dp_mode, and slice::partArr.

Here is the call graph for this function:

MotionInfoContexts* create_contexts_MotionInfo ( void   ) 

Allocation of contexts models for the motion info used for arithmetic decoding.

Definition at line 77 of file cabac.c.

References no_mem_exit().

Referenced by malloc_slice().

Here is the call graph for this function:

TextureInfoContexts* create_contexts_TextureInfo ( void   ) 

Allocates of contexts models for the texture info used for arithmetic decoding.

Definition at line 96 of file cabac.c.

References no_mem_exit().

Referenced by malloc_slice().

Here is the call graph for this function:

void delete_contexts_MotionInfo ( MotionInfoContexts *  deco_ctx  ) 

Frees the memory of the contexts models used for arithmetic decoding of the motion info.

Definition at line 115 of file cabac.c.

Referenced by free_slice().

void delete_contexts_TextureInfo ( TextureInfoContexts *  deco_ctx  ) 

Frees the memory of the contexts models used for arithmetic decoding of the texture info.

Definition at line 131 of file cabac.c.

Referenced by free_slice().

unsigned int exp_golomb_decode_eq_prob ( DecodingEnvironmentPtr  dep_dp,
int  k 
)

Exp Golomb binarization and decoding of a symbol with prob. of 0.5.

Definition at line 1788 of file cabac.c.

References biari_decode_symbol_eq_prob().

Referenced by unary_exp_golomb_level_decode(), and unary_exp_golomb_mv_decode().

Here is the call graph for this function:

int read_and_store_CBP_block_bit_444 ( Macroblock currMB,
DecodingEnvironmentPtr  dep_dp,
int  type 
)

Read CBP4-BIT.

Definition at line 1087 of file cabac.c.

References biari_decode_symbol(), get4x4Neighbour(), macroblock::p_Img, macroblock::p_Slice, slice::tex_ctx, and YUV444.

Referenced by readRunLevel_CABAC().

Here is the call graph for this function:

int read_and_store_CBP_block_bit_normal ( Macroblock currMB,
DecodingEnvironmentPtr  dep_dp,
int  type 
)

Read CBP4-BIT.

Definition at line 1321 of file cabac.c.

References biari_decode_symbol(), get4x4Neighbour(), macroblock::p_Img, macroblock::p_Slice, and slice::tex_ctx.

Referenced by readRunLevel_CABAC().

Here is the call graph for this function:

int read_significance_map ( Macroblock currMB,
DecodingEnvironmentPtr  dep_dp,
int  type,
int  coeff[] 
)

Read Significance MAP.

Definition at line 1495 of file cabac.c.

References biari_decode_symbol(), macroblock::p_Img, macroblock::p_Slice, and slice::tex_ctx.

Referenced by readRunLevel_CABAC().

Here is the call graph for this function:

void read_significant_coefficients ( DecodingEnvironmentPtr  dep_dp,
TextureInfoContexts *  tex_ctx,
int  type,
int  coeff[] 
)

Read Levels.

Definition at line 1560 of file cabac.c.

References biari_decode_symbol(), biari_decode_symbol_eq_prob(), and unary_exp_golomb_level_decode().

Referenced by readRunLevel_CABAC().

Here is the call graph for this function:

void readB8_typeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the 8x8 block type.

Definition at line 337 of file cabac.c.

References biari_decode_symbol(), slice::mot_ctx, macroblock::p_Slice, slice::slice_type, and syntaxelement::value1.

Referenced by read_one_macroblock_b_slice(), and read_one_macroblock_p_slice().

Here is the call graph for this function:

void readCBP_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the coded block pattern of a given MB.

Definition at line 909 of file cabac.c.

References biari_decode_symbol(), get4x4Neighbour(), macroblock::mb_left, macroblock::mb_up, macroblock::p_Img, macroblock::p_Slice, slice::tex_ctx, syntaxelement::value1, YUV400, and YUV444.

Referenced by read_CBP_and_coeffs_from_NAL_CABAC().

Here is the call graph for this function:

void readCIPredMode_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the chroma intra prediction mode of a given MB.

Definition at line 1043 of file cabac.c.

References biari_decode_symbol(), macroblock::c_ipred_mode, macroblock::mb_left, macroblock::mb_up, macroblock::p_Slice, slice::tex_ctx, unary_bin_max_decode(), and syntaxelement::value1.

Referenced by read_ipred_modes().

Here is the call graph for this function:

void readDquant_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the delta qp of a given MB.

Definition at line 874 of file cabac.c.

References biari_decode_symbol(), slice::mot_ctx, macroblock::p_Slice, unary_bin_decode(), and syntaxelement::value1.

Here is the call graph for this function:

void readIntraPredMode_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode a pair of intra prediction modes of a given MB.

Definition at line 765 of file cabac.c.

References biari_decode_symbol(), macroblock::p_Slice, slice::tex_ctx, and syntaxelement::value1.

Referenced by read_ipred_modes().

Here is the call graph for this function:

void readIPCM_CABAC ( Slice currSlice,
struct datapartition dP 
)

Read I_PCM macroblock.

Definition at line 1896 of file cabac.c.

References Bitstream::bitstream_length, GetBits(), Bitstream::streamBuffer, and YUV400.

Referenced by read_IPCM_coeffs_from_NAL().

Here is the call graph for this function:

void readMB_skip_flagInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the macroblock type info of a given MB.

Definition at line 421 of file cabac.c.

References biari_decode_symbol(), macroblock::mb_left, macroblock::mb_up, slice::mot_ctx, macroblock::p_Slice, slice::slice_type, syntaxelement::value1, and syntaxelement::value2.

Referenced by read_one_macroblock_b_slice(), and read_one_macroblock_p_slice().

Here is the call graph for this function:

void readMB_transform_size_flag_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the macroblock intra_pred_size flag info of a given MB.

Definition at line 470 of file cabac.c.

References biari_decode_symbol(), macroblock::mb_left, macroblock::mb_up, macroblock::p_Slice, slice::tex_ctx, and syntaxelement::value1.

Referenced by read_CBP_and_coeffs_from_NAL_CABAC(), read_CBP_and_coeffs_from_NAL_CAVLC(), read_one_macroblock_b_slice(), read_one_macroblock_i_slice(), and read_one_macroblock_p_slice().

Here is the call graph for this function:

void readMB_typeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the macroblock type info of a given MB.

Definition at line 499 of file cabac.c.

References biari_decode_final(), biari_decode_symbol(), syntaxelement::context, macroblock::mb_left, macroblock::mb_up, slice::mot_ctx, macroblock::p_Slice, slice::slice_type, and syntaxelement::value1.

Referenced by read_one_macroblock_b_slice(), read_one_macroblock_i_slice(), and read_one_macroblock_p_slice().

Here is the call graph for this function:

void readMVD_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the motion vector data of a B-frame MB.

Definition at line 252 of file cabac.c.

References biari_decode_symbol(), biari_decode_symbol_eq_prob(), syntaxelement::context, get4x4Neighbour(), slice::mot_ctx, macroblock::p_Img, macroblock::p_Slice, unary_exp_golomb_mv_decode(), syntaxelement::value1, and syntaxelement::value2.

Referenced by read_motion_info_from_NAL_b_slice(), and read_motion_info_from_NAL_p_slice().

Here is the call graph for this function:

void readRefFrame_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

This function is used to arithmetically decode the reference parameter of a given MB.

Definition at line 799 of file cabac.c.

References biari_decode_symbol(), syntaxelement::context, get4x4Neighbour(), slice::mot_ctx, storable_picture::motion, macroblock::p_Img, macroblock::p_Slice, pic_motion_params::ref_idx, unary_bin_decode(), syntaxelement::value1, and syntaxelement::value2.

Referenced by prepareListforRefIdx().

Here is the call graph for this function:

void readRunLevel_CABAC ( Macroblock currMB,
SyntaxElement se,
DecodingEnvironmentPtr  dep_dp 
)

int readSyntaxElement_CABAC ( SyntaxElement se,
ImageParameters *  p_Img,
DataPartition this_dataPart 
)

arithmetic decoding

Definition at line 1658 of file cabac.c.

References arideco_bits_read(), syntaxelement::len, and syntaxelement::reading.

Here is the call graph for this function:

static unsigned int unary_bin_decode ( DecodingEnvironmentPtr  dep_dp,
BiContextTypePtr  ctx,
int  ctx_offset 
) [static]

decoding of unary binarization using one or 2 distinct models for the first and all remaining bins

Definition at line 1721 of file cabac.c.

References biari_decode_symbol().

Referenced by readDquant_CABAC(), and readRefFrame_CABAC().

Here is the call graph for this function:

static unsigned int unary_bin_max_decode ( DecodingEnvironmentPtr  dep_dp,
BiContextTypePtr  ctx,
int  ctx_offset,
unsigned int  max_symbol 
) [static]

decoding of unary binarization using one or 2 distinct models for the first and all remaining bins; no terminating "0" for max_symbol

Definition at line 1686 of file cabac.c.

References biari_decode_symbol().

Referenced by readCIPredMode_CABAC().

Here is the call graph for this function:

static unsigned int unary_exp_golomb_level_decode ( DecodingEnvironmentPtr  dep_dp,
BiContextTypePtr  ctx 
) [static]

Exp-Golomb decoding for LEVELS.

Definition at line 1820 of file cabac.c.

References biari_decode_symbol(), and exp_golomb_decode_eq_prob().

Referenced by read_significant_coefficients().

Here is the call graph for this function:

static unsigned int unary_exp_golomb_mv_decode ( DecodingEnvironmentPtr  dep_dp,
BiContextTypePtr  ctx,
unsigned int  max_bin 
) [static]

Exp-Golomb decoding for Motion Vectors.

Definition at line 1856 of file cabac.c.

References biari_decode_symbol(), and exp_golomb_decode_eq_prob().

Referenced by readMVD_CABAC().

Here is the call graph for this function:


Variable Documentation

const byte* pos2ctx_last[] [static]

Initial value:

 {pos2ctx_last4x4, pos2ctx_last4x4, pos2ctx_last8x8, pos2ctx_last8x4,
                                         pos2ctx_last8x4, pos2ctx_last4x4, pos2ctx_last4x4, pos2ctx_last4x4,
                                         pos2ctx_last2x4c, pos2ctx_last4x4c,
                                         pos2ctx_last4x4, pos2ctx_last4x4, pos2ctx_last8x8,pos2ctx_last8x4,
                                         pos2ctx_last8x4, pos2ctx_last4x4,
                                         pos2ctx_last4x4, pos2ctx_last4x4, pos2ctx_last8x8,pos2ctx_last8x4,
                                         pos2ctx_last8x4, pos2ctx_last4x4}

Definition at line 1479 of file cabac.c.

const byte pos2ctx_last8x4[] [static]

Initial value:

 { 0,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2,
                                          3,  3,  3,  3,  4,  4,  4,  4,  5,  5,  6,  6,  7,  7,  8,  8}

Definition at line 1473 of file cabac.c.

const byte pos2ctx_last8x8[] [static]

Initial value:

 { 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
                                          2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
                                          3,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  4,  4,  4,
                                          5,  5,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8}

Definition at line 1469 of file cabac.c.

const byte* pos2ctx_map[] [static]

Initial value:

 {pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8, pos2ctx_map8x4,
                                        pos2ctx_map8x4, pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map4x4,
                                        pos2ctx_map2x4c, pos2ctx_map4x4c, 
                                        pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8,pos2ctx_map8x4,
                                        pos2ctx_map8x4, pos2ctx_map4x4,
                                        pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8,pos2ctx_map8x4,
                                        pos2ctx_map8x4,pos2ctx_map4x4}

Definition at line 1443 of file cabac.c.

const byte pos2ctx_map4x8i[] [static]

Initial value:

 { 0,  1,  1,  1,  2,  3,  3,  4,  4,  4,  5,  6,  2,  7,  7,  8,
                                         8,  8,  5,  6,  9, 10, 10, 11, 11, 11, 12, 13, 13, 14, 14, 14}

Definition at line 1458 of file cabac.c.

const byte pos2ctx_map8x4[] [static]

Initial value:

 { 0,  1,  2,  3,  4,  5,  7,  8,  9, 10, 11,  9,  8,  6,  7,  8,
                                         9, 10, 11,  9,  8,  6, 12,  8,  9, 10, 11,  9, 13, 13, 14, 14}

Definition at line 1438 of file cabac.c.

const byte pos2ctx_map8x4i[] [static]

Initial value:

 { 0,  1,  2,  3,  4,  5,  6,  3,  4,  5,  6,  3,  4,  7,  6,  8,
                                         9,  7,  6,  8,  9, 10, 11, 12, 12, 10, 11, 13, 13, 14, 14, 14}

Definition at line 1456 of file cabac.c.

const byte pos2ctx_map8x8[] [static]

Initial value:

 { 0,  1,  2,  3,  4,  5,  5,  4,  4,  3,  3,  4,  4,  4,  5,  5,
                                         4,  4,  4,  4,  3,  3,  6,  7,  7,  7,  8,  9, 10,  9,  8,  7,
                                         7,  6, 11, 12, 13, 11,  6,  7,  8,  9, 14, 10,  9,  8,  6, 11,
                                        12, 13, 11,  6,  9, 14, 10,  9, 11, 12, 13, 11 ,14, 10, 12, 14}

Definition at line 1434 of file cabac.c.

const byte pos2ctx_map8x8i[] [static]

Initial value:

 { 0,  1,  1,  2,  2,  3,  3,  4,  5,  6,  7,  7,  7,  8,  4,  5,
                                         6,  9, 10, 10,  8, 11, 12, 11,  9,  9, 10, 10,  8, 11, 12, 11,
                                         9,  9, 10, 10,  8, 11, 12, 11,  9,  9, 10, 10,  8, 13, 13,  9,
                                         9, 10, 10,  8, 13, 13,  9,  9, 10, 10, 14, 14, 14, 14, 14, 14}

Definition at line 1452 of file cabac.c.

const byte* pos2ctx_map_int[] [static]

Initial value:

 {pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8i,pos2ctx_map8x4i,
                                        pos2ctx_map4x8i,pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map4x4,
                                        pos2ctx_map2x4c, pos2ctx_map4x4c,
                                        pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8i,pos2ctx_map8x4i,
                                        pos2ctx_map8x4i,pos2ctx_map4x4,
                                        pos2ctx_map4x4, pos2ctx_map4x4, pos2ctx_map8x8i,pos2ctx_map8x4i,
                                        pos2ctx_map8x4i,pos2ctx_map4x4}

Definition at line 1460 of file cabac.c.


Documentation generated with DoxyGen