~ubuntu-branches/ubuntu/utopic/libav/utopic

« back to all changes in this revision

Viewing changes to libavfilter/vf_setpts.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-12-21 15:32:13 UTC
  • mto: (1.2.18)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20121221153213-fudzrugjzivtv0wp
Tags: upstream-9~beta3
ImportĀ upstreamĀ versionĀ 9~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
#define D2TS(d)  (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
103
103
#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
104
104
 
105
 
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
 
105
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
106
106
{
107
107
    SetPTSContext *setpts = inlink->dst->priv;
 
108
    int64_t in_pts = frame->pts;
108
109
    double d;
109
 
    AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
110
 
 
111
 
    if (!outpicref)
112
 
        return AVERROR(ENOMEM);
113
110
 
114
111
    if (isnan(setpts->var_values[VAR_STARTPTS]))
115
 
        setpts->var_values[VAR_STARTPTS] = TS2D(inpicref->pts);
 
112
        setpts->var_values[VAR_STARTPTS] = TS2D(frame->pts);
116
113
 
117
 
    setpts->var_values[VAR_INTERLACED] = inpicref->video->interlaced;
118
 
    setpts->var_values[VAR_PTS       ] = TS2D(inpicref->pts);
119
 
    setpts->var_values[VAR_POS       ] = inpicref->pos == -1 ? NAN : inpicref->pos;
 
114
    setpts->var_values[VAR_INTERLACED] = frame->video->interlaced;
 
115
    setpts->var_values[VAR_PTS       ] = TS2D(frame->pts);
 
116
    setpts->var_values[VAR_POS       ] = frame->pos == -1 ? NAN : frame->pos;
120
117
 
121
118
    d = av_expr_eval(setpts->expr, setpts->var_values, NULL);
122
 
    outpicref->pts = D2TS(d);
 
119
    frame->pts = D2TS(d);
123
120
 
124
121
#ifdef DEBUG
125
122
    av_log(inlink->dst, AV_LOG_DEBUG,
126
123
           "n:%"PRId64" interlaced:%d pos:%"PRId64" pts:%"PRId64" t:%f -> pts:%"PRId64" t:%f\n",
127
124
           (int64_t)setpts->var_values[VAR_N],
128
125
           (int)setpts->var_values[VAR_INTERLACED],
129
 
           inpicref ->pos,
130
 
           inpicref ->pts, inpicref ->pts * av_q2d(inlink->time_base),
131
 
           outpicref->pts, outpicref->pts * av_q2d(inlink->time_base));
 
126
           frame->pos, in_pts, in_pts * av_q2d(inlink->time_base),
 
127
           frame->pts, frame->pts * av_q2d(inlink->time_base));
132
128
#endif
133
129
 
 
130
 
134
131
    setpts->var_values[VAR_N] += 1.0;
135
 
    setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts);
136
 
    setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts);
137
 
    return ff_start_frame(inlink->dst->outputs[0], outpicref);
 
132
    setpts->var_values[VAR_PREV_INPTS ] = TS2D(in_pts);
 
133
    setpts->var_values[VAR_PREV_OUTPTS] = TS2D(frame->pts);
 
134
    return ff_filter_frame(inlink->dst->outputs[0], frame);
138
135
}
139
136
 
140
137
static av_cold void uninit(AVFilterContext *ctx)
150
147
        .type             = AVMEDIA_TYPE_VIDEO,
151
148
        .get_video_buffer = ff_null_get_video_buffer,
152
149
        .config_props     = config_input,
153
 
        .start_frame      = start_frame,
 
150
        .filter_frame     = filter_frame,
154
151
    },
155
152
    { NULL }
156
153
};