Recompile test fixed for as2 and as3.swf

This commit is contained in:
honfika@gmail.com
2014-10-04 14:55:31 +02:00
parent 00ad74ee74
commit 4fa91fab3e
4 changed files with 68 additions and 12 deletions

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;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA;
@@ -398,6 +400,11 @@ public class SWFOutputStream extends OutputStream {
nBits = enlargeBitCountS(nBits, xMax);
nBits = enlargeBitCountS(nBits, yMin);
nBits = enlargeBitCountS(nBits, yMax);
if (Configuration.debugCopy.get()) {
nBits = Math.max(nBits, value.nbits);
}
writeUB(5, nBits);
writeSB(nBits, xMin);
writeSB(nBits, xMax);
@@ -454,7 +461,7 @@ public class SWFOutputStream extends OutputStream {
* @param v Signed value
* @return Number of bits
*/
*/
private static int getNeededBitsS(int v) {
int counter = 32;
int mask = 0x80000000;
final int val = (v < 0) ? -v : v;
@@ -525,6 +532,9 @@ public class SWFOutputStream extends OutputStream {
}
public static int enlargeBitCountS(int currentBitCount, int value) {
if (value == 0) {
return currentBitCount;
}
int neededNew = getNeededBitsS(value);
if (neededNew > currentBitCount) {
return neededNew;
@@ -533,6 +543,9 @@ public class SWFOutputStream extends OutputStream {
}
public static int enlargeBitCountU(int currentBitCount, int value) {
if (value == 0) {
return currentBitCount;
}
int neededNew = getNeededBitsU(value);
if (neededNew > currentBitCount) {
return neededNew;
@@ -552,6 +565,11 @@ public class SWFOutputStream extends OutputStream {
int nBits = 0;
nBits = enlargeBitCountS(nBits, value.scaleX);
nBits = enlargeBitCountS(nBits, value.scaleY);
if (Configuration.debugCopy.get()) {
nBits = Math.max(nBits, value.nScaleBits);
}
writeUB(5, nBits);
writeSB(nBits, value.scaleX);
writeSB(nBits, value.scaleY);
@@ -561,6 +579,11 @@ public class SWFOutputStream extends OutputStream {
int nBits = 0;
nBits = enlargeBitCountS(nBits, value.rotateSkew0);
nBits = enlargeBitCountS(nBits, value.rotateSkew1);
if (Configuration.debugCopy.get()) {
nBits = Math.max(nBits, value.nRotateBits);
}
writeUB(5, nBits);
writeSB(nBits, value.rotateSkew0);
writeSB(nBits, value.rotateSkew1);
@@ -569,6 +592,10 @@ public class SWFOutputStream extends OutputStream {
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX);
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY);
if (Configuration.debugCopy.get()) {
NTranslateBits = Math.max(NTranslateBits, value.nTranslateBits);
}
writeUB(5, NTranslateBits);
writeSB(NTranslateBits, value.translateX);
@@ -597,6 +624,11 @@ public class SWFOutputStream extends OutputStream {
Nbits = enlargeBitCountS(Nbits, value.greenAddTerm);
Nbits = enlargeBitCountS(Nbits, value.blueAddTerm);
}
if (Configuration.debugCopy.get()) {
Nbits = Math.max(Nbits, value.nbits);
}
writeUB(4, Nbits);
if (value.hasMultTerms) {
writeSB(Nbits, value.redMultTerm);
@@ -633,6 +665,11 @@ public class SWFOutputStream extends OutputStream {
Nbits = enlargeBitCountS(Nbits, value.blueAddTerm);
Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm);
}
if (Configuration.debugCopy.get()) {
Nbits = Math.max(Nbits, value.nbits);
}
writeUB(4, Nbits);
if (value.hasMultTerms) {
writeSB(Nbits, value.redMultTerm);

View File

@@ -19,6 +19,7 @@ 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.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -60,6 +61,8 @@ public class DefineText2Tag extends TextTag {
@SWFType(BasicType.UI16)
public int characterID;
private final int glyphBits;
private final int advanceBits;
public RECT textBounds;
public MATRIX textMatrix;
public List<TEXTRECORD> textRecords;
@@ -452,6 +455,12 @@ public class DefineText2Tag extends TextTag {
advanceBits = SWFOutputStream.enlargeBitCountS(advanceBits, ge.glyphAdvance);
}
}
if (Configuration.debugCopy.get()) {
glyphBits = Math.max(glyphBits, this.glyphBits);
advanceBits = Math.max(advanceBits, this.advanceBits);
}
sos.writeUI8(glyphBits);
sos.writeUI8(advanceBits);
for (TEXTRECORD tr : textRecords) {
@@ -476,8 +485,8 @@ public class DefineText2Tag extends TextTag {
characterID = sis.readUI16("characterID");
textBounds = sis.readRECT("textBounds");
textMatrix = sis.readMatrix("textMatrix");
int glyphBits = sis.readUI8("glyphBits");
int advanceBits = sis.readUI8("advanceBits");
glyphBits = sis.readUI8("glyphBits");
advanceBits = sis.readUI8("advanceBits");
textRecords = new ArrayList<>();
TEXTRECORD tr;
while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits, "record")) != null) {

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.AppResources;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -61,6 +62,8 @@ public class DefineTextTag extends TextTag {
@SWFType(BasicType.UI16)
public int characterID;
private final int glyphBits;
private final int advanceBits;
public RECT textBounds;
public MATRIX textMatrix;
public List<TEXTRECORD> textRecords;
@@ -437,6 +440,8 @@ public class DefineTextTag extends TextTag {
this.textBounds = textBounds;
this.textMatrix = textMatrix;
this.textRecords = textRecords;
this.glyphBits = 0;
this.advanceBits = 0;
}
/**
@@ -463,6 +468,11 @@ public class DefineTextTag extends TextTag {
}
}
if (Configuration.debugCopy.get()) {
glyphBits = Math.max(glyphBits, this.glyphBits);
advanceBits = Math.max(advanceBits, this.advanceBits);
}
sos.writeUI8(glyphBits);
sos.writeUI8(advanceBits);
for (TEXTRECORD tr : textRecords) {
@@ -487,8 +497,8 @@ public class DefineTextTag extends TextTag {
characterID = sis.readUI16("characterID");
textBounds = sis.readRECT("textBounds");
textMatrix = sis.readMatrix("textMatrix");
int glyphBits = sis.readUI8("glyphBits");
int advanceBits = sis.readUI8("advanceBits");
glyphBits = sis.readUI8("glyphBits");
advanceBits = sis.readUI8("advanceBits");
textRecords = new ArrayList<>();
TEXTRECORD tr;
while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits, "record")) != null) {