enum AVPixelFormat in_format_overlay;
enum AVPixelFormat in_format_main;
+ AVBufferRef *hw_device_ctx;
AVCUDADeviceContext *hwctx;
CUcontext cu_ctx;
if (ret < 0)
return ret;
- if (!input_main || !input_overlay)
+ if (!input_main)
return AVERROR_BUG;
+ if (!input_overlay)
+ return ff_filter_frame(outlink, input_main);
+
ret = av_frame_make_writable(input_main);
if (ret < 0) {
av_frame_free(&input_main);
CHECK_CU(cu->cuModuleUnload(ctx->cu_module));
CHECK_CU(cu->cuCtxPopCurrent(&dummy));
}
+
+ av_buffer_unref(&ctx->hw_device_ctx);
+ ctx->hwctx = NULL;
}
/**
// initialize
- ctx->hwctx = frames_ctx->device_ctx->hwctx;
+ ctx->hw_device_ctx = av_buffer_ref(frames_ctx->device_ref);
+ if (!ctx->hw_device_ctx)
+ return AVERROR(ENOMEM);
+ ctx->hwctx = ((AVHWDeviceContext*)ctx->hw_device_ctx->data)->hwctx;
+
cuda_ctx = ctx->hwctx->cuda_ctx;
ctx->fs.time_base = inlink->time_base;
ctx->cu_stream = ctx->hwctx->stream;
outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+ if (!outlink->hw_frames_ctx)
+ return AVERROR(ENOMEM);
// load functions
{ NULL }
};
-AVFilter ff_vf_overlay_cuda = {
+const AVFilter ff_vf_overlay_cuda = {
.name = "overlay_cuda",
.description = NULL_IF_CONFIG_SMALL("Overlay one video on top of another using CUDA"),
.priv_size = sizeof(OverlayCUDAContext),