lavfi/vf_*_cuda: do not access hw contexts before checking they exist

The checks are performed in init_processing_chain().
release/7.1
Anton Khirnov 5 months ago
parent 99ee7a948f
commit ce24b5ba8f
  1. 13
      libavfilter/vf_bilateral_cuda.c
  2. 13
      libavfilter/vf_chromakey_cuda.c
  3. 14
      libavfilter/vf_colorspace_cuda.c
  4. 13
      libavfilter/vf_scale_cuda.c

@ -249,17 +249,20 @@ static av_cold int cuda_bilateral_config_props(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
CUDABilateralContext *s = ctx->priv;
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
AVHWFramesContext *frames_ctx;
AVCUDADeviceContext *device_hwctx;
int ret;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
ret = init_processing_chain(ctx, inlink->w, inlink->h);
if (ret < 0)
return ret;
frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
device_hwctx = frames_ctx->device_ctx->hwctx;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
// the window_size makes more sense when it is odd, so add 1 if even

@ -259,13 +259,10 @@ static av_cold int cudachromakey_config_props(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
ChromakeyCUDAContext *s = ctx->priv;
AVHWFramesContext *frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
AVHWFramesContext *frames_ctx;
AVCUDADeviceContext *device_hwctx;
int ret;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
if (s->is_yuv) {
s->chromakey_uv[0] = s->chromakey_rgba[1];
s->chromakey_uv[1] = s->chromakey_rgba[2];
@ -278,6 +275,12 @@ static av_cold int cudachromakey_config_props(AVFilterLink *outlink)
if (ret < 0)
return ret;
frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
device_hwctx = frames_ctx->device_ctx->hwctx;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
ret = cudachromakey_load_functions(ctx);

@ -226,14 +226,10 @@ static av_cold int cudacolorspace_config_props(AVFilterLink* outlink)
AVFilterContext* ctx = outlink->src;
AVFilterLink* inlink = outlink->src->inputs[0];
CUDAColorspaceContext* s = ctx->priv;
AVHWFramesContext* frames_ctx =
(AVHWFramesContext*)inlink->hw_frames_ctx->data;
AVCUDADeviceContext* device_hwctx = frames_ctx->device_ctx->hwctx;
AVHWFramesContext* frames_ctx;
AVCUDADeviceContext* device_hwctx;
int ret;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
outlink->w = inlink->w;
outlink->h = inlink->h;
@ -241,6 +237,12 @@ static av_cold int cudacolorspace_config_props(AVFilterLink* outlink)
if (ret < 0)
return ret;
frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
device_hwctx = frames_ctx->device_ctx->hwctx;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
if (inlink->sample_aspect_ratio.num) {
outlink->sample_aspect_ratio = av_mul_q(
(AVRational){outlink->h * inlink->w, outlink->w * inlink->h},

@ -349,14 +349,11 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
CUDAScaleContext *s = ctx->priv;
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
AVHWFramesContext *frames_ctx;
AVCUDADeviceContext *device_hwctx;
int w, h;
int ret;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
if ((ret = ff_scale_eval_dimensions(s,
s->w_expr, s->h_expr,
inlink, outlink,
@ -377,6 +374,12 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink)
if (ret < 0)
return ret;
frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
device_hwctx = frames_ctx->device_ctx->hwctx;
s->hwctx = device_hwctx;
s->cu_stream = s->hwctx->stream;
if (inlink->sample_aspect_ratio.num) {
outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
outlink->w*inlink->h},

Loading…
Cancel
Save