Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: block_match.h,v 1.10 2007/09/03 14:52:40 asuraparaju Exp $ $Name: Dirac_1_0_2 $ 00004 * 00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 * 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.1 (the "License"); you may not use this file except in compliance 00009 * with the License. You may obtain a copy of the License at 00010 * http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" basis, 00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 00014 * the specific language governing rights and limitations under the License. 00015 * 00016 * The Original Code is BBC Research and Development code. 00017 * 00018 * The Initial Developer of the Original Code is the British Broadcasting 00019 * Corporation. 00020 * Portions created by the Initial Developer are Copyright (C) 2004. 00021 * All Rights Reserved. 00022 * 00023 * Contributor(s): Thomas Davies (Original Author) 00024 * 00025 * Alternatively, the contents of this file may be used under the terms of 00026 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00027 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00028 * the GPL or the LGPL are applicable instead of those above. If you wish to 00029 * allow use of your version of this file only under the terms of the either 00030 * the GPL or LGPL and not to allow others to use your version of this file 00031 * under the MPL, indicate your decision by deleting the provisions above 00032 * and replace them with the notice and other provisions required by the GPL 00033 * or LGPL. If you do not delete the provisions above, a recipient may use 00034 * your version of this file under the terms of any one of the MPL, the GPL 00035 * or the LGPL. 00036 * ***** END LICENSE BLOCK ***** */ 00037 00038 #ifndef _BLOCK_MATCH_H_ 00039 #define _BLOCK_MATCH_H_ 00040 00041 #include <libdirac_motionest/me_utils.h> 00042 #include <vector> 00043 //handles the business of finding the best block match 00044 00045 namespace dirac 00046 { 00047 00048 typedef std::vector< std::vector< MVector > > CandidateList; 00049 00051 /* 00052 Add a new motion vector list to the set of lists consisting of the 00053 square neighbourhood [mv.x-xr,mv.x+xr] by 00054 [mv.y-yr,mv.y+yr]. Vectors that already occur in previous lists are 00055 not added. 00056 */ 00057 void AddNewVlist( CandidateList& vect_list , const MVector& mv , const int xr , const int yr ); 00058 00060 /* 00061 Add a new motion vector list to the set of lists consisting of the 00062 vectors of the form (mv.x+m*step,mv.y+n*step) where m lies between 00063 -xr and xr and n lies between -yr and yr. Vectors that already occur 00064 in previous lists are not added. 00065 */ 00066 void AddNewVlist( CandidateList& vect_list , const MVector& mv , const int xr , const int yr , const int step ); 00067 00069 /* 00070 Add a new motion vector list to the set of lists consisting of the 00071 diagonal neighbourhood of height 2yr+1 pixels and width 2xr+1 centred 00072 on \param mv. 00073 Vectors that already occur in previous lists are not added. 00074 */ 00075 void AddNewVlistD( CandidateList& vect_list , const MVector& mv , const int xr, const int yr); 00076 00078 00082 void AddVect( CandidateList& vect_list , const MVector& mv , const int list_num); 00083 00085 00089 ValueType GetVar(const MVector& mv1,const MVector& mv2); 00090 00092 00098 ValueType GetVar(const std::vector<MVector>& pred_list,const MVector& mv); 00099 00100 00102 00103 // Subsumes FindBestMatch and FindBestMatchSubpel 00104 class BlockMatcher 00105 { 00106 public: 00108 00118 BlockMatcher( const PicArray& ref_data , 00119 const PicArray& pic_data , 00120 const OLBParams& bparams , 00121 const int precision , 00122 const MvArray& mv_array , 00123 const TwoDArray< MvCostData >& cost_array); 00124 00125 ~BlockMatcher(); 00126 00128 00136 void FindBestMatchPel( const int xpos , const int ypos , 00137 const CandidateList& cand_list, 00138 const MVector& mv_prediction, 00139 const int list_start); 00140 00142 00150 void FindBestMatchSubp( const int xpos, const int ypos, 00151 const CandidateList& cand_list, 00152 const MVector& mv_prediction, 00153 const float lambda); 00154 00155 void RefineMatchSubp(const int xpos, const int ypos, 00156 const MVector& mv_prediction, 00157 const float lambda); 00158 00160 00165 ValueType GetVar( const MVector& predmv , const MVector& mv ) const; 00166 00168 00173 ValueType GetVarUp( const MVector& predmv , const MVector& mv ) const; 00174 00175 void SetPrecision( const int n ){ m_precision = n; } 00176 00177 private: 00178 // Local copies of the picture and reference 00179 const PicArray& m_pic_data; 00180 const PicArray& m_ref_data; 00181 00182 // Local copy of the motion vector array being populated 00183 const MvArray& m_mv_array; 00184 00185 // Local copy of the costs being determined through the matching 00186 const TwoDArray< MvCostData >& m_cost_array; 00187 00188 // Block difference elements. Will choose between them depending 00189 // on whether we're at the edge of the picture 00190 PelBlockDiff m_peldiff; 00191 00192 OneDArray<BlockDiffUp* > m_subpeldiff; 00193 00194 // The block parameters we're using 00195 OLBParams m_bparams; 00196 00197 // The maximum variations allowed in calculating motion vector costs 00198 const int m_var_max; 00199 const int m_var_max_up; 00200 00201 // The motion vector precision 00202 int m_precision; 00203 00204 }; 00205 00206 } // namespace dirac 00207 #endif
© 2004 British Broadcasting Corporation.
Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's
excellent Doxygen tool.