diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-03-31 12:47:03 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-04-13 15:11:56 +0200 |
commit | a85e7e5dea542019feb85ab0730338c10c770746 (patch) | |
tree | 087ae23e14ecff3c842b16ae6444dd391799450c /fftools/ffmpeg.c | |
parent | 798da60e6a1c2f1fd7f243829f5e007e69e914d0 (diff) | |
download | ffmpeg-a85e7e5dea542019feb85ab0730338c10c770746.tar.gz |
fftools/ffmpeg: track a list of non-lavfi outputs in InputStream
Currently, output streams where an input stream is sent directly (i.e.
not through lavfi) are determined by iterating over ALL the output
streams and skipping the irrelevant ones. This is awkward and
inefficient.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 74aba28a9b..f65ff879c7 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -948,9 +948,6 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; - if (ost->ist != ist) - return 0; - if (ost->finished & MUXER_FINISHED) return 0; @@ -1468,7 +1465,8 @@ static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_out if (!subtitle->num_rects) goto out; - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; if (!check_output_constraints(ist, ost) || !ost->enc_ctx || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; @@ -1830,7 +1828,8 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } else if (!ist->decoding_needed) eof_reached = 1; - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; if (!check_output_constraints(ist, ost) || ost->enc_ctx || (!pkt && no_eof)) continue; @@ -2577,13 +2576,11 @@ static int process_input(int file_index) } /* mark all outputs that don't go through lavfi as finished */ - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - if (ost->ist == ist && - (!ost->enc_ctx || ost->enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE)) { - OutputFile *of = output_files[ost->file_index]; - close_output_stream(ost); - of_output_packet(of, ost->pkt, ost, 1); - } + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; + OutputFile *of = output_files[ost->file_index]; + close_output_stream(ost); + of_output_packet(of, ost->pkt, ost, 1); } } |