Dirac - A Video Codec

Created by the British Broadcasting Corporation.


me_utils.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: me_utils.h,v 1.8 2004/08/25 16:47:37 asuraparaju Exp $ $Name: Dirac_0_4_3 $ 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 00046 //Utilities for motion estimation// 00047 //-------------------------------// 00049 00051 class BlockDiffParams 00052 { 00053 00054 public: 00056 BlockDiffParams(){} 00057 00059 BlockDiffParams( const int x_p , const int y_p , const int x_l , const int y_l): 00060 m_xp(x_p), 00061 m_yp(y_p), 00062 m_xl(x_l), 00063 m_yl(y_l) 00064 {} 00065 00067 //NB: Assume default copy constructor, assignment = and destructor// 00069 00070 // Sets ... 00071 00072 00074 00075 void SetBlockLimits( const OLBParams& bparams , 00076 const PicArray& pic_data , 00077 const int xbpos , const int ybpos); 00078 00079 // ... and gets 00080 00082 const int Xp() const {return m_xp;} 00083 00085 const int Yp() const {return m_yp;} 00086 00088 const int Xl() const {return m_xl;} 00089 00091 const int Yl() const {return m_yl;} 00092 00093 private: 00094 00095 int m_xp; 00096 int m_yp; 00097 int m_xl; 00098 int m_yl; 00099 00100 }; 00101 00103 //----Different difference classes, so that-----// 00104 //bounds-checking need only be done as necessary// 00106 00108 class BlockDiff 00109 { 00110 public: 00112 /* 00113 Constructor, initialising the reference and picture data 00114 \param ref the reference picture 00115 \param pic the picture being matched 00116 */ 00117 BlockDiff( const PicArray& ref , const PicArray& pic ); 00118 00120 virtual ~BlockDiff(){} 00121 00123 00128 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv )=0; 00129 00130 protected: 00131 00132 const PicArray& pic_data; 00133 const PicArray& ref_data; 00134 00135 private: 00137 BlockDiff( const BlockDiff& cpy ); 00138 00140 BlockDiff& operator=( const BlockDiff& rhs ); 00141 }; 00142 00144 class SimpleBlockDiff: public BlockDiff 00145 { 00146 public: 00148 /* 00149 Constructor, initialising the reference and picture data 00150 \param ref the reference picture 00151 \param pic the picture being matched 00152 */ 00153 SimpleBlockDiff( const PicArray& ref , const PicArray& pic ); 00154 00156 00161 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00162 00163 private: 00165 SimpleBlockDiff(const SimpleBlockDiff& cpy); 00166 00168 SimpleBlockDiff& operator=(const SimpleBlockDiff& rhs); 00169 }; 00170 00172 class BChkBlockDiff: public BlockDiff 00173 { 00174 public: 00176 /* 00177 Constructor, initialising the reference and picture data 00178 \param ref the reference picture 00179 \param pic the picture being matched 00180 */ 00181 BChkBlockDiff( const PicArray& ref , const PicArray& pic ); 00182 00184 00189 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00190 00191 private: 00193 BChkBlockDiff(const BChkBlockDiff& cpy); 00194 00196 BChkBlockDiff& operator=(const BChkBlockDiff& rhs); 00197 }; 00198 00200 class IntraBlockDiff 00201 { 00202 public: 00204 /* 00205 Constructor, initialising the picture data 00206 \param pic the picture being matched 00207 */ 00208 IntraBlockDiff( const PicArray& pic ); 00209 00211 00216 float Diff( const BlockDiffParams& dparams , ValueType& dc_val ); 00217 00218 private: 00220 IntraBlockDiff(const IntraBlockDiff& cpy); 00221 00223 IntraBlockDiff& operator=(const IntraBlockDiff& rhs); 00224 00225 const PicArray& pic_data; 00226 }; 00227 00229 class BiBlockDiff 00230 { 00231 public: 00233 /* 00234 Constructor, initialising the references and picture data 00235 \param ref1 the first reference picture 00236 \param ref2 the second reference picture 00237 \param pic the picture being matched 00238 */ 00239 BiBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic); 00240 00242 00248 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0; 00249 00250 protected: 00251 const PicArray& pic_data; 00252 const PicArray& ref_data1; 00253 const PicArray& ref_data2; 00254 00255 private: 00257 BiBlockDiff(const BiBlockDiff& cpy); 00258 00260 BiBlockDiff& operator=(const BiBlockDiff& rhs); 00261 }; 00262 00263 00265 class BiSimpleBlockDiff: public BiBlockDiff 00266 { 00267 public: 00268 00270 /* 00271 Constructor, initialising the references and picture data 00272 \param ref1 the first reference picture 00273 \param ref2 the second reference picture 00274 \param pic the picture being matched 00275 */ 00276 BiSimpleBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic); 00277 00279 00285 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00286 00287 private: 00289 BiSimpleBlockDiff(const BiSimpleBlockDiff& cpy); 00290 00292 BiSimpleBlockDiff& operator=(const BiSimpleBlockDiff& rhs); 00293 00294 }; 00295 00297 class BiBChkBlockDiff: public BiBlockDiff 00298 { 00299 public: 00301 BiBChkBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic ); 00302 00304 00310 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00311 00312 private: 00314 BiBChkBlockDiff(const BiBChkBlockDiff& cpy); 00315 00317 BiBChkBlockDiff& operator=(const BiBChkBlockDiff& rhs); 00318 00319 }; 00320 00321 // Classes where the reference is upconverted 00322 00324 class BlockDiffUp: public BlockDiff 00325 { 00326 public: 00328 /* 00329 Constructor, initialising the reference and picture data 00330 \param ref the reference picture 00331 \param pic the picture being matched 00332 */ 00333 BlockDiffUp( const PicArray& ref , const PicArray& pic); 00334 00336 virtual ~BlockDiffUp(){} 00337 00339 00344 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv )=0; 00345 00346 protected: 00348 int InterpLookup[9][4]; 00349 00350 private: 00352 BlockDiffUp(const BlockDiffUp& cpy); 00353 00355 BlockDiffUp& operator=(const BlockDiffUp& rhs); 00356 00357 }; 00358 00360 class SimpleBlockDiffUp: public BlockDiffUp 00361 { 00362 public: 00364 /* 00365 Constructor, initialising the reference and picture data 00366 \param ref the reference picture 00367 \param pic the picture being matched 00368 */ 00369 SimpleBlockDiffUp( const PicArray& ref , const PicArray& pic ); 00370 00372 ~SimpleBlockDiffUp(){} 00373 00375 00380 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00381 00382 private: 00384 SimpleBlockDiffUp(const SimpleBlockDiffUp& cpy); 00385 00387 SimpleBlockDiffUp& operator=(const SimpleBlockDiffUp& rhs); 00388 }; 00389 00391 class BChkBlockDiffUp: public BlockDiffUp{ 00392 00393 public: 00395 /* 00396 Constructor, initialising the reference and picture data 00397 \param ref the reference picture 00398 \param pic the picture being matched 00399 */ 00400 BChkBlockDiffUp(const PicArray& ref,const PicArray& pic); 00401 00403 ~BChkBlockDiffUp(){} 00404 00406 00411 float Diff( const BlockDiffParams& dparams , const MVector& mv ); 00412 private: 00414 BChkBlockDiffUp(const BChkBlockDiffUp& cpy); 00415 00417 BChkBlockDiffUp& operator=(const BChkBlockDiffUp& rhs); 00418 }; 00419 00421 class BiBlockDiffUp: public BiBlockDiff 00422 { 00423 public: 00425 /* 00426 Constructor, initialising the reference and picture data 00427 \param ref1 the first reference picture 00428 \param ref2 the second reference picture 00429 \param pic the picture being matched 00430 */ 00431 BiBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic); 00432 00434 virtual ~BiBlockDiffUp(){} 00435 00437 00443 virtual float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0; 00444 protected: 00446 int InterpLookup[9][4]; 00447 00448 private: 00450 BiBlockDiffUp(const BlockDiffUp& cpy); 00451 00453 BiBlockDiffUp& operator=(const BlockDiffUp& rhs); 00454 00455 }; 00456 00458 class BiSimpleBlockDiffUp: public BiBlockDiffUp 00459 { 00460 public: 00462 /* 00463 Constructor, initialising the reference and picture data 00464 \param ref1 the first reference picture 00465 \param ref2 the second reference picture 00466 \param pic the picture being matched 00467 */ 00468 BiSimpleBlockDiffUp( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic ); 00469 00471 00477 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00478 private: 00480 BiSimpleBlockDiffUp(const BiSimpleBlockDiffUp& cpy); 00481 00483 BiSimpleBlockDiffUp& operator=(const BiSimpleBlockDiffUp& rhs); 00484 }; 00485 00487 class BiBChkBlockDiffUp: public BiBlockDiffUp 00488 { 00489 public: 00491 /* 00492 Constructor, initialising the reference and picture data 00493 \param ref1 the first reference picture 00494 \param ref2 the second reference picture 00495 \param pic the picture being matched 00496 */ 00497 BiBChkBlockDiffUp( const PicArray& ref , const PicArray& ref2 , const PicArray& pic ); 00498 00500 00506 float Diff( const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 ); 00507 private: 00509 BiBChkBlockDiffUp(const BiBChkBlockDiffUp& cpy); 00510 00512 BiBChkBlockDiffUp& operator=(const BiBChkBlockDiffUp& rhs); 00513 }; 00514 #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.