macroblock.c File Reference

Decode a Macroblock. More...

#include "contributors.h"
#include <math.h>
#include "block.h"
#include "global.h"
#include "mbuffer.h"
#include "elements.h"
#include "errorconcealment.h"
#include "macroblock.h"
#include "fmo.h"
#include "cabac.h"
#include "vlc.h"
#include "image.h"
#include "mb_access.h"
#include "biaridecod.h"
#include "transform8x8.h"
#include "transform.h"
#include "mc_prediction.h"
#include "quant.h"
#include "intra4x4_pred.h"
#include "intra8x8_pred.h"
#include "intra16x16_pred.h"
#include "mv_prediction.h"

Include dependency graph for macroblock.c:

Go to the source code of this file.

Defines

#define TRACE_STRING(s)
#define TRACE_DECBITS(i)
#define TRACE_PRINTF(s)
#define TRACE_STRING_P(s)
#define ZERO_P8x8   (mbmode==5)
#define MODE_IS_P8x8   (mbmode==4 || mbmode==5)
#define MODE_IS_I4x4   (mbmode==6)
#define I16OFFSET   (mbmode-7)
#define MODE_IS_IPCM   (mbmode==31)

Functions

void dectracebitcnt (int count)
static void read_motion_info_from_NAL_p_slice (Macroblock *currMB)
static void read_motion_info_from_NAL_b_slice (Macroblock *currMB)
static void read_ipred_modes (Macroblock *currMB)
static void read_CBP_and_coeffs_from_NAL_CABAC (Macroblock *currMB)
static void read_CBP_and_coeffs_from_NAL_CAVLC (Macroblock *currMB)
static void read_IPCM_coeffs_from_NAL (Slice *currSlice, struct datapartition *dP)
static void read_one_macroblock_i_slice (Macroblock *currMB)
static void read_one_macroblock_p_slice (Macroblock *currMB)
static void read_one_macroblock_b_slice (Macroblock *currMB)
static int decode_one_component_i_slice (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture, MotionParams *colocated, int list_offset)
static int decode_one_component_p_slice (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture, MotionParams *colocated, int list_offset)
static int decode_one_component_b_slice (Macroblock *currMB, ColorPlane curr_plane, imgpel **currImg, StorablePicture *dec_picture, MotionParams *colocated, int list_offset)
static int BType2CtxRef (int btype)
static char readRefPictureIdx_VLC (Macroblock *currMB, SyntaxElement *currSE, DataPartition *dP, char b8mode, int list)
static char readRefPictureIdx_FLC (Macroblock *currMB, SyntaxElement *currSE, DataPartition *dP, char b8mode, int list)
static char readRefPictureIdx_Null (Macroblock *currMB, SyntaxElement *currSE, DataPartition *dP, char b8mode, int list)
static void prepareListforRefIdx (Macroblock *currMB, SyntaxElement *currSE, DataPartition *dP, int num_ref_idx_active, int refidx_present)
void set_chroma_qp (Macroblock *currMB)
void update_qp (Macroblock *currMB, int qp)
static void read_delta_quant (SyntaxElement *currSE, DataPartition *dP, Macroblock *currMB, const byte *partMap, int type)
static void readMBRefPictureIdx (SyntaxElement *currSE, DataPartition *dP, Macroblock *currMB, char **cur_ref_idx, int list, int step_v0, int step_h0)
static void readMBMotionVectors (SyntaxElement *currSE, DataPartition *dP, Macroblock *currMB, int list, int step_h0, int step_v0)
void invScaleCoeff (Macroblock *currMB, int level, int run, int qp_per, int i, int j, int i0, int j0, int coef_ctr, const byte(*pos_scan4x4)[2], int(*InvLevelScale4x4)[4])
void start_macroblock (Slice *currSlice, Macroblock **currMB)
Boolean exit_macroblock (Slice *currSlice, int eos_bit)
static void interpret_mb_mode_P (Macroblock *currMB)
static void interpret_mb_mode_I (Macroblock *currMB)
static void interpret_mb_mode_B (Macroblock *currMB)
static void interpret_mb_mode_SI (Macroblock *currMB)
void setup_slice_methods (Slice *currSlice)
static void init_macroblock (Macroblock *currMB)
void SetB8Mode (Macroblock *currMB, int value, int i)
void reset_coeffs (Slice *currSlice)
void field_flag_inference (Macroblock *currMB)
void skip_macroblock (Macroblock *currMB)
static void concealIPCMcoeffs (Macroblock *currMB)
static void init_decoding_engine_IPCM (Slice *currSlice)
void get_neighbors (Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x)
int predict_nnz (Macroblock *currMB, int block_type, int i, int j)
int predict_nnz_chroma (Macroblock *currMB, int i, int j)
static void readCoeff4x4_CAVLC (Macroblock *currMB, int block_type, int i, int j, int levarr[16], int runarr[16], int *number_coefficients)
static void readCompCoeff4x4SMB_CABAC (Macroblock *currMB, SyntaxElement *currSE, ColorPlane pl, int block_y, int block_x, int start_scan, int64 *cbp_blk)
static void readCompCoeff4x4MB_CABAC (Macroblock *currMB, SyntaxElement *currSE, ColorPlane pl, int intra, int(*InvLevelScale4x4)[4], int qp_per, int cbp)
static void readCompCoeff8x8_CABAC (Macroblock *currMB, SyntaxElement *currSE, ColorPlane pl, int b8)
static void readCompCoeff8x8MB_CABAC (Macroblock *currMB, SyntaxElement *currSE, ColorPlane pl)
static void readCompCoeff4x4MB_CAVLC (Macroblock *currMB, ColorPlane pl, int(*InvLevelScale4x4)[4], int qp_per, int cbp, byte **nzcoeff)
static void readCompCoeff8x8MB_CAVLC (Macroblock *currMB, ColorPlane pl, int(*InvLevelScale8x8)[8], int qp_per, int cbp, byte **nzcoeff)
static void check_dp_neighbors (Macroblock *currMB)
void decode_ipcm_mb (Macroblock *currMB)
int decode_one_macroblock (Macroblock *currMB, StorablePicture *dec_picture)
void change_plane_JV (ImageParameters *p_Img, int nplane)
void make_frame_picture_JV (ImageParameters *p_Img)


Detailed Description

Decode a Macroblock.

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

Definition in file macroblock.c.


Function Documentation

static int BType2CtxRef ( int  btype  )  [inline, static]

Set context for reference frames.

Definition at line 83 of file macroblock.c.

Referenced by readRefPictureIdx_FLC(), and readRefPictureIdx_VLC().

void change_plane_JV ( ImageParameters *  p_Img,
int  nplane 
)

change target plane for 4:4:4 Independent mode

Definition at line 5610 of file macroblock.c.

References slice::Co_located_JV.

Referenced by decode_one_slice(), and exit_picture().

static void check_dp_neighbors ( Macroblock currMB  )  [static]

Data partitioning: Check if neighboring macroblock is needed for CAVLC context decoding, and disable current MB if data partition is missing.

Definition at line 3527 of file macroblock.c.

References macroblock::dpl_flag, and macroblock::p_Img.

Referenced by read_CBP_and_coeffs_from_NAL_CABAC(), and read_CBP_and_coeffs_from_NAL_CAVLC().

void decode_ipcm_mb ( Macroblock currMB  ) 

Copy IPCM coefficients to decoded picture buffer and set parameters for this MB (for IPCM CABAC and IPCM CAVLC 28/11/2003).

Author:
Dong Wang <Dong.Wang@bristol.ac.uk>

Definition at line 4774 of file macroblock.c.

References storable_picture::imgUV, storable_picture::imgY, macroblock::mbAddrX, macroblock::p_Img, macroblock::p_Slice, update_qp(), and YUV400.

Referenced by decode_one_macroblock().

Here is the call graph for this function:

static int decode_one_component_b_slice ( Macroblock currMB,
ColorPlane  curr_plane,
imgpel **  currImg,
StorablePicture dec_picture,
MotionParams colocated,
int  list_offset 
) [static]

decode one color component

invalid index. Default to zero even though this case should not happen

invalid index. Default to zero even though this case should not happen

In such case, an array is needed for each different reference.

Definition at line 5104 of file macroblock.c.

References copy_image_data_4x4(), copy_image_data_8x8(), slice::direct_spatial_mv_pred_flag, error(), intrapred(), intrapred16x16(), intrapred8x8(), Inv_Residual_trans_4x4(), Inv_Residual_trans_8x8(), itrans4x4(), itrans8x8(), storable_picture::motion, motion_params::mv, pic_motion_params::mv, slice::num_ref_idx_l0_active, macroblock::p_Img, macroblock::p_Slice, motion_params::ref_idx, pic_motion_params::ref_idx, motion_params::ref_pic_id, pic_motion_params::ref_pic_id, slice::slice_type, YUV400, and YUV444.

Referenced by setup_slice_methods().

Here is the call graph for this function:

static int decode_one_component_i_slice ( Macroblock currMB,
ColorPlane  curr_plane,
imgpel **  currImg,
StorablePicture dec_picture,
MotionParams colocated,
int  list_offset 
) [static]

static int decode_one_component_p_slice ( Macroblock currMB,
ColorPlane  curr_plane,
imgpel **  currImg,
StorablePicture dec_picture,
MotionParams colocated,
int  list_offset 
) [static]

decode one color component. We should actually break these into "mode" related functions instead of slice

Definition at line 4933 of file macroblock.c.

References copy_image_data(), copy_image_data_16x16(), copy_image_data_4x4(), copy_image_data_8x8(), storable_picture::imgUV, intrapred(), intrapred16x16(), intrapred8x8(), Inv_Residual_trans_4x4(), Inv_Residual_trans_8x8(), itrans4x4(), itrans8x8(), macroblock::p_Img, macroblock::p_Slice, slice::slice_type, YUV400, and YUV444.

Referenced by setup_slice_methods().

Here is the call graph for this function:

int decode_one_macroblock ( Macroblock currMB,
StorablePicture dec_picture 
)

decode one macroblock

Definition at line 5481 of file macroblock.c.

References decode_ipcm_mb(), storable_picture::imgUV, storable_picture::imgY, macroblock::mbAddrX, macroblock::p_Img, macroblock::p_Slice, and YUV444.

Referenced by decode_one_slice().

Here is the call graph for this function:

void dectracebitcnt ( int  count  ) 

look up tables for FRExt_chroma support

Boolean exit_macroblock ( Slice currSlice,
int  eos_bit 
)

set coordinates of the next macroblock check end_of_slice condition

The if() statement below resembles the original code, which tested

p_Img->current_mb_nr == p_Img->PicSizeInMbs. Both is, of course, nonsense In an error prone environment, one can only be sure to have a new picture by checking the tr of the next slice header!

Definition at line 456 of file macroblock.c.

References FmoGetNextMBNr(), and slice::slice_type.

Referenced by decode_one_slice().

Here is the call graph for this function:

void get_neighbors ( Macroblock currMB,
PixelPos *  block,
int  mb_x,
int  mb_y,
int  blockshape_x 
)

Get current block spatial neighbors.

Definition at line 2069 of file macroblock.c.

References get4x4Neighbour(), and macroblock::p_Img.

Referenced by readMBMotionVectors().

Here is the call graph for this function:

static void init_decoding_engine_IPCM ( Slice currSlice  )  [static]

Initialize decoding engine after decoding an IPCM macroblock (for IPCM CABAC 28/11/2003).

Author:
Dong Wang <Dong.Wang@bristol.ac.uk>

Definition at line 1826 of file macroblock.c.

References arideco_start_decoding(), slice::dp_mode, PAR_DP_1, PAR_DP_3, slice::partArr, Bitstream::read_len, and Bitstream::streamBuffer.

Referenced by read_IPCM_coeffs_from_NAL().

Here is the call graph for this function:

static void init_macroblock ( Macroblock currMB  )  [static]

static void interpret_mb_mode_B ( Macroblock currMB  )  [static]

Interpret the mb mode for B-Frames.

Definition at line 592 of file macroblock.c.

Referenced by setup_slice_methods().

static void interpret_mb_mode_I ( Macroblock currMB  )  [static]

Interpret the mb mode for I-Frames.

Definition at line 556 of file macroblock.c.

Referenced by setup_slice_methods().

static void interpret_mb_mode_P ( Macroblock currMB  )  [static]

Interpret the mb mode for P-Frames.

Definition at line 501 of file macroblock.c.

References macroblock::p_Img.

Referenced by setup_slice_methods().

static void interpret_mb_mode_SI ( Macroblock currMB  )  [static]

Interpret the mb mode for SI-Frames.

Definition at line 673 of file macroblock.c.

References macroblock::p_Img.

Referenced by setup_slice_methods().

void make_frame_picture_JV ( ImageParameters *  p_Img  ) 

make frame picture from each plane data for 4:4:4 Independent mode

Definition at line 5626 of file macroblock.c.

References free_storable_picture().

Referenced by exit_picture().

Here is the call graph for this function:

int predict_nnz ( Macroblock currMB,
int  block_type,
int  i,
int  j 
)

Get the Prediction from the Neighboring Blocks for Number of Nonzero Coefficients.

Luma Blocks

Definition at line 2440 of file macroblock.c.

References error(), get4x4Neighbour(), macroblock::p_Img, and PAR_DP_3.

Referenced by readCoeff4x4_CAVLC().

Here is the call graph for this function:

int predict_nnz_chroma ( Macroblock currMB,
int  i,
int  j 
)

Get the Prediction from the Neighboring Blocks for Number of Nonzero Coefficients.

Chroma Blocks

Definition at line 2532 of file macroblock.c.

References get4x4Neighbour(), macroblock::p_Img, PAR_DP_3, and YUV444.

Referenced by readCoeff4x4_CAVLC().

Here is the call graph for this function:

static void prepareListforRefIdx ( Macroblock currMB,
SyntaxElement currSE,
DataPartition dP,
int  num_ref_idx_active,
int  refidx_present 
) [inline, static]

Function to prepare reference picture indice function pointer.

Definition at line 146 of file macroblock.c.

References Bitstream::ei_flag, linfo_ue(), syntaxelement::mapping, macroblock::p_Img, syntaxelement::reading, readRefFrame_CABAC(), readRefPictureIdx_FLC(), readRefPictureIdx_Null(), and readRefPictureIdx_VLC().

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:

static void read_CBP_and_coeffs_from_NAL_CABAC ( Macroblock currMB  )  [static]

static void read_CBP_and_coeffs_from_NAL_CAVLC ( Macroblock currMB  )  [static]

static void read_IPCM_coeffs_from_NAL ( Slice currSlice,
struct datapartition dP 
) [static]

Read IPCM pcm_alignment_zero_bit and pcm_byte[i] from stream to currSlice->cof (for IPCM CABAC and IPCM CAVLC).

Author:
Dong Wang <Dong.Wang@bristol.ac.uk>

Definition at line 1866 of file macroblock.c.

References Bitstream::frame_bitoffset, init_decoding_engine_IPCM(), syntaxelement::len, readIPCM_CABAC(), readSyntaxElement_FLC(), syntaxelement::value1, and YUV400.

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:

static void read_ipred_modes ( Macroblock currMB  )  [static]

static void read_motion_info_from_NAL_b_slice ( Macroblock currMB  )  [static]

static void read_motion_info_from_NAL_p_slice ( Macroblock currMB  )  [static]

static void read_one_macroblock_b_slice ( Macroblock currMB  )  [static]

static void read_one_macroblock_i_slice ( Macroblock currMB  )  [static]

Get the syntax elements from the NAL.

TO for error concealment If we have an INTRA Macroblock and we lost the partition which contains the intra coefficients Copy MB would be better than just a gray block. Seems to be a bit at the wrong place to do this right here, but for this case up to now there is no other way.

Definition at line 1002 of file macroblock.c.

References assignSE2partition, slice::dp_mode, slice::dpB_NotPresent, macroblock::ei_flag, Bitstream::ei_flag, init_macroblock(), syntaxelement::len, linfo_ue(), syntaxelement::mapping, pic_motion_params::mb_field, macroblock::mbAddrX, storable_picture::motion, macroblock::p_Img, macroblock::p_Slice, slice::partArr, macroblock::qp, read_IPCM_coeffs_from_NAL(), read_ipred_modes(), syntaxelement::reading, readMB_transform_size_flag_CABAC(), readMB_typeInfo_CABAC(), datapartition::readSyntaxElement, readSyntaxElement_FLC(), SE_HEADER, syntaxelement::type, update_qp(), and syntaxelement::value1.

Referenced by setup_slice_methods().

Here is the call graph for this function:

static void read_one_macroblock_p_slice ( Macroblock currMB  )  [static]

static void readCoeff4x4_CAVLC ( Macroblock currMB,
int  block_type,
int  i,
int  j,
int  levarr[16],
int  runarr[16],
int *  number_coefficients 
) [static]

static void readCompCoeff4x4MB_CABAC ( Macroblock currMB,
SyntaxElement currSE,
ColorPlane  pl,
int  intra,
int(*)  InvLevelScale4x4[4],
int  qp_per,
int  cbp 
) [static]

Get coefficients (run/level) of all 4x4 blocks in a MB from the NAL (CABAC Mode).

Definition at line 2991 of file macroblock.c.

References syntaxelement::context, macroblock::p_Img, macroblock::p_Slice, and readCompCoeff4x4SMB_CABAC().

Referenced by read_CBP_and_coeffs_from_NAL_CABAC().

Here is the call graph for this function:

static void readCompCoeff4x4MB_CAVLC ( Macroblock currMB,
ColorPlane  pl,
int(*)  InvLevelScale4x4[4],
int  qp_per,
int  cbp,
byte **  nzcoeff 
) [static]

Get coefficients (run/level) of 4x4 blocks in a MB from the NAL (CABAC Mode).

Definition at line 3249 of file macroblock.c.

References FIELD_SCAN, macroblock::p_Img, macroblock::p_Slice, readCoeff4x4_CAVLC(), and SNGL_SCAN.

Referenced by read_CBP_and_coeffs_from_NAL_CAVLC().

Here is the call graph for this function:

static void readCompCoeff4x4SMB_CABAC ( Macroblock currMB,
SyntaxElement currSE,
ColorPlane  pl,
int  block_y,
int  block_x,
int  start_scan,
int64 *  cbp_blk 
) [static]

static void readCompCoeff8x8_CABAC ( Macroblock currMB,
SyntaxElement currSE,
ColorPlane  pl,
int  b8 
) [static]

static void readCompCoeff8x8MB_CABAC ( Macroblock currMB,
SyntaxElement currSE,
ColorPlane  pl 
) [static]

Get coefficients (run/level) of 8x8 blocks in a MB from the NAL (CABAC Mode).

Definition at line 3233 of file macroblock.c.

References readCompCoeff8x8_CABAC().

Referenced by read_CBP_and_coeffs_from_NAL_CABAC().

Here is the call graph for this function:

static void readCompCoeff8x8MB_CAVLC ( Macroblock currMB,
ColorPlane  pl,
int(*)  InvLevelScale8x8[8],
int  qp_per,
int  cbp,
byte **  nzcoeff 
) [static]

Get coefficients (run/level) of 4x4 blocks in a MB from the NAL (CABAC Mode).

Definition at line 3383 of file macroblock.c.

References FIELD_SCAN8x8, macroblock::p_Img, macroblock::p_Slice, readCoeff4x4_CAVLC(), and SNGL_SCAN8x8.

Referenced by read_CBP_and_coeffs_from_NAL_CAVLC().

Here is the call graph for this function:

static void readMBMotionVectors ( SyntaxElement currSE,
DataPartition dP,
Macroblock currMB,
int  list,
int  step_h0,
int  step_v0 
) [inline, static]

static void readMBRefPictureIdx ( SyntaxElement currSE,
DataPartition dP,
Macroblock currMB,
char **  cur_ref_idx,
int  list,
int  step_v0,
int  step_h0 
) [static]

Function to read reference picture indice values.

Definition at line 233 of file macroblock.c.

Referenced by read_motion_info_from_NAL_b_slice(), and read_motion_info_from_NAL_p_slice().

static char readRefPictureIdx_FLC ( Macroblock currMB,
SyntaxElement currSE,
DataPartition dP,
char  b8mode,
int  list 
) [static]

Function for reading the reference picture indices using FLC.

Definition at line 113 of file macroblock.c.

References BType2CtxRef(), syntaxelement::context, syntaxelement::len, readSyntaxElement_FLC(), and syntaxelement::value1.

Referenced by prepareListforRefIdx().

Here is the call graph for this function:

static char readRefPictureIdx_Null ( Macroblock currMB,
SyntaxElement currSE,
DataPartition dP,
char  b8mode,
int  list 
) [static]

Dummy Function for reading the reference picture indices.

Definition at line 135 of file macroblock.c.

Referenced by prepareListforRefIdx().

static char readRefPictureIdx_VLC ( Macroblock currMB,
SyntaxElement currSE,
DataPartition dP,
char  b8mode,
int  list 
) [static]

Function for reading the reference picture indices using VLC.

Definition at line 94 of file macroblock.c.

References BType2CtxRef(), syntaxelement::context, macroblock::p_Img, datapartition::readSyntaxElement, syntaxelement::value1, and syntaxelement::value2.

Referenced by prepareListforRefIdx().

Here is the call graph for this function:

void SetB8Mode ( Macroblock currMB,
int  value,
int  i 
)

Sets mode for 8x8 block.

Definition at line 809 of file macroblock.c.

References macroblock::p_Slice, and slice::slice_type.

Referenced by read_one_macroblock_b_slice(), and read_one_macroblock_p_slice().

void setup_slice_methods ( Slice currSlice  ) 

void start_macroblock ( Slice currSlice,
Macroblock **  currMB 
)

void update_qp ( Macroblock currMB,
int  qp 
)


Documentation generated with DoxyGen