Dirac - A Video Codec

Created by the British Broadcasting Corporation.


band_codec.h
Go to the documentation of this file.
1/* ***** BEGIN LICENSE BLOCK *****
2*
3* $Id: band_codec.h,v 1.36 2009/01/21 05:18:09 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4*
5* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6*
7* The contents of this file are subject to the Mozilla Public License
8* Version 1.1 (the "License"); you may not use this file except in compliance
9* with the License. You may obtain a copy of the License at
10* http://www.mozilla.org/MPL/
11*
12* Software distributed under the License is distributed on an "AS IS" basis,
13* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14* the specific language governing rights and limitations under the License.
15*
16* The Original Code is BBC Research and Development code.
17*
18* The Initial Developer of the Original Code is the British Broadcasting
19* Corporation.
20* Portions created by the Initial Developer are Copyright (C) 2004.
21* All Rights Reserved.
22*
23* Contributor(s): Thomas Davies (Original Author),
24* Scott R Ladd,
25* Steve Bearcroft
26* Andrew Kennedy
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
30* Public License Version 2.1 (the "LGPL"), in which case the provisions of
31* the GPL or the LGPL are applicable instead of those above. If you wish to
32* allow use of your version of this file only under the terms of the either
33* the GPL or LGPL and not to allow others to use your version of this file
34* under the MPL, indicate your decision by deleting the provisions above
35* and replace them with the notice and other provisions required by the GPL
36* or LGPL. If you do not delete the provisions above, a recipient may use
37* your version of this file under the terms of any one of the MPL, the GPL
38* or the LGPL.
39* ***** END LICENSE BLOCK ***** */
40
41#ifndef _BAND_CODEC_H_
42#define _BAND_CODEC_H_
43
46
47
48namespace dirac
49{
50
51 class SubbandByteIO;
52
53 //Subclasses the arithmetic codec to produce a coding/decoding tool for subbands
54
55
57 template<typename EntropyCodec>
58 class GenericBandCodec: public EntropyCodec
59 {
60 public:
61
63
72 size_t number_of_contexts,
73 const SubbandList& band_list,
74 int band_num,
75 const bool is_intra);
76
77 protected:
79 inline void CodeVal( CoeffArray& in_data , const int xpos , const int ypos , const CoeffType val);
80
82 inline void DecodeVal(CoeffArray& out_data , const int xpos , const int ypos );
83
85 void CodeQuantIndexOffset( const int offset );
86
89
91 inline void SetToVal( const CodeBlock& code_block , CoeffArray& coeff_data , const CoeffType val);
92
94 virtual void ClearBlock( const CodeBlock& code_block , CoeffArray& coeff_data);
95
96 protected:
97 //functions
98 // Overridden from the base class
99 virtual void DoWorkCode(CoeffArray& in_data);
100 // Ditto
101 virtual void DoWorkDecode(CoeffArray& out_data);
102
103 virtual void CodeCoeffBlock(const CodeBlock& code_block , CoeffArray& in_data);
104 virtual void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
105
106 virtual void CodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
107
108 virtual void DecodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
110 inline int ChooseFollowContext( const int bin_number ) const;
111
113 inline int ChooseInfoContext() const;
114
116 inline int ChooseSignContext(const CoeffArray& data , const int xpos , const int ypos ) const;
117
118 private:
123
124 protected:
125
128
131
134
137
139 int m_qf;
140
143
146
149
152
155
156 };
157
159
164
166 //Finally,special class incorporating prediction for the DC band of intra frames//
168
170 template<typename EntropyCodec>
171 class GenericIntraDCBandCodec : public GenericBandCodec<EntropyCodec>
172 {
173 public:
175
182 size_t number_of_contexts,
183 const SubbandList& band_list)
184 : GenericBandCodec<EntropyCodec>(subband_byteio,number_of_contexts,
185 band_list, band_list.Length(),
186 true){}
187
188 protected:
190 void ClearBlock( const CodeBlock& code_block , CoeffArray& coeff_data);
191
193 CoeffType GetPrediction(const CoeffArray& data , const int xpos , const int ypos ) const;
194
196 void DecodeCoeffBlock(const CodeBlock& code_block , CoeffArray& out_data);
197 };
198
199
201
206 class IntraDCBandCodec: public GenericIntraDCBandCodec<ArithCodec<CoeffArray> >
207 {
208 public:
210
217 size_t number_of_contexts,
218 const SubbandList& band_list)
220 number_of_contexts,
221 band_list){}
222
223
224 private:
226 void DoWorkCode(CoeffArray& in_data); //overridden from the base class
227
229 void DoWorkDecode(CoeffArray& out_data);
230
232 void CodeCoeff(CoeffArray& in_data, const int xpos, const int ypos);
233
235 void DecodeCoeff(CoeffArray& out_data, const int xpos, const int ypos);
236
239
242
243 private:
245 };
246
247}// end namespace dirac
248#endif
Definition of class SequenceHeaderByteIO.
Definition accessunit_byteio.h:52
int CoeffType
Type of wavelet coefficient data (should be larger than ValueType)
Definition common.h:74
GenericBandCodec< ArithCodec< CoeffArray > > BandCodec
A general class for coding and decoding wavelet subband data.
Definition band_codec.h:162
BandCodec LFBandCodec
Definition band_codec.h:163
Subband Dirac-bytestream input/output.
Definition subband_byteio.h:57
Abstract binary arithmetic coding class.
Definition arith_codec.h:376
A template class for coding and decoding wavelet subband data.
Definition band_codec.h:59
virtual void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Definition band_codec_template.h:231
virtual void CodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Definition band_codec_template.h:106
int ChooseSignContext(const CoeffArray &data, const int xpos, const int ypos) const
A function for choosing the context for sign bits.
Definition band_codec_template.h:419
const Subband m_node
Definition band_codec.h:133
GenericBandCodec(const GenericBandCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
void CodeQuantIndexOffset(const int offset)
Encode the offset for a code block quantiser.
Definition band_codec_template.h:176
int DecodeQuantIndexOffset()
Decode the offset for a code block quantiser.
Definition band_codec_template.h:456
int ChooseInfoContext() const
A function for choosing the context for "information bits".
Definition band_codec_template.h:413
void DecodeVal(CoeffArray &out_data, const int xpos, const int ypos)
Decode an individual quantised value and perform inverse-quantisation.
Definition band_codec_template.h:330
bool m_parent_notzero
Definition band_codec.h:154
virtual void CodeCoeffBlock(const CodeBlock &code_block, CoeffArray &in_data)
Definition band_codec_template.h:53
Subband m_pnode
Definition band_codec.h:148
virtual void ClearBlock(const CodeBlock &code_block, CoeffArray &coeff_data)
Set all block values to 0.
Definition band_codec_template.h:488
int m_last_qf_idx
Definition band_codec.h:136
virtual void DoWorkCode(CoeffArray &in_data)
Definition band_codec_template.h:27
void SetToVal(const CodeBlock &code_block, CoeffArray &coeff_data, const CoeffType val)
Set a code block area to a given value.
Definition band_codec_template.h:476
GenericBandCodec & operator=(const GenericBandCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
virtual void DecodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Definition band_codec_template.h:306
CoeffType m_offset
Definition band_codec.h:142
GenericBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list, int band_num, const bool is_intra)
Constructor.
Definition band_codec_template.h:9
int ChooseFollowContext(const int bin_number) const
A function for choosing the context for "follow bits".
Definition band_codec_template.h:358
void CodeVal(CoeffArray &in_data, const int xpos, const int ypos, const CoeffType val)
Code an individual quantised value and perform inverse-quantisation.
Definition band_codec_template.h:131
bool m_nhood_nonzero
Definition band_codec.h:145
bool m_is_intra
Definition band_codec.h:127
virtual void DoWorkDecode(CoeffArray &out_data)
Definition band_codec_template.h:205
void ClearBlock(const CodeBlock &code_block, CoeffArray &coeff_data)
When coding a skipped block, propegate the predicted values for future non skipped blocks.
Definition band_codec_template.h:518
GenericIntraDCBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list)
Constructor.
Definition band_codec.h:181
CoeffType GetPrediction(const CoeffArray &data, const int xpos, const int ypos) const
Prediction of a DC value from its previously coded neighbours.
Definition band_codec_template.h:531
void DecodeCoeffBlock(const CodeBlock &code_block, CoeffArray &out_data)
Decode codeblock of coefficients and perform DC prediction.
Definition band_codec_template.h:500
void DoWorkDecode(CoeffArray &out_data)
Ditto.
void CodeCoeff(CoeffArray &in_data, const int xpos, const int ypos)
Encode a single coefficient using error-feedback DC quantization.
IntraDCBandCodec(const IntraDCBandCodec &cpy)
Private, bodyless copy constructor: class should not be copied.
void DecodeCoeff(CoeffArray &out_data, const int xpos, const int ypos)
Decode a single coefficient using error-feedback DC quantization.
IntraDCBandCodec & operator=(const IntraDCBandCodec &rhs)
Private, bodyless copy operator=: class should not be assigned.
IntraDCBandCodec(SubbandByteIO *subband_byteio, size_t number_of_contexts, const SubbandList &band_list)
Constructor.
Definition band_codec.h:216
void DoWorkCode(CoeffArray &in_data)
Initialize extra data required for error-feedback DC quantization.
CoeffArray m_dc_pred_res
Definition band_codec.h:244
Class for encapsulating metadata concerning a block of coefficients in a subband.
Definition wavelet_utils.h:60
Class encapsulating all the metadata relating to a wavelet subband.
Definition wavelet_utils.h:140
A class encapulating all the subbands produced by a transform.
Definition wavelet_utils.h:280
A class for wavelet coefficient data.
Definition wavelet_utils.h:623

© 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.