band_codec.h

00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: band_codec.h,v 1.2 2005/01/30 05:11:40 gabest Exp $ $Name:  $
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     //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands
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         // Code an individual value
00089         void CodeVal(PicArray& in_data, const ValueType val);
00090         // Decode an individual value
00091         void DecodeVal(PicArray& out_data);
00092 
00093     private:
00094         // Functions
00095         // Overridden from the base class
00096         virtual void DoWorkCode(PicArray& in_data);
00097         // Overridden from the base class
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         // Private, bodyless copy constructor: class should not be copied
00109         BandCodec(const BandCodec& cpy);
00110         // Private, bodyless copy operator=: class should not be assigned
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         // Overridden from the base class
00199         virtual void DoWorkCode(PicArray& InData);
00200         // Overridden from the base class
00201         virtual void DoWorkDecode(PicArray& OutData, int num_bits);
00202         // Private, bodyless copy constructor: class should not be copied
00203         LFBandCodec(const LFBandCodec& cpy);
00204         // Private, bodyless copy operator=: class should not be assigned
00205         LFBandCodec& operator=(const LFBandCodec& rhs);
00206 
00207     };
00208 
00209 
00211     //Finally,special class incorporating prediction for the DC band of intra frames//
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         // Overridden from the base class
00250         virtual void DoWorkCode(PicArray& InData);
00251         // Overridden from the base class
00252         virtual void DoWorkDecode(PicArray& OutData, int num_bits);
00253 
00254         // Private, bodyless copy constructor: class should not be copied
00255         IntraDCBandCodec(const IntraDCBandCodec& cpy);
00256         // Private, bodyless copy operator=: class should not be assigned
00257         IntraDCBandCodec& operator=(const IntraDCBandCodec& rhs);
00258 
00259         // Prediction of a DC value from its previously coded neighbours
00260         ValueType GetPrediction(const PicArray& Data) const;
00261     };
00262 
00263 } // namespace dirac
00264 #endif

Generated on Tue Dec 13 14:47:12 2005 for guliverkli by  doxygen 1.4.5