From patchwork Tue Nov 30 00:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31824 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968349iob; Mon, 29 Nov 2021 16:50:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjGsnZ8JnMLM6Z0pCLGMjNqg35+Jt7YFTs1jfLO13UP/wAdgsKi+prFYEVhR2zJUARsnCY X-Received: by 2002:a50:ef02:: with SMTP id m2mr77309983eds.172.1638233411518; Mon, 29 Nov 2021 16:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233411; cv=none; d=google.com; s=arc-20160816; b=RWUID4UK9DRi4d0hNYv/k1vexx4gwrnKra3n0JVwRdbfhAGIZvTw+DtN3eJrdM/5x/ OO8ptPyLVe99kyN1EZZJfu2kM1iuSoYVUwdA1eUcln+2TAG3pACr8l+LdnDRsLsTucix 0JJzIksDV5MjyGypm9sYezwlbLVb9ivSsKbM+3Swh0p88opc3MEubrkTFLh3A7rDVw8X AlSAfjhCjyV94gOAHSh3p0XIgIg25BXqGhKhPvbdAJXpMDy3+QK8VC9vonHsKWoswTiD vnIakTjnOvbqIHwrudCHvtXEarGcE8d706ugmNrrPDQxLjN9rRGhtsTGy+e4BG2krvL6 aRvA== 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:message-id:date:to:from :delivered-to; bh=O5+fhLB26IxTLcaQA6mmLh0kuW98urqh87dhiVp78fM=; b=AZe9DsTM2PuBgB4V+AYcbFH16jbd7XpzdzBnrqFge3o8SFUsc9Itlj63WgwZe935yV NJ7i70gLGftG6B8fE5s71l4f+DE8imD+VPDG3YgDesw5bLiuoAN9AyZ30t7jupLldrjI tsEuRUNCa4a084Ns/e5Xhx+VINndrxFi/xq2IP+Uh85tkYvD56rR+r2qhyf6/Oqq3OZU x2uo3FNnPoRA8UOVzJJspiHgOzSv3V1gkT8PoMyO8ckR9wZlmV1dssreWW/cEo/Vpgz/ smCOe75gjx7byWqbq4qNoh9iOITdrJPZZZ/2ds5ZCi68nofSvevWAXvFR0kFt1loBJPQ gdkQ== 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 i7si35537730edc.414.2021.11.29.16.50.10; Mon, 29 Nov 2021 16:50:11 -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; 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 A35BE68AE34; Tue, 30 Nov 2021 02:50:05 +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 D4FCA68A868 for ; Tue, 30 Nov 2021 02:49:58 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3987AE643C; Tue, 30 Nov 2021 01:49:58 +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 gCk9UfieTEg9; Tue, 30 Nov 2021 01:49:56 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9B5C3E3E38; Tue, 30 Nov 2021 01:49:56 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:46 +0100 Message-Id: <20211130004950.30697-1-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avformat/file: use proper return value in file_close 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: FVYGm38fIOik Signed-off-by: Marton Balint --- libavformat/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/file.c b/libavformat/file.c index 9c23f680cd..7001750c80 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -266,7 +266,8 @@ static int64_t file_seek(URLContext *h, int64_t pos, int whence) static int file_close(URLContext *h) { FileContext *c = h->priv_data; - return close(c->fd); + int ret = close(c->fd); + return (ret == -1) ? AVERROR(errno) : 0; } static int file_open_dir(URLContext *h) From patchwork Tue Nov 30 00:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31822 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968542iob; Mon, 29 Nov 2021 16:50:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcSWpMFQVc45dQ6DciqnT1WqqK8H3xBfZqoBpCbMVnsypQcd+BtdrxKuAwjSlTuda6O/iX X-Received: by 2002:a05:6402:2792:: with SMTP id b18mr78475506ede.329.1638233422504; Mon, 29 Nov 2021 16:50:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233422; cv=none; d=google.com; s=arc-20160816; b=TGIn4FNmN2ELBp74EeUkJowRq4YAglw2emjAIaCI5+IDFCYUAQQHFSLG+n8rvXt/FM 60Ymyhpdle8dfB1RySDGSCEip3XTHn0ZDmvTAt/ufed2OwYvJhjKhbU22Te1RkHACd8o ibk4LxY31tVB+XvGj+o1MeT7r5JNZ9T6sGwTn/0vRW9nQUafmFTSmbNPJzJ2nhXo54vV H68J2JnkFfqUzULIvTXFchX0qc9ITdVCQrKrodqKryuqtdHO44odeWyOqHsPX+OjHd88 Ale5KJpOzCuE3NkZ7G/fEAveTVPgQ8zxmL2skrPEzH2r9afjYCkAWkqdKYuLllNTJAvx JR6w== 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=IG6U/8fvbIdyfJb5EF4+pCn1j0wJzxRx2T80hZ87PWc=; b=BYVWWMWDbfNRu2Z2M/wRTZF1KbW31P/m1TmiJRH28fDSAqVM7Ag/AqAyv0b3JmJ8og auc9W+o1mW7P1QDNs2fQNUAzGQ7trY8WupMw4soqZ4EVPOKaO4TDsK3tMbJs531yainB INeYCt7wrv9O9v4CpPjFi2qRTQpjoMEwqlverzRqkRy1S+8M7DaUWrPU5CS4YHLT8MlV qBCxMTt7S2gLGJZGxHVOdh1YD+gEfoAVXeDzIEc1BPszba/uWfAKYk8WwXr4sA09Ph2P 8vnkeVDEpx+6Bad0q8tfx9iBnsG+iGZOalUopjpNoLVZe+P9gtiRdgaST9R1leGbG4NC Snww== 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 r24si20297897ejy.718.2021.11.29.16.50.22; Mon, 29 Nov 2021 16:50:22 -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; 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 1211068A868; Tue, 30 Nov 2021 02:50:08 +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 4739A68A868 for ; Tue, 30 Nov 2021 02:49:59 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B71E9E3E38; Tue, 30 Nov 2021 01:49:58 +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 wk0aDwkoT7j8; Tue, 30 Nov 2021 01:49:57 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 84C60E6372; Tue, 30 Nov 2021 01:49:57 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:47 +0100 Message-Id: <20211130004950.30697-2-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avformat/aviobuf: return stored AVIO context error on avio_close 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: MfcQw4PfIZWQ Otherwise IO errors at avio_flush() before closing may be lost. Signed-off-by: Marton Balint --- libavformat/aviobuf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 5da4dea7b6..d65c7b535d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1231,6 +1231,7 @@ int avio_close(AVIOContext *s) { FFIOContext *const ctx = ffiocontext(s); URLContext *h; + int ret, error; if (!s) return 0; @@ -1249,9 +1250,14 @@ int avio_close(AVIOContext *s) ctx->bytes_read, ctx->seek_count); av_opt_free(s); + error = s->error; avio_context_free(&s); - return ffurl_close(h); + ret = ffurl_close(h); + if (ret < 0) + return ret; + + return error; } int avio_closep(AVIOContext **s) From patchwork Tue Nov 30 00:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31825 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968695iob; Mon, 29 Nov 2021 16:50:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6NoX4TCcmCznpcHxAIdqgztNr5jxqCVa8SuASIr/P5mRZJ8B1sSg5rwu+vlIEASEQUbUF X-Received: by 2002:a50:e003:: with SMTP id e3mr78782474edl.374.1638233431744; Mon, 29 Nov 2021 16:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233431; cv=none; d=google.com; s=arc-20160816; b=yhxYwxmbEZ35qn2f1HI6fXoPVifqChRGQ5i3XA3WlViSZeKAd96vbtcC+bkLjHbhBq IaTBXYyaVqlV2EpHOgyXf6JYTDhRmnrTApxHCJetjdUNt2L40uGOdxQdbEaEPbfYqo5r d2OrH3DIG/UOu1gv0tw0fE+L33n8/pL5wCrf/sRIGKRkjeJh5L7l4B0vMTl5Ul8SmkXt XhXbpsGakfUg67EiWaDg4qiAeaZxeBheSer8lhGpYhGwfmhbEE/J/pZqWamBzRqS2QAC 4oOeaotyHjDkvm/a717yiWxaiClGcuw1P1zCetS0mesteFhLofm4Ja+tovVnUI/vf+Pm 2nHQ== 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=blDO9CUgaZr0B+IwbC9sRu6ULLXXLNVp9mnxmeCC+MI=; b=befjeFZeu7CDyvSr0jH3LZwGnyZU+bMGk1DtjMkHpZvfVQcILcpFiNr7+TC3UgnQx/ 85Uyj9ySzirmc+Pw8f5DFtzQQRxAvan9VDkNK9NUA1EauFAQqq2SR9JW2g4tdcAFJxX1 qVVrUlDH+k1gFNe6sAkysQzZObjzh0Ck/2VP9xl++QGOalat30Sasi99QxhKGIuUIGRf WCklaALJQSuTLQs7XJzRYiflt6uxk4KBrnvH5/X/J0xYa0fF19unWuawPP6/k5aC720f e33MF7dF7w7sN3dPDuPCGDhqDnQa8GM2fyDIdyrouZNcHQ3ub/phd8xPqEVD3z1Yp2/0 DWIA== 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 g9si32755530edz.166.2021.11.29.16.50.31; Mon, 29 Nov 2021 16:50:31 -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; 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 2146668AE72; Tue, 30 Nov 2021 02:50:09 +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 48E5B680C85 for ; Tue, 30 Nov 2021 02:50:00 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B7518E6372; Tue, 30 Nov 2021 01:49:59 +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 Ln6r7UpOnCWC; Tue, 30 Nov 2021 01:49:58 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 455A6E643E; Tue, 30 Nov 2021 01:49:58 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:48 +0100 Message-Id: <20211130004950.30697-3-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] fftools/ffmpeg: close output files before cleanup 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: xj88Fq5Qea+t This allows us to check the return value of avio_closep(). Signed-off-by: Marton Balint --- fftools/ffmpeg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 25360423b5..ea75fad637 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4716,7 +4716,7 @@ static int transcode(void) term_exit(); - /* write the trailer if needed and close file */ + /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; if (!output_files[i]->header_written) { @@ -4736,6 +4736,18 @@ static int transcode(void) /* dump report by using the first video and audio streams */ print_report(1, timer_start, av_gettime_relative()); + /* close the output files */ + for (i = 0; i < nb_output_files; i++) { + os = output_files[i]->ctx; + if (os && os->oformat && !(os->oformat->flags & AVFMT_NOFILE)) { + if ((ret = avio_closep(&os->pb)) < 0) { + av_log(NULL, AV_LOG_ERROR, "Error closing file %s: %s\n", os->url, av_err2str(ret)); + if (exit_on_error) + exit_program(1); + } + } + } + /* close each encoder */ for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; From patchwork Tue Nov 30 00:49:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31826 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968864iob; Mon, 29 Nov 2021 16:50:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJypjzqzEXUtl2CR2AjOqh/Job3A/g9DNKSM0PzGf8jXjgWcV1n/hVNdNoUHaSZsHIuaTniB X-Received: by 2002:a05:6402:5cb:: with SMTP id n11mr80382268edx.279.1638233441903; Mon, 29 Nov 2021 16:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233441; cv=none; d=google.com; s=arc-20160816; b=lu84FI4B+M58PpCOG5t2hbyK7PjMrpltkrLbeVg8DX2NXmHqAuWZ98ofF1YM2Af7/1 DaVx1Pokyc5Y4fBSCdKXytJe/UEWpotfO0zFiSJSIwJiUFpl6eOx35pLQuYa0Xf6wDAf SwU0qpyWLAYWHeaYvu4A+5FH51oSLC5N5RhXLWUm5mHtavUazeUFdY+UReF3PSN0iCcP i5RUW/ixKMF27HTSd+0jRTCL7+rtWA3dZvDQB7OFIeAuT74FpWfWtgWIKj9NqamJ9cpy 3cbEwd/vE3UIbMJP8itDXDWA0H8MGvyMzI0pmdoUS9d+m30RIOOY6L3ytgTDzDIKrDVj GEvg== 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=jyZOk6ipB8XHKh5yrI55Z66t3EUwbiKOnqHQsCpoCmM=; b=U3YCmf05VlyWnJ1Vi/9Z6RrO0FAFw4k6JJPPkvShbNoMqtaYHQ39eGO+xIGLa1vTl4 TwdBjL0SdtBq65gbP1A3Wf6NymJirV2B+LALuFlT1mYS4sd+FLLFXAe+RnS+06kzEd9U NrILpq67q6Hs9wO1qxx7Qy2jAPse/FZ4bRWKg+46kVhT68EgUcqse5zsN3wFkCAsd767 UOoILiqqzthfO8TwLy4/9u9Q0S2r6919nBo8M2uBlEHGS/H4AoRRGXm83L3K5bqAcrm3 8c4d1PVgr+3NAgfw8XGa1U3D9Jy1KaOpTHuFqqT7+FNqPhnqtiD5m4BPyTv/oLjomrDu IeGg== 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 dt15si24094185ejc.564.2021.11.29.16.50.41; Mon, 29 Nov 2021 16:50:41 -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; 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 3EACD68AE7C; Tue, 30 Nov 2021 02:50:10 +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 CD92C68AE46 for ; Tue, 30 Nov 2021 02:50:01 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4997BE6377; Tue, 30 Nov 2021 01:50:01 +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 AERzc41cQMBw; Tue, 30 Nov 2021 01:49:59 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EA42AE6441; Tue, 30 Nov 2021 01:49:58 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:49 +0100 Message-Id: <20211130004950.30697-4-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avformat: make AVFormatContext io_close return an int 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: Igr1tnHFc3Fg Otherwise there is no way to detect any error during avio_close(). Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavformat/avformat.h | 6 +++++- libavformat/internal.h | 6 +++++- libavformat/options.c | 4 ++-- libavformat/utils.c | 6 ++++-- libavformat/version.h | 4 ++-- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index bc9f4e38da..090263aedf 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-12-xx - xxxxxxxxxx - lavf 59.10.100 - avformat.h + AVFormatContext io_open now returns an int. + 2021-11-22 - xxxxxxxxxx - lavu 57.9.100 - pixfmt.h Add AV_PIX_FMT_P210, AV_PIX_FMT_P410, AV_PIX_FMT_P216, and AV_PIX_FMT_P416. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 75699f3a32..eec1f6b20c 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1756,8 +1756,12 @@ typedef struct AVFormatContext { /** * A callback for closing the streams opened with AVFormatContext.io_open(). + * + * @param s the format context + * @param pb IO context to be closed and freed + * @return 0 on success, a negative AVERROR code on failure */ - void (*io_close)(struct AVFormatContext *s, AVIOContext *pb); + int (*io_close)(struct AVFormatContext *s, AVIOContext *pb); /** * ',' separated list of disallowed protocols. diff --git a/libavformat/internal.h b/libavformat/internal.h index 20e93d9267..4f28885f3c 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -905,8 +905,12 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op /* * A wrapper around AVFormatContext.io_close that should be used * instead of calling the pointer directly. + * + * @param s AVFormatContext + * @param *pb the AVIOContext to be closed and freed. Can be NULL. + * @return >=0 on success, negative AVERROR in case of failure */ -void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); +int ff_format_io_close(AVFormatContext *s, AVIOContext **pb); /** * Utility function to check if the file uses http or https protocol diff --git a/libavformat/options.c b/libavformat/options.c index 72c9bdcefe..15f0c9e90c 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -146,9 +146,9 @@ static int io_open_default(AVFormatContext *s, AVIOContext **pb, return ffio_open_whitelist(pb, url, flags, &s->interrupt_callback, options, s->protocol_whitelist, s->protocol_blacklist); } -static void io_close_default(AVFormatContext *s, AVIOContext *pb) +static int io_close_default(AVFormatContext *s, AVIOContext *pb) { - avio_close(pb); + return avio_close(pb); } AVFormatContext *avformat_alloc_context(void) diff --git a/libavformat/utils.c b/libavformat/utils.c index 7840e8717c..db5ef46dc2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1829,11 +1829,13 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op return 0; } -void ff_format_io_close(AVFormatContext *s, AVIOContext **pb) +int ff_format_io_close(AVFormatContext *s, AVIOContext **pb) { + int ret = 0; if (*pb) - s->io_close(s, *pb); + ret = s->io_close(s, *pb); *pb = NULL; + return ret; } int ff_is_http_proto(const char *filename) { diff --git a/libavformat/version.h b/libavformat/version.h index 0705ee4112..1623835a78 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 9 -#define LIBAVFORMAT_VERSION_MICRO 102 +#define LIBAVFORMAT_VERSION_MINOR 10 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From patchwork Tue Nov 30 00:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31823 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6969018iob; Mon, 29 Nov 2021 16:50:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxx9jc4MIY5U9M54hALTNJYKbbIyAq7OBEvSNcD4vt3yrqR7M1Y/yZTUMIL0FEXjEaV04tW X-Received: by 2002:a17:907:1c82:: with SMTP id nb2mr62592016ejc.218.1638233452190; Mon, 29 Nov 2021 16:50:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233452; cv=none; d=google.com; s=arc-20160816; b=dqksRaSCh7q2qk25ka1M1G7y6xFqeGVCsxwG2o/x9aLZOhQAdRqFuoMVCUNUlNcZV9 CEv9Nmm90I4ZchzVXfp50kaZTaftz4teH/ZpJedtIkrPWAEJo13ib/icXuKjgQQZ6X+a VGHO8TpLXv/Zwo1CywxqeXt2cxnyHWnbgTRi43JdjERmD9I+QgQIpFZkt153wlsQCToc wXTHO36hslpsNyDHHu87JEYl4lGzajQuXQRVsiAWJNL672EPAeXkI+EpH7LKJAPRGlWk 5+HSK6GlXEzTCeMVTJ8mMCNvNdkWTJW7pltFjMEgu8zcOm2r31HEVjDn8NMqCihrwHdD AZPQ== 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=zcOz31hVmZhKXKRAOgkLM1xlFBK98XuomClRcZ7iib8=; b=rGw7KweDTG8eqPzw52suLETndwjgs+xG2ttrNi75Jd9x4RrE+nm1h29LdybJJPbIhu 0q+F31K2b2XouLdcn3kBZitFUhNW2SCZWEQEX68R/PpZ29FjvvaTc3yUCdfEryQiQW84 zWxCGto6sGcHtG6M2LPj0fhHbsa5R5EoSeSFvrA7af33kWarMP63GfDDsAYmNHssIamf jWAY8ZPXU6G0xsF6QM3aJEUwbKGZBVcBubXBsyBOhAot1CO/dUkoh2XtaqNgYCPgHymx x9eIikjNbkv34MoZ/W2fGoHUOmZfX92mMWrdXr4zI1ssx2XIPv4Aj6qAzoEozWrJr9Sz pj2Q== 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 k10si24031215ejx.113.2021.11.29.16.50.51; Mon, 29 Nov 2021 16:50:52 -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; 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 822C868AE87; Tue, 30 Nov 2021 02:50:11 +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 7091568AE46 for ; Tue, 30 Nov 2021 02:50:03 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BFDBCE643D; Tue, 30 Nov 2021 01:50:02 +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 05kCtJsJeGg8; Tue, 30 Nov 2021 01:50:00 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B996AE6442; Tue, 30 Nov 2021 01:49:59 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:50 +0100 Message-Id: <20211130004950.30697-5-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avformat/img2enc: do not ignore IO errors 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: yxT/rp6HCvG/ Signed-off-by: Marton Balint --- libavformat/img2enc.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 62202de9f4..ce23f38efb 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -124,6 +124,13 @@ static int write_packet_pipe(AVFormatContext *s, AVPacket *pkt) return 0; } +static int write_and_close(AVFormatContext *s, AVIOContext **pb, const unsigned char *buf, int size) +{ + avio_write(*pb, buf, size); + avio_flush(*pb); + return ff_format_io_close(s, pb); +} + static int write_packet(AVFormatContext *s, AVPacket *pkt) { VideoMuxData *img = s->priv_data; @@ -190,24 +197,22 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) ysize *= 2; usize *= 2; } - avio_write(pb[0], pkt->data , ysize); - avio_write(pb[1], pkt->data + ysize , usize); - avio_write(pb[2], pkt->data + ysize + usize, usize); - ff_format_io_close(s, &pb[1]); - ff_format_io_close(s, &pb[2]); - if (desc->nb_components > 3) { - avio_write(pb[3], pkt->data + ysize + 2*usize, ysize); - ff_format_io_close(s, &pb[3]); - } + if ((ret = write_and_close(s, &pb[0], pkt->data , ysize)) < 0 || + (ret = write_and_close(s, &pb[1], pkt->data + ysize , usize)) < 0 || + (ret = write_and_close(s, &pb[2], pkt->data + ysize + usize, usize)) < 0) + goto fail; + if (desc->nb_components > 3) + ret = write_and_close(s, &pb[3], pkt->data + ysize + 2*usize, ysize); } else if (img->muxer) { - ret = write_muxed_file(s, pb[0], pkt); - if (ret < 0) + if ((ret = write_muxed_file(s, pb[0], pkt)) < 0) goto fail; + ret = ff_format_io_close(s, &pb[0]); } else { - avio_write(pb[0], pkt->data, pkt->size); + ret = write_and_close(s, &pb[0], pkt->data, pkt->size); } - avio_flush(pb[0]); - ff_format_io_close(s, &pb[0]); + if (ret < 0) + goto fail; + for (i = 0; i < nb_renames; i++) { int ret = ff_rename(img->tmp[i], img->target[i], s); if (ret < 0)