Skip to content

Commit ce58672

Browse files
committed
Added code to avoid clobbering a chosen hardware decoding setting.
Added requirement for NVDec to be available before applying the NVDec setting.
1 parent 656b0c4 commit ce58672

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

VidCoderCommon/Model/JsonEncodeFactory.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,10 @@ private Video CreateVideo(
964964

965965
if (isEncode)
966966
{
967+
bool setHardwareDecoder = false;
967968
if (videoEncoder.IsQuickSync)
968969
{
970+
setHardwareDecoder = true;
969971
video.HardwareDecode = HandBrakeHardwareEncoderHelper.IsQsvAvailable && jobConfiguration.EnableQuickSyncDecoding ?
970972
NativeConstants.HB_DECODE_QSV | NativeConstants.HB_DECODE_FORCE_HW : 0;
971973

@@ -976,8 +978,9 @@ private Video CreateVideo(
976978
}
977979

978980
// Allow use of the QSV decoder is configurable for non QSV encoders.
979-
if (!videoEncoder.IsHardwareEncoder && jobConfiguration.UseQsvDecodeForNonQsvEncodes && jobConfiguration.EnableQuickSyncDecoding)
981+
if (!setHardwareDecoder && !videoEncoder.IsHardwareEncoder && jobConfiguration.UseQsvDecodeForNonQsvEncodes && jobConfiguration.EnableQuickSyncDecoding)
980982
{
983+
setHardwareDecoder = true;
981984
video.HardwareDecode = HandBrakeHardwareEncoderHelper.IsQsvAvailable ?
982985
NativeConstants.HB_DECODE_QSV | NativeConstants.HB_DECODE_FORCE_HW : 0;
983986
}
@@ -987,13 +990,15 @@ private Video CreateVideo(
987990
videoOptions = AdvancedOptionUtilities.Prepend("hyperencode=adaptive", videoOptions);
988991
}
989992

990-
if (jobConfiguration.EnableNVDec)
993+
if (!setHardwareDecoder && HandBrakeHardwareEncoderHelper.IsNVDecAvailable && jobConfiguration.EnableNVDec)
991994
{
995+
setHardwareDecoder = true;
992996
video.HardwareDecode = NativeConstants.HB_DECODE_NVDEC;
993997
}
994998

995-
if (HandBrakeHardwareEncoderHelper.IsDirectXAvailable && jobConfiguration.EnableDirectXDecoding)
999+
if (!setHardwareDecoder && HandBrakeHardwareEncoderHelper.IsDirectXAvailable && jobConfiguration.EnableDirectXDecoding)
9961000
{
1001+
setHardwareDecoder = true;
9971002
video.HardwareDecode = NativeConstants.HB_DECODE_MF | NativeConstants.HB_DECODE_FORCE_HW;
9981003
}
9991004
}

0 commit comments

Comments
 (0)