diff options
author | uau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-07-06 06:58:17 +0000 |
---|---|---|
committer | uau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-07-06 06:58:17 +0000 |
commit | e2727ec797e19fb6d4d2d3338ce17dce976e0b28 (patch) | |
tree | d66f39217166121fab9751c1b271eb0734f68999 /libmpcodecs/vf_tfields.c | |
parent | 11ade8f86d0d358e90737451983ed37075832e5e (diff) | |
download | mpv-e2727ec797e19fb6d4d2d3338ce17dce976e0b28.tar.bz2 mpv-e2727ec797e19fb6d4d2d3338ce17dce976e0b28.tar.xz |
Add a new video pts tracking mode, enabled by option -correct-pts.
This mode has the following differences:
- Video timing is correct for streams with B frames, at least with some
demuxers.
- Video filters can modify frame timestamps and insert new frames, and
removing frames is handled better than before.
- Some things are known to break, it's not usable as the default yet.
Things should work as before when the -correct-pts option is not used.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18922 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/vf_tfields.c')
-rw-r--r-- | libmpcodecs/vf_tfields.c | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/libmpcodecs/vf_tfields.c b/libmpcodecs/vf_tfields.c index 1b26fb89b9..b10b48ba10 100644 --- a/libmpcodecs/vf_tfields.c +++ b/libmpcodecs/vf_tfields.c @@ -15,6 +15,9 @@ struct vf_priv_s { int mode; int parity; + int buffered_i; + mp_image_t *buffered_mpi; + double buffered_pts; }; static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride) @@ -311,9 +314,27 @@ static void qpel_4tap_C(unsigned char *d, unsigned char *s, int w, int h, int ds static void (*qpel_li)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up); static void (*qpel_4tap)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up); +static int continue_buffered_image(struct vf_instance_s *); +extern int correct_pts; + static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) { - int i; + vf->priv->buffered_mpi = mpi; + vf->priv->buffered_pts = pts; + vf->priv->buffered_i = 0; + return continue_buffered_image(vf); +} + +static int continue_buffered_image(struct vf_instance_s *vf) +{ + int i=vf->priv->buffered_i; + double pts = vf->priv->buffered_pts; + mp_image_t *mpi = vf->priv->buffered_mpi; + + if (i == 0) + vf_queue_frame(vf, continue_buffered_image); + pts += i * .02; // XXX not right + int ret=0; mp_image_t *dmpi; void (*qpel)(unsigned char *, unsigned char *, int, int, int, int, int); @@ -344,7 +365,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) switch (vf->priv->mode) { case 0: - for (i=0; i<2; i++) { + for (; i<2; i++) { dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height/2); @@ -356,12 +377,15 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) dmpi->stride[1] = 2*mpi->stride[1]; dmpi->stride[2] = 2*mpi->stride[2]; } - ret |= vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); - if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); + ret |= vf_next_put_image(vf, dmpi, pts); + if (correct_pts) + break; + else + if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); } break; case 1: - for (i=0; i<2; i++) { + for (; i<2; i++) { dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height); @@ -383,14 +407,17 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) deint(dmpi->planes[2], dmpi->stride[2], mpi->planes[2], mpi->stride[2], mpi->chroma_width, mpi->chroma_height, (i^!tff)); } - ret |= vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); - if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); + ret |= vf_next_put_image(vf, dmpi, pts); + if (correct_pts) + break; + else + if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); } break; case 2: case 3: case 4: - for (i=0; i<2; i++) { + for (; i<2; i++) { dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height/2); @@ -406,11 +433,15 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) mpi->chroma_width, mpi->chroma_height/2, dmpi->stride[2], mpi->stride[2]*2, (i^!tff)); } - ret |= vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); - if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); + ret |= vf_next_put_image(vf, dmpi, pts); + if (correct_pts) + break; + else + if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); } break; } + vf->priv->buffered_i = 1; return ret; } |