aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs6
-rw-r--r--MediaBrowser.Model/Drawing/DrawingUtils.cs29
2 files changed, 34 insertions, 1 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index a9ab7d6db0..ab8d5dd5b2 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -1582,7 +1582,11 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!subtitleStream.IsExternal && playMethod == PlayMethod.Transcode && !transcoderSupport.CanExtractSubtitles(subtitleStream.Codec))
+ if (!subtitleStream.IsExternal
+ && playMethod == PlayMethod.Transcode
+ && !transcoderSupport.CanExtractSubtitles(subtitleStream.Codec)
+ && !subtitleStream.IsPgsSubtitleStream
+ && !subtitleStream.IsVobSubSubtitleStream)
{
continue;
}
diff --git a/MediaBrowser.Model/Drawing/DrawingUtils.cs b/MediaBrowser.Model/Drawing/DrawingUtils.cs
index 2040d26bbb..1fdd6a4a49 100644
--- a/MediaBrowser.Model/Drawing/DrawingUtils.cs
+++ b/MediaBrowser.Model/Drawing/DrawingUtils.cs
@@ -104,6 +104,35 @@ namespace MediaBrowser.Model.Drawing
}
/// <summary>
+ /// Scales a size down uniformly until it fits inside a bounding box.
+ /// Returns the original size if it already fits, so this never upscales.
+ /// </summary>
+ /// <param name="size">The size object.</param>
+ /// <param name="boundingBox">The box the result has to fit inside.</param>
+ /// <returns>A new size object, or <paramref name="size"/> if it already fits.</returns>
+ public static ImageDimensions ScaleDownToFit(ImageDimensions size, ImageDimensions boundingBox)
+ {
+ if (size.Width <= 0 || size.Height <= 0 || boundingBox.Width <= 0 || boundingBox.Height <= 0)
+ {
+ return size;
+ }
+
+ double widthRatio = size.Width / (double)boundingBox.Width;
+ double heightRatio = size.Height / (double)boundingBox.Height;
+ double scaleRatio = Math.Max(widthRatio, heightRatio);
+
+ if (scaleRatio <= 1)
+ {
+ return size;
+ }
+
+ var newWidth = Math.Clamp(Convert.ToInt32(Math.Round(size.Width / scaleRatio)), 1, boundingBox.Width);
+ var newHeight = Math.Clamp(Convert.ToInt32(Math.Round(size.Height / scaleRatio)), 1, boundingBox.Height);
+
+ return new ImageDimensions(newWidth, newHeight);
+ }
+
+ /// <summary>
/// Gets the new width.
/// </summary>
/// <param name="currentHeight">Height of the current.</param>