From patchwork Mon May 31 07:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657230iof; Mon, 31 May 2021 00:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjZwTZZHSjwjODihD+zJejwFDOBK3lPDgtWp+PAQY91cOb/qekwI7A1FYnfS5ukBoLq/Gz X-Received: by 2002:a17:906:3818:: with SMTP id v24mr13387372ejc.197.1622447888573; Mon, 31 May 2021 00:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447888; cv=none; d=google.com; s=arc-20160816; b=WSMpE8b1SZ5SGASPm3WS5zZcZWC/SCD4O8kqPS5OeTn5U7lXLfDsIO94WAcFAXewA9 QtjTB0Lse4vOyuysPojl2GE2ntm4mNaSZ98OrnP04RUnf62G0w+VqO4/CTiG+Z6zT8Uq s+lVp5d9ElLZgkCk4FQ0e9kQU2omQIo8ugb1/F6T2ekc9IZhUgLvbWqS6MRvx1aQlbyf EyZAt4JlvDSZOjWzU74qPVhV4XDZSl5BO4GzUWQ5FsWG1VXWsHF4jF1Agij5qy4jCYY4 gYe4DwqRJF5oy3LuiBWAH0Btrjfe0/8RQX0/vdWo02wYFs1eAWILnZM3tUiSy46Q8g9W Wb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=TfV2bHhLd8JhNYM9GtoUjilznO/6Jkp84IGRthgYDz4=; b=gwyX+tzZVtnhiNAYCqJpXQLr+H3oihDHueWBOAuMf3PUmHxmMZBXveWrOh5FABIvPf kvda/gCs7siUqppCQnKvHF0s88iWvUUgcsNYKbPJzkO5+eAOyFBpQsS1PougeHEWEO0W XbAkb59XS3+m9BN8L6nDO7maZge6CezQpl+5L2zTYGnBHghwFL1h+4mMxXDH5kzpwk7t 9ehBH4Itmig7gI5COsraO4QFtKr5f5GCZfGyt3mROe45rlWH9plXamAkmdafg2dyMDFM uKf7ApdvNf4czO9Ib7Zl5RxLjjLfqDTmZEFM9YimexLK/G80p7xtuLkgvWo0KT7JZxVh GqaA== 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 u20si12875876edv.439.2021.05.31.00.58.08; Mon, 31 May 2021 00:58: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 8B6076899A7; Mon, 31 May 2021 10:55:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3782E68803C for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F06C524069B for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6-O9i4K2g5w5 for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 536C42406A5 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 3584A3A1901; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:14 +0200 Message-Id: <20210531075515.19544-23-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/24] lavfi/vf_scale: forward errors from swscale 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6RsOq6agk6Vf --- libavfilter/vf_scale.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 37899de6a1..cdd7c4da0d 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -658,6 +658,7 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) AVFrame *out; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); char buf[32]; + int ret; int in_range; int frame_changed; @@ -672,7 +673,6 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) in->sample_aspect_ratio.num != link->sample_aspect_ratio.num; if (scale->eval_mode == EVAL_MODE_FRAME || frame_changed) { - int ret; unsigned vars_w[VARS_NB] = { 0 }, vars_h[VARS_NB] = { 0 }; av_expr_count_vars(scale->w_pexpr, vars_w, VARS_NB); @@ -794,8 +794,9 @@ scale: INT_MAX); if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) { - scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); - scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); + ret = scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); + if (ret >= 0) + ret = scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); } else if (scale->nb_slices) { int i, slice_h, slice_start, slice_end = 0; const int nb_slices = FFMIN(scale->nb_slices, link->h); @@ -803,14 +804,18 @@ scale: slice_start = slice_end; slice_end = (link->h * (i+1)) / nb_slices; slice_h = slice_end - slice_start; - scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); + ret = scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); + if (ret < 0) + break; } } else { - scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); + ret = scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); } av_frame_free(&in); - return 0; + if (ret < 0) + av_frame_free(frame_out); + return ret; } static int filter_frame(AVFilterLink *link, AVFrame *in)