#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"

Go to the source code of this file.
Functions | |
| void | reset_valid_modes (RD_PARAMS *enc_mb) |
| void | init_enc_mb_params (Macroblock *currMB, RD_PARAMS *enc_mb, int intra, int bslice) |
| void | list_prediction_cost (Macroblock *currMB, int list, int block, int mode, RD_PARAMS *enc_mb, int bmcost[5], char best_ref[2]) |
| int | compute_ref_cost (RD_PARAMS *enc_mb, int ref, int list) |
| void | determine_prediction_list (int mode, int bmcost[5], char best_ref[2], char *best_pdir, int *cost, short *bipred_me) |
| void | compute_mode_RD_cost (Slice *currSlice, Macroblock *currMB, RD_PARAMS *enc_mb, int mode, double *min_rdcost, double *min_dcost, double *min_rate, int i16mode, short bslice, short *inter_skip, int is_cavlc) |
| void | submacroblock_mode_decision (Slice *currSlice, RD_PARAMS *enc_mb, RD_8x8DATA *dataTr, Macroblock *currMB, int ****cofACtr, int *have_direct, short bslice, int block, int *cost_direct, int *cost, int *cost8x8_direct, int transform8x8, int is_cavlc) |
| void | submacroblock_mode_decision_low (Slice *currSlice, RD_PARAMS *enc_mb, RD_8x8DATA *dataTr, Macroblock *currMB, int ****cofACtr, int *have_direct, short bslice, int block, int *cost_direct, int *cost, int *cost8x8_direct, int transform8x8, int is_cavlc) |
| int | check_for_SI16 () |
| void | get_initial_mb16x16_cost (Macroblock *currMB) |
| void | adjust_mb16x16_cost (int cost) |
| void | update_lambda_costs (RD_PARAMS *enc_mb, int lambda_mf[3]) |
| int | iminarray (int arr[], int size, int *minind) |
| int | is_bipred_enabled (int mode) |
| int | transform_termination_control (Macroblock *currMB, int mode, int bslice) |
| int | bslice_16x16_termination_control (Block8x8Info *b8x8info, int *ctr16x16, int mode, int bslice) |
Variables | |
| const int | b8_mode_table [6] = {0, 4, 5, 6, 7} |
| const int | mb_mode_table [9] = {0, 1, 2, 3, P8x8, I16MB, I4MB, I8MB, IPCM} |
| int | luma_transform_size_8x8_flag |
Definition in file mode_decision.c.
| int bslice_16x16_termination_control | ( | Block8x8Info * | b8x8info, | |
| int * | ctr16x16, | |||
| int | mode, | |||
| int | bslice | |||
| ) |
Update prediction direction for mode P16x16 to check all prediction directions.
Definition at line 1342 of file mode_decision.c.
References Block8x8Info::best8x8pdir, Block8x8Info::bipred8x8me, InputParameters::BiPredMotionEstimation, and error().
Referenced by compute_mode_RD_cost().

| int check_for_SI16 | ( | void | ) |
Checks whether a primary SP slice macroblock was encoded as I16.
Definition at line 1196 of file mode_decision.c.
References ImageParameters::pix_x, and ImageParameters::pix_y.
Referenced by init_enc_mb_params().
| void compute_mode_RD_cost | ( | Slice * | currSlice, | |
| Macroblock * | currMB, | |||
| RD_PARAMS * | enc_mb, | |||
| int | mode, | |||
| double * | min_rdcost, | |||
| double * | min_dcost, | |||
| double * | min_rate, | |||
| int | i16mode, | |||
| short | bslice, | |||
| short * | inter_skip, | |||
| int | is_cavlc | |||
| ) |
RD decision process.
Definition at line 310 of file mode_decision.c.
References ImageParameters::AdaptiveRounding, ImageParameters::ARCofAdj4x4, ImageParameters::ARCofAdj8x8, ImageParameters::b8x8info, bslice_16x16_termination_control(), macroblock::c_ipred_mode, macroblock::cbp, ImageParameters::cofAC, InputParameters::EarlySkipEnable, InputParameters::FastCrIntraDecision, ImageParameters::lossless_qpprime_flag, macroblock::luma_transform_size_8x8_flag, InputParameters::nobskip, ImageParameters::NoResidueDirect, ImageParameters::opix_x, ImageParameters::opix_y, macroblock::qp_scaled, rc_store_diff(), InputParameters::RCEnable, RDCost_for_macroblocks(), InputParameters::rdopt, reset_adaptive_rounding_direct(), SetModesAndRefframeForBlocks(), store_macroblock_parameters(), InputParameters::Transform8x8Mode, 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 | mode, | |
| int | bmcost[5], | |||
| char | best_ref[2], | |||
| char * | best_pdir, | |||
| int * | cost, | |||
| short * | bipred_me | |||
| ) |
Determination of prediction list based on simple distortion computation.
Definition at line 284 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().

| int iminarray | ( | int | arr[], | |
| int | size, | |||
| int * | minind | |||
| ) |
Return array's minimum and its index.
Definition at line 1256 of file mode_decision.c.
Referenced by determine_prediction_list().
| void init_enc_mb_params | ( | Macroblock * | currMB, | |
| RD_PARAMS * | enc_mb, | |||
| int | intra, | |||
| int | bslice | |||
| ) |
Initialize Encoding parameters for Macroblock.
Definition at line 55 of file mode_decision.c.
References macroblock::c_ipred_mode, check_for_SI16(), storable_picture::chroma_vector_adjustment, InputParameters::DisableIntra16x16, InputParameters::DisableIntra4x4, InputParameters::DisableIntraInInter, InputParameters::EnableIPCM, F_PEL, H_PEL, InputParameters::InterSearch, ImageParameters::lambda_md, ImageParameters::lambda_me, ImageParameters::lambda_mf, macroblock::list_offset, ImageParameters::masterQP, macroblock::mb_field, macroblock::mb_nr, ImageParameters::MbaffFrameFlag, ImageParameters::nal_reference_idc, Q_PEL, ImageParameters::qp, InputParameters::RDOQ_CP_Mode, reset_valid_modes(), storable_picture::structure, ImageParameters::structure, InputParameters::Transform8x8Mode, ImageParameters::type, and InputParameters::UseRDOQuant.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().

| int is_bipred_enabled | ( | int | mode | ) |
Determines whether bi prediction is enabaled for current mode.
Definition at line 1278 of file mode_decision.c.
References InputParameters::BiPredMotionEstimation, and InputParameters::BiPredSearch.
Referenced by BlockMotionSearch(), ChromaPrediction(), ChromaPrediction4x4(), encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), encode_one_macroblock_low(), LumaPrediction(), set_stored_macroblock_parameters(), SetRefAndMotionVectors(), 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 202 of file mode_decision.c.
References BIDPartitionCost(), BPredPartitionCost(), ImageParameters::checkref, CheckReliabilityOfRef(), Q_PEL, InputParameters::rdopt, InputParameters::RestrictRef, InputParameters::sp2_frame_indicator, InputParameters::sp_output_indicator, and ImageParameters::type.
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 reset_valid_modes | ( | RD_PARAMS * | enc_mb | ) |
Reset Valid Modes.
Definition at line 43 of file mode_decision.c.
Referenced by init_enc_mb_params().
| void submacroblock_mode_decision | ( | Slice * | currSlice, | |
| RD_PARAMS * | enc_mb, | |||
| RD_8x8DATA * | dataTr, | |||
| Macroblock * | currMB, | |||
| int **** | cofACtr, | |||
| int * | have_direct, | |||
| short | bslice, | |||
| int | block, | |||
| int * | cost_direct, | |||
| int * | cost, | |||
| int * | cost8x8_direct, | |||
| int | transform8x8, | |||
| int | is_cavlc | |||
| ) |
Mode Decision for an 8x8 sub-macroblock.
Definition at line 407 of file mode_decision.c.
References ImageParameters::all_mv, ImageParameters::ARCofAdj4x4, ImageParameters::ARCofAdj8x8, macroblock::b8mode, ImageParameters::bipred_mv, ImageParameters::block_x, ImageParameters::block_y, ImageParameters::cofAC, InputParameters::CtxAdptLagrangeMult, Decoders::dec_mb_pred, Decoders::dec_mb_pred_best8x8, Decoders::dec_mbY_best8x8, determine_prediction_list(), direct_pdir, direct_ref_idx, errdo_get_best_block(), errdo_store_best_block(), F_PEL, H_PEL, storable_picture::imgUV, storable_picture::imgY, is_bipred_enabled(), list_prediction_cost(), macroblock::luma_transform_size_8x8_flag, macroblock::mb_nr, ImageParameters::mb_pred, storable_picture::motion, pic_motion_params::mv, ImageParameters::nz_coeff, ImageParameters::P444_joined, storable_picture::p_dec_img, PartitionMotionSearch(), ImageParameters::pix_x, ImageParameters::pix_y, Q_PEL, RDCost_for_8x8blocks(), InputParameters::rdopt, pic_motion_params::ref_idx, pic_motion_params::ref_pic_id, storable_picture::ref_pic_num, reset_coding_state(), SetRefAndMotionVectors(), store_coding_state(), StoreNewMotionVectorsBlock8x8(), ImageParameters::type, update_adaptive_rounding_8x8(), and macroblock::valid_8x8.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), and encode_one_macroblock_highloss().

| void submacroblock_mode_decision_low | ( | Slice * | currSlice, | |
| RD_PARAMS * | enc_mb, | |||
| RD_8x8DATA * | dataTr, | |||
| Macroblock * | currMB, | |||
| int **** | cofACtr, | |||
| int * | have_direct, | |||
| short | bslice, | |||
| int | block, | |||
| int * | cost_direct, | |||
| int * | cost, | |||
| int * | cost8x8_direct, | |||
| int | transform8x8, | |||
| int | is_cavlc | |||
| ) |
Low Complexity Mode Decision for an 8x8 sub-macroblock.
Definition at line 779 of file mode_decision.c.
References macroblock::ar_mode, ImageParameters::ARCofAdj4x4, ImageParameters::ARCofAdj8x8, macroblock::b8mode, B8Mode2Value(), macroblock::bipred_me, ImageParameters::block_x, ImageParameters::block_y, ImageParameters::cofAC, InputParameters::CtxAdptLagrangeMult, determine_prediction_list(), direct_pdir, direct_ref_idx, F_PEL, GetDirectCost8x8(), H_PEL, storable_picture::imgUV, storable_picture::imgY, is_bipred_enabled(), list_prediction_cost(), macroblock::luma_transform_size_8x8_flag, LumaResidualCoding8x8(), macroblock::mb_nr, ImageParameters::mb_pred, storable_picture::motion, ImageParameters::nz_coeff, ImageParameters::P444_joined, PartitionMotionSearch(), ImageParameters::pix_x, ImageParameters::pix_y, Q_PEL, pic_motion_params::ref_idx, pic_motion_params::ref_pic_id, storable_picture::ref_pic_num, reset_coding_state(), SetRefAndMotionVectors(), store_coding_state(), StoreNewMotionVectorsBlock8x8(), InputParameters::Transform8x8Mode, ImageParameters::type, update_adaptive_rounding_8x8(), and macroblock::valid_8x8.
Referenced by encode_one_macroblock_low().

| int transform_termination_control | ( | Macroblock * | currMB, | |
| int | mode, | |||
| int | bslice | |||
| ) |
Decides whether to perform tranform 8x8 for this mode.
Definition at line 1308 of file mode_decision.c.
References macroblock::luma_transform_size_8x8_flag, and InputParameters::Transform8x8Mode.
Referenced by compute_mode_RD_cost().