Skip to content

Commit

Permalink
Merge pull request #1014 from bpindelski/jpegxr
Browse files Browse the repository at this point in the history
Add initial structure for decompressing JPEG XR images (assist #8493).
  • Loading branch information
melissalinkert committed Apr 23, 2014
2 parents e852f90 + 8efacec commit d97fd41
Show file tree
Hide file tree
Showing 53 changed files with 4,252 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ant/toplevel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ merged-docs.source = ${root.dir}/components/formats-common/build/src:\
${root.dir}/components/formats-gpl/build/src:\
${root.dir}/components/bio-formats-plugins/build/src:\
${root.dir}/components/metakit/build/src:\
${root.dir}/components/ome-jxr/build/src:\
${root.dir}/components/ome-xml/build/src:\
${root.dir}/components/stubs/lwf-stubs/build/src:\
${root.dir}/components/test-suite/build/src:\
Expand Down Expand Up @@ -87,6 +88,7 @@ loci-tools.libraries = formats-api.jar \
metakit.jar \
native-lib-loader-2.0-SNAPSHOT.jar \
netcdf-4.3.19.jar \
ome-jxr.jar \
ome-xml.jar \
perf4j-0.9.13.jar \
ome-poi.jar \
Expand Down
45 changes: 45 additions & 0 deletions ant/toplevel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Type "ant -p" for a list of targets.
compile-lwf-stubs,
compile-mdbtools,
compile-metakit,
compile-ome-jxr,
compile-ome-xml,
compile-ome-poi,
compile-formats-api,
Expand All @@ -42,6 +43,7 @@ Type "ant -p" for a list of targets.
jar-lwf-stubs,
jar-mdbtools,
jar-metakit,
jar-ome-jxr,
jar-ome-xml,
jar-ome-poi,
jar-formats-api,
Expand All @@ -63,6 +65,7 @@ Type "ant -p" for a list of targets.
osgi-lwf-stubs,
osgi-mdbtools,
osgi-metakit,
osgi-ome-jxr,
osgi-ome-xml,
osgi-ome-poi,
osgi-formats-api,
Expand All @@ -89,6 +92,7 @@ Type "ant -p" for a list of targets.
findbugs-formats-api,
findbugs-formats-bsd,
findbugs-bio-formats-tools,
findbugs-ome-jxr,
findbugs-tests"
description="run findbugs on most components"/>

Expand All @@ -102,6 +106,7 @@ Type "ant -p" for a list of targets.
clean-lwf-stubs,
clean-mdbtools,
clean-metakit,
clean-ome-jxr,
clean-ome-xml,
clean-ome-poi,
clean-formats-api,
Expand All @@ -126,6 +131,7 @@ Type "ant -p" for a list of targets.
test-lwf-stubs,
test-mdbtools,
test-metakit,
test-ome-jxr,
test-ome-xml,
test-ome-poi,
test-formats-api,
Expand Down Expand Up @@ -335,6 +341,42 @@ Type "ant -p" for a list of targets.
<ant dir="components/metakit" target="test"/>
</target>

<!-- OME JPEG XR library -->

<target name="deps-ome-jxr"
depends="jar-formats-common, jar-formats-bsd"/>

<target name="compile-ome-jxr" depends="deps-ome-jxr"
description="compile classes for OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="ome-jxr.compile"/>
</target>

<target name="jar-ome-jxr" depends="deps-ome-jxr"
description="generate JAR file for OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="ome-jxr.jar"/>
</target>

<target name="osgi-ome-jxr" depends="jar-ome-jxr"
description="generate OSGi bundle for OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="ome-jxr.osgi"/>
</target>

<target name="findbugs-ome-jxr" depends="jar-ome-jxr"
description="run findbugs on OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="ome-jxr.findbugs"/>
</target>

<target name="clean-ome-jxr"
depends="clean-formats-common"
description="remove build files for OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="ome-jxr.clean"/>
</target>

<target name="test-ome-jxr" depends="jar-ome-jxr, testing-deps"
description="compile and run tests for OME JPEG XR Java library">
<ant dir="components/ome-jxr" target="test"/>
</target>

<!-- OME-XML Java library -->

<target name="deps-ome-xml" depends="copy-jars, jar-formats-common" />
Expand Down Expand Up @@ -554,6 +596,7 @@ Type "ant -p" for a list of targets.
depends="copy-jars, jar-formats-common,
jar-mdbtools,
jar-metakit,
jar-ome-jxr,
jar-ome-xml,
jar-ome-poi,
jar-formats-api,
Expand Down Expand Up @@ -583,6 +626,7 @@ Type "ant -p" for a list of targets.
depends="clean-formats-common,
clean-mdbtools,
clean-metakit,
clean-ome-jxr,
clean-ome-xml,
clean-ome-poi,
clean-formats-api,
Expand Down Expand Up @@ -797,6 +841,7 @@ Type "ant -p" for a list of targets.
jar-bio-formats-plugins,
jar-mdbtools,
jar-metakit,
jar-ome-jxr,
jar-ome-xml,
jar-ome-poi,
jar-formats-api,
Expand Down
26 changes: 26 additions & 0 deletions components/formats-bsd/src/loci/formats/codec/BitBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ public int getBits(int bitsToRead) {
return toStore;
}

/**
* Checks if the current position is on a byte boundary, that is the next
* bit in the byte array is the first bit in a byte.
*
* @return true if bit is on byte boundary, false otherwise.
*/
public boolean isBitOnByteBoundary() {
return currentBit % 8 == 0 ? true : false;
}

/**
* Testing method.
* @param args Ignored.
Expand Down Expand Up @@ -239,6 +249,7 @@ public static void main(String[] args) {
bb.skipBits(len[i]);
}
}

// Test reading past end of buffer.
LOGGER.info("Testing end of buffer");
bb = new BitBuffer(bw.toByteArray());
Expand All @@ -248,5 +259,20 @@ public static void main(String[] args) {
if (-1 != read) {
LOGGER.info("-1 expected at end of buffer, {} received.", read);
}

// Test byte boundary detection
LOGGER.info("Testing byte boundary detection");
bb = new BitBuffer(bw.toByteArray());
for (int i = 0; i < trials; i++) {
int c = r.nextInt(100);
if (c > 50) {
if (len[i] > 8) {
bb.getBits(8);
if (!bb.isBitOnByteBoundary()){
LOGGER.info("Bit on byte boundary expected, but not returned.");
}
}
}
}
}
}

0 comments on commit d97fd41

Please sign in to comment.