From c3f8c9a58e3028777466ce0d3f56374efb10f968 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 12 Dec 2012 23:35:01 +0100 Subject: options: move -ass-bottom-margin/-ass-top-margin options to vf_sub These options might be useful sometimes, but they are not that important, and work with vf_sub only. Make them vf_sub sub-options. --- DOCS/man/en/changes.rst | 1 + DOCS/man/en/options.rst | 8 -------- DOCS/man/en/vf.rst | 10 +++++++++- core/cfg-mplayer.h | 2 -- core/options.h | 2 -- video/filter/vf_sub.c | 25 +++++++++++++++---------- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index 82066cb75c..b82bef5167 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -113,6 +113,7 @@ Command line switches -subfont-text-scale --sub-scale -spugauss --sub-gauss -vobsub --sub (pass the .idx file) + -ass-bottom-margin --vf=sub=bottom:top =================================== =================================== input.conf and slave commands diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 0aa1098925..51ecab6166 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -118,10 +118,6 @@ text subtitles only, because ASS subtitles include their own styling information. ---ass-bottom-margin= - Adds a black band at the bottom of the frame. The SSA/ASS renderer can - place subtitles there (with ``--ass-use-margins``). - --ass-force-style=<[Style.]Param=Value[,...]> Override some style or script info parameters. @@ -156,10 +152,6 @@ (Default.) :no: Render subtitles as forced by subtitle scripts. ---ass-top-margin= - Adds a black band at the top of the frame. The SSA/ASS renderer can place - toptitles there (with ``--ass-use-margins``). - --ass-use-margins Enables placing toptitles and subtitles in black borders when they are available. diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst index 13d782c0f4..439701754a 100644 --- a/DOCS/man/en/vf.rst +++ b/DOCS/man/en/vf.rst @@ -661,11 +661,19 @@ screenshot screenshot_force Same as ``screenshot``, but prefer it over VO based screenshot code. -sub +sub=[=bottom-margin:top-margin] Moves subtitle rendering to an arbitrary point in the filter chain, or force subtitle rendering in the video filter as opposed to using video output OSD support. + + + Adds a black band at the bottom of the frame. The SSA/ASS renderer can + place subtitles there (with ``--ass-use-margins``). + + Black band on the top for toptitles (with ``--ass-use-margins``). + + *EXAMPLE*: ``--vf=sub,eq`` diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 762c13a2bb..65ebdbb595 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -512,8 +512,6 @@ const m_option_t common_opts[] = { OPT_MAKE_FLAGS("ass", ass_enabled, 0), OPT_FLOATRANGE("sub-scale", sub_scale, 0, 0, 100), OPT_FLOATRANGE("ass-line-spacing", ass_line_spacing, 0, -1000, 1000), - OPT_INTRANGE("ass-top-margin", ass_top_margin, 0, 0, 2000), - OPT_INTRANGE("ass-bottom-margin", ass_bottom_margin, 0, 0, 2000), OPT_MAKE_FLAGS("ass-use-margins", ass_use_margins, 0), OPT_MAKE_FLAGS("ass-vsfilter-aspect-compat", ass_vsfilter_aspect_compat, 0), OPT_MAKE_FLAGS("embeddedfonts", use_embedded_fonts, 0), diff --git a/core/options.h b/core/options.h index da4449cb11..a45c6d468f 100644 --- a/core/options.h +++ b/core/options.h @@ -119,8 +119,6 @@ typedef struct MPOpts { int sub_gray; int ass_enabled; float ass_line_spacing; - int ass_top_margin; - int ass_bottom_margin; int ass_use_margins; int ass_vsfilter_aspect_compat; int use_embedded_fonts; diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index 2dc1b9afd9..5b2a79a030 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -44,6 +44,7 @@ #include "core/m_struct.h" static const struct vf_priv_s { + int opt_top_margin, opt_bottom_margin; int outh, outw; unsigned int outfmt; @@ -63,7 +64,8 @@ static int config(struct vf_instance *vf, if (outfmt == IMGFMT_IF09) return 0; - vf->priv->outh = height + opts->ass_top_margin + opts->ass_bottom_margin; + vf->priv->outh = height + vf->priv->opt_top_margin + + vf->priv->opt_bottom_margin; vf->priv->outw = width; double dar = (double)d_width / d_height; @@ -77,8 +79,8 @@ static int config(struct vf_instance *vf, vf->priv->dim = (struct mp_osd_res) { .w = vf->priv->outw, .h = vf->priv->outh, - .mt = opts->ass_top_margin, - .mb = opts->ass_bottom_margin, + .mt = vf->priv->opt_top_margin, + .mb = vf->priv->opt_bottom_margin, .display_par = sar / dar, .video_par = dar / sar, }; @@ -108,7 +110,7 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi) return; } - int tmargin = vf->opts->ass_top_margin; + int tmargin = vf->priv->opt_top_margin; // set up mpi as a cropped-down image of dmpi: if (mpi->flags & MP_IMGFLAG_PLANAR) { mpi->planes[0] = vf->dmpi->planes[0] + tmargin * vf->dmpi->stride[0]; @@ -152,8 +154,7 @@ static void blank(mp_image_t *mpi, int y1, int y2) static int prepare_image(struct vf_instance *vf, mp_image_t *mpi) { - struct MPOpts *opts = vf->opts; - int tmargin = opts->ass_top_margin; + int tmargin = vf->priv->opt_top_margin; if (mpi->flags & MP_IMGFLAG_DIRECT || mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) { vf->dmpi = mpi->priv; @@ -165,8 +166,8 @@ static int prepare_image(struct vf_instance *vf, mp_image_t *mpi) // we've used DR, so we're ready... if (tmargin) blank(vf->dmpi, 0, tmargin); - if (opts->ass_bottom_margin) - blank(vf->dmpi, vf->priv->outh - opts->ass_bottom_margin, + if (vf->priv->opt_bottom_margin) + blank(vf->dmpi, vf->priv->outh - vf->priv->opt_bottom_margin, vf->priv->outh); if (!(mpi->flags & MP_IMGFLAG_PLANAR)) vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette @@ -209,8 +210,8 @@ static int prepare_image(struct vf_instance *vf, mp_image_t *mpi) } if (tmargin) blank(vf->dmpi, 0, tmargin); - if (opts->ass_bottom_margin) - blank(vf->dmpi, vf->priv->outh - opts->ass_bottom_margin, + if (vf->priv->opt_bottom_margin) + blank(vf->dmpi, vf->priv->outh - vf->priv->opt_bottom_margin, vf->priv->outh); return 0; } @@ -289,6 +290,10 @@ static int vf_open(vf_instance_t *vf, char *args) #define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f) static const m_option_t vf_opts_fields[] = { + {"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}, {NULL, NULL, 0, 0, 0, 0, NULL} }; -- cgit v1.2.3