Skip to content

Commit

Permalink
Fixed drc file used Kd-tree cannot be decoded
Browse files Browse the repository at this point in the history
Use exception to represent decoding status and use return value for decoded value.
  • Loading branch information
lexchou-aspose committed Dec 31, 2024
1 parent 4acff6f commit 9fca660
Show file tree
Hide file tree
Showing 95 changed files with 1,250 additions and 2,215 deletions.
66 changes: 37 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>dev.fileformat</groupId>
<artifactId>drako</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<name>drako</name>
<description>FileFormat.Drako for Java allows you to encode and decode Google Draco files with Java, Kotlin, Scala.</description>
<url>https://products.fileformat.dev/drako/java/</url>
Expand Down Expand Up @@ -41,33 +41,33 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
Expand Down Expand Up @@ -95,6 +95,8 @@
<version>2.9.1</version>
<configuration>
<source>8</source>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -151,11 +153,17 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
2 changes: 1 addition & 1 deletion src/compression/dev/fileformat/drako/HoleEventData.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void copyFrom(HoleEventData src)
this.symbolId = src.symbolId;
}

static final long serialVersionUID = -1530940656L;
static final long serialVersionUID = 1860329541L;
@Override
public int hashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ public int getParentAttributeType(int i)
}

@Override
public boolean setParentAttribute(PointAttribute att)
public void setParentAttribute(PointAttribute att)
throws DrakoException
{
if (att.getAttributeType() != AttributeType.POSITION)
return DracoUtils.failed();
throw DracoUtils.failed();
// Invalid attribute type.
if (att.getComponentsCount() != 3)
return DracoUtils.failed();
throw DracoUtils.failed();
// Currently works only for 3 component positions.
predictor_.pos_attribute_ = att;
return true;
}

public boolean getInitialized()
{

if (!predictor_.isInitialized())
return DracoUtils.failed();
return false;
//if (!meshData.Initialized)
// return DracoUtils.Failed();
if (!octahedron_tool_box_.isInitialized())
return DracoUtils.failed();
return false;
return true;
}

@Override
public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
public void computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
{
final int[] ref0 = new int[1];
final int[] ref1 = new int[1];
Expand Down Expand Up @@ -88,32 +88,25 @@ public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size,


flip_normal_bit_decoder_.endDecoding();
return true;
}

@Override
public boolean decodePredictionData(DecoderBuffer buffer)
public void decodePredictionData(DecoderBuffer buffer)
throws DrakoException
{
final byte[] ref2 = new byte[1];
if (!this.transform_.decodeTransformData(buffer))
return DracoUtils.failed();
this.transform_.decodeTransformData(buffer);

if (buffer.getBitstreamVersion() < 22)
{
byte prediction_mode;
buffer.decode3(ref2);
prediction_mode = ref2[0];
byte prediction_mode = buffer.decodeU8();

if (!predictor_.setNormalPredictionMode(prediction_mode))
return DracoUtils.failed();
throw DracoUtils.failed();
}


// Init normal flips.
if (!flip_normal_bit_decoder_.startDecoding(buffer))
return DracoUtils.failed();

return true;
flip_normal_bit_decoder_.startDecoding(buffer);
}

public int getPredictionMethod()
Expand All @@ -123,12 +116,12 @@ public int getPredictionMethod()

private RAnsBitEncoder flip_normal_bit_encoder_;
@Override
public boolean computeCorrectionValues(IntSpan in_data, IntSpan out_corr, int size, int num_components, int[] entry_to_point_id_map)
public void computeCorrectionValues(IntSpan in_data, IntSpan out_corr, int size, int num_components, int[] entry_to_point_id_map)
{
final int[] ref2 = new int[1];
final int[] ref3 = new int[1];
final int[] ref4 = new int[1];
final int[] ref5 = new int[1];
final int[] ref6 = new int[1];

octahedron_tool_box_.setQuantizationBits(((PredictionSchemeNormalOctahedronTransformBase)this.transform_).getQuantizationBits());
predictor_.entry_to_point_id_map_ = entry_to_point_id_map;
Expand All @@ -149,17 +142,17 @@ public boolean computeCorrectionValues(IntSpan in_data, IntSpan out_corr, int si
octahedron_tool_box_.canonicalizeIntegerVector(pred_normal_3d);
int s;
int t;
octahedron_tool_box_.integerVectorToQuantizedOctahedralCoords(pred_normal_3d, ref3, ref4);
s = ref3[0];
t = ref4[0];
octahedron_tool_box_.integerVectorToQuantizedOctahedralCoords(pred_normal_3d, ref2, ref3);
s = ref2[0];
t = ref3[0];
pos_pred_normal_oct.put(0, s);
pos_pred_normal_oct.put(1, t);
pred_normal_3d[0] = -pred_normal_3d[0];
pred_normal_3d[1] = -pred_normal_3d[1];
pred_normal_3d[2] = -pred_normal_3d[2];
octahedron_tool_box_.integerVectorToQuantizedOctahedralCoords(pred_normal_3d, ref5, ref6);
s = ref5[0];
t = ref6[0];
octahedron_tool_box_.integerVectorToQuantizedOctahedralCoords(pred_normal_3d, ref4, ref5);
s = ref4[0];
t = ref5[0];
neg_pred_normal_oct.put(0, s);
neg_pred_normal_oct.put(1, t);
int data_offset = data_id * 2;
Expand All @@ -185,20 +178,16 @@ public boolean computeCorrectionValues(IntSpan in_data, IntSpan out_corr, int si

}


return true;
}

@Override
public boolean encodePredictionData(EncoderBuffer buffer)
public void encodePredictionData(EncoderBuffer buffer)
{

if (!this.transform_.encodeTransformData(buffer))
return false;
this.transform_.encodeTransformData(buffer);

// Encode normal flips.
flip_normal_bit_encoder_.endEncoding(buffer);
return true;
}

private void $initFields$()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public int getPredictionMethod()
}

@Override
public boolean computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size, int numComponents, int[] entryToPointIdMap)
public void computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size, int numComponents, int[] entryToPointIdMap)
{
final int[] ref0 = new int[1];
final int[] ref1 = new int[1];
Expand Down Expand Up @@ -104,11 +104,10 @@ public boolean computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size
}

this.transform_.computeCorrection(inData, predVals, outCorr, 0);
return true;
}

@Override
public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
public void computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
{
this.transform_.initializeDecoding(numComponents);
IntSpan predVals = IntSpan.wrap(new int[numComponents]);
Expand Down Expand Up @@ -169,7 +168,6 @@ public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size,

}

return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public int getPredictionMethod()
}

@Override
public boolean computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size, int numComponents, int[] entryToPointIdMap)
public void computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size, int numComponents, int[] entryToPointIdMap)
{
this.transform_.initializeEncoding(inData, numComponents);
IntSpan predVals = IntSpan.wrap(new int[numComponents]);
Expand Down Expand Up @@ -94,11 +94,10 @@ public boolean computeCorrectionValues(IntSpan inData, IntSpan outCorr, int size
}

this.transform_.computeCorrection(inData, predVals, outCorr, 0);
return true;
}

@Override
public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
public void computeOriginalValues(IntSpan inCorr, IntSpan outData, int size, int numComponents, int[] entryToPointIdMap)
{
this.transform_.initializeDecoding(numComponents);
ICornerTable table = this.meshData.getCornerTable();
Expand All @@ -125,7 +124,6 @@ public boolean computeOriginalValues(IntSpan inCorr, IntSpan outData, int size,

}

return true;
}

// Computes parallelogram prediction for a given corner and data entry id.
Expand Down
Loading

0 comments on commit 9fca660

Please sign in to comment.