diff options
author | sr55 <[email protected]> | 2015-01-18 18:10:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-18 18:10:12 +0000 |
commit | fcf8255c2e1c6c646e1fa184cca8c2cd9d2fc5b6 (patch) | |
tree | f20fe9ddfe7e36e6a19d40dd53534e98867e0abf /win | |
parent | 3971869f634466f832c3ec33e0e9b1779058156f (diff) |
WinGui: Removing some redundant code from the interop library.
Fixed the libdvdnav option for the libhb based encoding.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6768 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
7 files changed, 6 insertions, 326 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 0fbc7dbfe..215b05e02 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -134,6 +134,8 @@ namespace HandBrake.ApplicationServices.Services.Encode this.ScanCompleted(job, this.instance);
};
+ HandBrakeUtils.SetDvdNav(!job.Configuration.IsDvdNavDisabled);
+
this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
}
catch (Exception exc)
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 2ffc766b5..50388fc0d 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -68,7 +68,6 @@ namespace HandBrake.ApplicationServices.Utilities // Audio Settings
job.AudioEncodings = new List<AudioEncoding>();
- job.ChosenAudioTracks = new List<int>();
foreach (AudioTrack track in work.AudioTracks)
{
AudioEncoding newTrack = new AudioEncoding
@@ -86,10 +85,6 @@ namespace HandBrake.ApplicationServices.Utilities };
job.AudioEncodings.Add(newTrack);
- if (track.Track != null)
- {
- job.ChosenAudioTracks.Add(track.Track.Value);
- }
}
// Title Settings
@@ -155,7 +150,6 @@ namespace HandBrake.ApplicationServices.Utilities // Picture Settings
job.Anamorphic = work.Anamorphic;
job.Cropping = new Cropping { Top = work.Cropping.Top, Bottom = work.Cropping.Bottom, Left = work.Cropping.Left, Right = work.Cropping.Right };
- job.CroppingType = CroppingType.Custom; // TODO deal with this better
job.DisplayWidth = work.DisplayWidth.HasValue ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString()) : 0;
job.PixelAspectX = work.PixelAspectX;
job.PixelAspectY = work.PixelAspectY;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index 52939e219..7d5c59f0d 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -233,7 +233,6 @@ <Compile Include="HandBrakeEncoderHelpers.cs" />
<Compile Include="Model\Encoding\Anamorphic.cs" />
<Compile Include="Model\Encoding\AudioEncodeRateType.cs" />
- <Compile Include="Model\Encoding\CroppingType.cs" />
<Compile Include="Model\Encoding\HBAudioEncoder.cs" />
<Compile Include="Model\Encoding\AudioEncoder.cs" />
<Compile Include="Model\Encoding\AudioEncoding.cs" />
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 1d7042ab3..1726ea635 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -295,249 +295,6 @@ namespace HandBrake.Interop }
/// <summary>
- /// Gets the total number of seconds on the given encode job.
- /// </summary>
- /// <param name="job">
- /// The encode job to query.
- /// </param>
- /// <param name="title">
- /// The title being encoded.
- /// </param>
- /// <returns>
- /// The total number of seconds of video to encode.
- /// </returns>
- internal static double GetJobLengthSeconds(EncodeJob job, Title title)
- {
- switch (job.RangeType)
- {
- // case VideoRangeType.All:
- // return title.Duration.TotalSeconds;
- case VideoRangeType.Chapters:
- TimeSpan duration = TimeSpan.Zero;
- for (int i = job.ChapterStart; i <= job.ChapterEnd; i++)
- {
- duration += title.Chapters[i - 1].Duration;
- }
-
- return duration.TotalSeconds;
- case VideoRangeType.Seconds:
- return job.SecondsEnd - job.SecondsStart;
- case VideoRangeType.Frames:
- return (job.FramesEnd - job.FramesStart) / title.Framerate;
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the number of audio samples used per frame for the given audio encoder.
- /// </summary>
- /// <param name="encoderName">
- /// The encoder to query.
- /// </param>
- /// <returns>
- /// The number of audio samples used per frame for the given
- /// audio encoder.
- /// </returns>
- internal static int GetAudioSamplesPerFrame(string encoderName)
- {
- switch (encoderName)
- {
- case "faac":
- case "ffaac":
- case "copy:aac":
- case "vorbis":
- return 1024;
- case "lame":
- case "copy:mp3":
- return 1152;
- case "ffac3":
- case "copy":
- case "copy:ac3":
- case "copy:dts":
- case "copy:dtshd":
- return 1536;
- }
-
- // Unknown encoder; make a guess.
- return 1536;
- }
-
- /// <summary>
- /// Gets the size in bytes for the audio with the given parameters.
- /// </summary>
- /// <param name="job">
- /// The encode job.
- /// </param>
- /// <param name="lengthSeconds">
- /// The length of the encode in seconds.
- /// </param>
- /// <param name="title">
- /// The title to encode.
- /// </param>
- /// <param name="outputTrackList">
- /// The list of tracks to encode.
- /// </param>
- /// <returns>
- /// The size in bytes for the audio with the given parameters.
- /// </returns>
- internal static long GetAudioSize(EncodeJob job, double lengthSeconds, Title title, List<Tuple<AudioEncoding, int>> outputTrackList)
- {
- long audioBytes = 0;
-
- foreach (Tuple<AudioEncoding, int> outputTrack in outputTrackList)
- {
- AudioEncoding encoding = outputTrack.Item1;
- AudioTrack track = title.AudioTracks[outputTrack.Item2 - 1];
-
- int samplesPerFrame = GetAudioSamplesPerFrame(encoding.Encoder);
- int audioBitrate;
-
- HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(encoding.Encoder);
-
- if (audioEncoder.IsPassthrough)
- {
- // Input bitrate is in bits/second.
- audioBitrate = track.Bitrate / 8;
- }
- else if (encoding.EncodeRateType == AudioEncodeRateType.Quality)
- {
- // Can't predict size of quality targeted audio encoding.
- audioBitrate = 0;
- }
- else
- {
- int outputBitrate;
- if (encoding.Bitrate > 0)
- {
- outputBitrate = encoding.Bitrate;
- }
- else
- {
- outputBitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(
- audioEncoder,
- encoding.SampleRateRaw == 0 ? track.SampleRate : encoding.SampleRateRaw,
- HandBrakeEncoderHelpers.SanitizeMixdown(HandBrakeEncoderHelpers.GetMixdown(encoding.Mixdown), audioEncoder, track.ChannelLayout));
- }
-
- // Output bitrate is in kbps.
- audioBitrate = outputBitrate * 1000 / 8;
- }
-
- audioBytes += (long)(lengthSeconds * audioBitrate);
-
- // Audio overhead
- audioBytes += encoding.SampleRateRaw * ContainerOverheadPerFrame / samplesPerFrame;
- }
-
- return audioBytes;
- }
-
- /// <summary>
- /// Calculates the video bitrate for the given job and target size.
- /// </summary>
- /// <param name="job">
- /// The encode job.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="sizeMB">
- /// The target size in MB.
- /// </param>
- /// <param name="overallSelectedLengthSeconds">
- /// The currently selected encode length. Used in preview
- /// for calculating bitrate when the target size would be wrong.
- /// </param>
- /// <returns>
- /// The video bitrate in kbps.
- /// </returns>
- public static int CalculateBitrate(EncodeJob job, Title title, int sizeMB, double overallSelectedLengthSeconds = 0)
- {
- long availableBytes = ((long)sizeMB) * 1024 * 1024;
-
- EncodeJob profile = job;
-
- double lengthSeconds = overallSelectedLengthSeconds > 0 ? overallSelectedLengthSeconds : GetJobLengthSeconds(job, title);
- lengthSeconds += 1.5;
-
- double outputFramerate;
- if (profile.Framerate == 0)
- {
- outputFramerate = title.Framerate;
- }
- else
- {
- // Not sure what to do for VFR here hb_calc_bitrate never handled it...
- // just use the peak for now.
- outputFramerate = profile.Framerate;
- }
-
- long frames = (long)(lengthSeconds * outputFramerate);
-
- availableBytes -= frames * ContainerOverheadPerFrame;
-
- List<Tuple<AudioEncoding, int>> outputTrackList = GetOutputTracks(job, title);
- availableBytes -= GetAudioSize(job, lengthSeconds, title, outputTrackList);
-
- if (availableBytes < 0)
- {
- return 0;
- }
-
- // Video bitrate is in kilobits per second, or where 1 kbps is 1000 bits per second.
- // So 1 kbps is 125 bytes per second.
- return (int)(availableBytes / (125 * lengthSeconds));
- }
-
- /// <summary>
- /// Gives estimated file size (in MB) of the given job and video bitrate.
- /// </summary>
- /// <param name="job">
- /// The encode job.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="videoBitrate">
- /// The video bitrate to be used (kbps).
- /// </param>
- /// <returns>
- /// The estimated file size (in MB) of the given job and video bitrate.
- /// </returns>
- public static double CalculateFileSize(EncodeJob job, Title title, int videoBitrate)
- {
- long totalBytes = 0;
-
- EncodeJob profile = job;
-
- double lengthSeconds = GetJobLengthSeconds(job, title);
- lengthSeconds += 1.5;
-
- double outputFramerate;
- if (profile.Framerate == 0)
- {
- outputFramerate = title.Framerate;
- }
- else
- {
- // Not sure what to do for VFR here hb_calc_bitrate never handled it...
- // just use the peak for now.
- outputFramerate = profile.Framerate;
- }
-
- long frames = (long)(lengthSeconds * outputFramerate);
-
- totalBytes += (long)(lengthSeconds * videoBitrate * 125);
- totalBytes += frames * ContainerOverheadPerFrame;
-
- List<Tuple<AudioEncoding, int>> outputTrackList = GetOutputTracks(job, title);
- totalBytes += GetAudioSize(job, lengthSeconds, title, outputTrackList);
-
- return (double)totalBytes / 1024 / 1024;
- }
-
- /// <summary>
/// Sends the message logged event to any registered listeners.
/// </summary>
/// <param name="message">
@@ -568,47 +325,5 @@ namespace HandBrake.Interop Debug.WriteLine("ERROR: " + message);
}
-
- /// <summary>
- /// Gets a list of encodings and target track indices (1-based).
- /// </summary>
- /// <param name="job">The encode job</param>
- /// <param name="title">The title the job is meant to encode.</param>
- /// <returns>A list of encodings and target track indices (1-based).</returns>
- private static List<Tuple<AudioEncoding, int>> GetOutputTracks(EncodeJob job, Title title)
- {
- var list = new List<Tuple<AudioEncoding, int>>();
-
- foreach (AudioEncoding encoding in job.AudioEncodings)
- {
- if (encoding.InputNumber == 0)
- {
- // Add this encoding for all chosen tracks
- foreach (int chosenTrack in job.ChosenAudioTracks)
- {
- // In normal cases we'll never have a chosen audio track that doesn't exist but when batch encoding
- // we just choose the first audio track without checking if it exists.
- if (chosenTrack <= title.AudioTracks.Count)
- {
- list.Add(new Tuple<AudioEncoding, int>(encoding, chosenTrack));
- }
- }
- }
- else if (encoding.InputNumber <= job.ChosenAudioTracks.Count)
- {
- // Add this encoding for the specified track, if it exists
- int trackNumber = job.ChosenAudioTracks[encoding.InputNumber - 1];
-
- // In normal cases we'll never have a chosen audio track that doesn't exist but when batch encoding
- // we just choose the first audio track without checking if it exists.
- if (trackNumber <= title.AudioTracks.Count)
- {
- list.Add(new Tuple<AudioEncoding, int>(encoding, trackNumber));
- }
- }
- }
-
- return list;
- }
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs index ce7209948..f231073f4 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs @@ -157,11 +157,6 @@ namespace HandBrake.Interop.Model public ScaleMethod ScaleMethod { get; set; }
/// <summary>
- /// Gets or sets the cropping type.
- /// </summary>
- public CroppingType CroppingType { get; set; }
-
- /// <summary>
/// Gets or sets the cropping.
/// </summary>
public Cropping Cropping { get; set; }
@@ -377,11 +372,6 @@ namespace HandBrake.Interop.Model public List<AudioEncoding> AudioEncodings { get; set; }
/// <summary>
- /// Gets or sets the list of chosen audio tracks (1-based)
- /// </summary>
- public List<int> ChosenAudioTracks { get; set; }
-
- /// <summary>
/// Gets or sets the audio encoder fallback.
/// </summary>
public string AudioEncoderFallback { get; set; }
@@ -439,7 +429,6 @@ namespace HandBrake.Interop.Model SecondsEnd = this.SecondsEnd,
FramesStart = this.FramesStart,
FramesEnd = this.FramesEnd,
- ChosenAudioTracks = new List<int>(this.ChosenAudioTracks),
Subtitles = this.Subtitles,
UseDefaultChapterNames = this.UseDefaultChapterNames,
DxvaDecoding = this.DxvaDecoding,
@@ -456,7 +445,6 @@ namespace HandBrake.Interop.Model MaxWidth = this.MaxWidth,
MaxHeight = this.MaxHeight,
ScaleMethod = this.ScaleMethod,
- CroppingType = this.CroppingType,
Cropping = this.Cropping.Clone(),
Anamorphic = this.Anamorphic,
UseDisplayWidth = this.UseDisplayWidth,
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs deleted file mode 100644 index e7c8da445..000000000 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/CroppingType.cs +++ /dev/null @@ -1,21 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="CroppingType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The type of cropping to apply.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.Interop.Model.Encoding
-{
- /// <summary>
- /// The type of cropping to apply.
- /// </summary>
- public enum CroppingType
- {
- Automatic,
- None,
- Custom
- }
-}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs index 0476b1673..716d65402 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs @@ -1,7 +1,10 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Rotation.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="PictureRotation.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
+// <summary>
+// Possible picture rotations.
+// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrake.Interop.Model.Encoding
|