From patchwork Sun Nov 27 00:09:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Miroslav_Sluge=C5=88?= X-Patchwork-Id: 1570 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1095371vsb; Sat, 26 Nov 2016 16:09:18 -0800 (PST) X-Received: by 10.28.4.199 with SMTP id 190mr12883739wme.11.1480205358289; Sat, 26 Nov 2016 16:09:18 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f7si39461038wjg.224.2016.11.26.16.09.17; Sat, 26 Nov 2016 16:09:18 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@email.cz; dkim=neutral (body hash did not verify) header.i=@email.cz; 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 dis=NONE) header.from=email.cz Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 68182689D92; Sun, 27 Nov 2016 02:09:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mxs2.seznam.cz (mxs2.seznam.cz [77.75.76.125]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3406689D92 for ; Sun, 27 Nov 2016 02:09:03 +0200 (EET) Received: from email.seznam.cz by email-smtpc11b.ng.seznam.cz (email-smtpc11b.ng.seznam.cz [10.23.14.75]) id 23c0c2041717da182352eb09; Sun, 27 Nov 2016 01:09:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1480205347; bh=m4b7BO6fPKw5fOKFj88MIBP80sUenFjopnNv+nXqxRs=; h=DKIM-Signature:Received:From:Subject:To:Message-ID:Date: User-Agent:MIME-Version:Content-Type; b=L5VMl5NSPjHsBmM18btu8nByBNT3oBzWDjSKHFW7PxB3W5mf26R2lfO1QdXBwcUc9 SnrPEKg3Ye21gJVOo9GO9vneiPNqEI8975xi2dPn+NtIvOOediEa/1A8N3ZxPiLQ/q 2FZ8BgYt3f4uWjpkedS0+7Pj3L8vwE6wRtzB//EM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1480205347; bh=m4b7BO6fPKw5fOKFj88MIBP80sUenFjopnNv+nXqxRs=; h=Received:From:Subject:To:Message-ID:Date:User-Agent:MIME-Version: Content-Type; b=U8W6Ae0PelvKkDN/bRLmEDKgf/NP+r0Jce0gevvWJDEPjynLoCKzBf/WRcoxUUMJ2 DbSu3dpMSewFmbnjz1RxbiiNlK7P3KybIs4UtjFFeAj37qvzvz0CK3GWHGMw+J4XaK gjiVVAUpuEIbqwBkrtlkpBbNvc7wQG+KNm3LDPfI= Received: from [192.168.0.6] (ip-94-113-140-7.net.upcbroadband.cz [94.113.140.7]) by email-relay8.ng.seznam.cz (Seznam SMTPD 1.3.41) with ESMTP; Sun, 27 Nov 2016 01:09:06 +0100 (CET) From: =?UTF-8?Q?Miroslav_Sluge=c5=88?= To: ffmpeg-devel@ffmpeg.org Message-ID: <583A2421.6090305@email.cz> Date: Sun, 27 Nov 2016 01:09:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vf_scale_npp: move aspect ratio correction after, av_frame_copy_props 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Updating output aspect ratio before calling nppscale_scale has no effect because nppscale_scale calls av_frame_copy_props which will overwrite output aspect ratio based on source frame. Simplest solution is to move aspect ratio update after nppscale_scale function, but it is also possible to move aspect ratio update directly to nppscale_scale function in future. This should fix aspect ratio bug when using scale_npp for resolution with different W/H than original resolution for example 1920x1080 -> 720x576 and codec which supports dynamic aspect ratio change which is libx264, nvenc not yet, that is the reason why that bug was hidden. From 6eb95f381add35de0ae83e826ee8fdeaccf6c31d Mon Sep 17 00:00:00 2001 From: Miroslav Slugen Date: Sun, 27 Nov 2016 00:58:16 +0100 Subject: [PATCH 1/1] vf_scale_npp: move aspect ratio correction after av_frame_copy_props --- libavfilter/vf_scale_npp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c index 78f541e..3c1d1e9 100644 --- a/libavfilter/vf_scale_npp.c +++ b/libavfilter/vf_scale_npp.c @@ -586,11 +586,6 @@ static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in) goto fail; } - av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, - (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, - (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, - INT_MAX); - err = device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx); if (err != CUDA_SUCCESS) { ret = AVERROR_UNKNOWN; @@ -603,6 +598,11 @@ static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in) if (ret < 0) goto fail; + av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, + (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, + (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, + INT_MAX); + av_frame_free(&in); return ff_filter_frame(outlink, out); fail: -- 2.1.4