[FFmpeg-devel] [PATCH] lavfi/setpts: enable debug logs, and improve/extend debug printing

Stefano Sabatini stefasab at gmail.com
Wed Dec 19 11:51:23 CET 2012


On date Tuesday 2012-12-18 23:06:42 +0100, Clément Bœsch encoded:
> On Tue, Dec 18, 2012 at 07:03:01PM +0100, Stefano Sabatini wrote:
> > ---
> >  libavfilter/f_setpts.c |   47 +++++++++++++++++++++++++++++++----------------
> >  1 file changed, 31 insertions(+), 16 deletions(-)
> > 
> > diff --git a/libavfilter/f_setpts.c b/libavfilter/f_setpts.c
> > index e5636e2..d7c6c8d 100644
> > --- a/libavfilter/f_setpts.c
> > +++ b/libavfilter/f_setpts.c
> > @@ -24,8 +24,6 @@
> >   * video presentation timestamp (PTS) modification filter
> >   */
> >  
> > -/* #define DEBUG */
> > -
> >  #include "libavutil/eval.h"
> >  #include "libavutil/internal.h"
> >  #include "libavutil/mathematics.h"
> > @@ -123,6 +121,17 @@ static int config_input(AVFilterLink *inlink)
> >  #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
> >  #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
> >  
> > +#define BUF_SIZE 64
> > +
> > +static inline char *double2int64(char *buf, double v)
> > +{
> > +    if (isnan(v)) snprintf(buf, BUF_SIZE, "NAN");
> > +    else          snprintf(buf, BUF_SIZE, "%"PRId64, (int64_t)v);
> > +    return buf;
> > +}
> > +
> > +#define d2i(v) double2int64((char[BUF_SIZE]){0}, v)
> > +
> >  static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
> >  {
> >      SetPTSContext *setpts = inlink->dst->priv;
> > @@ -148,26 +157,32 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
> >      }
> >  
> >      d = av_expr_eval(setpts->expr, setpts->var_values, NULL);
> > +
> > +    av_log(inlink->dst, AV_LOG_DEBUG,
> > +           "N:%"PRId64" PTS:%s T:%f POS:%s",
> > +           (int64_t)setpts->var_values[VAR_N],
> > +           d2i(setpts->var_values[VAR_PTS]),
> > +           setpts->var_values[VAR_T],
> > +           d2i(setpts->var_values[VAR_POS]));
> > +    switch (inlink->type) {
> > +    case AVMEDIA_TYPE_VIDEO:
> > +        av_log(inlink->dst, AV_LOG_DEBUG, " INTERLACED:%d",
> > +               (int)setpts->var_values[VAR_INTERLACED]);
> > +        break;
> > +    case AVMEDIA_TYPE_AUDIO:
> > +        av_log(inlink->dst, AV_LOG_DEBUG, " NB_SAMPLES:%"PRId64" NB_CONSUMED_SAMPLES:%"PRId64,
> > +               (int64_t)setpts->var_values[VAR_NB_SAMPLES],
> > +               (int64_t)setpts->var_values[VAR_NB_CONSUMED_SAMPLES]);
> > +        break;
> > +    }
> > +    av_log(inlink->dst, AV_LOG_DEBUG, " -> PTS:%s T:%f\n", d2i(d), TS2T(d, inlink->time_base));
> > +
> >      frame->pts = D2TS(d);
> >  
> >      setpts->var_values[VAR_PREV_INPTS ] = TS2D(in_pts);
> >      setpts->var_values[VAR_PREV_INT   ] = TS2T(in_pts, inlink->time_base);
> >      setpts->var_values[VAR_PREV_OUTPTS] = TS2D(frame->pts);
> >      setpts->var_values[VAR_PREV_OUTT]   = TS2T(frame->pts, inlink->time_base);
> > -
> > -    av_dlog(inlink->dst,
> > -            "n:%"PRId64" interlaced:%d nb_samples:%d nb_consumed_samples:%d "
> > -            "pos:%"PRId64" pts:%"PRId64" t:%f -> pts:%"PRId64" t:%f\n",
> > -            (int64_t)setpts->var_values[VAR_N],
> > -            (int)setpts->var_values[VAR_INTERLACED],
> > -            (int)setpts->var_values[VAR_NB_SAMPLES],
> > -            (int)setpts->var_values[VAR_NB_CONSUMED_SAMPLES],
> > -            (int64_t)setpts->var_values[VAR_POS],
> > -            (int64_t)setpts->var_values[VAR_PREV_INPTS],
> > -            setpts->var_values[VAR_PREV_INT],
> > -            (int64_t)setpts->var_values[VAR_PREV_OUTPTS],
> > -            setpts->var_values[VAR_PREV_OUTT]);
> > -
> >      setpts->var_values[VAR_N] += 1.0;
> >      if (setpts->type == AVMEDIA_TYPE_AUDIO) {
> >          setpts->var_values[VAR_NB_CONSUMED_SAMPLES] += frame->audio->nb_samples;
> 
> LGTM

Thanks, pushed with a few cosmetical changes.
-- 
FFmpeg = Fiendish Fiendish Magnificient Portable Extended Genius


More information about the ffmpeg-devel mailing list