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.14 2008/08/14 00:58:24 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 _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             m_xend(x_l+x_p),
00067             m_yend(y_l+y_p)
00068         {}
00069 
00071         //NB: Assume default copy constructor, assignment = and destructor//
00073 
00074         // Sets ...
00075 
00076 
00078         
00079         void SetBlockLimits( const OLBParams& bparams ,
00080                              const PicArray& pic_data , 
00081                              const int xbpos , const int ybpos);
00082 
00083         // ... and gets
00084 
00086         int Xp() const {return m_xp;}
00087 
00089         int Yp() const {return m_yp;}
00090 
00092         int Xl() const {return m_xl;}
00093 
00095         int Yl() const {return m_yl;}
00096 
00098         int Xend() const {return m_xend;}
00099 
00101         int Yend() const {return m_yend;}
00102 
00103     private: 
00104 
00105         int m_xp;
00106         int m_yp;
00107         int m_xl;
00108         int m_yl;
00109         int m_xend;
00110         int m_yend;
00111     };
00112 
00114     //----Different difference classes, so that-----//
00115     //bounds-checking need only be done as necessary//
00117 
00119     class BlockDiff
00120     {
00121     public:
00123         /*
00124              Constructor, initialising the reference and picture data
00125              \param  ref  the reference picture
00126              \param  pic  the picture being matched
00127         */
00128         BlockDiff( const PicArray& ref , const PicArray& pic );
00129 
00131         virtual ~BlockDiff(){}
00132 
00134 
00139         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv )=0;
00140 
00141     protected:
00142 
00143         const PicArray& m_pic_data;
00144         const PicArray& m_ref_data;
00145 
00146     private:
00148         BlockDiff( const BlockDiff& cpy );            
00149 
00151         BlockDiff& operator=( const BlockDiff& rhs );    
00152     };
00153 
00155     class PelBlockDiff: public BlockDiff
00156     {
00157     public:
00159         /*
00160              Constructor, initialising the reference and picture data
00161              \param  ref  the reference picture
00162              \param  pic  the picture being matched
00163         */
00164         PelBlockDiff( const PicArray& ref , const PicArray& pic );
00165 
00167 
00172         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00173 
00175 
00183         void Diff(  const BlockDiffParams& dparams ,
00184                     const MVector& mv ,
00185                     float& best_sum , 
00186                     MVector& best_mv ); 
00187 
00188     private:
00190         PelBlockDiff(const PelBlockDiff& cpy);
00191 
00193         PelBlockDiff& operator=(const PelBlockDiff& rhs);
00194     };
00195 
00196 
00198     class IntraBlockDiff
00199     {
00200     public:
00202         /*
00203              Constructor, initialising the picture data
00204              \param  pic  the picture being matched
00205         */
00206         IntraBlockDiff( const PicArray& pic );
00207 
00209 
00214         float Diff( const BlockDiffParams& dparams , ValueType& dc_val );
00215 
00217     ValueType CalcDC( const BlockDiffParams& dparams);
00218 
00219     private:
00221         IntraBlockDiff(const IntraBlockDiff& cpy);
00222 
00224         IntraBlockDiff& operator=(const IntraBlockDiff& rhs);
00225 
00226         const PicArray& m_pic_data;
00227     };
00228 
00230     class BiBlockDiff
00231     {
00232     public:
00234         /*
00235              Constructor, initialising the references and picture data
00236              \param  ref1  the first reference picture
00237              \param  ref2  the second reference picture
00238              \param  pic  the picture being matched
00239         */
00240         BiBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
00241 
00243         virtual ~BiBlockDiff( ) {}
00244 
00246 
00252         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0;
00253 
00254     protected:
00255         const PicArray& m_pic_data;
00256         const PicArray& m_ref_data1;
00257         const PicArray& m_ref_data2;
00258 
00259     private:
00261         BiBlockDiff(const BiBlockDiff& cpy);             
00262                                                                     
00264         BiBlockDiff& operator=(const BiBlockDiff& rhs);
00265     };
00266 
00267     // Classes where the reference is upconverted //
00270      class BlockDiffUp: public BlockDiff
00271      {
00272      
00273      public:
00274 
00276          /*
00277               Constructor, initialising the reference and picture data
00278               \param  ref  the reference picture
00279               \param  pic  the picture being matched
00280          */
00281          BlockDiffUp( const PicArray& ref , const PicArray& pic );
00282 
00284          virtual ~BlockDiffUp(){}
00285 
00287 
00292          virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv )=0;
00293 
00295 
00305          virtual void Diff( const BlockDiffParams& dparams,
00306                             const MVector& mv ,
00307                             const float mvcost,
00308                             const float lambda,
00309                             MvCostData& best_costs ,
00310                             MVector& best_mv)=0;
00311      private:
00313          BlockDiffUp(const BlockDiffUp& cpy);
00314 
00316          BlockDiffUp& operator=(const BlockDiffUp& rhs);
00317      };
00318  
00320     class BlockDiffHalfPel: public BlockDiffUp
00321     {
00322 
00323     public:
00325         /*
00326               Constructor, initialising the reference and picture data
00327               \param  ref  the reference picture
00328               \param  pic  the picture being matched
00329         */
00330         BlockDiffHalfPel( const PicArray& ref , const PicArray& pic );
00331 
00333         ~BlockDiffHalfPel(){}
00334 
00336 
00341         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00342 
00344 
00354         void Diff( const BlockDiffParams& dparams,
00355                     const MVector& mv ,
00356                     const float mvcost,
00357                     const float lambda,
00358                     MvCostData& best_costs ,
00359                     MVector& best_mv);
00360 
00361     private:
00363         BlockDiffHalfPel(const BlockDiffHalfPel& cpy);
00364 
00366         BlockDiffHalfPel& operator=(const BlockDiffHalfPel& rhs);
00367 
00368     };
00369 
00371     class BlockDiffQuarterPel: public BlockDiffUp
00372     {
00373     public:
00375         /*
00376              Constructor, initialising the reference and picture data
00377              \param  ref  the reference picture
00378              \param  pic  the picture being matched
00379         */
00380         BlockDiffQuarterPel( const PicArray& ref , const PicArray& pic );
00381 
00383         ~BlockDiffQuarterPel(){}
00384 
00386 
00391         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00392 
00394 
00404         void Diff( const BlockDiffParams& dparams,
00405                    const MVector& mv ,
00406                    const float mvcost,
00407                    const float lambda,
00408                    MvCostData& best_costs ,
00409                    MVector& best_mv);
00410 
00411     private:
00413         BlockDiffQuarterPel(const BlockDiffQuarterPel& cpy);
00414 
00416         BlockDiffQuarterPel& operator=(const BlockDiffQuarterPel& rhs);
00417     };
00418 
00420     class BlockDiffEighthPel: public BlockDiffUp
00421     {
00422     public:
00424         /*
00425              Constructor, initialising the reference and picture data
00426              \param  ref  the reference picture
00427              \param  pic  the picture being matched
00428         */
00429         BlockDiffEighthPel( const PicArray& ref , const PicArray& pic );
00430 
00432         ~BlockDiffEighthPel(){}
00433 
00435 
00440         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
00441 
00443 
00453         void Diff( const BlockDiffParams& dparams,
00454                     const MVector& mv ,
00455                     const float mvcost,
00456                     const float lambda,
00457                     MvCostData& best_costs ,
00458                     MVector& best_mv);
00459 
00460     private:
00462         BlockDiffEighthPel(const BlockDiffEighthPel& cpy);
00463 
00465         BlockDiffEighthPel& operator=(const BlockDiffEighthPel& rhs);
00466     };
00467 
00469     class BiBlockHalfPel: public BiBlockDiff
00470     {
00471     public:
00473         /*
00474              Constructor, initialising the reference and picture data
00475              \param  ref1  the first reference picture
00476              \param  ref2  the second reference picture
00477              \param  pic  the picture being matched
00478         */
00479         BiBlockHalfPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
00480 
00482 
00488         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00489     private:
00491         BiBlockHalfPel(const BiBlockHalfPel& cpy);
00492 
00494         BiBlockHalfPel& operator=(const BiBlockHalfPel& rhs);
00495     };
00496 
00498     class BiBlockQuarterPel: public BiBlockDiff
00499     {
00500     public:
00502         /*
00503              Constructor, initialising the reference and picture data
00504              \param  ref1  the first reference picture
00505              \param  ref2  the second reference picture
00506              \param  pic  the picture being matched
00507         */
00508         BiBlockQuarterPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
00509 
00511 
00517         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00518 
00519     private:
00521         BiBlockQuarterPel(const BiBlockQuarterPel& cpy);
00522 
00524         BiBlockQuarterPel& operator=(const BiBlockQuarterPel& rhs);
00525     };
00526 
00528     class BiBlockEighthPel: public BiBlockDiff
00529     {
00530     public:
00532         /*
00533              Constructor, initialising the reference and picture data
00534              \param  ref1  the first reference picture
00535              \param  ref2  the second reference picture
00536              \param  pic  the picture being matched
00537         */
00538         BiBlockEighthPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
00539 
00541 
00547         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
00548     private:
00550         BiBlockEighthPel(const BiBlockEighthPel& cpy);
00551 
00553         BiBlockEighthPel& operator=(const BiBlockEighthPel& rhs);
00554     };
00555 
00556 } // namespace dirac
00557 #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.