void SubpelRefine::DoBlock(const int xblock , const int yblock , BlockMatcher& my_bmatch, MEData& me_data , const int ref_id ) { // For each block, home into the sub-pixel vector // Provide aliases for the appropriate motion vector data components MvArray& mv_array = me_data.Vectors( ref_id ); const MVector mv_pred = GetPred( xblock , yblock , mv_array ); const float loc_lambda = me_data.LambdaMap()[yblock][xblock]; my_bmatch.RefineMatchSubp( xblock , yblock , mv_pred, loc_lambda ); }
void ModeDecider::DoModeDecn(const FrameBuffer& my_buffer, int frame_num, MEData& me_data) { // We've got 'raw' block motion vectors for up to two reference frames. Now we want // to make a decision as to mode. In this initial implementation, this is bottom-up // i.e. find mvs for MBs and sub-MBs and see whether it's worthwhile merging. int ref1,ref2; // Initialise // //////////////// fsort = my_buffer.GetFrame(frame_num).GetFparams().FSort(); if (fsort.IsInter()) { // Extract the references const vector<int>& refs = my_buffer.GetFrame(frame_num).GetFparams().Refs(); num_refs = refs.size(); ref1 = refs[0]; // The picture we're doing estimation from m_pic_data = &(my_buffer.GetComponent( frame_num , Y_COMP)); // Set up the hierarchy of motion vector data objects m_me_data_set[0] = new MEData( m_encparams.XNumMB() , m_encparams.YNumMB() , m_encparams.XNumBlocks()/4 , m_encparams.YNumBlocks()/4, num_refs ); m_me_data_set[1] = new MEData( m_encparams.XNumMB() , m_encparams.YNumMB() , m_encparams.XNumBlocks()/2 , m_encparams.YNumBlocks()/2, num_refs ); m_me_data_set[2] = &me_data; // Set up the lambdas to use per block m_me_data_set[0]->SetLambdaMap( 0 , me_data.LambdaMap() , 1.0/m_level_factor[0] ); m_me_data_set[1]->SetLambdaMap( 1 , me_data.LambdaMap() , 1.0/m_level_factor[1] ); // Set up the reference pictures m_ref1_updata = &(my_buffer.GetUpComponent( ref1 , Y_COMP)); if (num_refs>1) { ref2 = refs[1]; m_ref2_updata = &(my_buffer.GetUpComponent( ref2 , Y_COMP)); // Create an object for computing bi-directional prediction calculations if ( m_encparams.MVPrecision()==MV_PRECISION_EIGHTH_PIXEL ) m_bicheckdiff = new BiBlockEighthPel( *m_ref1_updata , *m_ref2_updata , *m_pic_data ); else if ( m_encparams.MVPrecision()==MV_PRECISION_QUARTER_PIXEL ) m_bicheckdiff = new BiBlockQuarterPel( *m_ref1_updata , *m_ref2_updata , *m_pic_data ); else m_bicheckdiff = new BiBlockHalfPel( *m_ref1_updata , *m_ref2_updata , *m_pic_data ); } else { ref2 = ref1; } // Create an object for doing intra calculations m_intradiff = new IntraBlockDiff( *m_pic_data ); // Loop over all the macroblocks, doing the work // /////////////////////////////////////////////////// for (m_ymb_loc=0 ; m_ymb_loc<m_encparams.YNumMB() ; ++m_ymb_loc ) { for (m_xmb_loc=0 ; m_xmb_loc<m_encparams.XNumMB(); ++m_xmb_loc ) { DoMBDecn(); }//m_xmb_loc }//m_ymb_loc delete m_intradiff; if (num_refs>1) delete m_bicheckdiff; } }