aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Drawing.Skia/SkiaEncoder.cs6
-rw-r--r--src/Jellyfin.Drawing/ImageProcessor.cs14
-rw-r--r--src/Jellyfin.Extensions/Json/Converters/JsonDelimitedArrayConverter.cs2
-rw-r--r--src/Jellyfin.Extensions/StreamExtensions.cs10
-rw-r--r--src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs67
5 files changed, 50 insertions, 49 deletions
diff --git a/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index 2d980db18..5a1d3dc5f 100644
--- a/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -489,10 +489,8 @@ public class SkiaEncoder : IImageEncoder
Directory.CreateDirectory(directory);
using (var outputStream = new SKFileWStream(outputPath))
{
- using (var pixmap = new SKPixmap(new SKImageInfo(width, height), saveBitmap.GetPixels()))
- {
- pixmap.Encode(outputStream, skiaOutputFormat, quality);
- }
+ using var pixmap = new SKPixmap(new SKImageInfo(width, height), saveBitmap.GetPixels());
+ pixmap.Encode(outputStream, skiaOutputFormat, quality);
}
return outputPath;
diff --git a/src/Jellyfin.Drawing/ImageProcessor.cs b/src/Jellyfin.Drawing/ImageProcessor.cs
index 4e5d3b4d5..4f16e294b 100644
--- a/src/Jellyfin.Drawing/ImageProcessor.cs
+++ b/src/Jellyfin.Drawing/ImageProcessor.cs
@@ -13,7 +13,6 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
@@ -112,10 +111,8 @@ public sealed class ImageProcessor : IImageProcessor, IDisposable
public async Task ProcessImage(ImageProcessingOptions options, Stream toStream)
{
var file = await ProcessImage(options).ConfigureAwait(false);
- using (var fileStream = AsyncFile.OpenRead(file.Path))
- {
- await fileStream.CopyToAsync(toStream).ConfigureAwait(false);
- }
+ using var fileStream = AsyncFile.OpenRead(file.Path);
+ await fileStream.CopyToAsync(toStream).ConfigureAwait(false);
}
/// <inheritdoc />
@@ -437,8 +434,13 @@ public sealed class ImageProcessor : IImageProcessor, IDisposable
=> (item.Path + image.DateModified.Ticks).GetMD5().ToString("N", CultureInfo.InvariantCulture);
/// <inheritdoc />
- public string GetImageCacheTag(BaseItem item, ChapterInfo chapter)
+ public string? GetImageCacheTag(BaseItem item, ChapterInfo chapter)
{
+ if (chapter.ImagePath is null)
+ {
+ return null;
+ }
+
return GetImageCacheTag(item, new ItemImageInfo
{
Path = chapter.ImagePath,
diff --git a/src/Jellyfin.Extensions/Json/Converters/JsonDelimitedArrayConverter.cs b/src/Jellyfin.Extensions/Json/Converters/JsonDelimitedArrayConverter.cs
index 321cfa502..17096c017 100644
--- a/src/Jellyfin.Extensions/Json/Converters/JsonDelimitedArrayConverter.cs
+++ b/src/Jellyfin.Extensions/Json/Converters/JsonDelimitedArrayConverter.cs
@@ -59,7 +59,7 @@ namespace Jellyfin.Extensions.Json.Converters
var typedValueIndex = 0;
for (var i = 0; i < stringEntries.Length; i++)
{
- if (parsedValues[i] != null)
+ if (parsedValues[i] is not null)
{
typedValues.SetValue(parsedValues[i], typedValueIndex);
typedValueIndex++;
diff --git a/src/Jellyfin.Extensions/StreamExtensions.cs b/src/Jellyfin.Extensions/StreamExtensions.cs
index 9751d9d42..182996852 100644
--- a/src/Jellyfin.Extensions/StreamExtensions.cs
+++ b/src/Jellyfin.Extensions/StreamExtensions.cs
@@ -26,10 +26,8 @@ namespace Jellyfin.Extensions
/// <returns>All lines in the stream.</returns>
public static string[] ReadAllLines(this Stream stream, Encoding encoding)
{
- using (StreamReader reader = new StreamReader(stream, encoding))
- {
- return ReadAllLines(reader).ToArray();
- }
+ using StreamReader reader = new StreamReader(stream, encoding);
+ return ReadAllLines(reader).ToArray();
}
/// <summary>
@@ -40,7 +38,7 @@ namespace Jellyfin.Extensions
public static IEnumerable<string> ReadAllLines(this TextReader reader)
{
string? line;
- while ((line = reader.ReadLine()) != null)
+ while ((line = reader.ReadLine()) is not null)
{
yield return line;
}
@@ -54,7 +52,7 @@ namespace Jellyfin.Extensions
public static async IAsyncEnumerable<string> ReadAllLinesAsync(this TextReader reader)
{
string? line;
- while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != null)
+ while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) is not null)
{
yield return line;
}
diff --git a/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs b/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs
index febe9516a..479e6ffdc 100644
--- a/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs
+++ b/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs
@@ -68,51 +68,54 @@ public static class FfProbeKeyframeExtractor
double streamDuration = 0;
double formatDuration = 0;
- while (!reader.EndOfStream)
+ using (reader)
{
- var line = reader.ReadLine().AsSpan();
- if (line.IsEmpty)
+ while (!reader.EndOfStream)
{
- continue;
- }
+ var line = reader.ReadLine().AsSpan();
+ if (line.IsEmpty)
+ {
+ continue;
+ }
- var firstComma = line.IndexOf(',');
- var lineType = line[..firstComma];
- var rest = line[(firstComma + 1)..];
- if (lineType.Equals("packet", StringComparison.OrdinalIgnoreCase))
- {
- // Split time and flags from the packet line. Example line: packet,7169.079000,K_
- var secondComma = rest.IndexOf(',');
- var ptsTime = rest[..secondComma];
- var flags = rest[(secondComma + 1)..];
- if (flags.StartsWith("K_"))
+ var firstComma = line.IndexOf(',');
+ var lineType = line[..firstComma];
+ var rest = line[(firstComma + 1)..];
+ if (lineType.Equals("packet", StringComparison.OrdinalIgnoreCase))
{
- if (double.TryParse(ptsTime, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var keyframe))
+ // Split time and flags from the packet line. Example line: packet,7169.079000,K_
+ var secondComma = rest.IndexOf(',');
+ var ptsTime = rest[..secondComma];
+ var flags = rest[(secondComma + 1)..];
+ if (flags.StartsWith("K_"))
{
- // Have to manually convert to ticks to avoid rounding errors as TimeSpan is only precise down to 1 ms when converting double.
- keyframes.Add(Convert.ToInt64(keyframe * TimeSpan.TicksPerSecond));
+ if (double.TryParse(ptsTime, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var keyframe))
+ {
+ // Have to manually convert to ticks to avoid rounding errors as TimeSpan is only precise down to 1 ms when converting double.
+ keyframes.Add(Convert.ToInt64(keyframe * TimeSpan.TicksPerSecond));
+ }
}
}
- }
- else if (lineType.Equals("stream", StringComparison.OrdinalIgnoreCase))
- {
- if (double.TryParse(rest, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var streamDurationResult))
+ else if (lineType.Equals("stream", StringComparison.OrdinalIgnoreCase))
{
- streamDuration = streamDurationResult;
+ if (double.TryParse(rest, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var streamDurationResult))
+ {
+ streamDuration = streamDurationResult;
+ }
}
- }
- else if (lineType.Equals("format", StringComparison.OrdinalIgnoreCase))
- {
- if (double.TryParse(rest, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var formatDurationResult))
+ else if (lineType.Equals("format", StringComparison.OrdinalIgnoreCase))
{
- formatDuration = formatDurationResult;
+ if (double.TryParse(rest, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var formatDurationResult))
+ {
+ formatDuration = formatDurationResult;
+ }
}
}
- }
- // Prefer the stream duration as it should be more accurate
- var duration = streamDuration > 0 ? streamDuration : formatDuration;
+ // Prefer the stream duration as it should be more accurate
+ var duration = streamDuration > 0 ? streamDuration : formatDuration;
- return new KeyframeData(TimeSpan.FromSeconds(duration).Ticks, keyframes);
+ return new KeyframeData(TimeSpan.FromSeconds(duration).Ticks, keyframes);
+ }
}
}