Skip to content

Commit

Permalink
Support More Resolutions & Improved Defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberbeing committed Apr 13, 2014
1 parent b7d1c7d commit 4032164
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>jar</packaging>

<name>BDSup2Sub</name>
<version>5.2.0-SNAPSHOT</version>
<version>5.2.0-Custom</version>
<url>https://github.com/mjuhasz/BDSup2Sub</url>

<properties>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/bdsup2sub/BDSup2Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,24 @@ private void processFrameRate() {
switch(options.getResolution().get()) {
case PAL: configuration.setFpsTrg(Framerate.PAL.getValue()); break;
case NTSC: configuration.setFpsTrg(Framerate.NTSC.getValue()); break;
case SD_720x404: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x528: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x533: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x534: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x536: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x544: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x545: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x576: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x688: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1280x692: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_720: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1440x1080: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x800: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x816: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x817: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x864: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x1038: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1920x1040: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
case HD_1080: configuration.setFpsTrg(Framerate.FPS_23_976.getValue()); break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bdsup2sub/cli/CommandLineOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void createAndAddOptions() {
Option resolution = OptionBuilder
.withArgName("resolution")
.withLongOpt("resolution")
.withDescription("Set resolution to: keep, ntsc=480, pal=576, 720p=720, 1080p=1080, 1440x1080\nDefault: keep")
.withDescription("Set resolution to: keep, ntsc=480, pal=576, 720x404, 1280x528, 1280x533, 1280x534, 1280x536, 1280x544, 1280x545, 1280x576, 1280x688, 1280x692, 720p=720, 1920x800, 1920x816, 1920x817, 1920x864, 1920x1038, 1920x1040, 1080p=1080, 1440x1080\nDefault: keep")
.hasArg().create(RESOLUTION);
options.addOption(resolution);

Expand Down
32 changes: 32 additions & 0 deletions src/main/java/bdsup2sub/cli/CommandLineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,42 @@ private void parseResolutionOption(CommandLine line) throws ParseException {
resolution = Optional.of(Resolution.PAL);
} else if (value.equalsIgnoreCase("ntsc") || value.equalsIgnoreCase("480")) {
resolution = Optional.of(Resolution.NTSC);
} else if (value.equalsIgnoreCase("720x404")) {
resolution = Optional.of(Resolution.SD_720x404);
} else if (value.equalsIgnoreCase("1280x528")) {
resolution = Optional.of(Resolution.HD_1280x528);
} else if (value.equalsIgnoreCase("1280x533")) {
resolution = Optional.of(Resolution.HD_1280x533);
} else if (value.equalsIgnoreCase("1280x534")) {
resolution = Optional.of(Resolution.HD_1280x534);
} else if (value.equalsIgnoreCase("1280x536")) {
resolution = Optional.of(Resolution.HD_1280x536);
} else if (value.equalsIgnoreCase("1280x544")) {
resolution = Optional.of(Resolution.HD_1280x544);
} else if (value.equalsIgnoreCase("1280x545")) {
resolution = Optional.of(Resolution.HD_1280x545);
} else if (value.equalsIgnoreCase("1280x576")) {
resolution = Optional.of(Resolution.HD_1280x576);
} else if (value.equalsIgnoreCase("1280x688")) {
resolution = Optional.of(Resolution.HD_1280x688);
} else if (value.equalsIgnoreCase("1280x692")) {
resolution = Optional.of(Resolution.HD_1280x692);
} else if (value.equalsIgnoreCase("720p") || value.equalsIgnoreCase("720")) {
resolution = Optional.of(Resolution.HD_720);
} else if (value.equalsIgnoreCase("1440x1080")) {
resolution = Optional.of(Resolution.HD_1440x1080);
} else if (value.equalsIgnoreCase("1920x800")) {
resolution = Optional.of(Resolution.HD_1920x800);
} else if (value.equalsIgnoreCase("1920x816")) {
resolution = Optional.of(Resolution.HD_1920x816);
} else if (value.equalsIgnoreCase("1920x817")) {
resolution = Optional.of(Resolution.HD_1920x817);
} else if (value.equalsIgnoreCase("1920x864")) {
resolution = Optional.of(Resolution.HD_1920x864);
} else if (value.equalsIgnoreCase("1920x1038")) {
resolution = Optional.of(Resolution.HD_1920x1038);
} else if (value.equalsIgnoreCase("1920x1040")) {
resolution = Optional.of(Resolution.HD_1920x1040);
} else if (value.equalsIgnoreCase("1080p") || value.equalsIgnoreCase("1080")) {
resolution = Optional.of(Resolution.HD_1080);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/bdsup2sub/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public final class Configuration {
public static final double MIN_FREE_SCALE_FACTOR = 0.5;
public static final double MAX_FREE_SCALE_FACTOR = 2.0;
public static final double DEFAULT_SOURCE_FRAMERATE = Framerate.FPS_23_976.getValue(); //TODO: dumb default
public static final double DEFAULT_TARGET_FRAMERATE = Framerate.PAL.getValue(); //TODO: dumb default
public static final Resolution DEFAULT_TARGET_RESOLUTION = Resolution.PAL; //TODO: dumb default
public static final double DEFAULT_TARGET_FRAMERATE = Framerate.FPS_23_976.getValue(); //TODO: dumb default
public static final Resolution DEFAULT_TARGET_RESOLUTION = Resolution.HD_720; //TODO: dumb default
public static final ForcedFlagState DEFAULT_FORCED_FLAG_STATE = ForcedFlagState.KEEP;
public static final int DEFAULT_ALPHA_CROP_THRESHOLD = 14;
public static final int DEFAULT_ALPHA_THRESHOLD = 80;
Expand All @@ -55,7 +55,7 @@ public final class Configuration {
public static final int DEFAULT_CROP_LINE_COUNT = 0;
//Two equal captions are merged of they are closer than 200ms (0.2*90000 = 18000)
public static final int DEFAULT_MERGE_PTS_DIFF = 18000;
public static final OutputMode DEFAULT_OUTPUT_MODE = OutputMode.VOBSUB;
public static final OutputMode DEFAULT_OUTPUT_MODE = OutputMode.BDSUP;

private boolean convertResolution = CONVERT_RESOLUTION_BY_DEFAULT;
private boolean convertFPS = CONVERT_FRAMERATE_BY_DEFAULT;
Expand Down Expand Up @@ -235,7 +235,7 @@ public void setFixZeroAlpha(boolean fixZeroAlpha) {
}

public ScalingFilter getScalingFilter() {
ScalingFilter defaultScalingFilter = ScalingFilter.BILINEAR;
ScalingFilter defaultScalingFilter = ScalingFilter.LANCZOS3;
try {
return ScalingFilter.valueOf(props.get("filter", defaultScalingFilter.name()));
} catch (IllegalArgumentException ex) {
Expand All @@ -251,7 +251,7 @@ public void setScalingFilter(ScalingFilter filter) {
* Get palette creation mode.
*/
public PaletteMode getPaletteMode() {
PaletteMode defaultPaletteMode = PaletteMode.CREATE_NEW;
PaletteMode defaultPaletteMode = PaletteMode.CREATE_DITHERED;
try {
return PaletteMode.valueOf(props.get("paletteMode", defaultPaletteMode.name()));
} catch (IllegalArgumentException ex) {
Expand Down
256 changes: 256 additions & 0 deletions src/main/java/bdsup2sub/core/Resolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,166 @@ public int[] getDimensions() {
return new int[]{720, 576};
}
},
SD_720x404 {
@Override
public String toString() {
return "404p (720x404)";
}

@Override
public String getResolutionNameForXml() {
return "720x404";
}

@Override
public int[] getDimensions() {
return new int[]{720, 404};
}
},
HD_1280x528 {
@Override
public String toString() {
return "528p (1280x528)";
}

@Override
public String getResolutionNameForXml() {
return "1280x528";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 528};
}
},
HD_1280x533 {
@Override
public String toString() {
return "533p (1280x533)";
}

@Override
public String getResolutionNameForXml() {
return "1280x533";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 533};
}
},
HD_1280x534 {
@Override
public String toString() {
return "534p (1280x534)";
}

@Override
public String getResolutionNameForXml() {
return "1280x534";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 534};
}
},
HD_1280x536 {
@Override
public String toString() {
return "536p (1280x536)";
}

@Override
public String getResolutionNameForXml() {
return "1280x536";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 536};
}
},
HD_1280x544 {
@Override
public String toString() {
return "544p (1280x544)";
}

@Override
public String getResolutionNameForXml() {
return "1280x544";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 544};
}
},
HD_1280x545 {
@Override
public String toString() {
return "545p (1280x545)";
}

@Override
public String getResolutionNameForXml() {
return "1280x545";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 545};
}
},
HD_1280x576 {
@Override
public String toString() {
return "576p (1280x576)";
}

@Override
public String getResolutionNameForXml() {
return "1280x576";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 576};
}
},
HD_1280x688 {
@Override
public String toString() {
return "688p (1280x688)";
}

@Override
public String getResolutionNameForXml() {
return "1280x688";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 688};
}
},
HD_1280x692 {
@Override
public String toString() {
return "692p (1280x692)";
}

@Override
public String getResolutionNameForXml() {
return "1280x692";
}

@Override
public int[] getDimensions() {
return new int[]{1280, 692};
}
},
HD_720 {
@Override
public String toString() {
Expand Down Expand Up @@ -80,6 +240,102 @@ public int[] getDimensions() {
return new int[]{1440, 1080};
}
},
HD_1920x800 {
@Override
public String toString() {
return "800p (1920x800)";
}

@Override
public String getResolutionNameForXml() {
return "1920x800";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 800};
}
},
HD_1920x816 {
@Override
public String toString() {
return "816p (1920x816)";
}

@Override
public String getResolutionNameForXml() {
return "1920x816";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 816};
}
},
HD_1920x817 {
@Override
public String toString() {
return "817p (1920x817)";
}

@Override
public String getResolutionNameForXml() {
return "1920x817";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 817};
}
},
HD_1920x864 {
@Override
public String toString() {
return "864p (1920x864)";
}

@Override
public String getResolutionNameForXml() {
return "1920x864";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 864};
}
},
HD_1920x1038 {
@Override
public String toString() {
return "1038p (1920x1038)";
}

@Override
public String getResolutionNameForXml() {
return "1920x1038";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 1038};
}
},
HD_1920x1040 {
@Override
public String toString() {
return "1040p (1920x1040)";
}

@Override
public String getResolutionNameForXml() {
return "1920x1040";
}

@Override
public int[] getDimensions() {
return new int[]{1920, 1040};
}
},
HD_1080 {
@Override
public String toString() {
Expand Down
Loading

0 comments on commit 4032164

Please sign in to comment.