private String posSizeString(long size) throws IOException { return posSizeString(raFile.getFilePointer(), size); }
private String posSizeString(long size) throws IOException { return posSizeString(raFile.getFilePointer(), size); }
/** Read type of next chunk that is not JUNK. * Returns type (or 0 if no non-JUNK chunk until endPosition) */ private int readType(long endPosition) throws IOException { while (true) { long pos = raFile.getFilePointer(); if (pos%paddingGranularity!=0) { pos = (pos/paddingGranularity+1)*paddingGranularity; raFile.seek(pos); //pad to even address } if (pos >= endPosition) return 0; int type = readInt(); if (type != FOURCC_JUNK) return type; long size = readInt()&SIZE_MASK; if (verbose) IJ.log("Skip JUNK: "+posSizeString(size)); raFile.seek(raFile.getFilePointer()+size); //skip junk } }
/** Read type of next chunk that is not JUNK. * Returns type (or 0 if no non-JUNK chunk until endPosition) */ private int readType(long endPosition) throws IOException { while (true) { long pos = raFile.getFilePointer(); if (pos%paddingGranularity!=0) { pos = (pos/paddingGranularity+1)*paddingGranularity; raFile.seek(pos); //pad to even address } if (pos >= endPosition) return 0; int type = readInt(); if (type != FOURCC_JUNK) return type; long size = readInt()&SIZE_MASK; if (verbose) IJ.log("Skip JUNK: "+posSizeString(size)); raFile.seek(raFile.getFilePointer()+size); //skip junk } }
/** Find the next position of fourcc or LIST fourcc, but does not read it, only * returns the first position inside the fourcc chunk and puts the file pointer * behind the fourcc chunk (if successful). * If not found, returns -1 */ private long findFourccAndSkip(int fourcc, boolean isList, long endPosition) throws IOException { while (true) { int type = readType(endPosition); if (type == 0) //reached endPosition without finding return -1; long size = readInt() & SIZE_MASK; long chunkPos = raFile.getFilePointer(); long nextPos = chunkPos + size; //note that 'size' of a list includes the 'type' that follows now if (isList && type == FOURCC_LIST) type = readInt(); if (verbose) IJ.log("Searching for (to skip) '"+fourccString(fourcc)+"', found "+fourccString(type)+ "' data "+posSizeString(chunkPos, size)); raFile.seek(nextPos); if (type == fourcc) return chunkPos; //found and skipped, breaks the loop } }
/** Find the next position of fourcc or LIST fourcc, but does not read it, only * returns the first position inside the fourcc chunk and puts the file pointer * behind the fourcc chunk (if successful). * If not found, returns -1 */ private long findFourccAndSkip(int fourcc, boolean isList, long endPosition) throws IOException { while (true) { int type = readType(endPosition); if (type == 0) //reached endPosition without finding return -1; long size = readInt() & SIZE_MASK; long chunkPos = raFile.getFilePointer(); long nextPos = chunkPos + size; //note that 'size' of a list includes the 'type' that follows now if (isList && type == FOURCC_LIST) type = readInt(); if (verbose) IJ.log("Searching for (to skip) '"+fourccString(fourcc)+"', found "+fourccString(type)+ "' data "+posSizeString(chunkPos, size)); raFile.seek(nextPos); if (type == fourcc) return chunkPos; //found and skipped, breaks the loop } }
IJ.log("MOVIE DATA "+posSizeString(endPosition-raFile.getFilePointer())+timeString()+ "\nSearching for stream "+streamNumber+": '"+ fourccString(type0xdb)+"' or '"+fourccString(type0xdc)+"' chunks"); IJ.showProgress((double)frameNumber /lastFrameToRead); if (verbose) IJ.log(frameNumber+" movie data '"+fourccString(type)+"' "+posSizeString(size)+timeString()); if (frameNumber >= firstFrame) { if (isVirtual) if (frameNumber>lastFrameToRead) break; } else if (verbose) IJ.log("skipped '"+fourccString(type)+"' "+posSizeString(size)); if (nextPos > endPosition) break; raFile.seek(nextPos);
IJ.log("MOVIE DATA "+posSizeString(endPosition-raFile.getFilePointer())+timeString()+ "\nSearching for stream "+streamNumber+": '"+ fourccString(type0xdb)+"' or '"+fourccString(type0xdc)+"' chunks"); IJ.showProgress((double)frameNumber /lastFrameToRead); if (verbose) IJ.log(frameNumber+" movie data '"+fourccString(type)+"' "+posSizeString(size)+timeString()); if (frameNumber >= firstFrame) { if (isVirtual) if (frameNumber>lastFrameToRead) break; } else if (verbose) IJ.log("skipped '"+fourccString(type)+"' "+posSizeString(size)); if (nextPos > endPosition) break; raFile.seek(nextPos);
frameInfos.add(new long[]{framePos+8, dwSize, (long)frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("idx1 movie data '"+fourccString(dwChunkId)+"' "+posSizeString(framePos,dwSize)+timeString());
frameInfos.add(new long[]{framePos+8, dwSize, (long)frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("idx1 movie data '"+fourccString(dwChunkId)+"' "+posSizeString(framePos,dwSize)+timeString());
type = readInt(); if (verbose) IJ.log("Search for '"+fourccString(fourcc)+"', found "+fourccString(type)+"' data "+posSizeString(nextPos-size, size)); if (type==fourcc) { contentOk = readContents(fourcc, nextPos);
type = readInt(); if (verbose) IJ.log("Search for '"+fourccString(fourcc)+"', found "+fourccString(type)+"' data "+posSizeString(nextPos-size, size)); if (type==fourcc) { contentOk = readContents(fourcc, nextPos);
int dwDuration = readInt(); //number of frames in ix00; ignored: not always trustworthy if (verbose) IJ.log(" indx entry: '" +fourccString(dwChunkId)+"' incl header "+posSizeString(qwOffset,dwSize)+timeString()); long nextIndxEntryPointer = raFile.getFilePointer(); frameInfos.add(new long[] {pos, dwSize, (long) frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("movie data "+frameNumber+" '"+fourccString(dwChunkId)+"' "+posSizeString(pos,dwSize)+timeString());
int dwDuration = readInt(); //number of frames in ix00; ignored: not always trustworthy if (verbose) IJ.log(" indx entry: '" +fourccString(dwChunkId)+"' incl header "+posSizeString(qwOffset,dwSize)+timeString()); long nextIndxEntryPointer = raFile.getFilePointer(); frameInfos.add(new long[] {pos, dwSize, (long) frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("movie data "+frameNumber+" '"+fourccString(dwChunkId)+"' "+posSizeString(pos,dwSize)+timeString());
IJ.log(" Reading "+biClrUsed+" Palette colors: " + posSizeString(spaceForPalette)); if (spaceForPalette < biClrUsed*4) throw new Exception("Not enough data ("+spaceForPalette+") for palette of size "+(biClrUsed*4));
IJ.log(" Reading "+biClrUsed+" Palette colors: " + posSizeString(spaceForPalette)); if (spaceForPalette < biClrUsed*4) throw new Exception("Not enough data ("+spaceForPalette+") for palette of size "+(biClrUsed*4));