Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: band_codec.h,v 1.11 2005/02/15 11:15:32 asuraparaju Exp $ $Name: Dirac_0_5_1 $ 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 _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 //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands 00048 00049 00051 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: 00089 void CodeVal( PicArray& in_data , const int xpos , const int ypos , const ValueType val); 00090 00092 void DecodeVal(PicArray& out_data , const int xpos , const int ypos ); 00093 00095 void SetToVal( const CodeBlock& code_block , PicArray& pic_data , const ValueType val); 00096 00097 private: 00098 //functions 00099 // Overridden from the base class 00100 virtual void DoWorkCode(PicArray& in_data); 00101 // Ditto 00102 virtual void DoWorkDecode(PicArray& out_data); 00103 00104 virtual void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00105 virtual void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00106 00107 void Update( const bool symbol , const int context_num ); 00108 void ResetAll(); 00109 00110 int ChooseContext( const int bin_number) const; 00111 int ChooseSignContext(const PicArray& data , const int xpos , const int ypos ) const; 00112 00114 BandCodec(const BandCodec& cpy); 00116 BandCodec& operator=(const BandCodec& rhs); 00117 00118 protected: 00120 int m_bnum; 00121 00123 const Subband m_node; 00124 00126 int m_vol; 00127 00129 int m_reset_coeff_num; 00130 00132 int m_coeff_count; 00133 00135 int m_qf, m_qfinv; 00136 00138 ValueType m_offset; 00139 00141 ValueType m_nhood_sum; 00142 00144 Subband m_pnode; 00145 00147 int m_pxp, m_pyp, m_pxl, m_pyl; 00148 00150 int m_pxpos, m_pypos; 00151 00153 bool m_parent_notzero; 00154 00156 ValueType m_cut_off_point; 00157 }; 00158 00160 00164 class LFBandCodec: public BandCodec 00165 { 00166 public: 00168 00175 LFBandCodec(BasicOutputManager* bits_out, 00176 size_t number_of_contexts, 00177 const SubbandList& band_list, 00178 int band_num) 00179 : BandCodec(bits_out,number_of_contexts,band_list,band_num){} 00180 00182 00189 LFBandCodec(BitInputManager* bits_in, 00190 size_t number_of_contexts, 00191 const SubbandList& band_list, 00192 int band_num) 00193 : BandCodec(bits_in,number_of_contexts,band_list,band_num){} 00194 00195 private: 00196 // Overridden from the base class 00197 void DoWorkCode(PicArray& in_data); 00198 // Ditto 00199 void DoWorkDecode(PicArray& out_data); 00200 00201 void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00202 void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00203 00205 LFBandCodec(const LFBandCodec& cpy); 00207 LFBandCodec& operator=(const LFBandCodec& rhs); 00208 00209 }; 00210 00211 00213 //Finally,special class incorporating prediction for the DC band of intra frames// 00215 00217 00221 class IntraDCBandCodec: public BandCodec 00222 { 00223 public: 00225 00231 IntraDCBandCodec(BasicOutputManager* bits_out, 00232 size_t number_of_contexts, 00233 const SubbandList& band_list) 00234 : BandCodec(bits_out,number_of_contexts,band_list,band_list.Length()){} 00235 00237 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 void DoWorkCode(PicArray& in_data); //overridden from the base class 00250 void DoWorkDecode(PicArray& out_data); //ditto 00251 00252 void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00253 void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00254 00256 IntraDCBandCodec(const IntraDCBandCodec& cpy); 00257 00259 IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs); 00260 00262 ValueType GetPrediction(const PicArray& data , const int xpos , const int ypos ) const; 00263 00264 private: 00265 PicArray m_dc_pred_res; 00266 }; 00267 00268 00269 }// end namespace dirac 00270 #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.