Browse Source

use proper nvidia accel output format for 10-bit content (#865)

pull/867/head
Jason Dove 3 years ago committed by GitHub
parent
commit
d114db091e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderH264Cuvid.cs
  2. 10
      ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderHevcCuvid.cs
  3. 10
      ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderMpeg2Cuvid.cs
  4. 10
      ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderMpeg4Cuvid.cs
  5. 19
      ErsatzTV.FFmpeg/Decoder/DecoderBase.cs

10
ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderH264Cuvid.cs

@ -17,8 +17,16 @@ public class DecoderH264Cuvid : DecoderBase @@ -17,8 +17,16 @@ public class DecoderH264Cuvid : DecoderBase
{
IList<string> result = base.InputOptions(inputFile);
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
{
result.Add("-hwaccel_output_format");
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
result.Add("cuda");
}
else
{
result.Add("-hwaccel_output_format");
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
}
return result;
}

10
ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderHevcCuvid.cs

@ -17,8 +17,16 @@ public class DecoderHevcCuvid : DecoderBase @@ -17,8 +17,16 @@ public class DecoderHevcCuvid : DecoderBase
{
IList<string> result = base.InputOptions(inputFile);
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
{
result.Add("-hwaccel_output_format");
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
result.Add("cuda");
}
else
{
result.Add("-hwaccel_output_format");
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
}
return result;
}

10
ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderMpeg2Cuvid.cs

@ -22,8 +22,16 @@ public class DecoderMpeg2Cuvid : DecoderBase @@ -22,8 +22,16 @@ public class DecoderMpeg2Cuvid : DecoderBase
{
IList<string> result = base.InputOptions(inputFile);
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
{
result.Add("-hwaccel_output_format");
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
result.Add("cuda");
}
else
{
result.Add("-hwaccel_output_format");
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
}
return result;
}

10
ErsatzTV.FFmpeg/Decoder/Cuvid/DecoderMpeg4Cuvid.cs

@ -17,8 +17,16 @@ public class DecoderMpeg4Cuvid : DecoderBase @@ -17,8 +17,16 @@ public class DecoderMpeg4Cuvid : DecoderBase
{
IList<string> result = base.InputOptions(inputFile);
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
{
result.Add("-hwaccel_output_format");
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
result.Add("cuda");
}
else
{
result.Add("-hwaccel_output_format");
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
}
return result;
}

19
ErsatzTV.FFmpeg/Decoder/DecoderBase.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using ErsatzTV.FFmpeg.Environment;
using ErsatzTV.FFmpeg.Format;
namespace ErsatzTV.FFmpeg.Decoder;
@ -20,4 +21,22 @@ public abstract class DecoderBase : IDecoder @@ -20,4 +21,22 @@ public abstract class DecoderBase : IDecoder
public bool AppliesTo(VideoInputFile videoInputFile) => true;
public bool AppliesTo(ConcatInputFile concatInputFile) => false;
protected int InputBitDepth(InputFile inputFile)
{
var bitDepth = 8;
if (inputFile is VideoInputFile videoInputFile)
{
foreach (VideoStream videoStream in videoInputFile.VideoStreams.HeadOrNone())
{
foreach (IPixelFormat pixelFormat in videoStream.PixelFormat)
{
bitDepth = pixelFormat.BitDepth;
}
}
}
return bitDepth;
}
}

Loading…
Cancel
Save