summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_lavfi.c
Commit message (Collapse)AuthorAgeFilesLines
* video: rewrite filtering glue codewm42018-01-301-517/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* vf_lavfi: remove old internal wrapper API stuffwm42017-11-291-92/+0
| | | | | This was for filters "redirecting" to vf_lavfi. All filters using it have been removed.
* Get rid of deprecated AVFrame accessorswm42017-10-301-1/+1
| | | | | | Fist we were required to use them for ABI compat. reasons (and other BS), now they're deprecated and we're supposed to access them directly again.
* vf_lavfi, af_lavfi: remove unused/deprecated includewm42017-04-051-1/+0
| | | | | Looks like Libav is going to drop it, unnecessarily making compilation fail.
* video: support positional arguments for automatic lavfi option bridgewm42017-04-031-1/+1
| | | | | | Now e.g. --vf=pad=1000:1000 works. All in all pretty ugly and hacky. Just look away.
* video: add automatic libavfilter bridge to option parsingwm42017-04-021-13/+81
| | | | | | | | | | Now you can for example do "--vf=hue=h=60" - there is no "hue" filter in mpv, so libavfilter's will be used. This has certain caveats (see manpage). The point of this is providing a relatively smooth transition path to removing our own filter stuff.
* vf_lavfi: don't crash with VOs without hardware decoding supportwm42017-01-251-5/+7
| | | | | | | | | When playing with VOs which do not provide mp_hwdec_ctx, vf->hwdec_devs will remain NULL. This would make it crash on hwdec_devices_get_first(), even if no hardware decoding or filters using hardware decoding were involved. Fixes #4064.
* build: replace some FFmpeg API checks with version checkswm42017-01-241-1/+1
| | | | | | The FFmpeg versions we support all have the APIs we were checking for. Only Libav missed them. Simplify this by explicitly checking for FFmpeg in the code, instead of trying to detect the presence of the API.
* video: support filtering hardware frames via libavfilterwm42017-01-161-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | Requires a bunch of hacks: - we access AVFilterLink.hw_frames_ctx. This is not a public API in FFmpeg and Libav. Newer FFmpeg provides an accessor (av_buffersink_get_hw_frames_ctx), but it's not available in Libav or the current FFmpeg release or Libav. We need this value after filter graph creation, so We have no choice but to access this. One alternative is making filter creation and format negotiation fully lazy (i.e. delay it and do it as filters are output), but this would be a huge change. So for now, we knowingly violate FFmpeg's and Libav's ABI and API constraints because they don't provide anything better. On newer FFmpeg, we use the (quite ugly) accessor, though. - mp_image_params doesn't (and can't) have a field for the frames context AVBufferRef. So we pass it via vf_set_proto_frame(), and even more hacks. - if a filter needs a hw context, but we haven't created one yet (because normally we create them lazily), it will fail at init. - we allow any hw format now, although this could go horrible wrong. Why all this effort? We could move hw deinterlacing filters etc. to FFmpeg, which is a very worthy goal.
* vf_lavfi: switch to AVBufferSrcParameterswm42017-01-161-7/+20
| | | | | | Instead of using the awful older "API" that passed the parameters formatted as string. AVBufferSrcParameters is also a prerequisite for hardware frame filtering support.
* vf_lavfi: remove pixel format whitelistwm42017-01-131-22/+2
| | | | Pointless now.
* af_lavfi, vf_lavfi: work around recent libavfilter EOF bugwm42017-01-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Looks quite like a bug. If you have a filter chain with only the dynaudnorm filter, and send call av_buffersrc_add_frame(s, NULL), then subsequent av_buffersink_get_frame() calls will return EAGAIN instead of EOF. This was apparently caused by a recent change in FFmpeg. Some other circumstances (which I didn't fully analyze and which is due to the playloop's absurd temporary-EOF behavior on seeks) then led the decoder loop to send data again, but since libavfilter was stuck in the EOF state now, it could never recover. It kept sending new input (due to missing output), until the demuxer refused to return more audio packets. Each time a filter error was printed. Fortunately, it's pretty easy to workaround. We just mark the p->eof flag as we send an EOF frame to libavfilter. The p->eof flag is used only to recover from temporary EOF: it resets the filter if new data is available again. We don't care much about av_buffersink_get_frame() returning a broken EAGAIN state in this situation and essentially ignore it, meaning if we get EAGAIN after sending EOF, we assume effectively that EOF was fully reached.
* af_lavfi, vf_lavfi: fix compilation on Libavwm42016-01-221-0/+1
| | | | It has no avfilter_graph_send_command().
* command: add vf-command commandwm42016-01-221-0/+8
|
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* video: switch from using display aspect to sample aspectwm42015-12-191-34/+7
| | | | | | | | | | | | | | | | MPlayer traditionally always used the display aspect ratio, e.g. 16:9, while FFmpeg uses the sample (aka pixel) aspect ratio. Both have a bunch of advantages and disadvantages. Actually, it seems using sample aspect ratio is generally nicer. The main reason for the change is making mpv closer to how FFmpeg works in order to make life easier. It's also nice that everything uses integer fractions instead of floats now (except --video-aspect option/property). Note that there is at least 1 user-visible change: vf_dsize now does not set the display size, only the display aspect ratio. This is because the image_params d_w/d_h fields did not just set the display aspect, but also the size (except in encoding mode).
* vf: remove old config() callbackwm42015-12-191-1/+0
|
* vf_lavfi: cosmetics: fix coding stylewm42015-09-111-11/+11
|
* vf_lavfi: drop useless option from wrapper filterswm42015-02-121-4/+1
| | | | | | | Filters which merely wrap libavfilter (for user-compatibility) like vf_gradfun had a "lavfi-enable" suboption, which could disable libavfilter usage. Since none of these filters has an internal implementation anymore, this was completely useless.
* video/filters: simplify libavfilter bridgewm42015-02-111-0/+1
| | | | | | | | | | Remove the confusing crap that allowed a filter using the libavfilter bridge to be compiled without libavfilter. Instead, compile the wrappers only if libavfilter is enabled at compile time. The only filter which still requires it is vf_stereo3d (unfortunately). Special-case this one. (The whole filter and how it interacts with lavfi is pure braindeath anyway.)
* video: remove vfcap.hwm42015-01-211-1/+1
| | | | | | | | | | | | | | | | | And remove all uses of the VFCAP_CSP_SUPPORTED* constants. This is supposed to reduce conversions if many filters are used (with many incompatible pixel formats), and also for preferring the VO's natively supported pixel formats (as opposed to conversion). This is worthless by now. Not only do the main VOs not use software conversion, but also the way vf_lavfi and libavfilter work mostly break the way the old MPlayer mechanism worked. Other important filters like vf_vapoursynth do not support "proper" format negotation either. Part of this was already removed with the vf_scale cleanup from today. While I'm touching every single VO, also fix the query_format argument (it's not a FourCC anymore).
* vf_lavfi: proper rounding for lavfi->mpv aspect ratiowm42014-10-091-2/+3
| | | | Or so I think. Not like it matters anyway.
* vf_lavfi: make chaining from other filters more flexiblewm42014-09-271-18/+29
| | | | | | | | | Some filters exists only to create a specific lavfi graph. Allow these filters to reset the graph exactly on reconfig, and allow them to modify some image parameters too. Also make vf_lw_update_graph() behave like vf_lw_set_graph() - they had a subtitle difference with filter==NULL. Useful for the following commit.
* vf_lavfi: fetch output frames incrementallywm42014-09-181-22/+24
| | | | | | | Uses the new mechanism introduced in the previous commit. Depending on the actual filter, this distributes CPU load more evenly over time, although it probably doesn't matter.
* Improve setting AVOptionswm42014-08-021-9/+6
| | | | | | | | Use OPT_KEYVALUELIST() for all places where AVOptions are directly set from mpv command line options. This allows escaping values, better diagnostics (also no more "pal"), and somehow reduces code size. Remove the old crappy option parser (av_opts.c).
* video: introduce failure path for image allocationswm42014-06-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, failure to allocate image data resulted in a crash (i.e. abort() was called). This was intentional, because it's pretty silly to degrade playback, and in almost all situations, the OOM will probably kill you anyway. (And then there's the standard Linux overcommit behavior, which also will kill you at some point.) But I changed my opinion, so here we go. This change does not affect _all_ memory allocations, just image data. Now in most failure cases, the output will just be skipped. For video filters, this coincidentally means that failure is treated as EOF (because the playback core assumes EOF if nothing comes out of the video filter chain). In other situations, output might be in some way degraded, like skipping frames, not scaling OSD, and such. Functions whose return values changed semantics: mp_image_alloc mp_image_new_copy mp_image_new_ref mp_image_make_writeable mp_image_setrefp mp_image_to_av_frame_and_unref mp_image_from_av_frame mp_image_new_external_ref mp_image_new_custom_ref mp_image_pool_make_writeable mp_image_pool_get mp_image_pool_new_copy mp_vdpau_mixed_frame_create vf_alloc_out_image vf_make_out_image_writeable glGetWindowScreenshot
* vf_lavfi: reinit after libavfilter EOFwm42014-05-021-13/+25
| | | | | | Basically, if we feed the filter a new image even after the EOF state has been reached (e.g. because the input stream "recovered"), we want the filter to restart, instead of returning an error forever.
* vf_lavfi: reset metadata in reset()Kevin Mitchell2014-04-291-0/+4
| | | | | | It might have been nice not to do this so that metadata could accumulate accross seeks, but it seems libavfilter looses its copy anyway on recreate_graph.
* vf-metadata: fix handling of NULL metadataKevin Mitchell2014-04-291-4/+7
| | | | | | lavfi would segfault due to a NULL dereference if it was asked for its metadata and none had been allocated (oops). This happens for libav which has no concept of filter metadata.
* vf_lavfi: distinguish real errors from other stateswm42014-04-281-2/+11
| | | | Don't just hide real errors, should a filter return them.
* video: don't drop last frame when deinterlacing with yadifwm42014-04-281-0/+2
| | | | | | | | | | | | | | | | | | Or in other words, add support for properly draining remaining frames from video filters. vf_yadif is buffering at least one frame, and the buffered frame was not retrieved on EOF. For most filters, ignore this for now, and just adjust them to the changed semantics of filter_ext. But for vf_lavfi (used by vf_yadif), real support is implemented. libavfilter handles this simply by passing a NULL frame to av_buffersrc_add_frame(), so we just have to make mp_to_av() handle NULL arguments. In load_next_vo_frame(), we first try to output a frame buffered in the VO, then the filter, and then (if EOF is reached and there's still no new frame) the VO again, with draining enabled. I guess this was implemented slightly incorrectly before, because the filter chain still could have had remaining output frames.
* vf_rotate: support all multiples of 90 degreeswm42014-04-211-2/+3
| | | | | | | | | | | | | This couldn't rotate by 180°. Add this, and also make the parameter in degrees, instead of magic numbers. For now, drop the flipping stuff. You can still flip with --vf=flip or --vf=mirror. Drop the landscape/portrait stuff - I think this is something almost nobody will use. If it turns out that we need some of these things, they can be readded later. Make it use libavfilter. Its vf_transpose implementation looks pretty simple, except that it uses slice threading and should be much faster.
* vf_lavfi: copy AVFrame metadata into vf_lavfi privKevin Mitchell2014-04-131-0/+20
| | | | | | | | store it as mp_tas and add VFCTRL_GET_METADATA to access it from elsewhere Signed-off-by: wm4 <wm4@nowhere> old-configure test by wm4.
* vf_lavfi: fix ffmpeg deprecation warning for avfilter_graph_parseKevin Mitchell2014-04-131-1/+1
| | | | use avfilter_graph_parse_ptr for ffmpeg
* Remove some more unneeded version checkswm42014-03-161-12/+2
| | | | | All of these check against things that happened before the latest supported FFmpeg/Libav release.
* m_option: add mp_log context to sub-module print_help callbackwm42013-12-211-7/+5
|
* video/filter: mp_msg conversionswm42013-12-211-5/+5
|
* vf_lavfi: don't access AVFilterPad directlywm42013-12-181-2/+3
| | | | Direct access is deprecated.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* video/filter: make vf->control non-recursivewm42013-12-071-2/+2
| | | | | | Reason: I never liked it being recursive. Generally, this seems to cause more problems than trouble, and is less flexible for access outside of the chain.
* vf: remove flags from filter format statuswm42013-12-071-3/+2
| | | | | | | | I don't think we need these flags anymore. Simplify the code and get rid of the vf_format struct. There still is the vf_format.configured field, but this can be replaced by checking for a valid image format.
* video/filter: remove legacy option handling hackswm42013-12-041-2/+2
| | | | | | | | | All filters now either use the generic option parser, or don't have options. This finally finishes a transition started in 2003 (see git commit 33b62af94760186c). Why are MPlayer devs so monumentally lazy? Sorry, but this takes the cake. You had 10 years.
* vf_lavfi: export a wrapper functionwm42013-12-041-6/+112
| | | | | | | | | | | This will allow old filter to run libavfilter instead by calling vf_lw_set_graph(), which turns the filter into a wrapper, using a given libavfilter graph. Later commits use that to automatically "reroute" a bunch of filters to libavfilter. We want to get rid of the old MPlayer filter code, because it's bad an unmaintained, but we still don't want to force everyone to use vf_lavfi, so this solution will do for a while.
* options: print lavfi filter list with --vf=lavfi=helpwm42013-11-231-0/+40
|
* video/filter: remove useless vf_info fieldswm42013-10-231-5/+3
| | | | | This time I didn't bother to move the contents of the author field to the file headers. "git log" is your friend.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-3/+3
| | | | Followup commit. Fixes all the files references.
* Fix some -Wshadow warningswm42013-07-231-1/+1
| | | | | | In general, this warning can hint to actual bugs. We don't enable it yet, because it would conflict with some unmerged code, and we should check with clang too (this commit was done by testing with gcc).
* options: use m_config for options instead of m_structwm42013-07-211-14/+7
| | | | | | | | | | | | | | | | | | For some reason, both m_config and m_struct are somewhat similar, except that m_config is much more powerful. m_config is used for VOs and some other things, so to unify them. We plan to kick out m_struct and use m_config for everything. (Unfortunately, m_config is also a bit more bloated, so this commit isn't all that great, but it will allow to reduce the option parser mess somewhat.) This commit also switches all video filters to use the option macros. One reason is that m_struct and m_config, even though they both use m_option, store the offsets of the option fields differently (sigh...), meaning the options defined for either are incompatible. It's easier to switch everything in one go. This commit will allow using the -vf option parser for other things, like VOs and AOs.
* video: add a new method to configure filters and VOswm42013-06-281-2/+2
| | | | | | | | | | | | | | | | | | The filter chain and the video ouputs have config() functions. They are strictly limited to transfering the video size and format. Other parameters (like color levels) have to be transferred separately. Improve upon this by introducing a separate set of reconfig() functions, which use mp_image_params to carry format parameters. This struct contains all image format related parameters from config(), plus additional parameters such as colorspace. Change vf_rotate to use it, as well as vo_opengl. vf_rotate is just an example/test case, but vo_opengl will need it later. The intention is also to get rid of VOCTRL_SET_YUV_COLORSPACE. This information is now handed to the VOs via reconfig(). The getter, VOCTRL_GET_YUV_COLORSPACE, will still be needed though.
* vf_lavfi: allow setting avoptswm42013-05-261-0/+9
|
* vf_lavfi: remove redundant statementswm42013-05-211-4/+0
|
* video/filter: fix option parser memory leakwm42013-05-181-1/+0
| | | | | | | This happens only if an option actually allocates memory (like strings). Change filter API such that vf->priv is free'd by vf.c instead by the filters. vf.c will free the option values as well.
* vf_lavfi: move compat crap to the start of the filewm42013-04-261-18/+18
|
* vf_lavfi: silence stupid deprecation warningwm42013-04-261-2/+12
| | | | | | |