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 _BAND_CODEC_H_
00039 #define _BAND_CODEC_H_
00040
00041 #include <libdirac_common/arith_codec.h>
00042 #include <libdirac_common/wavelet_utils.h>
00043
00044 namespace dirac
00045 {
00046
00047
00048
00050
00054 class BandCodec: public ArithCodec<PicArray >
00055 {
00056 public:
00057
00059
00066 BandCodec(BasicOutputManager* bits_out,
00067 size_t number_of_contexts,
00068 const SubbandList& band_list,
00069 int band_num);
00070
00072
00079 BandCodec(BitInputManager* bits_in,
00080 size_t number_of_contexts,
00081 const SubbandList& band_list,
00082 int band_num);
00083
00085 void InitContexts();
00086
00087 protected:
00088
00089 void CodeVal(PicArray& in_data, const ValueType val);
00090
00091 void DecodeVal(PicArray& out_data);
00092
00093 private:
00094
00095
00096 virtual void DoWorkCode(PicArray& in_data);
00097
00098 virtual void DoWorkDecode(PicArray& in_data, int num_bits);
00099
00100 void Update( const bool symbol , const int context_num );
00101 void Resize(const int context_num);
00102 void ResetAll();
00103
00104 int ChooseContext(const PicArray& data, const int bin_number) const;
00105 int ChooseContext(const PicArray& data) const;
00106 int ChooseSignContext(const PicArray& data) const;
00107
00108
00109 BandCodec(const BandCodec& cpy);
00110
00111 BandCodec& operator=(const BandCodec& rhs);
00112
00113 protected:
00115 int m_bnum;
00116
00118 const Subband m_node;
00119
00121 int m_xp, m_yp, m_xl, m_yl;
00122
00124 int m_xpos, m_ypos;
00125
00127 int m_vol;
00128
00130 int m_reset_coeff_num;
00131
00133 int m_coeff_count;
00134
00136 int m_qf, m_qfinv;
00137
00139 ValueType m_offset;
00140
00142 ValueType m_nhood_sum;
00143
00145 Subband m_pnode;
00146
00148 int m_pxp, m_pyp, m_pxl, m_pyl;
00149
00151 int m_pxpos, m_pypos;
00152
00154 bool m_parent_notzero;
00155
00157 ValueType m_cut_off_point;
00158 };
00159
00161
00166 class LFBandCodec: public BandCodec
00167 {
00168 public:
00170
00177 LFBandCodec(BasicOutputManager* bits_out,
00178 size_t number_of_contexts,
00179 const SubbandList& band_list,
00180 int band_num)
00181 : BandCodec(bits_out,number_of_contexts,band_list,band_num){}
00182
00184
00191 LFBandCodec(BitInputManager* bits_in,
00192 size_t number_of_contexts,
00193 const SubbandList& band_list,
00194 int band_num)
00195 : BandCodec(bits_in,number_of_contexts,band_list,band_num){}
00196
00197 private:
00198
00199 virtual void DoWorkCode(PicArray& InData);
00200
00201 virtual void DoWorkDecode(PicArray& OutData, int num_bits);
00202
00203 LFBandCodec(const LFBandCodec& cpy);
00204
00205 LFBandCodec& operator=(const LFBandCodec& rhs);
00206
00207 };
00208
00209
00211
00213
00215
00219 class IntraDCBandCodec: public BandCodec
00220 {
00221 public:
00223
00230 IntraDCBandCodec(BasicOutputManager* bits_out,
00231 size_t number_of_contexts,
00232 const SubbandList& band_list)
00233 : BandCodec(bits_out,number_of_contexts,band_list,band_list.Length()){}
00234
00236
00243 IntraDCBandCodec(BitInputManager* bits_in,
00244 size_t number_of_contexts,
00245 const SubbandList& band_list)
00246 : BandCodec(bits_in,number_of_contexts,band_list,band_list.Length()){}
00247
00248 private:
00249
00250 virtual void DoWorkCode(PicArray& InData);
00251
00252 virtual void DoWorkDecode(PicArray& OutData, int num_bits);
00253
00254
00255 IntraDCBandCodec(const IntraDCBandCodec& cpy);
00256
00257 IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00258
00259
00260 ValueType GetPrediction(const PicArray& Data) const;
00261 };
00262
00263 }
00264 #endif