[FFmpeg-cvslog] fftools/ffmpeg_mux_init: consolidate input stream flagging code
Anton Khirnov
git at videolan.org
Mon Apr 17 13:07:13 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Apr 11 12:48:41 2023 +0200| [c7438e87377b95191b395fcf72f1653ac69eab9c] | committer: Anton Khirnov
fftools/ffmpeg_mux_init: consolidate input stream flagging code
Makes it easier to see where the input stream is modified from muxer
code.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7438e87377b95191b395fcf72f1653ac69eab9c
---
fftools/ffmpeg_mux_init.c | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 74f0d5f56b..46fa17beb2 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1203,13 +1203,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
if (ost->enc_ctx && av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24)
av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
- if (ost->ist) {
- ost->ist->discard = 0;
- ost->ist->st->discard = ost->ist->user_set_discard;
-
- if (!(ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)))
- ist_output_add(ost->ist, ost);
- }
ost->last_mux_dts = AV_NOPTS_VALUE;
MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i,
@@ -1224,6 +1217,25 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
default: new_stream_unknown (mux, o, ost); break;
}
+ if (ost->ist) {
+ ost->ist->discard = 0;
+ ost->ist->st->discard = ost->ist->user_set_discard;
+
+ if (ost->enc)
+ ost->ist->decoding_needed |= DECODING_FOR_OST;
+
+ if (ost->enc &&
+ (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
+ ret = init_simple_filtergraph(ost->ist, ost);
+ if (ret < 0) {
+ av_log(ost, AV_LOG_ERROR,
+ "Error initializing a simple filtergraph\n");
+ exit_program(1);
+ }
+ } else
+ ist_output_add(ost->ist, ost);
+ }
+
if (ost->ist && !ost->enc) {
ret = streamcopy_init(mux, o, ost);
if (ret < 0)
@@ -2410,25 +2422,9 @@ int of_open(const OptionsContext *o, const char *filename)
/* check if all codec options have been used */
validate_enc_avopt(mux, o->g->codec_opts);
- /* set the decoding_needed flags and create simple filtergraphs */
for (int i = 0; i < of->nb_streams; i++) {
OutputStream *ost = of->streams[i];
- if (ost->enc_ctx && ost->ist) {
- InputStream *ist = ost->ist;
- ist->decoding_needed |= DECODING_FOR_OST;
-
- if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
- ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
- err = init_simple_filtergraph(ist, ost);
- if (err < 0) {
- av_log(ost, AV_LOG_ERROR,
- "Error initializing a simple filtergraph\n");
- exit_program(1);
- }
- }
- }
-
/* set the filter output constraints */
if (ost->filter) {
const AVCodec *c = ost->enc_ctx->codec;
More information about the ffmpeg-cvslog
mailing list