From patchwork Wed May 8 21:32:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Svechnikov X-Patchwork-Id: 13036 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 434C14480C5 for ; Thu, 9 May 2019 00:39:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2480A68A5DB; Thu, 9 May 2019 00:39:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76071689DA0 for ; Thu, 9 May 2019 00:39:19 +0300 (EEST) Received: by mail-lf1-f67.google.com with SMTP id h126so11719lfh.4 for ; Wed, 08 May 2019 14:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=90Lzv/ZiXBzvn8r6TAc4iEWpnsa7G4pMd8fwIG0TBsc=; b=JLwSXIV1ARrlY9wdk8S88ddfU60vxCJgCZXuqAM5lI5aV28UnAoOXZWLxf8kFjRhTX 35gspIjlbJ4AUlQbue4s3xVSO/OceAd4SlJFb+NHfQEou057kUTvyzY1k5dH0s7i1x/D lsATZiEg/f7njvlmSXcdOFMfE9gUvQ6zopsFcLj5Cy31EKUyx9kyEGEDyqeYY9AoLGEl BNSi3AgpIARFAr+00dKOwWkXb7ouxCUVxUn7oQkfrsz4Ve0sXrqBEbVbTwE+8cwnv/mX W/ms0y0QPbvM/8s5ZCRoe4QOp23wkyUx187X28QN5FJmhzitswHRc8Ej6+HwijtaM60c UDJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=90Lzv/ZiXBzvn8r6TAc4iEWpnsa7G4pMd8fwIG0TBsc=; b=EvIuskHFG36w/vxlTut+DLp6bWmjmCrtSbEGw8lWWQO2EXhaCZM1GAjCfn1qmhYH3I f+HXWSST/uFW+DJYnUrzqyww6fx1CDE8Al8MII9LLYfCqI+eRJ7bOe1wZVLetWt/Luqd fXQyMFBDNz6Ept6n+7nhB9S+NZ+6CK2nqxLLXv6YNZzF3tRZs0NAWC6d2QL4J9iXTuX6 mwoyWT5JhMiTA1/Ji5/qixVRulqG0CoEy44/GtW3eGV0c8MG12emutWTKULj6u6DUzxf p098NGxvPIqF4syVTzc/XhDdDf2gJ6uXT0tDeFWvNzcmIk5DMNwqyK30r3zcOGmoJCzm 6Ecg== X-Gm-Message-State: APjAAAUuUtMn5XHAJnxomFa37RTgwCgKrhl7+NyfRq0jRnl0rVV7PNiN FtRQwKfwuiWHsNh1d4k81rWaajcn7Iw= X-Google-Smtp-Source: APXvYqwgxezwk6KquEBDhCCDgyjNPkbyBl/zwtJp1wQGsn8uJS6pCyUTpzEvUGQ8TaxyxnkBSIgPvQ== X-Received: by 2002:a19:760c:: with SMTP id c12mr169260lff.105.1557351183534; Wed, 08 May 2019 14:33:03 -0700 (PDT) Received: from serg-ubuntu.corp.itmh.ru ([2a02:17d0:4a9:1800:867:6e7f:b0e9:492b]) by smtp.googlemail.com with ESMTPSA id k10sm222ljh.86.2019.05.08.14.33.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 May 2019 14:33:02 -0700 (PDT) From: Sergey Svechnikov To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 May 2019 02:32:51 +0500 Message-Id: <1557351171-11114-1-git-send-email-svechnikov66@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] libavfilter/vf_scale_cuda: fix frame dimensions 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: Sergey Svechnikov MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" AVHWFramesContext has aligned width and height. When initializing a new AVFrame, it receives these aligned values (in av_hwframe_get_buffer), which leads to incorrect scaling. The resulting frames are cropped either horizontally or vertically. As a fix we can overwrite the dimensions to original values right after av_hwframe_get_buffer. More info, samples and reproduction steps are here https://github.com/Svechnikov/ffmpeg-scale-cuda-problem --- libavfilter/vf_scale_cuda.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index c97a802..ef1bd82 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -463,6 +463,9 @@ static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in) if (ret < 0) return ret; + s->tmp_frame->width = s->planes_out[0].width; + s->tmp_frame->height = s->planes_out[0].height; + av_frame_move_ref(out, s->frame); av_frame_move_ref(s->frame, s->tmp_frame);