[FFmpeg-cvslog] fftools/ffmpeg_mux_init: return error codes from parse_forced_key_frames() instead of aborting

Anton Khirnov git at videolan.org
Sat Jul 15 12:02:56 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jul 12 16:40:19 2023 +0200| [4e3557aadb07c0bd029894dfed850c9c5b1b17f7] | committer: Anton Khirnov

fftools/ffmpeg_mux_init: return error codes from parse_forced_key_frames() instead of aborting

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e3557aadb07c0bd029894dfed850c9c5b1b17f7
---

 fftools/ffmpeg_mux_init.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index f85357d8e4..7a8c935795 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2245,8 +2245,8 @@ static int compare_int64(const void *a, const void *b)
     return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b);
 }
 
-static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
-                                    const char *spec)
+static int parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
+                                   const char *spec)
 {
     const char *p;
     int n = 1, i, size, index = 0;
@@ -2258,7 +2258,7 @@ static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
     size = n;
     pts = av_malloc_array(size, sizeof(*pts));
     if (!pts)
-        report_and_exit(AVERROR(ENOMEM));
+        return AVERROR(ENOMEM);
 
     p = spec;
     for (i = 0; i < n; i++) {
@@ -2275,7 +2275,7 @@ static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
             if (nb_ch > INT_MAX - size ||
                 !(pts = av_realloc_f(pts, size += nb_ch - 1,
                                      sizeof(*pts))))
-                report_and_exit(AVERROR(ENOMEM));
+                return AVERROR(ENOMEM);
             t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0;
 
             for (j = 0; j < nb_ch; j++) {
@@ -2297,6 +2297,8 @@ static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
     qsort(pts, size, sizeof(*pts), compare_int64);
     kf->nb_pts = size;
     kf->pts    = pts;
+
+    return 0;
 }
 
 static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
@@ -2331,7 +2333,9 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
         } else if (!strcmp(forced_keyframes, "source_no_drop")) {
             ost->kf.type = KF_FORCE_SOURCE_NO_DROP;
         } else {
-            parse_forced_key_frames(&ost->kf, mux, forced_keyframes);
+            int ret = parse_forced_key_frames(&ost->kf, mux, forced_keyframes);
+            if (ret < 0)
+                return ret;
         }
     }
 



More information about the ffmpeg-cvslog mailing list