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

Michael Niedermayer michaelni
Tue Nov 2 22:50:45 CET 2010


On Tue, Nov 02, 2010 at 05:37:42PM -0400, Alexander Strange wrote:
> 
> On Nov 2, 2010, at 5:33 PM, Stefano Sabatini wrote:
> 
> > 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.
> 
> Whatever does M_PHI have to do with pts?

we d like to support a consistengt set of constants accross expressions i guess
its also easier to document

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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/d2afeda8/attachment.pgp>



More information about the ffmpeg-devel mailing list