diff --git a/.gitignore b/.gitignore index a542e37a8..4dc1238a2 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,5 @@ hs_err_pid*.log /libsrc/uploader/build/ /libsrc/uploader/dist/ /jpexs_website.properties -/tools.properties \ No newline at end of file +/tools.properties +/nbproject/private/ \ No newline at end of file diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index 6d16ca520..812608953 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -946,9 +946,9 @@ public class SWFInputStream implements AutoCloseable { sb.append(" len="); sb.append(Helper.formatInt(tag.getOriginalDataLength(), 8)); sb.append(" "); - sb.append(Helper.bytesToHexString(64, tag.getData(), 0)); + sb.append(Helper.bytesToHexString(64, tag.getOriginalData(), 0)); out.println(sb.toString()); -// out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0)); + // out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0)); if (tag.hasSubTags()) { for (Tag subTag : tag.getSubTags()) { dumpTag(out, version, subTag, level + 1); @@ -1430,7 +1430,7 @@ public class SWFInputStream implements AutoCloseable { int tagIDTagLength = readUI16("tagIDTagLength"); int tagID = (tagIDTagLength) >> 6; - logger.log(Level.INFO, "Reading tag. ID={0}, position: {1}", new Object[]{tagID, pos}); + logger.log(Level.FINE, "Reading tag. ID={0}, position: {1}", new Object[]{tagID, pos}); long tagLength = (tagIDTagLength & 0x003F); boolean readLong = false; @@ -1466,7 +1466,7 @@ public class SWFInputStream implements AutoCloseable { } if (Configuration.debugMode.get()) { - byte[] data = ret.getOriginalData().getRangeData(); + byte[] data = ret.getOriginalData(); byte[] dataNew = ret.getData(); int ignoreFirst = 0; for (int i = 0; i < data.length; i++) { @@ -1886,7 +1886,7 @@ public class SWFInputStream implements AutoCloseable { */ public CLIPACTIONRECORD readCLIPACTIONRECORD(SWF swf, Tag tag, String name) throws IOException { newDumpLevel(name, "CLIPACTIONRECORD"); - CLIPACTIONRECORD ret = new CLIPACTIONRECORD(swf, this, getPos(), tag); + CLIPACTIONRECORD ret = new CLIPACTIONRECORD(swf, this, tag); endDumpLevel(); if (ret.eventFlags.isClear()) { return null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 2fbe0f600..b478193ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -619,8 +619,10 @@ public class Configuration { static { setConfigurationFields(); - if (useDetailedLogging.get() || debugMode.get()) { - logLevel = Level.CONFIG; + if (useDetailedLogging.get()) { + logLevel = Level.FINEST; + } else if (debugMode.get()) { + logLevel = Level.INFO; } else { logLevel = Level.WARNING; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index 4a996791e..acb9e3a0e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -133,7 +133,7 @@ public class DefineButton2Tag extends ButtonTag implements Container { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - ByteArrayInputStream bais = new ByteArrayInputStream(getOriginalData().getRangeData()); + ByteArrayInputStream bais = new ByteArrayInputStream(getOriginalData()); os = new CopyOutputStream(os, bais); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 419d1593f..3c869a804 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -102,7 +102,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { super(swf, ID, "DefineButton", null); buttonId = swf.getNextCharacterId(); characters = new ArrayList<>(); - actionBytes = new ByteArrayRange(new byte[] {0}); + actionBytes = ByteArrayRange.EMPTY; } /** @@ -119,7 +119,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { int pos = (int) sis.getPos(); byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes"); if (data != null) { - actionBytes = new ByteArrayRange(data.array, pos, bytes.length); + actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length); } else { actionBytes = new ByteArrayRange(bytes, 0, bytes.length); } @@ -135,7 +135,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); try { @@ -186,12 +186,12 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { @Override public ActionList getActions() throws InterruptedException { try { - int prevLength = actionBytes.pos; - SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + int prevLength = actionBytes.getPos(); + SWFInputStream rri = new SWFInputStream(swf, actionBytes.getArray()); if (prevLength != 0) { rri.seek(prevLength); } - ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { throw ex; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 45aba523d..7e4c22801 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -200,7 +200,7 @@ public class DefineFont3Tag extends FontTag { OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, getVersion()); if (Configuration.debugCopy.get()) { - sos = new SWFOutputStream(new CopyOutputStream(sos, new ByteArrayInputStream(getOriginalData().getRangeData())), getVersion()); + sos = new SWFOutputStream(new CopyOutputStream(sos, new ByteArrayInputStream(getOriginalData())), getVersion()); } try { List offsetTable = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index d127b96bf..cb734e730 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -233,7 +233,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); try { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index fc99e7e92..22a7a2f73 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -112,7 +112,7 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag { ByteArrayOutputStream bos = new ByteArrayOutputStream(); OutputStream os = bos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) { sos.writeUI32(flags); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index cc8e632b4..7309ed887 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -88,7 +88,7 @@ public class DoABCTag extends Tag implements ABCContainerTag { ByteArrayOutputStream bos = new ByteArrayOutputStream(); OutputStream os = bos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) { abc.saveToStream(sos); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 4a9d47f3d..3608a8e2d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -67,7 +67,7 @@ public class DoActionTag extends Tag implements ASMSource { super(sis.getSwf(), ID, "DoAction", data); int pos = (int) sis.getPos(); byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes"); - actionBytes = new ByteArrayRange(data.array, pos, bytes.length); + actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length); } /** @@ -78,7 +78,7 @@ public class DoActionTag extends Tag implements ASMSource { */ public DoActionTag(SWF swf, ByteArrayRange data) { super(swf, ID, "DoAction", data); - actionBytes = new ByteArrayRange(); + actionBytes = ByteArrayRange.EMPTY; } /** @@ -131,12 +131,12 @@ public class DoActionTag extends Tag implements ASMSource { @Override public ActionList getActions() throws InterruptedException { try { - int prevLength = actionBytes.pos; - SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + int prevLength = actionBytes.getPos(); + SWFInputStream rri = new SWFInputStream(swf, actionBytes.getArray()); if (prevLength != 0) { rri.seek(prevLength); } - ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { throw ex; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 282bb859f..0b1844419 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -74,7 +74,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { spriteId = sis.readUI16("spriteId"); int pos = (int) sis.getPos(); byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes"); - actionBytes = new ByteArrayRange(data.array, pos, bytes.length); + actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length); } /** @@ -127,12 +127,12 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { @Override public ActionList getActions() throws InterruptedException { try { - int prevLength = actionBytes.pos; - SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + int prevLength = actionBytes.getPos(); + SWFInputStream rri = new SWFInputStream(swf, actionBytes.getArray()); if (prevLength != 0) { rri.seek(prevLength); } - ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { throw ex; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index e5abc7a98..4ce680208 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -151,7 +151,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); try { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index 5f2cb8338..eda405650 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -227,7 +227,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); try { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index cfc284f48..43bc9651d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -229,7 +229,7 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; if (Configuration.debugCopy.get()) { - os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData().getRangeData())); + os = new CopyOutputStream(os, new ByteArrayInputStream(getOriginalData())); } SWFOutputStream sos = new SWFOutputStream(os, getVersion()); try { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index cc4f27de6..318f32192 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -332,7 +332,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, sos.write(newHeaderData); sos.write(newData); } else { - sos.write(originalRange.array, originalRange.pos, originalRange.length); + sos.write(originalRange.getArray(), originalRange.getPos(), originalRange.getLength()); } } @@ -357,14 +357,22 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, return originalRange; } - public final ByteArrayRange getOriginalData() { + /** + * Returns the original inner data of the tag, without the 2-6 bytes length header + * Call this method only from debug codes + * @return The data + */ + public final byte[] getOriginalData() { if (originalRange == null) { - return new ByteArrayRange(); + return null; } int dataLength = getOriginalDataLength(); - int pos = (int) (originalRange.pos + originalRange.length - dataLength); - return new ByteArrayRange(originalRange.array, pos, dataLength); + int pos = (int) (originalRange.getPos() + originalRange.getLength() - dataLength); + + byte[] data = new byte[dataLength]; + System.arraycopy(originalRange.getArray(), pos, data, 0, dataLength); + return data; } public final int getOriginalDataLength() { @@ -372,11 +380,11 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, return 0; } - return originalRange.length - (isLongOriginal() ? 6 : 2); + return originalRange.getLength() - (isLongOriginal() ? 6 : 2); } private boolean isLongOriginal() { - int shortLength = originalRange.array[(int) originalRange.pos] & 0x003F; + int shortLength = originalRange.getArray()[(int) originalRange.getPos()] & 0x003F; return shortLength == 0x3f; } @@ -389,11 +397,11 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, } public long getPos() { - return originalRange.pos; + return originalRange.getPos(); } public long getDataPos() { - return originalRange.pos + (isLongOriginal() ? 6 : 2); + return originalRange.getPos() + (isLongOriginal() ? 6 : 2); } public void setModified(boolean value) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagStub.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagStub.java index 7a45c1da3..cd6ddc5e8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagStub.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/TagStub.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; @@ -49,7 +50,7 @@ public class TagStub extends Tag { */ @Override public byte[] getData() { - return getOriginalData().getRangeData(); + throw new Error("TagStub.getData call is not supported."); } public SWFInputStream getDataStream() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index dc9806ca4..be3cdcf68 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -192,12 +192,12 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S @Override public ActionList getActions() throws InterruptedException { try { - int prevLength = actionBytes.pos; - SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + int prevLength = actionBytes.getPos(); + SWFInputStream rri = new SWFInputStream(swf, actionBytes.getArray()); if (prevLength != 0) { rri.seek(prevLength); } - ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index a3109d17a..a0011aed3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -93,18 +93,16 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S private final SWF swf; @Internal private final Tag tag; - @Internal - private long pos; //Constructor for Generic tag editor. TODO:Handle this somehow better public CLIPACTIONRECORD() { swf = null; tag = null; eventFlags = new CLIPEVENTFLAGS(); - actionBytes = new ByteArrayRange(new byte[0]); + actionBytes = ByteArrayRange.EMPTY; } - public CLIPACTIONRECORD(SWF swf, SWFInputStream sis, long pos, Tag tag) throws IOException { + public CLIPACTIONRECORD(SWF swf, SWFInputStream sis, Tag tag) throws IOException { this.swf = swf; this.tag = tag; eventFlags = sis.readCLIPEVENTFLAGS("eventFlags"); @@ -119,7 +117,6 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S int actionBytesPos = (int) sis.getPos(); byte[] bytes = sis.readBytesEx(actionRecordSize, "actionBytes"); actionBytes = new ByteArrayRange(swf.uncompressedData, actionBytesPos, bytes.length); - this.pos = pos; } @Override @@ -197,12 +194,12 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S @Override public ActionList getActions() throws InterruptedException { try { - int prevLength = actionBytes.pos; - SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + int prevLength = actionBytes.getPos(); + SWFInputStream rri = new SWFInputStream(swf, actionBytes.getArray()); if (prevLength != 0) { rri.seek(prevLength); } - ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { throw ex; diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/ByteArrayRange.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/ByteArrayRange.java index dd9a9c9d0..ff108e560 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/ByteArrayRange.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/ByteArrayRange.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.helpers; /** @@ -21,13 +22,11 @@ package com.jpexs.helpers; */ public class ByteArrayRange { - public final byte[] array; - public final int pos; - public final int length; - - public ByteArrayRange() { - this(new byte[0]); - } + public static final ByteArrayRange EMPTY = new ByteArrayRange(new byte[0]); + + private final byte[] array; + private final int pos; + private final int length; public ByteArrayRange(byte[] array) { this.array = array; @@ -41,6 +40,18 @@ public class ByteArrayRange { this.length = length; } + public byte[] getArray() { + return array; + } + + public int getPos() { + return pos; + } + + public int getLength() { + return length; + } + public byte[] getRangeData() { byte[] data = new byte[length]; System.arraycopy(array, pos, data, 0, length);