|
|
|
@ -209,8 +209,8 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder |
|
|
|
currentState = SetCrop(videoInputFile, desiredState, currentState); |
|
|
|
currentState = SetCrop(videoInputFile, desiredState, currentState); |
|
|
|
SetStillImageLoop(videoInputFile, videoStream, ffmpegState, desiredState, pipelineSteps); |
|
|
|
SetStillImageLoop(videoInputFile, videoStream, ffmpegState, desiredState, pipelineSteps); |
|
|
|
|
|
|
|
|
|
|
|
if (currentState.BitDepth == 8 && context.HasSubtitleOverlay || context.HasWatermark || |
|
|
|
if (currentState.BitDepth == 8 && (context.HasSubtitleOverlay || context.HasWatermark || |
|
|
|
context.HasGraphicsEngine) |
|
|
|
context.HasGraphicsEngine)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Option<IPixelFormat> desiredPixelFormat = Some((IPixelFormat)new PixelFormatYuv420P()); |
|
|
|
Option<IPixelFormat> desiredPixelFormat = Some((IPixelFormat)new PixelFormatYuv420P()); |
|
|
|
|
|
|
|
|
|
|
|
@ -282,7 +282,11 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
watermarkOverlayFilterSteps); |
|
|
|
watermarkOverlayFilterSteps); |
|
|
|
|
|
|
|
|
|
|
|
currentState = SetGraphicsEngine(graphicsEngineInput, currentState, graphicsEngineOverlayFilterSteps); |
|
|
|
currentState = SetGraphicsEngine( |
|
|
|
|
|
|
|
graphicsEngineInput, |
|
|
|
|
|
|
|
currentState, |
|
|
|
|
|
|
|
desiredState, |
|
|
|
|
|
|
|
graphicsEngineOverlayFilterSteps); |
|
|
|
|
|
|
|
|
|
|
|
// after everything else is done, apply the encoder
|
|
|
|
// after everything else is done, apply the encoder
|
|
|
|
if (pipelineSteps.OfType<IEncoder>().All(e => e.Kind != StreamKind.Video)) |
|
|
|
if (pipelineSteps.OfType<IEncoder>().All(e => e.Kind != StreamKind.Video)) |
|
|
|
@ -649,18 +653,42 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder |
|
|
|
private static FrameState SetGraphicsEngine( |
|
|
|
private static FrameState SetGraphicsEngine( |
|
|
|
Option<GraphicsEngineInput> graphicsEngineInput, |
|
|
|
Option<GraphicsEngineInput> graphicsEngineInput, |
|
|
|
FrameState currentState, |
|
|
|
FrameState currentState, |
|
|
|
|
|
|
|
FrameState desiredState, |
|
|
|
List<IPipelineFilterStep> graphicsEngineOverlayFilterSteps) |
|
|
|
List<IPipelineFilterStep> graphicsEngineOverlayFilterSteps) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (GraphicsEngineInput graphicsEngine in graphicsEngineInput) |
|
|
|
foreach (GraphicsEngineInput graphicsEngine in graphicsEngineInput) |
|
|
|
{ |
|
|
|
{ |
|
|
|
graphicsEngine.FilterSteps.Add(new PixelFormatFilter(new PixelFormatYuva420P())); |
|
|
|
if (currentState.BitDepth == 8) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
graphicsEngine.FilterSteps.Add(new PixelFormatFilter(new PixelFormatYuva420P())); |
|
|
|
|
|
|
|
|
|
|
|
graphicsEngine.FilterSteps.Add( |
|
|
|
graphicsEngine.FilterSteps.Add( |
|
|
|
new HardwareUploadCudaFilter(currentState with { FrameDataLocation = FrameDataLocation.Software })); |
|
|
|
new HardwareUploadCudaFilter(currentState with { FrameDataLocation = FrameDataLocation.Software })); |
|
|
|
|
|
|
|
|
|
|
|
var graphicsEngineFilter = new OverlayGraphicsEngineCudaFilter(); |
|
|
|
var graphicsEngineFilter = new OverlayGraphicsEngineCudaFilter(); |
|
|
|
graphicsEngineOverlayFilterSteps.Add(graphicsEngineFilter); |
|
|
|
graphicsEngineOverlayFilterSteps.Add(graphicsEngineFilter); |
|
|
|
currentState = graphicsEngineFilter.NextState(currentState); |
|
|
|
currentState = graphicsEngineFilter.NextState(currentState); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (IPixelFormat desiredPixelFormat in desiredState.PixelFormat) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IPixelFormat pf = desiredPixelFormat; |
|
|
|
|
|
|
|
if (desiredPixelFormat is PixelFormatNv12 nv12) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (IPixelFormat availablePixelFormat in AvailablePixelFormats.ForPixelFormat( |
|
|
|
|
|
|
|
nv12.Name, |
|
|
|
|
|
|
|
null)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pf = availablePixelFormat; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var graphicsEngineFilter = new OverlayGraphicsEngineFilter(pf); |
|
|
|
|
|
|
|
graphicsEngineOverlayFilterSteps.Add(graphicsEngineFilter); |
|
|
|
|
|
|
|
currentState = graphicsEngineFilter.NextState(currentState); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return currentState; |
|
|
|
return currentState; |
|
|
|
@ -787,7 +815,7 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ffmpegState.IsHdrTonemap) |
|
|
|
if (ffmpegState.IsHdrTonemap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var filter = new TonemapCudaFilter(ffmpegState, new PixelFormatNv12(FFmpegFormat.YUV420P)); |
|
|
|
var filter = new TonemapCudaFilter(ffmpegState, pixelFormat); |
|
|
|
currentState = filter.NextState(currentState); |
|
|
|
currentState = filter.NextState(currentState); |
|
|
|
videoStream.ResetColorParams(ColorParams.Default); |
|
|
|
videoStream.ResetColorParams(ColorParams.Default); |
|
|
|
videoInputFile.FilterSteps.Add(filter); |
|
|
|
videoInputFile.FilterSteps.Add(filter); |
|
|
|
|