1 /* ***** BEGIN LICENSE BLOCK *****
7 * Copyright (c) 2008 BBC Research
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * ***** END LICENSE BLOCK ***** */
29 #ifndef __SEQUENCEREADER_H
30 #define __SEQUENCEREADER_H
33 #include "rawFrameIO.h"
37 #include <QStringList>
42 class SequenceReader
: public QObject
48 //Values of this type are stored in the settings, so if you need to extend this enum please only add to the end,
49 //or settings and program values may get out of step.
50 typedef enum _RawType
{type_v216
,
71 enum ImageSizes
{SizeQSIF
=0, SizeQCIF
, SizeSIF
, SizeCIF
, Size4SIF
, Size4CIF
, SizeSD480
, SizeSD576
, SizeHD720
, SizeHD1080
, Size2K
, Size4K
, SizeSHV
, SizeCustom
, SizeUnknown
, NumSizes
=SizeUnknown
};
73 int getSequenceLength(void);
74 int getFirstFrameNum(void);
75 int getLastFrameNum(void);
76 int getCurrentFrameNum(void);
78 int getFrameWidth(void) {return frameWidth
;}
79 int getFrameHeight(void) {return frameHeight
;}
80 int getFrameDepth(void) {return frameDepth
;}
81 bool getFrameHasHeader(void);
84 int getCustomHeight();
85 RawFrame
& readFrame(int frameNum
);
88 void newFrame(const RawFrame
*);
89 void frameFileName(const QString
&);
90 void frameFormat(const QString
&);
91 void frameSize(QSize
&);
92 void sequencePosition(const QString
&, int, int, int, int);
93 void frameHasHeader(bool);
94 void frameBitDepth(int);
97 int setDirectoryOfFiles(const QString
&dir
);
98 int setFileNames(const QStringList
&);
99 void setSizeType(ImageSizes s
);
100 void setCustomSize(int width
, int height
);
101 void setRawFormat(RawType
);
102 void nextInSequence();
103 void prevInSequence();
109 int jumpInSequence(int);
111 typedef struct { //information about each file in the sequence
112 RawFrame::Chroma chroma
;
122 int rawImageWidth
[NumSizes
];
123 int rawImageHeight
[NumSizes
];
125 void buildFileInfo(void); //look through the file list and gather information on each video file
126 int bytesPerFrame(RawType
); //turn a file extension into a number of bytes per frame for the current picture size
127 bool hasHeader(RawType
); //does the file have a header which allows file information to be read?
128 int bitDepth(RawType
); //can the pixel bit depth be determined for a file from the file extension?
129 RawFrame::Chroma
chromaType(RawType
); //chroma type we read into, determined by file extension
130 RawType
rawType(QString
&extension
); //enumerated version of file extension
132 int fileIndexForFrameNum(int frameNum
); //look through the file info list for the file containing a particular frame number
134 RawType frameType
; //the user interface may force the raw yuv file type regardless of the extension
135 int frameDepth
; //the bit depth for the frame if is is known / deduced, or 0 otherwise
136 int frameWidth
; //the actual frame dimensions, either read from the header or taken from rawWidth/rawHeight
139 int rawWidth
; //dimensions for raw files, where the frame size is unknown
142 int firstFrame
; //first frame number in the sequence
143 int lastFrame
; //last frame number in the sequence
144 int currentFrameNum
; //current
145 int currentFileIndex
; //current file in the list of files to display (each may contain more than one frame)
146 FILE *filePtr
; //the currently open file
147 QStringList fileList
; //list of filenames
148 std::vector
<sequenceFileInfo
> infoList
; //list of info about each file of frames
149 RawFrame
*destFrame
; //the destination frame for reading into