From patchwork Mon May 31 07:16:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 27991 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2635489iof; Mon, 31 May 2021 00:17:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzV1Bl/Md1rPn96KNHu9K4qGB3rUP9M02nI9Hqln8gLjcUVTaOwpCnPM9BFcIuDD1qnLaS X-Received: by 2002:a05:6402:42cd:: with SMTP id i13mr23764575edc.34.1622445448655; Mon, 31 May 2021 00:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622445448; cv=none; d=google.com; s=arc-20160816; b=OUxFjulUKKGn2uaTwqWZ4Q3uVOSFH+UJTk3ckiknXhjysmMpLZW7Qxb4nidDVw61D4 gUK6Eu0UfZ6QC1VA4m6HlNPNe7ogC/9DzbekbsGaq09Lcgzu9Ejrm7mtL8OgNmyzKuIP WJIla5JcKjfXv1HNBLJXXJCGVwc7eGNkwpHgRYEIL+H033h78lzzfswzF7SSouVAJsAZ xczkLdQ2VAhX6YEzTw6OwiUg+bs638wafuUIDmdwV/RVfWZikuFCxivbwqJhadHcCMLX 3KjyNrEB52s6TZb1k5VhrHOvvwkfmvRsjN3q/th1ybriiFBdbT9lfLWqHr7cLnJlHs71 /XTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:message-id:date :to:from:delivered-to; bh=1WkDPmiYlk0FrwHUmh7yihBXRzVtcvQ7cogOvWNRmKY=; b=udxNLQINiefMQI2y07VZ0EeXJwNbjPfw3S0042c5A897DzOnOuj2xKt8INtVS/ZTa5 DUcRDivTKd170dN8VZfVG5J8v9u0GBBmjRBCrg2fLg9kKndLgstXVYEBH6mE00mqQwRd 6nlOWt7pDhNNHaJ1rlj5QaKEB9OswRAp6bFec52jmTT881tSf73dLDvWeOvcWOrqwNPp ih4hYoo2stvZuChX2UirnPe4734Gl90MnUTnQeMkGDD/WyeaC9DzYRkXbSBbwO/05e/V KxqMR5dh7G3HoPe5TyuVdWulXmNkr4SMoZn2zqW9SPS3OL0gP0Y9ZHtoGqwln96HlhS/ VllQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kuaishou.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d21si10767609ejm.343.2021.05.31.00.17.28; Mon, 31 May 2021 00:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kuaishou.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 134C1687F27; Mon, 31 May 2021 10:17:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpproxy21.qq.com (smtpbg704.qq.com [203.205.195.105]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1FDB680297 for ; Mon, 31 May 2021 10:17:18 +0300 (EEST) X-QQ-mid: bizesmtp47t1622445408taf11szc Received: from localhost (unknown [103.107.216.225]) by esmtp6.qq.com (ESMTP) with id ; Mon, 31 May 2021 15:16:47 +0800 (CST) X-QQ-SSF: 01100000004000Z0Z000B00A0020000 X-QQ-FEAT: pu1FmNdbQkJwIvY8pnn5hN0pKAPdXNrJcAC/P7veBUNPdBRabaRtXP7sU48g/ yRYXHyv017V1Q9/sJWFujAW7Zm+VygXdhIhGuZg9kYvV9dnh2zkQ7SCVaLE18T33yVFB1v2 ONIu5isMeHQjM7TX4H3UJIuieka9dYUeSWEilByLafxA8YkykzizLzErTCkb5x3hcIP0bXm tQZwcqqdXxWx5DRKjPG+Zl38KEwBq+e3df5bM3JEM9DFfZmV/0+YfNWOgDs8gL9vC2poYFT Pi88HGOrKXikniaFr1jBbN5SMBEks9E/us15s677gGgnZM X-QQ-GoodBg: 0 X-QQ-CSender: lq@chinaffmpeg.org From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 15:16:43 +0800 Message-Id: <20210531071643.39602-1-liuqi05@kuaishou.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_cuda: add hsub and vsub compute x and y positions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ARAUwc8cbFA5 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 --- 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,