diff mbox series

[FFmpeg-devel] avfilter/avf_concat: fix EOF timestamp

Message ID 20210726210051.30111-1-onemda@gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter/avf_concat: fix EOF timestamp
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Paul B Mahol July 26, 2021, 9 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/avf_concat.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Nicolas George July 26, 2021, 9:15 p.m. UTC | #1
Paul B Mahol (12021-07-26):
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/avf_concat.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
> index cb46f52a04..f7d3889dfa 100644
> --- a/libavfilter/avf_concat.c
> +++ b/libavfilter/avf_concat.c
> @@ -397,12 +397,16 @@ static int activate(AVFilterContext *ctx)
>      /* Forward status change */
>      if (cat->cur_idx < ctx->nb_inputs) {
>          for (i = 0; i < ctx->nb_outputs; i++) {
> -            ret = ff_inlink_acknowledge_status(ctx->inputs[cat->cur_idx + i], &status, &pts);

> +            AVFilterLink *inlink = ctx->inputs[cat->cur_idx + i];
> +
> +            ret = ff_inlink_acknowledge_status(inlink, &status, &pts);

Thanks for the change.

>              /* TODO use pts */
>              if (ret > 0) {
>                  close_input(ctx, cat->cur_idx + i);
>                  if (cat->cur_idx + ctx->nb_outputs >= ctx->nb_inputs) {
> -                    ff_outlink_set_status(ctx->outputs[i], status, pts);
> +                    ff_outlink_set_status(ctx->outputs[i], status,
> +                                          cat->delta_ts + av_rescale_q(pts, inlink->time_base,
> +                                                                       ctx->outputs[i]->time_base));

My first review also said:

"and re-affect pts
in the line before rather than inlining the computation."

This multiply-indented formula is hard to read and would be very
annoying to maintain.

                       pts = av_rescale_q(pts, inlink->time_base, ctx->outputs[i]->time_base);
		       pts += cat->delta_ts;

would be much nicer.

>                  }
>                  if (!cat->nb_in_active) {
>                      ret = flush_segment(ctx);

Regards,
diff mbox series

Patch

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index cb46f52a04..f7d3889dfa 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -397,12 +397,16 @@  static int activate(AVFilterContext *ctx)
     /* Forward status change */
     if (cat->cur_idx < ctx->nb_inputs) {
         for (i = 0; i < ctx->nb_outputs; i++) {
-            ret = ff_inlink_acknowledge_status(ctx->inputs[cat->cur_idx + i], &status, &pts);
+            AVFilterLink *inlink = ctx->inputs[cat->cur_idx + i];
+
+            ret = ff_inlink_acknowledge_status(inlink, &status, &pts);
             /* TODO use pts */
             if (ret > 0) {
                 close_input(ctx, cat->cur_idx + i);
                 if (cat->cur_idx + ctx->nb_outputs >= ctx->nb_inputs) {
-                    ff_outlink_set_status(ctx->outputs[i], status, pts);
+                    ff_outlink_set_status(ctx->outputs[i], status,
+                                          cat->delta_ts + av_rescale_q(pts, inlink->time_base,
+                                                                       ctx->outputs[i]->time_base));
                 }
                 if (!cat->nb_in_active) {
                     ret = flush_segment(ctx);