1
mirror of https://github.com/mpv-player/mpv synced 2024-11-07 01:47:00 +01:00
Commit Graph

17 Commits

Author SHA1 Message Date
wm4
4d47805a76 lavfi: fix warnings with newer libavfilter versions
Most likely will cause new warnings with avfilter_graph_alloc_filter()
on old libavfilter versions. Ingore that part.
2017-10-27 18:09:08 +02:00
wm4
1f593beeb4 audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).

The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.

Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.

For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.

Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 21:10:54 +02:00
wm4
f1d161d55f player: make --lavfi-complex changeable at runtime
Tends to be somewhat glitchy if subtitles are enabled, and you enable
and disable tracks.

On error, this will disable --lavfi-complex, which will result in
whatever behavior.
2017-08-12 23:10:40 +02:00
wm4
c391640645 player: fix --lavfi-complex freeze
Commit 0e0b87b6f3 fixed that dropped packets did not trigger further
work correctly. But it also made trivial --lavfi-complex freeze. The
reason is that the meaning if DATA_AGAIN was overloaded: the decoders
meant that they should be called again, while lavfi.c meant that other
outputs needed to be checked again. Rename the latter meaning to
DATA_STARVE, which means that the current input will deliver no more
data, until "other" work has been done (like reading other outputs, or
feeding input).

The decoders never return DATA_STARVE, because they don't get input from
the player core (instead, they get it from the demuxer directly, which
is why they still can return DATA_WAIT).

Also document the DATA_* semantics in the enum.

Fixes #4746.
2017-08-11 21:29:35 +02:00
wm4
992e582488 lavfi: temporary workaround for FFmpeg av_buffersrc_parameters_set() bug
The function ignores AVBufferSrcParameters.channel_layout. Set it
manually using the API.
2017-02-22 10:43:35 +01:00
wm4
e5df57c755 lavfi: support hwdec filters for --lavfi-complex
Not so important by itself, but important for when we replace the vf
libavfilter wrapper with the common implementation. (Which will
hopefully happen, but not too soon.)
2017-02-20 13:42:08 +01:00
wm4
134c9d9df5 lavfi: use AVBufferSrcParameters
It's nice that you don't have to create a parameter string anymore, but
the rest sure is complicated as hell.
2017-02-20 13:32:37 +01:00
wm4
fefc5a8f73 lavfi: use mp_image to store the filter pad format
Preparation for enabling hw filters. mp_image_params can't have an
AVHWFramesContext reference (because it can't hold any allocations, and
isn't meant to hold "active" data in the first place.

So just use a mp_image. It has all real data removed, because that would
essentially leak 1 frame once the decoder or renderer don't need it
anymore.
2017-02-20 13:15:50 +01:00
wm4
34b7d52317 lavfi: fix minor memory leak
The AVFrame in the tmp_frame field was never actually deallocated.

Since this AVFrame holds data temporarily only, and is unreferenced
immediately after use, there is actually no need to make it per-pad, so
simplify it a bit.

(There's also no real value in caching this tmp_frame at all, but I
guess it makes the control flow slightly simpler.)
2017-02-13 13:12:29 +01:00
wm4
f89ff14195 lavfi: cosmetics: more consistent variable naming 2017-02-09 11:33:04 +01:00
wm4
5085cf295f lavfi: slightly better disconnected output handling
If we have a disconnected output, read data only passively (and don't
cause input to be written). Otherwise, we're in danger of making
libavfilter queue too many frames on other outputs which are connected
to the same input, but don't read as quickly.

Also don't set pad->output_needed in this specific case, because it
would nonsensically make lavfi_process() return true, even if nothing is
going on.

This commit breaks if there is a simple filter chain with a connected
input, but a disconnected output, like

   --lavfi-complex='[aid1] copy [ao]'

and the audio output didn't initialize correctly. This will eventually
starve video as the audio packet queue get full (it will print a
warning, and then assume video EOF and exit).

But whatever.

Probably fixes #4118.
2017-02-08 20:29:38 +01:00
wm4
0c6c62cb17 lavfi: shut up false positive compiler warnings
As a positive side-effect, this also errors out gracefully for the
extremely unlikely but possible case certain builtin filters are not
available. (This could happen only with crippled libavfilter builds that
can't be used by anything using its public API.)
2016-04-26 19:38:51 +02:00
wm4
cf323d0cc1 lavfi: dump the filter graph
Especially useful to see what video formats are involved on the various
filter links.

I suspect this function is not available on Libav, so add necessary
ifdeffery preemptively.
2016-02-12 20:28:07 +01:00
wm4
ed6c04b1e5 lavfi: stop playback on some unrecoverable situations
Also improve the error message for the missing label case.
2016-02-10 22:01:16 +01:00
wm4
563b4785da lavfi: fix EOF case
This was dumb. Could make it burn 100% CPU and not exit at the end.
(Because it would retry as instructed, instead of terminating playback.)

It also needs to consider EOF as waiting for input. lavfi_process() will
decide if it's really EOF, or if further input might come in the future.
Without this, it'd would think that it does not need to wait for input,
i.e. that new input will be available immediately.

(Not so fond of the duplication of subtle logic.)
2016-02-06 19:13:32 +01:00
wm4
1661ba09eb lavfi: fix build on Libav
It doesn't provide this function. The code is not really designed to
work without it, so it will probably mess up big time, but at least
make it compile again.
2016-02-05 23:37:59 +01:00
wm4
c0de087ba1 player: add complex filter graph support
See --lavfi-complex option.

This is still quite rough. There's no support for dynamic configuration
of any kind. There are probably corner cases where playback might freeze
or burn 100% CPU (due to dataflow problems when interaction with
libavfilter).

Future possible plans might include:
- freely switch tracks by providing some sort of default track graph
  label
- automatically enabling audio visualization
- automatically mix audio or stack video when multiple tracks are
  selected at once (similar to how multiple sub tracks can be selected)
2016-02-05 23:19:56 +01:00