From patchwork Mon May 14 21:29:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 8962 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp605082jad; Mon, 14 May 2018 14:30:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq9UdPlKqUonwkD7CIOCs8ZYDfkC/EoBj1cz+ngWEc/VOVzI8xrUkSWaf0OFBBhn84UEyMi X-Received: by 2002:adf:ce8b:: with SMTP id r11-v6mr7745642wrn.242.1526333408335; Mon, 14 May 2018 14:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526333408; cv=none; d=google.com; s=arc-20160816; b=pqWgXk69Y55UPnsCZPkEewPLHQ92A0ZPKFIj2ucyKTHtYmQH1xit8kTssgsNtQrayL u87weo6njS6wEXBg7DSVUpE1wnMgzhwtkGEhB9jEA5+ssFMxTZttIPUeEP6zeed6JUTg 2eYxPO/95dyVIoR3tUm7NzFe41WRUIRfgdA89e+6p5D8XKASfOxgaMGQWGqZhtGBITke ItCTDNygWQyXxxKKscyfM54SnvCa2Tx55W5J1VjqsVt+vVK++230tMb7XPk6QH6Q6pKk wADcmVMuUboKH7E0evf6MHB/0h7H9oViCHoTWZwfm1qC6YZeLgc906FlINk0WzRH9Nmq bLJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Jw1nq0xCXtuO/a/IjrtPdvKGWNo32ve1vutfis429xc=; b=hB1OzCvulX7Hd4Z2JoSn6RcYS6RebXmYA+z5I3FVZw0H1jJvTC5dg7gVheXtW77o2U 3fCElkfIEiLDyEzUehDx1PkWWecUHUHWGq9ctGVv+4dUyX88W3oeDswY8MeOdsczoQRO pWsqcIwpbAPHPcj1pmZVubF84iNFlY4dFBDX8Y2l22dAG+GP0k9nMNhf0CGDiTChxTVy ziWRKLoMKkmDgjQwhCKfylHgjHYUDQSpOBr78YbjOzM5AJ04WHGQ5ootp2ddC37LDTEI r4Vp/UNnUyATg3PowpMglkEaoA6ejA9caNdw5Osph35HESzVPi2/85Lxbg79ELDq5nof lE0A== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o26-v6si8953868wrf.359.2018.05.14.14.30.07; Mon, 14 May 2018 14:30:08 -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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C1958689812; Tue, 15 May 2018 00:29:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EFD6068066E for ; Tue, 15 May 2018 00:29:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4D2A2E101E; Mon, 14 May 2018 23:30:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9wAYiGA5qA9n; Mon, 14 May 2018 23:29:57 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 10302E0E38; Mon, 14 May 2018 23:29:57 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 May 2018 23:29:50 +0200 Message-Id: <20180514212950.15764-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 Subject: [FFmpeg-devel] [PATCH] avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Regression since ece068a771ac3f725e854c681ecbef08e792addc. Signed-off-by: Marton Balint --- libavutil/hwcontext_cuda.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index cb5d15c9d9..e16d0a2b4b 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -159,10 +159,13 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) return res; // YUV420P is a special case. - // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them. + // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned if (ctx->sw_format == AV_PIX_FMT_YUV420P) { - FFSWAP(uint8_t*, frame->data[1], frame->data[2]); - FFSWAP(int, frame->linesize[1], frame->linesize[2]); + int aligned_width = FFALIGN(ctx->width, CUDA_FRAME_ALIGNMENT); + frame->data[2] = frame->data[0] + aligned_width * ctx->height; + frame->data[1] = frame->data[2] + aligned_width * ctx->height / 4; + frame->linesize[1] = aligned_width / 2; + frame->linesize[2] = aligned_width / 2; } frame->format = AV_PIX_FMT_CUDA;