cabac.c File Reference

CABAC entropy coding routines. More...

#include "global.h"
#include "cabac.h"
#include "biariencode.h"
#include "image.h"
#include "mb_access.h"

Include dependency graph for cabac.c:

Go to the source code of this file.

Functions

static void exp_golomb_encode_eq_prob (EncodingEnvironmentPtr eep_dp, unsigned int symbol, int k)
static void unary_bin_encode (EncodingEnvironmentPtr eep_dp, unsigned int symbol, BiContextTypePtr ctx, int ctx_offset)
static void unary_bin_max_encode (EncodingEnvironmentPtr eep_dp, unsigned int symbol, BiContextTypePtr ctx, int ctx_offset, unsigned int max_symbol)
static void unary_exp_golomb_level_encode (EncodingEnvironmentPtr eep_dp, unsigned int symbol, BiContextTypePtr ctx)
static void unary_exp_golomb_mv_encode (EncodingEnvironmentPtr eep_dp, unsigned int symbol, BiContextTypePtr ctx, unsigned int max_bin)
void CheckAvailabilityOfNeighborsCABAC (Macroblock *currMB)
MotionInfoContexts * create_contexts_MotionInfo (void)
TextureInfoContexts * create_contexts_TextureInfo (void)
void delete_contexts_MotionInfo (MotionInfoContexts *enco_ctx)
void delete_contexts_TextureInfo (TextureInfoContexts *enco_ctx)
void writeFieldModeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_Pskip_flagInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_Bskip_flagInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_transform_size_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_P_typeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_B_typeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMB_I_typeInfo_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeB8_B_typeInfo_CABAC (SyntaxElement *se, DataPartition *dp)
void writeB8_typeInfo_CABAC (SyntaxElement *se, DataPartition *dp)
void writeIntraPredMode_CABAC (SyntaxElement *se, DataPartition *dp)
void writeRefPic_P_CABAC (SyntaxElement *se, DataPartition *dp)
void writeRefPic_B_CABAC (SyntaxElement *se, DataPartition *dp)
void writeDquant_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeMVD_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeCIPredMode_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeCBP_BIT_CABAC (Macroblock *currMB, int b8, int bit, int cbp, EncodingEnvironmentPtr eep_dp, TextureInfoContexts *ctx)
void writeCBP_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void write_and_store_CBP_block_bit_444 (Macroblock *currMB, EncodingEnvironmentPtr eep_dp, int type, int cbp_bit, TextureInfoContexts *tex_ctx)
void write_and_store_CBP_block_bit (Macroblock *currMB, EncodingEnvironmentPtr eep_dp, int type, int cbp_bit, TextureInfoContexts *tex_ctx)
void write_significance_map (Macroblock *currMB, EncodingEnvironmentPtr eep_dp, int type, int coeff[], int coeff_ctr, TextureInfoContexts *tex_ctx)
void write_significant_coefficients (EncodingEnvironmentPtr eep_dp, int type, int coeff[], TextureInfoContexts *tex_ctx)
void writeRunLevel_CABAC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)

Variables

static const byte pos2ctx_map8x8 []
static const byte pos2ctx_map8x4 []
static const byte pos2ctx_map4x4 []
static const byte pos2ctx_map2x4c []
static const byte pos2ctx_map4x4c []
const bytepos2ctx_map []
static const byte pos2ctx_map8x8i []
static const byte pos2ctx_map8x4i []
static const byte pos2ctx_map4x8i []
const bytepos2ctx_map_int []
static const byte pos2ctx_last8x8 []
static const byte pos2ctx_last8x4 []
static const byte pos2ctx_last4x4 []
static const byte pos2ctx_last2x4c []
static const byte pos2ctx_last4x4c []
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

void CheckAvailabilityOfNeighborsCABAC ( Macroblock currMB  ) 

Check for available neighbouring blocks and set pointers in current macroblock.

Definition at line 306 of file cabac.c.

References img_par::mb_data, macroblock::mb_left, macroblock::mb_up, and macroblock::p_Img.

Referenced by start_macroblock(), writeMBLayerBSlice(), and writeMBLayerPSlice().

MotionInfoContexts* create_contexts_MotionInfo ( void   ) 

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

Definition at line 333 of file cabac.c.

References no_mem_exit().

Referenced by create_coding_state(), and 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 encoding.

Definition at line 352 of file cabac.c.

References no_mem_exit().

Referenced by create_coding_state(), and malloc_slice().

Here is the call graph for this function:

void delete_contexts_MotionInfo ( MotionInfoContexts *  enco_ctx  ) 

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

Definition at line 368 of file cabac.c.

Referenced by delete_coding_state(), and free_slice().

void delete_contexts_TextureInfo ( TextureInfoContexts *  enco_ctx  ) 

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

Definition at line 383 of file cabac.c.

Referenced by delete_coding_state(), and free_slice().

static void exp_golomb_encode_eq_prob ( EncodingEnvironmentPtr  eep_dp,
unsigned int  symbol,
int  k 
) [static]

Exp Golomb binarization and encoding.

Definition at line 148 of file cabac.c.

References biari_encode_symbol_eq_prob().

Referenced by unary_exp_golomb_level_encode(), and unary_exp_golomb_mv_encode().

Here is the call graph for this function:

static void unary_bin_encode ( EncodingEnvironmentPtr  eep_dp,
unsigned int  symbol,
BiContextTypePtr  ctx,
int  ctx_offset 
) [static]

Unary binarization and encoding of a symbol by using one or two distinct models for the first two and all remaining bins.

Definition at line 178 of file cabac.c.

References biari_encode_symbol().

Referenced by writeDquant_CABAC(), writeRefPic_B_CABAC(), and writeRefPic_P_CABAC().

Here is the call graph for this function:

static void unary_bin_max_encode ( EncodingEnvironmentPtr  eep_dp,
unsigned int  symbol,
BiContextTypePtr  ctx,
int  ctx_offset,
unsigned int  max_symbol 
) [static]

Unary binarization and encoding of a symbol by using one or two distinct models for the first two and all remaining bins; no terminating "0" for max_symbol (finite symbol alphabet).

Definition at line 207 of file cabac.c.

References biari_encode_symbol().

Referenced by writeCIPredMode_CABAC().

Here is the call graph for this function:

static void unary_exp_golomb_level_encode ( EncodingEnvironmentPtr  eep_dp,
unsigned int  symbol,
BiContextTypePtr  ctx 
) [static]

Exp-Golomb for Level Encoding.

Definition at line 237 of file cabac.c.

References biari_encode_symbol(), and exp_golomb_encode_eq_prob().

Referenced by write_significant_coefficients().

Here is the call graph for this function:

static void unary_exp_golomb_mv_encode ( EncodingEnvironmentPtr  eep_dp,
unsigned int  symbol,
BiContextTypePtr  ctx,
unsigned int  max_bin 
) [static]

Exp-Golomb for MV Encoding.

Definition at line 268 of file cabac.c.

References biari_encode_symbol(), and exp_golomb_encode_eq_prob().

Referenced by writeMVD_CABAC().

Here is the call graph for this function:

void write_and_store_CBP_block_bit ( Macroblock currMB,
EncodingEnvironmentPtr  eep_dp,
int  type,
int  cbp_bit,
TextureInfoContexts *  tex_ctx 
)

Write CBP4-BIT.

Definition at line 1632 of file cabac.c.

References biari_encode_symbol(), get4x4Neighbour(), img_par::mb_data, macroblock::mb_type, macroblock::p_Img, macroblock::subblock_x, and macroblock::subblock_y.

Here is the call graph for this function:

void write_and_store_CBP_block_bit_444 ( Macroblock currMB,
EncodingEnvironmentPtr  eep_dp,
int  type,
int  cbp_bit,
TextureInfoContexts *  tex_ctx 
)

Write CBP4-BIT (for 444 formats).

Definition at line 1405 of file cabac.c.

References biari_encode_symbol(), get4x4Neighbour(), img_par::mb_data, macroblock::mb_type, macroblock::p_Img, macroblock::subblock_x, macroblock::subblock_y, and YUV444.

Here is the call graph for this function:

void write_significance_map ( Macroblock currMB,
EncodingEnvironmentPtr  eep_dp,
int  type,
int  coeff[],
int  coeff_ctr,
TextureInfoContexts *  tex_ctx 
)

Write Significance MAP.

Definition at line 1737 of file cabac.c.

References biari_encode_symbol(), macroblock::p_Img, and img_par::structure.

Referenced by writeRunLevel_CABAC().

Here is the call graph for this function:

void write_significant_coefficients ( EncodingEnvironmentPtr  eep_dp,
int  type,
int  coeff[],
TextureInfoContexts *  tex_ctx 
)

Write Levels.

Definition at line 1784 of file cabac.c.

References biari_encode_symbol(), biari_encode_symbol_eq_prob(), and unary_exp_golomb_level_encode().

Referenced by writeRunLevel_CABAC().

Here is the call graph for this function:

void writeB8_B_typeInfo_CABAC ( SyntaxElement se,
DataPartition dp 
)

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

Definition at line 837 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::len, slice::mot_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeB8_typeInfo_CABAC ( SyntaxElement se,
DataPartition dp 
)

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

Definition at line 906 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::len, slice::mot_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeCBP_BIT_CABAC ( Macroblock currMB,
int  b8,
int  bit,
int  cbp,
EncodingEnvironmentPtr  eep_dp,
TextureInfoContexts *  ctx 
)

This function is used to arithmetically encode the coded block pattern of an 8x8 block.

Definition at line 1290 of file cabac.c.

References biari_encode_symbol(), get4x4Neighbour(), img_par::mb_data, macroblock::mb_type, macroblock::mb_up, and macroblock::p_Img.

Referenced by RDCost_for_8x8blocks(), and writeCBP_CABAC().

Here is the call graph for this function:

void writeCBP_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the coded block pattern of a macroblock.

Definition at line 1333 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::len, macroblock::mb_left, macroblock::mb_up, macroblock::p_slice, slice::tex_ctx, syntaxelement::value1, Bitstream::write_flag, writeCBP_BIT_CABAC(), YUV400, and YUV444.

Here is the call graph for this function:

void writeCIPredMode_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the chroma intra prediction mode of an 8x8 block.

Definition at line 1253 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), macroblock::c_ipred_mode, syntaxelement::len, macroblock::mb_left, macroblock::mb_type, macroblock::mb_up, slice::tex_ctx, unary_bin_max_encode(), syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeDquant_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the coded block pattern of a given delta quant.

Definition at line 1123 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::len, slice::tex_ctx, unary_bin_encode(), syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeFieldModeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the field mode info of a given MB in the case of mb-based frame/field decision.

Definition at line 399 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::context, syntaxelement::len, img_par::mb_data, macroblock::p_Img, slice::tex_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeIntraPredMode_CABAC ( SyntaxElement se,
DataPartition dp 
)

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

Definition at line 945 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::len, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_B_typeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the macroblock type info of a given MB in a B slice.

Definition at line 632 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), biari_encode_symbol_final(), syntaxelement::context, syntaxelement::len, macroblock::mb_left, macroblock::mb_type, macroblock::mb_up, slice::mot_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_Bskip_flagInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the mb_skip_flag for B slices.

Definition at line 462 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::context, syntaxelement::len, macroblock::mb_left, macroblock::mb_up, slice::mot_ctx, macroblock::p_slice, syntaxelement::value1, syntaxelement::value2, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_I_typeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the macroblock type info of a given MB in an I Slice.

Definition at line 758 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), biari_encode_symbol_final(), syntaxelement::context, syntaxelement::len, macroblock::mb_left, macroblock::mb_type, macroblock::mb_up, slice::mot_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_P_typeInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

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

Definition at line 526 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), biari_encode_symbol_final(), syntaxelement::len, slice::mot_ctx, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_Pskip_flagInfo_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

This function is used to arithmetically encode the mb_skip_flag.

Definition at line 430 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::context, syntaxelement::len, macroblock::mb_left, macroblock::mb_up, slice::mot_ctx, macroblock::p_slice, syntaxelement::value1, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMB_transform_size_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

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

Definition at line 497 of file cabac.c.

References arienco_bits_written(), biari_encode_symbol(), syntaxelement::context, syntaxelement::len, macroblock::mb_left, macroblock::mb_up, and Bitstream::write_flag.

Here is the call graph for this function:

void writeMVD_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)

void writeRefPic_B_CABAC ( SyntaxElement se,
DataPartition dp 
)

void writeRefPic_P_CABAC ( SyntaxElement se,
DataPartition dp 
)

void writeRunLevel_CABAC ( Macroblock currMB,
SyntaxElement se,
DataPartition dp 
)


Variable Documentation

const byte* pos2ctx_last[]

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 126 of file cabac.c.

const byte pos2ctx_last2x4c[] [static]

Initial value:

 {
  0,  0,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2
}

Definition at line 118 of file cabac.c.

const byte pos2ctx_last4x4[] [static]

Initial value:

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

Definition at line 114 of file cabac.c.

const byte pos2ctx_last4x4c[] [static]

Initial value:

 { 
  0,  0,  0,  0,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2
}

Definition at line 122 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 109 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 102 of file cabac.c.

const byte* pos2ctx_map[]

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 60 of file cabac.c.

const byte pos2ctx_map2x4c[] [static]

Initial value:

 {
  0,  0,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2
}

Definition at line 52 of file cabac.c.

const byte pos2ctx_map4x4[] [static]

Initial value:

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

Definition at line 48 of file cabac.c.

const byte pos2ctx_map4x4c[] [static]

Initial value:

 {
  0,  0,  0,  0,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2
}

Definition at line 56 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 84 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 43 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 79 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 36 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 72 of file cabac.c.

const byte* pos2ctx_map_int[]

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 89 of file cabac.c.


Documentation generated with DoxyGen