[FFmpeg-devel,V1,5/5] lavf/utils: add duration estimate method trace

Submitted by Jun Zhao on Sept. 28, 2019, 12:23 p.m.

Details

Message ID 1569673437-22200-5-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao Sept. 28, 2019, 12:23 p.m.
From: Jun Zhao <barryjzhao@tencent.com>

add duration estimate method trace, it's can help to some duration
issue trace or debug.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/utils.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

Comments

Michael Niedermayer Sept. 28, 2019, 3:29 p.m.
On Sat, Sep 28, 2019 at 08:23:57PM +0800, Jun Zhao wrote:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> add duration estimate method trace, it's can help to some duration
> issue trace or debug.

theres some english grammer issue here


> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/utils.c |   16 +++++++++++++++-
>  1 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index c0ccd8c..8620c6f 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2977,6 +2977,16 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
>      {
>          int i;
>          AVStream av_unused *st;
> +        const char *duration_method;

> +        struct duration_mode {
> +            enum AVDurationEstimationMethod mode;
> +            const char *name; ///< short name for the duration estimation method
> +        };
> +        struct duration_mode duration_modes[] = {
> +            { AVFMT_DURATION_FROM_PTS,    "pts"       },
> +            { AVFMT_DURATION_FROM_STREAM, "stream"    },
> +            { AVFMT_DURATION_FROM_BITRATE,"bit rate"  },
> +        };

This maybe could be in a seperate function


>          for (i = 0; i < ic->nb_streams; i++) {
>              st = ic->streams[i];
>              if (st->time_base.den)
> @@ -2984,10 +2994,14 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
>                         (double) st->start_time * av_q2d(st->time_base),
>                         (double) st->duration   * av_q2d(st->time_base));
>          }
> +        for (i = 0; i < FF_ARRAY_ELEMS(duration_modes); i++)
> +            if (ic->duration_estimation_method == duration_modes[i].mode)
> +                duration_method = duration_modes[i].name;
>          av_log(ic, AV_LOG_TRACE,
> -                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
> +                "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
>                  (double) ic->start_time / AV_TIME_BASE,
>                  (double) ic->duration   / AV_TIME_BASE,
> +                duration_method,
>                  (int64_t)ic->bit_rate / 1000);
>      }

rest LGTM

thx

[...]
mypopy@gmail.com Sept. 29, 2019, 12:59 a.m.
On Sat, Sep 28, 2019 at 11:29 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Sat, Sep 28, 2019 at 08:23:57PM +0800, Jun Zhao wrote:
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > add duration estimate method trace, it's can help to some duration
> > issue trace or debug.
>
> theres some english grammer issue here
>
Will fix, thx
>
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/utils.c |   16 +++++++++++++++-
> >  1 files changed, 15 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index c0ccd8c..8620c6f 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -2977,6 +2977,16 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
> >      {
> >          int i;
> >          AVStream av_unused *st;
> > +        const char *duration_method;
>
> > +        struct duration_mode {
> > +            enum AVDurationEstimationMethod mode;
> > +            const char *name; ///< short name for the duration estimation method
> > +        };
> > +        struct duration_mode duration_modes[] = {
> > +            { AVFMT_DURATION_FROM_PTS,    "pts"       },
> > +            { AVFMT_DURATION_FROM_STREAM, "stream"    },
> > +            { AVFMT_DURATION_FROM_BITRATE,"bit rate"  },
> > +        };
>
> This maybe could be in a seperate function
>
Will split as a seperate function
>
> >          for (i = 0; i < ic->nb_streams; i++) {
> >              st = ic->streams[i];
> >              if (st->time_base.den)
> > @@ -2984,10 +2994,14 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
> >                         (double) st->start_time * av_q2d(st->time_base),
> >                         (double) st->duration   * av_q2d(st->time_base));
> >          }
> > +        for (i = 0; i < FF_ARRAY_ELEMS(duration_modes); i++)
> > +            if (ic->duration_estimation_method == duration_modes[i].mode)
> > +                duration_method = duration_modes[i].name;
> >          av_log(ic, AV_LOG_TRACE,
> > -                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
> > +                "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
> >                  (double) ic->start_time / AV_TIME_BASE,
> >                  (double) ic->duration   / AV_TIME_BASE,
> > +                duration_method,
> >                  (int64_t)ic->bit_rate / 1000);
> >      }
>
> rest LGTM
>
> thx
>
> [...]
>
> --

Patch hide | download patch | download mbox

diff --git a/libavformat/utils.c b/libavformat/utils.c
index c0ccd8c..8620c6f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2977,6 +2977,16 @@  static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
     {
         int i;
         AVStream av_unused *st;
+        const char *duration_method;
+        struct duration_mode {
+            enum AVDurationEstimationMethod mode;
+            const char *name; ///< short name for the duration estimation method
+        };
+        struct duration_mode duration_modes[] = {
+            { AVFMT_DURATION_FROM_PTS,    "pts"       },
+            { AVFMT_DURATION_FROM_STREAM, "stream"    },
+            { AVFMT_DURATION_FROM_BITRATE,"bit rate"  },
+        };
         for (i = 0; i < ic->nb_streams; i++) {
             st = ic->streams[i];
             if (st->time_base.den)
@@ -2984,10 +2994,14 @@  static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
                        (double) st->start_time * av_q2d(st->time_base),
                        (double) st->duration   * av_q2d(st->time_base));
         }
+        for (i = 0; i < FF_ARRAY_ELEMS(duration_modes); i++)
+            if (ic->duration_estimation_method == duration_modes[i].mode)
+                duration_method = duration_modes[i].name;
         av_log(ic, AV_LOG_TRACE,
-                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
+                "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
                 (double) ic->start_time / AV_TIME_BASE,
                 (double) ic->duration   / AV_TIME_BASE,
+                duration_method,
                 (int64_t)ic->bit_rate / 1000);
     }
 }