Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: me_utils.h,v 1.10 2005/05/19 10:24:09 asuraparaju 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 _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 virtual ~BiBlockDiff( ) {} 00245 00247 00253 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0; 00254 00255 protected: 00256 const PicArray& pic_data; 00257 const PicArray& ref_data1; 00258 const PicArray& ref_data2; 00259 00260 private: 00262 BiBlockDiff(const BiBlockDiff& cpy); 00263 00265 BiBlockDiff& operator=(const BiBlockDiff& rhs); 00266 }; 00267 00268 00270 class BiSimpleBlockDiff: public BiBlockDiff 00271 { 00272 public: 00273 00275 /* 00276 Constructor, initialising the references and picture data 00277 \param ref1 the first reference picture 00278 \param ref2 the second reference picture 00279 \param pic the picture being matched 00280 */ 00281 BiSimpleBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic); 00282 00284 00290 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00291 00292 private: 00294 BiSimpleBlockDiff(const BiSimpleBlockDiff& cpy); 00295 00297 BiSimpleBlockDiff& operator=(const BiSimpleBlockDiff& rhs); 00298 00299 }; 00300 00302 class BiBChkBlockDiff: public BiBlockDiff 00303 { 00304 public: 00306 BiBChkBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic ); 00307 00309 00315 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00316 00317 private: 00319 BiBChkBlockDiff(const BiBChkBlockDiff& cpy); 00320 00322 BiBChkBlockDiff& operator=(const BiBChkBlockDiff& rhs); 00323 00324 }; 00325 00326 // Classes where the reference is upconverted 00327 00329 class BlockDiffUp: public BlockDiff 00330 { 00331 public: 00333 /* 00334 Constructor, initialising the reference and picture data 00335 \param ref the reference picture 00336 \param pic the picture being matched 00337 */ 00338 BlockDiffUp( const PicArray& ref , const PicArray& pic); 00339 00341 virtual ~BlockDiffUp(){} 00342 00344 00349 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv )=0; 00350 00351 protected: 00353 int InterpLookup[9][4]; 00354 00355 private: 00357 BlockDiffUp(const BlockDiffUp& cpy); 00358 00360 BlockDiffUp& operator=(const BlockDiffUp& rhs); 00361 00362 }; 00363 00365 class SimpleBlockDiffUp: public BlockDiffUp 00366 { 00367 public: 00369 /* 00370 Constructor, initialising the reference and picture data 00371 \param ref the reference picture 00372 \param pic the picture being matched 00373 */ 00374 SimpleBlockDiffUp( const PicArray& ref , const PicArray& pic ); 00375 00377 ~SimpleBlockDiffUp(){} 00378 00380 00385 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00386 00387 private: 00389 SimpleBlockDiffUp(const SimpleBlockDiffUp& cpy); 00390 00392 SimpleBlockDiffUp& operator=(const SimpleBlockDiffUp& rhs); 00393 }; 00394 00396 class BChkBlockDiffUp: public BlockDiffUp{ 00397 00398 public: 00400 /* 00401 Constructor, initialising the reference and picture data 00402 \param ref the reference picture 00403 \param pic the picture being matched 00404 */ 00405 BChkBlockDiffUp(const PicArray& ref,const PicArray& pic); 00406 00408 ~BChkBlockDiffUp(){} 00409 00411 00416 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00417 private: 00419 BChkBlockDiffUp(const BChkBlockDiffUp& cpy); 00420 00422 BChkBlockDiffUp& operator=(const BChkBlockDiffUp& rhs); 00423 }; 00424 00426 class BiBlockDiffUp: public BiBlockDiff 00427 { 00428 public: 00430 /* 00431 Constructor, initialising the reference and picture data 00432 \param ref1 the first reference picture 00433 \param ref2 the second reference picture 00434 \param pic the picture being matched 00435 */ 00436 BiBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic); 00437 00439 virtual ~BiBlockDiffUp(){} 00440 00442 00448 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0; 00449 protected: 00451 int InterpLookup[9][4]; 00452 00453 private: 00455 BiBlockDiffUp(const BlockDiffUp& cpy); 00456 00458 BiBlockDiffUp& operator=(const BlockDiffUp& rhs); 00459 00460 }; 00461 00463 class BiSimpleBlockDiffUp: public BiBlockDiffUp 00464 { 00465 public: 00467 /* 00468 Constructor, initialising the reference and picture data 00469 \param ref1 the first reference picture 00470 \param ref2 the second reference picture 00471 \param pic the picture being matched 00472 */ 00473 BiSimpleBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic ); 00474 00476 00482 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00483 private: 00485 BiSimpleBlockDiffUp(const BiSimpleBlockDiffUp& cpy); 00486 00488 BiSimpleBlockDiffUp& operator=(const BiSimpleBlockDiffUp& rhs); 00489 }; 00490 00492 class BiBChkBlockDiffUp: public BiBlockDiffUp 00493 { 00494 public: 00496 /* 00497 Constructor, initialising the reference and picture data 00498 \param ref1 the first reference picture 00499 \param ref2 the second reference picture 00500 \param pic the picture being matched 00501 */ 00502 BiBChkBlockDiffUp( const PicArray& ref , const PicArray& ref2 , const PicArray& pic ); 00503 00505 00511 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00512 private: 00514 BiBChkBlockDiffUp(const BiBChkBlockDiffUp& cpy); 00515 00517 BiBChkBlockDiffUp& operator=(const BiBChkBlockDiffUp& rhs); 00518 }; 00519 00520 } // namespace dirac 00521 #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.