From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [RFC PATCH] fftools/ffmpeg: make main function actually return Date: Fri, 2 Dec 2022 00:18:34 +0800 Message-ID: <tencent_929F62AB2F4E5E70082DE99AE040769A1008@qq.com> (raw) From: Zhao Zhili <zhilizhao@tencent.com> --- 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 <conio.h> #endif +#include <setjmp.h> #include <time.h> #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".
reply other threads:[~2022-12-01 16:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_929F62AB2F4E5E70082DE99AE040769A1008@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=zhilizhao@tencent.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git