This file is indexed.

/usr/include/opal/codec/ratectl.h is in libopal-dev 3.10.2~dfsg-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * ratectl.h
 *
 * Video rate controller
 *
 * Open Phone Abstraction Library (OPAL)
 *
 * Copyright (C) 2007 Matthias Schneider
 * Copyright (C) 2008 Post Increment
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Open Phone Abstraction Library.
 *
 * The Initial Developer of the Original Code is Matthias Schneider 
 *
 * Contributor(s): Post Increment
 *
 * $Revision: 22839 $
 * $Author: rjongbloed $
 * $Date: 2009-06-10 20:37:03 -0500 (Wed, 10 Jun 2009) $
 */

#ifndef OPAL_RATE_CONTROL_H
#define OPAL_RATE_CONTROL_H

#ifdef P_USE_PRAGMA
#pragma interface
#endif

#include <opal/buildopts.h>

#if OPAL_VIDEO

#include <rtp/rtp.h>

extern double OpalCalcSNR(const BYTE * src1, const BYTE * src2, PINDEX dataLen);

/**  This class is used to calculate the instantaneous bit rate of a data stream
  *  using a one second sliding window 
 */

class OpalBitRateCalculator
{
  public:
    /**  Create the calculator
    */
    OpalBitRateCalculator();

    /** Reset the statistics
    */
    void Reset();

    /** Set the quanta (usually the frame time)
    */
    void SetQuanta(
      unsigned quanta_
    );

    /** Get the quanta (usually the frame time)
    */
    unsigned GetQuanta() const
    { return m_quanta; }

    /** Add a new packet to the bit rate calculations
    */
    void AddPacket(PINDEX size, bool marker);

    /** Get the instantaneous bit rate
    */
    unsigned GetBitRate();

    /** Get the average bit rate since SetQuanta was called
    */
    unsigned GetAverageBitRate();

    /** Get the average bit rate since SetQuanta was called
    */
    unsigned GetAveragePacketSize();

    /** return the bit rate if the specific data size was transmitted
    */
    unsigned GetTrialBitRate(PINDEX size);

    /** Return total bytes sent since SetQuanta was called
    */
    PInt64 GetTotalSize() const;

    /** Return total miliseconds since SetQuanta was called
    */
    PInt64 GetTotalTime() const;

    /** Return number of frames in history
    */
    size_t GetHistoryCount() const
    { return m_history.size(); }

    /** Return number of bytes in history
    */
    unsigned GetHistorySize() const
    { return m_historySize; }

    /** Return earlist timestamp in history
    */
    PInt64 GetEarliestHistoryTime() const
    { if (m_history.size() == 0) return 0; return m_history.begin()->m_timeStamp; }

    /** Return number of marker bits in history
    */
    unsigned GetHistoryFrames() const;

    // flush old data from history
    void Flush();

    // used to get "now"
    static PInt64 GetNow();

  protected:

    void Flush(PInt64 now);

    struct History {
      History(PINDEX size_, PInt64 timeStamp_, bool marker_)
        : m_size(size_), m_timeStamp(timeStamp_), m_marker(marker_)
      { }

      PINDEX m_size;
      PInt64 m_timeStamp;
      bool m_marker;
    };

    std::deque<History> m_history;

    PINDEX m_historySize;
    PInt64 m_totalSize;
    PINDEX m_historyFrames;

    unsigned m_quanta;
    unsigned m_bitRate;
    bool m_first;
    PInt64 m_baseTimeStamp;
};

//
//  Declare a generic video rate controller class.
//  A rate controller seeks to maintain a constant bit rate by manipulating
//  the parameters of the video stream
//
//  Before encoding a potential output frame, use the SkipFrame function to determine if the 
//  frame should be skipped. 
//
//  If the frame is not skipped, encode the frame and call PushFrame to add the frame to the rate controller queue
//  PopFrame can then be called to retreive frames to transmit
//
//  PushFrame must always be called with packets from a single video frame, but PopFrame may return packets 
//  from multiple video frames
//

class OpalMediaFormat;

class OpalVideoRateController
{
  public:
    OpalVideoRateController();

    virtual ~OpalVideoRateController();

    /** Open the rate controller with the specific parameters
      */
    virtual void Open(
      const OpalMediaFormat & mediaFormat
    );

    /** Determine if the next frame should be skipped.
      * The rate controller can also indicate whether the next frame should
      * be encoded as an I-frame, which is useful if many frames have been skipped
      */
    virtual bool SkipFrame(
      bool & forceIFrame
    ) = 0;

    /** push encoded frames into the rate controller queue
      */
    virtual void Push(
      RTP_DataFrameList & inputFrames, 
      bool iFrame
    );

    /** retreive encoded frames from the rate controller queue
      */
    virtual bool Pop(
      RTP_DataFrameList & outputPackets, 
      bool & iFrame, 
      bool force
    );

    /** Bit rate calculator used by rate controller
      */
    OpalBitRateCalculator m_bitRateCalc;

  protected:
    unsigned m_targetBitRate;
    unsigned m_outputFrameTime;
    PInt64   m_inputFrameCount;
    PInt64   m_outputFrameCount;

    struct PacketEntry {
      PacketEntry(RTP_DataFrame * rtp_, bool iFrame_)
        : m_rtp(rtp_), m_iFrame(iFrame_)
      { }

      RTP_DataFrame * m_rtp;
      bool m_iFrame;
    };
    std::deque<PacketEntry> m_packets;
};

namespace PWLibStupidLinkerHacks {
  extern int rateControlKickerVal;
//  static class RateControlKicker { public: RateControlKicker() { rateControlKickerVal = 1; } } rateControlKicker;
};

#endif // OPAL_VIDEO

#endif // OPAL_RATE_CONTROL_H