mirror of https://git.ffmpeg.org/ffmpeg.git
fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions
Stop digging through encoder options manually. Will allow decoupling filtering from encoding in future commits.
This commit is contained in:
parent
bfeb751171
commit
f2c919252d
|
@ -291,6 +291,8 @@ typedef struct OutputFilterOptions {
|
||||||
AVDictionary *sws_opts;
|
AVDictionary *sws_opts;
|
||||||
AVDictionary *swr_opts;
|
AVDictionary *swr_opts;
|
||||||
|
|
||||||
|
const char *nb_threads;
|
||||||
|
|
||||||
// A combination of OFilterFlags.
|
// A combination of OFilterFlags.
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ typedef struct FilterGraphPriv {
|
||||||
|
|
||||||
const char *graph_desc;
|
const char *graph_desc;
|
||||||
|
|
||||||
|
char *nb_threads;
|
||||||
|
|
||||||
// frame for temporarily holding output from the filtergraph
|
// frame for temporarily holding output from the filtergraph
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
// frame for sending output to the encoder
|
// frame for sending output to the encoder
|
||||||
|
@ -976,6 +978,7 @@ void fg_free(FilterGraph **pfg)
|
||||||
}
|
}
|
||||||
av_freep(&fg->outputs);
|
av_freep(&fg->outputs);
|
||||||
av_freep(&fgp->graph_desc);
|
av_freep(&fgp->graph_desc);
|
||||||
|
av_freep(&fgp->nb_threads);
|
||||||
|
|
||||||
av_frame_free(&fgp->frame);
|
av_frame_free(&fgp->frame);
|
||||||
av_frame_free(&fgp->frame_enc);
|
av_frame_free(&fgp->frame_enc);
|
||||||
|
@ -1165,6 +1168,13 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1735,17 +1745,15 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
|
||||||
|
|
||||||
if (simple) {
|
if (simple) {
|
||||||
OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]);
|
OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]);
|
||||||
OutputStream *ost = fg->outputs[0]->ost;
|
|
||||||
|
|
||||||
if (filter_nbthreads) {
|
if (filter_nbthreads) {
|
||||||
ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0);
|
ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else if (fgp->nb_threads) {
|
||||||
const AVDictionaryEntry *e = NULL;
|
ret = av_opt_set(fgt->graph, "threads", fgp->nb_threads, 0);
|
||||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
if (ret < 0)
|
||||||
if (e)
|
return ret;
|
||||||
av_opt_set(fgt->graph, "threads", e->value, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (av_dict_count(ofp->sws_opts)) {
|
if (av_dict_count(ofp->sws_opts)) {
|
||||||
|
|
|
@ -1370,6 +1370,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||||
|
|
||||||
if (ost->enc &&
|
if (ost->enc &&
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
|
const AVDictionaryEntry *e;
|
||||||
char name[16];
|
char name[16];
|
||||||
OutputFilterOptions opts = {
|
OutputFilterOptions opts = {
|
||||||
.enc = enc,
|
.enc = enc,
|
||||||
|
@ -1395,6 +1396,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index);
|
snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index);
|
||||||
|
|
||||||
|
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||||
|
if (e)
|
||||||
|
opts.nb_threads = e->value;
|
||||||
|
|
||||||
// MJPEG encoder exports a full list of supported pixel formats,
|
// MJPEG encoder exports a full list of supported pixel formats,
|
||||||
// but the full-range ones are experimental-only.
|
// but the full-range ones are experimental-only.
|
||||||
// Restrict the auto-conversion list unless -strict experimental
|
// Restrict the auto-conversion list unless -strict experimental
|
||||||
|
|
Loading…
Reference in New Issue