mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-06 15:49:50 +08:00
fftools/ffmpeg: use an int for nb_threads
Removes unnecessary allocations. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@ -316,7 +316,7 @@ typedef struct OutputFilterOptions {
|
||||
AVDictionary *sws_opts;
|
||||
AVDictionary *swr_opts;
|
||||
|
||||
const char *nb_threads;
|
||||
int64_t nb_threads;
|
||||
|
||||
// A combination of OFilterFlags.
|
||||
unsigned flags;
|
||||
|
@ -60,7 +60,7 @@ typedef struct FilterGraphPriv {
|
||||
|
||||
const char *graph_desc;
|
||||
|
||||
char *nb_threads;
|
||||
int nb_threads;
|
||||
|
||||
// frame for temporarily holding output from the filtergraph
|
||||
AVFrame *frame;
|
||||
@ -1042,7 +1042,6 @@ 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);
|
||||
@ -1097,6 +1096,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
|
||||
fg->class = &fg_class;
|
||||
fgp->graph_desc = graph_desc;
|
||||
fgp->disable_conversions = !auto_conversion_filters;
|
||||
fgp->nb_threads = -1;
|
||||
fgp->sch = sch;
|
||||
|
||||
snprintf(fgp->log_name, sizeof(fgp->log_name), "fc#%d", fg->index);
|
||||
@ -1247,12 +1247,8 @@ int fg_create_simple(FilterGraph **pfg,
|
||||
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);
|
||||
}
|
||||
if (opts->nb_threads >= 0)
|
||||
fgp->nb_threads = opts->nb_threads;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1936,8 +1932,8 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
|
||||
ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
} else if (fgp->nb_threads) {
|
||||
ret = av_opt_set(fgt->graph, "threads", fgp->nb_threads, 0);
|
||||
} else if (fgp->nb_threads >= 0) {
|
||||
ret = av_opt_set_int(fgt->graph, "threads", fgp->nb_threads, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -930,6 +930,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||
.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
|
||||
0 : mux->of.start_time,
|
||||
.vs = vs,
|
||||
.nb_threads = -1,
|
||||
|
||||
.flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt |
|
||||
OFILTER_FLAG_AUTOSCALE * !!autoscale |
|
||||
@ -982,7 +983,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||
}
|
||||
|
||||
if (threads_manual) {
|
||||
ret = av_opt_get(enc_ctx, "threads", 0, (uint8_t**)&opts.nb_threads);
|
||||
ret = av_opt_get_int(enc_ctx, "threads", 0, &opts.nb_threads);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@ -1002,7 +1003,6 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||
ost->filter = ost->fg_simple->outputs[0];
|
||||
|
||||
}
|
||||
av_freep(&opts.nb_threads);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
Reference in New Issue
Block a user