Dirac - A Video Codec

Created by the British Broadcasting Corporation.


block_match.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: block_match.h,v 1.7 2005/01/24 14:43:29 tjdwave Exp $ $Name: Dirac_0_5_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 
00117         BlockMatcher( const PicArray& ref_data , 
00118                       const PicArray& pic_data , 
00119                       const OLBParams& bparams ,
00120                       const MvArray& mv_array ,
00121                       const TwoDArray< MvCostData >& cost_array);
00122 
00124 
00132         void FindBestMatch(int xpos , int ypos,
00133                            const CandidateList& cand_list,
00134                            const MVector& mv_prediction,
00135                            float lambda);
00136 
00138 
00146         void FindBestMatchSubp(int xpos, int ypos,
00147                                 const CandidateList& cand_list,
00148                                 const MVector& mv_prediction,
00149                                 float lambda);
00150 
00152 
00157         ValueType GetVar( const MVector& predmv , const MVector& mv ) const;
00158 
00160 
00165         ValueType GetVarUp( const MVector& predmv , const MVector& mv ) const;
00166 
00167     private:
00168         // Local copies of the picture and reference
00169         const PicArray& m_pic_data;
00170         const PicArray& m_ref_data;
00171         
00172         // Local copy of the motion vector array being populated
00173         const MvArray& m_mv_array;
00174         
00175         // Local copy of the costs being determined through the matching
00176         const TwoDArray< MvCostData >& m_cost_array; 
00177 
00178         // Block difference elements. Will choose between them depending 
00179         // on whether we're at the edge of the picture
00180         SimpleBlockDiff m_simplediff;
00181         BChkBlockDiff m_checkdiff;
00182         SimpleBlockDiffUp m_simplediffup;
00183         BChkBlockDiffUp m_checkdiffup;
00184 
00185         // The block parameters we're using
00186         OLBParams m_bparams;
00187 
00188         // The maximum variations allowed in calculating motion vector costs
00189         const int m_var_max;
00190         const int m_var_max_up;
00191 
00192     };
00193 
00194 } // namespace dirac
00195 #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.