diff options
-rw-r--r-- | Copyright | 12 | ||||
-rw-r--r-- | DOCS/man/vf.rst | 304 | ||||
-rw-r--r-- | video/filter/vf.c | 24 | ||||
-rw-r--r-- | video/filter/vf_crop.c | 133 | ||||
-rw-r--r-- | video/filter/vf_dsize.c | 118 | ||||
-rw-r--r-- | video/filter/vf_expand.c | 178 | ||||
-rw-r--r-- | video/filter/vf_flip.c | 60 | ||||
-rw-r--r-- | video/filter/vf_gradfun.c | 108 | ||||
-rw-r--r-- | video/filter/vf_mirror.c | 38 | ||||
-rw-r--r-- | video/filter/vf_noformat.c | 72 | ||||
-rw-r--r-- | video/filter/vf_pullup.c | 83 | ||||
-rw-r--r-- | video/filter/vf_rotate.c | 106 | ||||
-rw-r--r-- | video/filter/vf_scale.c | 258 | ||||
-rw-r--r-- | video/filter/vf_stereo3d.c | 225 | ||||
-rw-r--r-- | video/filter/vf_yadif.c | 97 | ||||
-rw-r--r-- | wscript_build.py | 14 |
16 files changed, 1 insertions, 1829 deletions
@@ -71,20 +71,8 @@ The following files are still GPL only (--enable-lgpl disables them): stream/stream_smb.c will stay GPLv3 stream/stream_tv.c will stay GPL stream/tv* will stay GPL - video/filter/vf_crop.c will be deleted - video/filter/vf_dsize.c will be deleted - video/filter/vf_expand.c will be deleted - video/filter/vf_flip.c will be deleted video/filter/vf_format.c will be deleted - video/filter/vf_gradfun.c will be deleted - video/filter/vf_mirror.c will be deleted - video/filter/vf_noformat.c will be deleted - video/filter/vf_pullup.c will be deleted - video/filter/vf_rotate.c will be deleted - video/filter/vf_scale.c will be deleted - video/filter/vf_stereo3d.c will be deleted video/filter/vf_sub.c will be deleted - video/filter/vf_yadif.c will be deleted video/out/opengl/hwdec_vaglx.c GPL video/out/vo_caca.c unknown video/out/vo_direct3d.c unknown diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index 617ceeea04..7f53e4ef17 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -100,159 +100,6 @@ With filters that support it, you can access parameters by their name. Available mpv-only filters are: -``crop[=w:h:x:y]`` - Crops the given part of the image and discards the rest. Useful to remove - black bands from widescreen videos. - - ``<w>,<h>`` - Cropped width and height, defaults to original width and height. - ``<x>,<y>`` - Position of the cropped picture, defaults to center. - -``expand[=w:h:x:y:aspect:round]`` - Expands (not scales) video resolution to the given value and places the - unscaled original at coordinates x, y. - - ``<w>,<h>`` - Expanded width,height (default: original width,height). Negative - values for w and h are treated as offsets to the original size. - - .. admonition:: Example - - ``expand=0:-50:0:0`` - Adds a 50 pixel border to the bottom of the picture. - - ``<x>,<y>`` - position of original image on the expanded image (default: center) - - ``<aspect>`` - Expands to fit an aspect instead of a resolution (default: 0). - - .. admonition:: Example - - ``expand=800::::4/3`` - Expands to 800x600, unless the source is higher resolution, in - which case it expands to fill a 4/3 aspect. - - ``<round>`` - Rounds up to make both width and height divisible by <r> (default: 1). - -``flip`` - Flips the image upside down. - -``mirror`` - Mirrors the image on the Y axis. - -``rotate[=0|90|180|270]`` - Rotates the image by a multiple of 90 degrees clock-wise. - -``scale[=w:h:param:param2:chr-drop:noup:arnd`` - Scales the image with the software scaler (slow) and performs a YUV<->RGB - color space conversion (see also ``--sws``). - - All parameters are optional. - - ``<w>:<h>`` - scaled width/height (default: original width/height) - - :0: scaled d_width/d_height - :-1: original width/height - :-2: Calculate w/h using the other dimension and the prescaled - aspect ratio. - :-3: Calculate w/h using the other dimension and the original - aspect ratio. - :-(n+8): Like -n above, but rounding the dimension to the closest - multiple of 16. - - ``<param>[:<param2>]`` (see also ``--sws``) - Set some scaling parameters depending on the type of scaler selected - with ``--sws``:: - - --sws=2 (bicubic): B (blurring) and C (ringing) - 0.00:0.60 default - 0.00:0.75 VirtualDub's "precise bicubic" - 0.00:0.50 Catmull-Rom spline - 0.33:0.33 Mitchell-Netravali spline - 1.00:0.00 cubic B-spline - - --sws=7 (Gaussian): sharpness (0 (soft) - 100 (sharp)) - - --sws=9 (Lanczos): filter length (1-10) - - ``<chr-drop>`` - chroma skipping - - :0: Use all available input lines for chroma (default). - :1: Use only every 2. input line for chroma. - :2: Use only every 4. input line for chroma. - :3: Use only every 8. input line for chroma. - - ``<noup>`` - Disallow upscaling past the original dimensions. - - :0: Allow upscaling (default). - :1: Disallow upscaling if one dimension exceeds its original value. - :2: Disallow upscaling if both dimensions exceed their original values. - - ``<arnd>`` - Accurate rounding for the vertical scaler, which may be faster or - slower than the default rounding. - - :no: Disable accurate rounding (default). - :yes: Enable accurate rounding. - -``dsize[=w:h:aspect-method:r:aspect]`` - Changes the intended display aspect at an arbitrary point in the - filter chain. Aspect can be given as a fraction (4/3) or floating point - number (1.33). Note that this filter does *not* do any scaling itself; it - just affects what later scalers (software or hardware) will do when - auto-scaling to the correct aspect. - - ``<w>,<h>`` - New aspect ratio given by a display width and height. Unlike older mpv - versions or MPlayer, this does not set the display size. - - Can also be these special values: - - :0: original display width and height - :-1: original video width and height (default) - :-2: Calculate w/h using the other dimension and the original display - aspect ratio. - :-3: Calculate w/h using the other dimension and the original video - aspect ratio. - - .. admonition:: Example - - ``dsize=800:-2`` - Specifies a display resolution of 800x600 for a 4/3 aspect - video, or 800x450 for a 16/9 aspect video. - - ``<aspect-method>`` - Modifies width and height according to original aspect ratios. - - :-1: Ignore original aspect ratio (default). - :0: Keep display aspect ratio by using ``<w>`` and ``<h>`` as maximum - resolution. - :1: Keep display aspect ratio by using ``<w>`` and ``<h>`` as minimum - resolution. - :2: Keep video aspect ratio by using ``<w>`` and ``<h>`` as maximum - resolution. - :3: Keep video aspect ratio by using ``<w>`` and ``<h>`` as minimum - resolution. - - .. admonition:: Example - - ``dsize=800:600:0`` - Specifies a display resolution of at most 800x600, or smaller, - in order to keep aspect. - - ``<r>`` - Rounds up to make both width and height divisible by ``<r>`` - (default: 1). - - ``<aspect>`` - Force an aspect ratio. - ``format=fmt=<value>:colormatrix=<value>:...`` Restricts the color space for the next filter without doing any conversion. Use together with the scale filter for a real conversion. @@ -425,16 +272,6 @@ Available mpv-only filters are: ``<spherical-yaw>``, ``<spherical-pitch>``, ``<spherical-roll>`` Reference angle in degree, if spherical video is used. -``noformat[=fmt]`` - Restricts the color space for the next filter without doing any conversion. - Unlike the format filter, this will allow any color space except the one - you specify. - - .. note:: For a list of available formats, see ``noformat=fmt=help``. - - ``<fmt>`` - Format name, e.g. rgb15, bgr24, 420p, etc. (default: 420p). - ``lavfi=graph[:sws-flags[:o=opts]]`` Filter video using FFmpeg's libavfilter. @@ -484,62 +321,6 @@ Available mpv-only filters are: ``'--vf=lavfi=yadif:o="threads=2,thread_type=slice"'`` forces a specific threading configuration. -``pullup[=jl:jr:jt:jb:sb:mp]`` - Pulldown reversal (inverse telecine) filter, capable of handling mixed - hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive - content. The ``pullup`` filter makes use of future context in making its - decisions. It is stateless in the sense that it does not lock onto a pattern - to follow, but it instead looks forward to the following fields in order to - identify matches and rebuild progressive frames. - - ``jl``, ``jr``, ``jt``, and ``jb`` - These options set the amount of "junk" to ignore at the left, right, - top, and bottom of the image, respectively. Left/right are in units of - 8 pixels, while top/bottom are in units of 2 lines. The default is 8 - pixels on each side. - - ``sb`` (strict breaks) - Setting this option to 1 will reduce the chances of ``pullup`` - generating an occasional mismatched frame, but it may also cause an - excessive number of frames to be dropped during high motion sequences. - Conversely, setting it to -1 will make ``pullup`` match fields more - easily. This may help process video with slight blurring between the - fields, but may also cause interlaced frames in the output. - - ``mp`` (metric plane) - This option may be set to ``u`` or ``v`` to use a chroma plane instead of the - luma plane for doing ``pullup``'s computations. This may improve accuracy - on very clean source material, but more likely will decrease accuracy, - especially if there is chroma noise (rainbow effect) or any grayscale - video. The main purpose of setting ``mp`` to a chroma plane is to reduce - CPU load and make pullup usable in realtime on slow machines. - -``yadif=[mode:interlaced-only]`` - Yet another deinterlacing filter - - ``<mode>`` - :frame: Output 1 frame for each frame. - :field: Output 1 frame for each field (default). - :frame-nospatial: Like ``frame`` but skips spatial interlacing check. - :field-nospatial: Like ``field`` but skips spatial interlacing check. - - ``<interlaced-only>`` - :no: Deinterlace all frames. - :yes: Only deinterlace frames marked as interlaced (default). - - This filter is automatically inserted when using the ``d`` key (or any - other key that toggles the ``deinterlace`` property or when using the - ``--deinterlace`` switch), assuming the video output does not have native - deinterlacing support. - - If you just want to set the default mode, put this filter and its options - into ``--vf-defaults`` instead, and enable deinterlacing with ``d`` or - ``--deinterlace``. - - Also, note that the ``d`` key is stupid enough to insert a deinterlacer twice - when inserting yadif with ``--vf``, so using the above methods is - recommended. - ``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 @@ -558,91 +339,6 @@ Available mpv-only filters are: subtitle colors and video under the influence of the video equalizer settings. -``stereo3d[=in:out]`` - Stereo3d converts between different stereoscopic image formats. - - ``<in>`` - Stereoscopic image format of input. Possible values: - - ``sbsl`` or ``side_by_side_left_first`` - side by side parallel (left eye left, right eye right) - ``sbsr`` or ``side_by_side_right_first`` - side by side crosseye (right eye left, left eye right) - ``abl`` or ``above_below_left_first`` - above-below (left eye above, right eye below) - ``abr`` or ``above_below_right_first`` - above-below (right eye above, left eye below) - ``ab2l`` or ``above_below_half_height_left_first`` - above-below with half height resolution (left eye above, right eye - below) - ``ab2r`` or ``above_below_half_height_right_first`` - above-below with half height resolution (right eye above, left eye - below) - - ``<out>`` - Stereoscopic image format of output. Possible values are all the input - formats as well as: - - ``arcg`` or ``anaglyph_red_cyan_gray`` - anaglyph red/cyan gray (red filter on left eye, cyan filter on - right eye) - ``arch`` or ``anaglyph_red_cyan_half_color`` - anaglyph red/cyan half colored (red filter on left eye, cyan filter - on right eye) - ``arcc`` or ``anaglyph_red_cyan_color`` - anaglyph red/cyan color (red filter on left eye, cyan filter on - right eye) - ``arcd`` or ``anaglyph_red_cyan_dubois`` - anaglyph red/cyan color optimized with the least-squares - projection of Dubois (red filter on left eye, cyan filter on right - eye) - ``agmg`` or ``anaglyph_green_magenta_gray`` - anaglyph green/magenta gray (green filter on left eye, magenta - filter on right eye) - ``agmh`` or ``anaglyph_green_magenta_half_color`` - anaglyph green/magenta half colored (green filter on left eye, - magenta filter on right eye) - ``agmc`` or ``anaglyph_green_magenta_color`` - anaglyph green/magenta colored (green filter on left eye, magenta - filter on right eye) - ``aybg`` or ``anaglyph_yellow_blue_gray`` - anaglyph yellow/blue gray (yellow filter on left eye, blue filter - on right eye) - ``aybh`` or ``anaglyph_yellow_blue_half_color`` - anaglyph yellow/blue half colored (yellow filter on left eye, blue - filter on right eye) - ``aybc`` or ``anaglyph_yellow_blue_color`` - anaglyph yellow/blue colored (yellow filter on left eye, blue - filter on right eye) - ``irl`` or ``interleave_rows_left_first`` - Interleaved rows (left eye has top row, right eye starts on next - row) - ``irr`` or ``interleave_rows_right_first`` - Interleaved rows (right eye has top row, left eye starts on next - row) - ``ml`` or ``mono_left`` - mono output (left eye only) - ``mr`` or ``mono_right`` - mono output (right eye only) - -``gradfun[=strength[:radius|:size=<size>]]`` - Fix the banding artifacts that are sometimes introduced into nearly flat - regions by truncation to 8-bit color depth. Interpolates the gradients that - should go where the bands are, and dithers them. - - ``<strength>`` - Maximum amount by which the filter will change any one pixel. Also the - threshold for detecting nearly flat regions (default: 1.5). - - ``<radius>`` - Neighborhood to fit the gradient to. Larger radius makes for smoother - gradients, but also prevents the filter from modifying pixels near - detailed regions (default: disabled). - - ``<size>`` - size of the filter in percent of the image diagonal size. This is - used to calculate the final radius size (default: 1). - ``vapoursynth=file:buffered-frames:concurrent-frames`` Loads a VapourSynth filter script. This is intended for streamed processing: mpv actually provides a source filter, instead of using a diff --git a/video/filter/vf.c b/video/filter/vf.c index 6e2cb251e0..0edd2a7dcf 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -39,20 +39,8 @@ #include "video/mp_image_pool.h" #include "vf.h" -extern const vf_info_t vf_info_crop; -extern const vf_info_t vf_info_expand; -extern const vf_info_t vf_info_scale; extern const vf_info_t vf_info_format; -extern const vf_info_t vf_info_noformat; -extern const vf_info_t vf_info_flip; -extern const vf_info_t vf_info_rotate; -extern const vf_info_t vf_info_mirror; -extern const vf_info_t vf_info_gradfun; -extern const vf_info_t vf_info_dsize; -extern const vf_info_t vf_info_pullup; extern const vf_info_t vf_info_sub; -extern const vf_info_t vf_info_yadif; -extern const vf_info_t vf_info_stereo3d; extern const vf_info_t vf_info_convert; extern const vf_info_t vf_info_lavfi; extern const vf_info_t vf_info_lavfi_bridge; @@ -66,19 +54,7 @@ extern const vf_info_t vf_info_d3d11vpp; // list of available filters: static const vf_info_t *const filter_list[] = { #if HAVE_GPL - &vf_info_crop, - &vf_info_expand, - &vf_info_scale, &vf_info_format, - &vf_info_noformat, - &vf_info_flip, - &vf_info_mirror, - &vf_info_rotate, - &vf_info_gradfun, - &vf_info_pullup, - &vf_info_yadif, - &vf_info_stereo3d, - &vf_info_dsize, &vf_info_sub, #endif diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c deleted file mode 100644 index 495abf65c7..0000000000 --- a/video/filter/vf_crop.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv 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. - * - * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "config.h" -#include "common/msg.h" -#include "options/options.h" - -#include "video/img_format.h" -#include "video/mp_image.h" -#include "vf.h" - -#include "options/m_option.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -static const struct vf_priv_s { - int crop_w,crop_h; - int crop_x,crop_y; -} vf_priv_dflt = { - -1,-1, - -1,-1 -}; - -//===========================================================================// - -static int reconfig(struct vf_instance *vf, struct mp_image_params *in, - struct mp_image_params *out) -{ - int width = in->w, height = in->h; - - // calculate the missing parameters: - if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width; - if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height; - if(vf->priv->crop_x<0) vf->priv->crop_x=(width-vf->priv->crop_w)/2; - if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2; - // rounding: - - int orig_x = vf->priv->crop_x; - int orig_y = vf->priv->crop_y; - - struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt); - - if (fmt.flags & MP_IMGFLAG_HWACCEL) { - vf->priv->crop_x = 0; - vf->priv->crop_y = 0; - } else { - vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x); - vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y); - } - - if (vf->priv->crop_x != orig_x || vf->priv->crop_y != orig_y) { - MP_WARN(vf, "Adjusting crop origin to %d/%d for pixel format alignment.\n", - vf->priv->crop_x, vf->priv->crop_y); - } - - // check: - if(vf->priv->crop_w+vf->priv->crop_x>width || - vf->priv->crop_h+vf->priv->crop_y>height){ - MP_WARN(vf, "Bad position/width/height - cropped area outside of the original!\n"); - return -1; - } - - *out = *in; - out->w = vf->priv->crop_w; - out->h = vf->priv->crop_h; - return 0; -} - -static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -{ - if (mpi->fmt.flags & MP_IMGFLAG_HWACCEL) { - mp_image_set_size(mpi, vf->fmt_out.w, vf->fmt_out.h); - } else { - mp_image_crop(mpi, vf->priv->crop_x, vf->priv->crop_y, - vf->priv->crop_x + vf->priv->crop_w, - vf->priv->crop_y + vf->priv->crop_h); - } - return mpi; -} - -static int query_format(struct vf_instance *vf, unsigned int fmt) -{ - return vf_next_query_format(vf, fmt); -} - -static int vf_open(vf_instance_t *vf){ - MP_WARN(vf, "This filter is deprecated. Use lavfi crop instead.\n"); - vf->reconfig=reconfig; - vf->filter=filter; - vf->query_format=query_format; - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_INT("w", crop_w, M_OPT_MIN, .min = 0), - OPT_INT("h", crop_h, M_OPT_MIN, .min = 0), - OPT_INT("x", crop_x, M_OPT_MIN, .min = -1), - OPT_INT("y", crop_y, M_OPT_MIN, .min = -1), - {0} -}; - -const vf_info_t vf_info_crop = { - .description = "cropping", - .name = "crop", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .priv_defaults = &vf_priv_dflt, - .options = vf_opts_fields, -}; - -//===========================================================================// diff --git a/video/filter/vf_dsize.c b/video/filter/vf_dsize.c deleted file mode 100644 index 12fa7242f3..0000000000 --- a/video/filter/vf_dsize.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv 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. - * - * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <inttypes.h> -#include <limits.h> - -#include "config.h" -#include "common/msg.h" -#include "options/m_option.h" - -#include "video/img_format.h" -#include "video/mp_image.h" -#include "vf.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -struct vf_priv_s { - int w, h; - int method; // aspect method, 0 -> downscale, 1-> upscale. +2 -> original aspect. - int round; - float aspect; -}; - -static int reconfig(struct vf_instance *vf, struct mp_image_params *in, - struct mp_image_params *out) -{ - int width = in->w, height = in->h; - int d_width, d_height; - mp_image_params_get_dsize(in, &d_width, &d_height); - int w = vf->priv->w; - int h = vf->priv->h; - if (vf->priv->aspect < 0.001) { // did the user input aspect or w,h params - if (w == 0) w = d_width; - if (h == 0) h = d_height; - if (w == -1) w = width; - if (h == -1) h = height; - if (w == -2) w = h * (double)d_width / d_height; - if (w == -3) w = h * (double)width / height; - if (h == -2) h = w * (double)d_height / d_width; - if (h == -3) h = w * (double)height / width; - if (vf->priv->method > -1) { - double aspect = (vf->priv->method & 2) ? ((double)height / width) : ((double)d_height / d_width); - if ((h > w * aspect) ^ (vf->priv->method & 1)) { - h = w * aspect; - } else { - w = h / aspect; - } - } - if (vf->priv->round > 1) { // round up - w += (vf->priv->round - 1 - (w - 1) % vf->priv->round); - h += (vf->priv->round - 1 - (h - 1) % vf->priv->round); - } - d_width = w; - d_height = h; - } else { - if (vf->priv->aspect * height > width) { - d_width = height * vf->priv->aspect + .5; - d_height = height; - } else { - d_height = width / vf->priv->aspect + .5; - d_width = width; - } - } - *out = *in; - mp_image_params_set_dsize(out, d_width, d_height); - return 0; -} - -static int vf_open(vf_instance_t *vf) -{ - MP_WARN(vf, "This filter is deprecated. No replacement.\n"); - - vf->reconfig = reconfig; - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -const vf_info_t vf_info_dsize = { - .description = "reset displaysize/aspect", - .name = "dsize", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .priv_defaults = &(const struct vf_priv_s){ - .aspect = 0.0, - .w = -1, - .h = -1, - .method = -1, - .round = 1, - }, - .options = (const struct m_option[]){ - OPT_INTRANGE("w", w, 0, -3, INT_MAX), - OPT_INTRANGE("h", h, 0, -3, INT_MAX), - OPT_INTRANGE("method", method, 0, -1, 3), - OPT_INTRANGE("round", round, 0, 0, 9999), - OPT_FLOAT("aspect", aspect, CONF_RANGE, .min = 0, .max = 10), - {0} - }, -}; diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c deleted file mode 100644 index 398d90ecba..0000000000 --- a/video/filter/vf_expand.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv 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. - * - * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdbool.h> - -#include <libavutil/common.h> - -#include "config.h" -#include "common/msg.h" -#include "options/options.h" - -#include "video/img_format.h" -#include "video/mp_image.h" -#include "vf.h" - -#include "options/m_option.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -static struct vf_priv_s { - // These four values are a backup of the values parsed from the command line. - // This is necessary so that we do not get a mess upon filter reinit due to - // e.g. aspect changes and with only aspect specified on the command line, - // where we would otherwise use the values calculated for a different aspect - // instead of recalculating them again. - int cfg_exp_w, cfg_exp_h; - int cfg_exp_x, cfg_exp_y; - int exp_w,exp_h; - int exp_x,exp_y; - double aspect; - int round; -} const vf_priv_dflt = { - -1,-1, - -1,-1, - -1,-1, - -1,-1, - 0., - 1, -}; - -//===========================================================================// - -static int reconfig(struct vf_instance *vf, struct mp_image_params *in, - struct mp_image_params *out) -{ - int width = in->w, height = in->h; - - vf->priv->exp_x = vf->priv->cfg_exp_x; - vf->priv->exp_y = vf->priv->cfg_exp_y; - vf->priv->exp_w = vf->priv->cfg_exp_w; - vf->priv->exp_h = vf->priv->cfg_exp_h; - if ( vf->priv->exp_w == -1 ) vf->priv->exp_w=width; - else if (vf->priv->exp_w < -1 ) vf->priv->exp_w=width - vf->priv->exp_w; - else if ( vf->priv->exp_w<width ) vf->priv->exp_w=width; - if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height; - else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h; - else if( vf->priv->exp_h<height ) vf->priv->exp_h=height; - if (vf->priv->aspect) { - float adjusted_aspect = vf->priv->aspect; - adjusted_aspect *= (double)in->p_w/in->p_h; - if (vf->priv->exp_h < vf->priv->exp_w / adjusted_aspect) { - vf->priv->exp_h = vf->priv->exp_w / adjusted_aspect + 0.5; - } else { - vf->priv->exp_w = vf->priv->exp_h * adjusted_aspect + 0.5; - } - } - if (vf->priv->round > 1) { // round up. - vf->priv->exp_w = (1 + (vf->priv->exp_w - 1) / vf->priv->round) * vf->priv->round; - vf->priv->exp_h = (1 + (vf->priv->exp_h - 1) / vf->priv->round) * vf->priv->round; - } - - if(vf->priv->exp_x<0 || vf->priv->exp_x+width>vf->priv->exp_w) vf->priv->exp_x=(vf->priv->exp_w-width)/2; - if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2; - - struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt); - - vf->priv->exp_x = MP_ALIGN_DOWN(vf->priv->exp_x, fmt.align_x); - vf->priv->exp_y = MP_ALIGN_DOWN(vf->priv->exp_y, fmt.align_y); - - *out = *in; - out->w = vf->priv->exp_w; - out->h = vf->priv->exp_h; - - return 0; -} - -static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -{ - int e_x = vf->priv->exp_x, e_y = vf->priv->exp_y; - int e_w = vf->priv->exp_w, e_h = vf->priv->exp_h; - - if (e_x == 0 && e_y == 0 && e_w == mpi->w && e_h == mpi->h) - return mpi; - - struct mp_image *dmpi = vf_alloc_out_image(vf); - if (!dmpi) { - talloc_free(mpi); - return NULL; - } - mp_image_copy_attributes(dmpi, mpi); - - struct mp_image cropped = *dmpi; - mp_image_crop(&cropped, e_x, e_y, e_x + mpi->w, e_y + mpi->h); - mp_image_copy(&cropped, mpi); - - int e_x2 = e_x + MP_ALIGN_DOWN(mpi->w, mpi->fmt.align_x); - int e_y2 = e_y + MP_ALIGN_DOWN(mpi->h, mpi->fmt.align_y); - - // top border (over the full width) - mp_image_clear(dmpi, 0, 0, e_w, e_y); - // bottom border (over the full width) - mp_image_clear(dmpi, 0, e_y2, e_w, e_h); - // left - mp_image_clear(dmpi, 0, e_y, e_x, e_y2); - // right - mp_image_clear(dmpi, e_x2, e_y, e_w, e_y2); - - talloc_free(mpi); - return dmpi; -} - -static int query_format(struct vf_instance *vf, unsigned int fmt) -{ - if (!IMGFMT_IS_HWACCEL(fmt)) - return vf_next_query_format(vf, fmt); - return 0; -} - -static int vf_open(vf_instance_t *vf){ - MP_WARN(vf, "This filter is deprecated. Use lavfi pad instead.\n"); - - vf->reconfig=reconfig; - vf->query_format=query_format; - vf->filter=filter; - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_INT("w", cfg_exp_w, 0), - OPT_INT("h", cfg_exp_h, 0), - OPT_INT("x", cfg_exp_x, M_OPT_MIN, .min = -1), - OPT_INT("y", cfg_exp_y, M_OPT_MIN, .min = -1), - OPT_DOUBLE("aspect", aspect, M_OPT_MIN, .min = 0), - OPT_INT("round", round, M_OPT_MIN, .min = 1), - {0} -}; - -const vf_info_t vf_info_expand = { - .description = "expanding", - .name = "expand", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .priv_defaults = &vf_priv_dflt, - .options = vf_opts_fields, -}; - -//===========================================================================// diff --git a/video/filter/vf_flip.c b/video/filter/vf_flip.c deleted file mode 100644 index 776f127fa1..0000000000 --- a/video/filter/vf_flip.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv 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. - * - * mpv 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 |