diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-04-04 11:30:18 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-04-09 10:34:18 +0200 |
commit | f2c919252da460f89f7281c769d3005e35d95b85 (patch) | |
tree | e102ca4dca0f61aa0b0295d235e21e36e6a2fd49 /fftools/ffmpeg_filter.c | |
parent | bfeb751171c87e81fa940f4152b1e72eb9b0a1c0 (diff) | |
download | ffmpeg-f2c919252da460f89f7281c769d3005e35d95b85.tar.gz |
fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions
Stop digging through encoder options manually.
Will allow decoupling filtering from encoding in future commits.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ec17e99494..9fc6e32960 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -59,6 +59,8 @@ typedef struct FilterGraphPriv { const char *graph_desc; + char *nb_threads; + // frame for temporarily holding output from the filtergraph AVFrame *frame; // frame for sending output to the encoder @@ -976,6 +978,7 @@ void fg_free(FilterGraph **pfg) } av_freep(&fg->outputs); av_freep(&fgp->graph_desc); + av_freep(&fgp->nb_threads); av_frame_free(&fgp->frame); av_frame_free(&fgp->frame_enc); @@ -1165,6 +1168,13 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, if (ret < 0) return ret; + if (opts->nb_threads) { + av_freep(&fgp->nb_threads); + fgp->nb_threads = av_strdup(opts->nb_threads); + if (!fgp->nb_threads) + return AVERROR(ENOMEM); + } + return 0; } @@ -1735,17 +1745,15 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) if (simple) { OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]); - OutputStream *ost = fg->outputs[0]->ost; if (filter_nbthreads) { ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0); if (ret < 0) goto fail; - } else { - const AVDictionaryEntry *e = NULL; - e = av_dict_get(ost->encoder_opts, "threads", NULL, 0); - if (e) - av_opt_set(fgt->graph, "threads", e->value, 0); + } else if (fgp->nb_threads) { + ret = av_opt_set(fgt->graph, "threads", fgp->nb_threads, 0); + if (ret < 0) + return ret; } if (av_dict_count(ofp->sws_opts)) { |