summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vf_softpulldown.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/vf_softpulldown.c')
-rw-r--r--libmpcodecs/vf_softpulldown.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/libmpcodecs/vf_softpulldown.c b/libmpcodecs/vf_softpulldown.c
index ab45c698ce..5bd5e66bfd 100644
--- a/libmpcodecs/vf_softpulldown.c
+++ b/libmpcodecs/vf_softpulldown.c
@@ -33,8 +33,22 @@ struct vf_priv_s {
int state;
long long in;
long long out;
+ struct vf_detc_pts_buf ptsbuf;
+ int last_frame_duration;
+ double buffered_pts;
+ mp_image_t *buffered_mpi;
+ int buffered_last_frame_duration;
};
+static int continue_buffered_image(struct vf_instance *vf)
+{
+ double pts = vf->priv->buffered_pts;
+ mp_image_t *mpi = vf->priv->buffered_mpi;
+ vf->priv->out++;
+ vf->priv->state=0;
+ return vf_next_put_image(vf, mpi, vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, pts, 0, 0, vf->priv->buffered_last_frame_duration));
+}
+
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
@@ -61,7 +75,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
}
if (state == 0) {
- ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
+ ret = vf_next_put_image(vf, mpi, vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, pts, 0, 0, vf->priv->last_frame_duration));
vf->priv->out++;
if (flags & MP_IMGFIELD_REPEAT_FIRST) {
my_memcpy_pic(dmpi->planes[0],
@@ -97,12 +111,13 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
mpi->chroma_width, mpi->chroma_height/2,
dmpi->stride[2]*2, mpi->stride[2]*2);
}
- ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
+ ret = vf_next_put_image(vf, dmpi, vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, pts, 0, 0, vf->priv->last_frame_duration));
vf->priv->out++;
if (flags & MP_IMGFIELD_REPEAT_FIRST) {
- ret |= vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
- vf->priv->out++;
- state=0;
+ vf->priv->buffered_mpi = mpi;
+ vf->priv->buffered_pts = pts;
+ vf->priv->buffered_last_frame_duration = vf->priv->last_frame_duration;
+ vf_queue_frame(vf, continue_buffered_image);
} else {
my_memcpy_pic(dmpi->planes[0],
mpi->planes[0], mpi->w, mpi->h/2,
@@ -125,6 +140,10 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
}
vf->priv->state = state;
+ if (flags & MP_IMGFIELD_REPEAT_FIRST)
+ vf->priv->last_frame_duration = 3;
+ else
+ vf->priv->last_frame_duration = 2;
return ret;
}
@@ -151,6 +170,8 @@ static int vf_open(vf_instance_t *vf, char *args)
vf->default_reqs = VFCAP_ACCEPT_STRIDE;
vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
vf->priv->state = 0;
+ vf->priv->last_frame_duration = 2;
+ vf_detc_init_pts_buf(&vf->priv->ptsbuf);
return 1;
}