Skip to content

Commit

Permalink
Updating to v3.3.2
Browse files Browse the repository at this point in the history
Replaces deprecated SharpDX with fresh Vortice!
Adds Master.GPUAdapters and Config.Video.GPUAdapterLuid to force a specific adapter

New Pixel Shader implementation and removes old large file shaders
Adds HDR to SDR (Aces, Habble Support
Adds Brightness & Contrast (Config.Video)

-= FlyleafLib.Controls.WPF =-
Adds HDR to SDR configuration in settings
Adds Brightness and Contrast to settings
Fixes an issue with PreventAutoDispose not found
  • Loading branch information
SuRGeoNix committed Sep 5, 2021
1 parent 529f03f commit 7bb39a4
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 98 deletions.
2 changes: 1 addition & 1 deletion FlyleafLib.Controls.WPF/Flyleaf.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Grid x:Name="PART_ContextMenuOwner" ContextMenu="{StaticResource PopUpMenu}">

<!--Pop Up Dialog (Settings/Set Values)-->
<materialDesign:DialogHost x:Name="PART_DialogSettings"/>
<materialDesign:DialogHost x:Name="PART_DialogSettings" OverlayBackground="{x:Null}"/>

<!-- Error Message -->
<TextBlock Margin="0 20 20 0" VerticalAlignment="top" HorizontalAlignment="Left" TextAlignment="Left" TextWrapping="Wrap" FontSize="16" Background="Black" Foreground="DarkOrange" FontWeight="Bold" Text="{Binding ErrorMsg}"/>
Expand Down
13 changes: 12 additions & 1 deletion FlyleafLib.Controls.WPF/Flyleaf.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,27 @@ public void SetSubtitlesFontAction(object obj = null)
public async void OpenSettingsAction(object obj = null)
{
if (dialogSettingsIdentifier == null) return;

if (DialogHost.IsDialogOpen(dialogSettingsIdentifier))
{
DialogHost.Close(dialogSettingsIdentifier, "cancel");
return;
}

var prevVideoConfig = VideoConfig.Clone();

var view = new Settings();//Session);
view.DataContext = this;
var result = await DialogHost.Show(view, dialogSettingsIdentifier, view.Closing);

if (result != null && result.ToString() == "cancel")
{
VideoConfig.HDRtoSDRMethod = prevVideoConfig.HDRtoSDRMethod;
VideoConfig.HDRtoSDRTone = prevVideoConfig.HDRtoSDRTone;
VideoConfig.Contrast = prevVideoConfig.Contrast;
VideoConfig.Brightness = prevVideoConfig.Brightness;
}

view.Closed(result);
}

Expand Down
10 changes: 6 additions & 4 deletions FlyleafLib.Controls.WPF/FlyleafLib.Controls.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net5.0-windows;net472</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<Version>1.1.7</Version>
<Version>1.1.8</Version>
<Authors>SuRGeoNix</Authors>
<Copyright>SuRGeoNix © 2021</Copyright>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -13,9 +13,11 @@
<PackageIconUrl />
<PackageTags>flyleaf flyleaflib video audio media player element control</PackageTags>
<Description>WPF Media Player Control/Element (based on FlyleafLib)</Description>
<PackageReleaseNotes>Required changes for the new FlyleafLib v3.3 which supports also audio only now</PackageReleaseNotes>
<AssemblyVersion>1.1.7.0</AssemblyVersion>
<FileVersion>1.1.7.0</FileVersion>
<PackageReleaseNotes>Adds HDR to SDR configuration in settings
Adds Brightness and Contrast to settings
Fixes an issue with PreventAutoDispose not found</PackageReleaseNotes>
<AssemblyVersion>1.1.8.0</AssemblyVersion>
<FileVersion>1.1.8.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
22 changes: 21 additions & 1 deletion FlyleafLib.Controls.WPF/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:fl="clr-namespace:FlyleafLib;assembly=FlyleafLib"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
xmlns:sys="clr-namespace:System;assembly=mscorlib"

Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{materialDesign:MaterialDesignFont}"
Expand Down Expand Up @@ -53,14 +54,20 @@
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextAlignment" Value="Right"/>
</Style>

<Style x:Key="FLTextboxNP" TargetType="{x:Type TextBox}" BasedOn="{StaticResource FLTextbox}">
<EventSetter Event="PreviewTextInput" Handler="ValidationNumericPositive"/>
</Style>

<Style x:Key="FLTextboxN" TargetType="{x:Type TextBox}" BasedOn="{StaticResource FLTextbox}">
<EventSetter Event="PreviewTextInput" Handler="ValidationNumeric"/>
</Style>

<ObjectDataProvider x:Key="dataFromEnum" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="fl:HDRtoSDRMethod"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>
</UserControl.Resources>

Expand Down Expand Up @@ -217,6 +224,19 @@

<TextBlock Grid.Row="4" Text="Decoder Threads" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Style="{StaticResource FLTextboxNP}" Text="{Binding DecoderConfig.VideoThreads, UpdateSourceTrigger=Explicit}"/>

<TextBlock Grid.Row="5" Text="HDR to SDR Method" VerticalAlignment="Center"/>
<ComboBox Grid.Row="5" x:Name="cmbHDRtoSDRMethod" Grid.Column="1" ItemsSource="{Binding Source={StaticResource dataFromEnum}}" SelectedItem="{Binding VideoConfig.HDRtoSDRMethod}"/>

<TextBlock Grid.Row="6" Text="HDR to SDR Tone" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Style="{StaticResource FLTextbox}" Text="{Binding VideoConfig.HDRtoSDRTone, UpdateSourceTrigger=LostFocus}"/>

<TextBlock Grid.Row="7" Text="Brightness" Margin="0,10,0,0" VerticalAlignment="Center"/>
<Slider Grid.Row="7" Grid.Column="2" Margin="-78,10,0,0" Style="{StaticResource MaterialDesignDiscreteSlider}" Value="{Binding VideoConfig.Brightness, Mode=TwoWay}" Minimum="0" Maximum="100"/>

<TextBlock Grid.Row="8" Text="Contrast" Margin="0,10,0,0" VerticalAlignment="Center"/>
<Slider Grid.Row="8" Grid.Column="2" Margin="-78,10,0,0" Style="{StaticResource MaterialDesignDiscreteSlider}" HorizontalAlignment="Stretch" Value="{Binding VideoConfig.Contrast, Mode=TwoWay}" Minimum="0" Maximum="100"/>

</Grid>
<StackPanel Margin="0, 0, 0, 10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Button Content="Apply" FontWeight="ExtraBold" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="apply"/>
Expand Down
23 changes: 9 additions & 14 deletions FlyleafLib.Controls.WPF/Settings.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

namespace FlyleafLib.Controls.WPF
{
public partial class Settings : UserControl, INotifyPropertyChanged
{
//public Session Session { get; set; }
//public Config.Audio Audio => Session.audio;
//public Config.Subs Subs => Session.subs;
//public Config.Video Video => Session.video;
//public Config.Decoder Decoder => Session.decoder;
//public Config.Demuxer Demuxer => Session.demuxer;

public Settings()//(Session session)
{
//Session = session;
InitializeComponent();
//DataContext = this;
}

public void Closing(object sender, DialogClosingEventArgs eventArgs) { }
public void Closed(object result) { if (result != null && result.ToString() == "apply") SaveSettings(); }
public void Closed(object result)
{
if (result != null && result.ToString() == "apply")
SaveSettings();
}
public void SaveSettings() { SaveSettingsRec(tabRoot); }
public void SaveSettingsRec(Visual parent)
{
Expand Down Expand Up @@ -60,7 +56,6 @@ public void SaveSettingsRec(Visual parent)
}
}


public event PropertyChangedEventHandler PropertyChanged;
protected void Raise([CallerMemberName] string propertyName = "")
{
Expand Down
29 changes: 23 additions & 6 deletions FlyleafLib/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
using System.Xml.Serialization;

using FlyleafLib.MediaPlayer;
using static FlyleafLib.MediaFramework.MediaRenderer.Renderer;

namespace FlyleafLib
{
/// <summary>
/// Player's main configuration
/// </summary>
public class Config : NotifyPropertyChanged
public unsafe class Config : NotifyPropertyChanged
{
public Config() { }
public Config Clone()
Expand Down Expand Up @@ -330,11 +329,29 @@ public System.Windows.Media.Color
/// </summary>
public short VSync { get; set; }

/// <summary>
/// Sets the Contrast
/// </summary>
public int Contrast { get=> _Contrast; set { if (Set(ref _Contrast, value)) player?.renderer?.UpdateContrast(); } }
int _Contrast = 50;

/// <summary>
/// Sets the Brightness
/// </summary>
public int Brightness { get=> _Brightness; set { if (Set(ref _Brightness, value)) player?.renderer?.UpdateBrightness(); } }
int _Brightness = 50;

public int Contrast { get; set; } = 50;
public int Brightness { get; set; } = 50;
public PSHDR2SDRMethod HDRtoSDRMethod { get; set; } = PSHDR2SDRMethod.Hable;
public float HDRtoSDRTone { get; set; } = 1.4f;
/// <summary>
/// The HDR to SDR method that will be used by the pixel shader
/// </summary>
public HDRtoSDRMethod HDRtoSDRMethod { get => _HDRtoSDRMethod; set { if (Set(ref _HDRtoSDRMethod, value)) player?.renderer?.UpdateHDRtoSDR(); }}
HDRtoSDRMethod _HDRtoSDRMethod = HDRtoSDRMethod.Hable;

/// <summary>
/// The HDR to SDR Tone float correnction (not used by Reinhard)
/// </summary>
public float HDRtoSDRTone { get => _HDRtoSDRTone; set { if (Set(ref _HDRtoSDRTone, value)) player?.renderer?.UpdateHDRtoSDR(); } }
float _HDRtoSDRTone = 1.4f;
}
public class AudioConfig : NotifyPropertyChanged
{
Expand Down
13 changes: 9 additions & 4 deletions FlyleafLib/FlyleafLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
<PackageIconUrl />
<RepositoryUrl></RepositoryUrl>
<Description>Media Player .NET Library for WPF/WinForms (based on FFmpeg/DirectX)</Description>
<Version>3.3.1</Version>
<Version>3.3.2</Version>
<Authors>SuRGeoNix</Authors>
<Copyright>SuRGeoNix © 2021</Copyright>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/SuRGeoNix/Flyleaf</PackageProjectUrl>
<PackageTags>flyleaf flyleaflib video audio media player engine framework ffmpeg sharpdx directx</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReleaseNotes></PackageReleaseNotes>
<AssemblyVersion>3.3.1.0</AssemblyVersion>
<FileVersion>3.3.1.0</FileVersion>
<PackageReleaseNotes>Replaces deprecated SharpDX with fresh Vortice!
Adds Master.GPUAdapters and Config.Video.GPUAdapterLuid to force a specific adapter

New Pixel Shader implementation and removes old large file shaders
Adds HDR to SDR (Aces, Habble Support (still no native HDR)
Adds Brightness &amp; Contrast (Config.Video)</PackageReleaseNotes>
<AssemblyVersion>3.3.2.0</AssemblyVersion>
<FileVersion>3.3.2.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
20 changes: 20 additions & 0 deletions FlyleafLib/FlyleafLib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions FlyleafLib/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public enum MediaType
Video,
Subs
}
public enum HDRtoSDRMethod : int
{
None = 0,
Aces = 1,
Hable = 2,
Reinhard= 3
}

public struct GPUAdapter
{
Expand Down
2 changes: 1 addition & 1 deletion FlyleafLib/MediaFramework/MediaDecoder/VideoDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ internal VideoFrame ProcessVideoFrame(AVFrame* frame)
HDRDataSent = true;
AVFrameSideData* sideData = *frame->side_data;
if (sideData->type == AVFrameSideDataType.AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)
Renderer?.FrameDisplayDataChanged((AVMasteringDisplayMetadata*)sideData->data);
Renderer?.UpdateHDRtoSDR((AVMasteringDisplayMetadata*)sideData->data);
}

// Hardware Frame (NV12|P010) | CopySubresourceRegion FFmpeg Texture Array -> Device Texture[1] (NV12|P010) / SRV (RX_RXGX) -> PixelShader (Y_UV)
Expand Down
Loading

0 comments on commit 7bb39a4

Please sign in to comment.