Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: rate_control.h,v 1.1 2007/03/21 11:32:14 tjdwave 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): 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 00099 void Allocate(const FrameParams& fparams, int num_bits); 00100 00102 void CalcNextQualFactor(const FrameParams& fparams, int num_bits); 00103 00105 void CalcNextIntraQualFactor(); 00106 00108 void CalcTotalBits(); 00109 00111 void SetIntraQualFactor(double value){m_I_qf = value;} 00112 00114 void ResetNumFrame(); 00115 00117 double IntraQualFactor() {return m_I_qf;} 00118 00120 double QualFactor() {return m_qf;} 00121 00122 00123 private: 00124 00126 double m_qf; 00127 00129 double m_I_qf; 00130 00132 int m_target_rate; 00133 00135 int m_Iframe_bits; 00136 00138 int m_enc_Iframe_bits; 00139 00141 int m_L1frame_bits; 00142 00144 int m_L2frame_bits; 00145 00147 int m_num_Iframe; 00148 00150 int m_num_L1frame; 00151 00153 int m_num_L2frame; 00154 00156 int m_total_GOP_bits; 00157 00159 int m_current_GOP_bits; 00160 00163 int m_enc_num_bits; 00164 00167 int m_t_num_bits; 00168 00170 double m_GOP_duration; 00171 00173 SourceParams& m_srcparams; 00174 00176 EncoderParams& m_encparams; 00177 00179 FrameComplexity m_frame_complexity; 00180 00182 int m_fcount; 00183 00185 int m_TXI; 00186 00188 int m_TXL1; 00189 00191 int m_TXL2; 00192 00193 }; 00194 00195 00196 }// namespace dirac 00197 #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.