This file is indexed.

/usr/include/mjpegtools/mpeg2enc/picture.hh is in libmjpegtools-dev 1:2.1.0+debian-2.1.

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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*  (C) 2000/2001/2002 Andrew Stevens */

/*  This is free software; you can redistribute it
 *  and/or modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 */


#ifndef _PICTURE_HH
#define _PICTURE_HH

#include "mjpeg_types.h"
#include "encoderparams.hh"
#include "synchrolib.h"
#include "macroblock.hh"
#include <vector>
#include "mpeg2syntaxcodes.h"

using namespace std;


/* Transformed per-picture data  */

typedef int MotionVecPred[2][2][2];
typedef int DC_DctPred[3];

class CodingPredictors
{
public:

    void Reset_DC_DCT_Pred()
        {
            int cc;
            for (cc=0; cc<3; cc++)
                dc_dct_pred[cc] = 0;
                
        }
    void Reset_MV_Pred()
        {
            int *base=&PMV[0][0][0];
            int v;
            for( v = 0; v < 2*2*2; ++v)
                base[v]=0;
        }

    DC_DctPred dc_dct_pred;
    MotionVecPred PMV;
    MacroBlock *prev_mb;
    
};

class RateCtl;
class Quantizer;
class StreamState;
class ElemStrmWriter;
class MPEG2CodingBuf;
class ImagePlanes;

class Picture : public CodingPredictors
{
public:
    
    
    Picture( EncoderParams &_encparams, 
             ElemStrmWriter &writer,
             Quantizer &_quantizer );
    ~Picture();

    void QuantiseAndCode(RateCtl &ratecontrol);

    void MotionSubSampledLum();
    void ITransform();
    void IQuantize();
    void CalcSNR();
    void Stats();
    void Reconstruct();
    void CommitCoding();
    void DiscardCoding();
    
    void SetFrameParams( const StreamState &ss, int field );

    
    // Metrics used for stearing the encoding
    inline double Complexity() const { return Xhi; }
    void SetComplexity( double _Xhi ) { Xhi = _Xhi; }
    int EncodedSize() const;
    double IntraCodedBlocks() const;   // Proportion of Macroblocks coded Intra


    void PutHeaders();                // Picture/Gop/Sequence headers
    void PutTrailers( int padding );  // Stuff after picture but before next picture

    void PutHeader(); 

    double ActivityBestMotionComp();
    double VarSumBestMotionComp();
    double VarSumBestFwdMotionComp();
    double MinVarBestMotionComp();
    //
    //
    inline bool Legal( const MotionVector &mv ) const
        {
            return mv[Dim::X] >= -sxf && mv[Dim::X] < sxf 
                && mv[Dim::Y] >= -syf && mv[Dim::Y] < syf;
        }


    inline bool InRangeFrameMVRef( const Coord &crd ) const
        {
            return  crd.x >= 0 && crd.x <= (encparams.enc_width-16)*2
                && crd.y >= 0 && crd.y <= (encparams.enc_height-16)*2;
            
        }

    inline bool InRangeFieldMVRef( const Coord &crd ) const
        {
            return  crd.x >= 0 && crd.x <= (encparams.enc_width-16)*2
                && crd.y >= 0 && crd.y <= (encparams.enc_height/2-16)*2;
            
        }

    inline bool FinalFieldOfRefFrame() const
        {
            return pict_type != B_TYPE && finalfield;
        }
protected:
    
    void SetFieldParams(int field);
    void PutSliceHdr( int slice_mb_y, int mquant );
    void PutMVs( MotionEst &me, bool back );
    void PutDCTBlocks( MacroBlock &mb, int mb_type );
    void PutCodingExt(); 
    bool SkippableMotionMode( MotionEst &cur_mb_mm, MotionEst &prev_mb_mm);

public:

    /***************
     *
     * Data areas allocated at construction
     *
     **************/

    EncoderParams &encparams;
    Quantizer &quantizer;
    MPEG2CodingBuf *coding;
    
	/* 8*8 block data, raw (unquantised) and quantised, and (eventually but
	   not yet inverse quantised */
	DCTblock *blocks;
	DCTblock *qblocks;

	/* Macroblocks of picture */
	vector<MacroBlock> mbinfo;


    /***************
     *
     * Data update as picture is re-used for different images in streams
     *
     **************/
 
	int decode;				// Number of frame in stream 
	int present;			// Number of frame in playback order
                            // == Number of frame in input stream

    bool last_picture;         // Last Picture of a stream
    bool finalfield;        // Last field of a frame

	/* multiple-reader/single-writer channels Synchronisation  
	   sync only: no data is "read"/"written"
	 */
    Picture *fwd_ref_frame;
    Picture *bwd_ref_frame;     // 0 if Not B_TYPE
    
	/* picture encoding source data  */
	ImagePlanes *fwd_org, *bwd_org;	// Original Images of fwd and bwd
                                    // reference pictures
	ImagePlanes *fwd_rec, *bwd_rec;	// Reconstructed  Images for fwd and 
                                    // bwd references pictures
	ImagePlanes *org_img, *rec_img;	// Images for current pict: orginal
                                                        // and reconstructed.  Reconstructed
                                                        // 0 for B planes except when debugging
	ImagePlanes *pred;
	int sxf, syf, sxb, syb;		/* MC search limits. */
	bool secondfield;			/* Second field of field frame */
	bool ipflag;				/* P pict in IP frame (FIELD pics only)*/

	/* picture structure (header) data */

	int temp_ref; /* temporal reference */
    PICTURE_CODING frame_type;  /* picture coding type for frame  (I, P or B) */
    int gop_decode;              /* Frame number in gop (decode order) */
    int bgrp_decode;            /* Frame number in 'B group' (decode order) */
    PICTURE_CODING pict_type;   /* picture coding type for current field (I, P or B) */
	int vbv_delay;              /* video buffering verifier delay (1/90000 seconds) */
	int forw_hor_f_code, forw_vert_f_code;
	int back_hor_f_code, back_vert_f_code; /* motion vector ranges */
	int dc_prec;				/* DC coefficient prec for intra blocks */
    PICTURE_STRUCT pict_struct;	/* picture structure (frame, top / bottom) */
	int topfirst;				/* display top field first */
	bool frame_pred_dct;			/* Use only frame prediction... */
	int intravlc;				/* Intra VLC format */
	int q_scale_type;			/* Quantiser scale... */
	bool altscan;				/* Alternate scan  pattern selected */
    const uint8_t *scan_pattern; /* The scan pattern itself */
	bool repeatfirst;			/* repeat first field after second field */
	bool prog_frame;				/* progressive frame */

    int unit_coeff_threshold;   // Unit coefficient density weight
                                // below which zeroing should be applied.
    int unit_coeff_first;       // First coefficient for zeroing purposes...
                                // either 1 or 0.
	/* Information for GOP start frames */
	bool gop_start;             /* GOP Start picture */
    bool closed_gop;            /* GOP is closed   */
	int nb;						/* B frames in GOP */
	int np;						/* P frames in GOP */
	bool new_seq;				/* GOP starts new sequence */
    bool end_seq;               /* Frame ends sequence */
    
    double Xhi;                 /* Complexity ... product of bits needed to code and
                                   quantisation */

    /* Rate control statistics  */
    double AQ;       // Mean actual quantisation of encoding (if any)
    double ABQ;      // Mean base quantisation of encoding (if any)


	/* Statistics... */
	int pad;
	//int split;

	double SQ;
	double avg_act;
	double sum_avg_act;

    
};


/* 
 * Local variables:
 *  c-file-style: "stroustrup"
 *  tab-width: 4
 *  indent-tabs-mode: nil
 * End:
 */
#endif