rdopt.c File Reference

Rate-Distortion optimized mode decision. More...

#include <math.h>
#include <limits.h>
#include "global.h"
#include "rdopt.h"
#include "q_around.h"
#include "rdopt_coding_state.h"
#include "memalloc.h"
#include "mb_access.h"
#include "elements.h"
#include "intrarefresh.h"
#include "image.h"
#include "transform8x8.h"
#include "cabac.h"
#include "biariencode.h"
#include "vlc.h"
#include "me_umhex.h"
#include "ratectl.h"
#include "mode_decision.h"
#include "rd_intra_jm.h"
#include "rd_intra_jm444.h"
#include "fmo.h"
#include "macroblock.h"
#include "symbol.h"
#include "q_offsets.h"
#include "conformance.h"
#include "errdo.h"
#include "mv_search.h"
#include "md_common.h"
#include "md_distortion.h"

Include dependency graph for rdopt.c:

Go to the source code of this file.

Defines

#define FASTMODE   1
#define IS_FW   ((b8x8info->best[mode][k].pdir==0 || b8x8info->best[mode][k].pdir==2) && (mode!=P8x8 || b8x8info->best[mode][k].mode!=0 || currSlice->slice_type != B_SLICE))
#define IS_BW   ((b8x8info->best[mode][k].pdir==1 || b8x8info->best[mode][k].pdir==2) && (mode!=P8x8 || b8x8info->best[mode][k].mode!=0))

Functions

static void compute_sad4x4_cost (ImageParameters *p_Img, imgpel **cur_img, imgpel **prd_img, int pic_opix_x, int *cost, int min_cost)
static void compute_sse4x4_cost (ImageParameters *p_Img, imgpel **cur_img, imgpel **prd_img, int pic_opix_x, int *cost, int min_cost)
static void compute_satd4x4_cost (ImageParameters *p_Img, imgpel **cur_img, imgpel **prd_img, int pic_opix_x, int *cost, int min_cost)
static void compute_comp4x4_cost (ImageParameters *p_Img, imgpel **cur_img, imgpel **prd_img, int pic_opix_x, int *cost, int min_cost)
static void set_stored_macroblock_parameters (Macroblock *currMB)
static void set_stored_macroblock_parameters_sp (Macroblock *currMB)
static void set_stored_macroblock_parameters_mpass (Macroblock *currMB)
static void set_ref_and_motion_vectors_P_slice (Macroblock *currMB, PicMotionParams *motion, Info8x8 *part, int block)
static void set_ref_and_motion_vectors_B_slice (Macroblock *currMB, PicMotionParams *motion, Info8x8 *part, int block)
static void copy_motion_vectors_MB (Slice *currSlice, RD_DATA *rdopt)
void alloc_rd8x8data (RD_8x8DATA *rd_data)
void free_rd8x8data (RD_8x8DATA *rd_data)
void clear_rdopt (Slice *currSlice)
void setupDistCost (Slice *currSlice, InputParameters *p_Inp)
void init_rdopt (Slice *currSlice)
void UpdatePixelMap (ImageParameters *p_Img, InputParameters *p_Inp)
int CheckReliabilityOfRef (Macroblock *currMB, int block, int list_idx, int ref, int mode)
double rdcost_for_4x4_intra_blocks (Macroblock *currMB, int *nonzero, int b8, int b4, int ipmode, double lambda, int mostProbableMode, double min_rdcost)
double rdcost_for_4x4_intra_blocks_444 (Macroblock *currMB, int *nonzero, int b8, int b4, int ipmode, double lambda, int mostProbableMode, double min_rdcost)
double RDCost_for_8x8blocks (Macroblock *currMB, RD_8x8DATA *dataTr, int *cnt_nonz, int64 *cbp_blk, double lambda, int block, short mode, Info8x8 *part, double min_rdcost)
short I16Offset (int cbp, short i16mode)
void SetModesAndRefframeForBlocks (Macroblock *currMB, short mode)
void SetCoeffAndReconstruction8x8 (Macroblock *currMB)
void restore_nz_coeff (Macroblock *currMB)
int RDCost_for_macroblocks (Macroblock *currMB, double lambda, short mode)
void init_md_best (BestMode *best)
void store_macroblock_parameters (Macroblock *currMB, int mode)
byte field_flag_inference (Macroblock *currMB)
void StoreMVBlock8x8 (Slice *currSlice, int dir, int block8x8, int mode, Info8x8 *B8x8Info)
void StoreMV8x8 (Slice *currSlice, int dir)
void RestoreMVBlock8x8 (Slice *currSlice, int dir, int block8x8, RD_8x8DATA *tr)
void RestoreMV8x8 (Slice *currSlice, int dir)
void StoreNewMotionVectorsBlock8x8 (Slice *currSlice, int dir, int block8x8, Info8x8 *B8x8Info)
int GetBestTransformP8x8 (Macroblock *currMB)
void set_mbaff_parameters (Macroblock *currMB)
void assign_enc_picture_params (Macroblock *currMB, int mode, Info8x8 *best, int block)
void set_block8x8_info (Block8x8Info *b8x8info, int mode, int block, Info8x8 *best)
void set_subblock8x8_info (Block8x8Info *b8x8info, int mode, int block, RD_8x8DATA *tr)
void update_refresh_map (Macroblock *currMB, int intra, int intra1)
int valid_intra_mode (Slice *currSlice, int ipmode)
void generate_pred_error_4x4 (imgpel **cur_img, imgpel **prd_img, imgpel **cur_prd, int **m7, int pic_opix_x, int block_x)
void generate_pred_error_8x8 (imgpel **cur_img, imgpel **prd_img, imgpel **cur_prd, int **m7, int pic_opix_x, int block_x)
void update_qp_cbp_tmp (Macroblock *currMB, int cbp)
void update_qp_cbp (Macroblock *currMB)
void copy_rdopt_data (Macroblock *currMB)


Detailed Description

Rate-Distortion optimized mode decision.

Author:
Date:
12. April 2001

Definition in file rdopt.c.


Function Documentation

int CheckReliabilityOfRef ( Macroblock currMB,
int  block,
int  list_idx,
int  ref,
int  mode 
)

Checks if a given reference frame is reliable for the current macroblock, given the motion vectors that the motion search has returned.

Returns:
If the return value is 1, the reference frame is reliable. If it is 0, then it is not reliable.
Note:
A specific area in each reference frame is assumed to be unreliable if the same area has been intra-refreshed in a subsequent frame. The information about intra-refreshed areas is kept in the p_Img->pixel_map.

Definition at line 351 of file rdopt.c.

References slice::all_mv, macroblock::block_x, macroblock::block_y, img_par::height, macroblock::p_Img, macroblock::p_slice, img_par::pixel_map, and img_par::width.

Referenced by list_prediction_cost().

void clear_rdopt ( Slice currSlice  ) 

delete structure for RD-optimized mode decision

Definition at line 92 of file rdopt.c.

References delete_coding_state(), EXTENDED, free_mem2D(), free_mem2Dint(), free_mem2Dpel(), free_mem3Dint(), free_mem3Dpel(), free_mem5Dshort(), free_mem_ACcoeff(), free_mem_ACcoeff_new(), free_mem_DCcoeff(), and inp_par_enc::ProfileIDC.

Referenced by free_slice().

Here is the call graph for this function:

void copy_rdopt_data ( Macroblock currMB  ) 

byte field_flag_inference ( Macroblock currMB  ) 

skip macroblock field inference

Returns:
inferred field flag

Definition at line 2803 of file rdopt.c.

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

Referenced by end_encode_one_macroblock(), RDCost_for_macroblocks(), writeMBLayerBSlice(), and writeMBLayerPSlice().

int GetBestTransformP8x8 ( Macroblock currMB  ) 

Makes the decision if 8x8 tranform will be used (for RD-off).

Definition at line 3061 of file rdopt.c.

References macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, and macroblock::pix_x.

Referenced by encode_one_macroblock_low().

void init_md_best ( BestMode *  best  ) 

Initialize best mode information.

Definition at line 1711 of file rdopt.c.

Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().

void init_rdopt ( Slice currSlice  ) 

double rdcost_for_4x4_intra_blocks ( Macroblock currMB,
int *  nonzero,
int  b8,
int  b4,
int  ipmode,
double  lambda,
int  mostProbableMode,
double  min_rdcost 
)

double rdcost_for_4x4_intra_blocks_444 ( Macroblock currMB,
int *  nonzero,
int  b8,
int  b4,
int  ipmode,
double  lambda,
int  mostProbableMode,
double  min_rdcost 
)

double RDCost_for_8x8blocks ( Macroblock currMB,
RD_8x8DATA *  dataTr,
int *  cnt_nonz,
int64 *  cbp_blk,
double  lambda,
int  block,
short  mode,
Info8x8 part,
double  min_rdcost 
)

int RDCost_for_macroblocks ( Macroblock currMB,
double  lambda,
short  mode 
)

void restore_nz_coeff ( Macroblock currMB  ) 

Restore Non zero coefficients.

Definition at line 1441 of file rdopt.c.

References macroblock::mbAddrX, img_par::nz_coeff, and macroblock::p_Img.

Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), and encode_one_macroblock_highloss().

void RestoreMV8x8 ( Slice currSlice,
int  dir 
)

Restore motion vectors of 8x8 partitions of one macroblock.

Definition at line 2971 of file rdopt.c.

References RestoreMVBlock8x8().

Referenced by set_stored_macroblock_parameters(), set_stored_macroblock_parameters_mpass(), set_stored_macroblock_parameters_sp(), and SetCoeffAndReconstruction8x8().

Here is the call graph for this function:

void RestoreMVBlock8x8 ( Slice currSlice,
int  dir,
int  block8x8,
RD_8x8DATA *  tr 
)

Restore motion vectors for 8x8 partition.

Definition at line 2909 of file rdopt.c.

References slice::all_mv, slice::bipred_mv, error(), and slice::slice_type.

Referenced by RestoreMV8x8().

Here is the call graph for this function:

void set_block8x8_info ( Block8x8Info b8x8info,
int  mode,
int  block,
Info8x8 best 
)

Set block 8x8 mode information.

Definition at line 3306 of file rdopt.c.

Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().

void set_mbaff_parameters ( Macroblock currMB  ) 

static void set_ref_and_motion_vectors_B_slice ( Macroblock currMB,
PicMotionParams motion,
Info8x8 pred,
int  block 
) [static]

Set reference frames and motion vectors.

Definition at line 2621 of file rdopt.c.

References slice::all_mv, slice::bipred_mv, macroblock::block_x, macroblock::block_y, slice::direct_ref_idx, is_bipred_enabled(), pic_motion_params::mv, macroblock::p_Img, macroblock::p_slice, pic_motion_params::ref_idx, and pic_motion_params::ref_pic_id.

Referenced by init_rdopt().

Here is the call graph for this function:

void set_ref_and_motion_vectors_P_slice ( Macroblock currMB,
PicMotionParams motion,
Info8x8 pred,
int  block 
) [static]

static void set_stored_macroblock_parameters ( Macroblock currMB  )  [static]

static void set_stored_macroblock_parameters_mpass ( Macroblock currMB  )  [static]

static void set_stored_macroblock_parameters_sp ( Macroblock currMB  )  [static]

void set_subblock8x8_info ( Block8x8Info b8x8info,
int  mode,
int  block,
RD_8x8DATA *  tr 
)

Set block 8x8 mode information for P8x8 mode.

Definition at line 3339 of file rdopt.c.

Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().

void SetCoeffAndReconstruction8x8 ( Macroblock currMB  ) 

void SetModesAndRefframeForBlocks ( Macroblock currMB,
short  mode 
)

void store_macroblock_parameters ( Macroblock currMB,
int  mode 
)

void StoreMV8x8 ( Slice currSlice,
int  dir 
)

Store motion vectors of 8x8 partitions of one macroblock.

Definition at line 2894 of file rdopt.c.

References StoreMVBlock8x8().

Referenced by SetCoeffAndReconstruction8x8().

Here is the call graph for this function:

void StoreMVBlock8x8 ( Slice currSlice,
int  dir,
int  block8x8,
int  mode,
Info8x8 B8x8Info 
)

Store motion vectors for 8x8 partition.

Definition at line 2831 of file rdopt.c.

References slice::all_mv, slice::bipred_mv, error(), and slice::slice_type.

Referenced by StoreMV8x8().

Here is the call graph for this function:

void StoreNewMotionVectorsBlock8x8 ( Slice currSlice,
int  dir,
int  block8x8,
Info8x8 B8x8Info 
)

Store predictors for 8x8 partition.

Definition at line 2987 of file rdopt.c.

References slice::all_mv, slice::bipred_mv, and slice::slice_type.

Referenced by submacroblock_mode_decision(), and submacroblock_mode_decision_low().

void update_qp_cbp ( Macroblock currMB  ) 

Update QP Parameters (in case of SKIP MBs or MBAFF).

Definition at line 3542 of file rdopt.c.

References inp_par_enc::MbInterlace, macroblock::p_Img, macroblock::p_slice, img_par::qp, macroblock::qp, and update_qp().

Referenced by end_encode_one_macroblock().

Here is the call graph for this function:

void UpdatePixelMap ( ImageParameters p_Img,
InputParameters p_Inp 
)

Updates the pixel map that shows, which reference frames are reliable for each MB-area of the picture.

Note:
The new values of the p_Img->pixel_map are taken from the temporary buffer p_Img->refresh_map

Definition at line 302 of file rdopt.c.

References img_par::height, inp_par_enc::num_ref_frames, img_par::pixel_map, img_par::refresh_map, and img_par::width.

Referenced by encode_one_frame().


Documentation generated with DoxyGen