Changeset 4906


Ignore:
Timestamp:
03/11/09 15:13:05 (11 years ago)
Author:
melissa
Message:

Moved native QuickTime reader to loci.formats.in.NativeQTReader. QTReader is now the master reader for QuickTime files, and will delegate to NativeQTReader or LegacyQTReader as appropriate. See #362.

Location:
trunk/components/bio-formats/src/loci/formats/in
Files:
1 added
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/LegacyQTReader.java

    r4819 r4906  
    113113  public void close(boolean fileOnly) throws IOException { 
    114114    try { 
    115       if (r.getVar("openMovieFile") != null) { 
     115      if (r != null && r.getVar("openMovieFile") != null) { 
    116116        r.exec("openMovieFile.close()"); 
    117117        if (!fileOnly) { 
  • trunk/components/bio-formats/src/loci/formats/in/NativeQTReader.java

    r4819 r4906  
    11// 
    2 // QTReader.java 
     2// NativeQTReader.java 
    33// 
    44 
     
    3434 
    3535/** 
    36  * QTReader is the file format reader for QuickTime movie files. 
     36 * NativeQTReader is the file format reader for QuickTime movie files. 
    3737 * It does not require any external libraries to be installed. 
    3838 * 
     
    4141 * 
    4242 * <dl><dt><b>Source code:</b></dt> 
    43  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/QTReader.java">Trac</a>, 
    44  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/QTReader.java">SVN</a></dd></dl> 
     43 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/NativeQTReader.java">Trac</a>, 
     44 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/NativeQTReader.java">SVN</a></dd></dl> 
    4545 * 
    4646 * @author Melissa Linkert linkert at wisc.edu 
    4747 */ 
    48 public class QTReader extends FormatReader { 
     48public class NativeQTReader extends FormatReader { 
    4949 
    5050  // -- Constants -- 
     
    9191  private int altPlanes; 
    9292 
    93   /** An instance of the old QuickTime reader, in case this one fails. */ 
    94   private LegacyQTReader legacy; 
    95  
    96   /** Flag indicating whether to use legacy reader by default. */ 
    97   private boolean useLegacy; 
    98  
    9993  /** Amount to subtract from each offset. */ 
    10094  private int scale; 
     
    114108 
    115109  /** Constructs a new QuickTime reader. */ 
    116   public QTReader() { 
     110  public NativeQTReader() { 
    117111    super("QuickTime", "mov"); 
    118112    blockCheckLen = 64; 
    119113  } 
    120  
    121   // -- QTReader API methods -- 
    122  
    123   /** Sets whether to use the legacy reader (QTJava) by default. */ 
    124   public void setLegacy(boolean legacy) { useLegacy = legacy; } 
    125114 
    126115  // -- IFormatReader API methods -- 
     
    163152  } 
    164153 
    165   /* @see loci.formats.IFormatReader#setMetadataStore(MetadataStore) */ 
    166   public void setMetadataStore(MetadataStore store) { 
    167     FormatTools.assertId(currentId, false, 1); 
    168     super.setMetadataStore(store); 
    169     if (useLegacy) legacy.setMetadataStore(store); 
    170   } 
    171  
    172   /** 
    173    * @see loci.formats.IFormatReader#openImage(int, int, int, int, int) 
    174    */ 
    175   public BufferedImage openImage(int no, int x, int y, int w, int h) 
    176     throws FormatException, IOException 
    177   { 
    178     FormatTools.assertId(currentId, true, 1); 
    179     FormatTools.checkPlaneNumber(this, no); 
    180  
    181     String code = codec; 
    182     if (no >= getImageCount() - altPlanes) code = altCodec; 
    183  
    184     boolean doLegacy = useLegacy; 
    185     if (!doLegacy && !code.equals("raw ") && !code.equals("rle ") && 
    186       !code.equals("jpeg") && !code.equals("mjpb") && !code.equals("rpza")) 
    187     { 
    188       if (debug) { 
    189         debug("Unsupported codec (" + code + "); using QTJava reader"); 
    190       } 
    191       doLegacy = true; 
    192     } 
    193     if (doLegacy) { 
    194       if (legacy == null) legacy = createLegacyReader(); 
    195       legacy.setId(currentId); 
    196       return legacy.openImage(no, x, y, w, h); 
    197     } 
    198     return super.openImage(no, x, y, w, h); 
    199   } 
    200  
    201154  /** 
    202155   * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) 
     
    211164    String code = codec; 
    212165    if (no >= getImageCount() - altPlanes) code = altCodec; 
    213  
    214     boolean doLegacy = useLegacy; 
    215     if (!doLegacy && !code.equals("raw ") && !code.equals("rle ") && 
    216       !code.equals("jpeg") && !code.equals("mjpb") && !code.equals("rpza")) 
    217     { 
    218       if (debug) { 
    219         debug("Unsupported codec (" + code + "); using QTJava reader"); 
    220       } 
    221       doLegacy = true; 
    222     } 
    223     if (doLegacy) { 
    224       if (legacy == null) legacy = createLegacyReader(); 
    225       legacy.setId(currentId); 
    226       return legacy.openBytes(no, buf, x, y, w, h); 
    227     } 
    228166 
    229167    int offset = ((Integer) offsets.get(no)).intValue(); 
     
    323261  public void close() throws IOException { 
    324262    super.close(); 
    325     if (legacy != null) { 
    326       legacy.close(); 
    327       legacy = null; 
    328     } 
    329263    offsets = null; 
    330264    prevPixels = null; 
     
    332266    pixelOffset = pixelBytes = bitsPerPixel = rawSize = 0; 
    333267    prevPlane = altPlanes = 0; 
    334     canUsePrevious = useLegacy = false; 
     268    canUsePrevious = false; 
    335269  } 
    336270 
     
    348282    status("Parsing tags"); 
    349283 
    350     Exception exc = null; 
    351     try { parse(0, 0, in.length()); } 
    352     catch (FormatException e) { exc = e; } 
    353     catch (IOException e) { exc = e; } 
    354     if (exc != null) { 
    355       if (debug) trace(exc); 
    356       useLegacy = true; 
    357       legacy = createLegacyReader(); 
    358       legacy.setId(id); 
    359       core = legacy.getCoreMetadata(); 
    360       return; 
    361     } 
     284    parse(0, 0, in.length()); 
    362285 
    363286    core[0].imageCount = offsets.size(); 
     
    732655  } 
    733656 
    734   /** Creates a legacy QT reader. */ 
    735   private LegacyQTReader createLegacyReader() { 
    736     // use the same id mappings that this reader does 
    737     LegacyQTReader reader = new LegacyQTReader(); 
    738     reader.setMetadataStore(getMetadataStore()); 
    739     return reader; 
    740   } 
    741  
    742657} 
Note: See TracChangeset for help on using the changeset viewer.