Message ID | 20210531071643.39602-1-liuqi05@kuaishou.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avfilter/vf_overlay_cuda: add hsub and vsub compute x and y positions | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
> 2021年5月31日 下午3:16,Steven Liu <liuqi05@kuaishou.com> 写道: > > fix problem when set x to odd number in nv12 by cuda, > > test step: > 1. ffmpeg -f lavfi testsrc2=s=176x144 -pix_fmt nv12 -t 1 output_overlay.yuv > 1. ffmpeg -f lavfi testsrc2=s=352x288 -pix_fmt nv12 -t 1 output_main.yuv > before this patch: > overlay_cuda=x=0:y=0 will right, > overlay_cuda=x=3:y=0 will wrong, > > both will right after patch. > > Signed-off-by: Steven Liu <liuqi05@kuaishou.com> > --- > libavfilter/vf_overlay_cuda.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c > index b91ac9a713..37886a9d3b 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, > -- > 2.25.0 > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > Ping Thanks Steven Liu
Missed this one, will give it a test. Looks good to me so far.
diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index b91ac9a713..37886a9d3b 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,
fix problem when set x to odd number in nv12 by cuda, test step: 1. ffmpeg -f lavfi testsrc2=s=176x144 -pix_fmt nv12 -t 1 output_overlay.yuv 1. ffmpeg -f lavfi testsrc2=s=352x288 -pix_fmt nv12 -t 1 output_main.yuv before this patch: overlay_cuda=x=0:y=0 will right, overlay_cuda=x=3:y=0 will wrong, both will right after patch. Signed-off-by: Steven Liu <liuqi05@kuaishou.com> --- libavfilter/vf_overlay_cuda.c | 8 ++++++++ 1 file changed, 8 insertions(+)