Skip to content

Commit c64d386

Browse files
author
RandomEngy
committed
Adds Modulus dropdown to Loose anamorphic choice. Fixed a problem where the
incorrect scaling would be chosen and pick the wrong aspect ratio. --HG-- branch : beta
1 parent 8f26c19 commit c64d386

8 files changed

Lines changed: 74 additions & 4 deletions

File tree

Lib/x64/HandBrakeInterop.dll

0 Bytes
Binary file not shown.

Lib/x64/HandBrakeInterop.pdb

0 Bytes
Binary file not shown.

Lib/x86/HandBrakeInterop.dll

512 Bytes
Binary file not shown.

Lib/x86/HandBrakeInterop.pdb

0 Bytes
Binary file not shown.

VidCoder/Utilities/EncodeProxy.cs

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace VidCoder
1414
using System.Xml.Serialization;
1515
using HandBrake.Interop;
1616
using HandBrake.Interop.Model;
17+
using HandBrake.Interop.SourceData;
1718
using Model;
1819
using Properties;
1920
using Services;
@@ -48,6 +49,10 @@ public class EncodeProxy : IHandBrakeEncoderCallback
4849
private ManualResetEventSlim encodeStartEvent;
4950
private ManualResetEventSlim encodeEndEvent;
5051

52+
// Instance and lock only used when doing in-process encode (for debugging)
53+
private HandBrakeInstance instance;
54+
private object encodeLock = new object();
55+
5156
// Timer that pings the worker process periodically to see if it's still alive.
5257
private Timer pingTimer;
5358

@@ -61,6 +66,11 @@ public class EncodeProxy : IHandBrakeEncoderCallback
6166

6267
public void StartEncode(EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds)
6368
{
69+
//#if DEBUG
70+
// this.StartEncodeInProcess(job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);
71+
// return;
72+
//#endif
73+
6474
this.logger = Unity.Container.Resolve<ILogger>();
6575

6676
this.encodeStartEvent = new ManualResetEventSlim(false);
@@ -163,6 +173,54 @@ public void StartEncode(EncodeJob job, bool preview, int previewNumber, int prev
163173
task.Start();
164174
}
165175

176+
private void StartEncodeInProcess(EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds)
177+
{
178+
this.encoding = true;
179+
180+
this.encodeStartEvent = new ManualResetEventSlim(false);
181+
this.encodeEndEvent = new ManualResetEventSlim(false);
182+
183+
this.instance = new HandBrakeInstance();
184+
this.instance.Initialize(Settings.Default.LogVerbosity);
185+
186+
this.instance.ScanCompleted += (o, e) =>
187+
{
188+
try
189+
{
190+
Title encodeTitle = this.instance.Titles.FirstOrDefault(title => title.TitleNumber == job.Title);
191+
192+
if (encodeTitle != null)
193+
{
194+
lock (this.encodeLock)
195+
{
196+
this.instance.StartEncode(job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds);
197+
this.OnEncodeStarted();
198+
}
199+
}
200+
else
201+
{
202+
this.OnEncodeComplete(true);
203+
}
204+
}
205+
catch (Exception exception)
206+
{
207+
this.OnException(exception.ToString());
208+
}
209+
};
210+
211+
this.instance.EncodeProgress += (o, e) =>
212+
{
213+
this.OnEncodeProgress(e.AverageFrameRate, e.CurrentFrameRate, e.EstimatedTimeLeft, e.FractionComplete, e.Pass);
214+
};
215+
216+
this.instance.EncodeCompleted += (o, e) =>
217+
{
218+
this.OnEncodeComplete(e.Error);
219+
};
220+
221+
this.instance.StartScan(job.SourcePath, Settings.Default.PreviewCount, job.Title);
222+
}
223+
166224
public void PauseEncode()
167225
{
168226
lock (this.encoderLock)
@@ -334,7 +392,10 @@ private void EndEncode(bool error)
334392
});
335393
}
336394

337-
this.pingTimer.Dispose();
395+
if (this.pingTimer != null)
396+
{
397+
this.pingTimer.Dispose();
398+
}
338399

339400
this.encoding = false;
340401
}

VidCoder/View/Panels/PicturePanel.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@
148148

149149
<Label
150150
Grid.Row="1" Grid.Column="0" Height="24" HorizontalAlignment="Left" VerticalAlignment="Center"
151-
Visibility="{Binding CustomAnamorphicFieldsVisible, Converter={StaticResource VisibilityConverter}}"
151+
Visibility="{Binding ModulusVisible, Converter={StaticResource VisibilityConverter}}"
152152
Content="{x:Static res:EncodingRes.ModulusLabel}"/>
153153
<ComboBox
154154
Grid.Row="1" Grid.Column="1" Height="22" VerticalAlignment="Top" Margin="0,1,0,0" HorizontalAlignment="Left" MinWidth="65"
155155
SelectedValue="{Binding Modulus}"
156156
SelectedValuePath="Content"
157-
Visibility="{Binding CustomAnamorphicFieldsVisible, Converter={StaticResource VisibilityConverter}}">
157+
Visibility="{Binding ModulusVisible, Converter={StaticResource VisibilityConverter}}">
158158
<ComboBoxItem>16</ComboBoxItem>
159159
<ComboBoxItem>8</ComboBoxItem>
160160
<ComboBoxItem>4</ComboBoxItem>

VidCoder/ViewModel/Panels/PicturePanelViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ public AnamorphicCombo SelectedAnamorphic
330330

331331
this.RaisePropertyChanged(() => this.SelectedAnamorphic);
332332
this.RaisePropertyChanged(() => this.CustomAnamorphicFieldsVisible);
333+
this.RaisePropertyChanged(() => this.ModulusVisible);
333334
this.RaisePropertyChanged(() => this.PixelAspectVisibile);
334335
this.RaisePropertyChanged(() => this.KeepDisplayAspect);
335336
this.RaisePropertyChanged(() => this.KeepDisplayAspectEnabled);
@@ -367,6 +368,14 @@ public int Modulus
367368
}
368369
}
369370

371+
public bool ModulusVisible
372+
{
373+
get
374+
{
375+
return this.Profile.Anamorphic == Anamorphic.Custom || this.Profile.Anamorphic == Anamorphic.Loose;
376+
}
377+
}
378+
370379
public bool UseDisplayWidth
371380
{
372381
get
@@ -653,6 +662,7 @@ public void NotifyAllChanged()
653662
this.RaisePropertyChanged(() => this.KeepDisplayAspectEnabled);
654663
this.RaisePropertyChanged(() => this.SelectedAnamorphic);
655664
this.RaisePropertyChanged(() => this.CustomAnamorphicFieldsVisible);
665+
this.RaisePropertyChanged(() => this.ModulusVisible);
656666
this.RaisePropertyChanged(() => this.Modulus);
657667
this.RaisePropertyChanged(() => this.UseDisplayWidth);
658668
this.RaisePropertyChanged(() => this.DisplayWidth);

VidCoder/ViewModel/PreviewViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ private void RefreshPreviews()
542542

543543
this.job = this.mainViewModel.EncodeJob;
544544

545-
//EncodingProfile profile = this.job.EncodingProfile;
546545
int width, height;
547546

548547
int parWidth, parHeight;

0 commit comments

Comments
 (0)