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.
27 #include "img_format.h"
40 static int put_image(vf_instance_t
*vf
, mp_image_t
*src
, double pts
)
42 struct vf_priv_s
*p
= vf
->priv
;
45 if (pts
== MP_NOPTS_VALUE
)
46 mp_msg(MSGT_VFILTER
, MSGL_INFO
, "PTS: undef\n");
48 mp_msg(MSGT_VFILTER
, MSGL_INFO
, "PTS: %f\n", pts
);
50 if (pts
!= MP_NOPTS_VALUE
&& p
->autostart
!= 0) {
54 } else if (pts
!= MP_NOPTS_VALUE
&& p
->autostep
> 0) {
55 p
->step
= pts
- p
->current
;
59 } else if (p
->have_step
) {
60 p
->current
+= p
->step
;
65 return vf_next_put_image(vf
, src
, pts
);
68 static void uninit(vf_instance_t
*vf
)
73 static int parse_args(struct vf_priv_s
*p
, const char *args
)
76 double num
, denom
= 1;
81 if (sscanf(args
, "print%n", &pos
) == 0 && pos
> 0) {
83 } else if (sscanf(args
, "fps=%lf%n/%lf%n", &num
, &pos
, &denom
, &pos
) >=
85 p
->step
= denom
/ num
;
87 } else if (sscanf(args
, "start=%lf%n", &num
, &pos
) >= 1 && pos
> 0) {
89 } else if (sscanf(args
, "autostart=%d%n", &iarg
, &pos
) == 1 && pos
> 0) {
91 } else if (sscanf(args
, "autofps=%d%n", &iarg
, &pos
) == 1 && pos
> 0) {
94 mp_msg(MSGT_VFILTER
, MSGL_FATAL
,
95 "fixpts: unknown suboption: %s\n", args
);
105 static int open(vf_instance_t
*vf
, char *args
)
108 struct vf_priv_s ptmp
= {
117 if (!parse_args(&ptmp
, args
== NULL
? "" : args
))
120 vf
->put_image
= put_image
;
122 vf
->priv
= p
= malloc(sizeof(struct vf_priv_s
));
124 p
->current
= -p
->step
;
129 vf_info_t vf_info_fixpts
= {
130 "Fix presentation timestamps",