Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: band_codec.h,v 1.19 2006/06/08 16:55:11 asuraparaju Exp $ $Name: Dirac_0_6_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): Thomas Davies (Original Author), 00024 * Scott R Ladd, 00025 * Steve Bearcroft 00026 * Andrew Kennedy 00027 * 00028 * Alternatively, the contents of this file may be used under the terms of 00029 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00030 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00031 * the GPL or the LGPL are applicable instead of those above. If you wish to 00032 * allow use of your version of this file only under the terms of the either 00033 * the GPL or LGPL and not to allow others to use your version of this file 00034 * under the MPL, indicate your decision by deleting the provisions above 00035 * and replace them with the notice and other provisions required by the GPL 00036 * or LGPL. If you do not delete the provisions above, a recipient may use 00037 * your version of this file under the terms of any one of the MPL, the GPL 00038 * or the LGPL. 00039 * ***** END LICENSE BLOCK ***** */ 00040 00041 #ifndef _BAND_CODEC_H_ 00042 #define _BAND_CODEC_H_ 00043 00044 #include <libdirac_common/arith_codec.h> 00045 #include <libdirac_common/wavelet_utils.h> 00046 00047 00048 namespace dirac 00049 { 00050 00051 class SubbandByteIO; 00052 00053 //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands 00054 00055 00057 00060 class BandCodec: public ArithCodec<PicArray> 00061 { 00062 public: 00063 00065 00072 BandCodec(SubbandByteIO* subband_byteio, 00073 size_t number_of_contexts, 00074 const SubbandList& band_list, 00075 int band_num); 00076 00078 void InitContexts(); 00079 00080 protected: 00082 inline void CodeVal( PicArray& in_data , const int xpos , const int ypos , const ValueType val); 00083 00085 inline void DecodeVal(PicArray& out_data , const int xpos , const int ypos ); 00086 00088 void CodeQIndexOffset( const int offset ); 00089 00091 int DecodeQIndexOffset(); 00092 00094 inline void SetToVal( const CodeBlock& code_block , PicArray& pic_data , const ValueType val); 00095 00097 inline void ClearBlock( const CodeBlock& code_block , PicArray& pic_data); 00098 00099 private: 00100 //functions 00101 // Overridden from the base class 00102 virtual void DoWorkCode(PicArray& in_data); 00103 // Ditto 00104 virtual void DoWorkDecode(PicArray& out_data); 00105 00106 virtual void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00107 virtual void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00108 00109 void ResetAll(); 00110 00112 inline int ChooseFollowContext( const int bin_number ) const; 00113 00115 inline int ChooseInfoContext() const; 00116 00118 inline int ChooseSignContext(const PicArray& data , const int xpos , const int ypos ) const; 00119 00121 BandCodec(const BandCodec& cpy); 00123 BandCodec& operator=(const BandCodec& rhs); 00124 00125 protected: 00127 int m_bnum; 00128 00130 const Subband m_node; 00131 00133 int m_vol; 00134 00136 int m_reset_coeff_num; 00137 00139 int m_coeff_count; 00140 00142 int m_qf; 00143 00145 ValueType m_offset; 00146 00148 ValueType m_nhood_sum; 00149 00151 Subband m_pnode; 00152 00154 int m_pxp, m_pyp, m_pxl, m_pyl; 00155 00157 int m_pxpos, m_pypos; 00158 00160 bool m_parent_notzero; 00161 00162 }; 00163 00165 00169 class LFBandCodec: public BandCodec 00170 { 00171 public: 00173 00180 LFBandCodec(SubbandByteIO* subband_byteio, 00181 size_t number_of_contexts, 00182 const SubbandList& band_list, 00183 int band_num) 00184 : BandCodec(subband_byteio,number_of_contexts,band_list,band_num){} 00185 00186 private: 00187 // Overridden from the base class 00188 void DoWorkCode(PicArray& in_data); 00189 // Ditto 00190 void DoWorkDecode(PicArray& out_data); 00191 00192 void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00193 void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00194 00196 LFBandCodec(const LFBandCodec& cpy); 00198 LFBandCodec& operator=(const LFBandCodec& rhs); 00199 00200 }; 00201 00202 00204 //Finally,special class incorporating prediction for the DC band of intra frames// 00206 00208 00212 class IntraDCBandCodec: public BandCodec 00213 { 00214 public: 00216 00222 IntraDCBandCodec(SubbandByteIO* subband_byteio, 00223 size_t number_of_contexts, 00224 const SubbandList& band_list) 00225 : BandCodec(subband_byteio,number_of_contexts,band_list,band_list.Length()){} 00226 00227 00228 private: 00229 void DoWorkCode(PicArray& in_data); //overridden from the base class 00230 void DoWorkDecode(PicArray& out_data); //ditto 00231 00232 void CodeCoeffBlock(const CodeBlock& code_block , PicArray& in_data); 00233 void DecodeCoeffBlock(const CodeBlock& code_block , PicArray& out_data); 00234 00236 IntraDCBandCodec(const IntraDCBandCodec& cpy); 00237 00239 IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs); 00240 00242 ValueType GetPrediction(const PicArray& data , const int xpos , const int ypos ) const; 00243 00244 private: 00245 PicArray m_dc_pred_res; 00246 }; 00247 00248 00249 }// end namespace dirac 00250 #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.