2006-10-01 17:09:04 +00:00
|
|
|
/*
|
2008-05-13 10:16:20 +00:00
|
|
|
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2006-10-01 17:09:04 +00:00
|
|
|
|
2006-07-07 18:26:51 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2007-09-18 09:30:42 +00:00
|
|
|
#include <inttypes.h>
|
2006-07-07 18:26:51 +00:00
|
|
|
#include <assert.h>
|
2012-05-25 20:31:10 +00:00
|
|
|
#include <libavutil/common.h>
|
2006-07-07 18:26:51 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/mp_msg.h"
|
|
|
|
#include "core/options.h"
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/img_format.h"
|
|
|
|
#include "video/mp_image.h"
|
2006-07-07 18:26:51 +00:00
|
|
|
#include "vf.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/sub.h"
|
2012-10-04 15:16:40 +00:00
|
|
|
#include "sub/dec_sub.h"
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/memcpy_pic.h"
|
|
|
|
#include "video/csputils.h"
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/m_option.h"
|
|
|
|
#include "core/m_struct.h"
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2007-11-09 06:58:32 +00:00
|
|
|
static const struct vf_priv_s {
|
2012-12-12 22:35:01 +00:00
|
|
|
int opt_top_margin, opt_bottom_margin;
|
2010-10-30 19:15:15 +00:00
|
|
|
int outh, outw;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2010-10-30 19:15:15 +00:00
|
|
|
unsigned int outfmt;
|
2012-10-19 17:11:08 +00:00
|
|
|
struct mp_csp_details csp;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2011-01-12 13:15:02 +00:00
|
|
|
struct osd_state *osd;
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
struct mp_osd_res dim;
|
2012-10-19 17:11:08 +00:00
|
|
|
} vf_priv_dflt = {
|
|
|
|
.csp = MP_CSP_DETAILS_DEFAULTS,
|
|
|
|
};
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int config(struct vf_instance *vf,
|
2010-10-30 19:15:15 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
2010-10-30 19:15:15 +00:00
|
|
|
struct MPOpts *opts = vf->opts;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2012-12-12 22:35:01 +00:00
|
|
|
vf->priv->outh = height + vf->priv->opt_top_margin +
|
|
|
|
vf->priv->opt_bottom_margin;
|
2010-10-30 19:15:15 +00:00
|
|
|
vf->priv->outw = width;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2012-11-08 01:57:42 +00:00
|
|
|
double dar = (double)d_width / d_height;
|
|
|
|
double sar = (double)width / height;
|
|
|
|
|
2010-10-30 19:15:15 +00:00
|
|
|
if (!opts->screen_size_x && !opts->screen_size_y) {
|
|
|
|
d_width = d_width * vf->priv->outw / width;
|
|
|
|
d_height = d_height * vf->priv->outh / height;
|
|
|
|
}
|
2006-07-07 18:26:51 +00:00
|
|
|
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
vf->priv->dim = (struct mp_osd_res) {
|
2012-10-18 15:31:00 +00:00
|
|
|
.w = vf->priv->outw,
|
|
|
|
.h = vf->priv->outh,
|
2012-12-12 22:35:01 +00:00
|
|
|
.mt = vf->priv->opt_top_margin,
|
|
|
|
.mb = vf->priv->opt_bottom_margin,
|
2012-10-18 15:31:00 +00:00
|
|
|
.display_par = sar / dar,
|
|
|
|
.video_par = dar / sar,
|
|
|
|
};
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2010-10-30 19:15:15 +00:00
|
|
|
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
|
|
|
|
d_height, flags, outfmt);
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void blank(mp_image_t *mpi, int y1, int y2)
|
|
|
|
{
|
2010-10-30 19:15:15 +00:00
|
|
|
int color[3] = {16, 128, 128}; // black (YUV)
|
|
|
|
int y;
|
|
|
|
unsigned char *dst;
|
|
|
|
int chroma_rows = (y2 - y1) >> mpi->chroma_y_shift;
|
|
|
|
|
|
|
|
dst = mpi->planes[0] + y1 * mpi->stride[0];
|
|
|
|
for (y = 0; y < y2 - y1; ++y) {
|
|
|
|
memset(dst, color[0], mpi->w);
|
|
|
|
dst += mpi->stride[0];
|
|
|
|
}
|
|
|
|
dst = mpi->planes[1] + (y1 >> mpi->chroma_y_shift) * mpi->stride[1];
|
|
|
|
for (y = 0; y < chroma_rows; ++y) {
|
|
|
|
memset(dst, color[1], mpi->chroma_width);
|
|
|
|
dst += mpi->stride[1];
|
|
|
|
}
|
|
|
|
dst = mpi->planes[2] + (y1 >> mpi->chroma_y_shift) * mpi->stride[2];
|
|
|
|
for (y = 0; y < chroma_rows; ++y) {
|
|
|
|
memset(dst, color[2], mpi->chroma_width);
|
|
|
|
dst += mpi->stride[2];
|
|
|
|
}
|
2006-07-07 18:26:51 +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 void prepare_image(struct vf_instance *vf, struct mp_image *dmpi,
|
|
|
|
struct mp_image *mpi)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
2012-12-12 22:35:01 +00:00
|
|
|
int tmargin = vf->priv->opt_top_margin;
|
2010-10-30 19:15:15 +00:00
|
|
|
// copy mpi->dmpi...
|
|
|
|
if (mpi->flags & MP_IMGFLAG_PLANAR) {
|
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
|
|
|
memcpy_pic(dmpi->planes[0] + tmargin * dmpi->stride[0],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->planes[0],
|
|
|
|
mpi->w,
|
|
|
|
mpi->h,
|
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
|
|
|
dmpi->stride[0],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->stride[0]);
|
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
|
|
|
memcpy_pic(dmpi->planes[1] + (tmargin >> mpi->chroma_y_shift) * dmpi->stride[1],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->planes[1],
|
|
|
|
mpi->w >> mpi->chroma_x_shift,
|
|
|
|
mpi->h >> mpi->chroma_y_shift,
|
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
|
|
|
dmpi->stride[1],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->stride[1]);
|
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
|
|
|
memcpy_pic(dmpi->planes[2] + (tmargin >> mpi->chroma_y_shift) * dmpi->stride[2],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->planes[2],
|
|
|
|
mpi->w >> mpi->chroma_x_shift,
|
|
|
|
mpi->h >> mpi->chroma_y_shift,
|
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
|
|
|
dmpi->stride[2],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->stride[2]);
|
|
|
|
} else {
|
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
|
|
|
memcpy_pic(dmpi->planes[0] + tmargin * dmpi->stride[0],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->planes[0],
|
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
|
|
|
mpi->w * (dmpi->bpp / 8),
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->h,
|
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
|
|
|
dmpi->stride[0],
|
2010-10-30 19:15:15 +00:00
|
|
|
mpi->stride[0]);
|
|
|
|
}
|
2011-09-03 10:47:56 +00:00
|
|
|
if (tmargin)
|
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
|
|
|
blank(dmpi, 0, tmargin);
|
2012-12-12 22:35:01 +00:00
|
|
|
if (vf->priv->opt_bottom_margin)
|
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
|
|
|
blank(dmpi, vf->priv->outh - vf->priv->opt_bottom_margin,
|
2011-09-03 10:47:56 +00:00
|
|
|
vf->priv->outh);
|
2006-07-07 18:26:51 +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)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
2012-08-25 18:22:39 +00:00
|
|
|
struct vf_priv_s *priv = vf->priv;
|
|
|
|
struct osd_state *osd = priv->osd;
|
2012-10-19 17:11: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
|
|
|
if (vf->priv->opt_top_margin || vf->priv->opt_bottom_margin ||
|
|
|
|
!mp_image_is_writeable(mpi))
|
|
|
|
{
|
|
|
|
struct mp_image *dmpi = vf_alloc_out_image(vf);
|
|
|
|
mp_image_copy_attributes(dmpi, mpi);
|
|
|
|
prepare_image(vf, dmpi, mpi);
|
|
|
|
talloc_free(mpi);
|
|
|
|
mpi = dmpi;
|
|
|
|
}
|
|
|
|
|
2012-10-27 16:06:09 +00:00
|
|
|
mp_image_set_colorspace_details(mpi, &priv->csp);
|
2012-10-19 17:11: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
|
|
|
if (mpi->pts != MP_NOPTS_VALUE)
|
|
|
|
osd_draw_on_image(osd, priv->dim, mpi->pts, OSD_DRAW_SUB_FILTER, 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
|
|
|
return mpi;
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
2010-10-30 19:15:15 +00:00
|
|
|
switch (fmt) {
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
case IMGFMT_420P:
|
2010-10-30 19:15:15 +00:00
|
|
|
return vf_next_query_format(vf, vf->priv->outfmt);
|
|
|
|
}
|
|
|
|
return 0;
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int control(vf_instance_t *vf, int request, void *data)
|
|
|
|
{
|
2010-10-30 19:15:15 +00:00
|
|
|
switch (request) {
|
2011-01-12 13:15:02 +00:00
|
|
|
case VFCTRL_SET_OSD_OBJ:
|
|
|
|
vf->priv->osd = data;
|
|
|
|
break;
|
2012-10-04 15:16:32 +00:00
|
|
|
case VFCTRL_INIT_OSD:
|
2012-08-25 14:47:50 +00:00
|
|
|
return CONTROL_TRUE;
|
2012-10-19 17:11:08 +00:00
|
|
|
case VFCTRL_SET_YUV_COLORSPACE: {
|
|
|
|
struct mp_csp_details colorspace = *(struct mp_csp_details *)data;
|
|
|
|
vf->priv->csp = colorspace;
|
|
|
|
break;
|
|
|
|
}
|
2010-10-30 19:15:15 +00:00
|
|
|
}
|
|
|
|
return vf_next_control(vf, request, data);
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static void uninit(struct vf_instance *vf)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
2010-10-30 19:15:15 +00:00
|
|
|
free(vf->priv);
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2010-10-30 19:15:15 +00:00
|
|
|
static const unsigned int fmt_list[] = {
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
IMGFMT_420P,
|
2010-10-30 19:15:15 +00:00
|
|
|
0
|
2006-07-07 18:26:51 +00:00
|
|
|
};
|
|
|
|
|
2010-02-21 13:40:49 +00:00
|
|
|
static int vf_open(vf_instance_t *vf, char *args)
|
2006-07-07 18:26:51 +00:00
|
|
|
{
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
vf->priv->outfmt = vf_match_csp(&vf->next, fmt_list, IMGFMT_420P);
|
2010-10-30 19:15:15 +00:00
|
|
|
if (!vf->priv->outfmt) {
|
|
|
|
uninit(vf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vf->config = config;
|
|
|
|
vf->query_format = query_format;
|
|
|
|
vf->uninit = uninit;
|
|
|
|
vf->control = control;
|
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;
|
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.
Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)
Remove all mentions of "eosd". It's simply "osd" now.
Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.
Fix the issue with margin borders in vo_corevideo.
2012-10-19 17:25:18 +00:00
|
|
|
vf->default_caps = VFCAP_OSD;
|
2010-10-30 19:15:15 +00:00
|
|
|
return 1;
|
2006-07-07 18:26:51 +00:00
|
|
|
}
|
|
|
|
|
2010-10-30 19:15:15 +00:00
|
|
|
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f)
|
2007-11-09 06:58:32 +00:00
|
|
|
static const m_option_t vf_opts_fields[] = {
|
2012-12-12 22:35:01 +00:00
|
|
|
{"bottom-margin", ST_OFF(opt_bottom_margin),
|
|
|
|
CONF_TYPE_INT, M_OPT_RANGE, 0, 2000},
|
|
|
|
{"top-margin", ST_OFF(opt_top_margin),
|
|
|
|
CONF_TYPE_INT, M_OPT_RANGE, 0, 2000},
|
2010-10-30 19:15:15 +00:00
|
|
|
{NULL, NULL, 0, 0, 0, 0, NULL}
|
2006-07-07 18:26:51 +00:00
|
|
|
};
|
|
|
|
|
2007-11-09 06:58:32 +00:00
|
|
|
static const m_struct_t vf_opts = {
|
2012-10-21 16:31:34 +00:00
|
|
|
"sub",
|
2010-10-30 19:15:15 +00:00
|
|
|
sizeof(struct vf_priv_s),
|
|
|
|
&vf_priv_dflt,
|
|
|
|
vf_opts_fields
|
2006-07-07 18:26:51 +00:00
|
|
|
};
|
|
|
|
|
2012-10-21 16:31:34 +00:00
|
|
|
const vf_info_t vf_info_sub = {
|
|
|
|
"Render subtitles",
|
|
|
|
"sub",
|
2010-10-30 19:15:15 +00:00
|
|
|
"Evgeniy Stepanov",
|
|
|
|
"",
|
|
|
|
vf_open,
|
|
|
|
&vf_opts
|
2006-07-07 18:26:51 +00:00
|
|
|
};
|