Skip to content

Commit a602fd7

Browse files
JustAMandmitrylyzo
authored andcommitted
Add option to disable scaling altogether when height is less than hard limit
Cherry-picked from: jellyfin@bcf4b5f
1 parent 35efbb9 commit a602fd7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/subtitles-octopus.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var SubtitlesOctopus = function (options) {
2020
self.libassMemoryLimit = options.libassMemoryLimit || 0; // set libass bitmap cache memory limit in MiB (approximate)
2121
self.libassGlyphLimit = options.libassGlyphLimit || 0; // set libass glyph cache memory limit in MiB (approximate)
2222
self.targetFps = options.targetFps || 30;
23-
self.prescaleTradeoff = options.prescaleTradeoff || 1.0; // render subtitles less than viewport when less than 1.0 to improve speed, render to more than 1.0 to improve quality
23+
self.prescaleTradeoff = options.prescaleTradeoff || null; // render subtitles less than viewport when less than 1.0 to improve speed, render to more than 1.0 to improve quality; set to null to disable scaling
2424
self.softHeightLimit = options.softHeightLimit || 1080; // don't apply prescaleTradeoff < 1 when viewport height is less that this limit
2525
self.hardHeightLimit = options.hardHeightLimit || 2160; // don't ever go above this limit
2626

@@ -674,7 +674,12 @@ var SubtitlesOctopus = function (options) {
674674
};
675675

676676
function _computeCanvasSize(width, height) {
677-
if (self.prescaleTradeoff > 1) {
677+
if (self.prescaleTradeoff === null) {
678+
if (height > self.hardHeightLimit) {
679+
width = width * self.hardHeightLimit / height;
680+
height = self.hardHeightLimit;
681+
}
682+
} else if (self.prescaleTradeoff > 1) {
678683
if (height * self.prescaleTradeoff <= self.softHeightLimit) {
679684
width *= self.prescaleTradeoff;
680685
height *= self.prescaleTradeoff;

0 commit comments

Comments
 (0)