This file is indexed.

/usr/include/pfs/pfs.h is in libpfs-dev 2.0.4-5build1.

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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/**
 * @file
 * @brief PFS library - core API interfaces
 *
 * Classes for reading and writing a stream of PFS frames.
 *
 * Note on the design of pfs library API: pfs library API makes
 * extensive usage of interfaces - classes that have only virtual
 * methods. This way no private fields are visible for the client
 * programs. Everything that is private is hidden in .cpp file rather
 * than the header .h. For example, pfs library uses STL to store some
 * internal data, but no STL class can be found the header file
 * pfs.h. Such design should hopefully give less problems when
 * extending and updating the library.
 * 
 * This file is a part of PFSTOOLS package.
 * ---------------------------------------------------------------------- 
 * Copyright (C) 2003,2004 Rafal Mantiuk and Grzegorz Krawczyk
 * 
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * ---------------------------------------------------------------------- 
 * 
 * @author Rafal Mantiuk, <mantiuk@mpi-sb.mpg.de>
 *
 * $Id: pfs.h,v 1.5 2014/04/05 22:04:13 rafm Exp $
 */

#ifndef PFS_H
#define PFS_H

#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include "array2d.h"

//struct option;

/**
 * All classes and function from PFS library reside in pfs namespace. 
 */
namespace pfs
{

  /**
   * Utility class that keeps pointer and deletes pointed object
   * when the class is deleted.
   *
   * Note that it is not a full implementation of the smart pointer
   * and memory management is not fool proof. You should never store
   * this object as a global variable or a field of a class. These
   * objects should be used only as local variables.
   */
  template<class T>
    class SelfDestructPtr
    {
      T *ptr;
      mutable bool itsOwn;
    public:
      explicit SelfDestructPtr( T *ptr = 0 ): ptr(ptr), itsOwn(ptr!=0)
        {
        }

      SelfDestructPtr( const SelfDestructPtr& r ) 
        : itsOwn(r.itsOwn), ptr(r.release()) {}
      
      SelfDestructPtr& operator=( const SelfDestructPtr& r ) {
        if (&r != this) {
            if (ptr != r.ptr) {
              if( itsOwn ) delete ptr;
              itsOwn = r.itsOwn;
            }
            else if( r.itsOwn ) itsOwn = true;
            ptr = r.release();
        }
        return *this;
      }
      
      ~SelfDestructPtr()
        {
          if( itsOwn ) 
            delete ptr;
        }  

      bool operator==( const SelfDestructPtr &x ) const {
        return *(ptr) == *(x.ptr);
      }

      bool operator!=( const SelfDestructPtr &x ) const {
        return *(ptr) != *(x.ptr);
      }
      
      T& operator*()  const            {return *ptr;}
      T* operator->() const            {return ptr;}
      T* get()        const            {return ptr;}
      T* release()    const  {itsOwn = false; return ptr;}
      
    };
  
  
  /**
   * Iterator that allows to get the list of available tags in a
   * TagContainer.
   */
  class TagIterator 
    {
    public:
      /**
       * Get next item on the list.
       *
       * @return name of the tag
       */
      virtual const char *getNext() = 0;
      /**
       * Returns true if there is still an item left on the list.
       */
      virtual bool hasNext() const = 0;

      virtual ~TagIterator()
	{
	}
    };

  typedef SelfDestructPtr<TagIterator> TagIteratorPtr;
  
/**
 * TagContainer interface allows to read and modify tags. A tag is "name"="value" pair.
 */
  class TagContainer
    {
    public:
      /**
       * Get a string tag of the name tagName from the TagContainer.
       * @param tagName name of the tag to retrieve
       * @return tag value or NULL if tag was not found
       */
      virtual const char* getString( const char *tagName ) = 0;

      /**
       * Set or add a string tag of the name tagName. 
       * @param tagName name of the tag to add or set
       * @param tagValue value of the tag
       */      
      virtual void setString( const char *tagName, const char *tagValue ) = 0;
      
      /**
       * Removes (if exists) a tag of the name tagName from the TagContainer.
       * @param tagName name of the tag to remove
       */
      virtual void removeTag( const char *tagName ) = 0;

      /**
       * Use TagIterator to iterate over all tags in the TagContainer.
       * TagIteratorPtr is a smart pointer, which destructs
       * TagIterator when TagIteratorPtr is destructed. Use ->
       * operator to access TagIterator members from a TagIteratorPtr
       * object.
       *
       * To iterate over all tags, use the following code:
       * <code>
       * pfs::TagIteratorPtr it( frame->getTags()->getIterator() );
       * while( it->hasNext() ) {
       *   const char *tagName = it->getNext();
       *   //Do something
       * }
       * </code>
       */
      virtual TagIteratorPtr getIterator() const = 0;
    };


/**
 * Channel interface represents a 2D rectangular array with
 * associated tags.
 */
  class Channel : public Array2D {
  public:
    /**
     * Gets width of the channel (in pixels).
     * This is a synonym for Array2D::getCols().
     */
    int getWidth() const {
      return getCols();
    }

    /**
     * Gets height of the channel (in pixels).
     * This is a synonym for Array2D::getRows().
     */
    virtual int getHeight() const
      {
        return getRows();
      }

    /**
     * Gets name of the channel. 
     */
    virtual const char *getName() const = 0;
        
    /**
     * Returns TagContainer that can be used to access or modify
     * tags associated with this Channel object.
     */
    virtual TagContainer *getTags() = 0;

    /**
     * For performance reasons, the channels can be accessed as a
     * table of float values. Data is given in row-major order, i.e.
     * it is indexed data[x+y*width]. If performance is not crucial,
     * use Array2D interface instead.
     *
     * @return a table of floats of the size width*height
     */
    virtual float *getRawData() = 0;
  };

  /**
   * Iterator that allows to get the list of available channels in a frame.
   */
  class ChannelIterator 
    {
    public:
      /**
       * Get next item on the list.
       */
      virtual Channel *getNext() = 0;
      /**
       * Returns true if there is still an item left on the list.
       */
      virtual bool hasNext() const = 0;

      virtual ~ChannelIterator()
	{
	}
    };
  
  typedef SelfDestructPtr<ChannelIterator> ChannelIteratorPtr;
  
/**
 * Interface representing a single PFS frame. Frame may contain 0
 * or more channels (e.g. color XYZ, depth channel, alpha
 * channnel). All the channels are of the same size. Frame can
 * also contain additional information in tags (see getTags).
 */
  class Frame {
  public:
    /**
     * Gets width of the channels (in pixels).
     */
    virtual int getWidth() const = 0;

    /**
     * Gets height of the channels (in pixels).
     */
    virtual int getHeight() const = 0;

    /**
     * Gets color channels in XYZ color space. May return NULLs
     * if such channels do not exist. Values assigned to
     * X, Y, Z are always either all NULLs or valid pointers to
     * channels.
     *
     * @param X [out] a pointer to store X channel in
     * @param Y [out] a pointer to store Y channel in
     * @param Z [out] a pointer to store Z channel in
     */
    virtual void getXYZChannels( Channel* &X, Channel* &Y, Channel* &Z ) = 0;

    /**
     * Creates color channels in XYZ color space. If such channels
     * already exists, returns existing channels, rather than
     * creating new ones.  Note, that nothing can be assumed about
     * the content of each channel.
     *
     * @param X [out] a pointer to store X channel in
     * @param Y [out] a pointer to store Y channel in
     * @param Z [out] a pointer to store Z channel in
     */
    virtual void createXYZChannels( Channel* &X, Channel* &Y, Channel* &Z ) = 0;

    /**
     * Gets a named channel. 
     *
     * @param name [in] name of the channel. Name must be 8 or less
     * character long.
     * @return channel or NULL if the channel does not exist
     */        
    virtual Channel* getChannel( const char *name ) = 0;

    /**
     * Creates a named channel. If the channel already exists, returns
     * existing channel.
     *
     * Note that new channels should be created only for the first
     * frame. The channels should not changes for the subsequent
     * frames of a sequence.
     *
     * @param name [in] name of the channel. Name must be 8 or less
     * character long.
     * @return existing or newly created channel
     */        
    virtual Channel* createChannel( const char *name ) = 0;


    /**
     * Removes a channel and frees the memory allocated for it. It is
     * safe to remove the channel pointed by the ChannelIterator.
     *
     * @param channel [in] channel that should be removed.
     */        
    virtual void removeChannel( Channel *channel ) = 0;
    
    /**
     * DEPRECIATED!!! Use getIterator instead.
     *
     * Returns iterator for all available channels.
     *
     * Note that only one iterator for particular frame can be used at
     * a time. This method returns each time the same data structure,
     * so the iterator from previous call is lost after the call. The
     * iterator MUST NOT be deleted after use.
     *
     * Object ChannelIterator MUST NOT be freed. It's responsibility
     * of a Frame object.
     */
    virtual ChannelIterator *getChannels() = 0;
    
    /**
     * Use ChannelIterator to iterate over all Channels in the Frame.
     * ChannelIteratorPtr is a smart pointer, which destructs
     * ChannelIterator when ChannelIteratorPtr is destructed. Use ->
     * operator to access ChannelIterator members from a
     * ChannelIteratorPtr object.
     *
     * To iterate over all channels, use the following code:
     * <code>
     * pfs::ChannelIteratorPtr it( frame->getChannelIterator() );
     * while( it->hasNext() ) {
     *   pfs::Channel *ch = cit->getNext();
     *   //Do whatever is needed
     * }
     * </code>
     */
    virtual ChannelIteratorPtr getChannelIterator() = 0;
    
    /**
     * Returns TagContainer that can be used to access or modify
     * tags associated with this Frame object.
     */
    virtual TagContainer *getTags() = 0;

    virtual ~Frame() = 0;
    
  };

  /**
   * Copy all tags from both the frame and its channels to the
   * destination frame. If there is no corresponding destination
   * channel for a source channel, the tags from that source channel
   * will not be copied. Note, that all tags in the destination
   * channel will be removed before copying. Therefore after this
   * operation, the destination will contain exactly the same tags as
   * the source.
   */
  void copyTags( Frame *from, Frame *to );
  
  /**
   * Copy all tags from one container into another. Note, that all
   * tags in the destination channel will be removed before
   * copying. Therefore after this operation, the destination will
   * contain exactly the same tags as the source.
   */
  void copyTags( const TagContainer *from, TagContainer *to );

  
  class DOMIOImpl;

/**
 * Reading and writing frames in PFS format from/to streams.
 */
  class DOMIO {
    DOMIOImpl *impl;
  public:
    DOMIO();
    ~DOMIO();

    /**
     * Creates a frame that can be latter written to the stream
     * using writeFrame method. This method and readFrame are the
     * only way to create Frame objects.
     *
     * Note: Frame object must be released with freeFrame methods
     * as soon as it is no longer needed. Otherwise the
     * application will run out of memory.
     *
     * @param width width of the frame to create
     * @param height height of the frame to create
     * @return Frame object that can be modified and written back to PFS
     * stream using writeFrame method
     */
    Frame *createFrame( int width, int height );

    /**
     * Read PFS frame from the input Stream. This method and
     * createFrame are the only way to create Frame objects.
     *
     * Note: Frame object must be released with freeFrame methods
     * as soon as it is no longer needed. Otherwise the
     * application will run out of memory.
     *
     * @param inputStream read frame from that stream
     * @return Frame object that contains PFS frame read from
     * the stream. NULL if there are no more frames.
     */
    Frame *readFrame( FILE *inputStream );

    /**
     * Writes Frame object to outputStream in PFS format.
     *
     * @param frame Frame object to be written. This object
     * must be created with readFrame or createFrame method.
     * @param outputStream write frame to that stream
     */
    void writeFrame( Frame *frame, FILE *outputStream );

    /**
     * Deallocated memory allocated with createFrame or readFrame. Must
     * be called as soon as frame is not needed. Pointer to a frame is
     * invalid after this method call.
     *
     * @param frame Frame object to be freed
     */
    void freeFrame( Frame *frame );
  };



  /**
   * A pair of a file name and file handler, returned from
   * FrameFileIterator.
   */
  struct FrameFile
  {
    FrameFile( FILE *fh, const char* fileName ): fh(fh), fileName( fileName )
    {
    }

    /**
     * File handler.
     */
    FILE *fh;

    /**
     * File name.
     */
    const char *fileName;
  };


  class FrameFileIteratorImpl;

/**
 * Utility class that can be used to iterate over file names
 * specified as command line arguments. It can handle patterns,
 * like frame%04d.hdr, where %04d is replaced with specified
 * range of frame numbers.
 *
 */
  class FrameFileIterator
    {
      FrameFileIteratorImpl *impl;
    public:
      /**
       * Creates new iterator over frame files. Command line
       * arguments are parsed and all recognized arguments are
       * removed.
       *
       * @param argc argument count passed to program's main function.
       * @param argv argument values passed to program's main function.
       * @param fopenMode mode used to fopen frame files, usually "rb" or "wb"
       * @param fileNamePrefix each frame pattern must be preceded
       * with this string (for example "-i'). If NULL, every argument that
       * does not start with "-" is treated as a frame pattern.
       * @param stdinout if set, treat '-' file name specially and instead
       * of opening a named file, use filedescriptor passed as this parameter.
       * It should be used to get or write data to stdin / stdout.
       * @param optstring parameter string passed to getopt()
       * function. When optstring != NULL, FrameFileIterator will skip
       * all parameters and their required arguments. Optional
       * arguments are not handled.
       * @param getopt_long parameter structure passed to getopt_long()
       * function. When getopt_long != NULL, FrameFileIterator will skip
       * all parameters and their required arguments. Optional
       * arguments are not handled.
       * @throws CommandLineException on bad syntax of command line options
       */
      FrameFileIterator( int &argc, char* argv[], const char *fopenMode,
        const char *fileNamePrefix = NULL, FILE *stdinout = NULL,
        const char *optstring = NULL, const struct option *getopt_long = NULL );

      ~FrameFileIterator();

      /**
       * Get the file handle FILE* and file name for the next
       * frame. Note that fileName string is valid until next
       * call to getNextFrameFile or closeFrameFile.
       *
       * When file handle is no longer needed, closeFileFile
       * should be called.
       *
       * @return file handle FILE* and file name of the next frame.
       * Returns file handle == NULL if there are no more frames.
       *
       * @throws Exception if the file is not found
       */
      FrameFile getNextFrameFile( );

      /**
       * Close file openned with getNextFrameFile.
       *
       * @param frameFile FrameFile object returned from getNextFrameFile
       */
      void closeFrameFile( FrameFile &frameFile );

      static void printUsage( FILE *out, const char *progName );

    };


/// This enum is used to specify color spaces for transformColorSpace function
  enum ColorSpace
    {
      CS_XYZ = 0,         ///< Absolute XYZ space, reference white - D65, Y is calibrated luminance in cd/m^2
      CS_RGB,             ///< Absolute XYZ space, reference white - D65
      CS_SRGB,            ///< sRGB color space for LDR images (see
                          ///www.srgb.com). The possible pixel values
                          ///for R, G and B channel should be within
                          ///range 0-1 (the values above or below this
                          ///range will be clamped). Peak luminance
                          ///level of the display is 80cd/m^2.
      CS_YUV,             ///< Perceptually uniform u and v color coordinates, Y is calibrated luminance in cd/m^2
      CS_Yxy,              ///< Luminance and normalized chromacities (x=X/(X+Y+Z), y=Y/(X+Y+Z))
      CS_LAST             ///< For internal purposes only
    };

/**
 * Transform color channels from one color space into
 * another. Input and output channels may point to the same data
 * for in-memory transform.
 *
 * @param inCS input color space
 * @param inC1 first color channel of the input image
 * @param inC2 second color channel of the input image
 * @param inC3 third color channel of the input image
 * @param outCS output color space
 * @param outC1 first color channel of the output image
 * @param outC2 second color channel of the output image
 * @param outC3 third color channel of the output image
 */
  void transformColorSpace( ColorSpace inCS,
    const Array2D *inC1, const Array2D *inC2, const Array2D *inC3,
    ColorSpace outCS,
    Array2D *outC1, Array2D *outC2, Array2D *outC3 );


/**
 * General exception class used to throw exceptions from pfs library.
 */
  class Exception
    {
      char msg[1024];
    public:
      /**
       * Creates a new exception.
       *
       * @param message description of the cause for the
       * exception. The copy of the message string is made, so it can
       * be freed after creating Exception.
       */
      Exception( const char* const message )
	{
          strcpy( msg, message );
	}
			
      ~Exception() {};

      /**
       * Returns the description of the problem.
       *
       * @return text description of the cause for the exception
       */
      const char* getMessage()
        {
          return msg;
	}
    };


/**
 * Exception class used to throw exceptions from FileFileIterator class.
 */
  class CommandLineException: public Exception
    {
    public:
      CommandLineException( const char* const message ): Exception( message )
	{
	}
    };


}



#endif