mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
76276c9210
Get rid of the old vf.c code. Replace it with a generic filtering framework, which can potentially handle more than just --vf. At least reimplementing --af with this code is planned. This changes some --vf semantics (including runtime behavior and the "vf" command). The most important ones are listed in interface-changes. vf_convert.c is renamed to f_swscale.c. It is now an internal filter that can not be inserted by the user manually. f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is conceptually easy, but a big mess due to the data flow changes). The existing filters are all changed heavily. The data flow of the new filter framework is different. Especially EOF handling changes - EOF is now a "frame" rather than a state, and must be passed through exactly once. Another major thing is that all filters must support dynamic format changes. The filter reconfig() function goes away. (This sounds complex, but since all filters need to handle EOF draining anyway, they can use the same code, and it removes the mess with reconfig() having to predict the output format, which completely breaks with libavfilter anyway.) In addition, there is no automatic format negotiation or conversion. libavfilter's primitive and insufficient API simply doesn't allow us to do this in a reasonable way. Instead, filters can use f_autoconvert as sub-filter, and tell it which formats they support. This filter will in turn add actual conversion filters, such as f_swscale, to perform necessary format changes. vf_vapoursynth.c uses the same basic principle of operation as before, but with worryingly different details in data flow. Still appears to work. The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are heavily changed. Fortunately, they all used refqueue.c, which is for sharing the data flow logic (especially for managing future/past surfaces and such). It turns out it can be used to factor out most of the data flow. Some of these filters accepted software input. Instead of having ad-hoc upload code in each filter, surface upload is now delegated to f_autoconvert, which can use f_hwupload to perform this. Exporting VO capabilities is still a big mess (mp_stream_info stuff). The D3D11 code drops the redundant image formats, and all code uses the hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a big mess for now. f_async_queue is unused.
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include "filter.h"
|
|
|
|
// A filter which uploads sw frames to hw. Ignores hw frames.
|
|
struct mp_hwupload {
|
|
struct mp_filter *f;
|
|
|
|
// Hardware wrapper format, e.g. IMGFMT_VAAPI.
|
|
int hw_imgfmt;
|
|
|
|
// List of supported underlying surface formats.
|
|
int *fmts;
|
|
int num_fmts;
|
|
// List of supported upload image formats. May contain duplicate entries
|
|
// (which should be ignored).
|
|
int *upload_fmts;
|
|
int num_upload_fmts;
|
|
// For fmts[n], fmt_upload_index[n] gives the index of the first supported
|
|
// upload format in upload_fmts[], and fmt_upload_num[n] gives the number
|
|
// of formats at this position.
|
|
int *fmt_upload_index;
|
|
int *fmt_upload_num;
|
|
};
|
|
|
|
struct mp_hwupload *mp_hwupload_create(struct mp_filter *parent, int hw_imgfmt);
|
|
|
|
// Return the best format suited for upload that is supported for a given input
|
|
// imgfmt. This returns the same as imgfmt if the format is natively supported,
|
|
// and otherwise a format that likely results in the least loss.
|
|
// Returns 0 if completely unsupported.
|
|
int mp_hwupload_find_upload_format(struct mp_hwupload *u, int imgfmt);
|