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 97D4C45A54 for ; Thu, 13 Jul 2023 10:59:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C51CC68C6E0; Thu, 13 Jul 2023 13:58:03 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9718E68C67E for ; Thu, 13 Jul 2023 13:57:52 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 61B902404EA for ; Thu, 13 Jul 2023 12:57:52 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id fPooHNFKO7rJ for ; Thu, 13 Jul 2023 12:57:51 +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 A2CE62406CF for ; Thu, 13 Jul 2023 12:57:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id ED98B3A1B0D for ; Thu, 13 Jul 2023 12:57:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jul 2023 12:55:42 +0200 Message-Id: <20230713105553.21052-22-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713105553.21052-1-anton@khirnov.net> References: <20230713105553.21052-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/33] fftools/ffmpeg_enc: return errors from enc_subtitle() 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 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: --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 4 +++- fftools/ffmpeg_enc.c | 16 ++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fdee20d6b2..bcd9cc584e 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -804,7 +804,7 @@ int enc_alloc(Encoder **penc, const AVCodec *codec); void enc_free(Encoder **penc); int enc_open(OutputStream *ost, AVFrame *frame); -void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub); +int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub); void enc_frame(OutputStream *ost, AVFrame *frame); void enc_flush(void); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 85bf8dc536..a1d811f512 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -439,7 +439,9 @@ static int process_subtitle(InputStream *ist, AVFrame *frame) if (!ost->enc || ost->type != AVMEDIA_TYPE_SUBTITLE) continue; - enc_subtitle(output_files[ost->file_index], ost, subtitle); + ret = enc_subtitle(output_files[ost->file_index], ost, subtitle); + if (ret < 0) + return ret; } return 0; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 4029501313..b35dbb6290 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -462,7 +462,7 @@ static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb) return 1; } -void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) +int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) { Encoder *e = ost->enc; int subtitle_out_max_size = 1024 * 1024; @@ -473,13 +473,11 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) if (sub->pts == AV_NOPTS_VALUE) { av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n"); - if (exit_on_error) - exit_program(1); - return; + return exit_on_error ? AVERROR(EINVAL) : 0; } if (ost->finished || (of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time)) - return; + return 0; enc = ost->enc_ctx; @@ -501,11 +499,11 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) AVSubtitle local_sub = *sub; if (!check_recording_time(ost, pts, AV_TIME_BASE_Q)) - return; + return 0; ret = av_new_packet(pkt, subtitle_out_max_size); if (ret < 0) - report_and_exit(AVERROR(ENOMEM)); + return AVERROR(ENOMEM); local_sub.pts = pts; // start_display_time is required to be 0 @@ -525,7 +523,7 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, &local_sub); if (subtitle_out_size < 0) { av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n"); - exit_program(1); + return subtitle_out_size; } av_shrink_packet(pkt, subtitle_out_size); @@ -544,6 +542,8 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) of_output_packet(of, ost, pkt); } + + return 0; } void enc_stats_write(OutputStream *ost, EncStats *es, -- 2.40.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".