Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickTime: images may not be readable when using Memoizer #4091

Open
melissalinkert opened this issue Aug 30, 2023 · 0 comments
Open

QuickTime: images may not be readable when using Memoizer #4091

melissalinkert opened this issue Aug 30, 2023 · 0 comments

Comments

@melissalinkert
Copy link
Member

Importing the file from curated/quicktime/qa-11074 into OMERO succeeds and the first 3 planes can be viewed, but subsequent planes fail to display with errors like this in the logs:

java.lang.NullPointerException: null
        at loci.formats.in.NativeQTReader.openBytes(NativeQTReader.java:231)
        at loci.formats.DelegateReader.openBytes(DelegateReader.java:227)
        at loci.formats.ImageReader.openBytes(ImageReader.java:465)
        at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:167)
        at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:159)
        at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:200)
        at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
        at ome.io.bioformats.BfPixelsWrapper.getTile(BfPixelsWrapper.java:350)
        at ome.io.bioformats.BfPixelBuffer.getTile(BfPixelBuffer.java:499)

I could not immediately reproduce this with showinf or showinf -cache. Some simple test code does show the same exception though:

$ cat Test.java 
import java.util.Arrays;
import loci.formats.ImageReader;
import loci.formats.Memoizer;

public class Test {
  public static void main(String[] args) throws Exception {
    try (ImageReader r = new ImageReader()) {
      r.setId(args[0]);

      for (int i=0; i<r.getImageCount(); i++) {
        Memoizer m = new Memoizer();
        m.setId(args[0]);
        byte[] regularPlane = r.openBytes(i);
        byte[] memoPlane = m.openBytes(i);
        System.out.println("plane #" + i + " equal: " + Arrays.equals(regularPlane, memoPlane));
      }
    }
  }
}
$ java Test hekdfcpgfpmcherry2xfyvelivestarve_p0.mov

The source of the issue seems to be that the prevPixels array in NativeQTReader (QTReader in 7.0.0+) changes after every openBytes - as expected, this is for handling the case when the stored plane is actually the difference between the current and previous planes. However, updates to prevPixels do not get written back to the memo file - also more or less as expected. This means that prevPixels can be in the wrong state for a given plane when the Memoizer is reinitialized on every plane read.

This may be slightly tricky to fix; getting prevPixels into the correct state for a particular plane can require reading all previous planes.

As far as I can tell, this was not recently introduced, and has likely been a problem for a long time. We might want to consider adding a repository test that demonstrates this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant