# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

# rate_control.h

Go to the documentation of this file.

    00001 /* ***** BEGIN LICENSE BLOCK *****
    00002 *
    00003 * $Id: rate_control.h,v 1.2 2007/03/27 15:20:39 tjdwave Exp $ $Name: Dirac_0_7_0 $
    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 FrameParams& fparams, int num_bits);
    00101
    00103         void CalcNextIntraQualFactor();
    00104
    00106         double IntraQualFactor() {return m_I_qf;}
    00107
    00109         double QualFactor() {return m_qf;}
    00110
    00111
    00112     private:
    00113
    00114         double TargetSubgroupRate();
    00115
    00116         double ProjectedSubgroupRate();
    00117
    00119         void Allocate();
    00120
    00122         void CalcTotalBits(const SourceParams& sourceparams);
    00123
    00125         void SetIntraQualFactor(double value){m_I_qf = value;}
    00126
    00128         void SetFrameDistribution();
    00129
    00131         float ReviewQualityFactor( const float qfac, const int num_bits );
    00132
    00134         float ClipQualityFactor( const float qfac );
    00135
    00137         void UpdateBuffer( const int num_bits );
    00138
    00139
    00140     private:
    00141
    00143         double m_qf;
    00144
    00146         double m_I_qf;
    00147
    00149         const int m_target_rate;
    00150
    00152         int m_Iframe_bits;
    00153
    00155         int m_L1frame_bits;
    00156
    00158         int m_L2frame_bits;
    00159
    00161         int m_num_Iframe;
    00162
    00164         int m_num_L1frame;
    00165
    00167         int m_num_L2frame;
    00168
    00170         int m_total_GOP_bits;
    00171
    00173         int m_picture_bits;
    00174
    00176         const int m_buffer_size;
    00177
    00179         int m_buffer_bits;
    00180
    00182         int m_current_GOP_bits;
    00183
    00185         double m_GOP_duration;
    00186
    00188         EncoderParams& m_encparams;
    00189
    00191         FrameComplexity m_frame_complexity;
    00192
    00194         int m_fcount;
    00195
    00196
    00197         // Indicated whether a sequence is being coded intra only or not
    00198         bool m_intra_only;
    00199
    00200         // Sum of complexity of L2 frames
    00201         int m_L2_complexity_sum;
    00202
    00203     };
    00204
    00205
    00206 }// namespace dirac
    00207 #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.