Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mot_comp.h,v 1.12 2005/05/19 10:16:08 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): Richard Felton (Original Author), 00024 * Thomas Davies 00025 * Anuradha Suraparaju 00026 * 00027 * Alternatively, the contents of this file may be used under the terms of 00028 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00029 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00030 * the GPL or the LGPL are applicable instead of those above. If you wish to 00031 * allow use of your version of this file only under the terms of the either 00032 * the GPL or LGPL and not to allow others to use your version of this file 00033 * under the MPL, indicate your decision by deleting the provisions above 00034 * and replace them with the notice and other provisions required by the GPL 00035 * or LGPL. If you do not delete the provisions above, a recipient may use 00036 * your version of this file under the terms of any one of the MPL, the GPL 00037 * or the LGPL. 00038 * ***** END LICENSE BLOCK ***** */ 00039 00040 // Motion Compensation routines. 00041 // Supports different sizes of blocks as long as the parameters 00042 // describing them are 'legal'. Blocks overlap the edge of the image 00043 // being written to but blocks in the reference image are forced to 00044 // lie completely within the image bounds. 00045 00046 #ifndef _INCLUDED_MOT_COMP 00047 #define _INCLUDED_MOT_COMP 00048 00049 #include <cstdlib> 00050 #include <ctime> 00051 #include <iostream> 00052 #include <vector> 00053 #include <libdirac_common/common.h> 00054 #include <libdirac_common/upconvert.h> 00055 #include <libdirac_common/motion.h> 00056 #include <libdirac_common/frame_buffer.h> 00057 00058 namespace dirac 00059 { 00060 class FrameBuffer; 00061 class Frame; 00062 00063 00065 00071 class MotionCompensator 00072 { 00073 00074 public: 00076 00079 MotionCompensator( const CodecParams &cp ); 00081 virtual ~MotionCompensator(); 00082 00084 00094 static void CompensateFrame ( const CodecParams &cp, 00095 const AddOrSub direction , 00096 FrameBuffer& buffer , 00097 const int fnum, 00098 const MvData& mv_data ); 00099 00101 00109 void CompensateFrame( const AddOrSub direction , 00110 FrameBuffer& my_buffer , 00111 int fnum , 00112 const MvData& mv_data ); 00113 00114 private: 00115 //private, body-less copy constructor: this class should not be copied 00116 MotionCompensator( const MotionCompensator& cpy ); 00117 //private, body-less assignment=: this class should not be assigned 00118 MotionCompensator& operator=( const MotionCompensator& rhs ); 00119 00120 //functions 00121 00123 void CompensateComponent( Frame& picframe , 00124 const Frame& ref1frame , 00125 const Frame& ref2frame , 00126 const MvData& mv_data , const CompSort cs); 00127 00130 void DCBlock( TwoDArray<CalcValueType> &pic_data , 00131 const ValueType dc , 00132 const ImageCoords& Pos , 00133 const TwoDArray<CalcValueType>& Weights ); 00134 void ReConfig(); 00135 00136 // Overlapping blocks are acheived by applying a 2D raised cosine shape 00137 // to them. This function facilitates the calculations 00138 float RaisedCosine(float t, float B); 00139 00141 00152 void CreateBlock(const OLBParams &bparams, bool FullX, bool FullY, TwoDArray<CalcValueType>& WeightArray); 00153 00155 void FlipX(const TwoDArray<CalcValueType>& Original, const OLBParams &bparams, TwoDArray<CalcValueType>& Flipped); 00156 00158 void FlipY(const TwoDArray<CalcValueType>& Original, const OLBParams &bparams, TwoDArray<CalcValueType>& Flipped); 00159 00161 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00162 const PicArray& refup_data , 00163 const MVector& Vec , 00164 const ImageCoords& Pos , 00165 const TwoDArray<CalcValueType>& Weights ) = 0; 00166 00167 protected: 00168 //variables 00169 00171 CodecParams m_cparams; 00172 00174 ChromaFormat m_cformat; 00175 bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma 00176 00177 // A marker saying whether we're doing MC addition or subtraction 00178 AddOrSub m_add_or_sub; 00179 00180 // Block information 00181 OLBParams m_bparams; 00182 TwoDArray<CalcValueType>* m_block_weights; 00183 TwoDArray<CalcValueType>* m_half_block_weights; 00184 00185 }; 00186 00188 class MotionCompensator_Pixel : public MotionCompensator 00189 { 00190 00191 public: 00193 00196 MotionCompensator_Pixel (const CodecParams &cp); 00197 00198 private: 00200 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00201 const PicArray& refup_data , 00202 const MVector& Vec , 00203 const ImageCoords& Pos , 00204 const TwoDArray<CalcValueType>& Weights ); 00205 }; 00206 00208 class MotionCompensator_HalfPixel : public MotionCompensator 00209 { 00210 public: 00212 00215 MotionCompensator_HalfPixel (const CodecParams &cp); 00216 private: 00218 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00219 const PicArray& refup_data , 00220 const MVector& Vec , 00221 const ImageCoords& Pos , 00222 const TwoDArray<CalcValueType>& Weights ); 00223 }; 00224 00226 class MotionCompensator_QuarterPixel : public MotionCompensator 00227 { 00228 public: 00230 00233 MotionCompensator_QuarterPixel (const CodecParams &cp); 00234 private: 00236 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00237 const PicArray& refup_data , 00238 const MVector& Vec , 00239 const ImageCoords& Pos , 00240 const TwoDArray<CalcValueType>& Weights ); 00241 }; 00242 00244 class MotionCompensator_EighthPixel : public MotionCompensator 00245 { 00246 public: 00248 00251 MotionCompensator_EighthPixel (const CodecParams &cp); 00252 private: 00254 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00255 const PicArray& refup_data , 00256 const MVector& Vec , 00257 const ImageCoords& Pos , 00258 const TwoDArray<CalcValueType>& Weights ); 00259 }; 00260 00261 00262 } // namespace dirac 00263 00264 #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.