From patchwork Sat Jul 15 10:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4239795pzb; Sat, 15 Jul 2023 03:49:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFq0bJX/FbVeNt1KTKInIfc1MpsD0EPA7tEY1TEgSrOE3ZomnDdX+I6FvB6T3YH2ak8Cwn X-Received: by 2002:a05:6402:524e:b0:51d:cf7b:c9f0 with SMTP id t14-20020a056402524e00b0051dcf7bc9f0mr7145628edd.12.1689418147847; Sat, 15 Jul 2023 03:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689418147; cv=none; d=google.com; s=arc-20160816; b=hsFR5ilo63hTGdbHzgxRTrIZ4yXpFabYXAc9XlZcUfr3TeRxxywc1zYbDbcOgfwhHL oxTPRa6J7+jkhXjErOHUd6PjXrHDNsMg/dLtfEH0vpd87J8lU9MbgkKfZp9w3DyRYEFV eGYuCQV+cbOxZ31uNnTCLTbfqoGgBgvYEHudA1rak/tC8Km4g/TEU9gtACaU6Y2DcLPv jy1tKSaR5pa+G0xKksVzQWZv3rIileacprLsVRg6LxV7ZdzQkTRUypJdGddupzgG2rRS eQamL+uCadCTNg63bvSAMxJlUF94dmEmw58en5ZQagM6own2kXFp8VRU+WPsoBCNI98j RuCw== 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=dorSthKkU6n3Q6EyhZKXnmCm6zMkCxnI7WvMXndEKbM=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=g3svzbUQdLNFU7uD7LbUkbT23Bifs6M34JnBEl97IRzHGkERAEyl64aMQaIcGKUfjO kjs2TDZsf4HYDFzJhjgdqw+qd5mS3joxVPbDC8pu0PbsS4FqzeCAW/dK52n2e8bhw73F 6rBqxicEc+KdmJdGgPMyLbxjdgRaPfiVbg1gfMbrtnb5W72u5R4T5FZmbRbu72UncDXN Fzlo9TwkWCbv3VLDg9LL0gMWg++BYUHYLhFJN8lyAm/IoOhNKfRLF9ASDk1OP/OgXyn9 TiYSPItqu2Kza2E2zLHsYGP7FUq99LbHOdUQYtA6EzVc3yQT8wcH8o2MI8tmYMqUu8Qy oVUw== 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 q18-20020aa7da92000000b0051e57e864b2si10342364eds.339.2023.07.15.03.49.07; Sat, 15 Jul 2023 03:49:07 -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 B84A168C6EB; Sat, 15 Jul 2023 13:46:52 +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 B5FE768C677 for ; Sat, 15 Jul 2023 13:46:34 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E25702405F9 for ; Sat, 15 Jul 2023 12:46:33 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ml-v9YsjGoLR for ; Sat, 15 Jul 2023 12:46:33 +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 C72C72406CD for ; Sat, 15 Jul 2023 12:46:26 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CF6683A1929 for ; Sat, 15 Jul 2023 12:46:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 12:45:43 +0200 Message-Id: <20230715104611.17902-19-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230715104611.17902-1-anton@khirnov.net> References: <20230715104611.17902-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/47] fftools/ffmpeg_filter: return error codes from choose_pix_fmts() instead of aborting 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: gSXzKqAiKuX8 --- fftools/ffmpeg_filter.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ed0df9f320..2a3204121a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -270,20 +270,20 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, ifp->sub2video.initialize = 0; } -/* May return NULL (no pixel format found), a static string or a string - * backed by the bprint. Nothing has been written to the AVBPrint in case +/* *dst may return be set to NULL (no pixel format found), a static string or a + * string backed by the bprint. Nothing has been written to the AVBPrint in case * NULL is returned. The AVBPrint provided should be clean. */ -static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) +static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, + const char **dst) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); OutputStream *ost = ofilter->ost; - if (ost->keep_pix_fmt) { - return ofp->format == AV_PIX_FMT_NONE ? NULL : + *dst = NULL; + + if (ost->keep_pix_fmt || ofp->format != AV_PIX_FMT_NONE) { + *dst = ofp->format == AV_PIX_FMT_NONE ? NULL : av_get_pix_fmt_name(ofp->format); - } - if (ofp->format != AV_PIX_FMT_NONE) { - return av_get_pix_fmt_name(ofp->format); } else if (ofp->formats) { const enum AVPixelFormat *p = ofp->formats; @@ -292,10 +292,12 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|'); } if (!av_bprint_is_complete(bprint)) - report_and_exit(AVERROR(ENOMEM)); - return bprint->str; - } else - return NULL; + return AVERROR(ENOMEM); + + *dst = bprint->str; + } + + return 0; } /* Define a function for appending a list of allowed formats @@ -1103,7 +1105,11 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, } av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); - if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) { + ret = choose_pix_fmts(ofilter, &bprint, &pix_fmts); + if (ret < 0) + return ret; + + if (pix_fmts) { AVFilterContext *filter; ret = avfilter_graph_create_filter(&filter,