diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index b91ac9a713..8a4d2c4312 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -145,11 +145,16 @@ static int overlay_cuda_blend(FFFrameSync *fs) AVFilterContext *avctx = fs->parent; OverlayCUDAContext *ctx = avctx->priv; AVFilterLink *outlink = avctx->outputs[0]; + AVFilterLink *inlink = avctx->inputs[0]; CudaFunctions *cu = ctx->hwctx->internal->cuda_dl; CUcontext dummy, cuda_ctx = ctx->hwctx->cuda_ctx; AVFrame *input_main, *input_overlay; + const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); + + int hsub = pix_desc->log2_chroma_w; + int vsub = pix_desc->log2_chroma_h; ctx->cu_ctx = cuda_ctx; @@ -178,6 +183,9 @@ static int overlay_cuda_blend(FFFrameSync *fs) return ret; } + ctx->x_position &= (1 << hsub) - 1; + ctx->y_position &= (1 << vsub) - 1; + // overlay first plane overlay_cuda_call_kernel(ctx,