Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mot_comp.h,v 1.17 2006/06/26 16:38:51 asuraparaju Exp $ $Name: Dirac_0_8_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): 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 00141 // Overlapping blocks are acheived by applying a 2D linear shape 00142 // to them. This function facilitates the calculations 00143 float Linear(float t, float B); 00144 00145 // Calculates a weighting arrays blocks. 00146 void CalculateWeights(int xblen, int yblen, int xbsep, int ybsep, TwoDArray<ValueType>* wt_array); 00147 00149 00160 void CreateBlock(int xblen, int yblen, int xbsep, int ybsep, bool FullX, bool FullY, TwoDArray<ValueType>& WeightArray); 00161 00163 void FlipX(const TwoDArray<ValueType>& Original, int xblen, int yblen, TwoDArray<ValueType>& Flipped); 00164 00166 void FlipY(const TwoDArray<ValueType>& Original, int xblen, int yblen, TwoDArray<ValueType>& Flipped); 00167 00169 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00170 const ImageCoords &orig_pic_size, 00171 const PicArray& refup_data , 00172 const MVector& Vec , 00173 const ImageCoords& Pos , 00174 const TwoDArray<ValueType>& Weights ) = 0; 00175 00176 protected: 00177 //variables 00178 00180 CodecParams m_cparams; 00181 00183 ChromaFormat m_cformat; 00184 bool luma_or_chroma; //true if we're doing luma, false if we're coding chroma 00185 00186 // A marker saying whether we're doing MC addition or subtraction 00187 AddOrSub m_add_or_sub; 00188 00189 // Block information 00190 OLBParams m_bparams; 00191 // Arrays of Ref1 and Ref2 block weights 00192 TwoDArray<ValueType>* m_block_weights[2]; 00193 // Array of Ref1+Ref2 block weights 00194 TwoDArray<ValueType>* m_full_block_weights; 00195 // Arrays of Ref1 and Ref2 super block weights 00196 TwoDArray<ValueType>* m_macro_block_weights[2]; 00197 // Array of Ref1+Ref2 super block weights 00198 TwoDArray<ValueType>* m_full_macro_block_weights; 00199 // Arrays of Ref1 and Ref2 sub super block weights 00200 TwoDArray<ValueType>* m_sub_block_weights[2]; 00201 // Array of Ref1+Ref2 sub super block weights 00202 TwoDArray<ValueType>* m_full_sub_block_weights; 00203 00204 // OBMC related values 00205 // Max value frame weight in x-direction 00206 CalcValueType m_max_h_weight; 00207 // Max value frame weight in y-direction 00208 CalcValueType m_max_v_weight; 00209 // Bits to round the output of OBMC to 00210 CalcValueType m_shift_bits; 00211 }; 00212 00214 class MotionCompensator_Pixel : public MotionCompensator 00215 { 00216 00217 public: 00219 00222 MotionCompensator_Pixel (const CodecParams &cp); 00223 00224 private: 00226 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00227 const ImageCoords &orig_pic_size, 00228 const PicArray& refup_data , 00229 const MVector& Vec , 00230 const ImageCoords& Pos , 00231 const TwoDArray<ValueType>& Weights ); 00232 }; 00233 00235 class MotionCompensator_HalfPixel : public MotionCompensator 00236 { 00237 public: 00239 00242 MotionCompensator_HalfPixel (const CodecParams &cp); 00243 private: 00245 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00246 const ImageCoords &orig_pic_size, 00247 const PicArray& refup_data , 00248 const MVector& Vec , 00249 const ImageCoords& Pos , 00250 const TwoDArray<ValueType>& Weights ); 00251 }; 00252 00254 class MotionCompensator_QuarterPixel : public MotionCompensator 00255 { 00256 public: 00258 00261 MotionCompensator_QuarterPixel (const CodecParams &cp); 00262 private: 00264 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00265 const ImageCoords &orig_pic_size, 00266 const PicArray& refup_data , 00267 const MVector& Vec , 00268 const ImageCoords& Pos , 00269 const TwoDArray<ValueType>& Weights ); 00270 }; 00271 00273 class MotionCompensator_EighthPixel : public MotionCompensator 00274 { 00275 public: 00277 00280 MotionCompensator_EighthPixel (const CodecParams &cp); 00281 private: 00283 virtual void CompensateBlock( TwoDArray<CalcValueType>& pic_data , 00284 const ImageCoords &orig_pic_size, 00285 const PicArray& refup_data , 00286 const MVector& Vec , 00287 const ImageCoords& Pos , 00288 const TwoDArray<ValueType>& Weights ); 00289 }; 00290 00291 00292 } // namespace dirac 00293 00294 #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.