Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: rate_control.h,v 1.7 2008/01/31 11:25:18 tjdwave Exp $ $Name: Dirac_1_0_2 $ 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): Myo Tun (Original Author, myo.tun@brunel.ac.uk) 00024 * Jonathan Loo (Jonathan.Loo@brunel.ac.uk) 00025 * School of Engineering and Design, Brunel University, UK 00026 * 00027 * Alternatively, the contents of this file may be used under the terms of 00028 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00029 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00030 * the GPL or the LGPL are applicable instead of those above. If you wish to 00031 * allow use of your version of this file only under the terms of the either 00032 * the GPL or LGPL and not to allow others to use your version of this file 00033 * under the MPL, indicate your decision by deleting the provisions above 00034 * and replace them with the notice and other provisions required by the GPL 00035 * or LGPL. If you do not delete the provisions above, a recipient may use 00036 * your version of this file under the terms of any one of the MPL, the GPL 00037 * or the LGPL. 00038 * ***** END LICENSE BLOCK ***** */ 00039 00040 00041 //Compression of an individual component, 00042 //after motion compensation if appropriate 00044 00045 #ifndef _RATE_CONTROL_H_ 00046 #define _RATE_CONTROL_H_ 00047 00048 #include <libdirac_common/common.h> 00049 00050 namespace dirac 00051 { 00052 class FrameComplexity 00053 { 00054 public: 00056 FrameComplexity(); 00057 00059 int IComplexity() {return m_XI;} 00060 00062 int L1Complexity() {return m_XL1;} 00063 00065 int L2Complexity() {return m_XL2;} 00066 00068 void SetIComplexity(int cpx) {m_XI = cpx;} 00069 00071 void SetL1Complexity(int cpx) {m_XL1 = cpx;} 00072 00074 void SetL2Complexity(int cpx) {m_XL2 = cpx;} 00075 00076 00077 private: 00078 00080 int m_XI; 00081 00083 int m_XL1; 00084 00086 int m_XL2; 00087 }; 00088 00089 00091 class RateController 00092 { 00093 public: 00094 00096 RateController(int trate, SourceParams& srcp, EncoderParams& encp); 00097 00098 00100 void CalcNextQualFactor(const PictureParams& fparams, int num_bits); 00101 00103 void CalcNextIntraQualFactor(); 00104 00106 void SetCutPictureQualFactor(); 00107 00109 double IntraQualFactor() {return m_I_qf;} 00110 00112 double QualFactor() {return m_qf;} 00113 00115 void Report(); 00116 00117 00118 private: 00119 00120 double TargetSubgroupRate(); 00121 00122 double ProjectedSubgroupRate(); 00123 00125 void Allocate(const int fnum); 00126 00128 void CalcTotalBits(const SourceParams& sourceparams); 00129 00131 void SetIntraQualFactor(double value){m_I_qf = value;} 00132 00134 void SetFrameDistribution(); 00135 00137 float ReviewQualityFactor( const float qfac, const long int num_bits ); 00138 00140 float ClipQualityFactor( const float qfac ); 00141 00143 void UpdateBuffer( const long int num_bits ); 00144 00145 00146 private: 00147 00149 double m_qf; 00150 00152 double m_I_qf; 00153 00155 double m_I_qf_long_term; 00156 00158 const int m_target_rate; 00159 00161 long int m_Iframe_bits; 00162 00164 long int m_L1frame_bits; 00165 00167 long int m_L2frame_bits; 00168 00170 int m_num_Iframe; 00171 00173 int m_num_L1frame; 00174 00176 int m_num_L2frame; 00177 00179 long int m_total_GOP_bits; 00180 00182 long int m_picture_bits; 00183 00185 const long int m_buffer_size; 00186 00188 long int m_buffer_bits; 00189 00191 long int m_old_buffer_bits; 00192 00194 double m_buffer_rate_of_change; 00195 00197 long int m_GOP_target; 00198 00200 double m_GOP_duration; 00201 00203 EncoderParams& m_encparams; 00204 00206 FrameComplexity m_frame_complexity; 00207 00209 int m_fcount; 00210 00211 // Indicated whether a sequence is being coded intra only or not 00212 bool m_intra_only; 00213 00214 // Sum of complexity of L2 frames 00215 int m_L2_complexity_sum; 00216 00217 }; 00218 00219 00220 }// namespace dirac 00221 #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.