From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 21F7044900 for ; Thu, 1 Dec 2022 16:19:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AE5B68B3AE; Thu, 1 Dec 2022 18:19:27 +0200 (EET) Received: from out203-205-251-66.mail.qq.com (out203-205-251-66.mail.qq.com [203.205.251.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D54B688127 for ; Thu, 1 Dec 2022 18:19:19 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1669911555; bh=c4tNqIJqH5q2APKk1+AgG4/H7yLdw8sbHr1SEGwq80Y=; h=From:To:Cc:Subject:Date; b=A50NEcoFe4T20sKQF2NQrVfoU37PJuGcbmWC3+6y6M4D8+Sj5hfV0rzOE1Hd0Lr1u Su0sv9NfKlXYmZhGbivYk5yjabgW4GQXHilUMEy1TO8rs1VhPbQpcndv1lK9Bvj2lG mH3GK/ZknRZh9znoqrC7S9Xj8mH7QcZ+JD/LXgUY= Received: from localhost.localdomain ([121.35.184.176]) by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP id 4CE33AE2; Fri, 02 Dec 2022 00:19:14 +0800 X-QQ-mid: xmsmtpt1669911554t8zaa0zap Message-ID: X-QQ-XMAILINFO: M2gD+HURHsrGtEKGFFzGvXB/aWXpyGI8XRsRnpULyskfEcEbcRel36sZCwOvxy 2b9vnkqzd3flAJM/rWEyKytWNFfv7FvX98ACQP27FoOuaMxfUZ2Z7FwCuXlps1q53IuyV3YCRVs7 7mZMAi4RPD4J5xTsFfvUnKj23Bl9TZH5Mw3ed1aYqXppGQJYgOj8HFH5gF0z9DAkJ2kt4rqK/Ve7 jHPkK/QbY6iIyp3+R9iJWPDQoZr9BoRW18zn5yemc+IysID9Gsw2y1WGpmChNw7h8lFX+w5iQLJF UTFY8OimuMXPWXiesNQUCCFt/GUPvmyY3BxVB9zhPABNtH7qbwEIp4B/eT/BazkrkPu+FJy87rNh QcriBz03F3sAYxrUuvW8G321n+OHkXGKsopt64XKHmM+QvLgKIMSPk1H+Veg8umN04qlEVhuvm7D YE9ct20q7TUGuvoU2ZH92VWwFBtumZUCWjkgQcBULTLvVszcg0qFxLm6h+dkgvev+hoZF4dPUIGn IzKVul+u+xm5B66GpmZ8tliJ0E032Mlu+lCsDTA+QTys4M1Z5B0M2+fHaoHrQPv6Pv+ZouQroItq c/Nlhz+32crE9oz2gaGCyjsZBkzTgCZ/+d1mUFClNv+v9mghesGGxVa9iIGPEHC7sWhXYZeahoTU e+UV70y/tp2P+EXxbZO+INd6jOfDV4NjssEKRRgu1lLuLGYJ5i3jBOBbNgij6j9zHvm3AxhyjXLu 2AU+89IVzNryq+1DiviWbCPQyqgET1JHJjTPSScEeydOxMu8a6pNNN7S8ucrM385a2Yfliy6NsQj 82c6/dWQwoWHubT9eFKo/2g63gY0yz5RhGCig4IIIkhLjEPLdHrTW/5CaF7RJyq7WUZGdKg9h597 bt2KPAjxmFxK1B3aloUEMgtRq19GxZt6lgotYHxroSIgDdwFA0ShWbC2rhkk99JPNXhHwVgdinPO +T1yeQ5cU= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Dec 2022 00:18:34 +0800 X-OQ-MSGID: <20221201161834.4836-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC PATCH] fftools/ffmpeg: make main function actually return 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: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Zhao Zhili --- When working on mediacodec encoder, I test it by making fftools/ffmpeg into a lib, since JNI requires a JVM environment. There are three steps mostly: 1. Rename main() function 2. Reset global variables 3. Make main() function actuall return There is no point for this patch, except making fftools/ffmpeg a little "lib friendly". And I understand fftools/ffmpeg isn't a lib by design. But sometimes it's quick and easier to hack it. fftools/ffmpeg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 771219f7df..4b12ad1ef8 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -100,6 +100,7 @@ #include #endif +#include #include #include "ffmpeg.h" @@ -491,10 +492,13 @@ static int decode_interrupt_cb(void *ctx) const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; +static jmp_buf exit_buf; + static void ffmpeg_cleanup(int ret) { int i, j; + main_return_code = ret; if (do_benchmark) { int maxrss = getmaxrss() / 1024; av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss); @@ -571,6 +575,7 @@ static void ffmpeg_cleanup(int ret) } term_exit(); ffmpeg_exited = 1; + longjmp(exit_buf, 1); } /* iterate over all output streams in all output files; @@ -3868,6 +3873,11 @@ int main(int argc, char **argv) int ret; BenchmarkTimeStamps ti; + if (setjmp(exit_buf)) { + // longjmp from ffmpeg_cleanup + return main_return_code; + } + init_dynload(); register_exit(ffmpeg_cleanup); -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".