From 3e1fabac30f194a75cb07cc65ffc35b5f299c505 Mon Sep 17 00:00:00 2001 From: Ivandro Jao Date: Tue, 30 Apr 2024 12:35:28 +0100 Subject: [PATCH] Refactor FfmpegMediaInfo to use Dimension for dimensions The properties VideoWidth and VideoHeight in FfmpegMediaInfo class have been replaced with a Dimension object. This modification leads to simpler and more readable code by encapsulating width and height information within the Dimension class. Any resolution information extracted is now directly assigned to the Dimension property. Signed-off-by: Ivandro Jao --- src/libse/Common/FfmpegMediaInfo.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libse/Common/FfmpegMediaInfo.cs b/src/libse/Common/FfmpegMediaInfo.cs index d4ff98e53..a45176794 100644 --- a/src/libse/Common/FfmpegMediaInfo.cs +++ b/src/libse/Common/FfmpegMediaInfo.cs @@ -11,8 +11,8 @@ namespace Nikse.SubtitleEdit.Core.Common public class FfmpegMediaInfo { public List Tracks { get; set; } - public int VideoWidth { get; set; } - public int VideoHeight { get; set; } + + public Dimension Dimension { get; set; } private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled); @@ -65,13 +65,12 @@ namespace Nikse.SubtitleEdit.Core.Common if (resolutionMatch.Success) { var parts = resolutionMatch.Value.Split('x'); - if (info.VideoWidth == 0 && + if (info.Dimension.Width == 0 && parts.Length == 2 && int.TryParse(parts[0], out var w) && int.TryParse(parts[1], out var h)) { - info.VideoWidth = w; - info.VideoHeight = h; + info.Dimension = new Dimension(h, w); } }