[FFmpeg-devel] [PATCH] Improved the performance of 1 decode + N filter graphs and adaptive bitrate.

Carl Eugen Hoyos ceffmpeg at gmail.com
Tue Mar 26 12:35:46 EET 2019


2019-03-26 23:07 GMT+01:00, Shaofei Wang <shaofei.wang at intel.com>:
> It enabled MULTIPLE SIMPLE filter graph concurrency, which
> bring above about 4%~20% improvement in some 1:N
> scenarios by CPU or GPU acceleration

Which version of the patch did you test to get this numbers?

The following is not an actual review, feel free to ignore all comments.

> -    /* Reap all buffers present in the buffer sinks */
> +    /* Reap all buffers present in the buffer sinks or just reap specified
> +     * buffer which related with the filter graph who got ifilter as
> input*/

/* Reap all buffers present in the buffer sinks */
/* or just reap specified buffer which related */
/* with the filter graph who got ifilter as input */

> +        if (ifilter && abr_threads_enabled)
> +            if (ost != ifilter->graph->outputs[0]->ost)
> +                continue;

if (filter && abr_threads_enabled && ost != ifilter->graph->outputs[0]->ost)
  continue;

> -        ret = reap_filters(1);
> +        ret = (HAVE_THREADS && abr_threads_enabled) ? reap_filters(1,
> ifilter) : reap_filters(1, NULL);

ret = reap_filters(1, HAVE_THREADS && abr_threads_enabled ? ifilter, NULL);

Same below.

> +        if (ret == AVERROR_EOF)
> +            ret = 0;
> +        else if (ret < 0) {

Please add "{" and "}".

> +            av_log(NULL, AV_LOG_ERROR,
> +                   "Failed to inject frame into filter network: %s\n",
> av_err2str(ret));
> +        } else {

>  static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
>  {
> -    int i, ret;
> +    int i, ret = 0;
>      AVFrame *f;
>
>      av_assert1(ist->nb_filters > 0); /* ensure ret is initialized */
> +

No.

>      for (i = 0; i < ist->nb_filters; i++) {
>          if (i < ist->nb_filters - 1) {
> -            f = ist->filter_frame;
> +            f = (HAVE_THREADS && abr_threads_enabled) ?
> ist->filters[i]->input_frm : ist->filter_frame;

See above.

> -        ret = ifilter_send_frame(ist->filters[i], f);
> -        if (ret == AVERROR_EOF)
> -            ret = 0; /* ignore */
> -        if (ret < 0) {
> -            av_log(NULL, AV_LOG_ERROR,
> -                   "Failed to inject frame into filter network: %s\n",
> av_err2str(ret));
> -            break;
> +        if (!HAVE_THREADS || !abr_threads_enabled) {
> +            ret = ifilter_send_frame(ist->filters[i], f);
> +            if (ret == AVERROR_EOF)
> +                ret = 0; /* ignore */
> +            if (ret < 0) {
> +                av_log(NULL, AV_LOG_ERROR,
> +                       "Failed to inject frame into filter network: %s\n",
> av_err2str(ret));
> +                break;

Some people here (including me) find the patch much easier
to read if you do the re-indentation in a separate patch.

> @@ -2334,7 +2442,6 @@ static int decode_audio
>                                                (AVRational){1,
> avctx->sample_rate});
>      ist->nb_samples = decoded_frame->nb_samples;
>      err = send_frame_to_filters(ist, decoded_frame);
> -

No.

Carl Eugen


More information about the ffmpeg-devel mailing list