Updating Contact email
[BrunelResearch-dirac.git] / libdirac_encoder / picture_compress.h
blobfb6cef26fc2049e585fb0331bd2972c9dd00cd01
1 /* ***** BEGIN LICENSE BLOCK *****
3 * $Id$ $Name$
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 * The Original Code is BBC Research and Development code.
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.
23 * Contributor(s): Thomas Davies (Original Author),
24 * Scott R Ladd,
25 * Anuradha Suraparaju
26 * Andrew Kennedy
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 ***** */
42 #ifndef _PICTURE_COMPRESS_H_
43 #define _PICTURE_COMPRESS_H_
45 #include <libdirac_encoder/enc_queue.h>
46 #include <libdirac_common/common.h>
47 #include <libdirac_common/motion.h>
48 #include <libdirac_byteio/picture_byteio.h>
50 namespace dirac
53 class MvData;
55 //! Compress a single image picture
56 /*!
57 This class compresses a single picture at a time, using parameters
58 supplied at its construction. PictureCompressor is used by
59 SequenceCompressor.
61 class PictureCompressor
63 public:
64 //! Constructor
65 /*!
66 Creates a FrameEncoder with specific set of parameters the control
67 the compression process. It encodes motion data before encoding
68 each component of the picture.
69 \param encp encoder parameters
71 PictureCompressor( EncoderParams& encp );
73 //! Destructor
74 ~PictureCompressor( );
76 //! Do pixel accurate motion estimate
77 void PixelME( EncQueue& my_buffer , int pnum );
79 //! Calculate the complexity of a picture
80 void CalcComplexity( EncQueue& my_buffer, int pnum , const OLBParams& olbparams );
81 void CalcComplexity2( EncQueue& my_buffer, int pnum );
83 //! Normalise picture complexity with respect to others in the queue
84 void NormaliseComplexity( EncQueue& my_buffer, int pnum );
86 //! Do subpixel accurate motion vector refinement
87 void SubPixelME( EncQueue& my_buffer , int pnum );
89 //! Do mode decision based on sub-pel vectors
90 void ModeDecisionME( EncQueue& my_buffer, int pnum );
92 //! Detect cuts in the current picture
93 void IntraModeAnalyse( EncQueue& my_buffer, int pnum );
95 //! Does motion compensation on picture pnum (forward or backward)
96 void MotionCompensate( EncQueue& my_buffer, int pnum, AddOrSub dirn );
98 //! Prefilter if required
99 void Prefilter( EncQueue& my_buffer, int pnum );
101 //! Do the DWT on a given picture
102 void DoDWT( EncQueue& my_buffer , int pnum, Direction dirn );
104 //! Compress a specific picture within a group of pictures (GOP)
106 Compresses a specified picture within a group of pictures.
107 \param my_pbuffer picture buffer in which the reference frames resides
108 \param pnum picture number to compress
109 \param pic_byteio compressed picture in Dirac bytestream format
111 void CodeResidue( EncQueue& my_pbuffer , int pnum , PictureByteIO* pic_byteio);
113 //! Compresses the motion vector data
114 void CodeMVData( EncQueue& my_buffer, int pnum, PictureByteIO* pic_byteio);
116 //! Returns true if the picture has been skipped rather than coded normally
117 bool IsSkipped(){ return m_skipped; }
119 //! Returns true if Motion estimation data is available
120 bool IsMEDataAvail() const { return m_medata_avail; }
122 //! Returns the motion estimation data
123 const MEData* GetMEData() const;
125 private:
126 //! Copy constructor is private and body-less
128 Copy constructor is private and body-less. This class should not
129 be copied.
131 PictureCompressor( const PictureCompressor& cpy );
133 //! Assignment = is private and body-less
135 Assignment = is private and body-less. This class should not be
136 assigned.
138 PictureCompressor& operator=(const PictureCompressor& rhs);
140 //! Initialise the coefficient data array for holding wavelet coefficients
141 void InitCoeffData( CoeffArray& coeff_data, const int xl, const int yl );
143 //! Returns the value lambda according to picture and component type
144 float GetCompLambda( const EncPicture& my_picture,
145 const CompSort csort );
147 void SelectQuantisers( CoeffArray& coeff_data ,
148 SubbandList& bands ,
149 const float lambda,
150 OneDArray<unsigned int>& est_counts,
151 const CodeBlockMode cb_mode,
152 const PictureParams& pp,
153 const CompSort csort );
155 int SelectMultiQuants( CoeffArray& coeff_data ,
156 SubbandList& bands ,
157 const int band_num,
158 const float lambda,
159 const PictureParams& pp,
160 const CompSort csort );
162 void SetupCodeBlocks( SubbandList& bands );
165 void AddSubAverage(CoeffArray& coeff_data,int xl,int yl,AddOrSub dirn);
167 private:
169 //member variables
170 // a local copy of the encoder params
171 EncoderParams& m_encparams;
173 // True if the picture has been skipped, false otherwise
174 bool m_skipped;
176 // True if we use global motion vectors, false otherwise
177 bool m_use_global;
179 // True if we use block motion vectors, false otherwise
180 bool m_use_block_mv;
182 // Prediction mode to use if we only have global motion vectors
183 PredMode m_global_pred_mode;
185 // A pointer to the current picture motion vector data
186 MEData* m_me_data;
188 // True if motion estimation data is available
189 bool m_medata_avail;
191 // True if we have detected a cut
192 bool m_is_a_cut;
194 // The original MV precision type
195 MVPrecisionType m_orig_prec;
199 } // namespace dirac
201 #endif