add new tags to sprites

This commit is contained in:
honfika@gmail.com
2014-11-06 11:49:12 +01:00
parent 7baee5eeb0
commit ea6568d71d
21 changed files with 437 additions and 76 deletions

View File

@@ -201,7 +201,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound;
import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap;
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag;
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo;
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA;
@@ -1365,7 +1365,7 @@ public class SWFInputStream implements AutoCloseable {
if (swf.gfx) { //GFX tags only in GFX files. There may be incorrect GFX tags in non GFX files
switch (tag.getId()) {
case 1000:
ret = new ExporterInfoTag(sis, data);
ret = new ExporterInfo(sis, data);
break;
case 1001:
ret = new DefineExternalImage(sis, data);

View File

@@ -28,6 +28,7 @@ import java.util.logging.Logger;
public class AVM2ConstantPool {
private static final Logger logger = Logger.getLogger(AVM2ConstantPool.class.getName());
public List<Long> constant_int = new ArrayList<>();
public List<Long> constant_uint = new ArrayList<>();
public List<Double> constant_double = new ArrayList<>();
@@ -122,7 +123,7 @@ public class AVM2ConstantPool {
try {
return constant_int.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return 0;
}
@@ -131,7 +132,7 @@ public class AVM2ConstantPool {
try {
return constant_namespace.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return null;
}
@@ -140,7 +141,7 @@ public class AVM2ConstantPool {
try {
return constant_namespace_set.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return null;
}
@@ -149,7 +150,7 @@ public class AVM2ConstantPool {
try {
return constant_multiname.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return null;
}
@@ -158,7 +159,7 @@ public class AVM2ConstantPool {
try {
return constant_uint.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return 0;
}
@@ -167,7 +168,7 @@ public class AVM2ConstantPool {
try {
return constant_double.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return 0;
}
@@ -176,7 +177,7 @@ public class AVM2ConstantPool {
try {
return constant_decimal.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return null;
}
@@ -185,7 +186,7 @@ public class AVM2ConstantPool {
try {
return constant_string.get(index);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex);
}
return null;
}

View File

@@ -713,7 +713,7 @@ public class Action implements GraphSourceItem {
} catch (InterruptedException ex) {
throw ex;
} catch (Exception | OutOfMemoryError | StackOverflowError ex) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex);
logger.log(Level.SEVERE, "Decompilation error in: " + path, ex);
convertException = ex;
Throwable cause = ex.getCause();
if (ex instanceof ExecutionException && cause instanceof Exception) {
@@ -728,10 +728,10 @@ public class Action implements GraphSourceItem {
if (convertException == null) {
Graph.graphToString(tree, writer, new LocalData());
} else if (convertException instanceof TimeoutException) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, convertException);
logger.log(Level.SEVERE, "Decompilation error in: " + path, convertException);
Helper.appendTimeoutComment(writer, timeout);
} else {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, convertException);
logger.log(Level.SEVERE, "Decompilation error in: " + path, convertException);
Helper.appendErrorComment(writer, convertException);
}
if (asm != null) {
@@ -871,7 +871,7 @@ public class Action implements GraphSourceItem {
try {
out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
} catch (OutOfMemoryError | TranslateException | StackOverflowError ex2) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex2);
logger.log(Level.SEVERE, "Decompilation error in: " + path, ex2);
if (ex2 instanceof OutOfMemoryError) {
Helper.freeMem();
}
@@ -1004,7 +1004,7 @@ public class Action implements GraphSourceItem {
try {
action.translate(localData, stack, output, staticOperation, path);
} catch (EmptyStackException ese) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ese);
logger.log(Level.SEVERE, "Decompilation error in: " + path, ese);
output.add(new UnsupportedActionItem(action, "Empty stack"));
}

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.helpers.ByteArrayRange;
@@ -36,6 +38,15 @@ public class FrameLabelTag extends Tag {
return namedAnchor;
}
/**
* Constructor
* @param swf
*/
public FrameLabelTag(SWF swf) {
super(swf, ID, "FrameLabel", null);
name = "New frame label";
}
public FrameLabelTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "FrameLabel", data);
name = sis.readString("name");

View File

@@ -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;
@@ -191,6 +192,14 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public PlaceObject2Tag(SWF swf) {
super(swf, ID, "PlaceObject2", null);
}
public PlaceObject2Tag(SWF swf, boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
super(swf, ID, "PlaceObject2", null);
this.placeFlagHasClipActions = placeFlagHasClipActions;

View File

@@ -12,10 +12,12 @@
* 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.EndOfStreamException;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
@@ -295,6 +297,14 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public PlaceObject3Tag(SWF swf) {
super(swf, ID, "PlaceObject3", null);
}
/**
* Constructor
*

View File

@@ -12,10 +12,12 @@
* 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.EndOfStreamException;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
@@ -297,6 +299,14 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public PlaceObject4Tag(SWF swf) {
super(swf, ID, "PlaceObject4", null);
}
/**
* Constructor
*

View File

@@ -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;
@@ -97,6 +98,15 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public PlaceObjectTag(SWF swf) {
super(swf, ID, "PlaceObject", null);
matrix = new MATRIX();
}
/**
* Constructor
*

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
@@ -31,6 +33,14 @@ public class RemoveObject2Tag extends Tag implements RemoveTag {
public int depth;
public static final int ID = 28;
/**
* Constructor
* @param swf
*/
public RemoveObject2Tag(SWF swf) {
super(swf, ID, "RemoveObject2", null);
}
public RemoveObject2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "RemoveObject2", data);
depth = sis.readUI16("depth");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
@@ -64,6 +66,15 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public RemoveObjectTag(SWF swf) {
super(swf, ID, "RemoveObject", null);
characterId = swf.getNextCharacterId();
}
/**
* Constructor
*

View File

@@ -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;
@@ -57,6 +58,10 @@ public class ShowFrameTag extends Tag {
super(swf, ID, "ShowFrame", data);
}
/**
* Constructor
* @param swf
*/
public ShowFrameTag(SWF swf) {
super(swf, ID, "ShowFrame", null);
}

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.Internal;
@@ -35,6 +37,15 @@ public class SoundStreamBlockTag extends Tag {
@Internal
public byte[] streamSoundData;
/**
* Constructor
* @param swf
*/
public SoundStreamBlockTag(SWF swf) {
super(swf, ID, "SoundStreamBlock", null);
streamSoundData = new byte[0];
}
/**
* Constructor
*

View File

@@ -181,12 +181,12 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
return streamSoundType;
}
public static void populateSoundStreamBlocks(int containerId, List<? extends ContainerItem> tags, Tag head, List<SoundStreamBlockTag> output) {
public static void populateSoundStreamBlocks(int containerId, List<? extends ContainerItem> tags, SoundStreamHeadTypeTag head, List<SoundStreamBlockTag> output) {
boolean found = false;
for (ContainerItem t : tags) {
if (t == head) {
found = true;
((SoundStreamHeadTypeTag) head).setVirtualCharacterId(containerId);
head.setVirtualCharacterId(containerId);
continue;
}
if (t instanceof Container) {

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
@@ -44,13 +46,25 @@ public class StartSound2Tag extends Tag {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
/*try {
//sos.write
} catch (IOException e) {
try {
sos.writeString(soundClassName);
sos.writeSOUNDINFO(soundInfo);
} catch (IOException e) {
throw new Error("This should never happen.", e);
}
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public StartSound2Tag(SWF swf) {
super(swf, ID, "StartSound2", null);
soundClassName = "NewSoundClass";
soundInfo = new SOUNDINFO();
}
/**
* Constructor
*

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -56,6 +58,15 @@ public class StartSoundTag extends Tag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public StartSoundTag(SWF swf) {
super(swf, ID, "StartSound", null);
soundInfo = new SOUNDINFO();
}
/**
* Constructor
*

View File

@@ -29,7 +29,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound;
import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap;
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag;
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo;
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.types.annotations.Internal;
@@ -216,7 +216,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem,
DefineExternalStreamSound.ID,
DefineGradientMap.ID,
DefineSubImage.ID,
ExporterInfoTag.ID,
ExporterInfo.ID,
FontTextureInfo.ID);
knownTagIds = tagIds;
}

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -58,6 +60,15 @@ public class VideoFrameTag extends Tag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public VideoFrameTag(SWF swf) {
super(swf, ID, "VideoFrame", null);
videoData = new byte[0];
}
/**
* Constructor
*

View File

@@ -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.gfx;
import com.jpexs.decompiler.flash.SWFInputStream;
@@ -30,7 +31,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class ExporterInfoTag extends Tag {
public class ExporterInfo extends Tag {
public static final int ID = 1000;
//Version (1.10 will be encoded as 0x10A)
@@ -87,7 +88,7 @@ public class ExporterInfoTag extends Tag {
* @param data
* @throws IOException
*/
public ExporterInfoTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
public ExporterInfo(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "ExporterInfo", data);
this.version = sis.readUI16("version");
if (this.version >= 0x10a) {

View File

@@ -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;
import com.jpexs.helpers.streams.SeekableInputStream;
@@ -40,7 +41,7 @@ public class MemoryInputStream extends SeekableInputStream {
public MemoryInputStream(byte[] buffer, int startPos, int maxLength) throws IOException {
this.buffer = buffer;
this.startPos = startPos;
this.startPos = startPos;
if (startPos > buffer.length) {
throw new IOException("Invalid startPos");
}
this.maxLength = maxLength;