1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:42:17 +00:00
mpv/video/out
wm4 3909e4cdfc filter_kernels: replace AGG-based code
This commit replaces code based on AGG, taken from this source file:

http://vector-agg.cvs.sourceforge.net/viewvc/vector-agg/agg-2.5/include/agg_image_filters.h

The intention is that filter_kernels.c can be relicensed to LGPL or BSD.
Because the AGG author died, full replacement is the only way to achieve
it.

This affects only some filter functions. These are exclusively
mathematical functions for computing filter coefficients. (Other parts
in filter_kernel.c were originally written by me, with heavy additions
and refactoring done by other mpv contributors.) While the code is
mostly just well-known mathematical formulas written down in C form,
AGG copyright could perhaps be claimed anyway.

To remove the AGG code, I replaced it with the filter functions from:

https://github.com/glumpy/glumpy/blob/master/glumpy/library/build-spatial-filters.py

These functions conveniently compute exactly the same thing in mpv,
Glumpy, AGG (and about anything that will filter images using the same
mathematical principles).

First I ported the Python code in the file to C. Then I replaced all
functions in filter_kernels.c with this code that could be replaced.
Then I investigated whether the remaining functions were based on AGG
code and took appropriate action:

hanning(), hamming(), quadric(), bicubic(), kaiser(), blackman(),
spline16(), spline36(), gaussian(), sinc() were taken straight from
Glumpy.

For sinc(), re-add the "fabs(x) < 1e-8" check, which was added in commit
586dc557 for unknown reasons.

gaussian() loses its filter parameter for some reason. (Well, who cares,
not my problem.)

The really awkward thing is that the text for hanning() and hamming()
does not change. In theory these functions are now based on Glumpy code,
but it seems like this can be neither proven nor denied. (The same
happened in some other cases with at least a few lines of code.)

sphinx() was added in commit 586dc557, and looks suspiciously like
sinc() as well. Replace the first 3 lines of the body with the ported
function (of which 2 lines do not change; the first uses code only in
mpv, and the second is just "return 1.0;"). The 4th line is only similar
on an abstract level (and that because of the mathematical relation
between these functions). Although the original sinc() was probably used
as template for it, with the other lines replaced, I don't think you
could make the claim that it falls under AGG copyright.

jinc() was added in commit 26baf5b9, but the code for it might be based
on sinc(). Rewrite it based on the "new" sinc(). Some of the same
remarks as with sphinx() apply.

cubic_bc() was ported from Glumpy's Mitchell(). (As far as I'm aware,
with the default parameters it's called "the" Mitchell-Netravali filter,
but in mpv this function is used to generate a whole group of filters.)

spline64() was added in commit a8b67c66, and was probably derived from
spline36(). Re-derive it from the "new" spline36().

triangle() could be considered derived from the original bilinear().
This is this in the original commit:

    static double bilinear(kernel *k, double x)
    {
        return 1.0 - x;
    }

This _might_ be based on AGG's image_filter_bilinear:

    struct image_filter_bilinear
    {
        static double radius() { return 1.0; }
        static double calc_weight(double x)
        {
            return 1.0 - x;
        }
    };

Considering that the "framework" was written by me, and the only part
from AGG taken is "return 1.0 - x;", and this part is trivial and was
later thoroughly replaced, this is probably not under the AGG copyright.

I'm hoping this doesn't introduce regressions. But the main focus is not
being productive anyway, and I didn't rigorously check unintended
changes in functionality.
2016-01-06 18:46:56 +01:00
..
cocoa
opengl vo_opengl: fix operation on GLES 2.0 2016-01-04 16:34:16 +01:00
wayland
win32 vo_opengl: win32: test for exclusive mode 2015-11-26 00:38:03 +11:00
aspect.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
aspect.h
bitmap_packer.c
bitmap_packer.h
cocoa_common.h
cocoa_common.m vo_opengl: cocoa: implement alpha window support 2015-12-19 10:24:03 +01:00
d3d_shader_420p.h
d3d_shader_nv12.h
d3d_shader_yuv.hlsl
dither.c
dither.h
drm_common.c drm: fix setting up connectors 2015-11-11 19:40:13 +01:00
drm_common.h vo_drm: use bool rather than integer return values 2015-11-08 15:00:15 +01:00
filter_kernels.c filter_kernels: replace AGG-based code 2016-01-06 18:46:56 +01:00
filter_kernels.h
vo_caca.c
vo_direct3d.c csputils: rename "yuv2rgb" functions 2015-12-09 00:23:36 +01:00
vo_drm.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
vo_image.c
vo_lavc.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
vo_null.c
vo_opengl_cb.c vo_opengl_cb: avoid NULL pointer deref in corner cases 2015-12-05 23:53:41 +01:00
vo_opengl.c vo_opengl: flip image if backend uses flipped rendering 2015-12-25 15:08:41 +01:00
vo_rpi.c vo_rpi: handle rotation 2016-01-05 14:48:27 +01:00
vo_sdl.c vo: get rid of vo_get_window_title() 2015-12-06 18:41:31 +01:00
vo_vaapi.c
vo_vdpau.c vo_opengl: disable interpolation without display-sync 2015-11-25 22:10:55 +01:00
vo_wayland.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
vo_x11.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
vo_xv.c
vo.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
vo.h vo: get rid of vo_get_window_title() 2015-12-06 18:41:31 +01:00
w32_common.c win32: add option to set VO MMCSS profile 2015-12-06 19:20:23 +01:00
w32_common.h
wayland_common.c wayland: fix typo in error message 2015-12-27 19:20:59 +01:00
wayland_common.h
win_state.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
win_state.h
x11_common.c x11: silence xdg-screensaver failure message 2016-01-03 15:50:00 +01:00
x11_common.h vo: get rid of vo_get_window_title() 2015-12-06 18:41:31 +01:00
x11_icon.bin