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

Michael Niedermayer michaelni
Tue Nov 2 22:16:30 CET 2010


On Tue, Nov 02, 2010 at 08:45:07PM +0100, Stefano Sabatini wrote:
[...]
> +/**
> + * @file
> + * video presentation timestamp (PTS) modification filter
> + */
> +

> +#define 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

[...]
--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101102/73c73eb6/attachment.pgp>



More information about the ffmpeg-devel mailing list