From patchwork Mon Mar 14 21:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 34738 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2497551nkb; Mon, 14 Mar 2022 14:06:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJOIn3/vel8kkVg9aKHjkMuGtAWKgOi41BYAe6Lv7ELgn4X2BLsYM1iFAIuMb0fMUIMRRb X-Received: by 2002:a17:907:c0c:b0:6d1:8c46:6415 with SMTP id ga12-20020a1709070c0c00b006d18c466415mr20468743ejc.326.1647292008843; Mon, 14 Mar 2022 14:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647292008; cv=none; d=google.com; s=arc-20160816; b=h/tPuJs7r7ShyOWKJ9kE9LYglHYLplpLeWt9prAHlLw9QwEpyTAqgWoKBe9GS5MgnF h1KcBFVoVGnJHxg56DC0/4jKmb0CutIBDnkGSYXJlmm3iHxdZsHJWRG0UaYUHbHhqGXL DJXYOIegALqxCJ8ppj0+4z04TXrL8tQn0kptByctNxZdoPLAJfagAZ3VDv3bs8nRnlPt 7s9h3JbTXmkLTF3voKpewwgBJQfsJkpSg/hCICHnHd2NxgKDngu72WRrO17dqt0S7rzB n+QmxDm7sjDZcrVkJnLLA1D1iUYG81i3/ILohJ8BixuvixI89BhZSptX8wk13UGREf8D o7pg== 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:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=gI7rGlYTR3IUV+BMbmqb/79X0JdxVSSzLad82Qt1Etw=; b=yG2KQN6mDSHOMKzBOMRfrT9yvXrk3XfPIGGBAvXTdZ8YYMTdN60t703wbr47W0x5GD jL9xJNJ4DqGMBCYeVshQqVFLi3msjq0tgK1EtYYySTpacst80b3LJDRXbmd7j5MLlFFQ kcf8Um6EJ2q/7vuDIRBk2/PpfH55BzSmxQ1zB+5CLSbjiqSTHZFnKq4xXK+GfPEsfq48 J1kZ3lsK/cRX7GqB1dn+9myX3Ug1er31mwE0pXYEwn8vV1tDlG8z5VEbtM4UGQ3lO59/ +reiHSEXKOHMTNDso1S+qT/RWK1GhqLCBpS+Uw3XAlhh8WRuvrikEiZVk3zNR/6beVEe j1eA== 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 b8-20020a056402084800b004169f49cf79si11959801edz.191.2022.03.14.14.06.48; Mon, 14 Mar 2022 14:06:48 -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 4588C68B15A; Mon, 14 Mar 2022 23:06:24 +0200 (EET) 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 5230E68B0A4 for ; Mon, 14 Mar 2022 23:06:18 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id AB3DFE67E3; Mon, 14 Mar 2022 22:06:18 +0100 (CET) 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 GDxbD2ZpF3j3; Mon, 14 Mar 2022 22:06:17 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6AF7EE67E2; Mon, 14 Mar 2022 22:06:16 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Mar 2022 22:06:03 +0100 Message-Id: <20220314210603.23870-4-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220314210603.23870-1-cus@passwd.hu> References: <20220314210603.23870-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_zscale: realign output buffer if needed 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: QiP9fKL7W6+8 Output buffer alignment might be different to ZIMG_ALIGNMENT or it may not be aligned at all if a downstream filter (e.g. vf_pad) intentionally misaligns it. Or maybe we should unconditionally always allocate output with av_frame_get_buffer() instead of ff_get_video_buffer()? Signed-off-by: Marton Balint --- libavfilter/vf_zscale.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index ceefc95224..2061e38bcc 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -632,7 +632,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des return 0; } -static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) +static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy) { AVFrame *aligned = NULL; int ret = 0, plane, planes; @@ -654,10 +654,10 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0) goto fail; - if ((ret = av_frame_copy(aligned, *frame)) < 0) + if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0) goto fail; - if ((ret = av_frame_copy_props(aligned, *frame)) < 0) + if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0) goto fail; av_frame_free(frame); @@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) goto fail; } + if ((ret = realign_frame(odesc, &out, 0)) < 0) + goto fail; + av_frame_copy_props(out, in); - if ((ret = realign_frame(desc, &in)) < 0) + if ((ret = realign_frame(desc, &in, 1)) < 0) goto fail; snprintf(buf, sizeof(buf)-1, "%d", outlink->w);