if (indexPosition > 0) { // attempt to get AVI2.0 index instead of scanning for all frames raFile.seek(indexPosition); nextPosition = findFourccAndRead(FOURCC_indx, false, indexPositionEnd, false); if (positionBehindMovie > FOUR_GB) isOversizedAvi1 = true; nextPosition = findFourccAndRead(FOURCC_idx1, false, fileSize, false); if (nextPosition >= 0) //AVI-1 index 'idx1' found break; } else { frameNumber = 1; findFourccAndRead(FOURCC_movi, true, fileSize, true); pos = findFourccAndRead(FOURCC_RIFF, false, fileSize, false); return;
if (indexPosition > 0) { // attempt to get AVI2.0 index instead of scanning for all frames raFile.seek(indexPosition); nextPosition = findFourccAndRead(FOURCC_indx, false, indexPositionEnd, false); if (positionBehindMovie > FOUR_GB) isOversizedAvi1 = true; nextPosition = findFourccAndRead(FOURCC_idx1, false, fileSize, false); if (nextPosition >= 0) //AVI-1 index 'idx1' found break; } else { frameNumber = 1; findFourccAndRead(FOURCC_movi, true, fileSize, true); pos = findFourccAndRead(FOURCC_RIFF, false, fileSize, false); return;
/** Read AVIX chunks following the first RIFF AVI for large files (sequential reading frame-by-frame beyond the first chunk) **/ private void readAVIX(long endPosition) throws Exception, IOException { if (verbose) IJ.log("Trying to read AVIX"+timeString()); int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVIX')"); if (riffType != FOURCC_AVIX) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_movi, true, fileSize, true); //read movie data }
/** Read AVIX chunks following the first RIFF AVI for large files (sequential reading frame-by-frame beyond the first chunk) **/ private void readAVIX(long endPosition) throws Exception, IOException { if (verbose) IJ.log("Trying to read AVIX"+timeString()); int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVIX')"); if (riffType != FOURCC_AVIX) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_movi, true, fileSize, true); //read movie data }
/** Open the file with given path and read its header */ private void openAndReadHeader (String path) throws Exception, IOException { startTime = System.currentTimeMillis(); if (verbose) IJ.log("OPEN AND READ AVI FILE HEADER "+timeString()); File file = new File(path); // o p e n raFile = new RandomAccessFile(file, "r"); raFilePath = path; fileSize = raFile.length(); int fileType = readInt(); // f i l e h e a d e r if (verbose) IJ.log("File header: File type='"+fourccString(fileType)+"' (should be 'RIFF')"+timeString()); if (fileType != FOURCC_RIFF) throw new Exception("Not an AVI file."); aviSize = readInt() & SIZE_MASK; //size of AVI chunk int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVI ')"); if (riffType != FOURCC_AVI) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_hdrl, true, fileSize, true); startTime -= System.currentTimeMillis(); //becomes minus elapsed Time headerOK = true; }
case FOURCC_hdrl: headerPositionEnd = endPosition; findFourccAndRead(FOURCC_avih, false, endPosition, true); findFourccAndRead(FOURCC_strl, true, endPosition, true); return true; case FOURCC_avih: return true; case FOURCC_strl: long nextPosition = findFourccAndRead(FOURCC_strh, false, endPosition, false); if (nextPosition<0) return false; indexPosition = findFourccAndRead(FOURCC_strf, false, endPosition, true); indexPositionEnd= endPosition; indexForCountingOnly = true; //try reading indx for counting number of entries totalFramesFromIndex = 0; nextPosition = findFourccAndRead(FOURCC_indx, false, endPosition, false); if (nextPosition > 0 && totalFramesFromIndex > dwTotalFrames) dwTotalFrames = totalFramesFromIndex;
case FOURCC_hdrl: headerPositionEnd = endPosition; findFourccAndRead(FOURCC_avih, false, endPosition, true); findFourccAndRead(FOURCC_strl, true, endPosition, true); return true; case FOURCC_avih: return true; case FOURCC_strl: long nextPosition = findFourccAndRead(FOURCC_strh, false, endPosition, false); if (nextPosition<0) return false; indexPosition = findFourccAndRead(FOURCC_strf, false, endPosition, true); indexPositionEnd= endPosition; indexForCountingOnly = true; //try reading indx for counting number of entries totalFramesFromIndex = 0; nextPosition = findFourccAndRead(FOURCC_indx, false, endPosition, false); if (nextPosition > 0 && totalFramesFromIndex > dwTotalFrames) dwTotalFrames = totalFramesFromIndex;
/** Open the file with given path and read its header */ private void openAndReadHeader (String path) throws Exception, IOException { startTime = System.currentTimeMillis(); if (verbose) IJ.log("OPEN AND READ AVI FILE HEADER "+timeString()); File file = new File(path); // o p e n raFile = new RandomAccessFile(file, "r"); raFilePath = path; fileSize = raFile.length(); int fileType = readInt(); // f i l e h e a d e r if (verbose) IJ.log("File header: File type='"+fourccString(fileType)+"' (should be 'RIFF')"+timeString()); if (fileType != FOURCC_RIFF) throw new Exception("Not an AVI file."); aviSize = readInt() & SIZE_MASK; //size of AVI chunk int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVI ')"); if (riffType != FOURCC_AVI) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_hdrl, true, fileSize, true); startTime -= System.currentTimeMillis(); //becomes minus elapsed Time headerOK = true; }
long nextIndxEntryPointer = raFile.getFilePointer(); findFourccAndRead(FOURCC_ix00, false, qwOffset+dwSize, false); raFile.seek(nextIndxEntryPointer); if (frameNumber>lastFrameToRead) break;
long nextIndxEntryPointer = raFile.getFilePointer(); findFourccAndRead(FOURCC_ix00, false, qwOffset+dwSize, false); raFile.seek(nextIndxEntryPointer); if (frameNumber>lastFrameToRead) break;