1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-18 13:14:36 +00:00

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
This commit is contained in:
iive 2006-04-08 15:30:09 +00:00
parent dc3f010d38
commit 69fe028f08

View File

@ -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;