libavcodec/h264_cavlc.c File Reference

H.264 / AVC / MPEG4 part10 cavlc bitstream decoding. More...

#include "internal.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "h264.h"
#include "h264data.h"
#include "h264_mvpred.h"
#include "golomb.h"
#include <assert.h>

Go to the source code of this file.

Defines

#define CABAC   0
#define UNCHECKED_BITSTREAM_READER   1
#define LEVEL_TAB_BITS   8
#define CHROMA_DC_COEFF_TOKEN_VLC_BITS   8
#define CHROMA422_DC_COEFF_TOKEN_VLC_BITS   13
#define COEFF_TOKEN_VLC_BITS   8
#define TOTAL_ZEROS_VLC_BITS   9
#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS   3
#define CHROMA422_DC_TOTAL_ZEROS_VLC_BITS   5
#define RUN_VLC_BITS   3
#define RUN7_VLC_BITS   6
#define STORE_BLOCK(type)

Functions

static int pred_non_zero_count (H264Context *h, int n)
 Get the predicted number of non-zero coefficients.
static av_cold void init_cavlc_level_tab (void)
av_cold void ff_h264_decode_init_vlc (void)
static int get_level_prefix (GetBitContext *gb)
static int decode_residual (H264Context *h, GetBitContext *gb, DCTELEM *block, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff)
 Decode a residual block.
static av_always_inline int decode_luma_residual (H264Context *h, GetBitContext *gb, const uint8_t *scan, const uint8_t *scan8x8, int pixel_shift, int mb_type, int cbp, int p)
int ff_h264_decode_mb_cavlc (H264Context *h)
 Decode a macroblock.

Variables

static const uint8_t golomb_to_inter_cbp_gray [16]
static const uint8_t golomb_to_intra4x4_cbp_gray [16]
static const uint8_t chroma_dc_coeff_token_len [4 *5]
static const uint8_t chroma_dc_coeff_token_bits [4 *5]
static const uint8_t chroma422_dc_coeff_token_len [4 *9]
static const uint8_t chroma422_dc_coeff_token_bits [4 *9]
static const uint8_t coeff_token_len [4][4 *17]
static const uint8_t coeff_token_bits [4][4 *17]
static const uint8_t total_zeros_len [16][16]
static const uint8_t total_zeros_bits [16][16]
static const uint8_t chroma_dc_total_zeros_len [3][4]
static const uint8_t chroma_dc_total_zeros_bits [3][4]
static const uint8_t chroma422_dc_total_zeros_len [7][8]
static const uint8_t chroma422_dc_total_zeros_bits [7][8]
static const uint8_t run_len [7][16]
static const uint8_t run_bits [7][16]
static VLC coeff_token_vlc [4]
static VLC_TYPE coeff_token_vlc_tables [520+332+280+256][2]
static const int coeff_token_vlc_tables_size [4] = {520,332,280,256}
static VLC chroma_dc_coeff_token_vlc
static VLC_TYPE chroma_dc_coeff_token_vlc_table [256][2]
static const int chroma_dc_coeff_token_vlc_table_size = 256
static VLC chroma422_dc_coeff_token_vlc
static VLC_TYPE chroma422_dc_coeff_token_vlc_table [8192][2]
static const int chroma422_dc_coeff_token_vlc_table_size = 8192
static VLC total_zeros_vlc [15]
static VLC_TYPE total_zeros_vlc_tables [15][512][2]
static const int total_zeros_vlc_tables_size = 512
static VLC chroma_dc_total_zeros_vlc [3]
static VLC_TYPE chroma_dc_total_zeros_vlc_tables [3][8][2]
static const int chroma_dc_total_zeros_vlc_tables_size = 8
static VLC chroma422_dc_total_zeros_vlc [7]
static VLC_TYPE chroma422_dc_total_zeros_vlc_tables [7][32][2]
static const int chroma422_dc_total_zeros_vlc_tables_size = 32
static VLC run_vlc [6]
static VLC_TYPE run_vlc_tables [6][8][2]
static const int run_vlc_tables_size = 8
static VLC run7_vlc
static VLC_TYPE run7_vlc_table [96][2]
static const int run7_vlc_table_size = 96
static int8_t cavlc_level_tab [7][1<< LEVEL_TAB_BITS][2]


Detailed Description

H.264 / AVC / MPEG4 part10 cavlc bitstream decoding.

Author:
Michael Niedermayer <michaelni@gmx.at>

Definition in file h264_cavlc.c.


Define Documentation

#define CABAC   0

Definition at line 28 of file h264_cavlc.c.

#define CHROMA422_DC_COEFF_TOKEN_VLC_BITS   13

Definition at line 276 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define CHROMA422_DC_TOTAL_ZEROS_VLC_BITS   5

Definition at line 280 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define CHROMA_DC_COEFF_TOKEN_VLC_BITS   8

Definition at line 275 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS   3

Definition at line 279 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define COEFF_TOKEN_VLC_BITS   8

Definition at line 277 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define LEVEL_TAB_BITS   8

Definition at line 272 of file h264_cavlc.c.

Referenced by decode_residual(), and init_cavlc_level_tab().

#define RUN7_VLC_BITS   6

Definition at line 282 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

#define RUN_VLC_BITS   3

Definition at line 281 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

#define STORE_BLOCK ( type   ) 

#define TOTAL_ZEROS_VLC_BITS   9

Definition at line 278 of file h264_cavlc.c.

Referenced by decode_residual(), and ff_h264_decode_init_vlc().

#define UNCHECKED_BITSTREAM_READER   1

Definition at line 29 of file h264_cavlc.c.


Function Documentation

static av_always_inline int decode_luma_residual ( H264Context h,
GetBitContext gb,
const uint8_t *  scan,
const uint8_t *  scan8x8,
int  pixel_shift,
int  mb_type,
int  cbp,
int  p 
) [static]

Definition at line 628 of file h264_cavlc.c.

Referenced by ff_h264_decode_mb_cavlc().

static int decode_residual ( H264Context h,
GetBitContext gb,
DCTELEM block,
int  n,
const uint8_t *  scantable,
const uint32_t *  qmul,
int  max_coeff 
) [static]

Decode a residual block.

Parameters:
n block index
scantable scantable
max_coeff number of coefficients in the block
Returns:
<0 if an error occurred

Definition at line 446 of file h264_cavlc.c.

Referenced by decode_luma_residual(), and ff_h264_decode_mb_cavlc().

av_cold void ff_h264_decode_init_vlc ( void   ) 

Definition at line 327 of file h264_cavlc.c.

Referenced by ff_h264_decode_init().

int ff_h264_decode_mb_cavlc ( H264Context h  ) 

Decode a macroblock.

Returns:
0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed

Definition at line 695 of file h264_cavlc.c.

Referenced by decode_slice().

static int get_level_prefix ( GetBitContext gb  )  [inline, static]

Definition at line 419 of file h264_cavlc.c.

Referenced by decode_residual().

static av_cold void init_cavlc_level_tab ( void   )  [static]

Definition at line 301 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

static int pred_non_zero_count ( H264Context h,
int  n 
) [inline, static]

Get the predicted number of non-zero coefficients.

Parameters:
n block index

Definition at line 288 of file h264_cavlc.c.

Referenced by decode_residual().


Variable Documentation

int8_t cavlc_level_tab[7][1<< LEVEL_TAB_BITS][2] [static]

Definition at line 273 of file h264_cavlc.c.

Referenced by decode_residual(), and init_cavlc_level_tab().

const uint8_t chroma422_dc_coeff_token_bits[4 *9] [static]

Initial value:

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

Definition at line 78 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma422_dc_coeff_token_len[4 *9] [static]

Initial value:

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

Definition at line 66 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

Definition at line 248 of file h264_cavlc.c.

VLC_TYPE chroma422_dc_coeff_token_vlc_table[8192][2] [static]

Definition at line 249 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int chroma422_dc_coeff_token_vlc_table_size = 8192 [static]

Definition at line 250 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma422_dc_total_zeros_bits[7][8] [static]

Initial value:

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

Definition at line 210 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma422_dc_total_zeros_len[7][8] [static]

Initial value:

 {
    { 1, 3, 3, 4, 4, 4, 5, 5 },
    { 3, 2, 3, 3, 3, 3, 3 },
    { 3, 3, 2, 2, 3, 3 },
    { 3, 2, 2, 2, 3 },
    { 2, 2, 2, 2 },
    { 2, 2, 1 },
    { 1, 1 },
}

Definition at line 200 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

Definition at line 260 of file h264_cavlc.c.

VLC_TYPE chroma422_dc_total_zeros_vlc_tables[7][32][2] [static]

Definition at line 261 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

Definition at line 262 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma_dc_coeff_token_bits[4 *5] [static]

Initial value:

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

Definition at line 58 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma_dc_coeff_token_len[4 *5] [static]

Initial value:

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

Definition at line 50 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

Definition at line 244 of file h264_cavlc.c.

VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2] [static]

Definition at line 245 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int chroma_dc_coeff_token_vlc_table_size = 256 [static]

Definition at line 246 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma_dc_total_zeros_bits[3][4] [static]

Initial value:

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

Definition at line 194 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t chroma_dc_total_zeros_len[3][4] [static]

Initial value:

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

Definition at line 188 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

Definition at line 256 of file h264_cavlc.c.

VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2] [static]

Definition at line 257 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int chroma_dc_total_zeros_vlc_tables_size = 8 [static]

Definition at line 258 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t coeff_token_bits[4][4 *17] [static]

Initial value:

{
{
     1, 0, 0, 0,
     5, 1, 0, 0,     7, 4, 1, 0,     7, 6, 5, 3,     7, 6, 5, 3,
     7, 6, 5, 4,    15, 6, 5, 4,    11,14, 5, 4,     8,10,13, 4,
    15,14, 9, 4,    11,10,13,12,    15,14, 9,12,    11,10,13, 8,
    15, 1, 9,12,    11,14,13, 8,     7,10, 9,12,     4, 6, 5, 8,
},
{
     3, 0, 0, 0,
    11, 2, 0, 0,     7, 7, 3, 0,     7,10, 9, 5,     7, 6, 5, 4,
     4, 6, 5, 6,     7, 6, 5, 8,    15, 6, 5, 4,    11,14,13, 4,
    15,10, 9, 4,    11,14,13,12,     8,10, 9, 8,    15,14,13,12,
    11,10, 9,12,     7,11, 6, 8,     9, 8,10, 1,     7, 6, 5, 4,
},
{
    15, 0, 0, 0,
    15,14, 0, 0,    11,15,13, 0,     8,12,14,12,    15,10,11,11,
    11, 8, 9,10,     9,14,13, 9,     8,10, 9, 8,    15,14,13,13,
    11,14,10,12,    15,10,13,12,    11,14, 9,12,     8,10,13, 8,
    13, 7, 9,12,     9,12,11,10,     5, 8, 7, 6,     1, 4, 3, 2,
},
{
     3, 0, 0, 0,
     0, 1, 0, 0,     4, 5, 6, 0,     8, 9,10,11,    12,13,14,15,
    16,17,18,19,    20,21,22,23,    24,25,26,27,    28,29,30,31,
    32,33,34,35,    36,37,38,39,    40,41,42,43,    44,45,46,47,
    48,49,50,51,    52,53,54,55,    56,57,58,59,    60,61,62,63,
}
}

Definition at line 121 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t coeff_token_len[4][4 *17] [static]

Initial value:

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

Definition at line 90 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

VLC coeff_token_vlc[4] [static]

Definition at line 240 of file h264_cavlc.c.

VLC_TYPE coeff_token_vlc_tables[520+332+280+256][2] [static]

Definition at line 241 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int coeff_token_vlc_tables_size[4] = {520,332,280,256} [static]

Definition at line 242 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t golomb_to_inter_cbp_gray[16] [static]

Initial value:

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

Definition at line 42 of file h264_cavlc.c.

Referenced by ff_h264_decode_mb_cavlc().

const uint8_t golomb_to_intra4x4_cbp_gray[16] [static]

Initial value:

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

Definition at line 46 of file h264_cavlc.c.

Referenced by ff_h264_decode_mb_cavlc().

VLC run7_vlc [static]

Definition at line 268 of file h264_cavlc.c.

VLC_TYPE run7_vlc_table[96][2] [static]

Definition at line 269 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int run7_vlc_table_size = 96 [static]

Definition at line 270 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t run_bits[7][16] [static]

Initial value:

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

Definition at line 230 of file h264_cavlc.c.

Referenced by codebook_trellis_rate(), encode_window_bands_info(), and ff_h264_decode_init_vlc().

const uint8_t run_len[7][16] [static]

Initial value:

{
    {1,1},
    {1,2,2},
    {2,2,2,2},
    {2,2,2,3,3},
    {2,2,3,3,3,3},
    {2,3,3,3,3,3,3},
    {3,3,3,3,3,3,3,4,5,6,7,8,9,10,11},
}

Definition at line 220 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

VLC run_vlc[6] [static]

Definition at line 264 of file h264_cavlc.c.

VLC_TYPE run_vlc_tables[6][8][2] [static]

Definition at line 265 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int run_vlc_tables_size = 8 [static]

Definition at line 266 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t total_zeros_bits[16][16] [static]

Initial value:

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

Definition at line 170 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const uint8_t total_zeros_len[16][16] [static]

Initial value:

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

Definition at line 152 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

VLC total_zeros_vlc[15] [static]

Definition at line 252 of file h264_cavlc.c.

VLC_TYPE total_zeros_vlc_tables[15][512][2] [static]

Definition at line 253 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().

const int total_zeros_vlc_tables_size = 512 [static]

Definition at line 254 of file h264_cavlc.c.

Referenced by ff_h264_decode_init_vlc().


Generated on Fri Oct 26 02:46:08 2012 for FFmpeg by  doxygen 1.5.8