2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2003-08-18 15:24:08 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/mp_msg.h"
|
|
|
|
#include "core/cpudetect.h"
|
2003-08-18 15:24:08 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/img_format.h"
|
|
|
|
#include "video/mp_image.h"
|
2003-08-18 15:24:08 +00:00
|
|
|
#include "vf.h"
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/memcpy_pic.h"
|
2003-08-18 15:24:08 +00:00
|
|
|
|
|
|
|
#include "pullup.h"
|
|
|
|
|
2004-06-10 05:06:34 +00:00
|
|
|
#undef MAX
|
|
|
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
|
|
|
|
2003-08-18 15:24:08 +00:00
|
|
|
struct vf_priv_s {
|
|
|
|
struct pullup_context *ctx;
|
|
|
|
int init;
|
|
|
|
int fakecount;
|
2003-12-11 16:07:14 +00:00
|
|
|
char *qbuf;
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
double lastpts;
|
2003-08-18 15:24:08 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static void init_pullup(struct vf_instance *vf, mp_image_t *mpi)
|
2003-08-18 15:24:08 +00:00
|
|
|
{
|
|
|
|
struct pullup_context *c = vf->priv->ctx;
|
|
|
|
|
|
|
|
if (mpi->flags & MP_IMGFLAG_PLANAR) {
|
|
|
|
c->format = PULLUP_FMT_Y;
|
2003-12-11 16:07:14 +00:00
|
|
|
c->nplanes = 4;
|
2003-08-18 15:24:08 +00:00
|
|
|
pullup_preinit_context(c);
|
|
|
|
c->bpp[0] = c->bpp[1] = c->bpp[2] = 8;
|
|
|
|
c->w[0] = mpi->w;
|
|
|
|
c->h[0] = mpi->h;
|
|
|
|
c->w[1] = c->w[2] = mpi->chroma_width;
|
|
|
|
c->h[1] = c->h[2] = mpi->chroma_height;
|
2003-12-11 16:07:14 +00:00
|
|
|
c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16);
|
|
|
|
c->h[3] = 2;
|
2012-12-12 22:55:41 +00:00
|
|
|
c->stride[0] = mpi->w;
|
2003-08-18 15:24:08 +00:00
|
|
|
c->stride[1] = c->stride[2] = mpi->chroma_width;
|
2003-12-11 16:07:14 +00:00
|
|
|
c->stride[3] = c->w[3];
|
2003-08-18 15:24:08 +00:00
|
|
|
c->background[1] = c->background[2] = 128;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX;
|
|
|
|
if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2;
|
|
|
|
if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE;
|
|
|
|
if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2003-08-18 15:24:08 +00:00
|
|
|
pullup_init_context(c);
|
|
|
|
|
|
|
|
vf->priv->init = 1;
|
2003-12-11 16:07:14 +00:00
|
|
|
vf->priv->qbuf = malloc(c->w[3]);
|
2003-08-18 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
2003-08-18 15:24:08 +00:00
|
|
|
{
|
|
|
|
struct pullup_context *c = vf->priv->ctx;
|
|
|
|
struct pullup_buffer *b;
|
|
|
|
struct pullup_frame *f;
|
|
|
|
int p;
|
2003-12-11 16:07:14 +00:00
|
|
|
int i;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
double pts = mpi->pts;
|
|
|
|
struct mp_image *dmpi = NULL;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2003-08-18 15:24:08 +00:00
|
|
|
if (!vf->priv->init) init_pullup(vf, mpi);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
if (1) {
|
2003-08-18 15:24:08 +00:00
|
|
|
b = pullup_get_buffer(c, 2);
|
|
|
|
if (!b) {
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,"Could not get buffer from pullup!\n");
|
|
|
|
f = pullup_get_frame(c);
|
|
|
|
pullup_release_frame(f);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
goto skip;
|
2003-08-18 15:24:08 +00:00
|
|
|
}
|
|
|
|
memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h,
|
|
|
|
c->stride[0], mpi->stride[0]);
|
|
|
|
if (mpi->flags & MP_IMGFLAG_PLANAR) {
|
|
|
|
memcpy_pic(b->planes[1], mpi->planes[1],
|
|
|
|
mpi->chroma_width, mpi->chroma_height,
|
|
|
|
c->stride[1], mpi->stride[1]);
|
|
|
|
memcpy_pic(b->planes[2], mpi->planes[2],
|
|
|
|
mpi->chroma_width, mpi->chroma_height,
|
|
|
|
c->stride[2], mpi->stride[2]);
|
|
|
|
}
|
|
|
|
}
|
2003-12-11 16:07:14 +00:00
|
|
|
if (mpi->qscale) {
|
2012-11-09 00:31:49 +00:00
|
|
|
memcpy(b->planes[3], mpi->qscale, c->w[3]);
|
|
|
|
memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]);
|
2003-12-11 16:07:14 +00:00
|
|
|
}
|
2003-08-18 15:24:08 +00:00
|
|
|
|
|
|
|
p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 :
|
|
|
|
(mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0);
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
|
|
|
|
if (pts == MP_NOPTS_VALUE) {
|
|
|
|
pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
|
|
|
|
pullup_submit_field(c, b, p^1, MP_NOPTS_VALUE);
|
|
|
|
if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST)
|
|
|
|
pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
|
|
|
|
} else {
|
|
|
|
double delta;
|
|
|
|
if (vf->priv->lastpts == MP_NOPTS_VALUE)
|
|
|
|
delta = 1001.0/60000.0; // delta = field time distance
|
|
|
|
else
|
|
|
|
delta = (pts - vf->priv->lastpts) / 2;
|
2011-06-01 06:42:24 +00:00
|
|
|
if (delta <= 0.0 || delta >= 0.5)
|
|
|
|
delta = 0.0;
|
|
|
|
vf->priv->lastpts = pts;
|
|
|
|
if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) {
|
|
|
|
pullup_submit_field(c, b, p, pts - delta);
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
pullup_submit_field(c, b, p^1, pts);
|
2011-06-01 06:42:24 +00:00
|
|
|
pullup_submit_field(c, b, p, pts + delta);
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
} else {
|
2011-06-01 06:42:24 +00:00
|
|
|
pullup_submit_field(c, b, p, pts - delta * 0.5);
|
|
|
|
pullup_submit_field(c, b, p^1, pts + delta * 0.5);
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-18 15:24:08 +00:00
|
|
|
|
|
|
|
pullup_release_buffer(b, 2);
|
|
|
|
|
|
|
|
f = pullup_get_frame(c);
|
|
|
|
|
|
|
|
/* Fake yes for first few frames (buffer depth) to keep from
|
|
|
|
* breaking A/V sync with G1's bad architecture... */
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
//if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0;
|
|
|
|
if (!f)
|
|
|
|
goto skip;
|
2003-08-18 15:24:08 +00:00
|
|
|
|
|
|
|
if (f->length < 2) {
|
|
|
|
pullup_release_frame(f);
|
|
|
|
f = pullup_get_frame(c);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
if (!f) goto skip;
|
2003-08-18 15:24:08 +00:00
|
|
|
if (f->length < 2) {
|
|
|
|
pullup_release_frame(f);
|
2005-03-17 00:43:55 +00:00
|
|
|
if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST))
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
goto skip;
|
2005-03-17 00:43:55 +00:00
|
|
|
f = pullup_get_frame(c);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
if (!f) goto skip;
|
2005-03-17 00:43:55 +00:00
|
|
|
if (f->length < 2) {
|
|
|
|
pullup_release_frame(f);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
goto skip;
|
2005-03-17 00:43:55 +00:00
|
|
|
}
|
2003-08-18 15:24:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-10 05:06:34 +00:00
|
|
|
#if 0
|
2003-12-11 16:07:14 +00:00
|
|
|
/* Average qscale tables from both frames. */
|
|
|
|
if (mpi->qscale) {
|
|
|
|
for (i=0; i<c->w[3]; i++) {
|
|
|
|
vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i]
|
|
|
|
+ f->ofields[1]->planes[3][i+c->w[3]])>>1;
|
|
|
|
}
|
|
|
|
}
|
2004-06-10 05:06:34 +00:00
|
|
|
#else
|
|
|
|
/* Take worst of qscale tables from both frames. */
|
|
|
|
if (mpi->qscale) {
|
|
|
|
for (i=0; i<c->w[3]; i++) {
|
|
|
|
vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-12-11 16:07:14 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
/* If the frame isn't already exportable... */
|
|
|
|
if (!f->buffer)
|
|
|
|
pullup_pack_frame(c, f);
|
|
|
|
|
|
|
|
// NOTE: the copy could probably be avoided by changing or using the
|
|
|
|
// pullup internal buffer management. But right now just do the
|
|
|
|
// safe thing and always copy. Code outside the filter might
|
|
|
|
// hold a buffer reference even if the filter chain is destroyed.
|
|
|
|
dmpi = vf_alloc_out_image(vf);
|
|
|
|
mp_image_copy_attributes(dmpi, mpi);
|
|
|
|
|
|
|
|
struct mp_image data = *dmpi;
|
2003-08-18 15:24:08 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
data.planes[0] = f->buffer->planes[0];
|
|
|
|
data.planes[1] = f->buffer->planes[1];
|
|
|
|
data.planes[2] = f->buffer->planes[2];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
data.stride[0] = c->stride[0];
|
|
|
|
data.stride[1] = c->stride[1];
|
|
|
|
data.stride[2] = c->stride[2];
|
2009-07-06 23:26:13 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
mp_image_copy(dmpi, &data);
|
|
|
|
|
|
|
|
dmpi->pts = f->pts;
|
|
|
|
|
|
|
|
// Warning: entirely bogus memory management of qscale
|
2003-12-11 16:07:14 +00:00
|
|
|
if (mpi->qscale) {
|
|
|
|
dmpi->qscale = vf->priv->qbuf;
|
|
|
|
dmpi->qstride = mpi->qstride;
|
|
|
|
dmpi->qscale_type = mpi->qscale_type;
|
|
|
|
}
|
2003-08-18 15:24:08 +00:00
|
|
|
pullup_release_frame(f);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
|
|
|
|
skip:
|
|
|
|
talloc_free(mpi);
|
|
|
|
return dmpi;
|
2003-08-18 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
2003-08-18 15:24:08 +00:00
|
|
|
{
|
|
|
|
/* FIXME - support more formats */
|
|
|
|
switch (fmt) {
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
return vf_next_query_format(vf, fmt);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int config(struct vf_instance *vf,
|
2003-08-18 15:24:08 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
|
|
|
{
|
|
|
|
if (height&3) return 0;
|
|
|
|
return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
|
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static void uninit(struct vf_instance *vf)
|
2003-08-18 15:24:08 +00:00
|
|
|
{
|
|
|
|
pullup_free_context(vf->priv->ctx);
|
|
|
|
free(vf->priv);
|
|
|
|
}
|
|
|
|
|
2010-02-21 13:40:49 +00:00
|
|
|
static int vf_open(vf_instance_t *vf, char *args)
|
2003-08-18 15:24:08 +00:00
|
|
|
{
|
|
|
|
struct vf_priv_s *p;
|
2004-06-10 05:20:50 +00:00
|
|
|
struct pullup_context *c;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
vf->filter = filter;
|
2003-08-18 15:24:08 +00:00
|
|
|
vf->config = config;
|
|
|
|
vf->query_format = query_format;
|
|
|
|
vf->uninit = uninit;
|
|
|
|
vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
|
2004-06-10 05:20:50 +00:00
|
|
|
p->ctx = c = pullup_alloc_context();
|
2005-03-20 20:37:44 +00:00
|
|
|
p->fakecount = 1;
|
2005-04-01 16:24:46 +00:00
|
|
|
c->verbose = verbose>0;
|
2004-06-10 05:20:50 +00:00
|
|
|
c->junk_left = c->junk_right = 1;
|
|
|
|
c->junk_top = c->junk_bottom = 4;
|
|
|
|
c->strict_breaks = 0;
|
2004-09-06 21:25:59 +00:00
|
|
|
c->metric_plane = 0;
|
2004-06-10 05:20:50 +00:00
|
|
|
if (args) {
|
2004-09-06 21:25:59 +00:00
|
|
|
sscanf(args, "%d:%d:%d:%d:%d:%d", &c->junk_left, &c->junk_right, &c->junk_top, &c->junk_bottom, &c->strict_breaks, &c->metric_plane);
|
2004-06-10 05:20:50 +00:00
|
|
|
}
|
2003-08-18 15:24:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-02-13 19:21:39 +00:00
|
|
|
const vf_info_t vf_info_pullup = {
|
2003-08-18 15:24:08 +00:00
|
|
|
"pullup (from field sequence to frames)",
|
|
|
|
"pullup",
|
|
|
|
"Rich Felker",
|
|
|
|
"",
|
2010-02-21 13:40:49 +00:00
|
|
|
vf_open,
|
2003-08-18 15:24:08 +00:00
|
|
|
NULL
|
|
|
|
};
|