Add facility to read frames in RGB & RGBA format
[imageviewer.git] / sequenceReader.cpp
blobee559be097bbf390aae4ce9c829610dba96aaf43
1 /* ***** BEGIN LICENSE BLOCK *****
3 * $Id$
5 * The MIT License
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
25 * THE SOFTWARE.
27 * ***** END LICENSE BLOCK ***** */
29 #include "sequenceReader.h"
31 #include "rawIOv216.h"
32 #include "rawIOv210.h"
33 #include "rawIOYV12.h"
34 #include "rawIOuyvy.h"
35 #include "rawIOpgm.h"
36 #include "rawIOppm.h"
37 #include "rawIOuy16.h"
38 #include "rawIOi420.h"
39 #include "rawIOyy16.h"
40 #include "rawIOyyy8.h"
41 #include "rawIO16P4.h"
42 #include "rawIO16P2.h"
43 #include "rawIO16P0.h"
44 #include "rawIOsgi.h"
45 #include "rawIO8P2.h"
46 #include "rawIOrgb.h"
47 #include "rawIOrgba.h"
48 #include "rawIOleader-frm.h"
50 #include <iostream>
51 #include <QtCore>
53 #include <stdio.h>
55 #define _FILE_OFFSET_BITS 64
57 #define DEBUG 0
59 SequenceReader::SequenceReader() :
60 QObject()
62 filePtr = NULL;
63 destFrame = new RawFrame(0, 0, RawFrame::Cr422); //bogus frame for now
64 firstFrame = 0;
65 lastFrame = 0;
66 currentFrameNum = 0;
67 currentFileIndex = 0;
69 //there must be a better way that this to initialise these arrays?
70 rawImageWidth[SizeQSIF] = 176; rawImageHeight[SizeQSIF] = 120;
71 rawImageWidth[SizeQCIF] = 176; rawImageHeight[SizeQCIF] = 144;
72 rawImageWidth[SizeSIF] = 352; rawImageHeight[SizeSIF] = 240;
73 rawImageWidth[SizeCIF] = 352; rawImageHeight[SizeCIF] = 288;
74 rawImageWidth[Size4SIF] = 704; rawImageHeight[Size4SIF] = 480;
75 rawImageWidth[Size4CIF] = 704; rawImageHeight[Size4CIF] = 576;
76 rawImageWidth[SizeSD480] = 720; rawImageHeight[SizeSD480] = 480;
77 rawImageWidth[SizeSD576] = 720; rawImageHeight[SizeSD576] = 576;
78 rawImageWidth[SizeHD720] = 1280; rawImageHeight[SizeHD720] = 720;
79 rawImageWidth[SizeHD1080] = 1920; rawImageHeight[SizeHD1080] = 1080;
80 rawImageWidth[Size2K] = 2048; rawImageHeight[Size2K] = 1556;
81 rawImageWidth[Size4K] = 4096; rawImageHeight[Size4K] = 3112;
82 rawImageWidth[SizeSHV] = 7680; rawImageHeight[SizeSHV] = 4320;
83 rawImageWidth[SizeCustom] = 640; rawImageHeight[SizeCustom] = 480;
86 int SequenceReader::getSequenceLength(void)
88 if (fileList.size() == 0)
89 return 0;
91 return lastFrame - firstFrame + 1;
94 int SequenceReader::getFirstFrameNum(void)
96 return firstFrame;
99 int SequenceReader::getLastFrameNum(void)
101 return lastFrame;
104 int SequenceReader::getCurrentFrameNum(void)
106 return currentFrameNum;
109 //identify those file types which contain a header giving image dimensions and maybe other useful stuff
110 bool SequenceReader::hasHeader(RawType type)
112 bool header;
114 switch (type) {
115 case type_leader_frm:
116 case type_pgm:
117 case type_ppm:
118 case type_sgi:
119 header = true;
120 break;
122 default:
123 header = false;
124 break;
127 return header;
130 //for raw file types we can sometimes know the bit depth given the file extension
131 int SequenceReader::bitDepth(RawType type)
133 int depth = 0;
135 switch (type) {
136 case type_uy16:
137 depth = 0; //we don't know what the depth of this file is
138 break;
140 case type_v210:
141 depth = 10;
142 break;
144 case type_v216:
145 case type_yy16:
146 case type_16P4:
147 case type_16P2:
148 case type_16P0:
149 depth = 16;
150 break;
152 case type_i420:
153 case type_rgb:
154 case type_rgba:
155 case type_yv12:
156 case type_uyvy:
157 case type_yyy8:
158 case type_8P2:
159 depth = 8;
160 break;
162 default:
163 depth = 0;
164 break;
167 return depth;
170 //convert a file extension into the enumerated file type
171 SequenceReader::RawType SequenceReader::rawType(QString &ext)
173 RawType type;
175 ext = ext.toLower();
177 if (ext == "v210") {
178 type = type_v210;
180 else if (ext == "v216") {
181 type = type_v216;
183 else if (ext == "uy16") {
184 type = type_uy16;
186 else if (ext == "yv12") {
187 type = type_yv12;
189 else if (ext == "i420") {
190 type = type_i420;
192 else if (ext == "uyvy") {
193 type = type_uyvy;
195 else if (ext == "yy16") {
196 type = type_yy16;
198 else if (ext == "yyy8") {
199 type = type_yyy8;
201 else if (ext == "16p4") {
202 type = type_16P4;
204 else if (ext == "16p2") {
205 type = type_16P2;
207 else if (ext == "16p0") {
208 type = type_16P0;
210 else if (ext == "frm" || ext == "FRM") {
211 type = type_leader_frm;
213 else if (ext == "pgm") {
214 type = type_pgm;
216 else if (ext == "pnm") { //hack
217 type = type_ppm;
219 else if (ext == "ppm") {
220 type = type_ppm;
222 else if (ext == "sgi") {
223 type = type_sgi;
225 else if (ext == "8p2") {
226 type = type_8P2;
228 else if (ext == "rgb")
230 type = type_rgb;
232 else if (ext == "rgba")
234 type = type_rgba;
236 else {
237 type = type_unknown;
240 return type;
243 //convert a file extension into enumerated chroma type
244 RawFrame::Chroma SequenceReader::chromaType(RawType type)
246 RawFrame::Chroma inChroma;
248 switch (type) {
249 case type_v210:
250 case type_v216:
251 case type_uy16:
252 case type_uyvy:
253 case type_16P2:
254 case type_8P2:
255 inChroma = RawFrame::Cr422;
256 break;
258 case type_i420:
259 case type_yv12:
260 case type_16P0:
261 inChroma = RawFrame::Cr420;
262 break;
264 case type_16P4:
265 inChroma = RawFrame::Cr444;
266 break;
268 case type_yy16:
269 case type_yyy8:
270 case type_pgm:
271 inChroma = RawFrame::YOnly;
272 break;
274 case type_ppm:
275 case type_sgi:
276 case type_rgb:
277 case type_rgba:
278 inChroma = RawFrame::CrRGB;
279 break;
281 case type_leader_frm: /* for leader, this is overridden later */
282 default:
283 inChroma = RawFrame::Cr422;
284 break;
288 return inChroma;
290 //return the number of bytes per frame for simple concatenated file types, or 0 for other types
291 int SequenceReader::bytesPerFrame(RawType type)
293 int bpf=0;
295 switch (type) {
297 case type_16P4:
298 bpf = rawWidth * rawHeight * 2 * 3;
299 break;
301 case type_v210:
302 bpf = ((rawWidth + 47)/48) * 48 * rawHeight * 2 * 4 / 3;
303 break;
305 case type_v216:
306 case type_uy16:
307 case type_16P2:
308 bpf = rawWidth * rawHeight * 2 * 2;
309 break;
311 case type_16P0:
312 bpf = rawWidth * rawHeight * 2 * 3 / 2;
313 break;
315 case type_i420:
316 case type_yv12:
317 bpf = rawWidth * rawHeight * 3 / 2;
318 break;
320 case type_uyvy:
321 case type_8P2:
322 bpf = rawWidth * rawHeight * 2;
323 break;
325 case type_yyy8:
326 bpf = rawWidth * rawHeight;
327 break;
329 case type_yy16:
330 bpf = rawWidth * rawHeight * 2;
331 break;
333 case type_rgb:
334 bpf = rawWidth * rawHeight * 3;
335 break;
337 case type_rgba:
338 bpf = rawWidth * rawHeight * 4;
339 break;
341 default:
342 bpf = 0;
343 break;
346 return bpf;
349 void SequenceReader::setRawFormat(RawType format)
351 frameType = format;
353 //if we have any files, the info will have changed
354 if (fileList.size() > 0)
355 buildFileInfo();
357 readFrame(currentFrameNum);
360 //open a directory full of files
361 int SequenceReader::setDirectoryOfFiles(const QString &dir)
363 //get directory contents with the extension of the selected file
364 //sorted by name, selecting only files not directories
365 QDir
366 dirInfo(
367 dir,
368 QString("*.v210 *.uy16 *.v216 *.yv12 *.i420 *.16P4 *.16P2 *16P0 *.uyvy *.yuv *.yyy8 *.yy16 *.8P2 *.rgb *.rgba"),
369 QDir::Name, QDir::Files);
371 if (dirInfo.count() == 0)
372 return -1;
374 QFileInfoList fileInfoList = dirInfo.entryInfoList();
375 QStringList list;
376 for (unsigned int i=0; i<dirInfo.count(); i++)
377 list.append(fileInfoList[i].absoluteFilePath());
379 fileList = list; //replace the old file list with the new one
381 if (filePtr != NULL) {
382 fclose(filePtr);
383 filePtr = NULL;
386 //build file information for the new file list
387 buildFileInfo();
389 //success
390 return 0;
393 //given a list of filenames, generate the complete list of filenames in a sequence
394 //if the filename is numerical, subsequent files of the same extension are added to the list
395 int SequenceReader::setFileNames(const QStringList &newFileList)
397 //check for empty list
398 if (newFileList.size() == 0) {
399 //tried to open an empty file list
400 return -1;
403 //check that all the files in the list have a recognised extension
404 for (int i=0; i<newFileList.size(); i++) {
405 QFileInfo info(newFileList.at(i));
406 QString ext = info.suffix();
408 //look for unknown file extensions
409 if ((rawType(ext) == type_unknown) && (frameType == type_auto))
410 //unknown file extension
411 return -2;
414 QStringList list = newFileList;
415 QFileInfo firstFileInfo(list.at(0));
416 bool firstIsNumerical = false;
417 firstFileInfo.baseName().toInt(&firstIsNumerical, 10);
419 //if there is a single entry in the file list, and the file name is a number,
420 //look for other files _after_ this one with the same extension, sorted by name
421 if (list.size() == 1 && firstIsNumerical) {
423 QString ext = firstFileInfo.suffix();
424 QString name = firstFileInfo.fileName();
426 //get directory contents with the extension of the selected file
427 //sorted by name, selecting only files not directories
428 QDir dirInfo(firstFileInfo.absolutePath(), QString("*." + ext),
429 QDir::Name, QDir::Files);
431 //it is possible to iterate over the dirInfo.entryList, but this is horribly slow
432 //instead, get a QFileInfoList which is very fast to access
433 QFileInfoList fileInfoList = dirInfo.entryInfoList();
435 //add to the file list all files which occur after the specified one
436 bool found = false;
437 for (int i = 0; i < fileInfoList.size(); ++i) {
439 //once we have found the selected file in the directory, add subsequent ones to the file list
440 if (found)
441 list.append(fileInfoList[i].absoluteFilePath());
443 //detect when the selected file has been found in the directory listing
444 if (found == false && (fileInfoList[i].fileName() == name))
445 found = true;
449 //we have built the new file list. Use this instead of the old one now.
450 fileList = list;
451 currentFileIndex = 0;
452 if (filePtr != NULL) {
453 fclose(filePtr);
454 filePtr = NULL;
457 //build file information for the new file list
458 buildFileInfo();
460 //success
461 return 0;
464 void SequenceReader::buildFileInfo()
466 infoList.clear();
467 QFileInfo firstFileInfo(fileList.at(0));
469 firstFrame = firstFileInfo.baseName().toInt(NULL, 10);
470 int firstInFile = firstFrame;
471 lastFrame = firstFrame;
473 //for each file in the list, get the info on it
474 for (int i=0; i<fileList.size(); i++) {
476 QFileInfo fileInfo(fileList.at(i));
477 QString ext = fileInfo.suffix();
479 sequenceFileInfo sfi;
481 if (frameType == type_auto)
482 sfi.rawType = rawType(ext);
483 else
484 sfi.rawType = frameType;
486 sfi.bytesPerFrame = bytesPerFrame(sfi.rawType);
488 //determine the number of frames in a file, avoiding a division by zero
489 if (sfi.bytesPerFrame > 0) {
490 sfi.framesInFile = (int)(fileInfo.size() / sfi.bytesPerFrame);
492 else {
493 sfi.framesInFile = 0;
496 //there is at least one frame, even if the file is too small for bytesPerFrame
497 if (sfi.framesInFile == 0)
498 sfi.framesInFile = 1;
500 sfi.bitDepth = bitDepth(sfi.rawType);
501 sfi.hasHeader = hasHeader(sfi.rawType);
502 sfi.chroma = chromaType(sfi.rawType);
503 sfi.firstFrameNum = firstInFile;
504 sfi.lastFrameNum = firstInFile + sfi.framesInFile - 1;
506 infoList.push_back(sfi);
508 firstInFile += sfi.framesInFile; //first frame number in next file
509 lastFrame = sfi.lastFrameNum; //last frame number in the sequence
512 if (DEBUG) {
514 printf("First frame is %d\n", firstFrame);
515 printf("Last frame is %d\n", lastFrame);
516 printf("Raw width is %d\n", rawWidth);
517 printf("Raw Height is %d\n", rawHeight);
519 //dump the file list, for interest
520 for (int i=0; i<fileList.size(); i++) {
521 printf("File list entry %d (%s)\n", i, fileList.at(i).toLatin1().data());
522 printf(" File info bytesPerFrame = %d\n", infoList.at(i).bytesPerFrame);
523 printf(" File info chroma = %d\n", (int)infoList.at(i).chroma);
524 printf(" File info has header = %d\n", (int)infoList.at(i).hasHeader);
525 printf(" File info bit depth = %d\n", infoList.at(i).bitDepth);
526 printf(" File info framesInFile = %d\n", infoList.at(i).framesInFile);
527 printf(" File info firstFrameNum = %d\n", infoList.at(i).firstFrameNum);
528 printf(" File info lastFrameNum = %d\n", infoList.at(i).lastFrameNum);
532 //sanity check on currentFrameNum, as the frame numbering may have changed
533 if (currentFrameNum < firstFrame)
534 currentFrameNum = firstFrame;
536 if (currentFrameNum > lastFrame)
537 currentFrameNum = lastFrame;
540 int SequenceReader::fileIndexForFrameNum(int frameNum)
542 int index=0;
544 if (frameNum > currentFrameNum) {
546 //search forwards
547 for (int i=currentFileIndex; i<(int)infoList.size(); i++) {
549 if (frameNum >= infoList.at(i).firstFrameNum && frameNum <= infoList.at(i).lastFrameNum) {
550 index = i;
551 break;
556 else {
558 //search backwards
559 for (int i=currentFileIndex; i>0; i--) {
560 if (frameNum >= infoList.at(i).firstFrameNum && frameNum <= infoList.at(i).lastFrameNum) {
561 index = i;
562 break;
568 return index;
571 void SequenceReader::nextInSequence()
573 readFrame(currentFrameNum+1);
576 void SequenceReader::prevInSequence()
578 readFrame(currentFrameNum-1);
581 //move to a frame number in the sequence
582 int SequenceReader::jumpInSequence(int wantedFrame)
584 //santiy check
585 if (wantedFrame > lastFrame || wantedFrame < firstFrame)
586 return -1;
588 if(fileList.size() < 1)
589 return -1;
591 //get the file index for the wanted frame number
592 int newFileIndex = fileIndexForFrameNum(wantedFrame);
594 //see if we have that file open at the moment
595 if (newFileIndex != currentFileIndex || filePtr == NULL) {
596 //open a the new file
597 currentFileIndex = newFileIndex;
599 //open the new file
600 if (filePtr != NULL)
601 fclose(filePtr);
602 filePtr = fopen(fileList.at(currentFileIndex).toLatin1().data(), "rb");
603 emit(frameFileName(fileList.at(currentFileIndex)));
606 if (filePtr == NULL) {
607 return -2;
610 //seek to the position of the wanted frame in the current file
611 off_t frameOffset = wantedFrame - infoList.at(currentFileIndex).firstFrameNum;
612 off_t byteOffset = frameOffset * infoList.at(currentFileIndex).bytesPerFrame;
614 #ifdef Q_OS_WIN32
615 #ifdef Q_CC_MSVC
616 #if _MSC_VER >= 1400
617 if(_fseeki64(filePtr, byteOffset, SEEK_SET)) {
618 #else
619 if(fseek(filePtr, byteOffset, SEEK_SET)) {
620 #endif
621 #endif
623 #ifdef Q_CC_GNU
624 if(fseeko64(filePtr, byteOffset, SEEK_SET)) {
625 #endif
626 #endif
628 #ifdef Q_OS_UNIX
629 if(fseeko(filePtr, byteOffset, SEEK_SET)) {
630 #endif
631 return -3;
634 //all done
635 currentFrameNum = wantedFrame;
637 QFileInfo fi(fileList.at(currentFileIndex));
639 emit(sequencePosition(fi.fileName(), currentFrameNum - infoList.at(currentFileIndex).firstFrameNum, firstFrame, currentFrameNum, lastFrame));
641 //success
642 return 0;
645 //read a particular frame number
646 RawFrame & SequenceReader::readFrame(int frameNum)
648 if(fileList.size()> 0) {
650 jumpInSequence(frameNum);
652 RawReader *r=NULL;
654 //select either the frame type from the extension, or the user selected override
655 RawType type;
657 if(infoList.at(currentFileIndex).hasHeader) {
658 type = infoList.at(currentFileIndex).rawType;
660 else {
661 type = (frameType == type_auto) ? infoList.at(currentFileIndex).rawType : frameType;
664 switch(type) {
666 case type_yyy8:
667 emit(frameFormat(QString("YYY8 (Yonly) 8Bit")));
668 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
669 r = new RawReaderYYY8(filePtr);
670 break;
672 case type_yy16:
673 emit(frameFormat(QString("YY16 (Yonly) 16Bit")));
674 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
675 r = new RawReaderYY16(filePtr);
676 break;
678 case type_v216:
679 emit(frameFormat(QString("V216 4:2:2 16Bit muxed")));
680 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
681 r = new RawReaderV216(filePtr);
682 break;
684 case type_uy16:
685 emit(frameFormat(QString("UY16 4:2:2 16Bit muxed")));
686 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
687 r = new RawReaderUY16(filePtr);
688 break;
690 case type_v210:
691 emit(frameFormat(QString("V210 4:2:2 10Bit packed")));
692 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
693 r = new RawReaderv210(filePtr);
694 break;
696 case type_yv12:
697 emit(frameFormat(QString("YV12 4:2:0 8Bit planar YVU")));
698 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
699 r = new RawReaderYV12(filePtr);
700 break;
702 case type_i420:
703 emit(frameFormat(QString("I420 4:2:0 8Bit planar YUV")));
704 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
705 r = new RawReaderi420(filePtr);
706 break;
708 case type_16P4:
709 emit(frameFormat(QString("16P4 4:4:4 16Bit planar YUV")));
710 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
711 r = new RawReader16P4(filePtr);
712 break;
714 case type_16P2:
715 emit(frameFormat(QString("16P2 4:2:2 16Bit planar YUV")));
716 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
717 r = new RawReader16P2(filePtr);
718 break;
720 case type_16P0:
721 emit(frameFormat(QString("16P0 4:2:0 16Bit planar YUV")));
722 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
723 r = new RawReader16P0(filePtr);
724 break;
726 case type_uyvy:
727 emit(frameFormat(QString("UYVY 4:2:2 8Bit muxed")));
728 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
729 r = new RawReaderuyvy(filePtr);
730 break;
732 case type_rgb:
733 emit(frameFormat(QString("RGB 8Bit muxed")));
734 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
735 r = new RawReaderrgb(filePtr);
736 break;
738 case type_rgba:
739 emit(frameFormat(QString("RGBA 8Bit muxed")));
740 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
741 r = new RawReaderrgba(filePtr);
742 break;
744 case type_leader_frm:
745 r = new RawReaderLeaderFRM(filePtr);
746 emit(frameFormat(QString("Leader RAW FRM (%1 bits)") .arg(r->getDepth())));
747 emit(frameBitDepth(r->getDepth()));
748 break;
750 case type_pgm:
751 r = new RawReaderpgm(filePtr);
752 emit(frameFormat(QString("Portable Greymap (%1 bits)") .arg(r->getDepth())));
753 emit(frameBitDepth(r->getDepth()));
754 break;
756 case type_ppm:
757 r = new RawReaderppm(filePtr);
758 emit(frameFormat(QString("Portable Pixmap (%1 bits)") .arg(r->getDepth())));
759 emit(frameBitDepth(r->getDepth()));
760 break;
762 case type_sgi:
763 r = new RawReadersgi(filePtr);
764 emit(frameFormat(QString("SGI file (%1 bits)") .arg(r->getDepth())));
765 emit(frameBitDepth(r->getDepth()));
766 break;
768 case type_8P2:
769 r = new RawReader8P2(filePtr);
770 emit(frameFormat(QString("8P2 4:2:2 8Bit planar YUV")));
771 emit(frameBitDepth(infoList.at(currentFileIndex).bitDepth));
772 break;
774 default:
775 emit(frameFormat(QString("File of unknown type '%1'") .arg(fileList.at(currentFileIndex))));
776 emit(frameBitDepth(0));
777 break;
780 //check if the frame dimensions can be read from the frame header
781 emit(frameHasHeader(infoList.at(currentFileIndex).hasHeader));
783 if(infoList.at(currentFileIndex).hasHeader) {
784 frameWidth = r->getWidth();
785 frameHeight = r->getHeight();
786 frameDepth = r->getDepth();
788 else {
789 frameDepth = infoList.at(currentFileIndex).bitDepth;
790 frameWidth = rawWidth;
791 frameHeight = rawHeight;
794 //determine the chroma type that we will read into
795 //this is set either by the file extension or the image->image format menu
796 RawFrame::Chroma chroma;
797 if (frameType == type_leader_frm)
798 chroma = ((RawReaderLeaderFRM*)r)->getChroma();
799 else if(frameType == type_auto)
800 chroma = infoList.at(currentFileIndex).chroma;
801 else
802 chroma = chromaType(frameType);
804 //sanity checks - is the destination frame type correct?
805 if(destFrame->chroma != chroma ||
806 destFrame->luma.width() != frameWidth ||
807 destFrame->luma.height() != frameHeight) {
808 delete destFrame;
809 destFrame = new RawFrame(frameWidth, frameHeight, chroma);
812 //read the frame
813 if(r != NULL) {
814 r->read(*destFrame);
815 delete(r);
818 emit newFrame(destFrame);
819 emit frameHasHeader(infoList.at(currentFileIndex).hasHeader);
821 QSize s = QSize(frameWidth, frameHeight);
822 emit frameSize(s);
825 return *destFrame;
828 void SequenceReader::setSizeType(ImageSizes s)
830 rawWidth = rawImageWidth[s];
831 rawHeight = rawImageHeight[s];
833 //if we have any files, the info will have changed
834 if (fileList.size() > 0)
835 buildFileInfo();
837 readFrame(currentFrameNum);
840 //the dimensions of the frame are changed
841 void SequenceReader::setCustomSize(int width, int height)
843 rawImageWidth[SizeCustom] = width;
844 rawImageHeight[SizeCustom] = height;
847 int SequenceReader::getCustomWidth() {
848 return rawImageWidth[SizeCustom];
851 int SequenceReader::getCustomHeight() {
852 return rawImageHeight[SizeCustom];
855 bool SequenceReader::getFrameHasHeader(void)
857 bool hasHeader = false;
859 if (infoList.size() > 0)
860 hasHeader = infoList.at(currentFileIndex).hasHeader;
862 return hasHeader;