From cb92f191a75c0a1383c91d07046074a0548abb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Mon, 10 Mar 2014 22:40:50 +0100 Subject: [PATCH] Improved export dialog (show only usable options, refactored) Nelly moser decoding, MP3 decoding WAV export for all soundtypes PNG only, JPEG only export modes for images --- trunk/lib/nellymoser.jar | Bin 0 -> 24836 bytes trunk/libsrc/nellymoser/build.xml | 73 + .../nellymoser/nbproject/build-impl.xml | 1407 +++++++++++++++++ .../nellymoser/nbproject/genfiles.properties | 8 + .../nellymoser/nbproject/project.properties | 71 + trunk/libsrc/nellymoser/nbproject/project.xml | 15 + .../src/lt/dkd/nellymoser/CodecImpl.java | 1017 ++++++++++++ trunk/nbproject/project.xml | 2 +- trunk/src/com/jpexs/decompiler/flash/SWF.java | 245 ++- .../decompiler/flash/abc/ScriptPack.java | 10 +- .../decompiler/flash/abc/avm2/AVM2Code.java | 14 +- .../abc/avm2/model/NewFunctionAVM2Item.java | 6 +- .../flash/abc/types/MethodBody.java | 10 +- .../flash/abc/types/traits/Trait.java | 14 +- .../flash/abc/types/traits/TraitClass.java | 10 +- .../flash/abc/types/traits/TraitFunction.java | 10 +- .../types/traits/TraitMethodGetterSetter.java | 10 +- .../abc/types/traits/TraitSlotConst.java | 6 +- .../flash/abc/types/traits/Traits.java | 10 +- .../abc/usages/ConstVarMultinameUsage.java | 14 +- .../abc/usages/MethodMultinameUsage.java | 14 +- .../jpexs/decompiler/flash/action/Action.java | 14 +- .../flash/action/ActionListReader.java | 4 +- .../flash/action/swf3/ActionWaitForFrame.java | 4 +- .../flash/action/swf4/ActionIf.java | 4 +- .../flash/action/swf4/ActionJump.java | 4 +- .../flash/action/swf4/ActionPush.java | 6 +- .../action/swf4/ActionWaitForFrame2.java | 4 +- .../action/swf5/ActionDefineFunction.java | 6 +- .../flash/action/swf5/ActionWith.java | 4 +- .../action/swf7/ActionDefineFunction2.java | 6 +- .../flash/action/swf7/ActionTry.java | 4 +- .../flash/configuration/Configuration.java | 4 + .../console/CommandLineArgumentParser.java | 48 +- .../exporters/modes/BinaryDataExportMode.java | 26 + .../exporters/modes/ImageExportMode.java | 26 + .../exporters/modes/MovieExportMode.java | 26 + .../exporters/modes/ScriptExportMode.java | 26 + .../exporters/modes/ShapeExportMode.java | 26 + .../exporters/modes/SoundExportMode.java | 46 + .../flash/exporters/modes/TextExportMode.java | 27 + .../decompiler/flash/gui/ExportDialog.java | 148 +- .../decompiler/flash/gui/ImagePanel.java | 41 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 205 ++- .../decompiler/flash/gui/PlayerListener.java | 2 +- .../decompiler/flash/gui/SoundTagPlayer.java | 288 ++-- .../flash/gui/abc/ASMSourceEditorPane.java | 14 +- .../flash/gui/abc/DecompiledEditorPane.java | 4 +- .../flash/gui/abc/MethodCodePanel.java | 14 +- .../flash/gui/abc/TraitsListItem.java | 10 +- .../flash/gui/action/ActionPanel.java | 16 +- .../flash/gui/locales/ExportDialog.properties | 21 +- .../gui/locales/ExportDialog_cs.properties | 14 +- .../gui/locales/ExportDialog_de.properties | 10 +- .../gui/locales/ExportDialog_es.properties | 14 +- .../gui/locales/ExportDialog_fr.properties | 14 +- .../gui/locales/ExportDialog_hu.properties | 14 +- .../gui/locales/ExportDialog_nl.properties | 14 +- .../gui/locales/ExportDialog_pt.properties | 10 +- .../gui/locales/ExportDialog_ru.properties | 14 +- .../gui/locales/ExportDialog_sv.properties | 14 +- .../gui/locales/ExportDialog_uk.properties | 14 +- .../gui/locales/ExportDialog_zh.properties | 10 +- .../flash/tags/DefineButtonTag.java | 4 +- .../decompiler/flash/tags/DefineSoundTag.java | 45 +- .../decompiler/flash/tags/DoActionTag.java | 4 +- .../flash/tags/DoInitActionTag.java | 4 +- .../flash/tags/SoundStreamHead2Tag.java | 24 +- .../flash/tags/SoundStreamHeadTag.java | 27 +- .../decompiler/flash/tags/base/ASMSource.java | 4 +- .../decompiler/flash/tags/base/SoundTag.java | 16 +- .../decompiler/flash/timeline/Timeline.java | 10 +- .../decompiler/flash/treenodes/TagNode.java | 10 +- .../flash/types/BUTTONCONDACTION.java | 4 +- .../flash/types/CLIPACTIONRECORD.java | 4 +- .../flash/types/sound/AdpcmDecoder.java | 19 +- .../flash/types/sound/MP3Decoder.java | 110 ++ .../flash/types/sound/NellyMoserDecoder.java | 64 + .../flash/types/sound/NoDecoder.java | 43 + .../flash/types/sound/SoundDecoder.java | 44 + .../flash/types/sound/SoundFormat.java | 214 +++ .../decompiler/flash/xfl/XFLConverter.java | 69 +- .../jpexs/decompiler/graph/ExportMode.java | 53 - .../com/jpexs/helpers/sound/SoundPlayer.java | 4 +- .../com/jpexs/helpers/sound/WavPlayer.java | 2 +- 85 files changed, 4175 insertions(+), 789 deletions(-) create mode 100644 trunk/lib/nellymoser.jar create mode 100644 trunk/libsrc/nellymoser/build.xml create mode 100644 trunk/libsrc/nellymoser/nbproject/build-impl.xml create mode 100644 trunk/libsrc/nellymoser/nbproject/genfiles.properties create mode 100644 trunk/libsrc/nellymoser/nbproject/project.properties create mode 100644 trunk/libsrc/nellymoser/nbproject/project.xml create mode 100644 trunk/libsrc/nellymoser/src/lt/dkd/nellymoser/CodecImpl.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/BinaryDataExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/ImageExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/MovieExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/ShapeExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/exporters/modes/TextExportMode.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/types/sound/SoundDecoder.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java delete mode 100644 trunk/src/com/jpexs/decompiler/graph/ExportMode.java diff --git a/trunk/lib/nellymoser.jar b/trunk/lib/nellymoser.jar new file mode 100644 index 0000000000000000000000000000000000000000..4c6973884df2085dc2a4b2b1de463e533879f544 GIT binary patch literal 24836 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�-AJ8Hq<&0c-3VX0 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 literal 0 HcmV?d00001 diff --git a/trunk/libsrc/nellymoser/build.xml b/trunk/libsrc/nellymoser/build.xml new file mode 100644 index 000000000..f6b35ff31 --- /dev/null +++ b/trunk/libsrc/nellymoser/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project nellymoser. + + + diff --git a/trunk/libsrc/nellymoser/nbproject/build-impl.xml b/trunk/libsrc/nellymoser/nbproject/build-impl.xml new file mode 100644 index 000000000..87a75aec3 --- /dev/null +++ b/trunk/libsrc/nellymoser/nbproject/build-impl.xml @@ -0,0 +1,1407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/libsrc/nellymoser/nbproject/genfiles.properties b/trunk/libsrc/nellymoser/nbproject/genfiles.properties new file mode 100644 index 000000000..85533b776 --- /dev/null +++ b/trunk/libsrc/nellymoser/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=413e5dbf +build.xml.script.CRC32=02c6606f +build.xml.stylesheet.CRC32=8064a381@1.68.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=413e5dbf +nbproject/build-impl.xml.script.CRC32=03e6ec15 +nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46 diff --git a/trunk/libsrc/nellymoser/nbproject/project.properties b/trunk/libsrc/nellymoser/nbproject/project.properties new file mode 100644 index 000000000..8cf85cb82 --- /dev/null +++ b/trunk/libsrc/nellymoser/nbproject/project.properties @@ -0,0 +1,71 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/nellymoser.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/trunk/libsrc/nellymoser/nbproject/project.xml b/trunk/libsrc/nellymoser/nbproject/project.xml new file mode 100644 index 000000000..a9e9de8d2 --- /dev/null +++ b/trunk/libsrc/nellymoser/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + nellymoser + + + + + + + + + diff --git a/trunk/libsrc/nellymoser/src/lt/dkd/nellymoser/CodecImpl.java b/trunk/libsrc/nellymoser/src/lt/dkd/nellymoser/CodecImpl.java new file mode 100644 index 000000000..62c235219 --- /dev/null +++ b/trunk/libsrc/nellymoser/src/lt/dkd/nellymoser/CodecImpl.java @@ -0,0 +1,1017 @@ +/* + * NellyMoser ASAO codec + * Copyright (C) 2007-2008 UAB "DKD" + * Copyright (C) 2007-2008 Joseph Artsimovich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package lt.dkd.nellymoser; + +public class CodecImpl { + + private static class BitStream { + + private int byteOffset = 0; + private int bitOffset = 0; + + public void push(int val, int len, byte[] buf) { + + if (bitOffset == 0) { + buf[byteOffset] = (byte)val; + } else { + buf[byteOffset] |= (byte)(val << bitOffset); + } + bitOffset += len; + if (bitOffset >= 8) { + ++byteOffset; + bitOffset -= 8; + if (bitOffset > 0) { + buf[byteOffset] = (byte)(val >> (len - bitOffset)); + } + } + } + + public int pop(int len, byte[] buf) { + + int val = ((int)buf[byteOffset] & 0xff) >> bitOffset; + final int bits_read = 8 - bitOffset; + + if (len >= bits_read) { + ++byteOffset; + if (len > bits_read) { + val |= buf[byteOffset] << bits_read; + } + } + + bitOffset = (bitOffset + len) & 7; + return val & ((1 << len) - 1); + } + } + + private static class NormalizedInt32 { + + public final int value; + public final int scale; + + public NormalizedInt32(final int val) { + if (val == 0) { + value = val; + scale = 31; + return; + } else if (val >= (1 << 30)) { + value = 0; + scale = 0; + return; + } + + int v = val; + int s = 0; + + if (v > 0) { + do { + v <<= 1; + ++s; + } while (v < (1 << 30)); + } else { + final int floor = 1 << 31; // lowest possible 32bit value + do { + v <<= 1; + ++s; + } while (v > floor + (1 << 30)); + } + + value = v; + scale = s; + } + } + + private static class Factor { + + public final int value; + public final int shift; + + public Factor(final int val) { + if (val == 124) { + // Common case optimization. + value = 4228; + shift = 19; + return; + } else if (val == 0) { + value = 0; + shift = 0; + return; + } + + final int sign = ((~val >>> 31) << 1) - 1; + + int abs = val * sign; + + int scale = -1; + while ((abs & (1 << 15)) == 0) { + abs <<= 1; + ++scale; + } + abs >>= 1; + + shift = 27 - scale; + + final int table_val = table9[(abs - 0x3e00) >> 10]; + int tmp = abs * table_val; + tmp = (1 << 30) - tmp; + tmp += (1 << 14); + tmp >>= 15; + tmp *= table_val; + tmp += (1 << 14); + tmp >>= 15; + final int tmp2 = tmp; + tmp *= abs; + tmp = (1 << 29) - tmp; + tmp += (1 << 14); + tmp >>= 15; + tmp *= tmp2; + tmp += (1 << 13); + tmp >>= 14; + tmp *= sign; + + if (tmp > 32767 && sign == 1) { + tmp = 32767; + } else if (tmp < -32768 && sign == -1) { + tmp = -32768; + } + + value = tmp; + } + } + + public static void encode(float[] state, float[] in, byte[] out) { + + float var_8d8[] = new float[256]; + float var_2e8[] = new float[23]; + float var_268[] = new float[23]; + float var_4d8[] = new float[124]; + float var_208[] = new float[124]; + + final BitStream bs = new BitStream(); + + fTransfm(state, in, 0, 7, var_8d8, 0); + fTransfm(state, in, 128, 7, var_8d8, 128); + + for (int i = 0; i < 23; ++i) { + int bound = bandBound[i]; + final int next_bound = bandBound[i + 1]; + double acc = 0.0; + for (; bound < next_bound; ++bound) { + final double a = var_8d8[bound]; + final double b = var_8d8[bound + 128]; + acc += a*a + b*b; + } + final double tmp = Math.max(1.0, acc / (table0[i] << 1)); + var_2e8[i] = Math.round(Math.log(tmp) * (1.44269502 * 1024.0)); + }; + + int idx = findClosest(var_2e8[0], table1, 0, 64); + var_268[0] = table1[idx]; + bs.push(idx, gainBit[0], out); + for (int i = 1; i < 23; ++i) { + idx = findClosest(var_2e8[i] - var_268[i - 1], table2, 0, 32); + var_268[i] = var_268[i - 1] + table2[idx]; + bs.push(idx, gainBit[i], out); + } + + for (int i = 0; i < 23; ++i) { + var_2e8[i] = (float)(1.0 / Math.pow(2.0, var_268[i] * (0.5 * 0.0009765625))); + } + + for (int i = 0; i < 23; ++i) { + int bound = bandBound[i]; + final int next_bound = bandBound[i + 1]; + for (; bound < next_bound; ++bound) { + var_4d8[bound] = var_268[i]; + var_208[bound] = var_2e8[i]; + } + } + + int packed_byte_sizes[] = new int[124]; + final int leftover = wc(var_4d8, 124, 198, packed_byte_sizes); + for (int off = 0; off < 256; off += 128) { + for (int i = 0; i < 124; ++i) { + final int packedSize = packed_byte_sizes[i]; + if (packedSize > 0) { + final int pow2 = 1 << packedSize; + idx = findClosestOrdered( + var_208[i] * var_8d8[off + i], + table3, pow2 - 1, (pow2 << 1) - 1 + ); + bs.push(idx, packedSize, out); + } + } + for (int i = leftover; i > 0; i -= 8) { + if (i > 8) { + bs.push(0, 8, out); + } else { + bs.push(0, i, out); + break; + } + } + } + } + + public static void decode(float[] state, byte[] in, float[] out) { + + byte[] unpacked_input = new byte[124]; + float[] var_808 = new float[128]; + float[] var_608 = new float[124]; + float[] var_418 = new float[124]; + + BitStream bs = new BitStream(); + + int unpacked_byte = bs.pop(gainBit[0], in); + unpacked_input[0] = (byte)unpacked_byte; + var_808[0] = table1[unpacked_byte]; + + for (int i = 1; i < 23; ++i) { + unpacked_byte = bs.pop(gainBit[i], in); + unpacked_input[i] = (byte)unpacked_byte; + var_808[i] = var_808[i - 1] + table2[unpacked_byte]; + }; + + for (int i = 0; i < 23; ++i) { + final float pow = (float)Math.pow( + 2.0, var_808[i] * (0.5 * 0.0009765625) + ); + + int bound = bandBound[i]; + final int next_bound = bandBound[i + 1]; + for (; bound < next_bound; ++bound) { + var_418[bound] = var_808[i]; + var_608[bound] = pow; + } + } + + int packed_byte_sizes[] = new int[124]; + final int leftover = wc(var_418, 124, 198, packed_byte_sizes); + + for (int out_off = 0; out_off < 256; out_off += 128) { + for (int i = 0; i < 124; ++i) { + final int packed_size = packed_byte_sizes[i]; + float val = var_608[i]; + if (packed_size > 0) { + final int pow2 = 1 << packed_size; + unpacked_byte = bs.pop(packed_size, in); + unpacked_input[i] = (byte)unpacked_byte; + val *= table3[pow2 - 1 + unpacked_byte]; + } else { + final double rnd_u32 = Math.random() * 4294967296.0; + if (rnd_u32 < (1<<30) + (1<<14)) { + val *= -0.707099974; + } else { + val *= 0.707099974; + } + } + var_808[i] = val; + } + + for (int i = 124; i < 128; ++i) { + var_808[i] = 0; + } + + for (int i = leftover; i > 0; i -= 8) { + if (i > 8) { + bs.pop(8, in); + } else { + bs.pop(i, in); + break; + } + } + + iTransfm(state, var_808, 7, out, out_off); + } + } + + private static void iTransfm(float[] state, float[] in, + int len_log2, float[] out, int out_off) { + + final int len = 1 << len_log2; + final int quarter_len = len >> 2; + int y = len - 1; + int x = len >> 1; + int j = x - 1; + int i = 0; + + /* + i--> <--j + ---------------------------- + x--> <--y + + i, j, x, y are indexes into table7. + table7 is defined as follows: + for (int i = 0; i < 128; ++i) { + table7[i] = Math.sin((i + 0.5) / 128 * (Math.PI / 2)); + } + */ + + auxceps(in, 0, len_log2, out, out_off); + + for (; i < quarter_len; ++i, --j, ++x, --y) { + final double state_i = state[i]; + final double state_j = state[j]; + final double out_x = out[out_off + x]; + final double out_y = out[out_off + y]; + + state[i] = -out[out_off + j]; + state[j] = -out[out_off + i]; + + out[out_off + i] = (float)(state_i * table7[y] + out_x * table7[i]); + out[out_off + j] = (float)(state_j * table7[x] + out_y * table7[j]); + + out[out_off + x] = (float)(table7[x] * -out_y + table7[j] * state_j); + out[out_off + y] = (float)(table7[y] * -out_x + table7[i] * state_i); + } + } + + private static void fTransfm(float[] state, float[] in, int in_off, + int len_log2, float[] out, int out_off) { + + final int len = 1 << len_log2; + final int quarter_len = len >> 2; + int y = len - 1; + int x = len >> 1; + int j = x - 1; + int i = 0; + + /* + i--> <--j + ---------------------------- + x--> <--y + + i, j, x, y are indexes into table7. + table7 is defined as follows: + for (int i = 0; i < 128; ++i) { + table7[i] = Math.sin((i + 0.5) / 128 * (Math.PI / 2)); + } + */ + + for (; i < quarter_len; ++i, ++x, --y, --j) { + out[out_off + x] = state[i]; + out[out_off + y] = state[j]; + + out[out_off + i] = -in[in_off + j] * table7[x] - in[in_off + x] * table7[j]; + out[out_off + j] = -in[in_off + y] * table7[i] - in[in_off + i] * table7[y]; + + state[i] = in[in_off + i] * table7[i] - in[in_off + y] * table7[y]; + state[j] = in[in_off + j] * table7[j] - in[in_off + x] * table7[x]; + } + + auxceps(out, out_off, len_log2, out, out_off); + } + + private static void auxceps( + float[] in, final int in_off, int len_log2, float[] out, final int out_off) { + + final int len = 1 << len_log2; + final int half_len_m1 = (len >> 1) - 1; + final int quarter_len = len >> 2; + + for (int i = 0; i < quarter_len; ++i) { + final int i2 = i << 1; + final int j = len - 1 - i2; + final int k = j - 1; + + final double in_i2 = in[in_off + i2]; + final double in_i2_1 = in[in_off + i2 + 1]; + final double in_j = in[in_off + j]; + final double in_k = in[in_off + k]; + + out[out_off + i2] = (float)(table4[i] * in_i2 - table6[i] * in_j); + out[out_off + i2 + 1] = (float)(in_j * table4[i] + in_i2 * table6[i]); + + out[out_off + k] = (float)(table4[half_len_m1 - i] * in_k - table6[half_len_m1 - i] * in_i2_1); + out[out_off + j] = (float)(in_i2_1 * table4[half_len_m1 - i] + in_k * table6[half_len_m1 - i]); + } + + HarXfm(out, out_off, len_log2 - 1); + + final float last_out = out[out_off + len - 1]; + final float pre_last_out = out[out_off + len - 2]; + + out[out_off] = table5[0] * out[out_off]; + out[out_off + len - 1] = out[out_off + 1] * -table5[0]; + + out[out_off + len - 2] = table5[half_len_m1] * out[out_off + len - 2] + table5[1] * last_out; + out[out_off + 1] = pre_last_out * table5[1] - last_out * table5[half_len_m1]; + + int i_out = len - 3; + int i_tbl = half_len_m1; + int j = 3; + for (int i = 1; i < quarter_len; ++i, --i_tbl, i_out -= 2, j += 2) { + final double old_out_a = out[out_off + i_out]; + final double old_out_b = out[out_off + i_out - 1]; + final double old_out_c = out[out_off + j]; + final double old_out_d = out[out_off + j - 1]; + + out[out_off + j - 1] = (float)(table5[i_tbl] * old_out_c + table5[(j - 1) >> 1] * old_out_d); + out[out_off + j] = (float)(old_out_b * table5[(j + 1) >> 1] - old_out_a * table5[i_tbl - 1]); + out[out_off + i_out] = (float)(old_out_d * table5[i_tbl] - old_out_c * table5[(j - 1) >> 1]); + out[out_off + i_out - 1] = (float)(table5[(j + 1) >> 1] * old_out_a + table5[i_tbl - 1] * old_out_b); + } + } + + private static void HarXfm(float[] data, int data_off, int half_len_log2) { + + final int half_len = 1 << half_len_log2; + + HarXfmHelper(data, data_off, half_len); + + int j = 0; + for (int i = half_len >> 1; i > 0; --i, j += 4) { + final float j0 = data[data_off + j]; + final float j1 = data[data_off + j + 1]; + final float j2 = data[data_off + j + 2]; + final float j3 = data[data_off + j + 3]; + data[data_off + j] = j0 + j2; + data[data_off + j + 1] = j1 + j3; + data[data_off + j + 2] = j0 - j2; + data[data_off + j + 3] = j1 - j3; + } + + j = 0; + for (int i = half_len >> 2; i > 0; --i, j += 8) { + final float j0 = data[data_off + j]; + final float j1 = data[data_off + j + 1]; + final float j2 = data[data_off + j + 2]; + final float j3 = data[data_off + j + 3]; + final float j4 = data[data_off + j + 4]; + final float j5 = data[data_off + j + 5]; + final float j6 = data[data_off + j + 6]; + final float j7 = data[data_off + j + 7]; + data[data_off + j] = j0 + j4; + data[data_off + j + 1] = j1 + j5; + data[data_off + j + 2] = j2 + j7; + data[data_off + j + 3] = j3 - j6; + data[data_off + j + 4] = j0 - j4; + data[data_off + j + 5] = j1 - j5; + data[data_off + j + 6] = j2 - j7; + data[data_off + j + 7] = j3 + j6; + } + + int i = 0; + int x = half_len >> 3; + int y = 64; + int z = 4; + for (int idx1 = half_len_log2 - 2; idx1 > 0; --idx1, z <<= 1, y >>= 1, x >>= 1) { + j = 0; + for (int idx2 = x; idx2 != 0; --idx2, j += z << 1) { + for (int idx3 = z >> 1; idx3 > 0; --idx3, j += 2, i += y) { + final int k = j + (z << 1); + + final double j0 = data[data_off + j]; + final double j1 = data[data_off + j + 1]; + final double k0 = data[data_off + k]; + final double k1 = data[data_off + k + 1]; + + data[data_off + k] = (float)(j0 - (k0 * table10[128 - i] + k1 * table10[i])); + data[data_off + j] = (float)(j0 + (k0 * table10[128 - i] + k1 * table10[i])); + data[data_off + k + 1] = (float)(j1 + (k0 * table10[i] - k1 * table10[128 - i])); + data[data_off + j + 1] = (float)(j1 - (k0 * table10[i] - k1 * table10[128 - i])); + } + for (int idx4 = z >> 1; idx4 > 0; --idx4, j += 2, i -= y) { + final int k = j + (z << 1); + + final double j0 = data[data_off + j]; + final double j1 = data[data_off + j + 1]; + final double k0 = data[data_off + k]; + final double k1 = data[data_off + k + 1]; + + data[data_off + k] = (float)(j0 + (k0 * table10[128 - i] - k1 * table10[i])); + data[data_off + j] = (float)(j0 - (k0 * table10[128 - i] - k1 * table10[i])); + data[data_off + k + 1] = (float)(j1 + (k1 * table10[128 - i] + k0 * table10[i])); + data[data_off + j + 1] = (float)(j1 - (k1 * table10[128 - i] + k0 * table10[i])); + } + } + } + } + + private static void HarXfmHelper(float[] data, int data_off, int half_len) { + + final int len = half_len << 1; + + int j = 1; + for (int i = 1; i < len; i += 2) { + if (i < j) { + final float tmp1 = data[data_off + i]; + data[data_off + i] = data[data_off + j]; + data[data_off + j] = tmp1; + + final float tmp2 = data[data_off + i - 1]; + data[data_off + i - 1] = data[data_off + j - 1]; + data[data_off + j - 1] = tmp2; + } + + int x = half_len; + while (x > 1 && x < j) { + j -= x; + x >>= 1; + } + j += x; + } + } + + private static int findClosest(float target, float[] values, int from, int to) { + + int min_idx = 0; + float min_distance = Math.abs(target - values[from]); + + for (int i = from; i < to; ++i) { + final float distance = Math.abs(target - values[i]); + if (distance < min_distance) { + min_distance = distance; + min_idx = i - from; + } + } + + return min_idx; + } + + private static int findClosestOrdered(float target, float[] values, int from, int to) { + + int begin = from; + int end = to; + do { + final int middle = (begin + end) >> 1; + if (target > values[middle]) { + begin = middle; + } else { + end = middle; + } + } while (end - begin > 1); + + if (end != to) { + if (target - values[begin] > values[end] - target) { + begin = end; + } + } + return begin - from; + } + + static int wc(float[] in, int len, int total_bits, int[] packed_sizes) { + + float max_input = 0; + for (int i = 0; i < len; ++i) { + if (in[i] > max_input) { + max_input = in[i]; + } + } + + int max_input_scale = 0; + { + NormalizedInt32 normalized = new NormalizedInt32((int)max_input); + max_input_scale = normalized.scale - 16; + } + + short scaled_input[] = new short[124]; + + if (max_input_scale < 0) { + for (int i = 0; i < len; ++i) { + scaled_input[i] = (short)((int)in[i] >> -max_input_scale); + } + } else { + for (int i = 0; i < len; ++i) { + scaled_input[i] = (short)((int)in[i] << max_input_scale); + } + } + + final Factor factor = new Factor(len); + + for (int i = 0; i < len; ++i) { + scaled_input[i] = (short)(((int)scaled_input[i] * 3) >> 2); // *= 0.75 + } + + int scaled_input_sum = 0; + for (int i = 0; i < len; ++i) { + scaled_input_sum += scaled_input[i]; + } + + max_input_scale += 11; + scaled_input_sum -= total_bits << max_input_scale; + int scaled_input_base = 0; + { + final int val = scaled_input_sum - (total_bits << max_input_scale); + final NormalizedInt32 normalized = new NormalizedInt32(val); + scaled_input_base = ((val >> 16) * factor.value) >> 15; + + final int shift = 31 - factor.shift - normalized.scale; + if (shift >= 0) { + scaled_input_base <<= shift; + } else { + scaled_input_base >>= -shift; + } + } + + int bits_used = getD(scaled_input, max_input_scale, len, 6, scaled_input_base); + if (bits_used != total_bits) { + int diff = bits_used - total_bits; + int diff_scale = 0; + if (diff <= 0) { + for (; diff >= -16384; diff <<= 1) { + ++diff_scale; + } + } else { + for (; diff < 16384; diff <<= 1) { + ++diff_scale; + } + } + + int base_delta = (diff * factor.value) >> 15; + diff_scale = max_input_scale - (factor.shift + diff_scale - 15); + if (diff_scale >= 0) { + base_delta <<= diff_scale; + } else { + base_delta >>= -diff_scale; + } + + int num_revisions = 1; + int last_bits_used; + int last_scaled_input_base; + for (;;) { + last_bits_used = bits_used; + last_scaled_input_base = scaled_input_base; + scaled_input_base += base_delta; + bits_used = getD(scaled_input, max_input_scale, len, 6, scaled_input_base); + if (++num_revisions > 19) { + break; + } + if ((bits_used - total_bits) * (last_bits_used - total_bits) <= 0) { + break; + } + + } + + if (bits_used != total_bits) { + int scaled_input_base_1; + int bits_used_1; + int bits_used_2; + if (bits_used > total_bits) { + scaled_input_base_1 = scaled_input_base; + scaled_input_base = last_scaled_input_base; + bits_used_1 = bits_used; + bits_used_2 = last_bits_used; + } else { + scaled_input_base_1 = last_scaled_input_base; + bits_used_1 = last_bits_used; + bits_used_2 = bits_used; + } + + while (bits_used != total_bits && num_revisions < 20) { + final int avg = (scaled_input_base + scaled_input_base_1) >> 1; + bits_used = getD(scaled_input, max_input_scale, len, 6, avg); + ++num_revisions; + if (bits_used > total_bits) { + scaled_input_base_1 = avg; + bits_used_1 = bits_used; + } else { + scaled_input_base = avg; + bits_used_2 = bits_used; + } + } + + final int dev_1 = Math.abs((int)bits_used_1 - total_bits); + final int dev_2 = Math.abs((int)bits_used_2 - total_bits); + + if (dev_1 < dev_2) { + scaled_input_base = scaled_input_base_1; + bits_used = bits_used_1; + } else { + bits_used = bits_used_2; + } + } + } + + for (int i = 0; i < len; ++i) { + int tmp = (int)scaled_input[i] - scaled_input_base; + if (tmp >= 0) { + tmp = (tmp + (1 << (max_input_scale - 1))) >> max_input_scale; + } else { + tmp = 0; + } + packed_sizes[i] = Math.min(tmp, 6); + } + + if (bits_used > total_bits) { + int i = 0; + int bit_count = 0; + for (; bit_count < total_bits; ++i) { + bit_count += packed_sizes[i]; + } + + bit_count -= packed_sizes[i - 1]; + packed_sizes[i - 1] = total_bits - bit_count; + bits_used = total_bits; + for (; i < len; ++i) { + packed_sizes[i] = 0; + } + } + + return total_bits - bits_used; + } + + private static int getD(short[] in, int scale, int len, int upper_bound, int base) { + int d = 0; + if (len <= 0) { + return d; + } + + final int var_1 = 1 << (scale - 1); + + for (int i = 0; i < len; ++i) { + int var_2 = (int)in[i] - base; + if (var_2 < 0) { + var_2 = 0; + } else { + var_2 = (var_2 + var_1) >> scale; + } + d += Math.min(var_2, upper_bound); + } + + return d; + } + + private static final int bandBound[] = { + 0, 2, 4, 6, + 8, 10, 12, 14, + 16, 18, 21, 24, + 28, 32, 37, 43, + 49, 56, 64, 73, + 83, 95, 109, 124 + }; + + private static final short gainBit[] = { + 6, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }; + + private static final int table0[] = { + 2, 2, 2, 2, + 2, 2, 2, 2, + 2, 3, 3, 4, + 4, 5, 6, 6, + 7, 8, 9, 10, + 12, 14, 15, 0 + }; + + private static final float table1[] = { + 3134, 5342, 6870, 7792, + 8569, 9185, 9744, 10191, + 10631, 11061, 11434, 11770, + 12116, 12513, 12925, 13300, + 13674, 14027, 14352, 14716, + 15117, 15477, 15824, 16157, + 16513, 16804, 17090, 17401, + 17679, 17948, 18238, 18520, + 18764, 19078, 19381, 19640, + 19921, 20205, 20500, 20813, + 21162, 21465, 21794, 22137, + 22453, 22756, 23067, 23350, + 23636, 23926, 24227, 24521, + 24819, 25107, 25414, 25730, + 26120, 26497, 26895, 27344, + 27877, 28463, 29426, 31355 + }; + + private static final float table2[] = { + -11725, -9420, -7910, -6801, + -5948, -5233, -4599, -4039, + -3507, -3030, -2596, -2170, + -1774, -1383, -1016, -660, + -329, -1, 337, 696, + 1085, 1512, 1962, 2433, + 2968, 3569, 4314, 5279, + 6622, 8154, 10076, 12975 + }; + + private static final float table3[] = { + 0.0f, -0.847256005f, 0.722470999f, -1.52474797f, + -0.453148007f, 0.375360996f, 1.47178996f, -1.98225796f, + -1.19293797f, -0.582937002f, -0.0693780035f, 0.390956998f, + 0.906920016f, 1.486274f, 2.22154093f, -2.38878703f, + -1.80675399f, -1.41054201f, -1.07736099f, -0.799501002f, + -0.555810988f, -0.333402008f, -0.132449001f, 0.0568020009f, + 0.254877001f, 0.477355003f, 0.738685012f, 1.04430604f, + 1.39544594f, 1.80987501f, 2.39187598f, -2.38938308f, + -1.98846805f, -1.75140405f, -1.56431198f, -1.39221299f, + -1.216465f, -1.04694998f, -0.890510023f, -0.764558017f, + -0.645457983f, -0.52592802f, -0.405954987f, -0.302971989f, + -0.209690005f, -0.123986997f, -0.0479229987f, 0.025773f, + 0.100134f, 0.173718005f, 0.258554012f, 0.352290004f, + 0.456988007f, 0.576775014f, 0.700316012f, 0.842552006f, + 1.00938797f, 1.18213499f, 1.35345602f, 1.53208196f, + 1.73326194f, 1.97223496f, 2.39781404f, -2.5756309f, + -2.05733204f, -1.89849198f, -1.77278101f, -1.66626f, + -1.57421803f, -1.49933195f, -1.43166399f, -1.36522806f, + -1.30009902f, -1.22809303f, -1.15885794f, -1.09212506f, + -1.013574f, -0.920284986f, -0.828705013f, -0.737488985f, + -0.644775987f, -0.559094012f, -0.485713989f, -0.411031991f, + -0.345970005f, -0.285115987f, -0.234162003f, -0.187058002f, + -0.144250005f, -0.110716999f, -0.0739680007f, -0.0365610011f, + -0.00732900016f, 0.0203610007f, 0.0479039997f, 0.0751969963f, + 0.0980999991f, 0.122038998f, 0.145899996f, 0.169434994f, + 0.197045997f, 0.225243002f, 0.255686998f, 0.287010014f, + 0.319709986f, 0.352582991f, 0.388906986f, 0.433492005f, + 0.476945996f, 0.520482004f, 0.564453006f, 0.612204015f, + 0.668592989f, 0.734165013f, 0.803215981f, 0.878404021f, + 0.956620991f, 1.03970695f, 1.12937701f, 1.22111595f, + 1.30802798f, 1.40248001f, 1.50568199f, 1.62277305f, + 1.77249599f, 1.94308805f, 2.29039311f, 0.0f + }; + + /** + * Lookup table. + *
+     * for (int i = 0; i < 64; ++i) {
+     *     table4[i] = Math.cos((i + 0.25) / 64 * (Math.PI / 2));
+     * }
+     * 
+ */ + private static final float table4[] = { + 0.999981225f, 0.999529421f, 0.998475611f, 0.996820271f, + 0.994564593f, 0.991709828f, 0.988257587f, 0.984210074f, + 0.979569793f, 0.974339426f, 0.968522072f, 0.962121427f, + 0.955141187f, 0.947585583f, 0.939459205f, 0.930767f, + 0.921513975f, 0.911705971f, 0.901348829f, 0.890448689f, + 0.879012227f, 0.867046177f, 0.854557991f, 0.841554999f, + 0.828045011f, 0.81403631f, 0.799537301f, 0.784556627f, + 0.769103289f, 0.753186822f, 0.736816585f, 0.720002472f, + 0.702754676f, 0.685083687f, 0.666999876f, 0.64851439f, + 0.629638195f, 0.610382795f, 0.590759695f, 0.570780694f, + 0.550458014f, 0.529803574f, 0.50883007f, 0.487550199f, + 0.465976506f, 0.444122106f, 0.422000289f, 0.399624199f, + 0.377007395f, 0.354163498f, 0.331106305f, 0.307849586f, + 0.284407496f, 0.260794103f, 0.237023607f, 0.213110298f, + 0.189068705f, 0.164913103f, 0.1406582f, 0.116318598f, + 0.0919089988f, 0.0674438998f, 0.0429382995f, 0.0184067003f + }; + + /** + * Lookup table. + *
+     * for (int i = 0; i < 64; ++i) {
+     *     table5[i] = Math.cos(i / 64.0 * (Math.PI / 2)) * Math.sqrt(2.0 / 128);
+     * }
+     * 
+ */ + private static final float table5[] = { + 0.125f, 0.124962397f, 0.124849401f, 0.124661297f, + 0.124398097f, 0.124059901f, 0.123647101f, 0.123159699f, + 0.122598201f, 0.121962801f, 0.1212539f, 0.120471999f, + 0.119617499f, 0.118690997f, 0.117693f, 0.116624102f, + 0.115484901f, 0.114276201f, 0.112998702f, 0.111653f, + 0.110240199f, 0.108760901f, 0.107216097f, 0.105606697f, + 0.103933699f, 0.102198102f, 0.100400902f, 0.0985433012f, + 0.0966262966f, 0.094651103f, 0.0926188976f, 0.0905309021f, + 0.0883883014f, 0.0861926004f, 0.0839449018f, 0.0816465989f, + 0.0792991966f, 0.076903902f, 0.0744623989f, 0.0719759986f, + 0.069446303f, 0.0668746978f, 0.0642627999f, 0.0616123006f, + 0.0589246005f, 0.0562013984f, 0.0534444004f, 0.0506552011f, + 0.0478353985f, 0.0449868999f, 0.0421111993f, 0.0392102003f, + 0.0362856016f, 0.0333391018f, 0.0303725004f, 0.0273876991f, + 0.0243862998f, 0.0213702004f, 0.0183412991f, 0.0153013002f, + 0.0122520998f, 0.0091955997f, 0.00613350002f, 0.00306769996f + }; + + /** + * Lookup table. + *
+     * for (int i = 0; i < 64; ++i) {
+     *     table6[i] = -Math.sin((i + 0.25) / 64 * (Math.PI / 2));
+     * }
+     * 
+ */ + private static final float table6[] = { + -0.00613590004f,-0.0306748003f, -0.0551952012f, -0.0796824023f, + -0.104121603f, -0.128498107f, -0.152797207f, -0.177004203f, + -0.201104596f, -0.225083902f, -0.248927593f, -0.272621393f, + -0.296150893f, -0.319501996f, -0.342660695f, -0.365613014f, + -0.388345003f, -0.410843194f, -0.433093786f, -0.455083609f, + -0.47679919f, -0.498227686f, -0.519356012f, -0.540171504f, + -0.560661614f, -0.580814004f, -0.600616515f, -0.620057225f, + -0.639124393f, -0.657806695f, -0.676092684f, -0.693971515f, + -0.711432219f, -0.728464425f, -0.745057821f, -0.761202395f, + -0.77688849f, -0.792106628f, -0.806847572f, -0.8211025f, + -0.834862888f, -0.848120272f, -0.860866904f, -0.873094976f, + -0.884797096f, -0.895966172f, -0.906595707f, -0.916679084f, + -0.926210225f, -0.935183525f, -0.943593502f, -0.95143503f, + -0.958703518f, -0.965394378f, -0.971503913f, -0.977028072f, + -0.981963873f, -0.986308098f, -0.990058184f, -0.993211925f, + -0.995767415f, -0.997723103f, -0.999077678f, -0.999830604f + }; + + /** + * Lookup table. + *
+     * for (int i = 0; i < 128; ++i) {
+     *     table7[i] = Math.sin((i + 0.5) / 128 * (Math.PI / 2));
+     * }
+     * 
+ */ + private static final float table7[] = { + 0.00613590004f, 0.0184067003f, 0.0306748003f, 0.0429382995f, + 0.0551952012f, 0.0674438998f, 0.0796824023f, 0.0919089988f, + 0.104121603f, 0.116318598f, 0.128498107f, 0.1406582f, + 0.152797207f, 0.164913103f, 0.177004203f, 0.189068705f, + 0.201104596f, 0.213110298f, 0.225083902f, 0.237023607f, + 0.248927593f, 0.260794103f, 0.272621393f, 0.284407496f, + 0.296150893f, 0.307849586f, 0.319501996f, 0.331106305f, + 0.342660695f, 0.354163498f, 0.365613014f, 0.377007395f, + 0.388345003f, 0.399624199f, 0.410843194f, 0.422000289f, + 0.433093786f, 0.444122106f, 0.455083609f, 0.465976506f, + 0.47679919f, 0.487550199f, 0.498227686f, 0.50883007f, + 0.519356012f, 0.529803574f, 0.540171504f, 0.550458014f, + 0.560661614f, 0.570780694f, 0.580814004f, 0.590759695f, + 0.600616515f, 0.610382795f, 0.620057225f, 0.629638195f, + 0.639124393f, 0.64851439f, 0.657806695f, 0.666999876f, + 0.676092684f, 0.685083687f, 0.693971515f, 0.702754676f, + 0.711432219f, 0.720002472f, 0.728464425f, 0.736816585f, + 0.745057821f, 0.753186822f, 0.761202395f, 0.769103289f, + 0.77688849f, 0.784556627f, 0.792106628f, 0.799537301f, + 0.806847572f, 0.81403631f, 0.8211025f, 0.828045011f, + 0.834862888f, 0.841554999f, 0.848120272f, 0.854557991f, + 0.860866904f, 0.867046177f, 0.873094976f, 0.879012227f, + 0.884797096f, 0.890448689f, 0.895966172f, 0.901348829f, + 0.906595707f, 0.911705971f, 0.916679084f, 0.921513975f, + 0.926210225f, 0.930767f, 0.935183525f, 0.939459205f, + 0.943593502f, 0.947585583f, 0.95143503f, 0.955141187f, + 0.958703518f, 0.962121427f, 0.965394378f, 0.968522072f, + 0.971503913f, 0.974339426f, 0.977028072f, 0.979569793f, + 0.981963873f, 0.984210074f, 0.986308098f, 0.988257587f, + 0.990058184f, 0.991709828f, 0.993211925f, 0.994564593f, + 0.995767415f, 0.996820271f, 0.997723103f, 0.998475611f, + 0.999077678f, 0.999529421f, 0.999830604f, 0.999981225f + }; + + private static final short table9[] = { + 32767, 30840, 29127, 27594, 26214, 24966, 23831, 22795, + 21845, 20972, 20165, 19418, 18725, 18079, 17476, 16913, + 16384, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + }; + + /** + * Lookup table. + *
+     * for (int i = 0; i <= 128; ++i) {
+     *     table10[i] = Math.sin((i / 128.0) * (Math.PI / 2));
+     * }
+     * 
+ */ + private static final float table10[] = { + 0.0f, 0.0122715384f, 0.024541229f, 0.0368072242f, + 0.0490676723f, 0.061320737f, 0.0735645667f, 0.0857973099f, + 0.0980171412f, 0.110222213f, 0.122410677f, 0.134580716f, + 0.146730468f, 0.158858135f, 0.170961887f, 0.183039889f, + 0.195090324f, 0.207111374f, 0.219101235f, 0.231058106f, + 0.242980182f, 0.254865646f, 0.266712755f, 0.27851969f, + 0.290284693f, 0.302005947f, 0.313681751f, 0.32531029f, + 0.336889863f, 0.348418683f, 0.359895051f, 0.371317178f, + 0.382683426f, 0.393992037f, 0.405241311f, 0.416429549f, + 0.427555084f, 0.438616246f, 0.449611336f, 0.460538715f, + 0.471396744f, 0.482183784f, 0.492898196f, 0.50353837f, + 0.514102757f, 0.524589658f, 0.534997642f, 0.545324981f, + 0.555570245f, 0.565731823f, 0.575808167f, 0.585797846f, + 0.59569931f, 0.605511069f, 0.615231574f, 0.624859512f, + 0.634393275f, 0.643831551f, 0.653172851f, 0.662415802f, + 0.671558976f, 0.680601001f, 0.689540565f, 0.698376238f, + 0.707106769f, 0.715730846f, 0.724247098f, 0.732654274f, + 0.740951121f, 0.749136388f, 0.757208824f, 0.765167296f, + 0.773010433f, 0.780737221f, 0.78834641f, 0.795836926f, + 0.803207517f, 0.81045723f, 0.817584813f, 0.824589312f, + 0.831469595f, 0.838224709f, 0.84485358f, 0.851355195f, + 0.857728601f, 0.863972843f, 0.870086968f, 0.876070082f, + 0.881921232f, 0.887639642f, 0.893224299f, 0.898674488f, + 0.903989315f, 0.909168005f, 0.914209783f, 0.919113874f, + 0.923879504f, 0.928506076f, 0.932992816f, 0.937339008f, + 0.941544056f, 0.945607305f, 0.949528158f, 0.953306019f, + 0.956940353f, 0.960430503f, 0.963776052f, 0.966976464f, + 0.970031261f, 0.972939968f, 0.975702107f, 0.97831738f, + 0.980785251f, 0.983105481f, 0.985277653f, 0.987301409f, + 0.989176512f, 0.990902662f, 0.992479503f, 0.993906975f, + 0.99518472f, 0.996312618f, 0.997290432f, 0.998118103f, + 0.99879545f, 0.999322355f, 0.999698818f, 0.999924719f, + 1.0f + }; +} + + diff --git a/trunk/nbproject/project.xml b/trunk/nbproject/project.xml index 21528e0a9..cec0ec384 100644 --- a/trunk/nbproject/project.xml +++ b/trunk/nbproject/project.xml @@ -156,7 +156,7 @@ src - lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/jsyntaxpane-0.9.5.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;lib/jl1.0.1.jar + lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/jsyntaxpane-0.9.5.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;lib/jl1.0.1.jar;lib/nellymoser.jar build javadoc reports diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 40500fa53..76b8f044b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -54,6 +54,13 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.exporters.ExportRectangle; import com.jpexs.decompiler.flash.exporters.Matrix; +import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; import com.jpexs.decompiler.flash.flv.AUDIODATA; import com.jpexs.decompiler.flash.flv.FLVOutputStream; import com.jpexs.decompiler.flash.flv.FLVTAG; @@ -110,10 +117,9 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.filters.BlendComposite; import com.jpexs.decompiler.flash.types.filters.FILTER; -import com.jpexs.decompiler.flash.types.sound.AdpcmDecoder; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.decompiler.flash.xfl.FLAVersion; import com.jpexs.decompiler.flash.xfl.XFLConverter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; @@ -773,7 +779,7 @@ public final class SWF implements TreeItem, Timelined { return true; } - public boolean exportAS3Class(String className, String outdir, ExportMode exportMode, boolean parallel) throws Exception { + public boolean exportAS3Class(String className, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { List abcTags = new ArrayList<>(); for (Tag t : tags) { @@ -840,7 +846,7 @@ public final class SWF implements TreeItem, Timelined { ScriptPack pack; String directory; List abcList; - ExportMode exportMode; + ScriptExportMode exportMode; ClassPath path; AtomicInteger index; int count; @@ -849,7 +855,7 @@ public final class SWF implements TreeItem, Timelined { long startTime; long stopTime; - public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List abcList, ExportMode exportMode, boolean parallel) { + public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List abcList, ScriptExportMode exportMode, boolean parallel) { this.pack = pack; this.directory = directory; this.abcList = abcList; @@ -885,7 +891,7 @@ public final class SWF implements TreeItem, Timelined { } } - public List exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ExportMode exportMode, boolean parallel, EventListener evl) throws IOException { + public List exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws IOException { List ret = new ArrayList<>(); List list2 = new ArrayList<>(); list2.addAll(tags); @@ -900,7 +906,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public List exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ExportMode exportMode, final boolean parallel) { + public List exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ScriptExportMode exportMode, final boolean parallel) { final AtomicInteger cnt = new AtomicInteger(1); final List abcTags = new ArrayList<>(); for (Tag t : tags) { @@ -962,7 +968,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public List exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ExportMode exportMode, boolean parallel) throws Exception { + public List exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { boolean asV3Found = false; List ret = new ArrayList<>(); final EventListener evl = new EventListener() { @@ -1197,33 +1203,35 @@ public final class SWF implements TreeItem, Timelined { } } - public void exportMovies(AbortRetryIgnoreHandler handler, String outdir) throws IOException { - exportMovies(handler, outdir, tags); + public void exportMovies(AbortRetryIgnoreHandler handler, String outdir, MovieExportMode mode) throws IOException { + exportMovies(handler, outdir, tags, mode); } - public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, boolean mp3, boolean wave) throws IOException { - exportSounds(handler, outdir, tags, mp3, wave); + public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportMode mode) throws IOException { + exportSounds(handler, outdir, tags, mode); } - public byte[] exportSound(Tag t) throws IOException { - boolean mp3 = true; - boolean wave = true; - try (ByteArrayOutputStream fos = new ByteArrayOutputStream()) { - if (t instanceof SoundTag) { - SoundTag st = (SoundTag) t; - if ((st.getSoundFormat() == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN || st.getSoundFormat() == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) && wave) { - //Does endiannes matter here? - createWavFromPcmData(fos, st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()); - } else if ((st.getSoundFormat() == DefineSoundTag.FORMAT_ADPCM) && wave) { - createWavFromAdpcm(fos, st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()); - } else if ((st.getSoundFormat() == DefineSoundTag.FORMAT_MP3) && mp3) { - fos.write(st.getRawSoundData()); - } else if(st instanceof DefineSoundTag) { + public byte[] exportSound(SoundTag t, SoundExportMode mode) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + exportSound(baos, t, mode); + return baos.toByteArray(); + } + + public void exportSound(OutputStream fos, SoundTag t, SoundExportMode mode) throws IOException { + if (t instanceof SoundTag) { + SoundTag st = (SoundTag) t; + SoundFormat fmt = st.getSoundFormat(); + int nativeFormat = fmt.getNativeExportFormat(); + + if (nativeFormat == SoundFormat.EXPORT_MP3 && mode.hasMP3()) { + fos.write(st.getRawSoundData()); + } else if ((nativeFormat == SoundFormat.EXPORT_FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) { + if (st instanceof DefineSoundTag) { FLVOutputStream flv = new FLVOutputStream(fos); flv.writeHeader(true, false); - flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormat(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()))); + flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()))); } else if (st instanceof SoundStreamHeadTypeTag) { - SoundStreamHeadTypeTag sh=(SoundStreamHeadTypeTag)st; + SoundStreamHeadTypeTag sh = (SoundStreamHeadTypeTag) st; FLVOutputStream flv = new FLVOutputStream(fos); flv.writeHeader(true, false); List blocks = sh.getBlocks(); @@ -1231,14 +1239,15 @@ public final class SWF implements TreeItem, Timelined { int ms = (int) (1000.0f / ((float) frameRate)); for (int b = 0; b < blocks.size(); b++) { byte[] data = blocks.get(b).getData(); - if (st.getSoundFormat() == 2) { //MP3 + if (st.getSoundFormatId() == 2) { //MP3 data = Arrays.copyOfRange(data, 4, data.length); } - flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(st.getSoundFormat(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); + flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); } } - } - return fos.toByteArray(); + } else { + fmt.createWav(new ByteArrayInputStream(st.getRawSoundData()), fos); + } } } @@ -1249,14 +1258,14 @@ public final class SWF implements TreeItem, Timelined { } } - private static void createWavFromPcmData(OutputStream fos, int soundRate, boolean soundSize, boolean soundType, byte[] data) throws IOException { + public static void createWavFromPcmData(OutputStream fos, int soundRateHz, boolean soundSize, boolean soundType, byte[] data) throws IOException { ByteArrayOutputStream subChunk1Data = new ByteArrayOutputStream(); int audioFormat = 1; //PCM writeLE(subChunk1Data, audioFormat, 2); int numChannels = soundType ? 2 : 1; writeLE(subChunk1Data, numChannels, 2); int[] rateMap = {5512, 11025, 22050, 44100}; - int sampleRate = rateMap[soundRate]; + int sampleRate = soundRateHz;//rateMap[soundRate]; writeLE(subChunk1Data, sampleRate, 4); int bitsPerSample = soundSize ? 16 : 8; int byteRate = sampleRate * numChannels * bitsPerSample / 8; @@ -1282,11 +1291,14 @@ public final class SWF implements TreeItem, Timelined { fos.write(chunkBytes); } - private static void createWavFromAdpcm(OutputStream fos, int soundRate, boolean soundSize, boolean soundType, byte[] data) throws IOException { - createWavFromPcmData(fos, soundRate, soundSize, soundType, AdpcmDecoder.decode(data, soundType)); - } - - public List exportSounds(AbortRetryIgnoreHandler handler, String outdir, List tags, boolean mp3, boolean wave) throws IOException { + /*private static void createWavFromAdpcm(OutputStream fos, int soundRateHz, boolean soundSize, boolean soundType, byte[] data) throws IOException { + createWavFromPcmData(fos, soundRateHz, soundSize, soundType, AdpcmDecoder.decode(data, soundType)); + } + + private static void createWavFromNelly(OutputStream fos, int soundRateHz,byte[] data) throws IOException { + createWavFromPcmData(fos, soundRateHz, true, false, NellyMoserDecoder.decode(data)); + }*/ + public List exportSounds(AbortRetryIgnoreHandler handler, String outdir, List tags, final SoundExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1305,90 +1317,48 @@ public final class SWF implements TreeItem, Timelined { if (t instanceof DefineSoundTag) { id = ((DefineSoundTag) t).soundId; } - - if(t instanceof SoundTag){ - final SoundTag st=(SoundTag)t; - if (st.getSoundFormat() == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN || st.getSoundFormat() == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { - //Does endiannes matter here? - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".wav"); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - createWavFromPcmData(os, st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()); - } - } - }, handler).run(); - }else if ((st.getSoundFormat() == DefineSoundTag.FORMAT_ADPCM) && wave) { - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".wav"); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - createWavFromAdpcm(os, st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()); - } - } - }, handler).run(); - } else if ((st.getSoundFormat() == DefineSoundTag.FORMAT_MP3) && mp3) { - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".mp3"); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - os.write(st.getRawSoundData()); - } - } - }, handler).run(); - } else if(st instanceof DefineSoundTag){ - final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ".flv"); - newfile = file; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - FileOutputStream fos = new FileOutputStream(file); - try (FLVOutputStream flv = new FLVOutputStream(fos)) { - flv.writeHeader(true, false); - flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormat(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), st.getRawSoundData()))); - } - } - }, handler).run(); - } else if(st instanceof SoundStreamHeadTypeTag){ - final File file = new File(outdir + File.separator + id + ".flv"); - newfile = file; - SoundStreamHeadTypeTag sh=(SoundStreamHeadTypeTag)st; - final List blocks=sh.getBlocks(); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - FLVOutputStream flv = new FLVOutputStream(os); - flv.writeHeader(true, false); - int ms = (int) (1000.0f / ((float) frameRate)); - for (int b = 0; b < blocks.size(); b++) { - byte data[] = blocks.get(b).getData(); - if (st.getSoundFormat() == 2) { //MP3 - data = Arrays.copyOfRange(data, 4, data.length); - } - flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(st.getSoundFormat(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); - } - } + if (t instanceof SoundTag) { + final SoundTag st = (SoundTag) t; + + String ext = "wav"; + SoundFormat fmt = st.getSoundFormat(); + switch (fmt.getNativeExportFormat()) { + case SoundFormat.EXPORT_MP3: + if (mode.hasMP3()) { + ext = "mp3"; } - }, handler).run(); + break; + case SoundFormat.EXPORT_FLV: + if (mode.hasFlv()) { + ext = "flv"; + } + break; } - } - - if (newfile != null) { + if (mode == SoundExportMode.FLV) { + ext = "flv"; + } + + final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + "." + ext); + newfile = file; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { + exportSound(os, st, mode); + } + } + }, handler).run(); + ret.add(newfile); + } + } return ret; } - public byte[] exportMovie(DefineVideoStreamTag videoStream) throws IOException { + public byte[] exportMovie(DefineVideoStreamTag videoStream, MovieExportMode mode) throws IOException { HashMap frames = new HashMap<>(); populateVideoFrames(videoStream.characterID, this.tags, frames); if (frames.isEmpty()) { @@ -1479,7 +1449,7 @@ public final class SWF implements TreeItem, Timelined { return fos.toByteArray(); } - public List exportMovies(AbortRetryIgnoreHandler handler, String outdir, List tags) throws IOException { + public List exportMovies(AbortRetryIgnoreHandler handler, String outdir, List tags, final MovieExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1500,7 +1470,7 @@ public final class SWF implements TreeItem, Timelined { @Override public void run() throws IOException { try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(exportMovie(videoStream)); + fos.write(exportMovie(videoStream, mode)); } } }, handler).run(); @@ -1510,7 +1480,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public List exportTexts(AbortRetryIgnoreHandler handler, String outdir, List tags, final boolean formatted) throws IOException { + public List exportTexts(AbortRetryIgnoreHandler handler, String outdir, List tags, final TextExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1530,7 +1500,7 @@ public final class SWF implements TreeItem, Timelined { @Override public void run() throws IOException { try (FileOutputStream fos = new FileOutputStream(file)) { - if (formatted) { + if (mode == TextExportMode.FORMATTED) { fos.write(Utf8Helper.getBytes(((TextTag) t).getFormattedText())); } else { fos.write(Utf8Helper.getBytes(((TextTag) t).getText())); @@ -1544,11 +1514,11 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, boolean formatted) throws IOException { - exportTexts(handler, outdir, tags, formatted); + public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportMode mode) throws IOException { + exportTexts(handler, outdir, tags, mode); } - public static List exportShapes(AbortRetryIgnoreHandler handler, String outdir, List tags) throws IOException { + public static List exportShapes(AbortRetryIgnoreHandler handler, String outdir, List tags, ShapeExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1583,7 +1553,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public static List exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List tags) throws IOException { + public static List exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, List tags, BinaryDataExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1615,7 +1585,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public List exportImages(AbortRetryIgnoreHandler handler, String outdir, List tags) throws IOException { + public List exportImages(AbortRetryIgnoreHandler handler, String outdir, List tags, final ImageExportMode mode) throws IOException { List ret = new ArrayList<>(); if (tags.isEmpty()) { return ret; @@ -1630,12 +1600,23 @@ public final class SWF implements TreeItem, Timelined { } for (final Tag t : tags) { if (t instanceof ImageTag) { - final File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterId() + "." + ((ImageTag) t).getImageFormat()); + + String fileFormat = ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH); + if (mode == ImageExportMode.PNG) { + fileFormat = "png"; + } + if (mode == ImageExportMode.JPEG) { + fileFormat = "jpg"; + } + + final File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterId() + "." + fileFormat); final List ttags = this.tags; + final String ffileFormat = fileFormat; new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - ImageIO.write(((ImageTag) t).getImage().getBufferedImage(), ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH), file); + + ImageIO.write(((ImageTag) t).getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); } }, handler).run(); ret.add(file); @@ -1644,16 +1625,16 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public void exportImages(AbortRetryIgnoreHandler handler, String outdir) throws IOException { - exportImages(handler, outdir, tags); + public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportMode mode) throws IOException { + exportImages(handler, outdir, tags, mode); } - public void exportShapes(AbortRetryIgnoreHandler handler, String outdir) throws IOException { - exportShapes(handler, outdir, tags); + public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportMode mode) throws IOException { + exportShapes(handler, outdir, tags, mode); } - public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir) throws IOException { - exportBinaryData(handler, outdir, tags); + public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportMode mode) throws IOException { + exportBinaryData(handler, outdir, tags, mode); } private final HashMap deobfuscated = new HashMap<>(); private List> allVariableNames = new ArrayList<>(); @@ -1671,7 +1652,7 @@ public final class SWF implements TreeItem, Timelined { GraphSourceItem ins = code.get(ip); if (debugMode) { - System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList(), new ArrayList(), new ArrayList(), code.version, ExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); + System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList(), new ArrayList(), new ArrayList(), code.version, ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); } if (ins.isExit()) { break; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index e87801973..8b88543bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.treeitems.TreeElementItem; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import java.io.File; @@ -122,7 +122,7 @@ public class ScriptPack implements TreeElementItem { return Helper.joinStrings(pathParts, File.separator); } - public void convert(final NulWriter writer, final List abcList, final Trait[] traits, final ExportMode exportMode, final boolean parallel) throws InterruptedException { + public void convert(final NulWriter writer, final List abcList, final Trait[] traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException { for (int t : traitIndices) { Trait trait = traits[t]; Multiname name = trait.getName(abc); @@ -135,7 +135,7 @@ public class ScriptPack implements TreeElementItem { } } - public void appendTo(GraphTextWriter writer, List abcList, Trait[] traits, ExportMode exportMode, boolean parallel) throws InterruptedException { + public void appendTo(GraphTextWriter writer, List abcList, Trait[] traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException { for (int t : traitIndices) { Trait trait = traits[t]; Multiname name = trait.getName(abc); @@ -148,7 +148,7 @@ public class ScriptPack implements TreeElementItem { } } - public void toSource(GraphTextWriter writer, final List abcList, final Trait[] traits, final ExportMode exportMode, final boolean parallel) throws InterruptedException { + public void toSource(GraphTextWriter writer, final List abcList, final Trait[] traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException { writer.suspendMeasure(); try { CancellableWorker.call(new Callable() { @@ -174,7 +174,7 @@ public class ScriptPack implements TreeElementItem { appendTo(writer, abcList, traits, exportMode, parallel); } - public File export(String directory, List abcList, ExportMode exportMode, boolean parallel) throws IOException { + public File export(String directory, List abcList, ScriptExportMode exportMode, boolean parallel) throws IOException { String scriptName = getPathScriptName(); String packageName = getPathPackage(); File outDir = new File(directory + File.separatorChar + makeDirPath(packageName)); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index ce4ccc644..5f1e9f9a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -213,9 +213,9 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -875,11 +875,11 @@ public class AVM2Code implements Serializable { return writer; } - public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ScriptExportMode exportMode, GraphTextWriter writer) { return toASMSource(constants, trait, info, body, new ArrayList(), exportMode, writer); } - public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List outputMap, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List outputMap, ScriptExportMode exportMode, GraphTextWriter writer) { invalidateCache(); if (trait != null) { if (trait instanceof TraitFunction) { @@ -1056,11 +1056,11 @@ public class AVM2Code implements Serializable { int largeLimit = 20000; boolean markOffsets = code.size() <= largeLimit; - if (exportMode == ExportMode.HEX) { + if (exportMode == ScriptExportMode.HEX) { Helper.byteArrayToHexWithHeader(writer, getBytes()); } else { for (AVM2Instruction ins : code) { - if (exportMode == ExportMode.PCODEWITHHEX) { + if (exportMode == ScriptExportMode.PCODE_HEX) { writer.appendNoHilight("; "); writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes())); writer.newLine(); @@ -2248,7 +2248,7 @@ public class AVM2Code implements Serializable { try { List outputMap = new ArrayList<>(); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer); + toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer); String src = writer.toString(); AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, null, body, info); @@ -2290,7 +2290,7 @@ public class AVM2Code implements Serializable { try { List outputMap = new ArrayList<>(); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer); + toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer); String src = writer.toString(); AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info); for (int i = 0; i < acode.code.size(); i++) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 132057498..54ee5d3c7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -21,9 +21,9 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.List; @@ -70,9 +70,9 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.append("{").newLine(); if (body != null) { if (writer instanceof NulWriter) { - body.convert(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null, false); + body.convert(path + "/inner", ScriptExportMode.AS, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null, false); } else { - body.toString(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null); + body.toString(path + "/inner", ScriptExportMode.AS, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null); } } writer.append("}"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 888e42801..e3dde0dc1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -24,8 +24,8 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -114,11 +114,11 @@ public class MethodBody implements Cloneable, Serializable { return ret; } - public void convert(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits, boolean firstLevel) throws InterruptedException { + public void convert(final String path, ScriptExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits, boolean firstLevel) throws InterruptedException { if (debugMode) { System.err.println("Decompiling " + path); } - if (exportMode != ExportMode.SOURCE) { + if (exportMode != ScriptExportMode.AS) { code.toASMSource(constants, trait, method_info[this.method_info], this, exportMode, writer); } else { if (!Configuration.decompile.get()) { @@ -154,8 +154,8 @@ public class MethodBody implements Cloneable, Serializable { } } - public GraphTextWriter toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits) throws InterruptedException { - if (exportMode != ExportMode.SOURCE) { + public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits) throws InterruptedException { + if (exportMode != ScriptExportMode.AS) { writer.indent(); code.toASMSource(constants, trait, method_info[this.method_info], this, exportMode, writer); writer.unindent(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index 82451a15f..97dc9f3e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import java.io.Serializable; import java.util.ArrayList; @@ -115,15 +115,15 @@ public abstract class Trait implements Serializable { return abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); } - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { writer.appendNoHilight(abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata)); return writer; } - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { } - public GraphTextWriter toStringPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toStringPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { String nsname = ns.getName(abc.constants); @@ -138,7 +138,7 @@ public abstract class Trait implements Serializable { return writer; } - public void convertPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convertPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { String nsname = ns.getName(abc.constants); @@ -146,12 +146,12 @@ public abstract class Trait implements Serializable { } } - public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { toString(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); return writer; } - public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index fd00532d8..874396f7b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -31,10 +31,10 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.util.ArrayList; @@ -324,17 +324,17 @@ public class TraitClass extends Trait implements TraitWithSlot { } @Override - public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames); return writer.appendNoHilight(classHeader); } @Override - public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { } @Override - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { writer.startClass(class_info); String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); @@ -496,7 +496,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } @Override - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { fullyQualifiedNames = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 96eab2be9..87d426dce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.util.List; @@ -43,7 +43,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { } @Override - public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { String modifier = getModifiers(abcTags, abc, isStatic) + " "; MethodBody body = abc.findBody(method_info); if (body == null) { @@ -63,11 +63,11 @@ public class TraitFunction extends Trait implements TraitWithSlot { } @Override - public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { } @Override - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); if (abc.instance_info[classIndex].isInterface()) { writer.appendNoHilight(";"); @@ -85,7 +85,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { } @Override - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); if (!abc.instance_info[classIndex].isInterface()) { int bodyIndex = abc.findBodyIndex(method_info); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 26e9e6b7e..200289549 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.util.List; @@ -38,11 +38,11 @@ public class TraitMethodGetterSetter extends Trait { } @Override - public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) { } @Override - public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) { String modifier = getModifiers(abcTags, abc, isStatic) + " "; if (modifier.equals(" ")) { modifier = ""; @@ -71,7 +71,7 @@ public class TraitMethodGetterSetter extends Trait { } @Override - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames); convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); @@ -83,7 +83,7 @@ public class TraitMethodGetterSetter extends Trait { } @Override - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames); toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 19a1b7fb8..7f4f6e05f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.ValueKind; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.Helper; @@ -119,7 +119,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { } @Override - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { String modifier = getModifiers(abcTags, abc, isStatic) + " "; if (modifier.equals(" ")) { modifier = ""; @@ -149,7 +149,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { } @Override - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { getNameStr(writer, abc, fullyQualifiedNames); if (assignedValue != null || value_kind != 0) { getValueStr(parent, writer, abc, fullyQualifiedNames); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 31fe7bad7..d666c3bda 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -83,7 +83,7 @@ public class Traits implements Serializable { List abcTags; ABC abc; boolean isStatic; - ExportMode exportMode; + ScriptExportMode exportMode; int scriptIndex; int classIndex; NulWriter writer; @@ -92,7 +92,7 @@ public class Traits implements Serializable { boolean parallel; Trait parent; - public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, int traitIndex, boolean parallel) { + public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, int traitIndex, boolean parallel) { this.trait = trait; this.parent = parent; this.makePackages = makePackages; @@ -120,7 +120,7 @@ public class Traits implements Serializable { } } - public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { for (int t = 0; t < traits.length; t++) { writer.newLine(); Trait trait = traits[t]; @@ -149,7 +149,7 @@ public class Traits implements Serializable { return writer; } - public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { if (!parallel || traits.length < 2) { for (int t = 0; t < traits.length; t++) { TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java index b81f6a825..de6ec534c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import java.util.ArrayList; import java.util.List; @@ -43,23 +43,23 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { NulWriter nulWriter = new NulWriter(); if (parentTraitIndex > -1) { if (isStatic) { - ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } } - ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); writer.appendNoHilight(super.toString(abcTags, abc) + " "); if (parentTraitIndex > -1) { if (isStatic) { - ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } } - ((TraitSlotConst) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitSlotConst) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); return writer.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java index 4b28ac4c9..ac1f2969b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -20,10 +20,10 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import java.util.ArrayList; import java.util.List; @@ -50,12 +50,12 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { if (!isInitializer) { if (parentTraitIndex > -1) { if (isStatic) { - ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } } - ((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); + ((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList(), false); } HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); @@ -70,13 +70,13 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { } else { if (parentTraitIndex > -1) { if (isStatic) { - ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } writer.appendNoHilight(" "); } - ((TraitMethodGetterSetter) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } return writer.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index ffcf160bc..2e9d1b89d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -58,12 +58,12 @@ import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -429,7 +429,7 @@ public class Action implements GraphSourceItem { * @param path * @return HilightedTextWriter */ - public static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, int version, ExportMode exportMode, GraphTextWriter writer, long swfPos, String path) { + public static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, int version, ScriptExportMode exportMode, GraphTextWriter writer, long swfPos, String path) { return actionsToString(listeners, address, list, importantOffsets, new ArrayList(), version, exportMode, writer, swfPos, path); } @@ -447,7 +447,7 @@ public class Action implements GraphSourceItem { * @param path * @return HilightedTextWriter */ - private static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer, long swfPos, String path) { + private static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer, long swfPos, String path) { long offset; if (importantOffsets == null) { //setActionsAddresses(list, 0, version); @@ -471,7 +471,7 @@ public class Action implements GraphSourceItem { a = (Action) s; } pos++; - if (exportMode == ExportMode.PCODEWITHHEX) { + if (exportMode == ScriptExportMode.PCODE_HEX) { if (lastPush) { writer.newLine(); lastPush = false; @@ -636,7 +636,7 @@ public class Action implements GraphSourceItem { * @param exportMode PCode or hex? * @return String of P-code source */ - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { return toString(); } @@ -1239,7 +1239,7 @@ public class Action implements GraphSourceItem { String s = null; try { HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - Action.actionsToString(new ArrayList(), address, ret, null, version, ExportMode.PCODE, writer, swfPos, path); + Action.actionsToString(new ArrayList(), address, ret, null, version, ScriptExportMode.PCODE, writer, swfPos, path); s = writer.toString(); ret = ASMParser.parse(address, swfPos, true, s, SWF.DEFAULT_VERSION, false); } catch (IOException | ParseException ex) { @@ -1268,7 +1268,7 @@ public class Action implements GraphSourceItem { } } - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode)); return writer; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java index 093de040d..cd130f6d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -36,7 +36,7 @@ import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; @@ -746,7 +746,7 @@ public class ActionListReader { } if (debugMode) { - String atos = a.getASMSource(new ArrayList(), new ArrayList(), cpool.constants, version, ExportMode.PCODE); + String atos = a.getASMSource(new ArrayList(), new ArrayList(), cpool.constants, version, ScriptExportMode.PCODE); if (a instanceof GraphSourceItemContainer) { atos = a.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index c372004ea..8e27591b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.special.ActionStore; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; @@ -56,7 +56,7 @@ public class ActionWaitForFrame extends Action implements ActionStore { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String ret = "WaitForFrame " + frame + " " + skipCount; return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index d88ff8631..8c88a5020 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.helpers.Helper; @@ -82,7 +82,7 @@ public class ActionIf extends Action { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : "")); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 6d36e0ace..5685489e4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.helpers.Helper; @@ -82,7 +82,7 @@ public class ActionJump extends Action { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); return "Jump loc" + ofsStr; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 116a59b8b..e9ddec268 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -28,9 +28,9 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; @@ -229,7 +229,7 @@ public class ActionPush extends Action { } @Override - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return toString(writer); } @@ -240,7 +240,7 @@ public class ActionPush extends Action { return writer; } - public GraphTextWriter paramsToStringReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter paramsToStringReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return paramsToString(writer); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index c1f4b7498..efa9f0ffe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -26,7 +26,7 @@ import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.special.ActionStore; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import java.io.ByteArrayOutputStream; @@ -116,7 +116,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String ret = "WaitForFrame2 " + skipCount; /*for (int i = 0; i < skipped.size(); i++) { if (skipped.get(i) instanceof ActionEnd) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 5439138db..29a72de5c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -23,8 +23,8 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -154,7 +154,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String paramStr = ""; for (int i = 0; i < paramNames.size(); i++) { paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\""; @@ -165,7 +165,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 8caaac8a1..a23c3b0d7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -80,7 +80,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { return "With {"; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index b1d526b64..93ff7c866 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -23,8 +23,8 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -234,7 +234,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; @@ -252,7 +252,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String paramStr = ""; for (int i = 0; i < paramNames.size(); i++) { paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index 4c8a48a78..3653a60d3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -26,7 +26,7 @@ import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -153,7 +153,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer { } @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode) { + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { String ret = ""; ret += "Try "; if (catchBlockFlag) { diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 55a4893a0..150e5cfd7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -247,6 +247,10 @@ public class Configuration { @ConfigurationName("check.updates.enabled") public static final ConfigurationItem checkForUpdatesAuto = null; + @ConfigurationDefaultString("") + @ConfigurationName("export.formats") + public static final ConfigurationItem lastSelectedExportFormats = null; + private enum OSId { WINDOWS, OSX, UNIX diff --git a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index ade59d558..9ca16ba62 100644 --- a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -26,9 +26,15 @@ import com.jpexs.decompiler.flash.SearchMode; import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; +import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.xfl.FLAVersion; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.streams.SeekableInputStream; @@ -330,16 +336,16 @@ public class CommandLineArgumentParser { return bValue; } - private static ExportMode strToExportFormat(String exportFormatStr) { + private static ScriptExportMode strToExportFormat(String exportFormatStr) { switch (exportFormatStr) { case "pcode": - return ExportMode.PCODE; + return ScriptExportMode.PCODE; case "pcodehex": - return ExportMode.PCODEWITHHEX; + return ScriptExportMode.PCODE_HEX; case "hex": - return ExportMode.HEX; + return ScriptExportMode.HEX; default: - return ExportMode.SOURCE; + return ScriptExportMode.AS; } } @@ -588,39 +594,39 @@ public class CommandLineArgumentParser { case "all_pcode": case "all_pcodehex": case "all_hex": - ExportMode allExportMode = ExportMode.SOURCE; + ScriptExportMode allExportMode = ScriptExportMode.AS; if (!exportFormat.equals("all")) { allExportMode = strToExportFormat(exportFormat.substring("all_".length() - 1)); } else if (formats.containsKey("script")) { allExportMode = strToExportFormat(formats.get("script")); } System.out.println("Exporting images..."); - exfile.exportImages(handler, outDir.getAbsolutePath() + File.separator + "images"); + exfile.exportImages(handler, outDir.getAbsolutePath() + File.separator + "images", ImageExportMode.PNG_JPEG); System.out.println("Exporting shapes..."); - exfile.exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes"); + exfile.exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes", ShapeExportMode.SVG); System.out.println("Exporting scripts..."); exfile.exportActionScript(handler, outDir.getAbsolutePath() + File.separator + "scripts", allExportMode, Configuration.parallelSpeedUp.get()); System.out.println("Exporting movies..."); - exfile.exportMovies(handler, outDir.getAbsolutePath() + File.separator + "movies"); + exfile.exportMovies(handler, outDir.getAbsolutePath() + File.separator + "movies", MovieExportMode.FLV); System.out.println("Exporting sounds..."); - exfile.exportSounds(handler, outDir.getAbsolutePath() + File.separator + "sounds", true, true); + exfile.exportSounds(handler, outDir.getAbsolutePath() + File.separator + "sounds", SoundExportMode.MP3_WAV_FLV); System.out.println("Exporting binaryData..."); - exfile.exportBinaryData(handler, outDir.getAbsolutePath() + File.separator + "binaryData"); + exfile.exportBinaryData(handler, outDir.getAbsolutePath() + File.separator + "binaryData", BinaryDataExportMode.RAW); System.out.println("Exporting texts..."); String allTextFormat = formats.get("text"); if (allTextFormat == null) { allTextFormat = "formatted"; } - exfile.exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts", allTextFormat.equals("formatted")); + exfile.exportTexts(handler, outDir.getAbsolutePath() + File.separator + "texts", allTextFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN); break; case "image": System.out.println("Exporting images..."); - exfile.exportImages(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "images" : "")); + exfile.exportImages(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "images" : ""), ImageExportMode.PNG_JPEG); //TODO: other modes break; case "shape": System.out.println("Exporting shapes..."); - exfile.exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : "")); + exfile.exportShapes(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "shapes" : ""), ShapeExportMode.SVG); break; case "script": case "as": @@ -628,7 +634,7 @@ public class CommandLineArgumentParser { case "pcodehex": case "hex": System.out.println("Exporting scripts..."); - ExportMode exportMode = ExportMode.SOURCE; + ScriptExportMode exportMode = ScriptExportMode.AS; if (!exportFormat.equals("script")) { exportMode = strToExportFormat(exportFormat); } else if (formats.containsKey("script")) { @@ -648,15 +654,15 @@ public class CommandLineArgumentParser { break; case "movie": System.out.println("Exporting movies..."); - exfile.exportMovies(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "movies" : "")); + exfile.exportMovies(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "movies" : ""), MovieExportMode.FLV); break; case "sound": System.out.println("Exporting sounds..."); - exfile.exportSounds(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "sounds" : ""), true, true); + exfile.exportSounds(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "sounds" : ""), SoundExportMode.MP3_WAV_FLV); break; case "binarydata": System.out.println("Exporting binaryData..."); - exfile.exportBinaryData(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "binaryData" : "")); + exfile.exportBinaryData(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "binaryData" : ""), BinaryDataExportMode.RAW); break; case "text": System.out.println("Exporting texts..."); @@ -664,11 +670,11 @@ public class CommandLineArgumentParser { if (textFormat == null) { textFormat = "formatted"; } - exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), textFormat.equals("formatted")); + exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), textFormat.equals("formatted") ? TextExportMode.FORMATTED : TextExportMode.PLAIN); break; case "textplain": System.out.println("Exporting texts..."); - exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), false); + exfile.exportTexts(handler, outDir.getAbsolutePath() + (exportFormats.length > 1 ? File.separator + "texts" : ""), TextExportMode.PLAIN); break; case "fla": System.out.println("Exporting FLA..."); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/BinaryDataExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/BinaryDataExportMode.java new file mode 100644 index 000000000..bb9a75d51 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/BinaryDataExportMode.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum BinaryDataExportMode { + + RAW +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ImageExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ImageExportMode.java new file mode 100644 index 000000000..00a1ee824 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ImageExportMode.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum ImageExportMode { + + PNG_JPEG, PNG, JPEG +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/MovieExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/MovieExportMode.java new file mode 100644 index 000000000..a9a009ee5 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/MovieExportMode.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum MovieExportMode { + + FLV +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java new file mode 100644 index 000000000..f011c9710 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum ScriptExportMode { + + AS, PCODE, PCODE_HEX, HEX; +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ShapeExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ShapeExportMode.java new file mode 100644 index 000000000..aeb16b6d4 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/ShapeExportMode.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum ShapeExportMode { + + SVG +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java new file mode 100644 index 000000000..72c5930b8 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum SoundExportMode { + + MP3_WAV_FLV(true, true, true), FLV(false, false, true), MP3_WAV(true, true, false), WAV(false, true, false); + + private boolean mp3, wav, flv; + + private SoundExportMode(boolean mp3, boolean wav, boolean flv) { + this.mp3 = mp3; + this.wav = wav; + this.flv = flv; + } + + public boolean hasMP3() { + return mp3; + } + + public boolean hasWav() { + return wav; + } + + public boolean hasFlv() { + return flv; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/TextExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/TextExportMode.java new file mode 100644 index 000000000..3d484b1b0 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/TextExportMode.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.exporters.modes; + +/** + * + * @author JPEXS + */ +public enum TextExportMode { + + PLAIN, + FORMATTED +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index b69d6dc46..2a7757f28 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -16,6 +16,22 @@ */ package com.jpexs.decompiler.flash.gui; +import com.jpexs.decompiler.flash.abc.ScriptPack; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; +import com.jpexs.decompiler.flash.tags.base.SoundTag; +import com.jpexs.decompiler.flash.tags.base.TextTag; +import com.jpexs.decompiler.flash.treenodes.TreeNode; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; @@ -24,6 +40,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.Arrays; +import java.util.List; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; @@ -36,35 +54,67 @@ import javax.swing.JPanel; public class ExportDialog extends AppDialog { boolean cancelled = false; - String[][] options = { - {translate("shapes.svg")}, - {translate("texts.plain"), translate("texts.formatted")}, - {translate("images.pngjpeg")}, - {translate("movies.flv")}, - {translate("sounds.mp3wavflv"), translate("sounds.flv")}, - {translate("actionscript.as"), translate("actionscript.pcode"), translate("actionscript.pcodehex"), translate("actionscript.hex")} - }; + String[] optionNames = { - translate("shapes"), - translate("texts"), - translate("images"), - translate("movies"), - translate("sounds"), - translate("actionscript") + "shapes", + "texts", + "images", + "movies", + "sounds", + "scripts", + "binaryData" }; - public static final int OPTION_SHAPES = 0; - public static final int OPTION_TEXTS = 1; - public static final int OPTION_IMAGES = 2; - public static final int OPTION_MOVIES = 3; - public static final int OPTION_SOUNDS = 4; - public static final int OPTION_ACTIONSCRIPT = 5; + + //Display options only when these classes found + Class[][] objClasses = { + {ShapeTag.class}, + {TextTag.class}, + {ImageTag.class}, + {DefineVideoStreamTag.class}, + {SoundTag.class}, + {TreeNode.class, ScriptPack.class}, + {DefineBinaryDataTag.class} + }; + + //Enum classes for values + Class[] optionClasses = { + ShapeExportMode.class, + TextExportMode.class, + ImageExportMode.class, + MovieExportMode.class, + SoundExportMode.class, + ScriptExportMode.class, + BinaryDataExportMode.class + }; + private final JComboBox[] combos; - public int getOption(int index) { - return combos[index].getSelectedIndex(); + public E getValue(Class option) { + for (int i = 0; i < optionClasses.length; i++) { + if (option == optionClasses[i]) { + E values[] = option.getEnumConstants(); + return values[combos[i].getSelectedIndex()]; + } + } + return null; } - public ExportDialog() { + private void saveConfig() { + String cfg = ""; + for (int i = 0; i < optionNames.length; i++) { + int selIndex = combos[i].getSelectedIndex(); + Class c = optionClasses[i]; + Object vals[] = c.getEnumConstants(); + String key = optionNames[i] + "." + vals[selIndex].toString().toLowerCase(); + if (i > 0) { + cfg += ","; + } + cfg += key; + } + Configuration.lastSelectedExportFormats.set(cfg); + } + + public ExportDialog(List exportables) { setTitle(translate("dialog.title")); addWindowListener(new WindowAdapter() { @Override @@ -85,14 +135,59 @@ public class ExportDialog extends AppDialog { labWidth = labels[i].getPreferredSize().width; } } + String exportFormatsStr = Configuration.lastSelectedExportFormats.get(); + if ("".equals(exportFormatsStr)) { + exportFormatsStr = null; + } + String exportFormatsArr[] = new String[0]; + if (exportFormatsStr != null) { + if (exportFormatsStr.contains(",")) { + exportFormatsArr = exportFormatsStr.split(","); + } else { + exportFormatsArr = new String[]{exportFormatsStr}; + } + + } + List exportFormats = Arrays.asList(exportFormatsArr); int comboWidth = 200; int top = 10; for (int i = 0; i < optionNames.length; i++) { - JLabel lab = new JLabel(optionNames[i]); + Class c = optionClasses[i]; + Object vals[] = c.getEnumConstants(); + String names[] = new String[vals.length]; + int itemIndex = -1; + for (int j = 0; j < vals.length; j++) { + + String key = optionNames[i] + "." + vals[j].toString().toLowerCase(); + if (exportFormats.contains(key)) { + itemIndex = j; + } + names[j] = translate(key); + } + + combos[i] = new JComboBox<>(names); + if (itemIndex > -1) { + combos[i].setSelectedIndex(itemIndex); + } + combos[i].setBounds(10 + labWidth + 10, top, comboWidth, combos[i].getPreferredSize().height); + boolean exportableExists = false; + if (exportables == null) { + exportableExists = true; + } else { + for (Object e : exportables) { + for (int j = 0; j < objClasses[i].length; j++) { + if (objClasses[i][j].isInstance(e)) { + exportableExists = true; + } + } + } + } + if (!exportableExists) { + continue; + } + JLabel lab = new JLabel(translate(optionNames[i])); lab.setBounds(10, top, lab.getPreferredSize().width, lab.getPreferredSize().height); comboPanel.add(lab); - combos[i] = new JComboBox<>(options[i]); - combos[i].setBounds(10 + labWidth + 10, top, comboWidth, combos[i].getPreferredSize().height); comboPanel.add(combos[i]); top += combos[i].getHeight(); } @@ -106,6 +201,7 @@ public class ExportDialog extends AppDialog { okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + saveConfig(); setVisible(false); } }); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 40a24e25a..f6983922a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -324,13 +324,13 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } stopAllSounds(); } - - private void stopAllSounds(){ + + private void stopAllSounds() { for (int i = soundPlayers.size() - 1; i >= 0; i--) { - SoundTagPlayer pl = soundPlayers.get(i); - pl.pause(); - } - soundPlayers.clear(); + SoundTagPlayer pl = soundPlayers.get(i); + pl.pause(); + } + soundPlayers.clear(); } private void nextFrame() { @@ -393,22 +393,21 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis CharacterTag c = swf.characters.get(sndId); if (c instanceof SoundTag) { SoundTag st = (SoundTag) c; - if (SoundTagPlayer.tagSupported(st)) { - final SoundTagPlayer sp = new SoundTagPlayer(st, 1); - synchronized (ImagePanel.class) { - soundPlayers.add(sp); - } - sp.addListener(new PlayerListener() { - - @Override - public void playingFinished() { - synchronized (ImagePanel.class) { - soundPlayers.remove(sp); - } - } - }); - sp.play(); + final SoundTagPlayer sp = new SoundTagPlayer(st, 1); + synchronized (ImagePanel.class) { + soundPlayers.add(sp); } + sp.addListener(new PlayerListener() { + + @Override + public void playingFinished() { + synchronized (ImagePanel.class) { + soundPlayers.remove(sp); + } + } + }); + sp.play(); + } } label.setIcon(icon); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 35da06385..e4f529818 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -29,6 +29,13 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; +import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; import com.jpexs.decompiler.flash.gui.abc.ABCPanel; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; @@ -36,7 +43,6 @@ import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.gui.abc.treenodes.TreeElement; import com.jpexs.decompiler.flash.gui.action.ActionPanel; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; -import com.jpexs.decompiler.flash.gui.player.MediaDisplay; import com.jpexs.decompiler.flash.gui.player.PlayerControls; import com.jpexs.decompiler.flash.gui.timeline.TimelineFrame; import com.jpexs.decompiler.flash.gui.treenodes.SWFBundleNode; @@ -116,14 +122,11 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.TEXTRECORD; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.decompiler.flash.xfl.FLAVersion; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; -import com.jpexs.helpers.sound.MP3Player; -import com.jpexs.helpers.sound.SoundPlayer; -import com.jpexs.helpers.sound.WavPlayer; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -155,7 +158,6 @@ import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -205,7 +207,6 @@ import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; -import javazoom.jl.decoder.JavaLayerException; /** * @@ -289,8 +290,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private SoundTagPlayer soundThread = null; - - private static final String ACTION_SELECT_BKCOLOR = "SELECTCOLOR"; private static final String ACTION_REPLACE_IMAGE = "REPLACEIMAGE"; private static final String ACTION_REPLACE_BINARY = "REPLACEBINARY"; @@ -666,20 +665,17 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } } } - final ExportDialog export = new ExportDialog(); - try { - File ftemp = new File(tempDir); - files = exportSelection(errorHandler, tempDir, export); - files.clear(); + File ftemp = new File(tempDir); + ExportDialog exd = new ExportDialog(null); + files = exportSelection(errorHandler, tempDir, exd); + files.clear(); - File[] fs = ftemp.listFiles(); - files.addAll(Arrays.asList(fs)); + File[] fs = ftemp.listFiles(); + files.addAll(Arrays.asList(fs)); + + Main.stopWork(); - Main.stopWork(); - } catch (IOException ex) { - return null; - } for (File f : files) { f.deleteOnExit(); } @@ -1466,24 +1462,64 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec return false; } + private List getSelection(SWF swf) { + List ret = new ArrayList<>(); + List sel = getAllSelected(tagTree); + for (TreeNode d : sel) { + if (d.getItem().getSwf() != swf) { + continue; + } + if (d instanceof ContainerNode) { + ContainerNode n = (ContainerNode) d; + TreeNodeType nodeType = TagTree.getTreeNodeType(n.getItem()); + if (nodeType == TreeNodeType.IMAGE) { + ret.add((Tag) n.getItem()); + } + if (nodeType == TreeNodeType.SHAPE) { + ret.add((Tag) n.getItem()); + } + if (nodeType == TreeNodeType.AS) { + ret.add(n); + } + if (nodeType == TreeNodeType.MOVIE) { + ret.add((Tag) n.getItem()); + } + if (nodeType == TreeNodeType.SOUND) { + ret.add((Tag) n.getItem()); + } + if (nodeType == TreeNodeType.BINARY_DATA) { + ret.add((Tag) n.getItem()); + } + if (nodeType == TreeNodeType.TEXT) { + ret.add((Tag) n.getItem()); + } + } + if (d instanceof TreeElement) { + if (((TreeElement) d).isLeaf()) { + TreeElement treeElement = (TreeElement) d; + ret.add((ScriptPack) treeElement.getItem()); + } + } + } + return ret; + } + public List exportSelection(AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException { - final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT)); - final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; - final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; List ret = new ArrayList<>(); List sel = getAllSelected(tagTree); for (SWFList swfList : swfs) { for (SWF swf : swfList) { - List tlsList = new ArrayList<>(); + List as3scripts = new ArrayList<>(); List images = new ArrayList<>(); List shapes = new ArrayList<>(); List movies = new ArrayList<>(); List sounds = new ArrayList<>(); List texts = new ArrayList<>(); - List actionNodes = new ArrayList<>(); + List as12scripts = new ArrayList<>(); List binaryData = new ArrayList<>(); + for (TreeNode d : sel) { if (d.getItem().getSwf() != swf) { continue; @@ -1498,7 +1534,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec shapes.add((Tag) n.getItem()); } if (nodeType == TreeNodeType.AS) { - actionNodes.add(n); + as12scripts.add(n); } if (nodeType == TreeNodeType.MOVIE) { movies.add((Tag) n.getItem()); @@ -1516,31 +1552,54 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (d instanceof TreeElement) { if (((TreeElement) d).isLeaf()) { TreeElement treeElement = (TreeElement) d; - tlsList.add((ScriptPack) treeElement.getItem()); + as3scripts.add((ScriptPack) treeElement.getItem()); } } } - ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images)); - ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes)); - ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts, isFormatted)); - ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies)); - ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, isMp3OrWav, isMp3OrWav)); - ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData)); + + List allnodes = new ArrayList<>(); + allnodes.addAll(as3scripts); + allnodes.addAll(as12scripts); + allnodes.addAll(images); + allnodes.addAll(shapes); + allnodes.addAll(movies); + allnodes.addAll(sounds); + allnodes.addAll(texts); + allnodes.addAll(binaryData); + + if (selFile == null) { + selFile = selectExportDir(); + if (selFile == null) { + return new ArrayList<>(); + } + } + + final ScriptExportMode scriptMode = export.getValue(ScriptExportMode.class); + ret.addAll(swf.exportImages(handler, selFile + File.separator + "images", images, export.getValue(ImageExportMode.class))); + ret.addAll(SWF.exportShapes(handler, selFile + File.separator + "shapes", shapes, export.getValue(ShapeExportMode.class))); + ret.addAll(swf.exportTexts(handler, selFile + File.separator + "texts", texts, export.getValue(TextExportMode.class))); + ret.addAll(swf.exportMovies(handler, selFile + File.separator + "movies", movies, export.getValue(MovieExportMode.class))); + ret.addAll(swf.exportSounds(handler, selFile + File.separator + "sounds", sounds, export.getValue(SoundExportMode.class))); + ret.addAll(SWF.exportBinaryData(handler, selFile + File.separator + "binaryData", binaryData, export.getValue(BinaryDataExportMode.class))); List abcList = swf.abcList; if (abcPanel != null) { - for (int i = 0; i < tlsList.size(); i++) { - ScriptPack tls = tlsList.get(i); - Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ..."); - ret.add(tls.export(selFile, abcList, exportMode, Configuration.parallelSpeedUp.get())); + for (int i = 0; i < as3scripts.size(); i++) { + ScriptPack tls = as3scripts.get(i); + Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + as3scripts.size() + " " + tls.getPath() + " ..."); + ret.add(tls.export(selFile, abcList, scriptMode, Configuration.parallelSpeedUp.get())); } } else { List allNodes = new ArrayList<>(); - List asNodes = getASTreeNodes(tagTree); - for (TreeNode asn : asNodes) { + List allAs12Scripts = new ArrayList<>(); + + if (abcPanel == null) { + allAs12Scripts = getASTreeNodes(tagTree); + } + for (TreeNode asn : allAs12Scripts) { allNodes.add(asn); TagNode.setExport(allNodes, false); - TagNode.setExport(actionNodes, true); - ret.addAll(TagNode.exportNodeAS(handler, allNodes, selFile, exportMode, null)); + TagNode.setExport(as12scripts, true); + ret.addAll(TagNode.exportNodeAS(handler, allNodes, selFile, scriptMode, null)); } } } @@ -1877,24 +1936,42 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } } + private String selectExportDir() { + JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get())); + chooser.setDialogTitle(translate("export.select.directory")); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setAcceptAllFileFilterUsed(false); + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + final long timeBefore = System.currentTimeMillis(); + Main.startWork(translate("work.exporting") + "..."); + final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath(); + Configuration.lastExportDir.set(Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath()); + return selFile; + } + return null; + } + public void export(final boolean onlySel) { - final ExportDialog export = new ExportDialog(); + + final SWF swf = getCurrentSwf(); + List sel = getSelection(swf); + if (!onlySel) { + sel = null; + } else { + if (sel.isEmpty()) { + return; + } + } + final ExportDialog export = new ExportDialog(sel); export.setVisible(true); if (!export.cancelled) { - JFileChooser chooser = new JFileChooser(); - chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get())); - chooser.setDialogTitle(translate("export.select.directory")); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setAcceptAllFileFilterUsed(false); - if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + final String selFile = selectExportDir(); + if (selFile != null) { final long timeBefore = System.currentTimeMillis(); Main.startWork(translate("work.exporting") + "..."); - final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath(); - Configuration.lastExportDir.set(Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath()); - final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT)); - final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; - final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; - final SWF swf = getCurrentSwf(); + final ScriptExportMode exportMode = export.getValue(ScriptExportMode.class); + new CancellableWorker() { @Override public Void doInBackground() throws Exception { @@ -1902,12 +1979,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (onlySel) { exportSelection(errorHandler, selFile, export); } else { - swf.exportImages(errorHandler, selFile + File.separator + "images"); - swf.exportShapes(errorHandler, selFile + File.separator + "shapes"); - swf.exportTexts(errorHandler, selFile + File.separator + "texts", isFormatted); - swf.exportMovies(errorHandler, selFile + File.separator + "movies"); - swf.exportSounds(errorHandler, selFile + File.separator + "sounds", isMp3OrWav, isMp3OrWav); - swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData"); + swf.exportImages(errorHandler, selFile + File.separator + "images", export.getValue(ImageExportMode.class)); + swf.exportShapes(errorHandler, selFile + File.separator + "shapes", export.getValue(ShapeExportMode.class)); + swf.exportTexts(errorHandler, selFile + File.separator + "texts", export.getValue(TextExportMode.class)); + swf.exportMovies(errorHandler, selFile + File.separator + "movies", export.getValue(MovieExportMode.class)); + swf.exportSounds(errorHandler, selFile + File.separator + "sounds", export.getValue(SoundExportMode.class)); + swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData", export.getValue(BinaryDataExportMode.class)); swf.exportActionScript(errorHandler, selFile, exportMode, Configuration.parallelSpeedUp.get()); } } catch (Exception ex) { @@ -2207,9 +2284,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); File selfile = Helper.fixDialogFile(fc.getSelectedFile()); DefineSoundTag ds = (DefineSoundTag) item; - int soundFormat = DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN; + int soundFormat = SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN; if (selfile.getName().toLowerCase().endsWith(".mp3")) { - soundFormat = DefineSoundTag.FORMAT_MP3; + soundFormat = SoundFormat.FORMAT_MP3; } boolean ok = false; try { @@ -2630,9 +2707,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec showCard(CARDDRAWPREVIEWPANEL); previewImagePanel.setImage(new SerializableImage(1, 1, BufferedImage.TYPE_INT_ARGB)); - - - soundThread = new SoundTagPlayer((SoundTag)tagObj,Integer.MAX_VALUE); + soundThread = new SoundTagPlayer((SoundTag) tagObj, Integer.MAX_VALUE); imagePlayControls.setMedia(soundThread); soundThread.play(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/PlayerListener.java b/trunk/src/com/jpexs/decompiler/flash/gui/PlayerListener.java index 41eaaa56e..d50be44b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/PlayerListener.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/PlayerListener.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.decompiler.flash.gui; /** @@ -22,5 +21,6 @@ package com.jpexs.decompiler.flash.gui; * @author JPEXS */ public interface PlayerListener { + public void playingFinished(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index e8b945d81..ecf8f12ea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -14,25 +14,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; -import com.jpexs.decompiler.flash.tags.DefineSoundTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.SoundTag; -import com.jpexs.helpers.sound.MP3Player; import com.jpexs.helpers.sound.SoundPlayer; import com.jpexs.helpers.sound.WavPlayer; import java.awt.Color; import java.io.ByteArrayInputStream; -import java.io.IOException; +import java.io.ByteArrayOutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javazoom.jl.decoder.JavaLayerException; /** * @@ -40,172 +32,152 @@ import javazoom.jl.decoder.JavaLayerException; */ public class SoundTagPlayer implements MediaDisplay { - private SoundPlayer player; + private SoundPlayer player; - private Thread thr; - private int actualPos = 0; - private boolean playing = false; - private SoundTag tag; - private byte data[]; - private List listeners=new ArrayList<>(); - - public void addListener(PlayerListener l){ - listeners.add(l); + private Thread thr; + private int actualPos = 0; + private boolean playing = false; + private SoundTag tag; + private byte data[]; + private List listeners = new ArrayList<>(); + + public void addListener(PlayerListener l) { + listeners.add(l); + } + + public void removeListener(PlayerListener l) { + listeners.remove(l); + } + + public void fireFinished() { + for (PlayerListener l : listeners) { + l.playingFinished(); } - - public void removeListener(PlayerListener l){ - listeners.remove(l); + } + + private static final int FRAME_DIVISOR = 1024; + + private int loops; + + public SoundTagPlayer(SoundTag tag, int loops) { + this.tag = tag; + this.loops = loops; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayInputStream bais = new ByteArrayInputStream(tag.getRawSoundData()); + tag.getSoundFormat().createWav(bais, baos); + this.data = baos.toByteArray(); + } + + @Override + public synchronized int getCurrentFrame() { + if (player == null) { + return 0; } - public void fireFinished(){ - for(PlayerListener l:listeners){ - l.playingFinished(); - } - } - - private static final int FRAME_DIVISOR = 1024; - - private int loops; - - public static boolean tagSupported(SoundTag tag){ - if(!Arrays.asList("mp3","wav").contains(tag.getExportFormat())){ - return false; - } - return true; - } - - public SoundTagPlayer(SoundTag tag, int loops) { - if(!tagSupported(tag)){ - throw new IllegalArgumentException("Format not supported"); - } - this.tag = tag; - this.loops = loops; - try { - this.data = ((Tag)tag).getSwf().exportSound((Tag)tag); - } catch (IOException ex) { - Logger.getLogger(SoundTagPlayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - - @Override - public synchronized int getCurrentFrame() { - if (player == null) { - return 0; - } - - if (!playing) { - return actualPos; - } - - actualPos = (int) (player.getSamplePosition() / FRAME_DIVISOR); + if (!playing) { return actualPos; } - @Override - public synchronized int getTotalFrames() { - //System.out.println("getTotalFrames"); - if (player == null) { - return 0; - } - int ret = (int) (player.samplesCount() / FRAME_DIVISOR); + actualPos = (int) (player.getSamplePosition() / FRAME_DIVISOR); + return actualPos; + } - //System.out.println("/getTotalFrames"); - return ret; + @Override + public synchronized int getTotalFrames() { + //System.out.println("getTotalFrames"); + if (player == null) { + return 0; } + int ret = (int) (player.samplesCount() / FRAME_DIVISOR); - @Override - public synchronized void pause() { - if (!playing) { - return; - } - playing = false; - actualPos = (int) (player.getSamplePosition() / FRAME_DIVISOR); + //System.out.println("/getTotalFrames"); + return ret; + } + + @Override + public synchronized void pause() { + if (!playing) { + return; + } + playing = false; + actualPos = (int) (player.getSamplePosition() / FRAME_DIVISOR); + player.stop(); + + } + + public void play(boolean async) { + if (player != null) { player.stop(); - } - public void play(boolean async){ - if (player != null) { - player.stop(); - } + player = new WavPlayer(new ByteArrayInputStream(data)); + final int startPos = actualPos * FRAME_DIVISOR; + Runnable r = new Runnable() { - if (tag.getExportFormat().equals("mp3")) { - final int soundRates[] = new int[]{5512, 11025, 22050, 44100}; - try { - player = new MP3Player(new ByteArrayInputStream(data), (int) (tag.getTotalSoundSampleCount() * (tag.getSoundType() ? 2 : 1)), soundRates[tag.getSoundRate()] * (tag.getSoundType() ? 2 : 1)); - } catch (JavaLayerException ex) { - Logger.getLogger(SoundTagPlayer.class.getName()).log(Level.SEVERE, null, ex); + @Override + public void run() { + player.skip(startPos); + player.play(); + fireFinished(); + if (loops > 0) { + loops--; } - } else if(tag.getExportFormat().equals("wav")){ - player = new WavPlayer(new ByteArrayInputStream(data)); - } - final int startPos = actualPos * FRAME_DIVISOR; - Runnable r = new Runnable() { - - @Override - public void run() { - player.skip(startPos); - player.play(); - fireFinished(); - if(loops>0){ - loops--; - } - if (playing && loops>0) { - gotoFrame(0); - play(); - } + if (playing && loops > 0) { + gotoFrame(0); + play(); } - }; - playing = true; - if(async){ - thr = new Thread(r); - thr.start(); - }else{ - r.run(); } - - } - - @Override - public synchronized void play() { - play(true); - } - - @Override - public void rewind() { - actualPos = 0; - } - - @Override - public boolean isPlaying() { - return playing; - } - - @Override - public synchronized void gotoFrame(int frame) { - if (playing) { - playing = false; - player.stop(); - } - actualPos = frame; - } - - @Override - public void setBackground(Color color) { - - } - - @Override - public int getFrameRate() { - if (player == null) { - return 1; - } - return (int) (player.getFrameRate() / FRAME_DIVISOR); - } - - @Override - public boolean isLoaded() { - return true; + }; + playing = true; + if (async) { + thr = new Thread(r); + thr.start(); + } else { + r.run(); } } + + @Override + public synchronized void play() { + play(true); + } + + @Override + public void rewind() { + actualPos = 0; + } + + @Override + public boolean isPlaying() { + return playing; + } + + @Override + public synchronized void gotoFrame(int frame) { + if (playing) { + playing = false; + player.stop(); + } + actualPos = frame; + } + + @Override + public void setBackground(Color color) { + + } + + @Override + public int getFrameRate() { + if (player == null) { + return 1; + } + return (int) (player.getFrameRate() / FRAME_DIVISOR); + } + + @Override + public boolean isLoaded() { + return true; + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index c0df3cc36..9d5195c0c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -27,12 +27,12 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; import java.io.ByteArrayInputStream; @@ -59,32 +59,32 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private HilightedText textWithHex; private HilightedText textNoHex; private HilightedText textHexOnly; - private ExportMode exportMode = ExportMode.PCODE; + private ScriptExportMode exportMode = ScriptExportMode.PCODE; private Trait trait; - public ExportMode getExportMode() { + public ScriptExportMode getExportMode() { return exportMode; } - private HilightedText getHilightedText(ExportMode exportMode) { + private HilightedText getHilightedText(ScriptExportMode exportMode) { HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], exportMode, writer); return new HilightedText(writer); } - public void setHex(ExportMode exportMode, boolean force) { + public void setHex(ScriptExportMode exportMode, boolean force) { if (this.exportMode == exportMode & !force) { return; } this.exportMode = exportMode; long oldOffset = getSelectedOffset(); - if (exportMode == ExportMode.PCODE) { + if (exportMode == ScriptExportMode.PCODE) { setContentType("text/flasm"); if (textNoHex == null) { textNoHex = getHilightedText(exportMode); } setText(textNoHex); - } else if (exportMode == ExportMode.PCODEWITHHEX) { + } else if (exportMode == ScriptExportMode.PCODE_HEX) { setContentType("text/flasm"); if (textWithHex == null) { textWithHex = getHilightedText(exportMode); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 41ddb20af..e9bdb8c71 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -27,12 +27,12 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Cache; import java.util.ArrayList; import java.util.List; @@ -447,7 +447,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (!cache.contains(scriptLeaf)) { boolean parallel = Configuration.parallelSpeedUp.get(); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true); - scriptLeaf.toSource(writer, abcList, script.traits.traits, ExportMode.SOURCE, parallel); + scriptLeaf.toSource(writer, abcList, script.traits.traits, ScriptExportMode.AS, parallel); hilightedCode = new HilightedText(writer); cache.put(scriptLeaf, new CachedDecompilation(hilightedCode)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index c7f6a038e..f8b9e6e45 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -21,9 +21,9 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.graph.ExportMode; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Insets; @@ -155,18 +155,18 @@ public class MethodCodePanel extends JPanel implements ActionListener { } } - private ExportMode getExportMode() { - ExportMode exportMode = hexOnlyButton.isSelected() ? ExportMode.HEX - : (hexButton.isSelected() ? ExportMode.PCODEWITHHEX : ExportMode.PCODE); + private ScriptExportMode getExportMode() { + ScriptExportMode exportMode = hexOnlyButton.isSelected() ? ScriptExportMode.HEX + : (hexButton.isSelected() ? ScriptExportMode.PCODE_HEX : ScriptExportMode.PCODE); return exportMode; } public void setEditMode(boolean val) { - ExportMode exportMode = getExportMode(); + ScriptExportMode exportMode = getExportMode(); if (val) { - sourceTextArea.setHex(exportMode == ExportMode.HEX ? ExportMode.HEX : ExportMode.PCODE, false); + sourceTextArea.setHex(exportMode == ScriptExportMode.HEX ? ScriptExportMode.HEX : ScriptExportMode.PCODE, false); } else { - if (exportMode != ExportMode.PCODE) { + if (exportMode != ScriptExportMode.PCODE) { sourceTextArea.setHex(exportMode, false); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java index c75abcc84..b0e7fb183 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java @@ -22,10 +22,10 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.ExportMode; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -89,14 +89,14 @@ public class TraitsListItem { String s = ""; try { if ((type != Type.INITIALIZER) && isStatic) { - abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); + abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - abc.class_info[classIndex].static_traits.traits[index].toStringHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); + abc.class_info[classIndex].static_traits.traits[index].toStringHeader(null, "", abcTags, abc, true, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if ((type != Type.INITIALIZER) && (!isStatic)) { - abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); + abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList(), false); HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - abc.instance_info[classIndex].instance_traits.traits[index].toStringHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); + abc.instance_info[classIndex].instance_traits.traits[index].toStringHeader(null, "", abcTags, abc, false, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if (!isStatic) { s = STR_INSTANCE_INITIALIZER; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 12eb28b16..722d8ded8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.Main; @@ -41,7 +42,6 @@ import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.treenodes.TreeNode; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; @@ -305,7 +305,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene }); } - private HilightedText getHilightedText(ExportMode exportMode) { + private HilightedText getHilightedText(ScriptExportMode exportMode) { ASMSource asm = (ASMSource) src; DisassemblyListener listener = getDisassemblyListener(); asm.addDisassemblyListener(listener); @@ -319,9 +319,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene return new HilightedText(writer); } - public void setHex(ExportMode exportMode) { - if (exportMode != ExportMode.HEX) { - if (exportMode == ExportMode.PCODE) { + public void setHex(ScriptExportMode exportMode) { + if (exportMode != ScriptExportMode.HEX) { + if (exportMode == ScriptExportMode.PCODE) { if (srcNoHex == null) { srcNoHex = getHilightedText(exportMode); } @@ -762,9 +762,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } } - private ExportMode getExportMode() { - ExportMode exportMode = hexOnlyButton.isSelected() ? ExportMode.HEX - : (hexButton.isSelected() ? ExportMode.PCODEWITHHEX : ExportMode.PCODE); + private ScriptExportMode getExportMode() { + ScriptExportMode exportMode = hexOnlyButton.isSelected() ? ScriptExportMode.HEX + : (hexButton.isSelected() ? ScriptExportMode.PCODE_HEX : ScriptExportMode.PCODE); return exportMode; } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties index a320f5771..a20f64366 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog.properties @@ -20,20 +20,27 @@ texts.plain = Plain text texts.formatted = Formatted text images = Images -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG +images.png = PNG +images.jpeg = JPEG movies = Movies movies.flv = FLV (No audio) sounds = Sounds -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Audio only) +sounds.mp3_wav = MP3/WAV +sounds.wav = WAV -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-code -actionscript.pcodehex = P-code with Hex -actionscript.hex = Hex +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code +scripts.pcode_hex = P-code with Hex +scripts.hex = Hex + +binaryData = Binary data +binaryData.raw = Raw dialog.title = Export... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_cs.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_cs.properties index 02be8fa93..38022ed55 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_cs.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_cs.properties @@ -20,20 +20,20 @@ texts.plain = \u010cist\u00fd Text texts.formatted = Form\u00e1tovan\u00fd text images = Obr\u00e1zky -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Videa movies.flv = FLV (bez zvuku) sounds = Zvuky -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (pouze zvuk) -actionscript = ActionScript -actionscript.as = AS -actionscript.pcode = P-k\u00f3d -actionscript.pcodehex = P-k\u00f3d s hex -actionscript.hex = Hex +scripts = Skripty +scripts.as = ActionScript +scripts.pcode = P-k\u00f3d +scripts.pcode_hex = P-k\u00f3d s hex +scripts.hex = Hex dialog.title = Exportovat... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_de.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_de.properties index 1f2cd661f..8416e40a3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_de.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_de.properties @@ -20,18 +20,18 @@ texts.plain = Klartext texts.formatted = Formatierter Text images = Bilder -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Movies movies.flv = FLV (Keine Ger\u00e4usche) sounds = Ger\u00e4usche -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Nur Ger\u00e4usche) -actionscript = ActionScript -actionscript.as = AS -actionscript.pcode = PCODE +scripts = Script +scripts.as = ActionScript +scripts.pcode = PCODE dialog.title = Exportieren... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_es.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_es.properties index 3f36c5afc..fdb0e5066 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_es.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_es.properties @@ -20,20 +20,20 @@ texts.plain = Texto plano texts.formatted = Texto formateado images = Im\u00e1genes -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Pel\u00edculas movies.flv = FLV (No audio) sounds = Sonidos -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Solo audio) -actionscript = ActionScript -actionscript.as = AS -actionscript.pcode = P-code -actionscript.pcodehex = P-code con Hexadecimal -actionscript.hex = Hexadecimal +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code +scripts.pcode_hex = P-code con Hexadecimal +scripts.hex = Hexadecimal dialog.title = Exportar... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_fr.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_fr.properties index d42ff65ec..cac57bbf8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_fr.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_fr.properties @@ -20,20 +20,20 @@ texts.plain = Texte brut texts.formatted = Texte format\u00e9 images = Images -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Vid\u00e9os movies.flv = FLV (Aucun son) sounds = Sons -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Audio seulement) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = Assembleur -actionscript.pcodehex = Assembleur hexad\u00e9cimal -actionscript.hex = Hexad\u00e9cimal +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = Assembleur +scripts.pcode_hex = Assembleur hexad\u00e9cimal +scripts.hex = Hexad\u00e9cimal dialog.title = Exportation... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_hu.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_hu.properties index 3885e92e4..dc0fbb3bc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_hu.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_hu.properties @@ -20,20 +20,20 @@ texts.plain = Egyszer\u0171 sz\u00f6veg texts.formatted = Form\u00e1zott sz\u00f6veg images = K\u00e9pek -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Mozg\u00f3k\u00e9pek movies.flv = FLV (Hang n\u00e9lk\u00fcl) sounds = Hangok -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Csak hang) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-code -actionscript.pcodehex = P-code \u00e9s Hexa -actionscript.hex = Hexa +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code +scripts.pcode_hex = P-code \u00e9s Hexa +scripts.hex = Hexa dialog.title = Export\u00e1l\u00e1s... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_nl.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_nl.properties index 820cd3c03..624d79fa4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_nl.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_nl.properties @@ -20,20 +20,20 @@ texts.plain = Platte tekst texts.formatted = Geformatteerde tekst images = Images -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Films movies.flv = FLV (Geen audio) sounds = Geluiden -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Alleen audio) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-code -actionscript.pcodehex = P-code met Hex -actionscript.hex = Hex +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code +scripts.pcode_hex = P-code met Hex +scripts.hex = Hex dialog.title = Exporteren... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_pt.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_pt.properties index bbd604762..26168dc6b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_pt.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_pt.properties @@ -20,18 +20,18 @@ texts.plain = Texto simples texts.formatted = Texto Formatador images = Imagens -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Filmes movies.flv = FLV (No audio) sounds = Sons -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Apenas audio) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-code +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code dialog.title = Exportar... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_ru.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_ru.properties index f774d5a2a..688a61407 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_ru.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_ru.properties @@ -20,20 +20,20 @@ texts.plain = \u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u044 texts.formatted = \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 images = \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = \u0412\u0438\u0434\u0435\u043e movies.flv = FLV (\u0411\u0435\u0437 \u0437\u0432\u0443\u043a\u0430) sounds = \u0417\u0432\u0443\u043a\u0438 -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0432\u0443\u043a) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-code -actionscript.pcodehex = P-code \u0441 Hex -actionscript.hex = Hex +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-code +scripts.pcode_hex = P-code \u0441 Hex +scripts.hex = Hex dialog.title = \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_sv.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_sv.properties index f4fed4788..04b8e191b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_sv.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_sv.properties @@ -20,20 +20,20 @@ texts.plain = Oformaterad text texts.formatted = Formaterad text images = Bilder -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = Filmer movies.flv = FLV (Inget Ljud) sounds = Ljud -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (Bara ljud) -actionscript = ActionScript -actionscript.as = AS -actionscript.pcode = P-code -actionscript.pcodehex = P-code med Hex -actionscript.hex = Hex +scripts = Scripts +scripts.as = AS +scripts.pcode = P-code +scripts.pcode_hex = P-code med Hex +scripts.hex = Hex dialog.title = Exportera... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_uk.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_uk.properties index 624144883..3d70f94a6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_uk.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_uk.properties @@ -20,20 +20,20 @@ texts.plain = \u0417\u0432\u0438\u0447\u0430\u0439\u043d\u0438\u0439 \u0442\u043 texts.formatted = \u0424\u043e\u0440\u043c\u0430\u0442\u043e\u0432\u0430\u043d\u0438\u0439 \u0442\u0435\u043a\u0441\u0442 images = \u0417\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044f -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = \u0412\u0456\u0434\u0435\u043e movies.flv = FLV (\u0411\u0435\u0437 \u0437\u0432\u0443\u043a\u0443) sounds = \u0417\u0432\u0443\u043a\u0438 -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (\u041b\u0438\u0448\u0435 \u0437\u0432\u0443\u043a) -actionscript = ActionScript -actionscript.as = ActionScript -actionscript.pcode = P-\u043a\u043e\u0434 -actionscript.pcodehex = P-\u043a\u043e\u0434 \u0437 Hex -actionscript.hex = Hex +scripts = Scripts +scripts.as = ActionScript +scripts.pcode = P-\u043a\u043e\u0434 +scripts.pcode_hex = P-\u043a\u043e\u0434 \u0437 Hex +scripts.hex = Hex dialog.title = \u0415\u043a\u0441\u043f\u043e\u0440\u0442\u0443\u0432\u0430\u0442\u0438... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_zh.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_zh.properties index c93dddff5..aa3d71fa2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_zh.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ExportDialog_zh.properties @@ -20,18 +20,18 @@ texts.plain = \u7eaf\u6587\u672c texts.formatted = \u683c\u5f0f\u5316\u7684\u6587\u672c images = \u56fe\u7247 -images.pngjpeg = PNG/JPEG +images.png_jpeg = PNG/JPEG movies = \u5f71\u7247 movies.flv = FLV (\u65e0\u97f3\u9891) sounds = \u58f0\u97f3 -sounds.mp3wavflv = MP3/WAV/FLV +sounds.mp3_wav_flv = MP3/WAV/FLV sounds.flv = FLV (\u4ec5\u97f3\u9891) -actionscript = \u811a\u672c -actionscript.as = AS -actionscript.pcode = PCODE +scripts = \u811a\u672c +scripts.as = ActionScript +scripts.pcode = PCODE dialog.title = \u8f93\u51fa... diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index fa7302bc5..a598c8f81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.Point; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; @@ -40,7 +41,6 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Cache; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; @@ -146,7 +146,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { * @throws java.lang.InterruptedException */ @Override - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { if (actions == null) { actions = getActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java index 6fcb4f0cc..ff6465ef7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.sound.MP3FRAME; import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.helpers.Helper; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; @@ -33,8 +34,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -52,14 +51,6 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { @SWFType(value = BasicType.UB, count = 4) public int soundFormat; - public static final int FORMAT_UNCOMPRESSED_NATIVE_ENDIAN = 0; - public static final int FORMAT_ADPCM = 1; - public static final int FORMAT_MP3 = 2; - public static final int FORMAT_UNCOMPRESSED_LITTLE_ENDIAN = 3; - public static final int FORMAT_NELLYMOSER16KHZ = 4; - public static final int FORMAT_NELLYMOSER8KHZ = 5; - public static final int FORMAT_NELLYMOSER = 6; - public static final int FORMAT_SPEEX = 11; @SWFType(value = BasicType.UB, count = 2) public int soundRate; @@ -124,16 +115,19 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { @Override public String getExportFormat() { - if (soundFormat == DefineSoundTag.FORMAT_MP3) { + if (soundFormat == SoundFormat.FORMAT_MP3) { return "mp3"; } - if (soundFormat == DefineSoundTag.FORMAT_ADPCM) { + if (soundFormat == SoundFormat.FORMAT_ADPCM) { return "wav"; } - if (soundFormat == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { + if (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { return "wav"; } - if (soundFormat == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + if (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + return "wav"; + } + if (soundFormat == SoundFormat.FORMAT_NELLYMOSER || soundFormat == SoundFormat.FORMAT_NELLYMOSER16KHZ || soundFormat == SoundFormat.FORMAT_NELLYMOSER8KHZ) { return "wav"; } return "flv"; @@ -194,7 +188,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { long newSoundSampleCount = -1; byte newSoundData[]; switch (newSoundFormat) { - case FORMAT_UNCOMPRESSED_LITTLE_ENDIAN: + case SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN: try (AudioInputStream audioIs = AudioSystem.getAudioInputStream(new BufferedInputStream(is))) { AudioFormat fmt = audioIs.getFormat(); newSoundType = fmt.getChannels() == 2; @@ -222,7 +216,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { return false; } break; - case FORMAT_MP3: + case SoundFormat.FORMAT_MP3: BufferedInputStream bis = new BufferedInputStream(is); loadID3v2(bis); byte mp3data[] = Helper.readStream(bis); @@ -276,7 +270,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { newSoundData = baos.toByteArray(); } catch (IOException ex) { return false; - } + } break; default: return false; @@ -311,19 +305,19 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { @Override public byte[] getRawSoundData() { - if (soundFormat == FORMAT_MP3) { + if (soundFormat == SoundFormat.FORMAT_MP3) { return Arrays.copyOfRange(soundData, 2, soundData.length - 2); } return soundData; } @Override - public int getSoundFormat() { + public int getSoundFormatId() { return soundFormat; } - + @Override - public long getTotalSoundSampleCount(){ + public long getTotalSoundSampleCount() { return soundSampleCount; } @@ -331,6 +325,11 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { public boolean getSoundSize() { return soundSize; } - - + + @Override + public SoundFormat getSoundFormat() { + final int[] rateMap = {5512, 11025, 22050, 44100}; + return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType()); + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 0ec28cd53..532a34e1e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.types.annotations.Internal; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.io.ByteArrayOutputStream; @@ -78,7 +78,7 @@ public class DoActionTag extends Tag implements ASMSource { * @throws java.lang.InterruptedException */ @Override - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { if (actions == null) { actions = getActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index dca09d927..470f7f017 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -22,13 +22,13 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.io.ByteArrayInputStream; @@ -108,7 +108,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { * @throws java.lang.InterruptedException */ @Override - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { if (actions == null) { actions = getActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java index ee43cff52..c379e5c64 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.Reserved; import com.jpexs.decompiler.flash.types.annotations.SWFType; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -78,16 +79,19 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe @Override public String getExportFormat() { - if (streamSoundCompression == DefineSoundTag.FORMAT_MP3) { + if (streamSoundCompression == SoundFormat.FORMAT_MP3) { return "mp3"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_ADPCM) { + if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) { return "wav"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { + if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { return "wav"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + return "wav"; + } + if (streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER16KHZ || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER8KHZ) { return "wav"; } return "flv"; @@ -157,7 +161,7 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe } @Override - public int getSoundFormat() { + public int getSoundFormatId() { return streamSoundCompression; } @@ -200,7 +204,7 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { for (SoundStreamBlockTag block : blocks) { - if (streamSoundCompression == DefineSoundTag.FORMAT_MP3) { + if (streamSoundCompression == SoundFormat.FORMAT_MP3) { baos.write(block.data, 4, block.data.length - 4); } else { baos.write(block.data); @@ -214,6 +218,12 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe @Override public long getTotalSoundSampleCount() { - return getBlocks().size()*streamSoundSampleCount; + return getBlocks().size() * streamSoundSampleCount; + } + + @Override + public SoundFormat getSoundFormat() { + final int[] rateMap = {5512, 11025, 22050, 44100}; + return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index 9bea81004..683858d20 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -28,16 +28,14 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.Reserved; import com.jpexs.decompiler.flash.types.annotations.SWFType; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -69,16 +67,19 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea @Override public String getExportFormat() { - if (streamSoundCompression == DefineSoundTag.FORMAT_MP3) { + if (streamSoundCompression == SoundFormat.FORMAT_MP3) { return "mp3"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_ADPCM) { + if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) { return "wav"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { + if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) { return "wav"; } - if (streamSoundCompression == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + if (streamSoundCompression == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN) { + return "wav"; + } + if (streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER16KHZ || streamSoundCompression == SoundFormat.FORMAT_NELLYMOSER8KHZ) { return "wav"; } return "flv"; @@ -153,7 +154,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea } @Override - public int getSoundFormat() { + public int getSoundFormatId() { return streamSoundCompression; } @@ -218,7 +219,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { for (SoundStreamBlockTag block : blocks) { - if (streamSoundCompression == DefineSoundTag.FORMAT_MP3) { + if (streamSoundCompression == SoundFormat.FORMAT_MP3) { baos.write(block.data, 4, block.data.length - 4); } else { baos.write(block.data); @@ -232,6 +233,12 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea @Override public long getTotalSoundSampleCount() { - return getBlocks().size()*streamSoundSampleCount; + return getBlocks().size() * streamSoundSampleCount; + } + + @Override + public SoundFormat getSoundFormat() { + final int[] rateMap = {5512, 11025, 22050, 44100}; + return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index 9a818c529..e673cbc19 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.treeitems.TreeItem; -import com.jpexs.decompiler.graph.ExportMode; import java.util.List; /** @@ -39,7 +39,7 @@ public interface ASMSource extends TreeItem { * @return ASM source * @throws java.lang.InterruptedException */ - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException; + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException; /** * Whether or not this object contains ASM source diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java index add190f22..0b9ba2f96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundTag.java @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.decompiler.flash.tags.base; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import java.io.InputStream; /** @@ -24,14 +24,26 @@ import java.io.InputStream; * @author JPEXS */ public interface SoundTag { + public String getExportFormat(); + public boolean importSupported(); + public boolean setSound(InputStream is, int newSoundFormat); + public int getSoundRate(); + public boolean getSoundType(); + public byte[] getRawSoundData(); - public int getSoundFormat(); + + public int getSoundFormatId(); + public long getTotalSoundSampleCount(); + public boolean getSoundSize(); + public String getCharacterExportFileName(); + + public SoundFormat getSoundFormat(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 91fe13f56..b15783eb5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -180,15 +180,15 @@ public class Timeline { } public List getSounds(int frame, DepthState stateUnderCursor, int mouseButton) { - List ret=new ArrayList<>(); + List ret = new ArrayList<>(); Frame fr = this.frames.get(frame); - ret.addAll(fr.sounds); + ret.addAll(fr.sounds); for (int d = this.getMaxDepth(); d >= 0; d--) { DepthState ds = fr.layers.get(d); if (ds != null) { CharacterTag c = swf.characters.get(ds.characterId); if (c instanceof Timelined) { - int dframe = ds.time % ((Timelined)c).getTimeline().frames.size(); + int dframe = ds.time % ((Timelined) c).getTimeline().frames.size(); if (c instanceof ButtonTag) { ButtonTag bt = (ButtonTag) c; dframe = ButtonTag.FRAME_UP; @@ -198,9 +198,9 @@ public class Timeline { } else { dframe = ButtonTag.FRAME_OVER; } - } + } } - ret.addAll(((Timelined)c).getTimeline().getSounds(dframe, stateUnderCursor, mouseButton)); + ret.addAll(((Timelined) c).getTimeline().getSounds(dframe, stateUnderCursor, mouseButton)); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java index 2c4ae411a..74024513a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/treenodes/TagNode.java @@ -20,11 +20,11 @@ import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Exportable; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.TranslateException; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -76,7 +76,7 @@ public class TagNode extends ContainerNode { return count; } - public static List exportNodeAS(final AbortRetryIgnoreHandler handler, final List nodeList, final String outdir, final ExportMode exportMode, final EventListener ev) throws IOException { + public static List exportNodeAS(final AbortRetryIgnoreHandler handler, final List nodeList, final String outdir, final ScriptExportMode exportMode, final EventListener ev) throws IOException { try { List result = CancellableWorker.call(new Callable>() { @@ -93,7 +93,7 @@ public class TagNode extends ContainerNode { return new ArrayList<>(); } - private static List exportNodeAS(AbortRetryIgnoreHandler handler, List nodeList, String outdir, ExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException { + private static List exportNodeAS(AbortRetryIgnoreHandler handler, List nodeList, String outdir, ScriptExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException { File dir = new File(outdir); List ret = new ArrayList<>(); if (!outdir.endsWith(File.separator)) { @@ -138,11 +138,11 @@ public class TagNode extends ContainerNode { File file = new File(f); ASMSource asm = ((ASMSource) node.item); try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) { - if (exportMode == ExportMode.HEX) { + if (exportMode == ScriptExportMode.HEX) { asm.getActionSourcePrefix(writer); asm.getActionBytesAsHex(writer); asm.getActionSourceSuffix(writer); - } else if (exportMode != ExportMode.SOURCE) { + } else if (exportMode != ScriptExportMode.AS) { asm.getActionSourcePrefix(writer); asm.getASMSource(exportMode, writer, null); asm.getActionSourceSuffix(writer); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 638541799..8bf3c7776 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.ContainerItem; @@ -28,7 +29,6 @@ import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.io.IOException; @@ -165,7 +165,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S * @throws java.lang.InterruptedException */ @Override - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { if (actions == null) { actions = getActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index bf60d89bf..78874373a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -21,13 +21,13 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; -import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.io.IOException; @@ -179,7 +179,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S * @throws java.lang.InterruptedException */ @Override - public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { + public GraphTextWriter getASMSource(ScriptExportMode exportMode, GraphTextWriter writer, List actions) throws InterruptedException { if (actions == null) { actions = getActions(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java index 122fb106b..6bc71a4c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java @@ -20,8 +20,6 @@ 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 java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -30,7 +28,7 @@ import java.io.OutputStream; * * @author JPEXS */ -public class AdpcmDecoder { +public class AdpcmDecoder extends SoundDecoder { private static final int[] indexAdjustTable2bit = { -1, 2, @@ -55,6 +53,10 @@ public class AdpcmDecoder { 27086, 29794, 32767 }; + public AdpcmDecoder(SoundFormat soundFormat) { + super(soundFormat); + } + private static class AdpcmState { public int index; @@ -200,13 +202,8 @@ public class AdpcmDecoder { return state.sample; } - public static byte[] decode(byte[] data, boolean isStereo) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - decode(new ByteArrayInputStream(data), baos, isStereo); - return baos.toByteArray(); - } - - public static void decode(InputStream is, OutputStream os, boolean is_stereo) throws IOException { + @Override + public void decode(InputStream is, OutputStream os) throws IOException { int adpcm_code_size; SWFInputStream sis = new SWFInputStream(is, SWF.DEFAULT_VERSION); SWFOutputStream sos = new SWFOutputStream(os, SWF.DEFAULT_VERSION); @@ -214,7 +211,7 @@ public class AdpcmDecoder { int bits_per_code = adpcm_code_size + 2; try { do { - if (is_stereo) { + if (soundFormat.stereo) { int initialSampleLeft = (int) sis.readSB(16); int initialIndexLeft = (int) sis.readUB(6); int initialSampleRight = (int) sis.readSB(16); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java new file mode 100644 index 000000000..11b587995 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types.sound; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javazoom.jl.decoder.Bitstream; +import javazoom.jl.decoder.BitstreamException; +import javazoom.jl.decoder.Decoder; +import javazoom.jl.decoder.DecoderException; +import javazoom.jl.decoder.Header; +import javazoom.jl.decoder.SampleBuffer; + +/** + * + * @author JPEXS + */ +public class MP3Decoder extends SoundDecoder { + + public MP3Decoder(SoundFormat soundFormat) { + super(soundFormat); + } + + @Override + public void decode(InputStream is, OutputStream os) throws IOException { + Decoder decoder = new Decoder(); + Bitstream bitstream = new Bitstream(is); + SampleBuffer buf; + while ((buf = readFrame(decoder, bitstream)) != null) { + short audio[] = buf.getBuffer(); + byte d[] = new byte[buf.getBufferLength() * 2]; + for (int i = 0; i < buf.getBufferLength(); i++) { + int s = audio[i]; + d[i * 2] = (byte) (s & 0xff); + d[i * 2 + 1] = (byte) ((s >> 8) & 0xff); + } + os.write(d); + } + } + + private SampleBuffer readFrame(Decoder decoder, Bitstream bitstream) { + try { + Header h = bitstream.readFrame(); + if (h == null) { + return null; + } + soundFormat.samplingRate = getSamplingRate(h); + soundFormat.stereo = h.mode() != Header.SINGLE_CHANNEL; + try { + SampleBuffer ret = (SampleBuffer) decoder.decodeFrame(h, bitstream); + bitstream.closeFrame(); + return ret; + } catch (DecoderException ex) { + return null; + } + } catch (BitstreamException ex) { + return null; + } + + } + + private static int getSamplingRate(Header h) { + switch (h.sample_frequency()) { + case Header.THIRTYTWO: + if (h.version() == Header.MPEG1) { + return 32000; + } else if (h.version() == Header.MPEG2_LSF) { + return 16000; + } else // SZD + { + return 8000; + } + case Header.FOURTYFOUR_POINT_ONE: + if (h.version() == Header.MPEG1) { + return 44100; + } else if (h.version() == Header.MPEG2_LSF) { + return 22050; + } else // SZD + { + return 11025; + } + case Header.FOURTYEIGHT: + if (h.version() == Header.MPEG1) { + return 48000; + } else if (h.version() == Header.MPEG2_LSF) { + return 24000; + } else // SZD + { + return 12000; + } + default: + return 0; + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java new file mode 100644 index 000000000..caca9a2e7 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types.sound; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.SWFInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import lt.dkd.nellymoser.CodecImpl; + +/** + * + * @author JPEXS + */ +public class NellyMoserDecoder extends SoundDecoder { + + public static final int NELLY_BLOCK_LEN = 64; + public static final int NELLY_BUF_LEN = 128; + public static final int NELLY_SAMPLES = 2 * NELLY_BUF_LEN; + + public NellyMoserDecoder(SoundFormat soundFormat) { + super(soundFormat); + } + + @Override + public void decode(InputStream is, OutputStream os) throws IOException { + soundFormat.stereo = false; + float audioD[] = new float[NELLY_SAMPLES]; + + final float[] state = new float[64]; + + SWFInputStream sis = new SWFInputStream(is, SWF.DEFAULT_VERSION); + while (sis.available() > 0) { + byte[] block = sis.readBytes(NELLY_BLOCK_LEN); + CodecImpl.decode(state, block, audioD); + short audio[] = new short[NELLY_SAMPLES]; + for (int i = 0; i < audioD.length; i++) { + audio[i] = (short) (audioD[i]); + } + byte d[] = new byte[audio.length * 2]; + for (int i = 0; i < audio.length; i++) { + int s = audio[i]; + d[i * 2] = (byte) (s & 0xff); + d[i * 2 + 1] = (byte) ((s >> 8) & 0xff); + } + os.write(d); + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java new file mode 100644 index 000000000..bac18b2e4 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2014 * @author JPEXS + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types.sound; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * + * @author JPEXS + */ +public class NoDecoder extends SoundDecoder { + + public NoDecoder(SoundFormat soundFormat) { + super(soundFormat); + } + + @Override + public void decode(InputStream is, OutputStream os) throws IOException { + byte buf[] = new byte[1024]; + int cnt; + while ((cnt = is.read(buf)) > 0) { + os.write(buf, 0, cnt); + } + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundDecoder.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundDecoder.java new file mode 100644 index 000000000..a6332ff8d --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundDecoder.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types.sound; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * + * @author JPEXS + */ +public abstract class SoundDecoder { + + public SoundFormat soundFormat; + + public SoundDecoder(SoundFormat soundFormat) { + this.soundFormat = soundFormat; + } + + public byte[] decode(byte[] data) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + decode(new ByteArrayInputStream(data), baos); + return baos.toByteArray(); + } + + public abstract void decode(InputStream is, OutputStream os) throws IOException; +} diff --git a/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java b/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java new file mode 100644 index 000000000..e7210160b --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.types.sound; + +import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.SourceDataLine; + +/** + * + * @author JPEXS + */ +public class SoundFormat { + + public int formatId; + public int samplingRate; + public boolean stereo; + + //int[] rateMap = {5512, 11025, 22050, 44100}; + public static final int FORMAT_UNCOMPRESSED_NATIVE_ENDIAN = 0; + public static final int FORMAT_ADPCM = 1; + public static final int FORMAT_MP3 = 2; + public static final int FORMAT_UNCOMPRESSED_LITTLE_ENDIAN = 3; + public static final int FORMAT_NELLYMOSER16KHZ = 4; + public static final int FORMAT_NELLYMOSER8KHZ = 5; + public static final int FORMAT_NELLYMOSER = 6; + public static final int FORMAT_SPEEX = 11; + + public static final int EXPORT_WAV = 0; + public static final int EXPORT_MP3 = 1; + public static final int EXPORT_FLV = 2; + + public SoundFormat() { + + } + + public int getNativeExportFormat() { + switch (formatId) { + case FORMAT_UNCOMPRESSED_NATIVE_ENDIAN: + case FORMAT_UNCOMPRESSED_LITTLE_ENDIAN: + case FORMAT_ADPCM: + return EXPORT_WAV; + case FORMAT_MP3: + return EXPORT_MP3; + case FORMAT_NELLYMOSER16KHZ: + case FORMAT_NELLYMOSER8KHZ: + case FORMAT_NELLYMOSER: + case FORMAT_SPEEX: + return EXPORT_FLV; + default: + return EXPORT_FLV; + } + } + + public SoundFormat(int formatId, int samplingRate, boolean stereo) { + this.formatId = formatId; + this.samplingRate = samplingRate; + this.stereo = stereo; + ensureFormat(); + } + + public byte[] decode(byte data[]) { + try { + return getDecoder().decode(data); + } catch (IOException ex) { + return null; + } + } + + public boolean decode(InputStream is, OutputStream os) { + try { + getDecoder().decode(is, os); + return true; + } catch (IOException ex) { + return false; + } + } + + public boolean play(byte data[]) { + return play(new ByteArrayInputStream(data)); + } + + public boolean play(InputStream is) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + if (!decode(is, baos)) { + return false; + } + + AudioFormat audioFormat = new AudioFormat(samplingRate, 16, stereo ? 2 : 1, true, false); + DataLine.Info info = new DataLine.Info(SourceDataLine.class, + audioFormat); + try (SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info)) { + line.open(audioFormat); + byte data[] = baos.toByteArray(); + line.write(data, 0, data.length); + line.drain(); + line.stop(); + return true; + } catch (LineUnavailableException ex) { + return false; + } + } + + private void ensureFormat() { + switch (formatId) { + case FORMAT_NELLYMOSER16KHZ: + samplingRate = 16000; + break; + case FORMAT_NELLYMOSER8KHZ: + samplingRate = 8000; + break; + case FORMAT_NELLYMOSER: + samplingRate = 22050; + break; + } + } + + public SoundDecoder getDecoder() { + ensureFormat(); + switch (formatId) { + case FORMAT_UNCOMPRESSED_NATIVE_ENDIAN: + case FORMAT_UNCOMPRESSED_LITTLE_ENDIAN: + return new NoDecoder(this); + case FORMAT_ADPCM: + return new AdpcmDecoder(this); + case FORMAT_MP3: + return new MP3Decoder(this); + case FORMAT_NELLYMOSER16KHZ: + return new NellyMoserDecoder(this); + case FORMAT_NELLYMOSER8KHZ: + return new NellyMoserDecoder(this); + case FORMAT_NELLYMOSER: + return new NellyMoserDecoder(this); + case FORMAT_SPEEX: + return null; //I haven't seen any Speex audio in the wild + default: + return null; + } + } + + private static void writeLE(OutputStream os, long val, int size) throws IOException { + for (int i = 0; i < size; i++) { + os.write((int) (val & 0xff)); + val >>= 8; + } + } + + public boolean createWav(InputStream is, OutputStream os) { + ensureFormat(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + decode(is, baos); + try { + createWavFromPcmData(os, samplingRate, true, stereo, baos.toByteArray()); + return true; + } catch (IOException ex) { + return false; + } + } + + public static void createWavFromPcmData(OutputStream fos, int soundRateHz, boolean sample16bit, boolean stereo, byte[] data) throws IOException { + ByteArrayOutputStream subChunk1Data = new ByteArrayOutputStream(); + int audioFormat = 1; //PCM + writeLE(subChunk1Data, audioFormat, 2); + int numChannels = stereo ? 2 : 1; + writeLE(subChunk1Data, numChannels, 2); + + int sampleRate = soundRateHz;//rateMap[soundRate]; + writeLE(subChunk1Data, sampleRate, 4); + int bitsPerSample = sample16bit ? 16 : 8; + int byteRate = sampleRate * numChannels * bitsPerSample / 8; + writeLE(subChunk1Data, byteRate, 4); + int blockAlign = numChannels * bitsPerSample / 8; + writeLE(subChunk1Data, blockAlign, 2); + writeLE(subChunk1Data, bitsPerSample, 2); + + ByteArrayOutputStream chunks = new ByteArrayOutputStream(); + chunks.write(Utf8Helper.getBytes("fmt ")); + byte[] subChunk1DataBytes = subChunk1Data.toByteArray(); + writeLE(chunks, subChunk1DataBytes.length, 4); + chunks.write(subChunk1DataBytes); + + chunks.write(Utf8Helper.getBytes("data")); + writeLE(chunks, data.length, 4); + chunks.write(data); + + fos.write(Utf8Helper.getBytes("RIFF")); + byte[] chunkBytes = chunks.toByteArray(); + writeLE(fos, 4 + chunkBytes.length, 4); + fos.write(Utf8Helper.getBytes("WAVE")); + fos.write(chunkBytes); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 0405cd3df..a61903d1c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -23,6 +23,9 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.MovieExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; @@ -56,6 +59,7 @@ import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.RemoveTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; +import com.jpexs.decompiler.flash.tags.base.SoundTag; import com.jpexs.decompiler.flash.tags.base.TextTag; import com.jpexs.decompiler.flash.tags.font.CharacterRanges; import com.jpexs.decompiler.flash.types.BUTTONCONDACTION; @@ -92,7 +96,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.decompiler.flash.types.sound.MP3FRAME; import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA; -import com.jpexs.decompiler.graph.ExportMode; +import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.helpers.SerializableImage; import com.jpexs.helpers.utf8.Utf8Helper; import java.awt.Font; @@ -1373,7 +1377,7 @@ public class XFLConverter { String exportFormat = "flv"; if (symbol instanceof SoundStreamHeadTypeTag) { SoundStreamHeadTypeTag sstream = (SoundStreamHeadTypeTag) symbol; - soundFormat = sstream.getSoundFormat(); + soundFormat = sstream.getSoundFormatId(); soundRate = sstream.getSoundRate(); soundType = sstream.getSoundType(); soundSize = sstream.getSoundSize(); @@ -1400,9 +1404,10 @@ public class XFLConverter { } int format = 0; int bits = 0; - if ((soundFormat == DefineSoundTag.FORMAT_ADPCM) - || (soundFormat == DefineSoundTag.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) - || (soundFormat == DefineSoundTag.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN)) { + if ((soundFormat == SoundFormat.FORMAT_ADPCM) + || (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN) + || (soundFormat == SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN)) { + exportFormat = "wav"; if (soundType) { //stereo format += 1; } @@ -1421,10 +1426,10 @@ public class XFLConverter { break; } } - if (soundFormat == DefineSoundTag.FORMAT_SPEEX) { + if (soundFormat == SoundFormat.FORMAT_SPEEX) { bits = 18; } - if (soundFormat == DefineSoundTag.FORMAT_ADPCM) { + if (soundFormat == SoundFormat.FORMAT_ADPCM) { SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(soundData), swf.version); exportFormat = "wav"; try { @@ -1434,7 +1439,7 @@ public class XFLConverter { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); } } - if (soundFormat == DefineSoundTag.FORMAT_MP3) { + if (soundFormat == SoundFormat.FORMAT_MP3) { exportFormat = "mp3"; if (!soundType) { //mono format += 1; @@ -1491,35 +1496,37 @@ public class XFLConverter { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); } } + SoundTag st = (SoundTag) symbol; + SoundFormat fmt = st.getSoundFormat(); byte[] data = new byte[0]; try { - data = swf.exportSound(symbol); + data = swf.exportSound(st, SoundExportMode.MP3_WAV); } catch (IOException ex) { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex); } - if (!exportFormat.equals("flv")) { //FLV import format unsupported - String symbolFile = "sound" + symbol.getCharacterId() + "." + exportFormat; - files.put(symbolFile, data); - String mediaLinkStr = ". - */ -package com.jpexs.decompiler.graph; - -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public enum ExportMode { - - // The order (or values) shoud be the same as in ExportDialog - SOURCE(0), PCODE(1), PCODEWITHHEX(2), HEX(3); - - private static final Map lookup = new HashMap<>(); - - static { - for (ExportMode s : EnumSet.allOf(ExportMode.class)) { - lookup.put(s.getCode(), s); - } - } - - private final int code; - - private ExportMode(int code) { - this.code = code; - } - - public int getCode() { - return code; - } - - public static ExportMode get(int code) { - return lookup.get(code); - } -} diff --git a/trunk/src/com/jpexs/helpers/sound/SoundPlayer.java b/trunk/src/com/jpexs/helpers/sound/SoundPlayer.java index a0673acc7..ee448903d 100644 --- a/trunk/src/com/jpexs/helpers/sound/SoundPlayer.java +++ b/trunk/src/com/jpexs/helpers/sound/SoundPlayer.java @@ -23,7 +23,7 @@ import java.io.InputStream; * @author JPEXS */ public abstract class SoundPlayer { - + protected InputStream is; protected SoundPlayer(InputStream is) { @@ -43,7 +43,5 @@ public abstract class SoundPlayer { public abstract boolean isPlaying(); public abstract long getFrameRate(); - - } diff --git a/trunk/src/com/jpexs/helpers/sound/WavPlayer.java b/trunk/src/com/jpexs/helpers/sound/WavPlayer.java index 027c3a1ee..00e946ece 100644 --- a/trunk/src/com/jpexs/helpers/sound/WavPlayer.java +++ b/trunk/src/com/jpexs/helpers/sound/WavPlayer.java @@ -91,7 +91,7 @@ public class WavPlayer extends SoundPlayer { } } catch (InterruptedException ex) { //Ignore - } + } } @Override