From c382d37d2c19e6d2cb466e57c1d39d83184bb619 Mon Sep 17 00:00:00 2001 From: Sep95 <32958359+Sep95@users.noreply.github.com> Date: Sat, 23 Feb 2019 09:21:04 +0100 Subject: [PATCH 1/2] Adapted VideoFormat() callback Correct video width and height according to TrackInfo --- src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs index d6d2e5d..b7207d0 100644 --- a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs +++ b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs @@ -146,6 +146,19 @@ private uint VideoFormat(out IntPtr userdata, IntPtr chroma, ref uint width, ref { var pixelFormat = IsAlphaChannelEnabled ? PixelFormats.Bgra32 : PixelFormats.Bgr32; FourCCConverter.ToFourCC("RV32", chroma); + + //Correct video width and height according to TrackInfo + var md = MediaPlayer.GetMedia(); + foreach (MediaTrack track in md.Tracks) + { + if (track.Type == MediaTrackTypes.Video) + { + var trackInfo = track.TrackInfo as VideoTrack; + width = trackInfo.Width; + height = trackInfo.Height; + break; + } + } pitches = this.GetAlignedDimension((uint)(width * pixelFormat.BitsPerPixel) / 8, 32); lines = this.GetAlignedDimension(height, 32); From 353d387b1f7722e1baf17ec7803077442139b1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Wed, 27 Feb 2019 19:36:17 +0100 Subject: [PATCH 2/2] Use the sample aspect ratio if present in the track info Fixes #386 --- src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs index b7207d0..f97d4ae 100644 --- a/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs +++ b/src/Vlc.DotNet.Wpf/VlcVideoSourceProvider.cs @@ -153,9 +153,13 @@ private uint VideoFormat(out IntPtr userdata, IntPtr chroma, ref uint width, ref { if (track.Type == MediaTrackTypes.Video) { - var trackInfo = track.TrackInfo as VideoTrack; + var trackInfo = (VideoTrack)track.TrackInfo; width = trackInfo.Width; height = trackInfo.Height; + if (trackInfo.SarDen != 0) + { + width = width * trackInfo.SarNum / trackInfo.SarDen; + } break; } }