Dirac - A Video Codec

Created by the British Broadcasting Corporation.


mv_codec.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: mv_codec.h,v 1.8 2004/08/11 14:40:01 asuraparaju Exp $ $Name: Dirac_0_4_3 $ 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), Scott R Ladd 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 _MV_CODEC_H_ 00039 #define _MV_CODEC_H_ 00040 00042 //Class to do motion vector coding and decoding// 00043 //------using adaptive arithmetic coding-------// 00045 00046 #include <libdirac_common/arith_codec.h> 00047 #include <libdirac_common/common.h> 00048 #include <libdirac_common/motion.h> 00049 #include <libdirac_common/wavelet_utils.h> 00050 #include <vector> 00051 00053 00056 class MvDataCodec: public ArithCodec<MvData> 00057 { 00058 public: 00060 00067 MvDataCodec(BasicOutputManager* bits_out, 00068 size_t number_of_contexts, 00069 const ChromaFormat & cf); 00070 00072 00079 MvDataCodec(BitInputManager* bits_in, 00080 size_t number_of_contexts, 00081 const ChromaFormat & cf); 00082 00084 void InitContexts(); 00085 00086 private: 00087 int MB_count; 00088 const ChromaFormat & m_cformat; 00089 00090 int b_xp, b_yp; //position of current block 00091 int mb_xp, mb_yp; //position of current MB 00092 int mb_tlb_x, mb_tlb_y; //position of top-left block of current MB 00093 00094 // functions 00095 MvDataCodec(const MvDataCodec& cpy); //private, bodyless copy constructor: class should not be copied 00096 MvDataCodec& operator=(const MvDataCodec& rhs); //private, bodyless copy operator=: class should not be assigned 00097 00098 // coding functions 00099 void CodeMBSplit(const MvData& in_data); //code the MB splitting mode 00100 void CodeMBCom(const MvData& in_data); //code the MB common ref mode 00101 void CodePredmode(const MvData& in_data); //code the block prediction mode 00102 void CodeMv1(const MvData& in_data); //code the first motion vector 00103 void CodeMv2(const MvData& in_data); //code the second motion vector 00104 void CodeDC(const MvData& in_data); //code the dc value of intra blocks 00105 00106 // decoding functions 00107 void DecodeMBSplit( MvData& out_data); //decode the MB splitting mode 00108 void DecodeMBCom( MvData& out_data);//decode the MB common ref mode 00109 void DecodePredmode(MvData& out_data);//decode the block prediction mode 00110 void DecodeMv1( MvData& out_data); //decode the first motion vector 00111 void DecodeMv2( MvData& out_data); //decode the second motion vector 00112 void DecodeDC( MvData& out_data); //decode the dc value of intra blocks 00113 00114 void DoWorkCode( MvData& in_data ); 00115 void DoWorkDecode(MvData& out_data, int num_bits); 00116 00117 // Context stuff 00118 void Update( const bool symbol , const int context_num ); 00119 void Resize(const int context_num); 00120 void ResetAll(); 00121 00122 int ChooseContext(const MvData& data, const int BinNumber) const; 00123 int ChooseContext(const MvData& data) const; 00124 int ChooseSignContext(const MvData& data) const; 00125 00126 int ChooseMBSContext(const MvData& data, const int BinNumber) const; 00127 int ChooseMBCContext(const MvData& data) const; 00128 int ChoosePredContext(const MvData& data, const int BinNumber) const; 00129 int ChooseREF1xContext(const MvData& data, const int BinNumber) const; 00130 int ChooseREF1xSignContext(const MvData& data) const; 00131 int ChooseREF1yContext(const MvData& data, const int BinNumber) const; 00132 int ChooseREF1ySignContext(const MvData& data) const; 00133 int ChooseREF2xContext(const MvData& data, const int BinNumber) const; 00134 int ChooseREF2xSignContext(const MvData& data) const; 00135 int ChooseREF2yContext(const MvData& data, const int BinNumber) const; 00136 int ChooseREF2ySignContext(const MvData& data) const; 00137 int ChooseYDCContext(const MvData& data, const int BinNumber) const; 00138 int ChooseUDCContext(const MvData& data, const int BinNumber) const; 00139 int ChooseVDCContext(const MvData& data, const int BinNumber) const; 00140 int ChooseYDCSignContext(const MvData& data) const; 00141 int ChooseUDCSignContext(const MvData& data) const; 00142 int ChooseVDCSignContext(const MvData& data) const; 00143 00144 //prediction stuff 00145 unsigned int MBSplitPrediction(const TwoDArray<int>& mbdata) const; 00146 bool MBCBModePrediction(const TwoDArray<bool>& mbdata) const; 00147 unsigned int BlockModePrediction(const TwoDArray<PredMode>& preddata) const; 00148 MVector Mv1Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const; 00149 MVector Mv2Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const; 00150 ValueType DCPrediction(const TwoDArray<ValueType>& dcdata,const TwoDArray<PredMode>& preddata) const; 00151 }; 00152 00153 #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.