Skip to content

Commit

Permalink
Add interlacing field order selection
Browse files Browse the repository at this point in the history
  • Loading branch information
simontime authored Jun 29, 2024
1 parent 2d46e67 commit 7a84582
Show file tree
Hide file tree
Showing 6 changed files with 698 additions and 652 deletions.
9 changes: 9 additions & 0 deletions Brovicon/Brovicon.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="Main.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>
1,210 changes: 572 additions & 638 deletions Brovicon/Main.Designer.cs

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Brovicon/Main.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using static Brovicon.Standards;

namespace Brovicon
{
public partial class Main : Form
Expand All @@ -16,6 +18,9 @@ private void Main_Load(object sender, EventArgs e)
// No resize
boxResizeMode.SelectedIndex = 0;

// Set FieldOrder enum data source for combo box
boxFieldOrder.DataSource = Enum.GetValues(typeof(FieldOrder));

// Ensure dependencies exist
if (!File.Exists("avs/ffmpeg.exe"))
{
Expand Down Expand Up @@ -82,13 +87,21 @@ private void chkForceInterlaced_CheckedChanged(object sender, EventArgs e)
{
// Unchecks 'Force Progressive' if it is checked
chkForceProgressive.Checked &= !chkForceInterlaced.Checked;

// Enables field order selector
lblFieldOrder.Enabled = chkForceInterlaced.Checked;
boxFieldOrder.Enabled = chkForceInterlaced.Checked;
}

// Triggered when 'Force Progressive' is toggled
private void chkForceProgressive_CheckedChanged(object sender, EventArgs e)
{
// Unchecks 'Force Interlaced' if it is checked
chkForceInterlaced.Checked &= !chkForceProgressive.Checked;

// Disables field order selector
lblFieldOrder.Enabled = false;
boxFieldOrder.Enabled = false;
}

// Triggered when resize mode is changed
Expand Down Expand Up @@ -360,6 +373,12 @@ private async void btnConvert_Click(object sender, EventArgs e)
if (chkForceProgressive.Checked)
deInterlace = false;

// Field order
var fieldOrder = FieldOrder.Auto;

if (boxFieldOrder.Enabled)
fieldOrder = (FieldOrder)boxFieldOrder.SelectedItem;

// Codecs and bit rates
var videoCodec = boxOutputVideoCodec.Text.ToLower();
var videoBitRate = 0;
Expand All @@ -384,6 +403,7 @@ private async void btnConvert_Click(object sender, EventArgs e)
var script = Scripting.GenerateAviSynthScript(
inputFilename,
deInterlace,
fieldOrder,
processNoise,
originalHeight,
originalRatio,
Expand Down
62 changes: 61 additions & 1 deletion Brovicon/Main.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down
41 changes: 28 additions & 13 deletions Brovicon/Scripting.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Brovicon
using static Brovicon.Standards;

namespace Brovicon
{
static class Scripting
{
Expand All @@ -25,18 +27,19 @@ static class Scripting
// Generates an AviSynth script given parameters
public static string GenerateAviSynthScript
(
string videoFileName,
bool deInterlace,
bool deNoise,
int originalHeight,
double originalRatio,
int targetWidth,
int targetHeight,
double cropRatio,
double stretchRatio,
bool stretchFirst,
double targetFrameRate,
bool interpolate
string videoFileName,
bool deInterlace,
FieldOrder fieldOrder,
bool deNoise,
int originalHeight,
double originalRatio,
int targetWidth,
int targetHeight,
double cropRatio,
double stretchRatio,
bool stretchFirst,
double targetFrameRate,
bool interpolate
)
{
// String the script will be written to
Expand Down Expand Up @@ -93,7 +96,19 @@ void callFunction(string function, params object[] args)

// De-interlace
if (deInterlace)
{
// Set field order
if (fieldOrder != FieldOrder.Auto)
{
if (fieldOrder == FieldOrder.Upper)
callFunction("AssumeTFF");

if (fieldOrder == FieldOrder.Lower)
callFunction("AssumeBFF");
}

callFunction("QTGMC");
}

// De-noise
if (deNoise)
Expand Down
8 changes: 8 additions & 0 deletions Brovicon/Standards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
{
static class Standards
{
// Interlacing - field dominance
public enum FieldOrder
{
Auto,
Upper,
Lower
}

public class NTSC : IStandard
{
// NTSC rates only
Expand Down

0 comments on commit 7a84582

Please sign in to comment.