#include <math.h>
#include <limits.h>
#include <float.h>
#include "global.h"
#include "rdopt_coding_state.h"
#include "mb_access.h"
#include "intrarefresh.h"
#include "image.h"
#include "transform8x8.h"
#include "ratectl.h"
#include "mode_decision.h"
#include "fmo.h"
#include "me_umhex.h"
#include "me_umhexsmp.h"
#include "macroblock.h"
#include "rdoq.h"
#include "errdo.h"
#include "q_around.h"
#include "slice.h"
#include "md_common.h"
#include "conformance.h"
#include "rdopt.h"
Go to the source code of this file.
Functions | |
void | reset_valid_modes (RD_PARAMS *enc_mb) |
static int | check_for_SI16 (int **lrec, int pix_x, int pix_y) |
void | end_encode_one_macroblock (Macroblock *currMB) |
void | init_enc_mb_params (Macroblock *currMB, RD_PARAMS *enc_mb, int intra) |
void | list_prediction_cost (Macroblock *currMB, int list, int block, int mode, RD_PARAMS *enc_mb, int bmcost[5], char best_ref[2]) |
static int | compute_ref_cost (ImageParameters *p_Img, RD_PARAMS *enc_mb, int ref, int list) |
void | determine_prediction_list (int bmcost[5], Info8x8 *best, int *cost) |
void | compute_mode_RD_cost (Macroblock *currMB, RD_PARAMS *enc_mb, short mode, short *inter_skip) |
void | submacroblock_mode_decision (Macroblock *currMB, RD_PARAMS *enc_mb, RD_8x8DATA *dataTr, int ****cofACtr, int block, int *cost) |
void | submacroblock_mode_decision_low (Macroblock *currMB, RD_PARAMS *enc_mb, RD_8x8DATA *dataTr, int ****cofACtr, int *have_direct, int block, int *cost_direct, int *cost, int *cost8x8_direct, int transform8x8) |
void | get_initial_mb16x16_cost (Macroblock *currMB) |
void | adjust_mb16x16_cost (Macroblock *currMB, int cost) |
void | update_lambda_costs (Macroblock *currMB, RD_PARAMS *enc_mb, int lambda_mf[3]) |
int | iminarray (int arr[], int size, int *minind) |
int | is_bipred_enabled (InputParameters *p_Inp, int mode) |
int | transform_termination_control (Macroblock *currMB, int mode) |
int | bslice_16x16_termination_control (InputParameters *p_Inp, Block8x8Info *b8x8info, int *ctr16x16, int mode, int bslice) |
void | get_bipred_cost (Macroblock *currMB, int mode, int block, int i, int j, Info8x8 *best, RD_PARAMS *enc_mb, int bmcost[5]) |
Definition in file mode_decision.c.
int bslice_16x16_termination_control | ( | InputParameters * | p_Inp, | |
Block8x8Info * | b8x8info, | |||
int * | ctr16x16, | |||
int | mode, | |||
int | bslice | |||
) |
Update prediction direction for mode P16x16 to check all prediction directions.
Definition at line 1424 of file mode_decision.c.
References inp_par_enc::BiPredMotionEstimation, and error().
Referenced by compute_mode_RD_cost().
static int check_for_SI16 | ( | int ** | lrec, | |
int | pix_x, | |||
int | pix_y | |||
) | [inline, static] |
Checks whether a primary SP slice macroblock was encoded as I16.
Definition at line 56 of file mode_decision.c.
Referenced by init_enc_mb_params().
void compute_mode_RD_cost | ( | Macroblock * | currMB, | |
RD_PARAMS * | enc_mb, | |||
short | mode, | |||
short * | inter_skip | |||
) |
RD decision process.
Definition at line 385 of file mode_decision.c.
References img_par::AdaptiveRounding, img_par::ARCofAdj4x4, img_par::ARCofAdj8x8, img_par::b8x8info, bslice_16x16_termination_control(), macroblock::c_ipred_mode, slice::cofAC, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, macroblock::pix_x, macroblock::qp_scaled, rc_store_diff(), inp_par_enc::RCEnable, RDCost_for_macroblocks(), reset_adaptive_rounding_direct(), SetModesAndRefframeForBlocks(), slice::slice_type, store_macroblock_parameters(), transform_termination_control(), and update_adaptive_rounding_16x16().
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), and encode_one_macroblock_highloss().
void determine_prediction_list | ( | int | bmcost[5], | |
Info8x8 * | best, | |||
int * | cost | |||
) |
Determination of prediction list based on simple distortion computation.
Definition at line 358 of file mode_decision.c.
References iminarray().
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), encode_one_macroblock_low(), submacroblock_mode_decision(), and submacroblock_mode_decision_low().
void end_encode_one_macroblock | ( | Macroblock * | currMB | ) |
Update parameters after encoding a macroblock.
Definition at line 74 of file mode_decision.c.
References field_flag_inference(), macroblock::mb_type, macroblock::mbAddrX, macroblock::p_Img, macroblock::p_slice, slice::slice_type, smpUMHEX_skip_intrabk_SAD(), update_qp_cbp(), and inp_par_enc::UseConstrainedIntraPred.
Referenced by encode_one_slice(), and encode_one_slice_MBAFF().
void get_bipred_cost | ( | Macroblock * | currMB, | |
int | mode, | |||
int | block, | |||
int | i, | |||
int | j, | |||
Info8x8 * | best, | |||
RD_PARAMS * | enc_mb, | |||
int | bmcost[5] | |||
) |
Compute bipred costs.
Definition at line 1480 of file mode_decision.c.
References slice::all_mv, slice::bipred_mv, list_prediction_cost(), and macroblock::p_slice.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and submacroblock_mode_decision().
int iminarray | ( | int | arr[], | |
int | size, | |||
int * | minind | |||
) |
Return array's minimum and its index.
Definition at line 1332 of file mode_decision.c.
Referenced by determine_prediction_list().
void init_enc_mb_params | ( | Macroblock * | currMB, | |
RD_PARAMS * | enc_mb, | |||
int | intra | |||
) |
Initialize Encoding parameters for Macroblock.
Definition at line 120 of file mode_decision.c.
References macroblock::c_ipred_mode, check_for_SI16(), F_PEL, H_PEL, img_par::lambda_md, img_par::lambda_me, img_par::lambda_mf, img_par::masterQP, macroblock::mbAddrX, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, Q_PEL, img_par::qp, reset_valid_modes(), slice::slice_type, smpUMHEX_decide_intrabk_SAD(), UMHEX_decide_intrabk_SAD(), and UMHEX_DefineThresholdMB().
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().
int is_bipred_enabled | ( | InputParameters * | p_Inp, | |
int | mode | |||
) |
Determines whether bi prediction is enabaled for current mode.
Definition at line 1354 of file mode_decision.c.
References inp_par_enc::BiPredMotionEstimation, and inp_par_enc::BiPredSearch.
Referenced by BlockMotionSearch(), chroma_prediction(), chroma_prediction_4x4(), encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), encode_one_macroblock_low(), luma_prediction(), set_ref_and_motion_vectors_B_slice(), set_stored_macroblock_parameters(), set_stored_macroblock_parameters_mpass(), set_stored_macroblock_parameters_sp(), submacroblock_mode_decision(), submacroblock_mode_decision_low(), and writeMotionVector8x8().
void list_prediction_cost | ( | Macroblock * | currMB, | |
int | list, | |||
int | block, | |||
int | mode, | |||
RD_PARAMS * | enc_mb, | |||
int | bmcost[5], | |||
char | best_ref[2] | |||
) |
computation of prediction list (including biprediction) cost
Definition at line 279 of file mode_decision.c.
References BIDPartitionCost(), BPredPartitionCost(), CheckReliabilityOfRef(), macroblock::p_Img, macroblock::p_slice, Q_PEL, slice::slice_type, inp_par_enc::sp2_frame_indicator, inp_par_enc::sp_output_indicator, and slice::wbp_weight.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), encode_one_macroblock_low(), get_bipred_cost(), submacroblock_mode_decision(), and submacroblock_mode_decision_low().
void reset_valid_modes | ( | RD_PARAMS * | enc_mb | ) |
Reset Valid Modes.
Definition at line 44 of file mode_decision.c.
Referenced by init_enc_mb_params().
void submacroblock_mode_decision | ( | Macroblock * | currMB, | |
RD_PARAMS * | enc_mb, | |||
RD_8x8DATA * | dataTr, | |||
int **** | cofACtr, | |||
int | block, | |||
int * | cost | |||
) |
Mode Decision for an 8x8 sub-macroblock.
Definition at line 509 of file mode_decision.c.
References slice::all_mv, img_par::ARCofAdj4x4, img_par::ARCofAdj8x8, slice::bipred_mv, macroblock::block_x, macroblock::block_y, slice::cofAC, copy_image_data_8x8(), inp_par_enc::CtxAdptLagrangeMult, decoders::dec_mb_pred, decoders::dec_mb_pred_best8x8, decoders::dec_mbY_best8x8, determine_prediction_list(), slice::direct_pdir, slice::direct_ref_idx, errdo_get_best_block(), errdo_store_best_block(), F_PEL, get_bipred_cost(), H_PEL, storable_picture::imgUV, storable_picture::imgY, is_bipred_enabled(), list_prediction_cost(), slice::mb_pred, macroblock::mbAddrX, storable_picture::motion, pic_motion_params::mv, img_par::nz_coeff, storable_picture::p_dec_img, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, Q_PEL, RDCost_for_8x8blocks(), pic_motion_params::ref_idx, pic_motion_params::ref_pic_id, slice::slice_type, StoreNewMotionVectorsBlock8x8(), SubPartitionMotionSearch(), and update_adaptive_rounding_8x8().
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), and encode_one_macroblock_highloss().
void submacroblock_mode_decision_low | ( | Macroblock * | currMB, | |
RD_PARAMS * | enc_mb, | |||
RD_8x8DATA * | dataTr, | |||
int **** | cofACtr, | |||
int * | have_direct, | |||
int | block, | |||
int * | cost_direct, | |||
int * | cost, | |||
int * | cost8x8_direct, | |||
int | transform8x8 | |||
) |
Low Complexity Mode Decision for an 8x8 sub-macroblock.
Definition at line 862 of file mode_decision.c.
References macroblock::ar_mode, img_par::ARCofAdj4x4, img_par::ARCofAdj8x8, B8Mode2Value(), macroblock::block_x, macroblock::block_y, slice::cofAC, copy_image_data_8x8(), inp_par_enc::CtxAdptLagrangeMult, determine_prediction_list(), slice::direct_pdir, slice::direct_ref_idx, F_PEL, GetDirectCost8x8(), H_PEL, storable_picture::imgUV, storable_picture::imgY, is_bipred_enabled(), img_par::lambda_mf, list_prediction_cost(), luma_residual_coding_8x8(), luma_residual_coding_p444_8x8(), slice::mb_pred, macroblock::mbAddrX, storable_picture::motion, img_par::nz_coeff, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, macroblock::pix_y, Q_PEL, pic_motion_params::ref_idx, pic_motion_params::ref_pic_id, slice::slice_type, StoreNewMotionVectorsBlock8x8(), SubPartitionMotionSearch(), and update_adaptive_rounding_8x8().
Referenced by encode_one_macroblock_low().
int transform_termination_control | ( | Macroblock * | currMB, | |
int | mode | |||
) |
Decides whether to perform tranform 8x8 for this mode.
Definition at line 1384 of file mode_decision.c.
References macroblock::p_Img, macroblock::p_slice, and slice::slice_type.
Referenced by compute_mode_RD_cost().