# 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.12 2006/04/20 10:41:58 asuraparaju Exp $ $Name: Dirac_0_7_0 $
    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         const int Xp() const {return m_xp;}
    00087
    00089         const int Yp() const {return m_yp;}
    00090
    00092         const int Xl() const {return m_xl;}
    00093
    00095         const int Yl() const {return m_yl;}
    00096
    00098         const int Xend() const {return m_xend;}
    00099
    00101         const 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
    00216     private:
    00218         IntraBlockDiff(const IntraBlockDiff& cpy);
    00219
    00221         IntraBlockDiff& operator=(const IntraBlockDiff& rhs);
    00222
    00223         const PicArray& m_pic_data;
    00224     };
    00225
    00227     class BiBlockDiff
    00228     {
    00229     public:
    00231         /*
    00232              Constructor, initialising the references and picture data
    00233              \param  ref1  the first reference picture
    00234              \param  ref2  the second reference picture
    00235              \param  pic  the picture being matched
    00236         */
    00237         BiBlockDiff( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic);
    00238
    00240         virtual ~BiBlockDiff( ) {}
    00241
    00243
    00249         virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 )=0;
    00250
    00251     protected:
    00252         const PicArray& m_pic_data;
    00253         const PicArray& m_ref_data1;
    00254         const PicArray& m_ref_data2;
    00255
    00256     private:
    00258         BiBlockDiff(const BiBlockDiff& cpy);
    00259
    00261         BiBlockDiff& operator=(const BiBlockDiff& rhs);
    00262     };
    00263
    00264     // Classes where the reference is upconverted //
    00267      class BlockDiffUp: public BlockDiff
    00268      {
    00269
    00270      public:
    00271
    00273          /*
    00274               Constructor, initialising the reference and picture data
    00275               \param  ref  the reference picture
    00276               \param  pic  the picture being matched
    00277          */
    00278          BlockDiffUp( const PicArray& ref , const PicArray& pic );
    00279
    00281          virtual ~BlockDiffUp(){}
    00282
    00284
    00289          virtual float Diff(  const BlockDiffParams& dparams , const MVector& mv )=0;
    00290
    00292
    00302          virtual void Diff( const BlockDiffParams& dparams,
    00303                             const MVector& mv ,
    00304                             const float mvcost,
    00305                             const float lambda,
    00306                             MvCostData& best_costs ,
    00307                             MVector& best_mv)=0;
    00308      private:
    00310          BlockDiffUp(const BlockDiffUp& cpy);
    00311
    00313          BlockDiffUp& operator=(const BlockDiffUp& rhs);
    00314      };
    00315
    00317     class BlockDiffHalfPel: public BlockDiffUp
    00318     {
    00319
    00320     public:
    00322         /*
    00323               Constructor, initialising the reference and picture data
    00324               \param  ref  the reference picture
    00325               \param  pic  the picture being matched
    00326         */
    00327         BlockDiffHalfPel( const PicArray& ref , const PicArray& pic );
    00328
    00330         ~BlockDiffHalfPel(){}
    00331
    00333
    00338         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
    00339
    00341
    00351         void Diff( const BlockDiffParams& dparams,
    00352                     const MVector& mv ,
    00353                     const float mvcost,
    00354                     const float lambda,
    00355                     MvCostData& best_costs ,
    00356                     MVector& best_mv);
    00357
    00358     private:
    00360         BlockDiffHalfPel(const BlockDiffHalfPel& cpy);
    00361
    00363         BlockDiffHalfPel& operator=(const BlockDiffHalfPel& rhs);
    00364
    00365     };
    00366
    00368     class BlockDiffQuarterPel: public BlockDiffUp
    00369     {
    00370     public:
    00372         /*
    00373              Constructor, initialising the reference and picture data
    00374              \param  ref  the reference picture
    00375              \param  pic  the picture being matched
    00376         */
    00377         BlockDiffQuarterPel( const PicArray& ref , const PicArray& pic );
    00378
    00380         ~BlockDiffQuarterPel(){}
    00381
    00383
    00388         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
    00389
    00391
    00401         void Diff( const BlockDiffParams& dparams,
    00402                    const MVector& mv ,
    00403                    const float mvcost,
    00404                    const float lambda,
    00405                    MvCostData& best_costs ,
    00406                    MVector& best_mv);
    00407
    00408     private:
    00410         BlockDiffQuarterPel(const BlockDiffQuarterPel& cpy);
    00411
    00413         BlockDiffQuarterPel& operator=(const BlockDiffQuarterPel& rhs);
    00414     };
    00415
    00417     class BlockDiffEighthPel: public BlockDiffUp
    00418     {
    00419     public:
    00421         /*
    00422              Constructor, initialising the reference and picture data
    00423              \param  ref  the reference picture
    00424              \param  pic  the picture being matched
    00425         */
    00426         BlockDiffEighthPel( const PicArray& ref , const PicArray& pic );
    00427
    00429         ~BlockDiffEighthPel(){}
    00430
    00432
    00437         float Diff(  const BlockDiffParams& dparams , const MVector& mv );
    00438
    00440
    00450         void Diff( const BlockDiffParams& dparams,
    00451                     const MVector& mv ,
    00452                     const float mvcost,
    00453                     const float lambda,
    00454                     MvCostData& best_costs ,
    00455                     MVector& best_mv);
    00456
    00457     private:
    00459         BlockDiffEighthPel(const BlockDiffEighthPel& cpy);
    00460
    00462         BlockDiffEighthPel& operator=(const BlockDiffEighthPel& rhs);
    00463     };
    00464
    00466     class BiBlockHalfPel: public BiBlockDiff
    00467     {
    00468     public:
    00470         /*
    00471              Constructor, initialising the reference and picture data
    00472              \param  ref1  the first reference picture
    00473              \param  ref2  the second reference picture
    00474              \param  pic  the picture being matched
    00475         */
    00476         BiBlockHalfPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
    00477
    00479
    00485         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
    00486     private:
    00488         BiBlockHalfPel(const BiBlockHalfPel& cpy);
    00489
    00491         BiBlockHalfPel& operator=(const BiBlockHalfPel& rhs);
    00492     };
    00493
    00495     class BiBlockQuarterPel: public BiBlockDiff
    00496     {
    00497     public:
    00499         /*
    00500              Constructor, initialising the reference and picture data
    00501              \param  ref1  the first reference picture
    00502              \param  ref2  the second reference picture
    00503              \param  pic  the picture being matched
    00504         */
    00505         BiBlockQuarterPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
    00506
    00508
    00514         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
    00515
    00516     private:
    00518         BiBlockQuarterPel(const BiBlockQuarterPel& cpy);
    00519
    00521         BiBlockQuarterPel& operator=(const BiBlockQuarterPel& rhs);
    00522     };
    00523
    00525     class BiBlockEighthPel: public BiBlockDiff
    00526     {
    00527     public:
    00529         /*
    00530              Constructor, initialising the reference and picture data
    00531              \param  ref1  the first reference picture
    00532              \param  ref2  the second reference picture
    00533              \param  pic  the picture being matched
    00534         */
    00535         BiBlockEighthPel( const PicArray& ref1 , const PicArray& ref2 , const PicArray& pic );
    00536
    00538
    00544         float Diff(  const BlockDiffParams& dparams , const MVector& mv1 , const MVector& mv2 );
    00545     private:
    00547         BiBlockEighthPel(const BiBlockEighthPel& cpy);
    00548
    00550         BiBlockEighthPel& operator=(const BiBlockEighthPel& rhs);
    00551     };
    00552
    00553 } // namespace dirac
    00554 #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.