Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2020-09-11 00:13:27 +0300
committerJan Ekström <jeebjp@gmail.com>2020-10-17 11:55:55 +0300
commit86228ebdb2f1c9c066473710c7e14eb8331265bf (patch)
treecf70df9563fcf21670d32dddf1f8b14e957fcdee /fftools/ffmpeg.c
parentbf4a253f3829a1faf5c8ba30bf79cd7170e87af8 (diff)
ffmpeg: deduplicate init_output_stream usage logic
Adds a wrapper function, which handles any errors depending on how fatal a failure would be.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r--fftools/ffmpeg.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 84306818a2..cb7644de6a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1392,6 +1392,26 @@ static void do_video_stats(OutputStream *ost, int frame_size)
static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+{
+ int ret = AVERROR_BUG;
+ char error[1024] = {0};
+
+ if (ost->initialized)
+ return 0;
+
+ ret = init_output_stream(ost, error, sizeof(error));
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
+ ost->file_index, ost->index, error);
+
+ if (fatal)
+ exit_program(1);
+ }
+
+ return ret;
+}
+
static void finish_output_stream(OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
@@ -1428,15 +1448,7 @@ static int reap_filters(int flush)
continue;
filter = ost->filter->filter;
- if (!ost->initialized) {
- char error[1024] = "";
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
- }
+ init_output_stream_wrapper(ost, 1);
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
return AVERROR(ENOMEM);
@@ -1860,7 +1872,6 @@ static void flush_encoders(void)
// Maybe we should just let encoding fail instead.
if (!ost->initialized) {
FilterGraph *fg = ost->filter->graph;
- char error[1024] = "";
av_log(NULL, AV_LOG_WARNING,
"Finishing stream %d:%d without any data written to it.\n",
@@ -1886,12 +1897,7 @@ static void flush_encoders(void)
finish_output_stream(ost);
}
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
+ init_output_stream_wrapper(ost, 1);
}
if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
@@ -3669,7 +3675,7 @@ static int transcode_init(void)
if (output_streams[i]->filter)
continue;
- ret = init_output_stream(output_streams[i], error, sizeof(error));
+ ret = init_output_stream_wrapper(output_streams[i], 0);
if (ret < 0)
goto dump_format;
}
@@ -4580,15 +4586,8 @@ static int transcode_step(void)
}
if (ost->filter && ost->filter->graph->graph) {
- if (!ost->initialized) {
- char error[1024] = {0};
- ret = init_output_stream(ost, error, sizeof(error));
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
- ost->file_index, ost->index, error);
- exit_program(1);
- }
- }
+ init_output_stream_wrapper(ost, 1);
+
if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0)
return ret;
if (!ist)