From e6dc00a5a05c0dc72241406bdc573143a2a1faa3 Mon Sep 17 00:00:00 2001 From: stax76 Date: Mon, 24 Apr 2017 17:30:33 +0200 Subject: [PATCH] - --- Controls/CommandLineControl.vb | 13 +- Controls/MacroEditorControl.vb | 66 +++++--- Encoding/IntelEncoder.vb | 2 +- Encoding/NVIDIAEncoder.vb | 5 + Encoding/x265.vb | 24 ++- Forms/AudioForm.vb | 12 +- Forms/CommandLineForm.Designer.vb | 1 - Forms/MainForm.vb | 28 ++-- Forms/MediaInfoForm.vb | 1 - Forms/Misc Forms.vb | 12 -- Forms/x264Form.vb | 1 - General/AudioProfile.vb | 57 +++++-- General/MediaInfo.vb | 20 +++ General/Package.vb | 30 ++-- General/Scripting.vb | 18 +- My Project/AssemblyInfo.vb | 2 +- StaxRip.vbproj | 3 - UI/Controls/Controls.vb | 7 +- UI/Controls/SimpleUI.vb | 10 +- UI/Menu Types.vb | 21 +-- md/test-build.md | 13 +- x265/alt_param.cpp | 263 ++++++++++++++++++++++-------- x265/alt_x265cli.h | 40 ++++- x265/param.cpp | 23 ++- x265/x265cli.h | 14 +- 25 files changed, 455 insertions(+), 231 deletions(-) delete mode 100644 Forms/Misc Forms.vb diff --git a/Controls/CommandLineControl.vb b/Controls/CommandLineControl.vb index e90393c9..e252e448 100644 --- a/Controls/CommandLineControl.vb +++ b/Controls/CommandLineControl.vb @@ -121,18 +121,10 @@ Class CommandLineControl If Not RestoreFunc Is Nothing Then f.bnContext.Text = " Restore Defaults... " f.bnContext.Visible = True + f.bnContext.AddClickAction(Sub() If MsgOK("Restore defaults?") Then f.MacroEditorControl.Value = RestoreFunc.Invoke) + f.MacroEditorControl.rtbDefaults.Text = RestoreFunc.Invoke End If - Dim t = f - - Dim resetAction = Sub() - If MsgOK("Restore defaults?") Then - t.MacroEditorControl.Value = RestoreFunc.Invoke - End If - End Sub - - f.bnContext.AddClickAction(resetAction) - If f.ShowDialog(FindForm) = DialogResult.OK Then Presets = f.MacroEditorControl.Value.ReplaceUnicode RaiseEvent PresetsChanged(Presets) @@ -142,6 +134,7 @@ Class CommandLineControl Private Sub bCmdlAddition_Click() Handles bu.Click Dim cms = TextCustomMenu.GetMenu(Presets, bu, components, AddressOf MenuItenClick) + Me.components.Add(cms) cms.Items.Add(New ToolStripSeparator) cms.Items.Add(New ActionMenuItem("Edit Menu...", AddressOf EditPresets)) cms.Show(bu, 0, bu.Height) diff --git a/Controls/MacroEditorControl.vb b/Controls/MacroEditorControl.vb index a48c7158..bd143553 100644 --- a/Controls/MacroEditorControl.vb +++ b/Controls/MacroEditorControl.vb @@ -13,18 +13,20 @@ Class MacroEditorControl MyBase.Dispose(disposing) End Sub - Friend WithEvents TabControl As System.Windows.Forms.TabControl - Friend WithEvents tpEdit As System.Windows.Forms.TabPage + + Private WithEvents TabControl As TabControl + Public WithEvents tpEdit As TabPage Friend WithEvents tpPreview As System.Windows.Forms.TabPage Friend WithEvents gb As System.Windows.Forms.GroupBox Friend WithEvents TipProvider As StaxRip.UI.TipProvider - Friend WithEvents rtbEdit As RichTextBoxEx - Friend WithEvents rtbPreview As RichTextBoxEx + Public WithEvents rtbEdit As RichTextBoxEx + Public WithEvents rtbPreview As RichTextBoxEx Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel Friend WithEvents FlowLayoutPanel1 As System.Windows.Forms.FlowLayoutPanel Friend WithEvents llMacros As SimpleLinkLabel Friend WithEvents llHelp As SimpleLinkLabel - + Public WithEvents tpDefaults As TabPage + Public WithEvents rtbDefaults As RichTextBoxEx Private components As System.ComponentModel.IContainer @@ -35,6 +37,8 @@ Class MacroEditorControl Me.rtbEdit = New StaxRip.UI.RichTextBoxEx() Me.tpPreview = New System.Windows.Forms.TabPage() Me.rtbPreview = New StaxRip.UI.RichTextBoxEx() + Me.tpDefaults = New System.Windows.Forms.TabPage() + Me.rtbDefaults = New StaxRip.UI.RichTextBoxEx() Me.gb = New System.Windows.Forms.GroupBox() Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel() Me.FlowLayoutPanel1 = New System.Windows.Forms.FlowLayoutPanel() @@ -44,6 +48,7 @@ Class MacroEditorControl Me.TabControl.SuspendLayout() Me.tpEdit.SuspendLayout() Me.tpPreview.SuspendLayout() + Me.tpDefaults.SuspendLayout() Me.gb.SuspendLayout() Me.TableLayoutPanel1.SuspendLayout() Me.FlowLayoutPanel1.SuspendLayout() @@ -56,6 +61,7 @@ Class MacroEditorControl Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.TabControl.Controls.Add(Me.tpEdit) Me.TabControl.Controls.Add(Me.tpPreview) + Me.TabControl.Controls.Add(Me.tpDefaults) Me.TabControl.Location = New System.Drawing.Point(3, 3) Me.TabControl.Name = "TabControl" Me.TabControl.SelectedIndex = 0 @@ -67,21 +73,18 @@ Class MacroEditorControl Me.tpEdit.Controls.Add(Me.rtbEdit) Me.tpEdit.Location = New System.Drawing.Point(12, 58) Me.tpEdit.Name = "tpEdit" - Me.tpEdit.Padding = New System.Windows.Forms.Padding(3) Me.tpEdit.Size = New System.Drawing.Size(584, 394) Me.tpEdit.TabIndex = 0 Me.tpEdit.Text = "Edit" - Me.tpEdit.UseVisualStyleBackColor = True ' 'rtbEdit ' Me.rtbEdit.AcceptsTab = True - Me.rtbEdit.BlockPaint = False Me.rtbEdit.BorderStyle = System.Windows.Forms.BorderStyle.None Me.rtbEdit.Dock = System.Windows.Forms.DockStyle.Fill - Me.rtbEdit.Location = New System.Drawing.Point(3, 3) + Me.rtbEdit.Location = New System.Drawing.Point(0, 0) Me.rtbEdit.Name = "rtbEdit" - Me.rtbEdit.Size = New System.Drawing.Size(578, 388) + Me.rtbEdit.Size = New System.Drawing.Size(584, 394) Me.rtbEdit.TabIndex = 0 Me.rtbEdit.Text = "" ' @@ -90,24 +93,41 @@ Class MacroEditorControl Me.tpPreview.Controls.Add(Me.rtbPreview) Me.tpPreview.Location = New System.Drawing.Point(12, 58) Me.tpPreview.Name = "tpPreview" - Me.tpPreview.Padding = New System.Windows.Forms.Padding(3) - Me.tpPreview.Size = New System.Drawing.Size(584, 407) + Me.tpPreview.Size = New System.Drawing.Size(584, 394) Me.tpPreview.TabIndex = 1 Me.tpPreview.Text = "Preview" - Me.tpPreview.UseVisualStyleBackColor = True ' 'rtbPreview ' - Me.rtbPreview.BlockPaint = False Me.rtbPreview.BorderStyle = System.Windows.Forms.BorderStyle.None Me.rtbPreview.Dock = System.Windows.Forms.DockStyle.Fill - Me.rtbPreview.Location = New System.Drawing.Point(3, 3) + Me.rtbPreview.Location = New System.Drawing.Point(0, 0) Me.rtbPreview.Name = "rtbPreview" Me.rtbPreview.ReadOnly = True - Me.rtbPreview.Size = New System.Drawing.Size(578, 401) + Me.rtbPreview.Size = New System.Drawing.Size(584, 394) Me.rtbPreview.TabIndex = 0 Me.rtbPreview.Text = "" ' + 'tpDefaults + ' + Me.tpDefaults.Controls.Add(Me.rtbDefaults) + Me.tpDefaults.Location = New System.Drawing.Point(12, 58) + Me.tpDefaults.Name = "tpDefaults" + Me.tpDefaults.Size = New System.Drawing.Size(584, 394) + Me.tpDefaults.TabIndex = 2 + Me.tpDefaults.Text = "Defaults" + ' + 'rtbDefaults + ' + Me.rtbDefaults.BorderStyle = System.Windows.Forms.BorderStyle.None + Me.rtbDefaults.Dock = System.Windows.Forms.DockStyle.Fill + Me.rtbDefaults.Location = New System.Drawing.Point(0, 0) + Me.rtbDefaults.Name = "rtbDefaults" + Me.rtbDefaults.ReadOnly = True + Me.rtbDefaults.Size = New System.Drawing.Size(584, 394) + Me.rtbDefaults.TabIndex = 0 + Me.rtbDefaults.Text = "" + ' 'gb ' Me.gb.Controls.Add(Me.TableLayoutPanel1) @@ -122,8 +142,8 @@ Class MacroEditorControl ' Me.TableLayoutPanel1.ColumnCount = 1 Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) - Me.TableLayoutPanel1.Controls.Add(Me.TabControl, 0, 0) Me.TableLayoutPanel1.Controls.Add(Me.FlowLayoutPanel1, 0, 1) + Me.TableLayoutPanel1.Controls.Add(Me.TabControl, 0, 0) Me.TableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill Me.TableLayoutPanel1.Location = New System.Drawing.Point(3, 40) Me.TableLayoutPanel1.Name = "TableLayoutPanel1" @@ -176,6 +196,7 @@ Class MacroEditorControl Me.TabControl.ResumeLayout(False) Me.tpEdit.ResumeLayout(False) Me.tpPreview.ResumeLayout(False) + Me.tpDefaults.ResumeLayout(False) Me.gb.ResumeLayout(False) Me.TableLayoutPanel1.ResumeLayout(False) Me.TableLayoutPanel1.PerformLayout() @@ -202,11 +223,9 @@ Class MacroEditorControl InitializeComponent() rtbEdit.EnableAutoDragDrop = True rtbEdit.Font = New Font("Consolas", 10 * s.UIScaleFactor) - rtbPreview.Font = rtbEdit.Font - + rtbDefaults.Font = rtbEdit.Font Dim c = ControlPaint.Dark(ToolStripRendererEx.ColorBorder, 0) - llHelp.LinkColor = c llMacros.LinkColor = c llHelp.Visible = False @@ -257,7 +276,6 @@ Class MacroEditorControl Private Sub UpdateWrapMode(rtb As RichTextBox) If AutoWrap Then rtb.WordWrap = Not rtb.Text.FixBreak.Contains(BR) - Dim s = TextRenderer.MeasureText(rtb.Text, rtb.Font) If s.Width > (rtb.Width - SystemInformation.VerticalScrollBarWidth) Then @@ -291,7 +309,13 @@ Class MacroEditorControl Protected Overrides Sub OnHandleCreated(e As EventArgs) UpdateWrapMode(rtbEdit) UpdateWrapMode(rtbPreview) + MyBase.OnHandleCreated(e) + + If rtbDefaults.Text = "" Then + TabControl.Controls.Remove(tpDefaults) + tpDefaults.Dispose() + End If End Sub Private Sub llMacros_Click(sender As Object, e As EventArgs) Handles llMacros.Click diff --git a/Encoding/IntelEncoder.vb b/Encoding/IntelEncoder.vb index 36ec80da..74c914d1 100644 --- a/Encoding/IntelEncoder.vb +++ b/Encoding/IntelEncoder.vb @@ -131,7 +131,7 @@ Public Class IntelEncoder End Sub Property Decoder As New OptionParam With {.Text = "Decoder:", .Options = {"AviSynth/VapourSynth", "QSVEncC Intel", "QSVEncC Software", "ffmpeg Intel", "ffmpeg DXVA2"}, .Values = {"avs", "qs", "qsw", "ffqsv", "ffdxva"}} - Property Codec As New OptionParam With {.Switch = "--codec", .Text = "Codec:", .Options = {"H.264", "H.265", "MPEG-2"}, .Values = {"h264", "hevc", "mpeg2"}} + Property Codec As New OptionParam With {.Switch = "--codec", .Text = "Codec:", .Options = {"H.264", "H.265", "MPEG-2"}, .Values = {"h264", "h265", "mpeg2"}} Property Mode As New OptionParam With {.Switches = {"--avbr", "--cbr", "--vbr", "--qvbr-q", "--cqp", "--vqp", "--icq", "--la-icq", "--vcm", "--la", "--la-hrd", "--qvbr"}, .Name = "Mode", .Text = "Mode:", .Expand = True, .Options = Modes.Select(Function(a) a.Value).ToArray, .Values = Modes.Select(Function(a) a.Name).ToArray, .InitValue = 2} Property Deinterlace As New OptionParam With {.Switch = "--vpp-deinterlace", .Text = "Deinterlace:", .Options = {"None", "Normal", "Inverse Telecine", "Double Framerate"}, .Values = {"none", "normal", "it", "bob"}} Property Quality As New NumParam With {.Text = "Quality:", .Value = 23, .DefaultValue = 23, .VisibleFunc = Function() {"icq", "la-icq", "qvbr-q"}.Contains(Mode.ValueText), .MinMaxStep = {0, 51, 1}} diff --git a/Encoding/NVIDIAEncoder.vb b/Encoding/NVIDIAEncoder.vb index d8146a32..660f2526 100644 --- a/Encoding/NVIDIAEncoder.vb +++ b/Encoding/NVIDIAEncoder.vb @@ -67,6 +67,11 @@ Public Class NVIDIAEncoder End Property Overrides Sub Encode() + If OutputExt = "h265" Then + Dim codecs = ProcessHelp.GetStdOut(Package.NVEncC.Path, "--check-hw").Right("Codec(s)") + If Not codecs?.ToLower.Contains("hevc") Then Throw New ErrorAbortException("NVEncC Error", "H.265/HEVC isn't supported by the graphics card.") + End If + p.Script.Synchronize() Dim batchPath = p.TempDir + p.TargetFile.Base + "_NVEncC.bat" Dim batchCode = Proc.WriteBatchFile(batchPath, Params.GetCommandLine(True, True)) diff --git a/Encoding/x265.vb b/Encoding/x265.vb index 84ed42d0..bc4f3d4b 100644 --- a/Encoding/x265.vb +++ b/Encoding/x265.vb @@ -803,6 +803,10 @@ Public Class x265Params .Switch = "--multi-pass-opt-distortion", .Text = "Multipass refinement of qp based on distortion data"} + Property LimitTU As New NumParam With { + .Switch = "--limit-tu", + .Text = "Limit TU:", .MinMaxStep = {0, 4, 1}} + Private ItemsValue As List(Of CommandLineParam) Overrides ReadOnly Property Items As List(Of CommandLineParam) @@ -818,7 +822,7 @@ Public Class x265Params New OptionParam With {.Switch = "--analysis-mode", .Text = "Analysis Mode:", .Options = {"off", "save", "load"}}, MinCuSize, MaxCuSize, MaxTuSize, LimitRefs, New NumParam With {.Switch = "--refine-level", .Text = "Refine Level:", .MinMaxStep = {1, 10, 1}, .InitValue = 5}, - New NumParam With {.Switch = "--limit-tu", .Text = "Limit TU:", .MinMaxStep = {0, 4, 1}}, + LimitTU, TUintra, TUinter, rdoqLevel, New NumParam() With {.Switch = "--dynamic-rd", .Text = "Dynamic RD:", .MinMaxStepDec = {0, 4, 1, 1}}) Add("Analysis 2", Rect, AMP, EarlySkip, FastIntra, BIntra, @@ -1070,16 +1074,17 @@ Public Class x265Params DeblockB.Value = 0 FrameThreads.Value = 0 IPRatio.Value = 1.4 + LimitModes.Value = False + LimitRefs.Value = 3 + LimitTU.Value = 0 + LookaheadSlices.Value = 8 MaxCuSize.Value = 0 MinCuSize.Value = 3 PBRatio.Value = 1.3 PsyRD.Value = 2.0 PsyRDOQ.Value = 1 QComp.Value = 0.6 - LookaheadSlices.Value = 8 RecursionSkip.Value = True - LimitRefs.Value = 3 - LimitModes.Value = False Select Case Preset.Value Case 0 'ultrafast @@ -1281,6 +1286,7 @@ Public Class x265Params FastIntra.Value = False LimitModes.Value = True LimitRefs.Value = 2 + LimitTU.Value = 4 LookaheadSlices.Value = 4 MaxMerge.Value = 3 MErange.Value = 57 @@ -1308,6 +1314,7 @@ Public Class x265Params EarlySkip.Value = False FastIntra.Value = False LimitModes.Value = True + LimitTU.Value = 4 LookaheadSlices.Value = 4 MaxMerge.Value = 4 MErange.Value = 57 @@ -1363,16 +1370,17 @@ Public Class x265Params DeblockB.DefaultValue = 0 FrameThreads.DefaultValue = 0 IPRatio.DefaultValue = 1.4 + LimitModes.DefaultValue = False + LimitRefs.DefaultValue = 3 + LimitTU.DefaultValue = 0 + LookaheadSlices.DefaultValue = 8 MaxCuSize.DefaultValue = 0 MinCuSize.DefaultValue = 3 PBRatio.DefaultValue = 1.3 PsyRD.DefaultValue = 2.0 PsyRDOQ.DefaultValue = 1 QComp.DefaultValue = 0.6 - LookaheadSlices.DefaultValue = 8 RecursionSkip.DefaultValue = True - LimitRefs.DefaultValue = 3 - LimitModes.DefaultValue = False Select Case Preset.Value Case 0 'ultrafast @@ -1574,6 +1582,7 @@ Public Class x265Params FastIntra.DefaultValue = False LimitModes.DefaultValue = True LimitRefs.DefaultValue = 2 + LimitTU.DefaultValue = 4 LookaheadSlices.DefaultValue = 4 MaxMerge.DefaultValue = 3 MErange.DefaultValue = 57 @@ -1601,6 +1610,7 @@ Public Class x265Params EarlySkip.DefaultValue = False FastIntra.DefaultValue = False LimitModes.DefaultValue = True + LimitTU.DefaultValue = 4 LookaheadSlices.DefaultValue = 4 MaxMerge.DefaultValue = 4 MErange.DefaultValue = 57 diff --git a/Forms/AudioForm.vb b/Forms/AudioForm.vb index bd7cde28..d53b4c5e 100644 --- a/Forms/AudioForm.vb +++ b/Forms/AudioForm.vb @@ -356,7 +356,6 @@ Class AudioForm Me.rtbCmdlPreview.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.rtbCmdlPreview.BlockPaint = False Me.rtbCmdlPreview.BorderStyle = System.Windows.Forms.BorderStyle.None Me.TableLayoutPanel1.SetColumnSpan(Me.rtbCmdlPreview, 2) Me.rtbCmdlPreview.LastCommandLine = Nothing @@ -525,12 +524,6 @@ Class AudioForm InitializeComponent() rtbCmdlPreview.ReadOnly = True - mbChannels.Add("1 (Mono)", 1) - mbChannels.Add("2 (Stereo)", 2) - mbChannels.Add("6 (5.1)", 6) - mbChannels.Add("7 (6.1)", 7) - mbChannels.Add("8 (7.1)", 8) - mbSamplingRate.Add("Original", 0) mbSamplingRate.Add("11025 Hz", 11025) mbSamplingRate.Add("22050 Hz", 22050) @@ -572,7 +565,6 @@ Class AudioForm Sub SetValues(gap As GUIAudioProfile) gap.Bitrate = TempProfile.Bitrate gap.Language = TempProfile.Language - gap.Channels = TempProfile.Channels gap.Delay = TempProfile.Delay gap.Name = TempProfile.Name gap.StreamName = TempProfile.StreamName @@ -715,7 +707,7 @@ Class AudioForm End Sub Private Sub mbChannels_ValueChanged() Handles mbChannels.ValueChangedUser - TempProfile.Channels = mbChannels.GetValue(Of Integer)() + TempProfile.Params.ChannelsMode = mbChannels.GetValue(Of ChannelsMode)() UpdateBitrate() UpdateControls() End Sub @@ -815,7 +807,7 @@ Class AudioForm tbName.SendMessageCue(TempProfile.Name, False) mbCodec.Value = TempProfile.Params.Codec - mbChannels.Value = TempProfile.Channels + mbChannels.Value = TempProfile.Params.ChannelsMode mbLanguage.Value = TempProfile.Language mbSamplingRate.Value = TempProfile.Params.SamplingRate mbEncoder.Value = TempProfile.Params.Encoder diff --git a/Forms/CommandLineForm.Designer.vb b/Forms/CommandLineForm.Designer.vb index 349e670f..aa89a4ae 100644 --- a/Forms/CommandLineForm.Designer.vb +++ b/Forms/CommandLineForm.Designer.vb @@ -59,7 +59,6 @@ Partial Class CommandLineForm Me.rtbCommandLine.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.rtbCommandLine.BlockPaint = False Me.rtbCommandLine.BorderStyle = System.Windows.Forms.BorderStyle.None Me.TableLayoutPanel1.SetColumnSpan(Me.rtbCommandLine, 4) Me.rtbCommandLine.LastCommandLine = Nothing diff --git a/Forms/MainForm.vb b/Forms/MainForm.vb index 5d664612..1545d364 100644 --- a/Forms/MainForm.vb +++ b/Forms/MainForm.vb @@ -4113,20 +4113,14 @@ Public Class MainForm getDefaults = Function() FilterCategory.GetVapourSynthDefaults End If - Using f As New ScriptEditor(GetFilterProfilesText(filterProfiles)) + Using f As New MacroEditor f.Text = "Filter Profiles" + f.SetScriptDefaults() + f.MacroEditorControl.Value = GetFilterProfilesText(filterProfiles) f.bnContext.Text = " Restore Defaults... " f.bnContext.Visible = True - - Dim t = f - - Dim resetAction = Sub() - If MsgOK("Restore defaults?") Then - t.MacroEditorControl.Value = GetFilterProfilesText(getDefaults()) - End If - End Sub - - f.bnContext.AddClickAction(resetAction) + f.MacroEditorControl.rtbDefaults.Text = GetFilterProfilesText(getDefaults()) + f.bnContext.AddClickAction(Sub() If MsgOK("Restore defaults?") Then f.MacroEditorControl.Value = GetFilterProfilesText(getDefaults())) If f.ShowDialog(Me) = DialogResult.OK Then filterProfiles.Clear() @@ -4350,12 +4344,12 @@ Public Class MainForm ret.Add("Tools|Edit Menu...", NameOf(ShowMainMenuEditor)) ret.Add("Tools|Settings...", NameOf(ShowSettingsDialog), Symbol.Settings, {""}) - ret.Add("Apps|AVSMeter...", NameOf(g.DefaultCommands.StartTool), {"AVSMeter"}) - ret.Add("Apps|BDSup2Sub++...", NameOf(g.DefaultCommands.StartTool), {"BDSup2Sub++"}) - ret.Add("Apps|Demux...", NameOf(g.DefaultCommands.StartTool), {"Demux"}) - ret.Add("Apps|DGIndexNV...", NameOf(g.DefaultCommands.StartTool), {"DGIndexNV"}) - ret.Add("Apps|ProjectX...", NameOf(g.DefaultCommands.StartTool), {"ProjectX"}) - ret.Add("Apps|VSRip...", NameOf(g.DefaultCommands.StartTool), {"VSRip"}) + ret.Add("Apps|AVSMeter", NameOf(g.DefaultCommands.StartTool), {"AVSMeter"}) + ret.Add("Apps|BDSup2Sub++", NameOf(g.DefaultCommands.StartTool), {"BDSup2Sub++"}) + ret.Add("Apps|Demux", NameOf(g.DefaultCommands.StartTool), {"Demux"}) + ret.Add("Apps|DGIndexNV", NameOf(g.DefaultCommands.StartTool), {"DGIndexNV"}) + ret.Add("Apps|ProjectX", NameOf(g.DefaultCommands.StartTool), {"ProjectX"}) + ret.Add("Apps|VSRip", NameOf(g.DefaultCommands.StartTool), {"VSRip"}) ret.Add("Apps|-") ret.Add("Apps|Manage...", NameOf(ShowAppsDialog)) diff --git a/Forms/MediaInfoForm.vb b/Forms/MediaInfoForm.vb index 71f7f71a..ba2a9edf 100644 --- a/Forms/MediaInfoForm.vb +++ b/Forms/MediaInfoForm.vb @@ -45,7 +45,6 @@ Class MediaInfoForm Me.rtb.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.rtb.BlockPaint = False Me.rtb.BorderStyle = System.Windows.Forms.BorderStyle.None Me.rtb.Location = New System.Drawing.Point(116, 6) Me.rtb.Margin = New System.Windows.Forms.Padding(6) diff --git a/Forms/Misc Forms.vb b/Forms/Misc Forms.vb deleted file mode 100644 index 589e4053..00000000 --- a/Forms/Misc Forms.vb +++ /dev/null @@ -1,12 +0,0 @@ -Imports StaxRip.UI - -Imports System.ComponentModel - -Class ScriptEditor - Inherits MacroEditor - - Sub New(script As String) - SetScriptDefaults() - MacroEditorControl.Value = script - End Sub -End Class \ No newline at end of file diff --git a/Forms/x264Form.vb b/Forms/x264Form.vb index 8fa9b37e..6877548e 100644 --- a/Forms/x264Form.vb +++ b/Forms/x264Form.vb @@ -878,7 +878,6 @@ Class x264Form Me.rtbCommandLine.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.rtbCommandLine.BlockPaint = False Me.rtbCommandLine.BorderStyle = System.Windows.Forms.BorderStyle.None Me.rtbCommandLine.LastCommandLine = Nothing Me.rtbCommandLine.Location = New System.Drawing.Point(8, 453) diff --git a/General/AudioProfile.vb b/General/AudioProfile.vb index e787a119..384df5df 100644 --- a/General/AudioProfile.vb +++ b/General/AudioProfile.vb @@ -14,11 +14,11 @@ Public MustInherit Class AudioProfile Property Language As New Language Property Delay As Integer Property StreamName As String = "" - Property Channels As Integer = 2 Property Gain As Single Property Streams As List(Of AudioStream) = New List(Of AudioStream) Property [Default] As Boolean + Overridable Property Channels As Integer = 2 Overridable Property OutputFileType As String = "unknown" Overridable Property Bitrate As Double Overridable Property SupportedInput As String() @@ -509,10 +509,7 @@ Class MuxAudioProfile page.ResumeLayout() Dim ret = f.ShowDialog() - - If ret = DialogResult.OK Then - ui.Save() - End If + If ret = DialogResult.OK Then ui.Save() Return ret End Using @@ -528,7 +525,6 @@ Class GUIAudioProfile Sub New(codec As AudioCodec, quality As Single) MyBase.New(Nothing) - Me.Channels = Channels Params.Codec = codec Params.Quality = quality @@ -542,6 +538,31 @@ Class GUIAudioProfile Bitrate = GetBitrate() End Sub + Public Overrides Property Channels As Integer + Get + Select Case Params.ChannelsMode + Case ChannelsMode.Original + If Not Stream Is Nothing Then + Return Stream.Channels + ElseIf File <> "" AndAlso IO.File.Exists(File) Then + Return MediaInfo.GetChannels(File) + End If + Case ChannelsMode._1 + Return 1 + Case ChannelsMode._6 + Return 6 + Case ChannelsMode._7 + Return 7 + Case ChannelsMode._8 + Return 8 + End Select + + Return 2 + End Get + Set(value As Integer) + End Set + End Property + Private SourceBitDepthValue As Integer ReadOnly Property SourceBitDepth As Integer 'can be 0 @@ -1007,19 +1028,17 @@ Class GUIAudioProfile If Params Is Nothing Then Exit Property Dim ch As String - Select Case Channels - Case 8 + Select Case Params.ChannelsMode + Case ChannelsMode._8 ch += " 7.1" - Case 7 + Case ChannelsMode._7 ch += " 6.1" - Case 6 + Case ChannelsMode._6 ch += " 5.1" - Case 2 + Case ChannelsMode._2 ch += " 2.0" - Case 1 + Case ChannelsMode._1 ch += " Mono" - Case Else - ch += " " & Channels & "ch" End Select Dim circa = If(Params.RateMode = AudioRateMode.VBR OrElse Params.Codec = AudioCodec.Flac, "~", "") @@ -1135,6 +1154,7 @@ Class GUIAudioProfile Property Quality As Single = 0.3 Property RateMode As AudioRateMode Property SamplingRate As Integer + Property ChannelsMode As ChannelsMode End Class End Class @@ -1180,4 +1200,13 @@ Public Enum AudioDownMixMode Stereo Surround Surround2 +End Enum + +Public Enum ChannelsMode + Original + _1 + _2 + _6 + _7 + _8 End Enum \ No newline at end of file diff --git a/General/MediaInfo.vb b/General/MediaInfo.vb index 8bce62b9..82f3e649 100644 --- a/General/MediaInfo.vb +++ b/General/MediaInfo.vb @@ -208,6 +208,7 @@ Public Class MediaInfo Shared Function GetSummary(path As String) As String Dim mi = GetMediaInfo(path) MediaInfo_Option(mi.Handle, "Complete", "0") + MediaInfo_Option(mi.Handle, "Language", "raw") Dim ret = Marshal.PtrToStringUni(MediaInfo_Inform(mi.Handle, 0)) Return Regex.Replace(ret, "Unique ID +: .+\n", "").FormatColumn(":").Trim End Function @@ -275,6 +276,25 @@ Public Class MediaInfo Return GetMediaInfo(path).GetFrameRate(defaultValue) End Function + Function GetChannels() As Integer + Dim channelString = GetInfo(MediaInfoStreamKind.Audio, "Channel(s)") + Dim ret = channelString.ToInt + If ret = 0 Then ret = GetInfo(MediaInfoStreamKind.Audio, "Channel(s)_Original").ToInt + + If ret = 0 Then + Dim match = Regex.Match(channelString, "(\d+) */ *(\d+)") + If match.Success Then ret = match.Groups(1).Value.ToInt + End If + + If ret = 0 Then ret = 2 + Return ret + End Function + + Shared Function GetChannels(path As String) As Integer + Dim mi = GetMediaInfo(path) + Return mi.GetChannels + End Function + Shared Function GetAudioCodecs(path As String) As String Dim ret = GetGeneral(path, "Audio_Codec_List") diff --git a/General/Package.vb b/General/Package.vb index bbc908b1..28d17d3b 100644 --- a/General/Package.vb +++ b/General/Package.vb @@ -59,6 +59,14 @@ Public Class Package .Description = "nvidia GPU accelerated H.264/H.265 encoder.", .HelpFile = "help.txt"}) + Shared Property mvtools2 As Package = Add(New PluginPackage With { + .Name = "mvtools2", + .Filename = "mvtools2.dll", + .WebURL = "https://github.com/pinterf/mvtools", + .HelpURL = "http://avisynth.org.ru/mvtools/mvtools2.html", + .Description = "MVTools is collection of functions for estimation and compensation of objects motion in video clips. Motion compensation may be used for strong temporal denoising, advanced framerate conversions, image restoration and other tasks.", + .AviSynthFilterNames = {"MSuper", "MAnalyse", "MCompensate", "MMask", "MDeGrain1", "MDeGrain2", "MDegrain3"}}) + Shared Property ProjectX As New ProjectXPackage Shared Property qaac As New qaacPackage Shared Property TDeint As New TDeintPackage @@ -176,7 +184,7 @@ Public Class Package .IsRequiredFunc = Function() TypeOf p.VideoEncoder Is AMDEncoder, .WebURL = "https://onedrive.live.com/?id=6BDD4375AC8933C6!516&cid=6BDD4375AC8933C6"}) - Public Shared DGDecodeNV As New PluginPackage With { + Shared Property DGDecodeNV As Package = Add(New PluginPackage With { .Name = "DGDecodeNV", .Filename = "DGDecodeNV.dll", .WebURL = "http://rationalqm.us/dgdecnv/dgdecnv.html", @@ -185,9 +193,9 @@ Public Class Package .IsRequiredFunc = Function() p.Script.Filters(0).Script.Contains("DGSource("), .AviSynthFilterNames = {"DGSource"}, .AviSynthFiltersFunc = Function() {New VideoFilter("Source", "DGSource", "DGSource(""%source_file%"")"), - New VideoFilter("Source", "DGSourceIM", "DGSourceIM(""%source_file%"")")}} + New VideoFilter("Source", "DGSourceIM", "DGSourceIM(""%source_file%"")")}}) - Public Shared ffms2 As New PluginPackage With { + Shared Property ffms2 As Package = Add(New PluginPackage With { .Name = "ffms2", .Filename = "ffms2.dll", .WebURL = "https://github.com/FFMS/ffms2", @@ -196,7 +204,7 @@ Public Class Package .AviSynthFilterNames = {"FFVideoSource", "FFAudioSource"}, .AviSynthFiltersFunc = Function() {New VideoFilter("Source", "FFVideoSource", "FFVideoSource(""%source_file%"", cachefile = ""%source_temp_file%.ffindex"", colorspace = ""YV12"")")}, .VapourSynthFilterNames = {"ffms2"}, - .VapourSynthFiltersFunc = Function() {New VideoFilter("Source", "ffms2", "clip = core.ffms2.Source(r""%source_file%"", cachefile = r""%source_temp_file%.ffindex"")")}} + .VapourSynthFiltersFunc = Function() {New VideoFilter("Source", "ffms2", "clip = core.ffms2.Source(r""%source_file%"", cachefile = r""%source_temp_file%.ffindex"")")}}) Shared Function Add(pack As Package) As Package Items(pack.ID) = pack @@ -218,7 +226,6 @@ Public Class Package Add(BeSweet) Add(checkmate) Add(DGDecodeIM) - Add(DGDecodeNV) Add(DGIndexIM) Add(DGIndexNV) Add(DivX265) @@ -243,7 +250,6 @@ Public Class Package Add(x264_10) Add(x265) Add(xvid_encraw) - Add(ffms2) Add(avs2pipemod) #Region "misc" @@ -430,12 +436,12 @@ Public Class Package .AviSynthFiltersFunc = Function() {New VideoFilter("Field", "nnedi3", "nnedi3(field = 1)")}}) Add(New PluginPackage With { - .Name = "mvtools2", - .Filename = "mvtools2.dll", - .WebURL = "https://github.com/pinterf/mvtools", - .HelpURL = "http://avisynth.org.ru/mvtools/mvtools2.html", - .Description = "MVTools is collection of functions for estimation and compensation of objects motion in video clips. Motion compensation may be used for strong temporal denoising, advanced framerate conversions, image restoration and other tasks.", - .AviSynthFilterNames = {"MSuper", "MAnalyse", "MCompensate", "MMask", "MDeGrain1", "MDeGrain2", "MDegrain3"}}) + .Name = "TIVTC", + .Filename = "TIVTC.dll", + .WebURL = "https://github.com/pinterf/TIVTC", + .HelpURL = "http://avisynth.nl/index.php/TIVTC", + .Description = "TIVTC is a plugin package containing 7 different filters and 3 conditional functions.", + .AviSynthFilterNames = {"TFM", "TDecimate", "MergeHints", "FrameDiff", "FieldDiff", "ShowCombedTIVTC", "RequestLinear"}}) Add(New PluginPackage With { .Name = "masktools2", diff --git a/General/Scripting.vb b/General/Scripting.vb index 9c90baff..076e5482 100644 --- a/General/Scripting.vb +++ b/General/Scripting.vb @@ -1,29 +1,23 @@ -Imports System.Dynamic -Imports System.Management.Automation.Runspaces +Imports System.Management.Automation.Runspaces Imports System.Threading.Tasks Imports Microsoft.CodeAnalysis.CSharp.Scripting Imports Microsoft.CodeAnalysis.Scripting Public Class Scripting - Shared Sub RunCSharp(code As String, Optional hideErrors As Boolean = False) - RunCSharpAsync(code, hideErrors).Wait() + Shared Sub RunCSharp(code As String) + RunCSharpAsync(code).Wait() End Sub - Private Shared Async Function RunCSharpAsync(code As String, Optional hideErrors As Boolean = False) As Task(Of Object) + Private Shared Async Function RunCSharpAsync(code As String) As Task(Of Object) Try - If Not s.Storage.GetBool("c# scripting removal") Then - MsgWarn("C# scripting support will be removed, use PowerShell scripting instead.") - s.Storage.SetBool("c# scripting removal", True) - End If - + MsgWarn("C# scripting support will be removed, use PowerShell scripting instead.") Dim options = ScriptOptions.Default.WithImports( "StaxRip", "System.Linq", "System.IO", "System.Text.RegularExpressions"). WithReferences(GetType(Scripting).Assembly, GetType(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo).Assembly) - Await CSharpScript.Create(code, options).RunAsync() Catch ex As Exception - If Not hideErrors Then MsgError(ex.Message) + g.ShowException(ex) End Try End Function diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 22cacf0b..08f22002 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -8,4 +8,4 @@ Imports System.Runtime.InteropServices - \ No newline at end of file + \ No newline at end of file diff --git a/StaxRip.vbproj b/StaxRip.vbproj index d1561aed..48da26b5 100644 --- a/StaxRip.vbproj +++ b/StaxRip.vbproj @@ -373,9 +373,6 @@ Form - - Form - Form diff --git a/UI/Controls/Controls.vb b/UI/Controls/Controls.vb index 35307cee..68c33161 100644 --- a/UI/Controls/Controls.vb +++ b/UI/Controls/Controls.vb @@ -1,12 +1,7 @@ Imports System.Reflection Imports System.ComponentModel -Imports System.IO Imports System.Runtime.InteropServices -Imports System.Drawing.Drawing2D Imports System.Windows.Forms.VisualStyles -Imports System.Text -Imports System.Text.RegularExpressions -Imports System.Drawing.Design Imports System.Threading Imports System.Threading.Tasks @@ -456,6 +451,8 @@ Namespace UI Public Class RichTextBoxEx Inherits RichTextBox + + Property BlockPaint As Boolean Private BorderRect As Native.RECT diff --git a/UI/Controls/SimpleUI.vb b/UI/Controls/SimpleUI.vb index b5ab439e..66558b60 100644 --- a/UI/Controls/SimpleUI.vb +++ b/UI/Controls/SimpleUI.vb @@ -455,10 +455,7 @@ Public Class SimpleUI Using f As New MacroEditor f.SetBatchDefaults() f.MacroEditorControl.Value = Text - - If f.ShowDialog() = DialogResult.OK Then - Text = f.MacroEditorControl.Value - End If + If f.ShowDialog() = DialogResult.OK Then Text = f.MacroEditorControl.Value End Using End Sub @@ -466,10 +463,7 @@ Public Class SimpleUI Using f As New MacroEditor f.SetMacroDefaults() f.MacroEditorControl.Value = Text - - If f.ShowDialog() = DialogResult.OK Then - Text = f.MacroEditorControl.Value - End If + If f.ShowDialog() = DialogResult.OK Then Text = f.MacroEditorControl.Value End Using End Sub End Class diff --git a/UI/Menu Types.vb b/UI/Menu Types.vb index d7445a60..ea13b530 100644 --- a/UI/Menu Types.vb +++ b/UI/Menu Types.vb @@ -345,10 +345,13 @@ Namespace UI Dim img = Await ImageHelp.GetSymbolImageAsync(symbol) - If Not mi.IsDisposed Then - mi.ImageScaling = ToolStripItemImageScaling.None - mi.Image = img - End If + Try + If Not mi.IsDisposed Then + mi.ImageScaling = ToolStripItemImageScaling.None + mi.Image = img + End If + Catch + End Try End Sub Protected Overrides Sub Dispose(disposing As Boolean) @@ -612,19 +615,13 @@ Namespace UI Using f As New MacroEditor f.SetMacroDefaults() f.MacroEditorControl.Value = value + f.MacroEditorControl.rtbDefaults.Text = defaults f.Text = "Menu Editor" - Dim t = f - - Dim resetAction = Sub() - If MsgOK("Restore defaults?") Then - t.MacroEditorControl.Value = defaults - End If - End Sub If helpName <> "" Then f.bnContext.Text = " Restore Defaults... " f.bnContext.Visible = True - f.bnContext.AddClickAction(resetAction) + f.bnContext.AddClickAction(Sub() If MsgOK("Restore defaults?") Then f.MacroEditorControl.Value = defaults) End If If f.ShowDialog(owner) = DialogResult.OK Then diff --git a/md/test-build.md b/md/test-build.md index 27aa7b51..1e81707f 100644 --- a/md/test-build.md +++ b/md/test-build.md @@ -27,6 +27,7 @@ https://onedrive.live.com/redir?resid=604D4754F64B0ABC!4140&authkey=!ANUm9V3vTPm - flash3kyuu_deband VapourSynth support added - new macro %eval_ps:% added to evaluate PowerShell expressions - various improvements in the batch/cli audio encoder GUI +- deafults tab added to video filter profile editor and several menu editors #### Fixed Bugs @@ -65,17 +66,18 @@ https://onedrive.live.com/redir?resid=604D4754F64B0ABC!4140&authkey=!ANUm9V3vTPm - migrated C# HDR script to PowerShell - updated VapourSynth's built in filters - up/down menu items for the avs/vs filter list in main dialog +- x265 --limit-tu defaults for slower and veryslow presets updated #### Updated Tools - QSVEncC 2.62 -- masktools2 2.2.2 - VCEEncC 3.06 - HAvsFunc 2017-03-06 - x264 2762 - MediaInfo 0.7.93 - ffmpeg 3.2.2 - qaac 2.62 +- mvtools (vs) 18 - L-SMASH-Works (avs) 929 - vslsmashsource (vs) 929 - KNLMeansCL 1.0.2 @@ -83,10 +85,11 @@ https://onedrive.live.com/redir?resid=604D4754F64B0ABC!4140&authkey=!ANUm9V3vTPm - RgTools (avs) 0.95 - AviSynth+ 2455 - VapourSynth 37 -- x265 2.3+30 -- mkvtoolnix 10.0.0 - ffms2 2.2000 test3 -- mvtools (vs) 18 - VSFilterMod (avs, vs) 4 - flash3kyuu_deband (avs, vs) 2.0.20140721 -- mp4box 0.7.0 \ No newline at end of file +- TIVTC (avs) 1.0.6 +- mkvtoolnix 11.0.0 +- x265 2.4+2 +- mvtools2 (avs) 2.7.16.22 +- masktools2 2.2.7 diff --git a/x265/alt_param.cpp b/x265/alt_param.cpp index cd623106..3b601f71 100644 --- a/x265/alt_param.cpp +++ b/x265/alt_param.cpp @@ -131,6 +131,7 @@ void x265_param_default(x265_param* param) param->bEnableAccessUnitDelimiters = 0; param->bEmitHRDSEI = 0; param->bEmitInfoSEI = 1; + param->bEmitHDRSEI = 0; /* CU definitions */ param->maxCUSize = 64; @@ -149,7 +150,8 @@ void x265_param_default(x265_param* param) param->bBPyramid = 1; param->scenecutThreshold = 40; /* Magic number pulled in from x264 */ param->lookaheadSlices = 8; - + param->lookaheadThreads = 0; + param->scenecutBias = 5.0; /* Intra Coding Tools */ param->bEnableConstrainedIntra = 0; param->bEnableStrongIntraSmoothing = 1; @@ -177,6 +179,7 @@ void x265_param_default(x265_param* param) param->bEnableTemporalMvp = 1; param->bSourceReferenceEstimation = 0; param->limitTU = 0; + param->dynamicRd = 0; /* Loop Filter */ param->bEnableLoopFilter = 1; @@ -192,12 +195,16 @@ void x265_param_default(x265_param* param) param->psyRd = 2.0; param->psyRdoq = 0.0; param->analysisMode = 0; + param->analysisMultiPassRefine = 0; + param->analysisMultiPassDistortion = 0; param->analysisFileName = NULL; param->bIntraInBFrames = 0; param->bLossless = 0; param->bCULossless = 0; param->bEnableTemporalSubLayers = 0; param->bEnableRdRefine = 0; + param->bMultiPassOptRPS = 0; + param->bSsimRd = 0; /* Rate control options */ param->rc.vbvMaxBitrate = 0; @@ -261,6 +268,9 @@ void x265_param_default(x265_param* param) param->bEmitVUIHRDInfo = 1; param->bOptQpPPS = 1; param->bOptRefListLengthPPS = 1; + param->bOptCUDeltaQP = 0; + param->bAQMotion = 0; + param->bHDROpt = 0; } @@ -915,6 +925,26 @@ int x265_param_parse(x265_param* p, const char* name, const char* value) OPT("limit-tu") p->limitTU = atoi(value); OPT("opt-qp-pps") p->bOptQpPPS = atobool(value); OPT("opt-ref-list-length-pps") p->bOptRefListLengthPPS = atobool(value); + OPT("multi-pass-opt-rps") p->bMultiPassOptRPS = atobool(value); + OPT("scenecut-bias") p->scenecutBias = atof(value); + OPT("lookahead-threads") p->lookaheadThreads = atoi(value); + OPT("opt-cu-delta-qp") p->bOptCUDeltaQP = atobool(value); + OPT("multi-pass-opt-analysis") p->analysisMultiPassRefine = atobool(value); + OPT("multi-pass-opt-distortion") p->analysisMultiPassDistortion = atobool(value); + OPT("aq-motion") p->bAQMotion = atobool(value); + OPT("dynamic-rd") p->dynamicRd = atof(value); + OPT("ssim-rd") + { + int bval = atobool(value); + if (bError || bval) + { + bError = false; + p->psyRd = 0.0; + p->bSsimRd = atobool(value); + } + } + OPT("hdr") p->bEmitHDRSEI = atobool(value); + OPT("hdr-opt") p->bHDROpt = atobool(value); else return X265_PARAM_BAD_NAME; } @@ -1077,8 +1107,8 @@ int x265_check_params(x265_param* param) "Multiple-Slices mode must be enable Wavefront Parallel Processing (--wpp)"); CHECK(param->internalBitDepth != X265_DEPTH, "internalBitDepth must match compiled bit depth"); - CHECK(param->minCUSize != 64 && param->minCUSize != 32 && param->minCUSize != 16 && param->minCUSize != 8, - "minimim CU size must be 8, 16, 32, or 64"); + CHECK(param->minCUSize != 32 && param->minCUSize != 16 && param->minCUSize != 8, + "minimim CU size must be 8, 16 or 32"); CHECK(param->minCUSize > param->maxCUSize, "min CU size must be less than or equal to max CU size"); CHECK(param->rc.qp < -6 * (param->internalBitDepth - 8) || param->rc.qp > QP_MAX_SPEC, @@ -1087,8 +1117,8 @@ int x265_check_params(x265_param* param) "Frame rate numerator and denominator must be specified"); CHECK(param->interlaceMode < 0 || param->interlaceMode > 2, "Interlace mode must be 0 (progressive) 1 (top-field first) or 2 (bottom field first)"); - CHECK(param->searchMethod<0 || param->searchMethod> X265_FULL_SEARCH, - "Search method is not supported value (0:DIA 1:HEX 2:UMH 3:HM 5:FULL)"); + CHECK(param->searchMethod < 0 || param->searchMethod > X265_FULL_SEARCH, + "Search method is not supported value (0:DIA 1:HEX 2:UMH 3:HM 4:SEA 5:FULL)"); CHECK(param->searchRange < 0, "Search Range must be more than 0"); CHECK(param->searchRange >= 32768, @@ -1121,7 +1151,7 @@ int x265_check_params(x265_param* param) "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1"); CHECK((param->maxTUSize != 32 && param->maxTUSize != 16 && param->maxTUSize != 8 && param->maxTUSize != 4), "max TU size must be 4, 8, 16, or 32"); - CHECK(param->limitTU > 2, "Invalid limit-tu option, limit-TU must be 0, 1 or 2"); + CHECK(param->limitTU > 4, "Invalid limit-tu option, limit-TU must be between 0 and 4"); CHECK(param->maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); CHECK(param->maxNumMergeCand > 5, "MaxNumMergeCand must be 5 or smaller."); @@ -1143,6 +1173,8 @@ int x265_check_params(x265_param* param) "RD Level is out of range"); CHECK(param->rdoqLevel < 0 || param->rdoqLevel > 2, "RDOQ Level is out of range"); + CHECK(param->dynamicRd < 0 || param->dynamicRd > x265_ADAPT_RD_STRENGTH, + "Dynamic RD strength must be between 0 and 4"); CHECK(param->bframes && param->bframes >= param->lookaheadDepth && !param->rc.bStatRead, "Lookahead depth must be greater than the max consecutive bframe count"); CHECK(param->bframes < 0, @@ -1217,6 +1249,8 @@ int x265_check_params(x265_param* param) "Valid Logging level -1:none 0:error 1:warning 2:info 3:debug 4:full"); CHECK(param->scenecutThreshold < 0, "scenecutThreshold must be greater than 0"); + CHECK(param->scenecutBias < 0 || 100 < param->scenecutBias, + "scenecut-bias must be between 0 and 100"); CHECK(param->rdPenalty < 0 || param->rdPenalty > 2, "Valid penalty for 32x32 intra TU in non-I slices. 0:disabled 1:RD-penalty 2:maximum"); CHECK(param->keyframeMax < -1, @@ -1247,10 +1281,16 @@ int x265_check_params(x265_param* param) "qpmax exceeds supported range (0 to 69)"); CHECK(param->rc.qpMin < QP_MIN || param->rc.qpMin > QP_MAX_MAX, "qpmin exceeds supported range (0 to 69)"); - CHECK(param->log2MaxPocLsb < 4, - "maximum of the picture order count can not be less than 4"); - CHECK(1 > param->maxSlices || param->maxSlices > ((param->sourceHeight + param->maxCUSize - 1) / param->maxCUSize), - "The slices can not be more than number of rows"); + CHECK(param->log2MaxPocLsb < 4 || param->log2MaxPocLsb > 16, + "Supported range for log2MaxPocLsb is 4 to 16"); +#if !X86_64 + CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480), + "SEA motion search does not support resolutions greater than 480p in 32 bit build"); +#endif + + if (param->masteringDisplayColorVolume || param->maxFALL || param->maxCLL) + param->bEmitHDRSEI = 1; + return check_failed; } @@ -1338,9 +1378,8 @@ void x265_print_params(x265_param* param) x265_log(param, X265_LOG_INFO, "ME / range / subpel / merge : %s / %d / %d / %d\n", x265_motion_est_names[param->searchMethod], param->searchRange, param->subpelRefine, param->maxNumMergeCand); - if (param->keyframeMax != INT_MAX || param->scenecutThreshold) - x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut : %d / %d / %d\n", param->keyframeMin, param->keyframeMax, param->scenecutThreshold); + x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut / bias: %d / %d / %d / %.2lf\n", param->keyframeMin, param->keyframeMax, param->scenecutThreshold, param->scenecutBias * 100); else x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut : disabled\n"); @@ -1385,6 +1424,7 @@ void x265_print_params(x265_param* param) TOOLOPT(param->bEnableAMP, "amp"); TOOLOPT(param->limitModes, "limit-modes"); TOOLVAL(param->rdLevel, "rd=%d"); + TOOLVAL(param->dynamicRd, "dynamic-rd=%.2f"); TOOLVAL(param->psyRd, "psy-rd=%.2lf"); TOOLVAL(param->rdoqLevel, "rdoq=%d"); TOOLVAL(param->psyRdoq, "psy-rdoq=%.2lf"); @@ -1404,6 +1444,7 @@ void x265_print_params(x265_param* param) TOOLOPT(param->bEnableFastIntra, "fast-intra"); TOOLOPT(param->bEnableStrongIntraSmoothing, "strong-intra-smoothing"); TOOLVAL(param->lookaheadSlices, "lslices=%d"); + TOOLVAL(param->lookaheadThreads, "lthreads=%d") if (param->maxSlices > 1) TOOLVAL(param->maxSlices, "slices=%d"); if (param->bEnableLoopFilter) @@ -1424,7 +1465,7 @@ void x265_print_params(x265_param* param) fflush(stderr); } -char *x265_param2string(x265_param* p) +char *x265_param2string(x265_param* p, int padx, int pady) { char *buf, *s; @@ -1435,71 +1476,93 @@ char *x265_param2string(x265_param* p) #define BOOL(param, cliopt) \ s += sprintf(s, " %s", (param) ? cliopt : "no-" cliopt); - s += sprintf(s, "%dx%d", p->sourceWidth,p->sourceHeight); - s += sprintf(s, " fps=%u/%u", p->fpsNum, p->fpsDenom); - s += sprintf(s, " bitdepth=%d", p->internalBitDepth); + s += sprintf(s, "cpuid=%d", p->cpuid); + s += sprintf(s, " frame-threads=%d", p->frameNumThreads); + if (p->numaPools) + s += sprintf(s, " numa-pools=%s", p->numaPools); BOOL(p->bEnableWavefront, "wpp"); + BOOL(p->bDistributeModeAnalysis, "pmode"); + BOOL(p->bDistributeMotionEstimation, "pme"); + BOOL(p->bEnablePsnr, "psnr"); + BOOL(p->bEnableSsim, "ssim"); + s += sprintf(s, " log-level=%d", p->logLevel); + s += sprintf(s, " bitdepth=%d", p->internalBitDepth); + s += sprintf(s, " input-csp=%d", p->internalCsp); + s += sprintf(s, " fps=%u/%u", p->fpsNum, p->fpsDenom); + s += sprintf(s, " input-res=%dx%d", p->sourceWidth - padx, p->sourceHeight - pady); + s += sprintf(s, " interlace=%d", p->interlaceMode); + s += sprintf(s, " total-frames=%d", p->totalFrames); + s += sprintf(s, " level-idc=%d", p->levelIdc); + s += sprintf(s, " high-tier=%d", p->bHighTier); + s += sprintf(s, " uhd-bd=%d", p->uhdBluray); + s += sprintf(s, " ref=%d", p->maxNumReferences); + BOOL(p->bAllowNonConformance, "allow-non-conformance"); + BOOL(p->bRepeatHeaders, "repeat-headers"); + BOOL(p->bAnnexB, "annexb"); + BOOL(p->bEnableAccessUnitDelimiters, "aud"); + BOOL(p->bEmitHRDSEI, "hrd"); + BOOL(p->bEmitInfoSEI, "info"); + s += sprintf(s, " hash=%d", p->decodedPictureHashSEI); + BOOL(p->bEnableTemporalSubLayers, "temporal-layers"); + BOOL(p->bOpenGOP, "open-gop"); + s += sprintf(s, " min-keyint=%d", p->keyframeMin); + s += sprintf(s, " keyint=%d", p->keyframeMax); + s += sprintf(s, " bframes=%d", p->bframes); + s += sprintf(s, " b-adapt=%d", p->bFrameAdaptive); + BOOL(p->bBPyramid, "b-pyramid"); + s += sprintf(s, " bframe-bias=%d", p->bFrameBias); + s += sprintf(s, " rc-lookahead=%d", p->lookaheadDepth); + s += sprintf(s, " lookahead-slices=%d", p->lookaheadSlices); + s += sprintf(s, " scenecut=%d", p->scenecutThreshold); + BOOL(p->bIntraRefresh, "intra-refresh"); s += sprintf(s, " ctu=%d", p->maxCUSize); s += sprintf(s, " min-cu-size=%d", p->minCUSize); + BOOL(p->bEnableRectInter, "rect"); + BOOL(p->bEnableAMP, "amp"); s += sprintf(s, " max-tu-size=%d", p->maxTUSize); - s += sprintf(s, " tu-intra-depth=%d", p->tuQTMaxIntraDepth); s += sprintf(s, " tu-inter-depth=%d", p->tuQTMaxInterDepth); + s += sprintf(s, " tu-intra-depth=%d", p->tuQTMaxIntraDepth); + s += sprintf(s, " limit-tu=%d", p->limitTU); + s += sprintf(s, " rdoq-level=%d", p->rdoqLevel); + s += sprintf(s, " dynamic-rd=%.2f", p->dynamicRd); + BOOL(p->bEnableSignHiding, "signhide"); + BOOL(p->bEnableTransformSkip, "tskip"); + s += sprintf(s, " nr-intra=%d", p->noiseReductionIntra); + s += sprintf(s, " nr-inter=%d", p->noiseReductionInter); + BOOL(p->bEnableConstrainedIntra, "constrained-intra"); + BOOL(p->bEnableStrongIntraSmoothing, "strong-intra-smoothing"); + s += sprintf(s, " max-merge=%d", p->maxNumMergeCand); + s += sprintf(s, " limit-refs=%d", p->limitReferences); + BOOL(p->limitModes, "limit-modes"); s += sprintf(s, " me=%d", p->searchMethod); s += sprintf(s, " subme=%d", p->subpelRefine); s += sprintf(s, " merange=%d", p->searchRange); - BOOL(p->bEnableRectInter, "rect"); - BOOL(p->bEnableAMP, "amp"); - s += sprintf(s, " max-merge=%d", p->maxNumMergeCand); BOOL(p->bEnableTemporalMvp, "temporal-mvp"); - BOOL(p->bEnableEarlySkip, "early-skip"); - BOOL(p->bEnableRecursionSkip, "rskip"); - s += sprintf(s, " rdpenalty=%d", p->rdPenalty); - BOOL(p->bEnableTransformSkip, "tskip"); - BOOL(p->bEnableTSkipFast, "tskip-fast"); - BOOL(p->bEnableStrongIntraSmoothing, "strong-intra-smoothing"); - BOOL(p->bLossless, "lossless"); - BOOL(p->bCULossless, "cu-lossless"); - BOOL(p->bEnableConstrainedIntra, "constrained-intra"); - BOOL(p->bEnableFastIntra, "fast-intra"); - BOOL(p->bOpenGOP, "open-gop"); - BOOL(p->bEnableTemporalSubLayers, "temporal-layers"); - s += sprintf(s, " interlace=%d", p->interlaceMode); - s += sprintf(s, " keyint=%d", p->keyframeMax); - s += sprintf(s, " min-keyint=%d", p->keyframeMin); - s += sprintf(s, " scenecut=%d", p->scenecutThreshold); - s += sprintf(s, " rc-lookahead=%d", p->lookaheadDepth); - s += sprintf(s, " lookahead-slices=%d", p->lookaheadSlices); - s += sprintf(s, " bframes=%d", p->bframes); - s += sprintf(s, " bframe-bias=%d", p->bFrameBias); - s += sprintf(s, " b-adapt=%d", p->bFrameAdaptive); - s += sprintf(s, " ref=%d", p->maxNumReferences); - s += sprintf(s, " limit-refs=%d", p->limitReferences); - BOOL(p->limitModes, "limit-modes"); BOOL(p->bEnableWeightedPred, "weightp"); BOOL(p->bEnableWeightedBiPred, "weightb"); - s += sprintf(s, " aq-mode=%d", p->rc.aqMode); - s += sprintf(s, " qg-size=%d", p->rc.qgSize); - s += sprintf(s, " aq-strength=%.2f", p->rc.aqStrength); - s += sprintf(s, " cbqpoffs=%d", p->cbQpOffset); - s += sprintf(s, " crqpoffs=%d", p->crQpOffset); - s += sprintf(s, " rd=%d", p->rdLevel); - s += sprintf(s, " psy-rd=%.2f", p->psyRd); - s += sprintf(s, " rdoq-level=%d", p->rdoqLevel); - s += sprintf(s, " psy-rdoq=%.2f", p->psyRdoq); - s += sprintf(s, " log2-max-poc-lsb=%d", p->log2MaxPocLsb); - s += sprintf(s, " limit-tu=%d", p->limitTU); - BOOL(p->bEnableRdRefine, "rd-refine"); - BOOL(p->bEnableSignHiding, "signhide"); + BOOL(p->bSourceReferenceEstimation, "analyze-src-pics"); BOOL(p->bEnableLoopFilter, "deblock"); if (p->bEnableLoopFilter) s += sprintf(s, "=%d:%d", p->deblockingFilterTCOffset, p->deblockingFilterBetaOffset); BOOL(p->bEnableSAO, "sao"); BOOL(p->bSaoNonDeblocked, "sao-non-deblock"); - BOOL(p->bBPyramid, "b-pyramid"); - BOOL(p->rc.cuTree, "cutree"); - BOOL(p->bIntraRefresh, "intra-refresh"); + s += sprintf(s, " rd=%d", p->rdLevel); + BOOL(p->bEnableEarlySkip, "early-skip"); + BOOL(p->bEnableRecursionSkip, "rskip"); + BOOL(p->bEnableFastIntra, "fast-intra"); + BOOL(p->bEnableTSkipFast, "tskip-fast"); + BOOL(p->bCULossless, "cu-lossless"); + BOOL(p->bIntraInBFrames, "b-intra"); + s += sprintf(s, " rdpenalty=%d", p->rdPenalty); + s += sprintf(s, " psy-rd=%.2f", p->psyRd); + s += sprintf(s, " psy-rdoq=%.2f", p->psyRdoq); + BOOL(p->bEnableRdRefine, "rd-refine"); + s += sprintf(s, " analysis-mode=%d", p->analysisMode); + BOOL(p->bLossless, "lossless"); + s += sprintf(s, " cbqpoffs=%d", p->cbQpOffset); + s += sprintf(s, " crqpoffs=%d", p->crQpOffset); s += sprintf(s, " rc=%s", p->rc.rateControlMode == X265_RC_ABR ? ( - p->rc.bStatRead ? "2 pass" : p->rc.bitrate == p->rc.vbvMaxBitrate ? "cbr" : "abr") + p->rc.bitrate == p->rc.vbvMaxBitrate ? "cbr" : "abr") : p->rc.rateControlMode == X265_RC_CRF ? "crf" : "cqp"); if (p->rc.rateControlMode == X265_RC_ABR || p->rc.rateControlMode == X265_RC_CRF) { @@ -1507,17 +1570,20 @@ char *x265_param2string(x265_param* p) s += sprintf(s, " crf=%.1f", p->rc.rfConstant); else s += sprintf(s, " bitrate=%d", p->rc.bitrate); - s += sprintf(s, " qcomp=%.2f qpmin=%d qpmax=%d qpstep=%d", - p->rc.qCompress, p->rc.qpMin, p->rc.qpMax, p->rc.qpStep); + s += sprintf(s, " qcomp=%.2f qpstep=%d", p->rc.qCompress, p->rc.qpStep); + s += sprintf(s, " stats-write=%d", p->rc.bStatWrite); + s += sprintf(s, " stats-read=%d", p->rc.bStatRead); if (p->rc.bStatRead) - s += sprintf( s, " cplxblur=%.1f qblur=%.1f", - p->rc.complexityBlur, p->rc.qblur); + s += sprintf(s, " cplxblur=%.1f qblur=%.1f", + p->rc.complexityBlur, p->rc.qblur); + if (p->rc.bStatWrite && !p->rc.bStatRead) + BOOL(p->rc.bEnableSlowFirstPass, "slow-firstpass"); if (p->rc.vbvBufferSize) { - s += sprintf(s, " vbv-maxrate=%d vbv-bufsize=%d", - p->rc.vbvMaxBitrate, p->rc.vbvBufferSize); + s += sprintf(s, " vbv-maxrate=%d vbv-bufsize=%d vbv-init=%.1f", + p->rc.vbvMaxBitrate, p->rc.vbvBufferSize, p->rc.vbvBufferInit); if (p->rc.rateControlMode == X265_RC_CRF) - s += sprintf(s, " crf-max=%.1f", p->rc.rfConstantMax); + s += sprintf(s, " crf-max=%.1f crf-min=%.1f", p->rc.rfConstantMax, p->rc.rfConstantMin); } } else if (p->rc.rateControlMode == X265_RC_CQP) @@ -1528,6 +1594,63 @@ char *x265_param2string(x265_param* p) if (p->bframes) s += sprintf(s, " pbratio=%.2f", p->rc.pbFactor); } + s += sprintf(s, " aq-mode=%d", p->rc.aqMode); + s += sprintf(s, " aq-strength=%.2f", p->rc.aqStrength); + BOOL(p->rc.cuTree, "cutree"); + s += sprintf(s, " zone-count=%d", p->rc.zoneCount); + if (p->rc.zoneCount) + { + for (int i = 0; i < p->rc.zoneCount; ++i) + { + s += sprintf(s, " zones: start-frame=%d end-frame=%d", + p->rc.zones[i].startFrame, p->rc.zones[i].endFrame); + if (p->rc.zones[i].bForceQp) + s += sprintf(s, " qp=%d", p->rc.zones[i].qp); + else + s += sprintf(s, " bitrate-factor=%f", p->rc.zones[i].bitrateFactor); + } + } + BOOL(p->rc.bStrictCbr, "strict-cbr"); + s += sprintf(s, " qg-size=%d", p->rc.qgSize); + BOOL(p->rc.bEnableGrain, "rc-grain"); + s += sprintf(s, " qpmax=%d qpmin=%d", p->rc.qpMax, p->rc.qpMin); + s += sprintf(s, " sar=%d", p->vui.aspectRatioIdc); + if (p->vui.aspectRatioIdc == X265_EXTENDED_SAR) + s += sprintf(s, " sar-width : sar-height=%d:%d", p->vui.sarWidth, p->vui.sarHeight); + s += sprintf(s, " overscan=%d", p->vui.bEnableOverscanInfoPresentFlag); + if (p->vui.bEnableOverscanInfoPresentFlag) + s += sprintf(s, " overscan-crop=%d", p->vui.bEnableOverscanAppropriateFlag); + s += sprintf(s, " videoformat=%d", p->vui.videoFormat); + s += sprintf(s, " range=%d", p->vui.bEnableVideoFullRangeFlag); + s += sprintf(s, " colorprim=%d", p->vui.colorPrimaries); + s += sprintf(s, " transfer=%d", p->vui.transferCharacteristics); + s += sprintf(s, " colormatrix=%d", p->vui.matrixCoeffs); + s += sprintf(s, " chromaloc=%d", p->vui.bEnableChromaLocInfoPresentFlag); + if (p->vui.bEnableChromaLocInfoPresentFlag) + s += sprintf(s, " chromaloc-top=%d chromaloc-bottom=%d", + p->vui.chromaSampleLocTypeTopField, p->vui.chromaSampleLocTypeBottomField); + s += sprintf(s, " display-window=%d", p->vui.bEnableDefaultDisplayWindowFlag); + if (p->vui.bEnableDefaultDisplayWindowFlag) + s += sprintf(s, " left=%d top=%d right=%d bottom=%d", + p->vui.defDispWinLeftOffset, p->vui.defDispWinTopOffset, + p->vui.defDispWinRightOffset, p->vui.defDispWinBottomOffset); + if (p->masteringDisplayColorVolume) + s += sprintf(s, " master-display=%s", p->masteringDisplayColorVolume); + s += sprintf(s, " max-cll=%hu,%hu", p->maxCLL, p->maxFALL); + s += sprintf(s, " min-luma=%hu", p->minLuma); + s += sprintf(s, " max-luma=%hu", p->maxLuma); + s += sprintf(s, " log2-max-poc-lsb=%d", p->log2MaxPocLsb); + BOOL(p->bEmitVUITimingInfo, "vui-timing-info"); + BOOL(p->bEmitVUIHRDInfo, "vui-hrd-info"); + s += sprintf(s, " slices=%d", p->maxSlices); + BOOL(p->bOptQpPPS, "opt-qp-pps"); + BOOL(p->bOptRefListLengthPPS, "opt-ref-list-length-pps"); + BOOL(p->bMultiPassOptRPS, "multi-pass-opt-rps"); + s += sprintf(s, " scenecut-bias=%.2f", p->scenecutBias); + BOOL(p->bOptCUDeltaQP, "opt-cu-delta-qp"); + BOOL(p->bAQMotion, "aq-motion"); + BOOL(p->bEmitHDRSEI, "hdr"); + BOOL(p->bHDROpt, "hdr-opt"); #undef BOOL return buf; } @@ -1537,10 +1660,10 @@ bool parseLambdaFile(x265_param* param) if (!param->rc.lambdaFileName) return false; - FILE *lfn = fopen(param->rc.lambdaFileName, "r"); + FILE *lfn = x265_fopen(param->rc.lambdaFileName, "r"); if (!lfn) { - x265_log(param, X265_LOG_ERROR, "unable to read lambda file <%s>\n", param->rc.lambdaFileName); + x265_log_file(param, X265_LOG_ERROR, "unable to read lambda file <%s>\n", param->rc.lambdaFileName); return true; } diff --git a/x265/alt_x265cli.h b/x265/alt_x265cli.h index 9f9f7051..e00887d9 100644 --- a/x265/alt_x265cli.h +++ b/x265/alt_x265cli.h @@ -121,9 +121,11 @@ static const struct option long_options[] = { "min-keyint", required_argument, NULL, 'i' }, { "scenecut", required_argument, NULL, 0 }, { "no-scenecut", no_argument, NULL, 0 }, + { "scenecut-bias", required_argument, NULL, 0 }, { "intra-refresh", no_argument, NULL, 0 }, { "rc-lookahead", required_argument, NULL, 0 }, { "lookahead-slices", required_argument, NULL, 0 }, + { "lookahead-threads", required_argument, NULL, 0 }, { "bframes", required_argument, NULL, 'b' }, { "bframe-bias", required_argument, NULL, 0 }, { "b-adapt", required_argument, NULL, 0 }, @@ -164,6 +166,7 @@ static const struct option long_options[] = { "rd", required_argument, NULL, 0 }, { "rdoq-level", required_argument, NULL, 0 }, { "no-rdoq-level", no_argument, NULL, 0 }, + { "dynamic-rd", required_argument, NULL, 0 }, { "psy-rd", required_argument, NULL, 0 }, { "psy-rdoq", required_argument, NULL, 0 }, { "no-psy-rd", no_argument, NULL, 0 }, @@ -217,6 +220,8 @@ static const struct option long_options[] = { "no-opt-qp-pps", no_argument, NULL, 0 }, { "opt-ref-list-length-pps", no_argument, NULL, 0 }, { "no-opt-ref-list-length-pps", no_argument, NULL, 0 }, + { "opt-cu-delta-qp", no_argument, NULL, 0 }, + { "no-opt-cu-delta-qp", no_argument, NULL, 0 }, { "no-dither", no_argument, NULL, 0 }, { "dither", no_argument, NULL, 0 }, { "no-repeat-headers", no_argument, NULL, 0 }, @@ -234,8 +239,14 @@ static const struct option long_options[] = { "nr-inter", required_argument, NULL, 0 }, { "stats", required_argument, NULL, 0 }, { "pass", required_argument, NULL, 0 }, + { "multi-pass-opt-analysis", no_argument, NULL, 0 }, + { "no-multi-pass-opt-analysis", no_argument, NULL, 0 }, + { "multi-pass-opt-distortion", no_argument, NULL, 0 }, + { "no-multi-pass-opt-distortion", no_argument, NULL, 0 }, { "slow-firstpass", no_argument, NULL, 0 }, { "no-slow-firstpass", no_argument, NULL, 0 }, + { "multi-pass-opt-rps", no_argument, NULL, 0 }, + { "no-multi-pass-opt-rps", no_argument, NULL, 0 }, { "analysis-mode", required_argument, NULL, 0 }, { "analysis-file", required_argument, NULL, 0 }, { "strict-cbr", no_argument, NULL, 0 }, @@ -246,6 +257,14 @@ static const struct option long_options[] = { "analyze-src-pics", no_argument, NULL, 0 }, { "no-analyze-src-pics", no_argument, NULL, 0 }, { "slices", required_argument, NULL, 0 }, + { "aq-motion", no_argument, NULL, 0 }, + { "no-aq-motion", no_argument, NULL, 0 }, + { "ssim-rd", no_argument, NULL, 0 }, + { "no-ssim-rd", no_argument, NULL, 0 }, + { "hdr", no_argument, NULL, 0 }, + { "no-hdr", no_argument, NULL, 0 }, + { "hdr-opt", no_argument, NULL, 0 }, + { "no-hdr-opt", no_argument, NULL, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, @@ -324,12 +343,14 @@ static void showHelp(x265_param *param) H0(" --max-tu-size <32|16|8|4> Maximum TU size (WxH). Default %d\n", param->maxTUSize); H0(" --tu-intra-depth Max TU recursive depth for intra CUs. Default %d\n", param->tuQTMaxIntraDepth); H0(" --tu-inter-depth Max TU recursive depth for inter CUs. Default %d\n", param->tuQTMaxInterDepth); - H0(" --limit-tu Enable early exit from TU recursion for inter coded blocks. Default %d\n", param->limitTU); + H0(" --limit-tu <0..4> Enable early exit from TU recursion for inter coded blocks. Default %d\n", param->limitTU); H0("\nAnalysis:\n"); H0(" --rd <1..6> Level of RDO in mode decision 1:least....6:full RDO. Default %d\n", param->rdLevel); H0(" --[no-]psy-rd <0..5.0> Strength of psycho-visual rate distortion optimization, 0 to disable. Default %.1f\n", param->psyRd); H0(" --[no-]rdoq-level <0|1|2> Level of RDO in quantization 0:none, 1:levels, 2:levels & coding groups. Default %d\n", param->rdoqLevel); H0(" --[no-]psy-rdoq <0..50.0> Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default %.1f\n", param->psyRdoq); + H0(" --dynamic-rd <0..4.0> Strength of dynamic RD, 0 to disable. Default %.2f\n", param->dynamicRd); + H0(" --[no-]ssim-rd Enable ssim rate distortion optimization, 0 to disable. Default %s\n", OPT(param->bSsimRd)); H0(" --[no-]rd-refine Enable QP based RD refinement for rd levels 5 and 6. Default %s\n", OPT(param->bEnableRdRefine)); H0(" --[no-]early-skip Enable early SKIP detection. Default %s\n", OPT(param->bEnableEarlySkip)); H0(" --[no-]rskip Enable early exit from recursion. Default %s\n", OPT(param->bEnableRecursionSkip)); @@ -365,9 +386,11 @@ static void showHelp(x265_param *param) H0("-i/--min-keyint Scenecuts closer together than this are coded as I, not IDR. Default: auto\n"); H0(" --no-scenecut Disable adaptive I-frame decision\n"); H0(" --scenecut How aggressively to insert extra I-frames. Default %d\n", param->scenecutThreshold); + H1(" --scenecut-bias <0..100.0> Bias for scenecut detection. Default %.2f\n", param->scenecutBias); H0(" --intra-refresh Use Periodic Intra Refresh instead of IDR frames\n"); H0(" --rc-lookahead Number of frames for frame-type lookahead (determines encoder latency) Default %d\n", param->lookaheadDepth); H1(" --lookahead-slices <0..16> Number of slices to use per lookahead cost estimate. Default %d\n", param->lookaheadSlices); + H0(" --lookahead-threads Number of threads to be dedicated to perform lookahead only. Default %d\n", param->lookaheadThreads); H0(" --bframes Maximum number of consecutive b-frames (now it only enables B GOP structure) Default %d\n", param->bframes); H1(" --bframe-bias Bias towards B frame decisions. Default %d\n", param->bFrameBias); H0(" --b-adapt <0..2> 0 - none, 1 - fast, 2 - full (trellis) adaptive B frame scheduling. Default %d\n", param->bFrameAdaptive); @@ -392,6 +415,8 @@ static void showHelp(x265_param *param) " - 1 : First pass, creates stats file\n" " - 2 : Last pass, does not overwrite stats file\n" " - 3 : Nth pass, overwrites stats file\n"); + H0(" --[no-]multi-pass-opt-analysis Refine analysis in 2 pass based on analysis information from pass 1\n"); + H0(" --[no-]multi-pass-opt-distortion Use distortion of CTU from pass 1 to refine qp in 2 pass\n"); H0(" --stats Filename for stats file in multipass pass rate control. Default x265_2pass.log\n"); H0(" --[no-]analyze-src-pics Motion estimation uses source frame planes. Default disable\n"); H0(" --[no-]slow-firstpass Enable a slow first pass in a multipass rate control mode. Default %s\n", OPT(param->rc.bEnableSlowFirstPass)); @@ -400,6 +425,7 @@ static void showHelp(x265_param *param) H0(" --analysis-file Specify file name used for either dumping or reading analysis data.\n"); H0(" --aq-mode Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes. Default %d\n", param->rc.aqMode); H0(" --aq-strength Reduces blocking and blurring in flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength); + H0(" --[no-]aq-motion Adaptive Quantization based on the relative motion of each CU w.r.t., frame. Default %s\n", OPT(param->bOptCUDeltaQP)); H0(" --qg-size Specifies the size of the quantization group (64, 32, 16, 8). Default %d\n", param->rc.qgSize); H0(" --[no-]cutree Enable cutree for Adaptive Quantization. Default %s\n", OPT(param->rc.cuTree)); H0(" --[no-]rc-grain Enable ratecontrol mode to handle grains specifically. turned on with tune grain. Default %s\n", OPT(param->rc.bEnableGrain)); @@ -446,6 +472,8 @@ static void showHelp(x265_param *param) H0(" --master-display SMPTE ST 2086 master display color volume info SEI (HDR)\n"); H0(" format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n"); H0(" --max-cll Emit content light level info SEI as \"cll,fall\" (HDR)\n"); + H0(" --[no-]hdr Control dumping of HDR SEI packet. If max-cll or master-display has non-zero values, this is enabled. Default %s\n", OPT(param->bEmitHDRSEI)); + H0(" --[no-]hdr-opt Add luma and chroma offsets for HDR/WCG content. Default %s\n", OPT(param->bHDROpt)); H0(" --min-luma Minimum luma plane value of input source picture\n"); H0(" --max-luma Maximum luma plane value of input source picture\n"); H0("\nBitstream options:\n"); @@ -456,10 +484,12 @@ static void showHelp(x265_param *param) H0(" --[no-]aud Emit access unit delimiters at the start of each access unit. Default %s\n", OPT(param->bEnableAccessUnitDelimiters)); H1(" --hash Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI); H0(" --log2-max-poc-lsb Maximum of the picture order count\n"); - H0(" --[no-]vui-timing-info Discard optional VUI timing information from the bistream. Default %s\n", OPT(param->bEmitVUITimingInfo)); - H0(" --[no-]vui-hrd-info Discard optional HRD timing information from the bistream. Default %s\n", OPT(param->bEmitVUIHRDInfo)); - H0(" --[no-]opt-qp-pps Discard optional HRD timing information from the bistream. Default %s\n", OPT(param->bOptQpPPS)); - H0(" --[no-]opt-ref-list-length-pps Discard optional HRD timing information from the bistream. Default %s\n", OPT(param->bOptRefListLengthPPS)); + H0(" --[no-]vui-timing-info Emit VUI timing information in the bistream. Default %s\n", OPT(param->bEmitVUITimingInfo)); + H0(" --[no-]vui-hrd-info Emit VUI HRD information in the bistream. Default %s\n", OPT(param->bEmitVUIHRDInfo)); + H0(" --[no-]opt-qp-pps Dynamically optimize QP in PPS (instead of default 26) based on QPs in previous GOP. Default %s\n", OPT(param->bOptQpPPS)); + H0(" --[no-]opt-ref-list-length-pps Dynamically set L0 and L1 ref list length in PPS (instead of default 0) based on values in last GOP. Default %s\n", OPT(param->bOptRefListLengthPPS)); + H0(" --[no-]multi-pass-opt-rps Enable storing commonly used RPS in SPS in multi pass mode. Default %s\n", OPT(param->bMultiPassOptRPS)); + H0(" --[no-]opt-cu-delta-qp Optimize to signal consistent CU level delta QPs in frame. Default %s\n", OPT(param->bOptCUDeltaQP)); H1("\nReconstructed video options (debugging):\n"); H1("-r/--recon Reconstructed raw image YUV or Y4M output file name\n"); H1(" --recon-depth Bit-depth of reconstructed raw image file. Defaults to input bit depth, or 8 if Y4M\n"); diff --git a/x265/param.cpp b/x265/param.cpp index 3b601f71..70bb478f 100644 --- a/x265/param.cpp +++ b/x265/param.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2013 x265 project + * Copyright (C) 2013-2017 MulticoreWare, Inc * * Authors: Deepthi Nandakumar * Min Chen @@ -187,7 +187,7 @@ void x265_param_default(x265_param* param) /* SAO Loop Filter */ param->bEnableSAO = 1; param->bSaoNonDeblocked = 0; - + param->bLimitSAO = 0; /* Coding Quality */ param->cbQpOffset = 0; param->crQpOffset = 0; @@ -271,7 +271,10 @@ void x265_param_default(x265_param* param) param->bOptCUDeltaQP = 0; param->bAQMotion = 0; param->bHDROpt = 0; + param->analysisRefineLevel = 5; + param->toneMapFile = NULL; + param->bDhdr10opt = 0; } int x265_param_default_preset(x265_param* param, const char* preset, const char* tune) @@ -395,6 +398,7 @@ int x265_param_default_preset(x265_param* param, const char* preset, const char* param->limitModes = 1; param->bIntraInBFrames = 1; param->lookaheadSlices = 4; // limit parallelism as already enough work exists + param->limitTU = 4; } else if (!strcmp(preset, "veryslow")) { @@ -416,6 +420,7 @@ int x265_param_default_preset(x265_param* param, const char* preset, const char* param->limitModes = 1; param->bIntraInBFrames = 1; param->lookaheadSlices = 0; // disabled for best quality + param->limitTU = 4; } else if (!strcmp(preset, "placebo")) { @@ -933,6 +938,7 @@ int x265_param_parse(x265_param* p, const char* name, const char* value) OPT("multi-pass-opt-distortion") p->analysisMultiPassDistortion = atobool(value); OPT("aq-motion") p->bAQMotion = atobool(value); OPT("dynamic-rd") p->dynamicRd = atof(value); + OPT("refine-level") p->analysisRefineLevel = atoi(value); OPT("ssim-rd") { int bval = atobool(value); @@ -945,6 +951,9 @@ int x265_param_parse(x265_param* p, const char* name, const char* value) } OPT("hdr") p->bEmitHDRSEI = atobool(value); OPT("hdr-opt") p->bHDROpt = atobool(value); + OPT("limit-sao") p->bLimitSAO = atobool(value); + OPT("dhdr10-info") p->toneMapFile = strdup(value); + OPT("dhdr10-opt") p->bDhdr10opt = atobool(value); else return X265_PARAM_BAD_NAME; } @@ -1277,6 +1286,8 @@ int x265_check_params(x265_param* param) "Strict-cbr cannot be applied without specifying target bitrate or vbv bufsize"); CHECK(param->analysisMode && (param->analysisMode < X265_ANALYSIS_OFF || param->analysisMode > X265_ANALYSIS_LOAD), "Invalid analysis mode. Analysis mode 0: OFF 1: SAVE : 2 LOAD"); + CHECK(param->analysisMode && (param->analysisRefineLevel < 1 || param->analysisRefineLevel > 10), + "Invalid analysis refine level. Value must be between 1 and 10 (inclusive)"); CHECK(param->rc.qpMax < QP_MIN || param->rc.qpMax > QP_MAX_MAX, "qpmax exceeds supported range (0 to 69)"); CHECK(param->rc.qpMin < QP_MIN || param->rc.qpMin > QP_MAX_MAX, @@ -1425,6 +1436,7 @@ void x265_print_params(x265_param* param) TOOLOPT(param->limitModes, "limit-modes"); TOOLVAL(param->rdLevel, "rd=%d"); TOOLVAL(param->dynamicRd, "dynamic-rd=%.2f"); + TOOLOPT(param->bSsimRd, "ssim-rd"); TOOLVAL(param->psyRd, "psy-rd=%.2lf"); TOOLVAL(param->rdoqLevel, "rdoq=%d"); TOOLVAL(param->psyRdoq, "psy-rdoq=%.2lf"); @@ -1461,6 +1473,9 @@ void x265_print_params(x265_param* param) TOOLOPT(!param->bSaoNonDeblocked && param->bEnableSAO, "sao"); TOOLOPT(param->rc.bStatWrite, "stats-write"); TOOLOPT(param->rc.bStatRead, "stats-read"); +#if ENABLE_DYNAMIC_HDR10 + TOOLVAL(param->toneMapFile != NULL, "dhdr10-info"); +#endif x265_log(param, X265_LOG_INFO, "tools:%s\n", buf); fflush(stderr); } @@ -1525,6 +1540,7 @@ char *x265_param2string(x265_param* p, int padx, int pady) s += sprintf(s, " limit-tu=%d", p->limitTU); s += sprintf(s, " rdoq-level=%d", p->rdoqLevel); s += sprintf(s, " dynamic-rd=%.2f", p->dynamicRd); + BOOL(p->bSsimRd, "ssim-rd"); BOOL(p->bEnableSignHiding, "signhide"); BOOL(p->bEnableTransformSkip, "tskip"); s += sprintf(s, " nr-intra=%d", p->noiseReductionIntra); @@ -1651,6 +1667,9 @@ char *x265_param2string(x265_param* p, int padx, int pady) BOOL(p->bAQMotion, "aq-motion"); BOOL(p->bEmitHDRSEI, "hdr"); BOOL(p->bHDROpt, "hdr-opt"); + BOOL(p->bDhdr10opt, "dhdr10-opt"); + s += sprintf(s, " refine-level=%d", p->analysisRefineLevel); + BOOL(p->bLimitSAO, "limit-sao"); #undef BOOL return buf; } diff --git a/x265/x265cli.h b/x265/x265cli.h index e00887d9..7b85d952 100644 --- a/x265/x265cli.h +++ b/x265/x265cli.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2013 x265 project + * Copyright (C) 2013-2017 MulticoreWare, Inc * * Authors: Steve Borho * Min Chen @@ -249,6 +249,7 @@ static const struct option long_options[] = { "no-multi-pass-opt-rps", no_argument, NULL, 0 }, { "analysis-mode", required_argument, NULL, 0 }, { "analysis-file", required_argument, NULL, 0 }, + { "refine-level", required_argument, NULL, 0 }, { "strict-cbr", no_argument, NULL, 0 }, { "temporal-layers", no_argument, NULL, 0 }, { "no-temporal-layers", no_argument, NULL, 0 }, @@ -265,6 +266,11 @@ static const struct option long_options[] = { "no-hdr", no_argument, NULL, 0 }, { "hdr-opt", no_argument, NULL, 0 }, { "no-hdr-opt", no_argument, NULL, 0 }, + { "limit-sao", no_argument, NULL, 0 }, + { "no-limit-sao", no_argument, NULL, 0 }, + { "dhdr10-info", required_argument, NULL, 0 }, + { "dhdr10-opt", no_argument, NULL, 0}, + { "no-dhdr10-opt", no_argument, NULL, 0}, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, @@ -310,6 +316,10 @@ static void showHelp(x265_param *param) H1(" 1 - i420 (4:2:0 default)\n"); H1(" 2 - i422 (4:2:2)\n"); H1(" 3 - i444 (4:4:4)\n"); +#if ENABLE_DYNAMIC_HDR10 + H0(" --dhdr10-info JSON file containing the Creative Intent Metadata to be encoded as Dynamic Tone Mapping \n"); + H0(" --[no-]dhdr10-opt Insert tone mapping SEI only for IDR frames and when the tone mapping information changes. Default disabled"); +#endif H0("-f/--frames Maximum number of frames to encode. Default all\n"); H0(" --seek First frame to encode\n"); H1(" --[no-]interlace Indicate input pictures are interlace fields in temporal order. Default progressive\n"); @@ -423,6 +433,7 @@ static void showHelp(x265_param *param) H0(" --[no-]strict-cbr Enable stricter conditions and tolerance for bitrate deviations in CBR mode. Default %s\n", OPT(param->rc.bStrictCbr)); H0(" --analysis-mode save - Dump analysis info into file, load - Load analysis buffers from the file. Default %d\n", param->analysisMode); H0(" --analysis-file Specify file name used for either dumping or reading analysis data.\n"); + H0(" --refine-level <1..10> Level of analysis refinement indicates amount of info stored/reused in save/load mode, 1:least....10:most. Default %d\n", param->analysisRefineLevel); H0(" --aq-mode Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes. Default %d\n", param->rc.aqMode); H0(" --aq-strength Reduces blocking and blurring in flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength); H0(" --[no-]aq-motion Adaptive Quantization based on the relative motion of each CU w.r.t., frame. Default %s\n", OPT(param->bOptCUDeltaQP)); @@ -452,6 +463,7 @@ static void showHelp(x265_param *param) H0(" --[no-]deblock Enable Deblocking Loop Filter, optionally specify tC:Beta offsets Default %s\n", OPT(param->bEnableLoopFilter)); H0(" --[no-]sao Enable Sample Adaptive Offset. Default %s\n", OPT(param->bEnableSAO)); H1(" --[no-]sao-non-deblock Use non-deblocked pixels, else right/bottom boundary areas skipped. Default %s\n", OPT(param->bSaoNonDeblocked)); + H0(" --[no-]limit-sao Limit Sample Adaptive Offset types. Default %s\n", OPT(param->bLimitSAO)); H0("\nVUI options:\n"); H0(" --sar Sample Aspect Ratio, the ratio of width to height of an individual pixel.\n"); H0(" Choose from 0=undef, 1=1:1(\"square\"), 2=12:11, 3=10:11, 4=16:11,\n");