/* ***** BEGIN LICENSE BLOCK ***** * * $Id: me_subpel.cpp,v 1.14 2006/04/20 10:41:58 asuraparaju Exp $ $Name: Dirac_0_7_0 $ * * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is BBC Research and Development code. * * The Initial Developer of the Original Code is the British Broadcasting * Corporation. * Portions created by the Initial Developer are Copyright (C) 2004. * All Rights Reserved. * * Contributor(s): Thomas Davies (Original Author) * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser * Public License Version 2.1 (the "LGPL"), in which case the provisions of * the GPL or the LGPL are applicable instead of those above. If you wish to * allow use of your version of this file only under the terms of the either * the GPL or LGPL and not to allow others to use your version of this file * under the MPL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by the GPL * or LGPL. If you do not delete the provisions above, a recipient may use * your version of this file under the terms of any one of the MPL, the GPL * or the LGPL. * ***** END LICENSE BLOCK ***** */ #include #include using namespace dirac; #include using std::vector; SubpelRefine::SubpelRefine(const EncoderParams& encp): m_encparams(encp), m_nshift(4) { //define the relative coordinates of the four neighbours m_nshift[0].x = -1; m_nshift[0].y = 0; m_nshift[1].x = -1; m_nshift[1].y = -1; m_nshift[2].x = 0; m_nshift[2].y = -1; m_nshift[3].x = 1; m_nshift[3].y = -1; } void SubpelRefine::DoSubpel(const FrameBuffer& my_buffer,int frame_num, MEData& me_data) { //main loop for the subpel refinement int ref1,ref2; const FrameSort fsort = my_buffer.GetFrame(frame_num).GetFparams().FSort(); if (fsort.IsInter()) { // Get the references const vector& refs = my_buffer.GetFrame(frame_num).GetFparams().Refs(); int num_refs = refs.size(); ref1 = refs[0]; if (num_refs>1) ref2 = refs[1]; else ref2 = ref1; const PicArray& pic_data = my_buffer.GetComponent(frame_num , Y_COMP); const PicArray& refup1_data = my_buffer.GetUpComponent( ref1 , Y_COMP); const PicArray& refup2_data = my_buffer.GetUpComponent( ref2 , Y_COMP); // Now match the pictures MatchPic( pic_data , refup1_data , me_data ,1 ); if (ref1 != ref2 ) MatchPic( pic_data , refup2_data , me_data ,2 ); } } void SubpelRefine::MatchPic(const PicArray& pic_data , const PicArray& refup_data , MEData& me_data , int ref_id) { // Match a picture against a single reference. Loop over all the blocks // doing the matching // Initialisation // //////////////////// // Provide aliases for the appropriate motion vector data components MvArray& mv_array = me_data.Vectors( ref_id ); TwoDArray& pred_costs = me_data.PredCosts( ref_id ); // Provide a block matching object to do the work BlockMatcher my_bmatch( pic_data , refup_data , m_encparams.LumaBParams(2) , m_encparams.MVPrecision() , mv_array , pred_costs ); // Do the work // ///////////////// // Loop over all the blocks, doing the work for (int yblock=0 ; yblock neighbours; if (xblock>0 && yblock>0 && xblock=0 && n_coords.y>=0 && n_coords.x