@@ -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},