Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mot_comp.h,v 1.14 2005/11/08 11:34:39 asuraparaju Exp $ $Name: Dirac_0_5_4 $ 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 ImageCoords &orig_pic_size, 00132 const ValueType dc , 00133 const ImageCoords& Pos , 00134 const TwoDArray<ValueType>& Weights ); 00135 void ReConfig(); 00136 00137 // Overlapping blocks are acheived by applying a 2D raised cosine shape 00138 // to them. This function facilitates the calculations 00139 float RaisedCosine(float t, float B); 00140 00142 00153 void CreateBlock(int xblen, int yblen, int xbsep, int ybsep, bool FullX, bool FullY, TwoDArray<ValueType>& WeightArray); 00154 00156 void FlipX(const TwoDArray<ValueType>& Original, int xblen, int yblen, TwoDArray<ValueType>& Flipped); 00157 00159 void FlipY(const TwoDArray<ValueType>& Original, int xblen, int yblen, TwoDArray<ValueType>& Flipped); 00160 00162 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00163 const ImageCoords &orig_pic_size, 00164 const PicArray& refup_data , 00165 const MVector& Vec , 00166 const ImageCoords& Pos , 00167 const TwoDArray<ValueType>& Weights ) = 0; 00168 00169 protected: 00170 //variables 00171 00173 CodecParams m_cparams; 00174 00176 ChromaFormat m_cformat; 00177 bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma 00178 00179 // A marker saying whether we're doing MC addition or subtraction 00180 AddOrSub m_add_or_sub; 00181 00182 // Block information 00183 OLBParams m_bparams; 00184 TwoDArray<ValueType>* m_block_weights; 00185 TwoDArray<ValueType>* m_half_block_weights; 00186 TwoDArray<ValueType>* m_macro_block_weights; 00187 TwoDArray<ValueType>* m_half_macro_block_weights; 00188 TwoDArray<ValueType>* m_sub_block_weights; 00189 TwoDArray<ValueType>* m_half_sub_block_weights; 00190 }; 00191 00193 class MotionCompensator_Pixel : public MotionCompensator 00194 { 00195 00196 public: 00198 00201 MotionCompensator_Pixel (const CodecParams &cp); 00202 00203 private: 00205 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00206 const ImageCoords &orig_pic_size, 00207 const PicArray& refup_data , 00208 const MVector& Vec , 00209 const ImageCoords& Pos , 00210 const TwoDArray<ValueType>& Weights ); 00211 }; 00212 00214 class MotionCompensator_HalfPixel : public MotionCompensator 00215 { 00216 public: 00218 00221 MotionCompensator_HalfPixel (const CodecParams &cp); 00222 private: 00224 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00225 const ImageCoords &orig_pic_size, 00226 const PicArray& refup_data , 00227 const MVector& Vec , 00228 const ImageCoords& Pos , 00229 const TwoDArray<ValueType>& Weights ); 00230 }; 00231 00233 class MotionCompensator_QuarterPixel : public MotionCompensator 00234 { 00235 public: 00237 00240 MotionCompensator_QuarterPixel (const CodecParams &cp); 00241 private: 00243 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00244 const ImageCoords &orig_pic_size, 00245 const PicArray& refup_data , 00246 const MVector& Vec , 00247 const ImageCoords& Pos , 00248 const TwoDArray<ValueType>& Weights ); 00249 }; 00250 00252 class MotionCompensator_EighthPixel : public MotionCompensator 00253 { 00254 public: 00256 00259 MotionCompensator_EighthPixel (const CodecParams &cp); 00260 private: 00262 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00263 const ImageCoords &orig_pic_size, 00264 const PicArray& refup_data , 00265 const MVector& Vec , 00266 const ImageCoords& Pos , 00267 const TwoDArray<ValueType>& Weights ); 00268 }; 00269 00270 00271 } // namespace dirac 00272 00273 #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.