diff options
author | sr55 <[email protected]> | 2013-08-23 13:20:38 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-23 13:20:38 +0000 |
commit | c7dc884bbee9c87fb4e7eb974d5ee029f4c234e4 (patch) | |
tree | 9775daec15adcc3c39b957e9dd37e858b5a2cbf1 /win/CS/HandBrakeWPF/Views | |
parent | 1270ebc49fc8dc11ea509815094faacfa8338834 (diff) |
WinGui: Manually merged the QuickSync UI changes from the qsv branch to trunk
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5741 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Views')
-rw-r--r-- | win/CS/HandBrakeWPF/Views/VideoView.xaml | 75 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/VideoView.xaml.cs | 86 |
2 files changed, 134 insertions, 27 deletions
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index c4bd565c7..fffbfd0b2 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -6,7 +6,8 @@ xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
xmlns:Video="clr-namespace:HandBrakeWPF.Converters.Video"
xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
- xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d" >
+ xmlns:cal="http://www.caliburnproject.org"
+ mc:Ignorable="d" >
<UserControl.Resources>
<Converters:BooleanConverter x:Key="boolConverter" />
@@ -74,12 +75,18 @@ <StackPanel Orientation="Horizontal">
<TextBlock Text="Framerate (FPS):" VerticalAlignment="Top" Margin="0,5,0,0" Width="100"/>
<StackPanel Orientation="Vertical">
- <ComboBox Width="120" ItemsSource="{Binding Framerates}" SelectedItem="{Binding SelectedFramerate}" />
- <RadioButton Content="Constant Framerate" IsChecked="{Binding IsConstantFramerate}" Margin="0,10,0,0" />
- <RadioButton Content="Variable Framerate" IsChecked="{Binding IsVariableFramerate}" Margin="0,5,0,0"
+ <ComboBox Width="120" ItemsSource="{Binding Framerates}" SelectedItem="{Binding SelectedFramerate}"
+ Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+ <TextBlock Text="Same as source" VerticalAlignment="Center" Margin="0,5,0,0"
+ Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
+
+ <StackPanel Orientation="Vertical" Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}}">
+ <RadioButton Content="Constant Framerate" IsChecked="{Binding IsConstantFramerate}" Margin="0,10,0,0" />
+ <RadioButton Content="Variable Framerate" IsChecked="{Binding IsVariableFramerate}" Margin="0,5,0,0"
Visibility="{Binding ShowPeakFramerate, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
- <RadioButton Content="Peak Framerate" IsChecked="{Binding IsPeakFramerate}" Margin="0,5,0,0"
+ <RadioButton Content="Peak Framerate" IsChecked="{Binding IsPeakFramerate}" Margin="0,5,0,0"
Visibility="{Binding ShowPeakFramerate, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
+ </StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
@@ -89,7 +96,7 @@ <TextBlock Text="Quality" FontWeight="Bold" Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" >
- <RadioButton Content="Constant Quality:" IsChecked="{Binding IsConstantQuantity}" Margin="0,0,10,0"/>
+ <RadioButton Content="Constant Quality:" IsChecked="{Binding IsConstantQuantity}" Margin="0,0,10,0" Checked="qsv_preset_radiobutton"/>
<TextBlock Text="{Binding DisplayRF}" MinWidth="30" />
<TextBlock Text="{Binding Rfqp}" FontWeight="Bold" Margin="5,0,0,0" />
@@ -112,22 +119,21 @@ </Grid>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
- <RadioButton Content="Avg Bitrate (kbps):" IsChecked="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,10,0"/>
- <TextBox Width="75" Text="{Binding Task.VideoBitrate, UpdateSourceTrigger=PropertyChanged}"
- IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" />
+ <RadioButton Content="Avg Bitrate (kbps):" IsChecked="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,10,0" Checked="qsv_preset_radiobutton"/>
+ <TextBox Width="75" Text="{Binding Task.VideoBitrate, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}" />
</StackPanel>
- <StackPanel Orientation="Horizontal" Margin="30,0,0,0">
+ <StackPanel Orientation="Horizontal" Margin="30,0,0,0" Visibility="{Binding DisplayNonQSVControls, Converter={StaticResource boolToVisConverter}}">
<CheckBox Content="2-Pass Encoding" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}"
- IsChecked="{Binding Task.TwoPass}" Margin="0,0,10,0" />
+ IsChecked="{Binding TwoPass}" Margin="0,0,10,0" />
<CheckBox Content="Turbo first pass" IsEnabled="{Binding IsConstantQuantity, Converter={StaticResource boolConverter}, ConverterParameter=true}"
- IsChecked="{Binding Task.TurboFirstPass}" />
+ IsChecked="{Binding TurboFirstPass}" />
</StackPanel>
</StackPanel>
<!-- H264 settings -->
- <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}">
+ <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="0,20,0,0" Visibility="{Binding DisplayH264Options, Converter={StaticResource boolToVisConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -139,8 +145,7 @@ <CheckBox Content="Use Advanced Tab instead" Grid.Row="1" IsChecked="{Binding UseAdvancedTab}"
Visibility="{Binding ShowAdvancedTab, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
- <Grid Grid.Row="2" Margin="0,5,0,0" IsEnabled="{Binding UseAdvancedTab, Converter={StaticResource inverseConverter}}"
- Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}">
+ <Grid Grid.Row="2" Margin="0,5,0,0" IsEnabled="{Binding UseAdvancedTab, Converter={StaticResource inverseConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -160,22 +165,36 @@ <!-- Row 1 -->
- <TextBlock Text="x264 Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" />
- <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal">
+ <TextBlock Text="x264 Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
+ <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" >
<Slider Minimum="0" Maximum="9" Width="150" Value="{Binding X264PresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}"
IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" ToolTip="{x:Static Properties:Resources.Video_x264Preset}"
Style="{StaticResource LongToolTipHolder}" />
<TextBlock Text="{Binding X264Preset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />
</StackPanel>
- <TextBlock Text="x264 Tune:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,10,0,0" />
+ <TextBlock Text="x264 Tune:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="0,10,0,0"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
<ComboBox Width="100" Grid.Row="2" Grid.Column="1" Margin="5,10,5,0" Height="22"
- ItemsSource="{Binding X264Tunes, Converter={StaticResource enumComboConverter}}"
- SelectedItem="{Binding X264Tune, Converter={StaticResource enumComboConverter}}"
- ToolTip="{x:Static Properties:Resources.Video_x264Tune}"
- Style="{StaticResource LongToolTipHolder}" />
+ ItemsSource="{Binding X264Tunes, Converter={StaticResource enumComboConverter}}"
+ SelectedItem="{Binding X264Tune, Converter={StaticResource enumComboConverter}}"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}"
+ ToolTip="{x:Static Properties:Resources.Video_x264Tune}"
+ Style="{StaticResource LongToolTipHolder}" />
<CheckBox IsChecked="{Binding FastDecode}" Content="Fast Decode" Grid.Row="2" Grid.Column="2" Margin="10,10,10,0" VerticalAlignment="Center"
- ToolTip="{x:Static Properties:Resources.Video_x264FastDecode}"/>
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}"
+ ToolTip="{x:Static Properties:Resources.Video_x264FastDecode}"/>
+
+ <TextBlock Text="QSV Preset:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" />
+ <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal"
+ Visibility="{Binding DisplayQSVOptions, Converter={StaticResource boolToVisConverter}}" >
+ <Slider Minimum="0" Maximum="{Binding QsvSliderMax}" Width="150" Value="{Binding QsvPresetValue, Mode=Default, UpdateSourceTrigger=PropertyChanged}"
+ IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" ValueChanged="qsv_preset_ValueChanged"/>
+ <TextBlock Text="{Binding QsvPreset, Converter={StaticResource enumComboConverter}}" Margin="5,0,0,0" />
+ </StackPanel>
<!-- Row 2-->
@@ -194,13 +213,15 @@ ToolTip="{x:Static Properties:Resources.Video_x264Level}"/>
<!-- Row 3 -->
- <TextBlock Text="Extra Options:" Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
+ <TextBlock Text="Extra Options:" Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" />
<TextBox Text="{Binding ExtraArguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
- ToolTip="{Binding FullOptionsTooltip}" Style="{StaticResource LongToolTipHolder}">
+ Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
+ ToolTip="{Binding FullOptionsTooltip}" Style="{StaticResource LongToolTipHolder}"
+ Visibility="{Binding DisplayX264Options, Converter={StaticResource boolToVisConverter}}" >
<TextBox.ContextMenu>
<ContextMenu>
- <MenuItem Header="Copy Full Query" Micro:Message.Attach="[Event Click] = [Action CopyQuery]" />
+ <MenuItem Header="Copy Full Query" cal:Message.Attach="[Event Click] = [Action CopyQuery]" />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs b/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs index 8a0842a96..a285e490b 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml.cs @@ -9,8 +9,19 @@ namespace HandBrakeWPF.Views
{
+ using System.Collections.Generic;
+ using System.Windows;
using System.Windows.Controls;
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Utilities;
+ using HandBrake.Interop.Model.Encoding;
+
+ using HandBrakeWPF.ViewModels;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
/// <summary>
/// Interaction logic for VideoView.xaml
/// </summary>
@@ -23,5 +34,80 @@ namespace HandBrakeWPF.Views {
InitializeComponent();
}
+
+
+ private void qsv_preset_radiobutton(object sender, System.Windows.RoutedEventArgs e)
+ {
+ qsv_preset_ValueChanged(sender, null);
+ }
+
+ private void qsv_preset_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+ {
+ VideoViewModel mvm = ((VideoViewModel)this.DataContext);
+ EncodeTask task = mvm.Task;
+
+ string addon = "";
+
+ if (SystemInfo.IsHswOrNewer)
+ {
+ if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
+ {
+ if (task.QsvPreset == QsvPreset.Balanced ||
+ task.QsvPreset == QsvPreset.Speed)
+ addon = "num-ref-frame=1";
+ }
+ if (task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)
+ {
+ if (task.QsvPreset == QsvPreset.Quality)
+ addon = "lookahead=1:gop-ref-dist=3";
+ else
+ if (task.QsvPreset == QsvPreset.Balanced)
+ {
+ addon = "num-ref-frame=1:gop-ref-dist=1";
+ }
+ else
+ if (task.QsvPreset == QsvPreset.Speed)
+ addon = "gop-ref-dist=1";
+ }
+ }
+
+
+ string full_string = addon + ":";
+
+ IDictionary<string, string> newOptions = new Dictionary<string, string>();
+ string[] existingSegments = full_string.Split(':');
+ foreach (string existingSegment in existingSegments)
+ {
+ string optionName = existingSegment;
+ string optionValue = string.Empty;
+ int equalsIndex = existingSegment.IndexOf('=');
+ if (equalsIndex >= 0)
+ {
+ optionName = existingSegment.Substring(
+ 0, existingSegment.IndexOf("=", System.StringComparison.Ordinal));
+ optionValue = existingSegment.Substring(equalsIndex);
+ }
+
+ if (optionName != string.Empty)
+ {
+ if (newOptions.ContainsKey(optionName))
+ newOptions.Remove(optionName);
+ newOptions.Add(optionName, optionValue);
+ }
+ }
+
+ full_string = "";
+ foreach (KeyValuePair<string, string> entry in newOptions)
+ {
+ full_string += entry.Key;
+ if (entry.Value != string.Empty)
+ full_string += entry.Value;
+ full_string += ":";
+ }
+ full_string = full_string.TrimEnd(':');
+
+ task.AdvancedEncoderOptions = full_string;
+ task.NotifyOfPropertyChange(() => task.AdvancedEncoderOptions);
+ }
}
}
|