Commit 80b47487 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_srcnn: use function to get number of threads

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent e3a697ed
...@@ -337,6 +337,7 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in) ...@@ -337,6 +337,7 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in)
AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h); AVFrame* out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
ThreadData td; ThreadData td;
ConvThreadData ctd; ConvThreadData ctd;
int nb_threads;
if (!out){ if (!out){
av_log(context, AV_LOG_ERROR, "could not allocate memory for output frame\n"); av_log(context, AV_LOG_ERROR, "could not allocate memory for output frame\n");
...@@ -351,20 +352,21 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in) ...@@ -351,20 +352,21 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in)
td.height = ctd.height = out->height; td.height = ctd.height = out->height;
td.width = ctd.width = out->width; td.width = ctd.width = out->width;
context->internal->execute(context, uint8_to_double, &td, NULL, FFMIN(td.height, context->graph->nb_threads)); nb_threads = ff_filter_get_nb_threads(context);
context->internal->execute(context, uint8_to_double, &td, NULL, FFMIN(td.height, nb_threads));
ctd.conv = &srcnn_context->conv1; ctd.conv = &srcnn_context->conv1;
ctd.input = srcnn_context->input_output_buf; ctd.input = srcnn_context->input_output_buf;
ctd.output = srcnn_context->conv1_buf; ctd.output = srcnn_context->conv1_buf;
context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, context->graph->nb_threads)); context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, nb_threads));
ctd.conv = &srcnn_context->conv2; ctd.conv = &srcnn_context->conv2;
ctd.input = srcnn_context->conv1_buf; ctd.input = srcnn_context->conv1_buf;
ctd.output = srcnn_context->conv2_buf; ctd.output = srcnn_context->conv2_buf;
context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, context->graph->nb_threads)); context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, nb_threads));
ctd.conv = &srcnn_context->conv3; ctd.conv = &srcnn_context->conv3;
ctd.input = srcnn_context->conv2_buf; ctd.input = srcnn_context->conv2_buf;
ctd.output = srcnn_context->input_output_buf; ctd.output = srcnn_context->input_output_buf;
context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, context->graph->nb_threads)); context->internal->execute(context, convolve, &ctd, NULL, FFMIN(ctd.height, nb_threads));
context->internal->execute(context, double_to_uint8, &td, NULL, FFMIN(td.height, context->graph->nb_threads)); context->internal->execute(context, double_to_uint8, &td, NULL, FFMIN(td.height, nb_threads));
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment