From 12cac1d1119a0dab3469dc52c851b8eb528d63b7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 29 Nov 2017 18:10:59 +0100 Subject: vf: remove most GPL video filters Almost all of them had their guts removed and replaced by libavfilter long ago, but remove them anyway. They're pointless and have been scheduled for deprecation. Still leave vf_format (because we need it in some form) and vf_sub (not sure). This will break some builtin functionality: lavfi yadif defaults are different, auto rotation and stereo3d downconversion are broken. These might be fixed later. --- Copyright | 12 -- DOCS/man/vf.rst | 304 --------------------------------------------- video/filter/vf.c | 24 ---- video/filter/vf_crop.c | 133 -------------------- video/filter/vf_dsize.c | 118 ------------------ video/filter/vf_expand.c | 178 -------------------------- video/filter/vf_flip.c | 60 --------- video/filter/vf_gradfun.c | 108 ---------------- video/filter/vf_mirror.c | 38 ------ video/filter/vf_noformat.c | 72 ----------- video/filter/vf_pullup.c | 83 ------------- video/filter/vf_rotate.c | 106 ---------------- video/filter/vf_scale.c | 258 -------------------------------------- video/filter/vf_stereo3d.c | 225 --------------------------------- video/filter/vf_yadif.c | 97 --------------- wscript_build.py | 14 +-- 16 files changed, 1 insertion(+), 1829 deletions(-) delete mode 100644 video/filter/vf_crop.c delete mode 100644 video/filter/vf_dsize.c delete mode 100644 video/filter/vf_expand.c delete mode 100644 video/filter/vf_flip.c delete mode 100644 video/filter/vf_gradfun.c delete mode 100644 video/filter/vf_mirror.c delete mode 100644 video/filter/vf_noformat.c delete mode 100644 video/filter/vf_pullup.c delete mode 100644 video/filter/vf_rotate.c delete mode 100644 video/filter/vf_scale.c delete mode 100644 video/filter/vf_stereo3d.c delete mode 100644 video/filter/vf_yadif.c diff --git a/Copyright b/Copyright index 7dd4c6a27e..d021e10e3f 100644 --- a/Copyright +++ b/Copyright @@ -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. - - ``,`` - Cropped width and height, defaults to original width and height. - ``,`` - 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. - - ``,`` - 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. - - ``,`` - position of original image on the expanded image (default: center) - - ```` - 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. - - ```` - Rounds up to make both width and height divisible by (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. - - ``:`` - 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. - - ``[:]`` (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) - - ```` - 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. - - ```` - 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. - - ```` - 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. - - ``,`` - 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. - - ```` - Modifies width and height according to original aspect ratios. - - :-1: Ignore original aspect ratio (default). - :0: Keep display aspect ratio by using ```` and ```` as maximum - resolution. - :1: Keep display aspect ratio by using ```` and ```` as minimum - resolution. - :2: Keep video aspect ratio by using ```` and ```` as maximum - resolution. - :3: Keep video aspect ratio by using ```` and ```` as minimum - resolution. - - .. admonition:: Example - - ``dsize=800:600:0`` - Specifies a display resolution of at most 800x600, or smaller, - in order to keep aspect. - - ```` - Rounds up to make both width and height divisible by ```` - (default: 1). - - ```` - Force an aspect ratio. - ``format=fmt=:colormatrix=:...`` 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: ````, ````, ```` 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``. - - ```` - 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 - - ```` - :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. - - ```` - :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. - - ```` - 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) - - ```` - 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=]]`` - 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. - - ```` - Maximum amount by which the filter will change any one pixel. Also the - threshold for detecting nearly flat regions (default: 1.5). - - ```` - 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 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 . - */ - -#include -#include -#include - -#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 . - */ - -#include -#include -#include -#include -#include - -#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 . - */ - -#include -#include -#include -#include - -#include - -#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_wpriv->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_hpriv->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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see . - */ - -#include -#include -#include - -#include "config.h" -#include "common/msg.h" - -#include "video/mp_image.h" -#include "vf.h" - -#include "video/out/vo.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -{ - mp_image_vflip(mpi); - return mpi; -} - -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 vflip instead.\n"); - - vf->filter=filter; - vf->query_format = query_format; - return 1; -} - -const vf_info_t vf_info_flip = { - .description = "flip image upside-down", - .name = "flip", - .open = vf_open, -}; diff --git a/video/filter/vf_gradfun.c b/video/filter/vf_gradfun.c deleted file mode 100644 index 33bc883c61..0000000000 --- a/video/filter/vf_gradfun.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2009 Loren Merritt - * - * 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 . - */ - -#include -#include -#include -#include - -#include "vf.h" - -#include "common/common.h" -#include "options/m_option.h" - -#include "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -struct vf_priv_s { - float cfg_thresh; - int cfg_radius; - float cfg_size; - int radius; - - struct vf_lw_opts *lw_opts; -} const vf_priv_dflt = { - .cfg_thresh = 1.5, - .cfg_radius = -1, - .cfg_size = -1, -}; - -static int lavfi_reconfig(struct vf_instance *vf, - struct mp_image_params *in, - struct mp_image_params *out) -{ - struct vf_priv_s *p = vf_lw_old_priv(vf); - int w = in->w; - int h = in->h; - p->radius = p->cfg_radius; - if (p->cfg_size > -1) - p->radius = (p->cfg_size / 100.0f) * sqrtf(w * w + h * h); - p->radius = MPCLAMP((p->radius+1)&~1, 4, 32); - vf_lw_update_graph(vf, "gradfun", "%f:%d", p->cfg_thresh, p->radius); - return 0; -} - -static int vf_open(vf_instance_t *vf) -{ - MP_WARN(vf, "%s", VF_LW_REPLACE); - - bool have_radius = vf->priv->cfg_radius > -1; - bool have_size = vf->priv->cfg_size > -1; - - if (have_radius && have_size) { - MP_ERR(vf, "scale: gradfun: only one of " - "radius/size parameters allowed at the same time!\n"); - return 0; - } - - if (!have_radius && !have_size) - vf->priv->cfg_size = 1.0; - - if (vf_lw_set_graph(vf, vf->priv->lw_opts, "gradfun", "%f:4", - vf->priv->cfg_thresh) >= 0) - { - vf_lw_set_reconfig_cb(vf, lavfi_reconfig); - return 1; - } - - MP_FATAL(vf, "This version of libavfilter has no 'gradfun' filter.\n"); - return 0; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_FLOATRANGE("strength", cfg_thresh, 0, 0.51, 255), - OPT_INTRANGE("radius", cfg_radius, 0, 4, 32), - OPT_FLOATRANGE("size", cfg_size, 0, 0.1, 5.0), - OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0), - {0} -}; - -const vf_info_t vf_info_gradfun = { - .description = "gradient deband", - .name = "gradfun", - .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_mirror.c b/video/filter/vf_mirror.c deleted file mode 100644 index 91cc9a5503..0000000000 --- a/video/filter/vf_mirror.c +++ /dev/null @@ -1,38 +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 . - */ - -#include - -#include "vf.h" -#include "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -static int vf_open(vf_instance_t *vf) -{ - MP_WARN(vf, "This filter is deprecated. Use lavfi hflip instead.\n"); - return vf_lw_set_graph(vf, NULL, NULL, "hflip") >= 0; -} - -const vf_info_t vf_info_mirror = { - .description = "horizontal mirror", - .name = "mirror", - .open = vf_open, -}; diff --git a/video/filter/vf_noformat.c b/video/filter/vf_noformat.c deleted file mode 100644 index b6a71d9417..0000000000 --- a/video/filter/vf_noformat.c +++ /dev/null @@ -1,72 +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 . - */ - -#include -#include -#include -#include - -#include "config.h" -#include "common/msg.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 { - int fmt; -} const vf_priv_dflt = { - IMGFMT_420P -}; - -//===========================================================================// - -static int query_format(struct vf_instance *vf, unsigned int fmt){ - if(fmt!=vf->priv->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 and will be removed (no replacement)\n"); - vf->query_format=query_format; - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_IMAGEFORMAT("fmt", fmt, 0), - {0} -}; - -const vf_info_t vf_info_noformat = { - .description = "disallow one output format", - .name = "noformat", - .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_pullup.c b/video/filter/vf_pullup.c deleted file mode 100644 index 83d5f177b3..0000000000 --- a/video/filter/vf_pullup.c +++ /dev/null @@ -1,83 +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 . - */ - -#include -#include -#include - -#include "common/msg.h" -#include "options/m_option.h" - -#include "vf.h" - -#include "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -struct vf_priv_s { - struct pullup_context *ctx; - int init; - int fakecount; - double lastpts; - int junk_left, junk_right, junk_top, junk_bottom; - int strict_breaks, metric_plane; - struct vf_lw_opts *lw_opts; -}; - -static int vf_open(vf_instance_t *vf) -{ - MP_WARN(vf, "%s", VF_LW_REPLACE); - - struct vf_priv_s *p = vf->priv; - const char *pname[3] = {"y", "u", "v"}; - if (vf_lw_set_graph(vf, p->lw_opts, "pullup", "%d:%d:%d:%d:%d:%s", - p->junk_left, p->junk_right, p->junk_top, p->junk_bottom, - p->strict_breaks, pname[p->metric_plane]) >= 0) - { - return 1; - } - - MP_FATAL(vf, "This version of libavfilter has no 'pullup' filter.\n"); - return 0; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -const vf_info_t vf_info_pullup = { - .description = "pullup (from field sequence to frames)", - .name = "pullup", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .priv_defaults = &(const struct vf_priv_s){ - .junk_left = 1, - .junk_right = 1, - .junk_top = 4, - .junk_bottom = 4, - }, - .options = (const struct m_option[]){ - OPT_INT("jl", junk_left, 0), - OPT_INT("jr", junk_right, 0), - OPT_INT("jt", junk_top, 0), - OPT_INT("jb", junk_bottom, 0), - OPT_INT("sb", strict_breaks, 0), - OPT_CHOICE("mp", metric_plane, 0, ({"y", 0}, {"u", 1}, {"v", 2})), - OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0), - {0} - }, -}; diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c deleted file mode 100644 index 443a0dac42..0000000000 --- a/video/filter/vf_rotate.c +++ /dev/null @@ -1,106 +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 . - */ - -#include -#include -#include -#include -#include - -#include "common/msg.h" -#include "options/m_option.h" - -#include "vf.h" -#include "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -struct vf_priv_s { - int angle; - int warn; - struct vf_lw_opts *lw_opts; -}; - -static const char *const rot[] = { - "null", - "transpose=clock", - "vflip,hflip", - "transpose=cclock", - "null", // actually set in lavfi_recreate() -}; - -static int lavfi_reconfig(struct vf_instance *vf, - struct mp_image_params *in, - struct mp_image_params *out) -{ - struct vf_priv_s *p = vf_lw_old_priv(vf); - if (p->angle == 4) { // "auto" - int r = in->rotate; - if (r < 0 || r >= 360) { - MP_ERR(vf, "Can't apply rotation of %d degrees.\n", r); - return -1; - } - if (r % 90) { - double a = r / 180.0 * M_PI; - vf_lw_update_graph(vf, NULL, "rotate=%f:ow=rotw(%f):oh=roth(%f)", - a, a, a); - } else { - vf_lw_update_graph(vf, NULL, "%s", rot[(r / 90) % 360]); - } - out->rotate = 0; - } - return 0; -} - -static int vf_open(vf_instance_t *vf) -{ - struct vf_priv_s *p = vf->priv; - - if (p->warn) - MP_WARN(vf, "%s", VF_LW_REPLACE); - - if (vf_lw_set_graph(vf, p->lw_opts, NULL, "%s", rot[p->angle]) >= 0) { - vf_lw_set_reconfig_cb(vf, lavfi_reconfig); - return 1; - } - - return 0; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -const vf_info_t vf_info_rotate = { - .description = "rotate", - .name = "rotate", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .options = (const struct m_option[]){ - OPT_CHOICE("angle", angle, 0, - ({"0", 0}, - {"90", 1}, - {"180", 2}, - {"270", 3}, - {"auto", 4})), - OPT_FLAG("warn", warn, 0, OPTDEF_INT(1)), - OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0), - {0} - }, -}; - -//===========================================================================// diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c deleted file mode 100644 index 28508e4466..0000000000 --- a/video/filter/vf_scale.c +++ /dev/null @@ -1,258 +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 . - */ - -#include -#include -#include -#include -#include - -#include - -#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 "video/fmt-conversion.h" - -#include "video/sws_utils.h" - -#include "video/csputils.h" -#include "video/out/vo.h" - -#include "options/m_option.h" - -#include "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -static struct vf_priv_s { - int w, h; - int cfg_w, cfg_h; - int v_chr_drop; - double param[2]; - struct mp_sws_context *sws; - int noup; - int accurate_rnd; - int warn; -} const vf_priv_dflt = { - 0, 0, - -1, -1, - 0, - {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT}, - .warn = 1, -}; - -static int find_best_out(vf_instance_t *vf, int in_format) -{ - int best = 0; - for (int out_format = IMGFMT_START; out_format < IMGFMT_END; out_format++) { - if (!vf_next_query_format(vf, out_format)) - continue; - if (sws_isSupportedOutput(imgfmt2pixfmt(out_format)) < 1) - continue; - if (best) { - int candidate = mp_imgfmt_select_best(best, out_format, in_format); - if (candidate) - best = candidate; - } else { - best = out_format; - } - } - return best; -} - -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); - - unsigned int best = find_best_out(vf, in->imgfmt); - int round_w = 0, round_h = 0; - - if (!best) { - MP_WARN(vf, "no supported output format found\n"); - return -1; - } - - vf->next->query_format(vf->next, best); - - vf->priv->w = vf->priv->cfg_w; - vf->priv->h = vf->priv->cfg_h; - - if (vf->priv->w <= -8) { - vf->priv->w += 8; - round_w = 1; - } - if (vf->priv->h <= -8) { - vf->priv->h += 8; - round_h = 1; - } - - if (vf->priv->w < -3 || vf->priv->h < -3 || - (vf->priv->w < -1 && vf->priv->h < -1)) - { - MP_ERR(vf, "invalid parameters\n"); - return -1; - } - - if (vf->priv->w == -1) - vf->priv->w = width; - if (vf->priv->w == 0) - vf->priv->w = d_width; - - if (vf->priv->h == -1) - vf->priv->h = height; - if (vf->priv->h == 0) - vf->priv->h = d_height; - - if (vf->priv->w == -3) - vf->priv->w = vf->priv->h * width / height; - if (vf->priv->w == -2) - vf->priv->w = vf->priv->h * d_width / d_height; - - if (vf->priv->h == -3) - vf->priv->h = vf->priv->w * height / width; - if (vf->priv->h == -2) - vf->priv->h = vf->priv->w * d_height / d_width; - - if (round_w) - vf->priv->w = ((vf->priv->w + 8) / 16) * 16; - if (round_h) - vf->priv->h = ((vf->priv->h + 8) / 16) * 16; - - // check for upscaling, now that all parameters had been applied - if (vf->priv->noup) { - if ((vf->priv->w > width) + (vf->priv->h > height) >= vf->priv->noup) { - vf->priv->w = width; - vf->priv->h = height; - } - } - - MP_DBG(vf, "scaling %dx%d to %dx%d\n", width, height, vf->priv->w, vf->priv->h); - - // Compute new d_width and d_height, preserving aspect - // while ensuring that both are >= output size in pixels. - if (vf->priv->h * d_width > vf->priv->w * d_height) { - d_width = vf->priv->h * d_width / d_height; - d_height = vf->priv->h; - } else { - d_height = vf->priv->w * d_height / d_width; - d_width = vf->priv->w; - } - - *out = *in; - out->w = vf->priv->w; - out->h = vf->priv->h; - mp_image_params_set_dsize(out, d_width, d_height); - out->imgfmt = best; - - // Second-guess what libswscale is going to output and what not. - // It depends what libswscale supports for in/output, and what makes sense. - struct mp_imgfmt_desc s_fmt = mp_imgfmt_get_desc(in->imgfmt); - struct mp_imgfmt_desc d_fmt = mp_imgfmt_get_desc(out->imgfmt); - // keep colorspace settings if the data stays in yuv - if (!(s_fmt.flags & MP_IMGFLAG_YUV) || !(d_fmt.flags & MP_IMGFLAG_YUV)) { - out->color.space = MP_CSP_AUTO; - out->color.levels = MP_CSP_LEVELS_AUTO; - } - mp_image_params_guess_csp(out); - - mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->opts->vo->sws_opts); - vf->priv->sws->flags |= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT; - vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND; - vf->priv->sws->src = *in; - vf->priv->sws->dst = *out; - - if (mp_sws_reinit(vf->priv->sws) < 0) { - // error... - MP_WARN(vf, "Couldn't init libswscale for this setup\n"); - return -1; - } - return 0; -} - -static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -{ - struct mp_image *dmpi = vf_alloc_out_image(vf); - if (!dmpi) - return NULL; - mp_image_copy_attributes(dmpi, mpi); - - mp_sws_scale(vf->priv->sws, dmpi, mpi); - - talloc_free(mpi); - return dmpi; -} - -static int query_format(struct vf_instance *vf, unsigned int fmt) -{ - if (IMGFMT_IS_HWACCEL(fmt) || sws_isSupportedInput(imgfmt2pixfmt(fmt)) < 1) - return 0; - return !!find_best_out(vf, fmt); -} - -static void uninit(struct vf_instance *vf) -{ -} - -static int vf_open(vf_instance_t *vf) -{ - vf->reconfig = reconfig; - vf->filter = filter; - vf->query_format = query_format; - vf->uninit = uninit; - vf->priv->sws = mp_sws_alloc(vf); - vf->priv->sws->log = vf->log; - vf->priv->sws->params[0] = vf->priv->param[0]; - vf->priv->sws->params[1] = vf->priv->param[1]; - if (vf->priv->warn) - MP_WARN(vf, "%s", VF_LW_REPLACE); - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_INT("w", cfg_w, M_OPT_MIN, .min = -11), - OPT_INT("h", cfg_h, M_OPT_MIN, .min = -11), - OPT_DOUBLE("param", param[0], M_OPT_RANGE, .min = 0.0, .max = 100.0), - OPT_DOUBLE("param2", param[1], M_OPT_RANGE, .min = 0.0, .max = 100.0), - OPT_INTRANGE("chr-drop", v_chr_drop, 0, 0, 3), - OPT_INTRANGE("noup", noup, 0, 0, 2), - OPT_FLAG("arnd", accurate_rnd, 0), - OPT_FLAG("warn", warn, 0), - {0} -}; - -const vf_info_t vf_info_scale = { - .description = "software scaling", - .name = "scale", - .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_stereo3d.c b/video/filter/vf_stereo3d.c deleted file mode 100644 index 3d29dcd8e8..0000000000 --- a/video/filter/vf_stereo3d.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2010 Gordon Schmidt s2000.tu-chemnitz.de> - * - * 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 . - */ - -//==includes==// -#include -#include -#include -#include - -#include - -#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 "vf_lavfi.h" - -#include "config.h" -#if !HAVE_GPL -#error GPL only -#endif - -//==types==// -typedef enum stereo_code { - ANAGLYPH_RC_GRAY, //anaglyph red/cyan gray - ANAGLYPH_RC_HALF, //anaglyph red/cyan half colored - ANAGLYPH_RC_COLOR, //anaglyph red/cyan colored - ANAGLYPH_RC_DUBOIS, //anaglyph red/cyan dubois - ANAGLYPH_GM_GRAY, //anaglyph green/magenta gray - ANAGLYPH_GM_HALF, //anaglyph green/magenta half colored - ANAGLYPH_GM_COLOR, //anaglyph green/magenta colored - ANAGLYPH_GM_DUBOIS, //anaglyph green/magenta dubois - ANAGLYPH_YB_GRAY, //anaglyph yellow/blue gray - ANAGLYPH_YB_HALF, //anaglyph yellow/blue half colored - ANAGLYPH_YB_COLOR, //anaglyph yellow/blue colored - ANAGLYPH_YB_DUBOIS, //anaglyph yellow/blue dubois - MONO_L, //mono output for debugging (left eye only) - MONO_R, //mono output for debugging (right eye only) - SIDE_BY_SIDE_LR, //side by side parallel (left eye left, right eye right) - SIDE_BY_SIDE_RL, //side by side crosseye (right eye left, left eye right) - SIDE_BY_SIDE_2_LR, //side by side parallel with half width resolution - SIDE_BY_SIDE_2_RL, //side by side crosseye with half width resolution - ABOVE_BELOW_LR, //above-below (left eye above, right eye below) - ABOVE_BELOW_RL, //above-below (right eye above, left eye below) - ABOVE_BELOW_2_LR, //above-below with half height resolution - ABOVE_BELOW_2_RL, //above-below with half height resolution - INTERLEAVE_ROWS_LR, //row-interleave (left eye has top row) - INTERLEAVE_ROWS_RL, //row-interleave (right eye has top row) - STEREO_AUTO, //use video metadata info (for input) - ALTERNATING_LR, //alternating frames (left first) - ALTERNATING_RL, //alternating frames (right first) - STEREO_CODE_COUNT //no value set - TODO: needs autodetection -} stereo_code; - -struct vf_priv_s { - int in_fmt; - int out_fmt; - bool auto_in; - int warn; - struct vf_lw_opts *lw_opts; -} const vf_priv_default = { - SIDE_BY_SIDE_LR, - ANAGLYPH_RC_DUBOIS, - .warn = 1, -}; - -const struct m_opt_choice_alternatives stereo_code_names[] = { - {"arcg", ANAGLYPH_RC_GRAY}, - {"anaglyph_red_cyan_gray", ANAGLYPH_RC_GRAY}, - {"arch", ANAGLYPH_RC_HALF}, - {"anaglyph_red_cyan_half_color", ANAGLYPH_RC_HALF}, - {"arcc", ANAGLYPH_RC_COLOR}, - {"anaglyph_red_cyan_color", ANAGLYPH_RC_COLOR}, - {"arcd", ANAGLYPH_RC_DUBOIS}, - {"anaglyph_red_cyan_dubios", ANAGLYPH_RC_DUBOIS}, - {"agmg", ANAGLYPH_GM_GRAY}, - {"anaglyph_green_magenta_gray", ANAGLYPH_GM_GRAY}, - {"agmh", ANAGLYPH_GM_HALF}, - {"anaglyph_green_magenta_half_color",ANAGLYPH_GM_HALF}, - {"agmc", ANAGLYPH_GM_COLOR}, - {"anaglyph_green_magenta_color", ANAGLYPH_GM_COLOR}, - {"agmd", ANAGLYPH_GM_DUBOIS}, - {"anaglyph_green_magenta_dubois", ANAGLYPH_GM_DUBOIS}, - {"aybg", ANAGLYPH_YB_GRAY}, - {"anaglyph_yellow_blue_gray", ANAGLYPH_YB_GRAY}, - {"aybh", ANAGLYPH_YB_HALF}, - {"anaglyph_yellow_blue_half_color", ANAGLYPH_YB_HALF}, - {"aybc", ANAGLYPH_YB_COLOR}, - {"anaglyph_yellow_blue_color", ANAGLYPH_YB_COLOR}, - {"aybd", ANAGLYPH_YB_DUBOIS}, - {"anaglyph_yellow_blue_dubois", ANAGLYPH_YB_DUBOIS}, - {"ml", MONO_L}, - {"mono_left", MONO_L}, - {"mr", MONO_R}, - {"mono_right", MONO_R}, - {"sbsl", SIDE_BY_SIDE_LR}, - {"side_by_side_left_first", SIDE_BY_SIDE_LR}, - {"sbsr", SIDE_BY_SIDE_RL}, - {"side_by_side_right_first", SIDE_BY_SIDE_RL}, - {"sbs2l", SIDE_BY_SIDE_2_LR}, - {"side_by_side_half_width_left_first", SIDE_BY_SIDE_2_LR}, - {"sbs2r", SIDE_BY_SIDE_2_RL}, - {"side_by_side_half_width_right_first",SIDE_BY_SIDE_2_RL}, - {"abl", ABOVE_BELOW_LR}, - {"above_below_left_first", ABOVE_BELOW_LR}, - {"abr", ABOVE_BELOW_RL}, - {"above_below_right_first", ABOVE_BELOW_RL}, - {"ab2l", ABOVE_BELOW_2_LR}, - {"above_below_half_height_left_first", ABOVE_BELOW_2_LR}, - {"ab2r", ABOVE_BELOW_2_RL}, - {"above_below_half_height_right_first",ABOVE_BELOW_2_RL}, - {"irl", INTERLEAVE_ROWS_LR}, - {"interleave_rows_left_first", INTERLEAVE_ROWS_LR}, - {"irr", INTERLEAVE_ROWS_RL}, - {"interleave_rows_right_first", INTERLEAVE_ROWS_RL}, - {"al", ALTERNATING_LR}, - {"ar", ALTERNATING_RL}, - // convenience alias for MP_STEREO3D_MONO - {"mono", MONO_L}, - // for filter auto-insertion - {"auto", STEREO_AUTO}, - { NULL, 0} -}; - -// Extremely stupid; can be dropped when the internal filter is dropped, -// and OPT_CHOICE_C() can be used instead. -static int opt_to_stereo3dmode(int val) -{ - // Find x for name == MP_STEREO3D_NAME(x) - const char *name = m_opt_choice_str(stereo_code_names, val); - for (int n = 0; n < MP_STEREO3D_COUNT; n++) { - const char *o = MP_STEREO3D_NAME(val); - if (name && o && strcmp(o, name) == 0) - return n; - } - return MP_STEREO3D_INVALID; -} - -static int lavfi_reconfig(struct vf_instance *vf, - struct mp_image_params *in, - struct mp_image_params *out) -{ - struct vf_priv_s *p = vf_lw_old_priv(vf); - if (p->auto_in) { - const char *inf = MP_STEREO3D_NAME(in->stereo_in); - if (!inf) { - MP_ERR(vf, "Unknown/unsupported 3D mode.\n"); - return -1; - } - vf_lw_update_graph(vf, "stereo3d", "%s:%s", - inf, m_opt_choice_str(stereo_code_names, p->out_fmt)); - out->stereo_in = out->stereo_out = opt_to_stereo3dmode(p->out_fmt); - } - return 0; -} - -static void lavfi_init(vf_instance_t *vf) -{ - if (vf->priv->in_fmt == STEREO_AUTO && - vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "null") >= 0) - { - vf_lw_set_reconfig_cb(vf, lavfi_reconfig); - return; - } - - if (vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "%s:%s", - m_opt_choice_str(stereo_code_names, vf->priv->in_fmt), - m_opt_choice_str(stereo_code_names, vf->priv->out_fmt)) >= 0) - return; -} - -static int vf_open(vf_instance_t *vf) -{ - if (vf->priv->warn) - MP_WARN(vf, "%s", VF_LW_REPLACE); - - if (vf->priv->out_fmt == STEREO_AUTO) { - MP_FATAL(vf, "No autodetection for stereo output.\n"); - return 0; - } - if (vf->priv->in_fmt == STEREO_AUTO) - vf->priv->auto_in = 1; - - lavfi_init(vf); - return 1; -} - -#define OPT_BASE_STRUCT struct vf_priv_s -static const m_option_t vf_opts_fields[] = { - OPT_CHOICE_C("in", in_fmt, 0, stereo_code_names), - OPT_CHOICE_C("out", out_fmt, 0, stereo_code_names), - OPT_FLAG("warn", warn, 0), - OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0), - {0} -}; - -const vf_info_t vf_info_stereo3d = { - .description = "stereoscopic 3d view", - .name = "stereo3d", - .open = vf_open, - .priv_size = sizeof(struct vf_priv_s), - .priv_defaults = &vf_priv_default, - .options = vf_opts_fields, -}; diff --git a/video/filter/vf_yadif.c b/video/filter/vf_yadif.c deleted file mode 100644 index 3eee572a5f..0000000000 --- a/video/filter/vf_yadif.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2006 Michael Niedermayer - * - * 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 . - */ - -#include - -#include