1 // --------------------------------------------------------------------------------------------------------------------
2 // <copyright file="HandBrakeEncoderHelpers.cs" company="HandBrake Project (https://handbrake.fr)">
3 //   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
4 // </copyright>
5 // <summary>
6 //   The encoders.
7 // </summary>
8 // --------------------------------------------------------------------------------------------------------------------
9 
10 namespace HandBrake.Interop.Interop
11 {
12     using System;
13     using System.Collections.Generic;
14     using System.Linq;
15 
16     using HandBrake.Interop.Interop.HbLib;
17     using HandBrake.Interop.Interop.Helpers;
18     using HandBrake.Interop.Interop.Interfaces.Model;
19     using HandBrake.Interop.Interop.Interfaces.Model.Encoders;
20     using HandBrake.Interop.Utilities;
21 
22     public static class HandBrakeEncoderHelpers
23     {
24         private static List<HBAudioEncoder> audioEncoders;
25         private static List<HBVideoEncoder> videoEncoders;
26         private static List<HBRate> videoFramerates;
27         private static List<HBMixdown> mixdowns;
28         private static List<HBContainer> containers;
29         private static List<int> audioBitrates;
30         private static List<HBRate> audioSampleRates;
31 
32         /// <summary>
33         /// Initializes static members of the HandBrakeEncoderHelpers class.
34         /// </summary>
HandBrakeEncoderHelpers()35         static HandBrakeEncoderHelpers()
36         {
37             if (!HandBrakeUtils.IsInitialised())
38             {
39                 throw new Exception("Please Initialise with HandBrakeUtils.EnsureGlobalInit before using!");
40             }
41         }
42 
43         /// <summary>
44         /// Gets a list of supported audio encoders.
45         /// </summary>
46         public static List<HBAudioEncoder> AudioEncoders
47         {
48             get
49             {
50                 if (audioEncoders == null)
51                 {
52                     audioEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBAudioEncoder>(HBFunctions.hb_audio_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToAudioEncoder);
53                 }
54 
55                 return audioEncoders;
56             }
57         }
58 
59         /// <summary>
60         /// Gets a list of supported video encoders.
61         /// </summary>
62         public static List<HBVideoEncoder> VideoEncoders
63         {
64             get
65             {
66                 if (videoEncoders == null)
67                 {
68                     videoEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBVideoEncoder>(HBFunctions.hb_video_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToVideoEncoder);
69                 }
70 
71                 return videoEncoders;
72             }
73         }
74 
75         /// <summary>
76         /// Gets a list of supported video framerates (in pts).
77         /// </summary>
78         public static List<HBRate> VideoFramerates
79         {
80             get
81             {
82                 if (videoFramerates == null)
83                 {
84                     videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
85                 }
86 
87                 return videoFramerates;
88             }
89         }
90 
91         /// <summary>
92         /// Gets a list of supported mixdowns.
93         /// </summary>
94         public static List<HBMixdown> Mixdowns
95         {
96             get
97             {
98                 if (mixdowns == null)
99                 {
100                     mixdowns = InteropUtilities.ToListFromIterator<hb_mixdown_s, HBMixdown>(HBFunctions.hb_mixdown_get_next, HandBrakeUnitConversionHelpers.NativeToMixdown);
101                 }
102 
103                 return mixdowns;
104             }
105         }
106 
107         /// <summary>
108         /// Gets a list of supported audio bitrates.
109         /// </summary>
110         public static List<int> AudioBitrates
111         {
112             get
113             {
114                 if (audioBitrates == null)
115                 {
116                     audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);
117                 }
118 
119                 return audioBitrates;
120             }
121         }
122 
123         /// <summary>
124         /// Gets a list of supported audio sample rates (in Hz).
125         /// </summary>
126         public static List<HBRate> AudioSampleRates
127         {
128             get
129             {
130                 if (audioSampleRates == null)
131                 {
132                     audioSampleRates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_audio_samplerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
133                 }
134 
135                 return audioSampleRates;
136             }
137         }
138 
139         /// <summary>
140         /// Gets a list of supported containers.
141         /// </summary>
142         public static List<HBContainer> Containers
143         {
144             get
145             {
146                 if (containers == null)
147                 {
148                     containers = InteropUtilities.ToListFromIterator<hb_container_s, HBContainer>(HBFunctions.hb_container_get_next, HandBrakeUnitConversionHelpers.NativeToContainer);
149                 }
150 
151                 return containers;
152             }
153         }
154 
155         /// <summary>
156         /// Gets a value indicating whether SRT subtitles can be burnt in.
157         /// </summary>
158         public static bool CanBurnSrt
159         {
160             get
161             {
162                 return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSRT) > 0;
163             }
164         }
165 
166         /// <summary>
167         /// Gets a value indicating whether SRT subtitles can be burnt in.
168         /// </summary>
169         public static bool CanBurnSSA
170         {
171             get
172             {
173                 return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSSA) > 0;
174             }
175         }
176 
177         /// <summary>
178         /// Gets the audio encoder with the specified short name.
179         /// </summary>
180         /// <param name="shortName">
181         /// The name of the audio encoder.
182         /// </param>
183         /// <returns>
184         /// The requested audio encoder.
185         /// </returns>
GetAudioEncoder(string shortName)186         public static HBAudioEncoder GetAudioEncoder(string shortName)
187         {
188             return AudioEncoders.SingleOrDefault(e => e.ShortName == shortName);
189         }
190 
191         /// <summary>
192         /// Gets the audio encoder with the specified codec ID.
193         /// </summary>
194         /// <param name="codecId">
195         /// The ID of the audio encoder.
196         /// </param>
197         /// <returns>
198         /// The requested audio encoder.
199         /// </returns>
GetAudioEncoder(int codecId)200         public static HBAudioEncoder GetAudioEncoder(int codecId)
201         {
202             return AudioEncoders.SingleOrDefault(e => e.Id == codecId);
203         }
204 
GetAutoPassthruEncoder(int inputCodec, int copyMask, int fallback, int muxer)205         public static HBAudioEncoder GetAutoPassthruEncoder(int inputCodec, int copyMask, int fallback, int muxer)
206         {
207            int encoder = HBFunctions.hb_autopassthru_get_encoder(inputCodec, copyMask, fallback, muxer);
208 
209            return GetAudioEncoder(encoder);
210         }
211 
212         /// <summary>
213         /// Gets the video encoder with the specified short name.
214         /// </summary>
215         /// <param name="shortName">
216         /// The name of the video encoder.
217         /// </param>
218         /// <returns>
219         /// The requested video encoder.
220         /// </returns>
GetVideoEncoder(string shortName)221         public static HBVideoEncoder GetVideoEncoder(string shortName)
222         {
223             return VideoEncoders.SingleOrDefault(e => e.ShortName == shortName);
224         }
225 
226         /// <summary>
227         /// Gets the mixdown with the specified short name.
228         /// </summary>
229         /// <param name="shortName">
230         /// The name of the mixdown.
231         /// </param>
232         /// <returns>
233         /// The requested mixdown.
234         /// </returns>
GetMixdown(string shortName)235         public static HBMixdown GetMixdown(string shortName)
236         {
237             return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);
238         }
239 
240         /// <summary>
241         /// Gets the mixdown with the specified ID.
242         /// </summary>
243         /// <param name="id">The mixdown ID.</param>
244         /// <returns>The requested mixdown.</returns>
GetMixdown(int id)245         public static HBMixdown GetMixdown(int id)
246         {
247             return Mixdowns.SingleOrDefault(m => m.Id == id);
248         }
249 
250         /// <summary>
251         /// Gets the container with the specified short name.
252         /// </summary>
253         /// <param name="shortName">
254         /// The name of the container.
255         /// </param>
256         /// <returns>
257         /// The requested container.
258         /// </returns>
GetContainer(string shortName)259         public static HBContainer GetContainer(string shortName)
260         {
261             return Containers.SingleOrDefault(c => c.ShortName == shortName);
262         }
263 
264         /// <summary>
265         /// Returns true if the subtitle source type can be set to forced only.
266         /// </summary>
267         /// <param name="source">
268         /// The subtitle source type (SSA, VobSub, etc)
269         /// </param>
270         /// <returns>
271         /// True if the subtitle source type can be set to forced only.
272         /// </returns>
SubtitleCanSetForcedOnly(int source)273         public static bool SubtitleCanSetForcedOnly(int source)
274         {
275             return HBFunctions.hb_subtitle_can_force(source) > 0;
276         }
277 
278         /// <summary>
279         /// Returns true if the subtitle source type can be burned in.
280         /// </summary>
281         /// <param name="source">
282         /// The subtitle source type (SSA, VobSub, etc)
283         /// </param>
284         /// <returns>
285         /// True if the subtitle source type can be burned in.
286         /// </returns>
SubtitleCanBurn(int source)287         public static bool SubtitleCanBurn(int source)
288         {
289             return HBFunctions.hb_subtitle_can_burn(source) > 0;
290         }
291 
292         /// <summary>
293         /// Returns true if the subtitle type can be passed through using the given muxer.
294         /// </summary>
295         /// <param name="subtitleSourceType">
296         /// The subtitle source type (SSA, VobSub, etc)
297         /// </param>
298         /// <param name="muxer">
299         /// The ID of the muxer.
300         /// </param>
301         /// <returns>
302         /// True if the subtitle type can be passed through with the given muxer.
303         /// </returns>
SubtitleCanPassthrough(int subtitleSourceType, int muxer)304         public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer)
305         {
306             return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0;
307         }
308 
309         /// <summary>
310         /// Gets the subtitle source type's name.
311         /// </summary>
312         /// <param name="source">
313         /// The subtitle source type (SSA, VobSub, etc).
314         /// </param>
315         /// <returns>
316         /// The name of the subtitle source.
317         /// </returns>
GetSubtitleSourceName(int source)318         public static string GetSubtitleSourceName(int source)
319         {
320             switch ((hb_subtitle_s_subsource)source)
321             {
322                 case hb_subtitle_s_subsource.CC608SUB:
323                     return "CC608";
324                 case hb_subtitle_s_subsource.CC708SUB:
325                     return "CC708";
326                 case hb_subtitle_s_subsource.IMPORTSRT:
327                     return "SRT";
328                 case hb_subtitle_s_subsource.IMPORTSSA:
329                 case hb_subtitle_s_subsource.SSASUB:
330                     return "SSA";
331                 case hb_subtitle_s_subsource.TX3GSUB:
332                     return "TX3G";
333                 case hb_subtitle_s_subsource.UTF8SUB:
334                     return "UTF8";
335                 case hb_subtitle_s_subsource.VOBSUB:
336                     return "VobSub";
337                 case hb_subtitle_s_subsource.PGSSUB:
338                     return "PGS";
339                 default:
340                     return string.Empty;
341             }
342         }
343 
344         /// <summary>
345         /// Determines if the given encoder is compatible with the given track.
346         /// </summary>
347         /// <param name="codecId">
348         /// The codec Id.
349         /// </param>
350         /// <param name="encoder">
351         /// The encoder to examine.
352         /// </param>
353         /// <returns>
354         /// True if the given encoder is compatible with the given audio track.
355         /// </returns>
356         /// <remarks>
357         /// Only works with passthrough encoders.
358         /// </remarks>
AudioEncoderIsCompatible(int codecId, HBAudioEncoder encoder)359         public static bool AudioEncoderIsCompatible(int codecId, HBAudioEncoder encoder)
360         {
361             return (codecId & encoder.Id) > 0;
362         }
363 
364         /// <summary>
365         /// Determines if the given mixdown supports the given channel layout.
366         /// </summary>
367         /// <param name="mixdown">
368         /// The mixdown to evaluate.
369         /// </param>
370         /// <param name="layout">
371         /// The channel layout to evaluate.
372         /// </param>
373         /// <returns>
374         /// True if the mixdown supports the given channel layout.
375         /// </returns>
MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)376         public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)
377         {
378             return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;
379         }
380 
381         /// <summary>
382         /// Determines if the given encoder supports the given mixdown.
383         /// </summary>
384         /// <param name="mixdown">
385         /// The mixdown to evaluate.
386         /// </param>
387         /// <param name="encoder">
388         /// The encoder to evaluate.
389         /// </param>
390         /// <returns>
391         /// True if the encoder supports the mixdown.
392         /// </returns>
MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)393         public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)
394         {
395             return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0;
396         }
397 
398         /// <summary>
399         /// Determines if a mixdown is available for a given track and encoder.
400         /// </summary>
401         /// <param name="mixdown">
402         /// The mixdown to evaluate.
403         /// </param>
404         /// <param name="encoder">
405         /// The encoder to evaluate.
406         /// </param>
407         /// <param name="channelLayout">channel layout of the source track</param>
408         /// <returns>True if available.</returns>
MixdownIsSupported(HBMixdown mixdown, HBAudioEncoder encoder, long channelLayout)409         public static bool MixdownIsSupported(HBMixdown mixdown, HBAudioEncoder encoder, long channelLayout)
410         {
411             return HBFunctions.hb_mixdown_is_supported(mixdown.Id, (uint)encoder.Id, (uint)channelLayout) > 0;
412         }
413 
414         /// <summary>
415         /// Determines if DRC can be applied to the given track with the given encoder.
416         /// </summary>
417         /// <param name="handle">
418         /// The handle.
419         /// </param>
420         /// <param name="trackNumber">
421         /// The track Number.
422         /// </param>
423         /// <param name="encoder">
424         /// The encoder to use for DRC.
425         /// </param>
426         /// <param name="title">
427         /// The title.
428         /// </param>
429         /// <returns>
430         /// True if DRC can be applied to the track with the given encoder.
431         /// </returns>
CanApplyDrc(IntPtr handle, int trackNumber, HBAudioEncoder encoder, int title)432         public static bool CanApplyDrc(IntPtr handle, int trackNumber, HBAudioEncoder encoder, int title)
433         {
434             return HBFunctions.hb_audio_can_apply_drc2(handle, title, trackNumber, encoder.Id) > 0;
435         }
436 
437         /// <summary>
438         /// Determines if the given input audio codec can be passed through.
439         /// </summary>
440         /// <param name="codecId">
441         /// The input codec to consider.
442         /// </param>
443         /// <returns>
444         /// True if the codec can be passed through.
445         /// </returns>
CanPassthroughAudio(int codecId)446         public static bool CanPassthroughAudio(int codecId)
447         {
448             return (codecId & NativeConstants.HB_ACODEC_PASS_MASK) > 0;
449         }
450 
451         /// <summary>
452         /// Sanitizes a mixdown given the output codec and input channel layout.
453         /// </summary>
454         /// <param name="mixdown">
455         /// The desired mixdown.
456         /// </param>
457         /// <param name="encoder">
458         /// The output encoder to be used.
459         /// </param>
460         /// <param name="layout">
461         /// The input channel layout.
462         /// </param>
463         /// <returns>
464         /// A sanitized mixdown value.
465         /// </returns>
SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout)466         public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout)
467         {
468             if (mixdown == null || encoder == null)
469             {
470                 return null;
471             }
472 
473             int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id);
474             if (sanitizedMixdown != -1)
475             {
476                 return Mixdowns.Single(m => m.Id == sanitizedMixdown);
477             }
478 
479             return Mixdowns.FirstOrDefault(); // "none"
480         }
481 
482         /// <summary>
483         /// Gets the default mixdown for the given audio encoder and channel layout.
484         /// </summary>
485         /// <param name="encoder">
486         /// The output codec to be used.
487         /// </param>
488         /// <param name="layout">
489         /// The input channel layout.
490         /// </param>
491         /// <returns>
492         /// The default mixdown for the given codec and channel layout.
493         /// </returns>
GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)494         public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)
495         {
496             int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout);
497             return Mixdowns.Single(m => m.Id == defaultMixdown);
498         }
499 
500         /// <summary>
501         /// Sanitizes the given sample rate for the given encoder.
502         /// </summary>
503         /// <param name="encoder">The encoder.</param>
504         /// <param name="sampleRate">The sample rate to sanitize.</param>
505         /// <returns>The sanitized sample rate.</returns>
SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate)506         public static int SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate)
507         {
508             return HBFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id);
509         }
510 
511         /// <summary>
512         /// Gets the bitrate limits for the given audio codec, sample rate and mixdown.
513         /// </summary>
514         /// <param name="encoder">
515         /// The audio encoder used.
516         /// </param>
517         /// <param name="sampleRate">
518         /// The sample rate used (Hz).
519         /// </param>
520         /// <param name="mixdown">
521         /// The mixdown used.
522         /// </param>
523         /// <returns>
524         /// Limits on the audio bitrate for the given settings.
525         /// </returns>
GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)526         public static BitrateLimits GetBitrateLimits(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
527         {
528             int low = 0;
529             int high = 0;
530 
531             HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);
532 
533             return new BitrateLimits(low, high);
534         }
535 
536         /// <summary>
537         /// Gets the video quality limits for the given video codec.
538         /// </summary>
539         /// <param name="encoder">
540         /// The video encoder to check.
541         /// </param>
542         /// <returns>
543         /// Limits on the video quality for the encoder.
544         /// </returns>
GetVideoQualityLimits(HBVideoEncoder encoder)545         public static VideoQualityLimits GetVideoQualityLimits(HBVideoEncoder encoder)
546         {
547             float low = 0;
548             float high = 0;
549             float granularity = 0;
550             int direction = 0;
551 
552             HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);
553 
554             return new VideoQualityLimits(low, high, granularity, direction == 0);
555         }
556 
557         /// <summary>
558         /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.
559         /// </summary>
560         /// <param name="audioBitrate">
561         /// The desired audio bitrate.
562         /// </param>
563         /// <param name="encoder">
564         /// The output encoder to be used.
565         /// </param>
566         /// <param name="sampleRate">
567         /// The output sample rate to be used.
568         /// </param>
569         /// <param name="mixdown">
570         /// The mixdown to be used.
571         /// </param>
572         /// <returns>
573         /// A sanitized audio bitrate.
574         /// </returns>
SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)575         public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
576         {
577             return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);
578         }
579 
580         /// <summary>
581         /// Gets the default audio bitrate for the given parameters.
582         /// </summary>
583         /// <param name="encoder">
584         /// The encoder to use.
585         /// </param>
586         /// <param name="sampleRate">
587         /// The sample rate to use.
588         /// </param>
589         /// <param name="mixdown">
590         /// The mixdown to use.
591         /// </param>
592         /// <returns>
593         /// The default bitrate for these parameters.
594         /// </returns>
GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)595         public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
596         {
597             return HBFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id);
598         }
599 
600         /// <summary>
601         /// Gets limits on audio quality for a given encoder.
602         /// </summary>
603         /// <param name="encoderId">
604         /// The audio encoder ID.
605         /// </param>
606         /// <returns>
607         /// Limits on the audio quality for the given encoder.
608         /// </returns>
GetAudioQualityLimits(int encoderId)609         public static RangeLimits GetAudioQualityLimits(int encoderId)
610         {
611             float low = 0, high = 0, granularity = 0;
612             int direction = 0;
613             HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
614 
615             return new RangeLimits(direction == 0, granularity, high, low);
616         }
617 
618         /// <summary>
619         /// Gets limits on audio compression for a given encoder.
620         /// </summary>
621         /// <param name="encoderId">
622         /// The audio encoder ID.
623         /// </param>
624         /// <returns>
625         /// Limits on the audio compression for the given encoder.
626         /// </returns>
GetAudioCompressionLimits(int encoderId)627         public static RangeLimits GetAudioCompressionLimits(int encoderId)
628         {
629             float low = 0, high = 0, granularity = 0;
630             int direction = 0;
631             HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
632 
633             return new RangeLimits(direction == 0, granularity, high, low);
634         }
635 
636         /// <summary>
637         /// The get default quality.
638         /// </summary>
639         /// <param name="encoder">
640         /// The encoder.
641         /// </param>
642         /// <returns>
643         /// The <see cref="double"/>.
644         /// </returns>
GetDefaultQuality(HBAudioEncoder encoder)645         public static double GetDefaultQuality(HBAudioEncoder encoder)
646         {
647            return HBFunctions.hb_audio_quality_get_default((uint)encoder.Id);
648         }
649 
650         /// <summary>
651         /// The get default audio compression.
652         /// </summary>
653         /// <param name="encoder">
654         /// The encoder.
655         /// </param>
656         /// <returns>
657         /// The <see cref="double"/>.
658         /// </returns>
GetDefaultAudioCompression(HBAudioEncoder encoder)659         public static double GetDefaultAudioCompression(HBAudioEncoder encoder)
660         {
661             return HBFunctions.hb_audio_compression_get_default((uint)encoder.Id);
662         }
663 
BuildCopyMask(bool audioAllowMP2Pass, bool audioAllowMP3Pass, bool audioAllowAACPass, bool audioAllowAC3Pass, bool audioAllowDTSPass, bool audioAllowDTSHDPass, bool audioAllowEac3Pass, bool audioAllowFlacPass, bool audioAllowTruehdPass)664         public static uint BuildCopyMask(bool audioAllowMP2Pass, bool audioAllowMP3Pass, bool audioAllowAACPass, bool audioAllowAC3Pass, bool audioAllowDTSPass, bool audioAllowDTSHDPass, bool audioAllowEac3Pass, bool audioAllowFlacPass, bool audioAllowTruehdPass)
665         {
666             uint mask = 0;
667 
668             if (audioAllowMP2Pass)
669             {
670                 mask |= NativeConstants.HB_ACODEC_MP2_PASS;
671             }
672 
673             if (audioAllowMP3Pass)
674             {
675                 mask |= NativeConstants.HB_ACODEC_MP3_PASS;
676             }
677 
678             if (audioAllowAACPass)
679             {
680                 mask |= NativeConstants.HB_ACODEC_AAC_PASS;
681             }
682 
683             if (audioAllowAC3Pass)
684             {
685                 mask |= NativeConstants.HB_ACODEC_AC3_PASS;
686             }
687 
688             if (audioAllowDTSPass)
689             {
690                 mask |= NativeConstants.HB_ACODEC_DCA_PASS;
691             }
692 
693             if (audioAllowDTSHDPass)
694             {
695                 mask |= NativeConstants.HB_ACODEC_DCA_HD_PASS;
696             }
697 
698             if (audioAllowEac3Pass)
699             {
700                 mask |= NativeConstants.HB_ACODEC_EAC3_PASS;
701             }
702 
703             if (audioAllowFlacPass)
704             {
705                 mask |= NativeConstants.HB_ACODEC_FLAC_PASS;
706             }
707 
708             if (audioAllowTruehdPass)
709             {
710                 mask |= NativeConstants.HB_ACODEC_TRUEHD_PASS;
711             }
712 
713             return mask;
714         }
715 
GetQsvAdaptorList()716         public static List<int> GetQsvAdaptorList()
717         {
718             if (HandBrakeHardwareEncoderHelper.IsQsvAvailable)
719             {
720                 IntPtr gpuListPtr = HBFunctions.hb_qsv_adapters_list();
721 
722                 List<int> gpuList = InteropUtilities.ToListFromHandBrakeList<int>(gpuListPtr);
723 
724                 return gpuList;
725             }
726 
727             return new List<int>();
728         }
729     }
730 }
731