me_utils.h

00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: me_utils.h,v 1.2 2005/01/30 05:11:42 gabest Exp $ $Name:  $
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 _ME_UTILS_H_
00039 #define _ME_UTILS_H_
00040 
00041 #include <algorithm>
00042 #include <libdirac_common/motion.h>
00043 #include <libdirac_common/common.h>
00044 namespace dirac
00045 {
00046 
00048     //Utilities for motion estimation//
00049     //-------------------------------//
00051 
00053     class BlockDiffParams
00054     {
00055 
00056     public:
00058         BlockDiffParams(){}
00059 
00061         BlockDiffParams( const int x_p , const int y_p , const int x_l , const int y_l):
00062             m_xp(x_p),
00063             m_yp(y_p),
00064             m_xl(x_l),
00065             m_yl(y_l)
00066         {}
00067 
00069         //NB: Assume default copy constructor, assignment = and destructor//
00071 
00072         // Sets ...
00073 
00074 
00076         
00077         void SetBlockLimits( const OLBParams& bparams ,
00078                              const PicArray& pic_data , 
00079                              const int xbpos , const int ybpos);
00080 
00081         // ... and gets
00082 
00084         const int Xp() const {return m_xp;}
00085 
00087         const int Yp() const {return m_yp;}
00088 
00090         const int Xl() const {return m_xl;}
00091 
00093         const int Yl() const {return m_yl;}
00094 
00095     private: 
00096 
00097         int m_xp;
00098         int m_yp;
00099         int m_xl;
00100         int m_yl;
00101 
00102     };
00103 
00105     //----Different difference classes, so that-----//
00106     //bounds-checking need only be done as necessary//
00108 
00110     class BlockDiff
00111     {
00112     public:
00114         /*
00115              Constructor, initialising the reference and picture data
00116              \param  ref  the reference picture
00117              \param  pic  the picture being matched
00118         */
00119         BlockDiff( const PicArray& ref , const PicArray& pic );
00120 
00122         virtual ~BlockDiff(){}
00123 
00125 
00130         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv )=0;
00131 
00132     protected:
00133 
00134         const PicArray& pic_data;
00135         const PicArray& ref_data;
00136 
00137     private:
00139         BlockDiff( const BlockDiff& cpy );            
00140 
00142         BlockDiff& operator=( const BlockDiff& rhs );    
00143     };
00144 
00146     class SimpleBlockDiff: public BlockDiff
00147     {
00148     public:
00150         /*
00151              Constructor, initialising the reference and picture data
00152              \param  ref  the reference picture
00153              \param  pic  the picture being matched
00154         */
00155         SimpleBlockDiff( const PicArray& ref , const PicArray& pic );
00156 
00158 
00163         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00164 
00165     private:
00167         SimpleBlockDiff(const SimpleBlockDiff& cpy);
00168 
00170         SimpleBlockDiff& operator=(const SimpleBlockDiff& rhs);
00171     };
00172 
00174     class BChkBlockDiff: public BlockDiff
00175     {
00176     public:
00178         /*
00179              Constructor, initialising the reference and picture data
00180              \param  ref  the reference picture
00181              \param  pic  the picture being matched
00182         */
00183         BChkBlockDiff( const PicArray& ref , const PicArray& pic );
00184 
00186 
00191         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00192 
00193     private:
00195         BChkBlockDiff(const BChkBlockDiff& cpy); 
00196 
00198         BChkBlockDiff& operator=(const BChkBlockDiff& rhs);
00199     };
00200 
00202     class IntraBlockDiff
00203     {
00204     public:
00206         /*
00207              Constructor, initialising the picture data
00208              \param  pic  the picture being matched
00209         */
00210         IntraBlockDiff( const PicArray& pic );
00211 
00213 
00218         float Diff( const BlockDiffParams& dparams , ValueType& dc_val );
00219 
00220     private:
00222         IntraBlockDiff(const IntraBlockDiff& cpy);
00223 
00225         IntraBlockDiff& operator=(const IntraBlockDiff& rhs);
00226 
00227         const PicArray& pic_data;
00228     };
00229 
00231     class BiBlockDiff
00232     {
00233     public:
00235         /*
00236              Constructor, initialising the references and picture data
00237              \param  ref1  the first reference picture
00238              \param  ref2  the second reference picture
00239              \param  pic  the picture being matched
00240         */
00241         BiBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
00242 
00244 
00250         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0;
00251 
00252     protected:
00253         const PicArray& pic_data;
00254         const PicArray& ref_data1;
00255         const PicArray& ref_data2;
00256 
00257     private:
00259         BiBlockDiff(const BiBlockDiff& cpy);             
00260                                                                     
00262         BiBlockDiff& operator=(const BiBlockDiff& rhs);
00263     };
00264 
00265 
00267     class BiSimpleBlockDiff: public BiBlockDiff
00268     {
00269     public:
00270 
00272         /*
00273              Constructor, initialising the references and picture data
00274              \param  ref1  the first reference picture
00275              \param  ref2  the second reference picture
00276              \param  pic  the picture being matched
00277         */
00278         BiSimpleBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
00279 
00281 
00287         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00288 
00289     private:
00291         BiSimpleBlockDiff(const BiSimpleBlockDiff& cpy);
00292 
00294         BiSimpleBlockDiff& operator=(const BiSimpleBlockDiff& rhs);    
00295                                                                     
00296     };
00297 
00299     class BiBChkBlockDiff: public BiBlockDiff
00300     {
00301     public:
00303         BiBChkBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
00304 
00306 
00312         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00313 
00314     private:
00316         BiBChkBlockDiff(const BiBChkBlockDiff& cpy);             
00317 
00319         BiBChkBlockDiff& operator=(const BiBChkBlockDiff& rhs);     
00320                                                                 
00321     };
00322 
00323     // Classes where the reference is upconverted
00324 
00326     class BlockDiffUp: public BlockDiff
00327     {
00328     public:    
00330         /*
00331              Constructor, initialising the reference and picture data
00332              \param  ref  the reference picture
00333              \param  pic  the picture being matched
00334         */
00335         BlockDiffUp( const PicArray& ref , const PicArray& pic);
00336 
00338         virtual ~BlockDiffUp(){}
00339 
00341 
00346         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv )=0;
00347 
00348     protected:
00350         int InterpLookup[9][4];
00351 
00352     private:
00354         BlockDiffUp(const BlockDiffUp& cpy); 
00355                                                         
00357         BlockDiffUp& operator=(const BlockDiffUp& rhs);
00358                                                         
00359     };
00360 
00362     class SimpleBlockDiffUp: public BlockDiffUp
00363     {
00364     public:
00366         /*
00367              Constructor, initialising the reference and picture data
00368              \param  ref  the reference picture
00369              \param  pic  the picture being matched
00370         */
00371         SimpleBlockDiffUp( const PicArray& ref , const PicArray& pic );
00372 
00374         ~SimpleBlockDiffUp(){}
00375 
00377 
00382         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00383 
00384     private:
00386         SimpleBlockDiffUp(const SimpleBlockDiffUp& cpy);
00387 
00389         SimpleBlockDiffUp& operator=(const SimpleBlockDiffUp& rhs);
00390     };
00391 
00393     class BChkBlockDiffUp: public BlockDiffUp{
00394 
00395     public:
00397         /*
00398              Constructor, initialising the reference and picture data
00399              \param  ref  the reference picture
00400              \param  pic  the picture being matched
00401         */
00402         BChkBlockDiffUp(const PicArray& ref,const PicArray& pic);
00403 
00405         ~BChkBlockDiffUp(){}
00406 
00408 
00413         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00414     private:
00416         BChkBlockDiffUp(const BChkBlockDiffUp& cpy);
00417 
00419         BChkBlockDiffUp& operator=(const BChkBlockDiffUp& rhs);    
00420     };
00421 
00423     class BiBlockDiffUp: public BiBlockDiff
00424     {
00425     public:    
00427         /*
00428              Constructor, initialising the reference and picture data
00429              \param  ref1  the first reference picture
00430              \param  ref2  the second reference picture
00431              \param  pic  the picture being matched
00432         */
00433         BiBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
00434 
00436         virtual ~BiBlockDiffUp(){}
00437 
00439 
00445         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0;
00446     protected:
00448         int InterpLookup[9][4];
00449 
00450     private:
00452         BiBlockDiffUp(const BlockDiffUp& cpy); 
00453                                                         
00455         BiBlockDiffUp& operator=(const BlockDiffUp& rhs);
00456                                                         
00457     };
00458 
00460     class BiSimpleBlockDiffUp: public BiBlockDiffUp
00461     {
00462     public:
00464         /*
00465              Constructor, initialising the reference and picture data
00466              \param  ref1  the first reference picture
00467              \param  ref2  the second reference picture
00468              \param  pic  the picture being matched
00469         */
00470         BiSimpleBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
00471 
00473 
00479         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00480     private:
00482         BiSimpleBlockDiffUp(const BiSimpleBlockDiffUp& cpy);
00483 
00485         BiSimpleBlockDiffUp& operator=(const BiSimpleBlockDiffUp& rhs);
00486     };
00487 
00489     class BiBChkBlockDiffUp: public BiBlockDiffUp
00490     {
00491     public:
00493         /*
00494              Constructor, initialising the reference and picture data
00495              \param  ref1  the first reference picture
00496              \param  ref2  the second reference picture
00497              \param  pic  the picture being matched
00498         */
00499         BiBChkBlockDiffUp( const PicArray& ref , const PicArray& ref2 , const PicArray& pic );
00500 
00502 
00508         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00509     private:
00511         BiBChkBlockDiffUp(const BiBChkBlockDiffUp& cpy);
00512 
00514         BiBChkBlockDiffUp& operator=(const BiBChkBlockDiffUp& rhs);    
00515     };
00516 
00517 } // namespace dirac
00518 #endif

Generated on Tue Dec 13 14:47:17 2005 for guliverkli by  doxygen 1.4.5