00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _MV_CODEC_H_
00039 #define _MV_CODEC_H_
00040
00042
00043
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
00052 namespace dirac
00053 {
00055
00059 class MvDataCodec: public ArithCodec<MvData>
00060 {
00061 public:
00063
00069 MvDataCodec(BasicOutputManager* bits_out,
00070 size_t number_of_contexts,
00071 const ChromaFormat & cf);
00072
00074
00080 MvDataCodec(BitInputManager* bits_in,
00081 size_t number_of_contexts,
00082 const ChromaFormat & cf);
00083
00085 void InitContexts();
00086
00087 private:
00088 int MB_count;
00089 const ChromaFormat & m_cformat;
00090
00091 int b_xp, b_yp;
00092 int mb_xp, mb_yp;
00093 int mb_tlb_x, mb_tlb_y;
00094
00095
00096 MvDataCodec(const MvDataCodec& cpy);
00097 MvDataCodec& operator=(const MvDataCodec& rhs);
00098
00099
00100 void CodeMBSplit(const MvData& in_data);
00101 void CodeMBCom(const MvData& in_data);
00102 void CodePredmode(const MvData& in_data);
00103 void CodeMv1(const MvData& in_data);
00104 void CodeMv2(const MvData& in_data);
00105 void CodeDC(const MvData& in_data);
00106
00107
00108 void DecodeMBSplit( MvData& out_data);
00109 void DecodeMBCom( MvData& out_data);
00110 void DecodePredmode(MvData& out_data);
00111 void DecodeMv1( MvData& out_data);
00112 void DecodeMv2( MvData& out_data);
00113 void DecodeDC( MvData& out_data);
00114
00115 void DoWorkCode( MvData& in_data );
00116 void DoWorkDecode(MvData& out_data, int num_bits);
00117
00118
00119 void Update( const bool symbol , const int context_num );
00120 void Resize(const int context_num);
00121 void ResetAll();
00122
00123 int ChooseContext(const MvData& data, const int BinNumber) const;
00124 int ChooseContext(const MvData& data) const;
00125 int ChooseSignContext(const MvData& data) const;
00126
00127 int ChooseMBSContext(const MvData& data, const int BinNumber) const;
00128 int ChooseMBCContext(const MvData& data) const;
00129 int ChoosePredContext(const MvData& data, const int BinNumber) const;
00130 int ChooseREF1xContext(const MvData& data, const int BinNumber) const;
00131 int ChooseREF1xSignContext(const MvData& data) const;
00132 int ChooseREF1yContext(const MvData& data, const int BinNumber) const;
00133 int ChooseREF1ySignContext(const MvData& data) const;
00134 int ChooseREF2xContext(const MvData& data, const int BinNumber) const;
00135 int ChooseREF2xSignContext(const MvData& data) const;
00136 int ChooseREF2yContext(const MvData& data, const int BinNumber) const;
00137 int ChooseREF2ySignContext(const MvData& data) const;
00138 int ChooseYDCContext(const MvData& data, const int BinNumber) const;
00139 int ChooseUDCContext(const MvData& data, const int BinNumber) const;
00140 int ChooseVDCContext(const MvData& data, const int BinNumber) const;
00141 int ChooseYDCSignContext(const MvData& data) const;
00142 int ChooseUDCSignContext(const MvData& data) const;
00143 int ChooseVDCSignContext(const MvData& data) const;
00144
00145
00146 unsigned int MBSplitPrediction(const TwoDArray<int>& mbdata) const;
00147 bool MBCBModePrediction(const TwoDArray<bool>& mbdata) const;
00148 unsigned int BlockModePrediction(const TwoDArray<PredMode>& preddata) const;
00149 MVector Mv1Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const;
00150 MVector Mv2Prediction(const MvArray& mvarray,const TwoDArray<PredMode>& preddata) const;
00151 ValueType DCPrediction(const TwoDArray<ValueType>& dcdata,const TwoDArray<PredMode>& preddata) const;
00152 };
00153
00154 }
00155
00156 #endif