diff options
author | iive <iive@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-08 15:30:09 +0000 |
---|---|---|
committer | iive <iive@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-08 15:30:09 +0000 |
commit | 69fe028f08740fa675b4c8350ce3b00687ea7707 (patch) | |
tree | 583917709fbdfd0920d62dd6c713836cea5e4602 /libmpcodecs | |
parent | dc3f010d38d1e5bf6fbb3b10849e0740a086335d (diff) | |
download | mpv-69fe028f08740fa675b4c8350ce3b00687ea7707.tar.bz2 mpv-69fe028f08740fa675b4c8350ce3b00687ea7707.tar.xz |
New mode for tinterlace filter
patch by Walter Belhaven <wbelhaven at yahoo >
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18056 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/vf_tinterlace.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/libmpcodecs/vf_tinterlace.c b/libmpcodecs/vf_tinterlace.c index a02f10d0be..eb02872b0e 100644 --- a/libmpcodecs/vf_tinterlace.c +++ b/libmpcodecs/vf_tinterlace.c @@ -35,6 +35,22 @@ struct vf_priv_s { mp_image_t *dmpi; }; +// Copied verbatim from vf_telecine.c: +static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride) +{ + int i; + void *retval=dst; + + for(i=0; i<height; i++) + { + memcpy(dst, src, bytesPerLine); + src+= srcStride; + dst+= dstStride; + } + + return retval; +} + static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) { int ret = 0; @@ -116,6 +132,57 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) } ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); break; + case 4: + // Interleave even lines (only) from Frame 'i' with odd + // lines (only) from Frame 'i+1', halving the Frame + // rate and preserving image height. + + dmpi = vf->priv->dmpi; + + // @@ Need help: Should I set dmpi->fields to indicate + // that the (new) frame will be interlaced!? E.g. ... + // dmpi->fields |= MP_IMGFIELD_INTERLACED; + // dmpi->fields |= MP_IMGFIELD_TOP_FIRST; + // etc. + + if (dmpi == NULL) { + dmpi = vf_get_image(vf->next, mpi->imgfmt, + MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE | + MP_IMGFLAG_PRESERVE, + mpi->width, mpi->height); + + vf->priv->dmpi = dmpi; + + my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2, + dmpi->stride[0]*2, mpi->stride[0]*2); + if (mpi->flags & MP_IMGFLAG_PLANAR) { + my_memcpy_pic(dmpi->planes[1], mpi->planes[1], + mpi->chroma_width, mpi->chroma_height/2, + dmpi->stride[1]*2, mpi->stride[1]*2); + my_memcpy_pic(dmpi->planes[2], mpi->planes[2], + mpi->chroma_width, mpi->chroma_height/2, + dmpi->stride[2]*2, mpi->stride[2]*2); + } + } else { + vf->priv->dmpi = NULL; + + my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0], + mpi->planes[0]+mpi->stride[0], + mpi->w, mpi->h/2, + dmpi->stride[0]*2, mpi->stride[0]*2); + if (mpi->flags & MP_IMGFLAG_PLANAR) { + my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1], + mpi->planes[1]+mpi->stride[1], + mpi->chroma_width, mpi->chroma_height/2, + dmpi->stride[1]*2, mpi->stride[1]*2); + my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2], + mpi->planes[2]+mpi->stride[2], + 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); + } + break; } vf->priv->frame++; @@ -145,6 +212,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt); case 1: /* odd frames */ case 2: /* even frames */ + case 4: /* alternate frame (height-preserving) interlacing */ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } return 0; |