Skip to content

Commit

Permalink
Fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
palemieux committed Jun 21, 2024
1 parent eac5f5d commit 322dcb1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,12 @@ private static boolean isValidHT(CompositionImageEssenceDescriptorModel imageDes
return false;
}

if (p.cod.scod != 0b01000000) {
/* COD missing */
/* no scod constraints? */

/* code-block style */

if (p.cod.cbStyle != 0b01000000) {
/* bad code-block style */
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ static public class COD {
short numDecompLevels;
short cbWidth;
short cbHeight;
short cbStyle;
short transformation;
short precinctSize[];
}
Expand Down Expand Up @@ -519,6 +520,10 @@ private J2KHeaderParameters parseJ2KParameters() {

if (pcap != null) {

params.cap = new J2KHeaderParameters.CAP();

params.cap.pcap = pcap;

DOMNodeObjectModel ccapiNode = capNode.getDOMNode("Ccapi");

if (ccapiNode != null) {
Expand Down Expand Up @@ -547,12 +552,19 @@ private J2KHeaderParameters parseJ2KParameters() {
/* COD */
String codString = j2kNode.getFieldAsString("CodingStyleDefault");

if (codString != null && codString.length() >= 18) {
if (codString != null && codString.length() >= 20) {

params.cod = new J2KHeaderParameters.COD();

params.cod.scod = (short) Integer.parseInt(codString.substring(0, 2), 16);
params.cod.progressionOrder = (short) Integer.parseInt(codString.substring(2, 6), 16);
params.cod.progressionOrder = (short) Integer.parseInt(codString.substring(2, 4), 16);
params.cod.numLayers = (int) Integer.parseInt(codString.substring(4, 8), 16);
params.cod.multiComponentTransform = (short) Integer.parseInt(codString.substring(8, 10), 16);
params.cod.numDecompLevels = (short) Integer.parseInt(codString.substring(10, 12), 16);
params.cod.cbWidth = (short) Integer.parseInt(codString.substring(12, 14), 16);
params.cod.cbHeight = (short) Integer.parseInt(codString.substring(14, 16), 16);
params.cod.cbStyle = (short) Integer.parseInt(codString.substring(16, 18), 16);
params.cod.transformation = (short) Integer.parseInt(codString.substring(18, 20), 16);

} else {
/* missing COD */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ public List<Integer> getFieldsAsInteger(String name) {

Node child = this.getNode().getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName() == name)
values.add(Integer.getInteger(child.getTextContent()));
if (child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName().equals(name))
values.add(Integer.parseInt(child.getTextContent()));

child = child.getNextSibling();
}
Expand Down

0 comments on commit 322dcb1

Please sign in to comment.