From 714dd8761ce9024e5d73c2e3b761bcbf1063bb96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 16 Nov 2025 22:29:18 +0100 Subject: [PATCH] Removed resampling from CLI and all source code Frames with streamed sound are not taken as same. --- CHANGELOG.md | 3 ++ .../src/com/jpexs/decompiler/flash/SWF.java | 10 ++--- .../flash/configuration/Configuration.java | 3 ++ .../flash/exporters/SoundExporter.java | 10 ++--- .../exporters/script/AS3ScriptExporter.java | 2 +- .../settings/ScriptExportSettings.java | 7 +--- .../settings/SoundExportSettings.java | 9 +--- .../swf/SwfFlashDevelopExporter.java | 2 +- .../swf/SwfIntelliJIdeaExporter.java | 2 +- .../exporters/swf/SwfVsCodeExporter.java | 2 +- .../flash/flexsdk/MxmlcAs3ScriptReplacer.java | 2 +- .../flash/importers/AS3ScriptImporter.java | 2 +- .../decompiler/flash/timeline/Timeline.java | 7 +++- .../flash/types/sound/SoundFormat.java | 7 ++-- .../types/sound/SoundInfoSoundCacheEntry.java | 10 +---- .../decompiler/flash/xfl/XFLConverter.java | 4 +- .../jpexs/decompiler/flash/ExportTest.java | 2 +- .../console/CommandLineArgumentParser.java | 11 ++--- .../decompiler/flash/gui/ExportDialog.java | 28 ++----------- .../decompiler/flash/gui/ImagePanel.java | 10 +---- .../jpexs/decompiler/flash/gui/MainPanel.java | 14 +++---- .../decompiler/flash/gui/SoundTagPlayer.java | 42 ++++++------------- .../flash/gui/player/MediaDisplay.java | 2 - .../flash/gui/player/PlayerControls.java | 21 +--------- 24 files changed, 67 insertions(+), 145 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c558f55b..0ba1211a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ All notable changes to this project will be documented in this file. ### Changed - Simple editor uses percent as units for filter strength +### Removed +- Removed resampling from CLI and all source code + ## [24.1.0] - 2025-09-28 ### Added - [#2477] Option to disable AS2 detection of uninitialized class fields diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 3b5669fe2..e8dc5f63d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -4493,11 +4493,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * * @param soundInfo Sound info * @param soundTag Sound tag - * @param resample Resample to 44kHz? * @param data Byte data */ - public void putToCache(SOUNDINFO soundInfo, SoundTag soundTag, boolean resample, byte[] data) { - SoundInfoSoundCacheEntry key = new SoundInfoSoundCacheEntry(soundInfo, soundTag, resample); + public void putToCache(SOUNDINFO soundInfo, SoundTag soundTag, byte[] data) { + SoundInfoSoundCacheEntry key = new SoundInfoSoundCacheEntry(soundInfo, soundTag); soundCache.put(key, data); } @@ -4720,11 +4719,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * * @param soundInfo Sound info * @param soundTag Sound tag - * @param resample Resample to 44kHz * @return Byte data */ - public byte[] getFromCache(SOUNDINFO soundInfo, SoundTag soundTag, boolean resample) { - SoundInfoSoundCacheEntry key = new SoundInfoSoundCacheEntry(soundInfo, soundTag, resample); + public byte[] getFromCache(SOUNDINFO soundInfo, SoundTag soundTag) { + SoundInfoSoundCacheEntry key = new SoundInfoSoundCacheEntry(soundInfo, soundTag); if (soundCache.contains(key)) { return soundCache.get(key); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 39e338ed2..a7ea8ee6e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -48,6 +48,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import jdk.jfr.internal.RemoveFields; /** * Configuration of FFDec. @@ -1003,10 +1004,12 @@ public final class Configuration { @ConfigurationDefaultBoolean(false) @ConfigurationCategory("export") + @ConfigurationRemoved public static ConfigurationItem lastExportResampleWav = null; @ConfigurationDefaultBoolean(true) @ConfigurationCategory("display") + @ConfigurationRemoved public static ConfigurationItem previewResampleSound = null; @ConfigurationDefaultBoolean(false) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java index c8a02b2ad..3b6716ad9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java @@ -118,7 +118,7 @@ public class SoundExporter { final File file = new File(outdir + File.separator + Helper.makeFileName(st.getCharacterExportFileName()) + ext); new RetryTask(() -> { try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - exportSound(os, st, settings.mode, settings.resampleWav); + exportSound(os, st, settings.mode); } }, handler).run(); @@ -152,13 +152,13 @@ public class SoundExporter { return ret; } - public byte[] exportSound(SoundTag t, SoundExportMode mode, boolean resampleWav) throws IOException { + public byte[] exportSound(SoundTag t, SoundExportMode mode) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - exportSound(baos, t, mode, resampleWav); + exportSound(baos, t, mode); return baos.toByteArray(); } - public void exportSound(OutputStream fos, SoundTag st, SoundExportMode mode, boolean resampleWav) throws IOException { + public void exportSound(OutputStream fos, SoundTag st, SoundExportMode mode) throws IOException { SoundFormat fmt = st.getSoundFormat(); SoundExportFormat nativeFormat = fmt.getNativeExportFormat(); @@ -202,7 +202,7 @@ public class SoundExporter { } } else { List soundData = st.getRawSoundData(); - fmt.createWav(null, soundData, fos, st.getInitialLatency(), resampleWav); + fmt.createWav(null, soundData, fos, st.getInitialLatency()); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index b330370d9..65fd55689 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -651,7 +651,7 @@ public class AS3ScriptExporter { return ret; } SoundExporter se = new SoundExporter(); - se.exportSounds(handler, ASSETS_DIR, rttl, new SoundExportSettings(SoundExportMode.MP3_WAV, exportSettings.resampleWav), evl); + se.exportSounds(handler, ASSETS_DIR, rttl, new SoundExportSettings(SoundExportMode.MP3_WAV), evl); if (CancellableWorker.isInterrupted()) { return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java index 0b569c1a8..4bcc02ab0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/ScriptExportSettings.java @@ -95,10 +95,9 @@ public class ScriptExportSettings implements Cloneable { boolean singleFile, boolean ignoreFrameScripts, boolean exportEmbed, - boolean exportEmbedFlaMode, - boolean resampleWav + boolean exportEmbedFlaMode ) { - this(mode, singleFile, ignoreFrameScripts, exportEmbed, exportEmbedFlaMode, resampleWav, "/_assets/", false, false); + this(mode, singleFile, ignoreFrameScripts, exportEmbed, exportEmbedFlaMode, "/_assets/", false, false); } public ScriptExportSettings( @@ -107,7 +106,6 @@ public class ScriptExportSettings implements Cloneable { boolean ignoreFrameScripts, boolean exportEmbed, boolean exportEmbedFlaMode, - boolean resampleWav, String assetsDir, boolean includeAllClasses, boolean ignoreAccessibility @@ -117,7 +115,6 @@ public class ScriptExportSettings implements Cloneable { this.ignoreFrameScripts = ignoreFrameScripts; this.exportEmbed = exportEmbed; this.exportEmbedFlaMode = exportEmbedFlaMode; - this.resampleWav = resampleWav; this.assetsDir = assetsDir; this.includeAllClasses = includeAllClasses; this.ignoreAccessibility = ignoreAccessibility; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java index df0692739..7c4b641bd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/settings/SoundExportSettings.java @@ -35,18 +35,13 @@ public class SoundExportSettings { */ public SoundExportMode mode; - /** - * Resample WAV - */ - public boolean resampleWav; - + /** * Constructor. * @param mode Mode * @param resampleWav Resample WAV */ - public SoundExportSettings(SoundExportMode mode, boolean resampleWav) { + public SoundExportSettings(SoundExportMode mode) { this.mode = mode; - this.resampleWav = resampleWav; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java index 96a229b26..467236099 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfFlashDevelopExporter.java @@ -343,7 +343,7 @@ public class SwfFlashDevelopExporter { } boolean parallel = Configuration.parallelSpeedUp.get(); - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, false, "/_assets/", Configuration.linkAllClasses.get(), false); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, "/_assets/", Configuration.linkAllClasses.get(), false); swf.exportActionScript(handler, outFile.toPath().getParent().resolve(srcPath).toFile().getAbsolutePath(), scriptExportSettings, parallel, eventListener); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java index 27c409cbb..5b15e26ac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfIntelliJIdeaExporter.java @@ -315,7 +315,7 @@ public class SwfIntelliJIdeaExporter { } boolean parallel = Configuration.parallelSpeedUp.get(); - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, false, "/_assets/", Configuration.linkAllClasses.get(), false); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, "/_assets/", Configuration.linkAllClasses.get(), false); swf.exportActionScript(handler, new File(outDir, "src").getAbsolutePath(), scriptExportSettings, parallel, eventListener); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java index 505d97877..b9550d690 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfVsCodeExporter.java @@ -411,7 +411,7 @@ public class SwfVsCodeExporter { libsDir.mkdirs(); boolean parallel = Configuration.parallelSpeedUp.get(); - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, false, "/_assets/", Configuration.linkAllClasses.get(), false); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, false, true, false, "/_assets/", Configuration.linkAllClasses.get(), false); swf.exportActionScript(handler, srcDir.getAbsolutePath(), scriptExportSettings, parallel, eventListener); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java index 1cfc49497..52f47ff45 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java @@ -328,7 +328,7 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl //This compiled code won't be used at all in original SWF, //it is used only by Flex to properly compile current script AS3ScriptExporter ex = new AS3ScriptExporter(); - ex.exportActionScript3(swfCopy, null, tempDir.getAbsolutePath(), removedPacks, new ScriptExportSettings(ScriptExportMode.AS_METHOD_STUBS, false, false, false /* ??? FIXME */, false, true), false, null); + ex.exportActionScript3(swfCopy, null, tempDir.getAbsolutePath(), removedPacks, new ScriptExportSettings(ScriptExportMode.AS_METHOD_STUBS, false, false, false /* ??? FIXME */, false), false, null); //now really remove the classes from SWF copy for (ABC a : modAbcs) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/AS3ScriptImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/AS3ScriptImporter.java index 8229d92c4..d02d0ba4b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/AS3ScriptImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/AS3ScriptImporter.java @@ -83,7 +83,7 @@ public class AS3ScriptImporter { continue; } try { - File file = pack.getExportFile(scriptsFolder, new ScriptExportSettings(ScriptExportMode.AS, false, false, false, false, true)); + File file = pack.getExportFile(scriptsFolder, new ScriptExportSettings(ScriptExportMode.AS, false, false, false, false)); if (file.exists()) { Openable openable = pack.getOpenable(); SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index ff1218d14..170f8c604 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -2197,6 +2197,11 @@ public class Timeline { */ public boolean isSingleFrame(int frame) { Frame frameObj = getFrame(frame); + for (int i = 0; i < frameObj.innerTags.size(); i++) { + if (frameObj.innerTags.get(i) instanceof SoundStreamBlockTag) { + return false; + } + } for (int i = 0; i <= maxDepth; i++) { if (!frameObj.layers.containsKey(i)) { continue; @@ -2217,7 +2222,7 @@ public class Timeline { if (!drawable.isSingleFrame()) { return false; } - } + } } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java index a8994f7a1..8c5ce6fca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java @@ -296,7 +296,7 @@ public class SoundFormat { return baosResampled.toByteArray(); } - public boolean createWav(SOUNDINFO soundInfo, List dataRanges, OutputStream os, int skipSamples, boolean resample) throws IOException { + public boolean createWav(SOUNDINFO soundInfo, List dataRanges, OutputStream os, int skipSamples) throws IOException { byte[] decodedData = decode(soundInfo, dataRanges, skipSamples); boolean convertedStereo = stereo; @@ -351,10 +351,9 @@ public class SoundFormat { convertedStereo = true; } - byte[] resampled = resample ? resample(baosFiltered.toByteArray()) : baosFiltered.toByteArray(); - + try { - createWavFromPcmData(os, resample ? 44100 : samplingRate, true, convertedStereo, resampled); + createWavFromPcmData(os, samplingRate, true, convertedStereo, baosFiltered.toByteArray()); return true; } catch (IOException ex) { return false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundInfoSoundCacheEntry.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundInfoSoundCacheEntry.java index 97503733e..1bdfecd3a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundInfoSoundCacheEntry.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundInfoSoundCacheEntry.java @@ -29,12 +29,10 @@ public class SoundInfoSoundCacheEntry { public SOUNDINFO soundInfo; public SoundTag soundTag; - public boolean resample; - - public SoundInfoSoundCacheEntry(SOUNDINFO soundInfo, SoundTag soundTag, boolean resample) { + + public SoundInfoSoundCacheEntry(SOUNDINFO soundInfo, SoundTag soundTag) { this.soundInfo = soundInfo; this.soundTag = soundTag; - this.resample = resample; } @Override @@ -42,7 +40,6 @@ public class SoundInfoSoundCacheEntry { int hash = 7; hash = 97 * hash + Objects.hashCode(this.soundInfo); hash = 97 * hash + Objects.hashCode(this.soundTag); - hash = 97 * hash + (this.resample ? 1 : 0); return hash; } @@ -58,9 +55,6 @@ public class SoundInfoSoundCacheEntry { return false; } final SoundInfoSoundCacheEntry other = (SoundInfoSoundCacheEntry) obj; - if (this.resample != other.resample) { - return false; - } if (!Objects.equals(this.soundInfo, other.soundInfo)) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 59e3574b2..5095e300f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -2031,7 +2031,7 @@ public class XFLConverter { SoundTag st = (SoundTag) symbol; byte[] data = SWFInputStream.BYTE_ARRAY_EMPTY; try { - data = new SoundExporter().exportSound(st, convertMp3ToWav ? SoundExportMode.WAV : SoundExportMode.MP3_WAV, false); + data = new SoundExporter().exportSound(st, convertMp3ToWav ? SoundExportMode.WAV : SoundExportMode.MP3_WAV); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } @@ -6157,7 +6157,7 @@ public class XFLConverter { } if (useAS3 && settings.exportScript) { try { - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, true, false, true, true, "/_assets/", Configuration.linkAllClasses.get(), true); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, true, false, true, "/_assets/", Configuration.linkAllClasses.get(), true); swf.exportActionScript(handler, scriptsDir.getAbsolutePath(), scriptExportSettings, parallel, null); } catch (Exception ex) { logger.log(Level.SEVERE, "Error during ActionScript3 export", ex); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java index e8eae230d..04d2cc15e 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ExportTest.java @@ -108,7 +108,7 @@ public class ExportTest extends FileTestBase { return this; } - }, fdir.getAbsolutePath(), new ScriptExportSettings(exportMode, false, false, false, false, true), false, null); + }, fdir.getAbsolutePath(), new ScriptExportSettings(exportMode, false, false, false, false), false, null); } catch (Exception ex) { fail("Exception during decompilation: " + filePath + " " + ex.getMessage()); } diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 88c602015..8cbb82c12 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -510,7 +510,6 @@ public class CommandLineArgumentParser { boolean cliMode = false; boolean air = false; boolean exportEmbed = false; - boolean resampleWav = false; boolean transparentBackground = false; Selection selection = new Selection(); Selection selectionIds = new Selection(); @@ -549,9 +548,6 @@ public class CommandLineArgumentParser { case "-exportembed": exportEmbed = true; break; - case "-resamplewav": - resampleWav = true; - break; case "-ignorebackground": transparentBackground = true; break; @@ -681,7 +677,7 @@ public class CommandLineArgumentParser { } else if (command.equals("proxy")) { parseProxy(args); } else if (command.equals("export")) { - parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom, charset, exportEmbed, resampleWav, transparentBackground, urlResolver, subLength); + parseExport(selectionClasses, selection, selectionIds, args, handler, traceLevel, format, zoom, charset, exportEmbed, transparentBackground, urlResolver, subLength); System.exit(0); } else if (command.equals("compress")) { parseCompress(args); @@ -2121,7 +2117,6 @@ public class CommandLineArgumentParser { double zoom, String charset, boolean exportEmbed, - boolean resampleWav, boolean transparentBackground, UrlResolver urlResolver, int subFrameLength) { @@ -2321,7 +2316,7 @@ public class CommandLineArgumentParser { if (exportAll || exportFormats.contains("sound")) { System.out.println("Exporting sounds..."); - new SoundExporter().exportSounds(handler, outDir + (multipleExportTypes ? File.separator + SoundExportSettings.EXPORT_FOLDER_NAME : ""), new ReadOnlyTagList(extags), new SoundExportSettings(enumFromStr(formats.get("sound"), SoundExportMode.class), resampleWav), evl); + new SoundExporter().exportSounds(handler, outDir + (multipleExportTypes ? File.separator + SoundExportSettings.EXPORT_FOLDER_NAME : ""), new ReadOnlyTagList(extags), new SoundExportSettings(enumFromStr(formats.get("sound"), SoundExportMode.class)), evl); } if (exportAll || exportFormats.contains("binarydata")) { @@ -2395,7 +2390,7 @@ public class CommandLineArgumentParser { singleScriptFile = false; } - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(enumFromStr(formats.get("script"), ScriptExportMode.class), singleScriptFile, false, exportEmbed, false, resampleWav); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(enumFromStr(formats.get("script"), ScriptExportMode.class), singleScriptFile, false, exportEmbed, false); boolean exportAllScript = exportAll || exportFormats.contains("script"); boolean exportAs2Script = exportAllScript || exportFormats.contains("script_as2"); boolean exportAs3Script = exportAllScript || exportFormats.contains("script_as3"); diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index 8692d2832..0a778f639 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -154,9 +154,7 @@ public class ExportDialog extends AppDialog { private JTextField zoomTextField = new JTextField(4); private JCheckBox embedCheckBox; - - private JCheckBox resampleWavCheckBox; - + private JCheckBox transparentFrameBackgroundCheckBox; @SuppressWarnings("unchecked") @@ -182,11 +180,7 @@ public class ExportDialog extends AppDialog { public boolean isEmbedEnabled() { return embedCheckBox.isSelected(); - } - - public boolean isResampleWavEnabled() { - return resampleWavCheckBox.isSelected(); - } + } public boolean isTransparentFrameBackgroundEnabled() { return transparentFrameBackgroundCheckBox.isSelected(); @@ -217,9 +211,6 @@ public class ExportDialog extends AppDialog { if (embedCheckBox.isVisible()) { Configuration.lastExportEnableEmbed.set(embedCheckBox.isSelected()); } - if (resampleWavCheckBox.isVisible()) { - Configuration.lastExportResampleWav.set(resampleWavCheckBox.isSelected()); - } if (transparentFrameBackgroundCheckBox.isVisible()) { Configuration.lastExportTransparentBackground.set(transparentFrameBackgroundCheckBox.isSelected()); } @@ -410,20 +401,7 @@ public class ExportDialog extends AppDialog { if (Configuration.lastExportEnableEmbed.get()) { embedCheckBox.setSelected(true); } - } - - resampleWavCheckBox = new JCheckBox(translate("resampleWav")); - resampleWavCheckBox.setVisible(false); - - if (embedCheckBox.isVisible() || visibleOptionClasses.contains(SoundExportMode.class)) { - /*gbc.gridy++; - resampleWavCheckBox.setVisible(true); - comboPanel.add(resampleWavCheckBox, gbc); - if (Configuration.lastExportResampleWav.get()) { - resampleWavCheckBox.setSelected(true); - }*/ - resampleWavCheckBox.setSelected(false); - } + } transparentFrameBackgroundCheckBox = new JCheckBox(translate("transparentFrameBackground")); transparentFrameBackgroundCheckBox.setVisible(false); diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index eb67ba58b..5a36ae5ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -290,8 +290,6 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private boolean muted = false; - private boolean resample = false; - private boolean mutable = false; private boolean alwaysDisplay = false; @@ -1026,11 +1024,6 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } - @Override - public void setResample(boolean resample) { - this.resample = resample; - } - private static void drawGridSwf(Graphics2D g, Rectangle realRect, double zoom) { g.setColor(Configuration.gridColor.get()); double x; @@ -4788,7 +4781,6 @@ public final class ImagePanel extends JPanel implements MediaDisplay { this.frozen = frozen; this.frozenButtons = frozenButtons; this.muted = muted; - this.resample = false; //Configuration.previewResampleSound.get(); this.mutable = mutable; depthStateUnderCursor = null; hilightedEdge = null; @@ -5986,7 +5978,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { loopCount = Math.max(1, soundInfo.loopCount); } - sp = new SoundTagPlayer(soundInfo, st, loopCount, false, resample); + sp = new SoundTagPlayer(soundInfo, st, loopCount, false); sp.addEventListener(new MediaDisplayListener() { @Override public void mediaDisplayStateChanged(MediaDisplay source) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 1cfa3b6ce..593e0e694 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2298,7 +2298,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (export.isOptionEnabled(SoundExportMode.class)) { ret.addAll(new SoundExporter().exportSounds(handler, selFile2 + File.separator + SoundExportSettings.EXPORT_FOLDER_NAME, sounds, - new SoundExportSettings(export.getValue(SoundExportMode.class), export.isResampleWavEnabled()), evl)); + new SoundExportSettings(export.getValue(SoundExportMode.class)), evl)); } if (export.isOptionEnabled(BinaryDataExportMode.class)) { @@ -2362,7 +2362,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se singleScriptFile = false; } - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false, export.isResampleWavEnabled()); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false); String singleFileName = Path.combine(scriptsFolder, openable.getShortFileName() + scriptExportSettings.getFileExtension()); try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) { scriptExportSettings.singleFileWriter = writer; @@ -2416,7 +2416,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (export.isOptionEnabled(SoundExportMode.class)) { new SoundExporter().exportSounds(handler, Path.combine(selFile, SoundExportSettings.EXPORT_FOLDER_NAME), swf.getTags(), - new SoundExportSettings(export.getValue(SoundExportMode.class), export.isResampleWavEnabled()), evl); + new SoundExportSettings(export.getValue(SoundExportMode.class)), evl); } if (export.isOptionEnabled(BinaryDataExportMode.class)) { @@ -2469,7 +2469,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se singleScriptFile = false; } - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false, export.isResampleWavEnabled()); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(export.getValue(ScriptExportMode.class), singleScriptFile, false, export.isEmbedEnabled(), false); String singleFileName = Path.combine(scriptsFolder, swf.getShortFileName() + scriptExportSettings.getFileExtension()); try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) { scriptExportSettings.singleFileWriter = writer; @@ -2519,7 +2519,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (export.isOptionEnabled(SoundExportMode.class)) { for (SoundExportMode exportMode : SoundExportMode.values()) { new SoundExporter().exportSounds(handler, Path.combine(selFile, SoundExportSettings.EXPORT_FOLDER_NAME, exportMode.name()), swf.getTags(), - new SoundExportSettings(exportMode, export.isResampleWavEnabled()), evl); + new SoundExportSettings(exportMode), evl); } } @@ -2586,7 +2586,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se singleScriptFile = false; } - ScriptExportSettings scriptExportSettings = new ScriptExportSettings(exportMode, singleScriptFile, false, export.isEmbedEnabled(), false, export.isResampleWavEnabled()); + ScriptExportSettings scriptExportSettings = new ScriptExportSettings(exportMode, singleScriptFile, false, export.isEmbedEnabled(), false); String singleFileName = Path.combine(scriptsFolder, swf.getShortFileName() + scriptExportSettings.getFileExtension()); try (FileTextWriter writer = scriptExportSettings.singleFile ? new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(singleFileName)) : null) { scriptExportSettings.singleFileWriter = writer; @@ -6187,7 +6187,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se previewPanel.setImageReplaceButtonVisible(false, false, false, !((SoundTag) treeItem).isReadOnly() && ((SoundTag) treeItem).importSupported(), false, false, false); if (!(treeItem instanceof SoundStreamHeadTypeTag)) { try { - SoundTagPlayer soundThread = new SoundTagPlayer(null, (SoundTag) treeItem, Configuration.loopMedia.get() ? Integer.MAX_VALUE : 1, true, false); // Configuration.previewResampleSound.get()); + SoundTagPlayer soundThread = new SoundTagPlayer(null, (SoundTag) treeItem, Configuration.loopMedia.get() ? Integer.MAX_VALUE : 1, true); if (!Configuration.autoPlaySounds.get()) { soundThread.pause(); } diff --git a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index 372cc41e5..85f5faa74 100644 --- a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -54,8 +54,6 @@ public class SoundTagPlayer implements MediaDisplay { private boolean closed = false; - private boolean resample = false; - private final Object playLock = new Object(); private final SoundTag tag; @@ -75,17 +73,13 @@ public class SoundTagPlayer implements MediaDisplay { private long lengthInMicroSec = 0; private double microsecPerByte = 0; - - private double microsecPerByteResampled = 0; - + private double positionMicrosec = 0; private Long newPositionMicrosec = null; private byte[] wavData = null; - private byte[] wavDataResampled = null; - private boolean active = false; private static int totalInstances = 0; @@ -166,7 +160,7 @@ public class SoundTagPlayer implements MediaDisplay { private static final int FRAME_DIVISOR = 8000; - public SoundTagPlayer(final SOUNDINFO soundInfo, final SoundTag tag, int loops, boolean async, boolean resample) throws LineUnavailableException, IOException, UnsupportedAudioFileException { + public SoundTagPlayer(final SOUNDINFO soundInfo, final SoundTag tag, int loops, boolean async) throws LineUnavailableException, IOException, UnsupportedAudioFileException { this.tag = tag; this.loopCount = loops; @@ -188,13 +182,11 @@ public class SoundTagPlayer implements MediaDisplay { setPausedFlag(true); } - this.resample = resample; - thread = new Thread("Sound tag player") { @Override public void run() { try { - openSound(soundInfo, tag, resample); + openSound(soundInfo, tag); } catch (IOException | LineUnavailableException | UnsupportedAudioFileException ex) { Logger.getLogger(SoundTagPlayer.class.getName()).log(Level.SEVERE, null, ex); } @@ -216,20 +208,16 @@ public class SoundTagPlayer implements MediaDisplay { thread.start(); } - private void openSound(SOUNDINFO soundInfo, SoundTag tag, boolean resample) throws IOException, LineUnavailableException, UnsupportedAudioFileException { + private void openSound(SOUNDINFO soundInfo, SoundTag tag) throws IOException, LineUnavailableException, UnsupportedAudioFileException { SWF swf = (SWF) tag.getOpenable(); - wavData = swf.getFromCache(soundInfo, tag, false); - wavDataResampled = swf.getFromCache(soundInfo, tag, true); - if (wavData == null || wavDataResampled == null) { + wavData = swf.getFromCache(soundInfo, tag); + if (wavData == null) { List soundData = tag.getRawSoundData(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - tag.getSoundFormat().createWav(soundInfo, soundData, baos, tag.getInitialLatency(), false); + tag.getSoundFormat().createWav(soundInfo, soundData, baos, tag.getInitialLatency()); wavData = baos.toByteArray(); - swf.putToCache(soundInfo, tag, false, wavData); - baos = new ByteArrayOutputStream(); - tag.getSoundFormat().createWav(soundInfo, soundData, baos, tag.getInitialLatency(), true); - wavDataResampled = baos.toByteArray(); - swf.putToCache(soundInfo, tag, true, wavDataResampled); + swf.putToCache(soundInfo, tag, wavData); + baos = new ByteArrayOutputStream(); } long soundLength44 = 0; @@ -255,7 +243,6 @@ public class SoundTagPlayer implements MediaDisplay { break; } - microsecPerByteResampled = 1000000d / (44100d * sampleLen); lengthInMicroSec = soundLength44 * 1000000 / 44100; synchronized (playLock) { @@ -300,7 +287,7 @@ public class SoundTagPlayer implements MediaDisplay { } private void reloadAudioStream() throws IOException, UnsupportedAudioFileException, LineUnavailableException { - audioStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(resample ? wavDataResampled : wavData)); + audioStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(wavData)); if (sourceLine != null) { sourceLine.drain(); @@ -330,7 +317,7 @@ public class SoundTagPlayer implements MediaDisplay { } if (!getPausedFlag()) { if (newPositionMicrosec != null) { - long newPosBytes = (long) (newPositionMicrosec / (resample ? microsecPerByteResampled : microsecPerByte)); + long newPosBytes = (long) (newPositionMicrosec / microsecPerByte); audioStream.close(); reloadAudioStream(); audioStream.skip(newPosBytes); @@ -346,7 +333,7 @@ public class SoundTagPlayer implements MediaDisplay { } sourceLine.write(data, 0, numReadBytes); synchronized (playLock) { - positionMicrosec = (resample ? microsecPerByteResampled : microsecPerByte) * posBytes; + positionMicrosec = microsecPerByte * posBytes; } } } @@ -491,11 +478,6 @@ public class SoundTagPlayer implements MediaDisplay { } } - public void setResample(boolean resample) { - this.resample = resample; - rewind(); - } - @Override public void gotoFrame(int frame) { synchronized (playLock) { diff --git a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java index 476f7ae6b..712e8a47d 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java +++ b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java @@ -43,8 +43,6 @@ public interface MediaDisplay extends Closeable { public void setLoop(boolean loop); - public void setResample(boolean resample); - public void gotoFrame(int frame); public void setBackground(Color color); diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 14e2c6281..63b64a161 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -69,8 +69,6 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { private final JButton loopButton; - private final JToggleButton resampleButton; - private MediaDisplay display; private JProgressBar progress; @@ -90,9 +88,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { private static final Icon loopIcon = View.getIcon("loopon16"); private static final Icon noLoopIcon = View.getIcon("loopoff16"); - - private static final Icon resampleIcon = View.getIcon("resample16"); - + //private final JLabel percentLabel = new JLabel("100%"); private final ZoomPanel zoomPanel; @@ -293,16 +289,9 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { boolean loop = Configuration.loopMedia.get(); loopButton.setIcon(loop ? loopIcon : noLoopIcon); - resampleButton = new JToggleButton(resampleIcon); - resampleButton.setToolTipText(AppStrings.translate("preview.resample")); - resampleButton.setMargin(new Insets(4, 2, 2, 2)); - resampleButton.addActionListener(this::resampleButtonActionPerformed); - resampleButton.setSelected(false); //Configuration.previewResampleSound.get()); - buttonsPanel.add(pauseButton); buttonsPanel.add(stopButton); buttonsPanel.add(loopButton); - //buttonsPanel.add(resampleButton); controlPanel.add(buttonsPanel, BorderLayout.CENTER); progress = new JProgressBar(); @@ -443,13 +432,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { loopButton.setIcon(loop ? loopIcon : noLoopIcon); display.setLoop(loop); } - - private void resampleButtonActionPerformed(ActionEvent evt) { - boolean resample = resampleButton.isSelected(); - Configuration.previewResampleSound.set(resample); - display.setResample(resample); - } - + private void gotoFrameButtonActionPerformed(ActionEvent evt) { final JPanel gotoPanel = new JPanel(new BorderLayout()); final JTextField frameField = new JTextField("" + display.getCurrentFrame());