vlc.c File Reference

(CA)VLC coding functions More...

#include "contributors.h"
#include <math.h>
#include "global.h"
#include "enc_statistics.h"
#include "vlc.h"

Include dependency graph for vlc.c:

Go to the source code of this file.

Defines

#define SYMTRACESTRING(s)

Functions

int ue_v (char *tracestring, int value, Bitstream *bitstream)
int se_v (char *tracestring, int value, Bitstream *bitstream)
Boolean u_1 (char *tracestring, int value, Bitstream *bitstream)
int u_v (int n, char *tracestring, int value, Bitstream *bitstream)
void ue_linfo (int ue, int dummy, int *len, int *info)
void se_linfo (int se, int dummy, int *len, int *info)
void cbp_linfo_intra_other (int cbp, int dummy, int *len, int *info)
void cbp_linfo_intra_normal (int cbp, int dummy, int *len, int *info)
void cbp_linfo_inter_other (int cbp, int dummy, int *len, int *info)
void cbp_linfo_inter_normal (int cbp, int dummy, int *len, int *info)
void levrun_linfo_c2x2 (int level, int run, int *len, int *info)
void levrun_linfo_inter (int level, int run, int *len, int *info)
int symbol2uvlc (SyntaxElement *sym)
void writeSE_UVLC (SyntaxElement *se, DataPartition *dp)
void writeSE_SVLC (SyntaxElement *se, DataPartition *dp)
void writeCBP_VLC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeIntraPredMode_CAVLC (SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement2Buf_UVLC (SyntaxElement *se, Bitstream *this_streamBuffer)
void writeUVLC2buffer (SyntaxElement *se, Bitstream *currStream)
int writeSyntaxElement2Buf_Fixed (SyntaxElement *se, Bitstream *this_streamBuffer)
void writeSE_Flag (SyntaxElement *se, DataPartition *dp)
void writeSE_invFlag (SyntaxElement *se, DataPartition *dp)
void writeSE_Dummy (SyntaxElement *se, DataPartition *dp)
void writeSE_Fix (SyntaxElement *se, Bitstream *bitstream)
int symbol2vlc (SyntaxElement *sym)
int writeSyntaxElement_VLC (SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_NumCoeffTrailingOnes (SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_NumCoeffTrailingOnesChromaDC (ImageParameters *p_Img, SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_TotalZeros (SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_TotalZerosChromaDC (ImageParameters *p_Img, SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_Run (SyntaxElement *se, DataPartition *dp)
int writeSyntaxElement_Level_VLC1 (SyntaxElement *se, DataPartition *dp, int profile_idc)
int writeSyntaxElement_Level_VLCN (SyntaxElement *se, int vlc, DataPartition *dp, int profile_idc)
void writeVlcByteAlign (ImageParameters *p_Img, Bitstream *currStream, StatParameters *cur_stats)
void reset_mb_nz_coeff (ImageParameters *p_Img, int mb_number)
void writeUVLC_CAVLC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeSVLC_CAVLC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)
void writeFlag_CAVLC (Macroblock *currMB, SyntaxElement *se, DataPartition *dp)

Variables

static const byte NCBP [2][48][2]


Detailed Description

(CA)VLC coding functions

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

Definition in file vlc.c.


Function Documentation

void cbp_linfo_inter_normal ( int  cbp,
int  dummy,
int *  len,
int *  info 
)

Input:
Number in the code table
Output:
length and info

Definition at line 335 of file vlc.c.

References NCBP, and ue_linfo().

Referenced by start_macroblock().

Here is the call graph for this function:

void cbp_linfo_inter_other ( int  cbp,
int  dummy,
int *  len,
int *  info 
)

Input:
Number in the code table
Output:
length and info

Definition at line 322 of file vlc.c.

References NCBP, and ue_linfo().

Referenced by start_macroblock().

Here is the call graph for this function:

void cbp_linfo_intra_normal ( int  cbp,
int  dummy,
int *  len,
int *  info 
)

Input:
Number in the code table
Output:
length and info

Definition at line 309 of file vlc.c.

References NCBP, and ue_linfo().

Referenced by start_macroblock().

Here is the call graph for this function:

void cbp_linfo_intra_other ( int  cbp,
int  dummy,
int *  len,
int *  info 
)

Input:
Number in the code table
Output:
length and info

Definition at line 295 of file vlc.c.

References NCBP, and ue_linfo().

Referenced by start_macroblock().

Here is the call graph for this function:

void levrun_linfo_c2x2 ( int  level,
int  run,
int *  len,
int *  info 
)

2x2 transform of chroma DC

Input:
level and run for coefficients
Output:
length and info
Note:
see ITU document for bit assignment

Definition at line 352 of file vlc.c.

void levrun_linfo_inter ( int  level,
int  run,
int *  len,
int *  info 
)

Single scan coefficients.

Input:
level and run for coefficients
Output:
length and info
Note:
see ITU document for bit assignment

Definition at line 399 of file vlc.c.

Referenced by dct_4x4_sp().

void reset_mb_nz_coeff ( ImageParameters p_Img,
int  mb_number 
)

void se_linfo ( int  se,
int  dummy,
int *  len,
int *  info 
)

mapping for se(v) syntax elements

Parameters:
se value to be mapped
dummy dummy parameter
len returns mapped value length
info returns mapped value

Definition at line 272 of file vlc.c.

Referenced by se_v(), and writeSE_SVLC().

int se_v ( char *  tracestring,
int  value,
Bitstream bitstream 
)

se_v, writes an se(v) syntax element, returns the length in bits

Parameters:
tracestring the string for the trace file
value the value to be coded
bitstream the target bitstream the value should be coded into
Returns:
Number of bits used by the coded syntax element
\ note This function writes always the bit buffer for the progressive scan flag, and should not be used (or should be modified appropriately) for the interlace crap When used in the context of the Parameter Sets, this is obviously not a problem.

Definition at line 117 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, se_linfo(), symbol2uvlc(), syntaxelement::value1, syntaxelement::value2, and writeUVLC2buffer().

Referenced by GeneratePic_parameter_set_rbsp(), GenerateSeq_parameter_set_rbsp(), pred_weight_table(), Scaling_List(), and SliceHeader().

Here is the call graph for this function:

int symbol2uvlc ( SyntaxElement sym  ) 

Makes code word and passes it back A code word has the following format: 0 0 0 ... 1 Xn ...X2 X1 X0.

Input:
Info : Xn..X2 X1 X0
Length : Total number of bits in the codeword

Definition at line 451 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::inf, and syntaxelement::len.

Referenced by se_v(), ue_v(), writeCBP_VLC(), writeSE_SVLC(), writeSE_UVLC(), and writeSyntaxElement2Buf_UVLC().

int symbol2vlc ( SyntaxElement sym  ) 

Boolean u_1 ( char *  tracestring,
int  value,
Bitstream bitstream 
)

u_1, writes a flag (u(1) syntax element, returns the length in bits, always 1

Parameters:
tracestring the string for the trace file
value the value to be coded
bitstream the target bitstream the value should be coded into
Returns:
Number of bits used by the coded syntax element (always 1)
\ note This function writes always the bit buffer for the progressive scan flag, and should not be used (or should be modified appropriately) for the interlace crap When used in the context of the Parameter Sets, this is obviously not a problem.

Definition at line 163 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::len, syntaxelement::value1, and writeUVLC2buffer().

Referenced by dec_ref_pic_marking(), GeneratePic_parameter_set_rbsp(), GenerateSeq_parameter_set_rbsp(), GenerateVUI_parameters_rbsp(), pred_weight_table(), ref_pic_list_reordering(), SliceHeader(), and WriteHRDParameters().

Here is the call graph for this function:

int u_v ( int  n,
char *  tracestring,
int  value,
Bitstream bitstream 
)

u_v, writes a n bit fixed length syntax element, returns the length in bits,

Parameters:
n length in bits
tracestring the string for the trace file
value the value to be coded
bitstream the target bitstream the value should be coded into
Returns:
Number of bits used by the coded syntax element
\ note This function writes always the bit buffer for the progressive scan flag, and should not be used (or should be modified appropriately) for the interlace crap When used in the context of the Parameter Sets, this is obviously not a problem.

Definition at line 210 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::len, syntaxelement::value1, and writeUVLC2buffer().

Referenced by GeneratePic_parameter_set_rbsp(), GenerateSEImessage_rbsp(), GenerateSeq_parameter_set_rbsp(), GenerateVUI_parameters_rbsp(), SliceHeader(), and WriteHRDParameters().

Here is the call graph for this function:

void ue_linfo ( int  ue,
int  dummy,
int *  len,
int *  info 
)

mapping for ue(v) syntax elements

Parameters:
ue value to be mapped
dummy dummy parameter
info returns mapped value
len returns mapped value length

Definition at line 245 of file vlc.c.

Referenced by cbp_linfo_inter_normal(), cbp_linfo_inter_other(), cbp_linfo_intra_normal(), cbp_linfo_intra_other(), ComposeSparePictureMessage(), CompressSpareMBMap(), FinalizeSpareMBMap(), FinalizeSubseqInfo(), RDCost_for_8x8blocks(), RDCost_for_macroblocks(), ue_v(), and writeSE_UVLC().

int ue_v ( char *  tracestring,
int  value,
Bitstream bitstream 
)

ue_v, writes an ue(v) syntax element, returns the length in bits

Parameters:
tracestring the string for the trace file
value the value to be coded
bitstream the target bitstream the value should be coded into
Returns:
Number of bits used by the coded syntax element
\ note This function writes always the bit buffer for the progressive scan flag, and should not be used (or should be modified appropriately) for the interlace crap When used in the context of the Parameter Sets, this is obviously not a problem.

Definition at line 72 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2uvlc(), ue_linfo(), syntaxelement::value1, syntaxelement::value2, and writeUVLC2buffer().

Referenced by dec_ref_pic_marking(), GeneratePic_parameter_set_rbsp(), GenerateSeq_parameter_set_rbsp(), GenerateVUI_parameters_rbsp(), pred_weight_table(), ref_pic_list_reordering(), SliceHeader(), and WriteHRDParameters().

Here is the call graph for this function:

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

generates UVLC code and passes the codeword to the buffer

Definition at line 510 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, macroblock::mb_type, symbol2uvlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Here is the call graph for this function:

void writeIntraPredMode_CAVLC ( SyntaxElement se,
DataPartition dp 
)

generates code and passes the codeword to the buffer

Definition at line 540 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::inf, syntaxelement::len, syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Here is the call graph for this function:

void writeSE_Dummy ( SyntaxElement se,
DataPartition dp 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 734 of file vlc.c.

References syntaxelement::len.

void writeSE_Fix ( SyntaxElement se,
Bitstream bitstream 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 748 of file vlc.c.

References writeUVLC2buffer().

Here is the call graph for this function:

void writeSE_Flag ( SyntaxElement se,
DataPartition dp 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 692 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::len, syntaxelement::value1, and writeUVLC2buffer().

Referenced by writeMBLayerBSlice(), and writeMBLayerPSlice().

Here is the call graph for this function:

void writeSE_invFlag ( SyntaxElement se,
DataPartition dp 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 713 of file vlc.c.

References syntaxelement::bitpattern, syntaxelement::len, syntaxelement::value1, and writeUVLC2buffer().

Here is the call graph for this function:

void writeSE_SVLC ( SyntaxElement se,
DataPartition dp 
)

generates UVLC code and passes the codeword to the buffer

Definition at line 488 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, se_linfo(), symbol2uvlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Here is the call graph for this function:

void writeSE_UVLC ( SyntaxElement se,
DataPartition dp 
)

generates UVLC code and passes the codeword to the buffer

Definition at line 466 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2uvlc(), syntaxelement::type, ue_linfo(), syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by end_macroblock(), Partition_BC_Header(), writeMBLayerBSlice(), and writeMBLayerPSlice().

Here is the call graph for this function:

int writeSyntaxElement2Buf_Fixed ( SyntaxElement se,
Bitstream this_streamBuffer 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 673 of file vlc.c.

References syntaxelement::len, syntaxelement::type, and writeUVLC2buffer().

Referenced by FinalizeSubseqInfo().

Here is the call graph for this function:

int writeSyntaxElement2Buf_UVLC ( SyntaxElement se,
Bitstream this_streamBuffer 
)

generates UVLC code and passes the codeword to the buffer

Author:
Tian Dong

Definition at line 577 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2uvlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, and writeUVLC2buffer().

Referenced by ComposeSparePictureMessage(), CompressSpareMBMap(), FinalizeSpareMBMap(), and FinalizeSubseqInfo().

Here is the call graph for this function:

int writeSyntaxElement_Level_VLC1 ( SyntaxElement se,
DataPartition dp,
int  profile_idc 
)

write VLC for Coeff Level (VLC1)

Definition at line 1224 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_Level_VLCN ( SyntaxElement se,
int  vlc,
DataPartition dp,
int  profile_idc 
)

write VLC for Coeff Level

Definition at line 1293 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_NumCoeffTrailingOnes ( SyntaxElement se,
DataPartition dp 
)

write VLC for NumCoeff and TrailingOnes

Definition at line 820 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_NumCoeffTrailingOnesChromaDC ( ImageParameters p_Img,
SyntaxElement se,
DataPartition dp 
)

write VLC for NumCoeff and TrailingOnes for Chroma DC

Definition at line 918 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_Run ( SyntaxElement se,
DataPartition dp 
)

write VLC for Run Before Next Coefficient, VLC0

Definition at line 1167 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_TotalZeros ( SyntaxElement se,
DataPartition dp 
)

write VLC for TotalZeros

Definition at line 994 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_TotalZerosChromaDC ( ImageParameters p_Img,
SyntaxElement se,
DataPartition dp 
)

write VLC for TotalZeros for Chroma DC

Definition at line 1067 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

int writeSyntaxElement_VLC ( SyntaxElement se,
DataPartition dp 
)

generates VLC code and passes the codeword to the buffer

Definition at line 793 of file vlc.c.

References syntaxelement::inf, syntaxelement::len, symbol2vlc(), syntaxelement::type, syntaxelement::value1, syntaxelement::value2, Bitstream::write_flag, and writeUVLC2buffer().

Referenced by writeCoeff4x4_CAVLC_444(), and writeCoeff4x4_CAVLC_normal().

Here is the call graph for this function:

void writeUVLC2buffer ( SyntaxElement se,
Bitstream currStream 
)

void writeVlcByteAlign ( ImageParameters p_Img,
Bitstream currStream,
StatParameters *  cur_stats 
)

puts the less than 8 bits in the byte buffer of the Bitstream into the streamBuffer.

Parameters:
p_Img ImageParameters for current picture encoding
currStream the Bitstream the alignment should be established
cur_stats currently used statistics parameters

Definition at line 1438 of file vlc.c.

References Bitstream::bits_to_go, Bitstream::byte_buf, Bitstream::byte_pos, and Bitstream::streamBuffer.

Referenced by start_slice().


Variable Documentation

const byte NCBP[2][48][2] [static]

Initial value:

{
  {  
    { 1, 0},{10, 1},{11, 2},{ 6, 5},{12, 3},{ 7, 6},{14,14},{ 2,10},{13, 4},{15,15},{ 8, 7},{ 3,11},
    { 9, 8},{ 4,12},{ 5,13},{ 0, 9},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
    { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
    { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0}
  },
  {
    { 3, 0},{29, 2},{30, 3},{17, 7},{31, 4},{18, 8},{37,17},{ 8,13},{32, 5},{38,18},{19, 9},{ 9,14},
    {20,10},{10,15},{11,16},{ 2,11},{16, 1},{33,32},{34,33},{21,36},{35,34},{22,37},{39,44},{ 4,40},
    {36,35},{40,45},{23,38},{ 5,41},{24,39},{ 6,42},{ 7,43},{ 1,19},{41, 6},{42,24},{43,25},{25,20},
    {44,26},{26,21},{46,46},{12,28},{45,27},{47,47},{27,22},{13,29},{28,23},{14,30},{15,31},{ 0,12}
  }
}
gives codeword number from CBP value, both for intra and inter

Definition at line 32 of file vlc.c.

Referenced by cbp_linfo_inter_normal(), cbp_linfo_inter_other(), cbp_linfo_intra_normal(), and cbp_linfo_intra_other().


Documentation generated with DoxyGen