Dirac - A Video Codec

Created by the British Broadcasting Corporation.


rate_control.h
Go to the documentation of this file.
1/* ***** BEGIN LICENSE BLOCK *****
2*
3* $Id: rate_control.h,v 1.7 2008/01/31 11:25:18 tjdwave 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): Myo Tun (Original Author, myo.tun@brunel.ac.uk)
24* Jonathan Loo (Jonathan.Loo@brunel.ac.uk)
25* School of Engineering and Design, Brunel University, UK
26*
27* Alternatively, the contents of this file may be used under the terms of
28* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
29* Public License Version 2.1 (the "LGPL"), in which case the provisions of
30* the GPL or the LGPL are applicable instead of those above. If you wish to
31* allow use of your version of this file only under the terms of the either
32* the GPL or LGPL and not to allow others to use your version of this file
33* under the MPL, indicate your decision by deleting the provisions above
34* and replace them with the notice and other provisions required by the GPL
35* or LGPL. If you do not delete the provisions above, a recipient may use
36* your version of this file under the terms of any one of the MPL, the GPL
37* or the LGPL.
38* ***** END LICENSE BLOCK ***** */
39
40
41//Compression of an individual component,
42//after motion compensation if appropriate
44
45#ifndef _RATE_CONTROL_H_
46#define _RATE_CONTROL_H_
47
49
50namespace dirac
51{
53 {
54 public:
57
59 int IComplexity() {return m_XI;}
60
62 int L1Complexity() {return m_XL1;}
63
65 int L2Complexity() {return m_XL2;}
66
68 void SetIComplexity(int cpx) {m_XI = cpx;}
69
71 void SetL1Complexity(int cpx) {m_XL1 = cpx;}
72
74 void SetL2Complexity(int cpx) {m_XL2 = cpx;}
75
76
77 private:
78
80 int m_XI;
81
83 int m_XL1;
84
86 int m_XL2;
87 };
88
89
92 {
93 public:
94
96 RateController(int trate, SourceParams& srcp, EncoderParams& encp);
97
98
100 void CalcNextQualFactor(const PictureParams& fparams, int num_bits);
101
104
107
109 double IntraQualFactor() {return m_I_qf;}
110
112 double QualFactor() {return m_qf;}
113
115 void Report();
116
117
118 private:
119
121
123
125 void Allocate(const int fnum);
126
128 void CalcTotalBits(const SourceParams& sourceparams);
129
131 void SetIntraQualFactor(double value){m_I_qf = value;}
132
135
137 float ReviewQualityFactor( const float qfac, const long int num_bits );
138
140 float ClipQualityFactor( const float qfac );
141
143 void UpdateBuffer( const long int num_bits );
144
145
146 private:
147
149 double m_qf;
150
152 double m_I_qf;
153
156
158 const int m_target_rate;
159
162
165
168
171
174
177
180
183
185 const long int m_buffer_size;
186
189
192
195
197 long int m_GOP_target;
198
201
204
207
210
211 // Indicated whether a sequence is being coded intra only or not
213
214 // Sum of complexity of L2 frames
216
217 };
218
219
220}// namespace dirac
221#endif
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:52
Parameters relating to the source material being encoded/decoded.
Definition: common.h:289
Parameters for initialising picture class objects.
Definition: common.h:533
Parameters for the encoding process.
Definition: common.h:1280
Definition: rate_control.h:53
void SetL2Complexity(int cpx)
Set the complexity of L2 frame.
Definition: rate_control.h:74
int m_XL1
Complexity of L1 frame.
Definition: rate_control.h:83
void SetIComplexity(int cpx)
Set the complexity of I frame.
Definition: rate_control.h:68
void SetL1Complexity(int cpx)
Set the complexity of L1 frame.
Definition: rate_control.h:71
int m_XL2
Complexity of L2 frame.
Definition: rate_control.h:86
int L2Complexity()
Return the complexity of L2 frame.
Definition: rate_control.h:65
int L1Complexity()
Return the complexity of L1 frame.
Definition: rate_control.h:62
int m_XI
Complexity of I frame.
Definition: rate_control.h:80
int IComplexity()
Return the complexity of I frame.
Definition: rate_control.h:59
FrameComplexity()
Default constructor.
A clas for allocation the bits to each and every types of frames in a GOP.
Definition: rate_control.h:92
double m_qf
Current Quality Factor.
Definition: rate_control.h:149
const int m_target_rate
Target bit rate in kbps.
Definition: rate_control.h:158
bool m_intra_only
Definition: rate_control.h:212
double ProjectedSubgroupRate()
long int m_buffer_bits
Number of bits in the buffer.
Definition: rate_control.h:188
double QualFactor()
Return qf.
Definition: rate_control.h:112
double m_I_qf
I frame Quality Factor.
Definition: rate_control.h:152
void CalcNextQualFactor(const PictureParams &fparams, int num_bits)
Calculate the Quality factor of the next frame to encode.
void CalcTotalBits(const SourceParams &sourceparams)
Calculate the total number of bits in a GOP.
void UpdateBuffer(const long int num_bits)
Update the internal decoder buffer model.
float ReviewQualityFactor(const float qfac, const long int num_bits)
Review the quality factor to make sure it's being set sensibly.
double IntraQualFactor()
Return I frame qf.
Definition: rate_control.h:109
void SetFrameDistribution()
Set the number of I, L1 and L2 frames in the GOP.
int m_num_L1frame
Number of L1 frames.
Definition: rate_control.h:173
double m_buffer_rate_of_change
The rate of change of buffer occupancy.
Definition: rate_control.h:194
void SetCutPictureQualFactor()
Use the long-term average intra quality factor.
long int m_L1frame_bits
Number of bits for L1 frame.
Definition: rate_control.h:164
float ClipQualityFactor(const float qfac)
Clip the quality factor to something sensible.
int m_num_Iframe
Number of I frames.
Definition: rate_control.h:170
int m_L2_complexity_sum
Definition: rate_control.h:215
void Allocate(const int fnum)
Allocate the bits to each type of frame in a GOP.
void Report()
Report the allocation to picture types.
long int m_GOP_target
The target number of bits for the current GOP.
Definition: rate_control.h:197
const long int m_buffer_size
Size of the decoded bit buffer.
Definition: rate_control.h:185
RateController(int trate, SourceParams &srcp, EncoderParams &encp)
Default constructor.
long int m_total_GOP_bits
Total Number of bits in a GOP.
Definition: rate_control.h:179
FrameComplexity m_frame_complexity
A class to hold the frame complexity object.
Definition: rate_control.h:206
void CalcNextIntraQualFactor()
Calculate the Quality factor of the next I frame to encode.
long int m_old_buffer_bits
The old buffer occupancy.
Definition: rate_control.h:191
long int m_picture_bits
Mean number of bits in a picture.
Definition: rate_control.h:182
EncoderParams & m_encparams
A reference to the encoder parameters.
Definition: rate_control.h:203
void SetIntraQualFactor(double value)
Set the value of Current IQF.
Definition: rate_control.h:131
double m_I_qf_long_term
Long-term average of I frame Quality Factor.
Definition: rate_control.h:155
int m_num_L2frame
Number of L2 frames.
Definition: rate_control.h:176
double m_GOP_duration
The duration of a GOP.
Definition: rate_control.h:200
long int m_L2frame_bits
Number of bits for L2 frame.
Definition: rate_control.h:167
long int m_Iframe_bits
Number of bits for I frame.
Definition: rate_control.h:161
int m_fcount
A frame counter, giving the position within a subgroup.
Definition: rate_control.h:209

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