[FFmpeg-devel] [PATCH 3/4] Add setpts filter by Victor Paesa.

Stefano Sabatini stefano.sabatini-lala
Tue Nov 2 22:33:51 CET 2010


On date Tuesday 2010-11-02 22:16:30 +0100, Michael Niedermayer encoded:
> On Tue, Nov 02, 2010 at 08:45:07PM +0100, Stefano Sabatini wrote:
> [...]
> > +/**
> > + * @file
> > + * video presentation timestamp (PTS) modification filter
> > + */
> > +
> 
> > +#define DEBUG
> 
> ?

Commented out, I'd like to keep it in case I need to debug, but I
don't want to spam the log everytime I enable -loglevel debug.

> > +
> > +#include "libavutil/eval.h"
> > +#include "avfilter.h"
> > +
> > +static const char *var_names[] = {
> > +    "E",           ///< Euler number
> > +    "INTERLACED",  ///< tell if the current frame is interlaced
> > +    "N",           ///< frame number (starting at zero)
> > +    "PHI",         ///< golden ratio
> > +    "PI",          ///< greek pi
> > +    "POS",         ///< original position in the file of the frame
> > +    "PREV_INPTS",  ///< previous  input PTS
> > +    "PREV_OUTPTS", ///< previous output PTS
> > +    "PTS",         ///< original pts in the file of the frame
> > +    "STARTPTS",   ///< PTS at start of movie
> > +    "TB",          ///< timebase
> > +    NULL
> > +};
> > +
> > +enum var_name {
> > +    VAR_E,
> > +    VAR_INTERLACED,
> > +    VAR_N,
> > +    VAR_PHI,
> > +    VAR_PI,
> > +    VAR_POS,
> > +    VAR_PREV_INPTS,
> > +    VAR_PREV_OUTPTS,
> > +    VAR_PTS,
> > +    VAR_STARTPTS,
> > +    VAR_TB,
> > +    VAR_VARS_NB
> > +};
> > +
> > +typedef struct {
> > +    AVExpr *expr;
> > +    double var_values[VAR_VARS_NB];
> > +} SetPTSContext;
> > +
> > +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> > +{
> > +    SetPTSContext *setpts = ctx->priv;
> > +    int ret;
> > +
> > +    if ((ret = av_parse_expr(&setpts->expr, args ? args : "PTS",
> > +                             var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
> > +        av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", args);
> > +        return ret;
> > +    }
> > +
> > +    setpts->var_values[VAR_E          ] = M_E;
> > +    setpts->var_values[VAR_N          ] = 0.0;
> > +    setpts->var_values[VAR_PHI        ] = M_PHI;
> > +    setpts->var_values[VAR_PI         ] = M_PI;
> > +    setpts->var_values[VAR_PREV_INPTS ] = NAN;
> > +    setpts->var_values[VAR_PREV_OUTPTS] = NAN;
> > +    setpts->var_values[VAR_STARTPTS   ] = NAN;
> > +    return 0;
> > +}
> > +
> 
> > +static int config_input(AVFilterLink *inlink)
> > +{
> > +    SetPTSContext *setpts = inlink->dst->priv;
> > +
> > +    setpts->var_values[VAR_TB]    = (double)inlink->time_base.num/inlink->time_base.den;
> 
> av_q2d
> 
> otherwise lgtm

Fixed and updated.
-- 
FFmpeg = Fiendish and Fascinating MultiPurpose Ecumenical God



More information about the ffmpeg-devel mailing list