2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "img_format.h"
41 static int put_image(vf_instance_t *vf, mp_image_t *src, double pts)
43 struct vf_priv_s *p = vf->priv;
46 if (pts == MP_NOPTS_VALUE)
47 mp_msg(MSGT_VFILTER, MSGL_INFO, "PTS: undef\n");
49 mp_msg(MSGT_VFILTER, MSGL_INFO, "PTS: %f\n", pts);
51 if (pts != MP_NOPTS_VALUE && p->autostart != 0) {
55 } else if (pts != MP_NOPTS_VALUE && p->autostep > 0) {
56 p->step = pts - p->current;
60 } else if (p->have_step) {
61 p->current += p->step;
66 return vf_next_put_image(vf, src, pts);
69 static void uninit(vf_instance_t *vf)
74 static int parse_args(struct vf_priv_s *p, const char *args)
77 double num, denom = 1;
82 if (sscanf(args, "print%n", &pos) == 0 && pos > 0) {
84 } else if (sscanf(args, "fps=%lf%n/%lf%n", &num, &pos, &denom, &pos) >=
86 p->step = denom / num;
88 } else if (sscanf(args, "start=%lf%n", &num, &pos) >= 1 && pos > 0) {
90 } else if (sscanf(args, "autostart=%d%n", &iarg, &pos) == 1 && pos > 0) {
92 } else if (sscanf(args, "autofps=%d%n", &iarg, &pos) == 1 && pos > 0) {
95 mp_msg(MSGT_VFILTER, MSGL_FATAL,
96 "fixpts: unknown suboption: %s\n", args);
106 static int open(vf_instance_t *vf, char *args)
109 struct vf_priv_s ptmp = {
118 if (!parse_args(&ptmp, args == NULL ? "" : args))
121 vf->put_image = put_image;
123 vf->priv = p = malloc(sizeof(struct vf_priv_s));
125 p->current = -p->step;
130 const vf_info_t vf_info_fixpts = {
131 "Fix presentation timestamps",