Commit Graph

438 Commits

Author SHA1 Message Date
wm4 385e1ccbce vf_vapoursynth: don't error if invoke() doesn't return a clip
Not all functions are for creating filters. Consider for example
LoadPlugin.
2014-10-12 20:25:25 +02:00
wm4 7b0c58ab49 vf_vapoursynth: resolve paths relative to home/config
This affects the script filename passed to the filter. Resolve "~" (and
some other variants) as described in the "Paths" section of mpv.rst.
2014-10-12 20:24:20 +02:00
wm4 3093d93e1f vf_vapoursynth: add standalone Lua scripting 2014-10-12 01:33:10 +02:00
wm4 1b4f51ae73 vf_vapoursynth: abstract scripting backend
In theory, vsscript should be doing it, but it's not there yet, neither
did there seem to be any interest in making it flexible enough to handle
more than 1 scripting language.
2014-10-12 01:33:09 +02:00
wm4 227e470ee2 vf_vapoursynth: return dummy frames if frames are requested during init
An attempt at fixing #1168.

I see black frames flashing, so it's certainly not perfect.
2014-10-11 18:17:20 +02:00
wm4 46b16cf206 vf_vapoursynth: factor stuff 2014-10-11 18:16:09 +02:00
wm4 54e2ca809c vf_vapoursynth: when seeking, recreate only if it's already created 2014-10-11 18:15:38 +02:00
wm4 ab41b8d27b vf_vapoursynth: fail gracefully if filter init requests frames
Some VS filters will requests frames from their parent filters while
they're initialized. Thy do this in a blocking manner, and
initialization will not succeed until the frame request is satisfied.
This deadlocked mpv, because we can feed frames to the filter only after
initialization is finished.

Return an error instead of deadlocking.

Note that we (probably) can handle frames being requested during init
fine, as long as the requests don't block initialization. But we can
distinguish this situation, and a simple test seems to indicate VS
usually doesn't do this.

See #1168.
2014-10-11 13:25:38 +02:00
wm4 fef9ea5f62 vf_lavfi: proper rounding for lavfi->mpv aspect ratio
Or so I think. Not like it matters anyway.
2014-10-09 18:18:05 +02:00
wm4 014547bdc2 vf_lavfi: fix compilation failure
Apparently this fails to compile with clang6. Patch by someone else.

CC: @mpv-player/stable
2014-10-08 12:44:47 +02:00
Alessandro Ghedini d02275d35a vf_stereo3d: fix "auto" input format with libav 2014-10-04 16:28:30 +02:00
wm4 aeaa1767e9 Fix build with libavfilter disabled
Although I'm not sure why we even support this.
2014-09-28 19:10:50 +02:00
wm4 cdb25d5a21 video: change automatic rotation and 3D filter insertion
We inserted these filters with fixed parameters, which was ok. But this
also didn't change image parameters for the filters down the filter
chain and the VO. For example, if rotation by 90° was requested by the
file, we would insert a filter and rotate the video, but the VO would
still receive image parameters that direct rotation by 90°.

This wasn't a problem, but it could become one.

Fix this by letting the filters automatically pick up the image params.
The image params are reset on application. (We could probably also
always try to apply and reset image params in a filter, instead of
having special "auto" parameters. This would probably work, and video.c
would insert a "rotate=0" filter. But I'm afraid this would be confusing
and the current solution is cosmetically slightly nicer.)

Unfortunately, the vf_stereo3d.c change turned out a big mess, but once
the "internal" filter is fully replaced with libavfilter, most of this
can be radically simplified.
2014-09-27 18:31:59 +02:00
wm4 0ec6df2ddf vf_lavfi: make chaining from other filters more flexible
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.
2014-09-27 17:21:29 +02:00
wm4 debbff76f9 Remove mpbswap.h
This was once central, but now it's almost unused. Only vf_divtc still
uses it for extremely weird and incomprehensible reasons. The use in
stream.c is trivial. Replace these, and remove mpbswap.h.
2014-09-25 21:32:55 +02:00
wm4 1f4a74cbed vf_vapoursynth: make it possible to get filter output incrementally
Until now, we always required the playback core to decode a new frame to
get more output from the filter. That seems to be completely
unnecessary, because filtered results may arrive before that.

Add a filter_out callback, and restructure the code such that it can
return any filtered frames, or block if it hasn't read at least one
frame.

In the worst case, it still can happen that bursts of input requests and
output requests happen. (This commit tries to reduce burst-like
behavior, but it's not entirely possible due to the indeterministic
nature of VS threading.)

This is a similar change as with 95bb0bb6.
2014-09-23 00:35:57 +02:00
wm4 95bb0bb671 vf_lavfi: fetch output frames incrementally
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.
2014-09-18 19:36:55 +02:00
wm4 580cf433bd video/filter: allow better dataflow
Consider a filter which turns 1 frame into 2 frames (such as an
deinterlacer). Until now, we forced filters to produce all output frames
at once. This was done for simplicity.

Change the filter API such that a filter can produce frames
incrementally.
2014-09-18 19:36:27 +02:00
wm4 8599c959fe video: initial Matroska 3D support
This inserts an automatic conversion filter if a Matroska file is marked
as 3D (StereoMode element). The basic idea is similar to video rotation
and colorspace handling: the 3D mode is added as a property to the video
params. Depending on this property, a video filter can be inserted.

As of this commit, extending mp_image_params is actually completely
unnecessary - but the idea is that it will make it easier to integrate
with VOs supporting stereo 3D mogrification. Although vo_opengl does
support some stereo rendering, it didn't support the mode my sample file
used, so I'll leave that part for later.

Not that most mappings from Matroska mode to vf_stereo3d mode are
probably wrong, and some are missing.

Assuming that Matroska modes, and vf_stereo3d in modes, and out modes
are all the same might be an oversimplification - we'll see.

See issue #1045.
2014-08-30 23:24:46 +02:00
shdown 730d94741c vf_softpulldown: handle null mpi_image correctly
Check if mpi is NULL before accessing mpi->fields.
2014-08-30 15:15:38 +02:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
bstr.c doesn't really deserve its own directory, and compat had just
a few files, most of which may as well be in osdep. There isn't really
any justification for these extra directories, so get rid of them.

The compat/libav.h was empty - just delete it. We changed our approach
to API compatibility, and will likely not need it anymore.
2014-08-29 12:31:52 +02:00
Bin Jin 1e12afa80a vf_vapoursynth: add more VS frame properties
Add the missing frame properties in 48587e88.
2014-08-22 14:22:06 +02:00
Bin Jin 96c2021cb1 vf_vapoursynth: add display resolution support
Add two new script environment variables 'video_in_dw' and
'video_in_dh', representing the display resolution of video. Along
with video resolution, sample ratio aspect can be calculated in
scripts.

Currently it's impossible to change sample ratio aspect with single
vapoursynth filter since '_SARNum' and '_SARDen' frame properties
from output clip will be ignored. A following 'dsize' filter is
necessary for this purpose.
2014-08-22 14:22:04 +02:00
wm4 beceb2fedc vf_vapoursynth: print more diagnostics on error 2014-08-11 21:57:15 +02:00
wm4 d68a759fa4 Improve setting AVOptions
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).
2014-08-02 03:12:33 +02:00
wm4 f8ab732ac3 video/filter: add vf_buffer
Mostly useful for debugging.
2014-07-30 23:29:00 +02:00
wm4 417ffa8b40 Remove some mp_msg calls with no trailing \n
The final goal is all mp_msg calls produce complete lines. We want this
because otherwise, race conditions could corrupt the terminal output,
and it's inconvenient for the client API too. This commit works towards
this goal. There's still code that has this not fixed yet, though.
2014-07-13 20:12:13 +02:00
wm4 6fcb34d887 vf_vapoursynth: reset error state on seeking
When seeking, we violently destroy the filter, because vapoursynth has
no proper API for terminating a video with unknown frame count. This
looks like an error to vapoursynth, and the error is returned via the
frame callbacks. The bug is that we remember this error state across
reinitialization, so on the first filter call after reinitialization, we
thought filtering the current frame failed. This caused a shift by 1
frame on each seek.

CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
Marcoen Hirschberg c4f518f132 vf_dlopen: fix the order of the arguments to mp_image_alloc 2014-06-19 23:07:02 +02:00
wm4 a28e2a7432 video: correct spelling: mp_image_params_equals -> mp_image_params_equal
The type is struct mp_image_params, so the "params" should have a "s".
"equals" shouldn't, because it's plural for 2 params. Important.
2014-06-17 23:30:27 +02:00
wm4 d107cae0e7 video: check image parameters
Make sure every video filter has valid parameters for input and output.
(This also ensures we don't take possibly invalid decoder output, or
feed invalid decodr/filter output to VOs.)

Also, the updated image size check now (almost) works like the
corresponding check in FFmpeg.
2014-06-17 22:44:13 +02:00
wm4 72aac9ae8a video: introduce failure path for image allocations
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
2014-06-17 22:43:43 +02:00
wm4 a9538e17ad video: synchronize mpv rgb pixel format names with ffmpeg names
This affects packed RGB formats up to 16 bits per pixel. The old mplayer
names used LSB-to-MSB order, while FFmpeg (and some other libraries) use
MSB-to-LSB.

Nothing should change with this commit, i.e. no bit order or endian bugs
should be added or fixed. In some cases, the name stays the same, even
though the byte order changes, e.g. RGB8->BGR8 and BGR8->RGB8, and this
affects the user-visible names too; this might cause confusion.
2014-06-14 10:03:04 +02:00
wm4 6ab72f9760 video: automatically strip "le" and "be" suffix from pixle format names
These suffixes are annoying when they're redundant, so strip them
automatically. On little endian machines, always strip the "le" suffix,
and on big endian machines vice versa (although I don't think anyone
ever tried to run mpv on a big endian machine).

Since pixel format strings are returned by a certain function and we
can't just change static strings, use a trick to pass a stack buffer
transparently. But this also means the string can't be permanently
stored by the caller, so vf_dlopen.c has to be updated. There seems
to be no other case where this is done, though.
2014-06-14 09:58:48 +02:00
wm4 e34e1080d2 vf_noise: remove global variables 2014-06-11 00:39:14 +02:00
wm4 e9391e5827 vf_divtc: remove a global variable 2014-06-11 00:39:14 +02:00
wm4 99f5fef0ea Add more const
While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
2014-06-11 00:39:14 +02:00
wm4 fd5207f56d options: remove global variables for swscale options; rename them
Additionally to removing the global variables, this makes the options
more uniform. --ssf-... becomes --sws-..., and --sws becomes --sws-
scaler. For --sws-scaler, use choices instead of magic integer values.
2014-06-11 00:39:13 +02:00
wm4 ba1447822c vf_vdpaupp: cosmetics: rename function 2014-05-25 16:01:33 +02:00
Kevin Mitchell 2b1b8d6c95 vf_dlopen: update usage message to new-style args 2014-05-15 10:32:16 -07:00
Kevin Mitchell 125dcf306a vf_dlopen: remove buggy private name -> imgfmt conversion
This was presumably for backward compatibility,
but it was preventing the use of the new names.
2014-05-15 10:32:16 -07:00
wm4 0128579542 vf_vapoursynth: fix debug output 2014-05-15 16:59:26 +02:00
wm4 97604ebcd2 vf_vapoursynth: add more debug output
Also, move num_requested() to where it's used. Remove newlines from VS
error messages. Remove an assert(0) on an error path.
2014-05-15 14:50:35 +02:00
wm4 daf4898668 vf_vapoursynth: avoid unnecessary waiting
It could in theory happen that the filter loop will enter a blocking
wait, even though it could make progress by emptying the list of
already-filtered images. I'm not quite sure if this could actually cause
a real issue - probably not.
2014-05-14 21:02:56 +02:00
wm4 bc6959c35d vf_vapoursynth: allow parallel processing
VapourSynth won't just filter multiple frames at once on its own. You
have to request multiple frames at once manually. This is what this
commit introduces: a sub-option controls how many frames will be
requested at once. This also changes the semantics of the maxbuffer sub-
option, now renamed to buffered-frames.
2014-05-14 20:42:04 +02:00
wm4 70ffbbe927 vf: print for which filter initialization failed 2014-05-04 16:07:43 +02:00
wm4 f5a564d417 vf_vdpaupp: make code clarity improvements
This shouldn't change anything functionally, except that it buffers 1
frame less in the first-field deinterlacing mode.
2014-05-04 11:03:21 +02:00
wm4 a7fe47e495 vdpau: deduplicate video surface upload code
This was a minor code duplication between vf_vdpaupp.c and vo_vdpau.c.

(In theory, we could always require using vf_vdpaupp with vo_vdpau, but
I think it's better if vo_vdpau can work standalone.)
2014-05-04 10:51:14 +02:00
wm4 bc07c86da5 vf_vapoursynth: fix aspect ratio passed to vapoursynth
This was recently either changed or clarified in vapoursynth.

Pass the aspect ratio as pixel aspect to VS.
2014-05-03 15:17:13 +02:00
wm4 33a945cc7e video: removed unused stuff 2014-05-02 14:48:52 +02:00
wm4 50ebcf1a43 video: handle colorspace and aspect overrides separately
Now the video filter code handles these explicitly, which should
increase robustness (or at least find bugs earlier).
2014-05-02 01:09:55 +02:00
wm4 f4eaceee0f vf: sanitize filter input, instead of overriding it
vf_fix_img_params() takes care of overwriting image parameters that are
normally not set correctly by filters. But this makes no sense for input
images. So instead, check that the input is correct.

It still has to be done for the first input image, because that's used
to handle some overrides (see video_reconfig_filters()).
2014-05-02 01:09:03 +02:00
wm4 4049532501 vf: add alternate functions for retrieving filter output
These replace vf_read_output_frame(), although we still emulate that
function. This change is preparation for another commit (and this is
basically just to reduce the diff and signal/noise ratio in that
commit).
2014-05-02 01:08:06 +02:00
wm4 9243249a0e vf: expose input parameters; clear parameters on failure
Preparation (and simplification) for following commits.
2014-05-02 01:08:05 +02:00
wm4 2a9b1d19ba vf: mark auto-inserted conversion filters in verbose output
Nota that this flag is not set for other auto-inserted filters (like
deinterlacing or rotation).
2014-05-02 01:08:05 +02:00
wm4 ffde8083f6 vf_lavfi: reinit after libavfilter EOF
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.
2014-05-02 01:08:05 +02:00
wm4 50538c0ea2 vf_vdpaupp: always provide past and future fields
Some non-deinterlacing filters (potentially denoising) also use
additional frames for filtering. The vdpau docs suggest providing at
least 1 future and 2 past _fields_, which means we need to provide 1
past frame (the future field is already the other field of the current
field, and both fields are in the same frame).

We can easily achieve this by buffering an additional frame in the non-
deint case.
2014-05-02 01:08:05 +02:00
wm4 1efb5fd465 vf_vdpaupp: allow toggling deinterlace
Basically makes the 'D' key work again. (But only if the filter is
already inserted.)
2014-05-02 01:08:04 +02:00
wm4 073ee146ea vf_vdpaupp: allow non-vdpau input
So you can use vdpau deinterlacing without using vdpau hardware
decoding.

vf_vavpp does something similar.
2014-05-02 01:08:04 +02:00
wm4 ec60669cd1 vdpau: add a postprocessing pseudo-filter
This factors out some code from vo_vdpau.c, especially deinterlacing
handling. The intention is to use this for vo_vdpau.c to make the logic
significantly easier, and to use it for vo_opengl (gl_hwdec_vdpau.c) to
allow selecting deinterlace and postprocessing modes.

As of this commit, the filter actually does nothing, since both vo_vdpau
and vo_opengl treat the generated images as normal vdpau images. This
will change in the following commits.
2014-05-02 01:08:02 +02:00
wm4 3f0f666d14 vf: print error if filtering a frame fails
The filters don't always print an error on their own, and printing an
error is better than silently dropping the frame.
2014-04-30 22:19:38 +02:00
Kevin Mitchell 479dab5718 vf_lavfi: reset metadata in reset()
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.
2014-04-29 08:31:44 -07:00
Kevin Mitchell e3e565c194 vf-metadata: fix handling of NULL metadata
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.
2014-04-29 08:31:44 -07:00
wm4 48587e88e0 vf_vapoursynth: add more VS frame properties
We only support them for input. The frame properties of output frames
are ignored (except frame durations).

Properties not set for now: _ChromaLocation, _Field, _FieldBased
2014-04-28 23:44:57 +02:00
wm4 6b0b8368a4 vf_vapoursynth: use frame durations instead of _AbsoluteTime
Set _DurationNum/_DurationDen on each VS frame, instead of
_AbsoluteTime. The duration is the difference between the timestamp of
the frame and the next frame, and when receiving filtered VS frames, we
convert them back to an absolute PTS by summing them.

We pass the timestamps with microsecond resolution. mpv uses double for
timestamps internally, so we don't know the "real" timebase or FPS. VS
on the other hand uses fractions for frame durations. We can't pass
through the numbers exactly, but microseconds ought to be enough to be
even safe from accumulating rounding errors.
2014-04-28 22:23:32 +02:00
wm4 062d5eea3b vf_vapoursynth: fix memory leak on error
Since this leaks video images, and the player keeps feeding new images
to the fitler even if it fails, this would probably have disastrous
consequences.
2014-04-28 22:23:32 +02:00
wm4 dffb7c2409 vf_vapoursynth: remove incorrect copyright notice
This file merely started out by copy&pasting vf_lavfi.c and removing
everything to have a basic skeleton.
2014-04-28 22:23:32 +02:00
wm4 f39e4210f7 vf_lavfi: distinguish real errors from other states
Don't just hide real errors, should a filter return them.
2014-04-28 22:23:31 +02:00
wm4 42f65ce108 video: don't drop last frame when deinterlacing with yadif
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.
2014-04-28 22:23:31 +02:00
wm4 b20416abe3 vf_vapoursynth: use official AbsoluteTime property
I thought the "_" in "_AbsoluteTime" was part of the documentation
markup.

This still doesn't help us with VS filters that change timing;
apparently you must use frame durations instead.
2014-04-27 22:16:56 +02:00
wm4 9e47bd11cc vf_vapoursynth: keep pixel aspect ratio
Make the filter apply the pixel aspect ratio of the input to the output.
This is more useful than forcing 1:1 PAR when playing anamorphic video
such as DVDs.

VapourSynth itself actually allows passing through the aspect ratio, but
it's in a not very useful form for us: it's per video-frame instead of
constant (i.e in VSVideoInfo). As long as we don't have a way to allow a
filter to spontaneously change output parameters, we can't use this.
(And I don't really feel like making this possible.)
2014-04-27 17:05:26 +02:00
wm4 40c517cc41 vf_pp: PP_PICT_TYPE_QP2 is always defined 2014-04-25 19:21:17 +02:00
wm4 dd39b47f7c vf: print all image parameter information in verbose output 2014-04-22 01:42:57 +02:00
wm4 ba1380223a vf: remove autoinserted filters on reconfig
When using rotation with hw decoding, and the VO does not support
rotation, vf_rotate is attempted to be inserted. This will go wrong, and
after that it can't recover because a vf_scale filter was autoinserted.
Just removing all autoinserted filters before reconfig fixes this.
2014-04-21 02:57:17 +02:00
wm4 f69312e329 vf: add function to remove a filter from the chain 2014-04-21 02:57:16 +02:00
wm4 5e4e248dc2 video: make mp_image use mp_image_params directly
Minor cleanup, so that we can stuff more information into
mp_image_params later.
2014-04-21 02:57:16 +02:00
wm4 44096073e9 vf_rotate: support all multiples of 90 degrees
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.
2014-04-21 02:56:48 +02:00
wm4 85998f6121 Fix some libav* include statements
Fix all include statements of the form:

   #include "libav.../..."

These come from MPlayer times, when FFmpeg was somehow part of the
MPlayer build tree, and this form was needed to prefer the local files
over system FFmpeg.

In some cases, the include statement wasn't needed or could be replaced
with mpv defined symbols.
2014-04-19 17:18:10 +02:00
wm4 0cff5836c3 Remove CPU detection and inline asm handling
Not needed anymore. I'm not opposed to having asm, but inline asm is too
much of a pain, and it was planned long ago to eventually get rid fo all
inline asm uses.

For the note, the inline asm use that was removed with the previous
commits was almost worthless. It was confined to video filters, and most
video filtering is now done with libavfilter. Some mpv filters (like
vf_pullup) actually redirect to libavfilter if possible.

If asm is added in the future, it should happen in the form of external
files.
2014-04-19 17:10:56 +02:00
wm4 061c7eba97 vf_pp: fix include statement 2014-04-19 17:10:20 +02:00
wm4 c56b1f2d90 vf_pp: use native libpostproc CPU detection 2014-04-19 17:10:20 +02:00
wm4 60fbce16bb vf_divtc: remove inline asm
Becomes a bit slower (tested with progressive solid color video only),
but this filter is pretty obscure and I'm not even sure what it's useful
for.
2014-04-19 17:10:20 +02:00
wm4 d0ebecb1c4 vf_pullup: remove inline asm
No change in speed (or even slightly faster, though I tested with
progressive solid color video only), and normally we use libavformat's
vf_pullup anyway.
2014-04-19 17:10:20 +02:00
wm4 d55ed011ab vf_noise: remove line asm
I didn't test the speed, but by default, this filter diverts to
libavfilter already. So this would help only if libavfilter is disabled,
or libavfilter doesn't have vf_noise (like on Libav). For these cases,
we still provide the (possibly but not necessarily) slower C
implementation of vf_noise.
2014-04-19 15:50:52 +02:00
wm4 b69c835945 vf_ilpack: remove inline asm
This makes it multiple times slower. However, the output format (packed
YUV) isn't handled efficiently by anything to begin with, and I have no
clue we even have this filter. I guess it's one of these filters which
find some use sometimes, but are not of higher importance, which
justifies removing the faster inline asm.
2014-04-19 15:48:30 +02:00
wm4 c4f5dc0d53 vf_eq: remove slow inline asm
Compiled with -O2, the C code runs just as far (or even slightly faster)
then the MMX inline asm.
2014-04-19 15:38:04 +02:00
wm4 e1f1b0c275 vf_vapoursynth: handle destruction more gracefully
We were relying on vsscript_freeScript() to take care of proper
termination. But it doesn't do that: it doesn't wait for the filters to
finish and exit at all. Instead, it just destroys all objects, which
causes the worker threads to crash sometimes.

Also, we're supposed to wait for the frame callback to finish before
freeing the associated node.

Handle this by explicitly waiting as far as we can. Probably fixes
crashes on seeking, although VapourSynth itself might also need some
work to make this case completely stable.
2014-04-14 20:51:27 +02:00
wm4 7178257bb6 vf_vapoursynth: wipe vapoursynth state completely on reloading
Before this commit, the filter attempted to keep the vsscript state
(p->se) even when the script was reloaded. Change it to destroy the
script state too on reloading. Now no workaround for LoadPlugin is
necessary, and this also fixes a weird theoretical race condition when
destroying and recreating the mpv source filter.
2014-04-14 18:03:13 +02:00
wm4 78128bddda Kill all tabs
I hate tabs.

This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
2014-04-13 18:03:01 +02:00
Kevin Mitchell f09134b76d vf_lavfi: copy AVFrame metadata into vf_lavfi priv
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.
2014-04-13 18:03:01 +02:00
Kevin Mitchell 0a278f92e6 vf_lavfi: fix ffmpeg deprecation warning for avfilter_graph_parse
use avfilter_graph_parse_ptr for ffmpeg
2014-04-13 18:03:01 +02:00
Kevin Mitchell 7305140a8a vf: auto-label video filters if no label is specified
Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 18:03:01 +02:00
Kevin Mitchell 7ae2eb8e2c vf: add vf_control_by_label to send vfctrl to specific filter 2014-04-13 18:03:01 +02:00
wm4 7ded55f667 vf_vapoursynth: print an error if VapourSynth returns an unknown format
Apparently there is no real format negotiation, so this can actually
happen.
2014-04-13 12:30:57 +02:00
wm4 8161f4374c vf_vapoursynth: error out early if the file sub-option is not set
Instead of crashing by possibly passing a NULL pointer to VapourSynth.
2014-04-13 12:29:40 +02:00
wm4 33f822b715 video: add VapourSynth filter bridge
Mainly meant to apply simple VapourSynth filters to video at runtime.
This has various restrictions, which are listed in the manpage.

Additionally, this actually copies video frames when converting frame
references from mpv to VapourSynth, and a second time when going from
VapourSynth to mpv. This is inefficient and could probably be easily
improved. But for now, this is simpler, and in fact I'm not sure if
we even can references VapourSynth frames after the core has been
destroyed.
2014-04-12 19:31:50 +02:00
wm4 9db08cf53b vf_eq: don't malloc priv struct
There wasn't any reason for this. In fact, it's a memory leak. The
proper priv struct is already allocated vf.c and the option parser.
2014-03-30 10:19:02 +02:00
wm4 49d13f76ca vaapi: make struct va_surface private
It's not really needed to be public. Other code can just use mp_image.
The only disadvantage is that the other code needs to call an accessor
to get the VASurfaceID.
2014-03-17 18:22:35 +01:00
wm4 31fc5e8563 vaapi: replace image pool implementation with mp_image_pool
Although I at first thought it would be better to have a separate
implementation for hwaccels because the difference to software images
are too large, it turns out you can actually save some code with it.

Note that the old implementation had a small memory management bug. This
got painted over in commit 269c1e1, but is hereby solved properly.

Also note that I couldn't test vf_vavpp.c (due to lack of hardware), and
I hope I didn't accidentally break it.
2014-03-17 18:22:25 +01:00
wm4 8e6bd496ca vf_delogo: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 48e32e13fe vf_hqdn3d: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 2520249b16 vf_yadif: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 04a74ea3e2 vf_unsharp: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 b2ec5c4b66 vf_gradfun: remove internal implementation
This follows the (only slowly progressing) plan to replace all internal
video filters with libavfilter.

All what's left in vf_gradfun.c is the weird wrapper around vf_lavfi.c.
2014-03-16 13:19:29 +01:00
wm4 98cd2c4122 build: simplify libavfilter configure checks
This is all not needed anymore. In particular, remove all configure
switches except --enable-libavfilter.
2014-03-16 13:19:29 +01:00
wm4 64c01a814c Remove some more unneeded version checks
All of these check against things that happened before the latest
supported FFmpeg/Libav release.
2014-03-16 13:19:28 +01:00
wm4 5d7cf6e508 video: add rounding to aspect ratio calculations
Small errors are unavoidable, but truncation can cause anamorphic video
to be off by 1 or 2 pixels.
2014-02-19 15:37:47 +01:00
wm4 245e5b8441 msg: remove global state 2013-12-21 23:11:12 +01:00
wm4 eef36f03ea msg: rename mp_msg_log -> mp_msg
Same for companion functions.
2013-12-21 22:13:04 +01:00
wm4 7bdee8f35e m_option: add mp_log context to sub-module print_help callback 2013-12-21 21:43:16 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of
course affects all users of this API as well.

In stream.c, pass a mp_null_log, because we can't do it properly yet.
This will be fixed later.
2013-12-21 21:05:02 +01:00
wm4 70af7ab8e5 vaapi: mp_msg conversions
This ended up a little bit messy. In order to get a mp_log everywhere,
mostly make use of the fact that va_surface already references global
state anyway.
2013-12-21 20:50:11 +01:00
wm4 38342436cd sws_utils: mp_msg conversions
This requires the caller to provide a mp_log in order to see error
messages. Unfortunately we don't do this in most places, but I guess we
have to live with it.
2013-12-21 20:50:10 +01:00
wm4 426ebbae5f video/filter: mp_msg conversions 2013-12-21 20:50:10 +01:00
wm4 6ae36d3225 vf_lavfi: don't access AVFilterPad directly
Direct access is deprecated.
2013-12-18 17:13:13 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
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.
2013-12-17 02:07:57 +01:00
wm4 7dc7b900c6 Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsg
The tmsg stuff was for the internal gettext() based translation system,
which nobody ever attempted to use and thus was removed. mp_gtext() and
set_osd_tmsg() were also for this.

mp_dbg was once enabled in debug mode only, but since we have log level
for enabling debug messages, it seems utterly useless.
2013-12-16 20:41:08 +01:00
wm4 a59ebae2ad vf_dsize: fix bug caused by typo 2013-12-14 01:50:32 +01:00
wm4 e6e6b88b6d video: move VO reinit from filter chain to player
This gets rid of the vf_vo pseudo-filter. It ends the idea of MPlayer's
architecture that the VO is just a (terminating) video filter. It didn't
really work for us with respect to video timing (the "end" of the video
chain isn't really made for video timing, and making it do so would be
awkward), and now we're removing it entirely. We will be able to fix
some things, such as properly draining video on reconfiguration.
2013-12-10 20:07:39 +01:00
wm4 2f46b23d51 video: move handling of brightness and deinterlacing control
Handling of brightness/gamma/saturation/etc. and deinterlacing is moved
from vf_vo.c to dec_video.c.
2013-12-10 20:07:39 +01:00
wm4 5f0585177e vf_vo: remove VO reset on filter uninit
I don't think this has any reason to exist. It's likely that this used
to be required by the old direct rendering infrastructure. (See
git blame output.)
2013-12-10 20:07:39 +01:00
wm4 d658b115a0 vf: redo conversion filter insertion/format negotiation
Remove the inconsistent, duplicated, and insufficient scale filter
insertion code, and do it in one place instead. This also compensates
for the earlier removal of vf_match_csp() (which was in fact duplicated
code).

The algorithm to determine where to insert a filter etc. is probably the
same, though it also comes with some changes that should make debugging
easier when trying to figure out why a chain is failing to configure.

Add an "in" pseudo filter, which makes insertion of conversion filters
easier. Also change the vf->reconfig signature. At a later point, I'll
probably change format negotiation such that the generic filter code
will choose the output format, so having separate in and out params will
be useful.
2013-12-07 19:35:55 +01:00
wm4 37fbef2ccb video/filter: make vf->control non-recursive
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.
2013-12-07 19:33:38 +01:00
wm4 0af9ede546 vf: remove flags from filter format status
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.
2013-12-07 19:33:11 +01:00
wm4 bb6165342d video: create a separate context for video filter chain
This adds vf_chain, which unlike vf_instance refers to the filter chain
as a whole. This makes the filter API less awkward, and will allow
handling format negotiation better.
2013-12-07 19:32:44 +01:00
wm4 75d3bf4711 video/filter: remove vf_match_csp()
This function improves automatic filter insertion, but this really
should be done by the generic filter code. Remove vf_match_csp() and all
code using it as preparation for that.

This commit temporarily makes handling of filter insertion worse for
now, but it will be fixed with the following commits.
2013-12-07 19:32:03 +01:00
wm4 6025abffda vf: remove unused function 2013-12-07 19:31:47 +01:00
wm4 a54b775f80 vf: print error when creating filter fails
Before that we relied on the filters printing their own error messages.
2013-12-07 19:31:33 +01:00
wm4 9839bb08df vf: declare config() as legacy 2013-12-05 22:58:54 +01:00
wm4 2d0a9c7af0 video/filter: remove unneeded config callbacks
They didn't do anything.

vf_screenshot.c actually did release the previous image, but that's not
really required. At worst you could take a screenshot and get an old
frame when there's no new frame yet.
2013-12-05 22:58:54 +01:00
wm4 66e20ef8ad video: remove --flip
The --flip option flipped the image upside-down, by trying to use VO
support, or if not available, by inserting a video filter. I'm not sure
why it existed. Maybe it was important in ancient times when VfW based
decoders output an image this way (but even then, flipping an image is a
free operation by negating the stride).

One nice thing about this is that it provided a possible path for
implementing video orientation, which is a feature we should probably
support eventually. The important part is that it would be for free for
VOs that support it, and would work even with hardware decoding.

But for now get rid of it. It's useless, trivial, stands in the way, and
supporting video orientation would require solving other problems first.
2013-12-05 22:58:54 +01:00
wm4 b2c4653b88 vf: move norm_qscale() to the only filter which uses it 2013-12-05 22:58:53 +01:00
wm4 e3809e5b52 vf_sub, vf_dlopen: default struct is not needed 2013-12-05 22:58:53 +01:00
wm4 4904df42e9 vf: cleanup removed filter entry 2013-12-05 22:58:53 +01:00
wm4 f6e68b33bc video/filter: fix some bogus free() calls
The generic filter code frees these; recent regression.
2013-12-05 01:50:05 +01:00
wm4 e9f49ea84d options: remove legacy hacks for sub-option handling 2013-12-04 23:13:46 +01:00
wm4 aeed84bd27 vf_noise: reduce binary size
Same issues as in previous commit.
2013-12-04 02:17:19 +01:00
wm4 0c2a0a67b6 vf_eq: revert unintended binary size increase
The vf_eq context contains a very large lookup table, and the method of
setting default values caused the vf_eq context to be included in the
compiled code.
2013-12-04 01:51:27 +01:00
wm4 437ecc5cad video/filter: remove legacy option handling hacks
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 33b62af947).

Why are MPlayer devs so monumentally lazy? Sorry, but this takes the
cake. You had 10 years.
2013-12-04 00:07:40 +01:00
wm4 079e0e7963 vf_vo: don't abuse option strings to set VO
Whoever thought this was a good idea should be punched.
2013-12-04 00:07:40 +01:00
wm4 0d5e4ba799 vf_rotate: use option parser 2013-12-04 00:07:40 +01:00
wm4 fabfb23232 vf_pp: use option parser 2013-12-04 00:07:40 +01:00
wm4 a605fae6fa vf_ilpack: use option parser 2013-12-04 00:07:40 +01:00
wm4 e92f4d4726 vf_eq: use option parser 2013-12-04 00:07:39 +01:00
wm4 3201a40234 vf_dsize: use option parser
Mostly backwards compatible, we don't change much because we just want
to get rid of the legacy option string handling.

You can't pass an aspect as first argument anymore.
2013-12-04 00:07:39 +01:00
wm4 43a6dd1ed5 vf_divtc: use option parser 2013-12-04 00:07:39 +01:00
wm4 5b7351ee3a video/filter: remove vf_down3dright
Apparently you can get this with: stereo3d=ab[2]{l,r}:sbs[2]{l,r}

So it seems the filter is redundant and can be removed.

Also see FFmpeg commit 2f11aa141a01.
2013-12-04 00:07:39 +01:00
wm4 66f74d031d vf: remove unneeded field
This was once required for padding, because many filters didn't use
designated initializers, and initialized a removed field with NULL.
2013-12-04 00:07:39 +01:00
wm4 5b48204e84 vf_pullup: change options, reroute to vf_lavfi
The options are probably mostly backwards compatible.
2013-12-04 00:07:39 +01:00
wm4 b21cb279d7 vf_unsharp: change options, reroute to vf_lavfi 2013-12-04 00:07:39 +01:00
wm4 1acb32201b vf_phase: change options, reroute to vf_lavfi
The option change is probably backwards compatible.
2013-12-04 00:07:39 +01:00
wm4 6a2eeedc4c vf_noise: reroute to vf_lavfi
Unfortunately, this forces filtering both luma and chroma, because
otherwise we'd have to deal with libavfilter's vf_noise weird handling
of YUV vs. RGB formats. Would we e.g. filter luma only, it would filter
red in RGB mode only, because it goes by component and there's no way to
distinguish YUV and RGB by just using the filter's options.
2013-12-04 00:07:39 +01:00
wm4 ad950be415 vf_stereo3d: reroute to vf_lavfi 2013-12-04 00:07:39 +01:00
wm4 54d67581d7 vf_hqdn3d: change options, reroute to vf_lavfi 2013-12-04 00:07:39 +01:00
wm4 7d04327e71 vf_gradfun: reroute to vf_lavfi
Also update the manpage. We changed defaults and added a suboption quite
some time ago, and we forgot to update the manpage at all.
2013-12-04 00:07:39 +01:00
wm4 5064ef87c3 vf_delogo: reroute to vf_lavfi
The ``file`` suboption is unsupported on lavfi.
2013-12-04 00:07:39 +01:00
wm4 86ba9a7f24 vf_yadif: change options, reroute to vf_lavfi
Also remove the ability to disable deinterlacing at runtime. You can
still disable deinterlacing at runtime by using the ``D`` key and its
automatical filter insertion/removal.
2013-12-04 00:07:38 +01:00
wm4 25635a62c3 vf_lavfi: export a wrapper function
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.
2013-12-04 00:07:38 +01:00
wm4 733c2369d3 video: remove VFCAP_POSTPROC
This wasn't used anymore, not even until recently.
2013-12-04 00:07:38 +01:00
wm4 1176ca9465 vf_screenshot: remove unnecessary code 2013-12-04 00:07:38 +01:00
wm4 b18f02d1ad options: add options that set defaults for af/vf/ao/vo
There are some use cases for this. For example, you can use it to set
defaults of automatically inserted filters (like af_lavrresample). It's
also useful if you have a non-trivial VO configuration, and want to use
--vo to quickly change between the drivers without repeating the whole
configuration in the --vo argument.
2013-12-01 00:12:10 +01:00
wm4 597b8a3550 Take care of some libavutil deprecations, drop support for FFmpeg 1.0
PIX_FMT_* -> AV_PIX_FMT_* (except some pixdesc constants)
enum PixelFormat -> enum AVPixelFormat
Losen some version checks in certain newer pixel formats.
av_pix_fmt_descriptors -> av_pix_fmt_desc_get

This removes support for FFmpeg 1.0.x, which is even older than
Libav 9.x. Support for it probably was already broken, and its
libswresample was rejected by our build system anyway because it's
broken.

Mostly untested; it does compile with Libav 9.9.
2013-11-29 17:39:57 +01:00
wm4 2ec629bede vf_pullup: properly reset on seek
Sometimes, vf_pullup hanged on seek. This was because it never was
properly reset. Old timestamps messed up the timestamp calculations,
which made the player show frames for a ridiculously long time, which is
perceived as pausing or hanging.
2013-11-29 15:08:05 +01:00
wm4 60cd300558 vaapi: remove unused hw image formats, simplify
PIX_FMT_VDA_VLD and PIX_FMT_VAAPI_VLD were never used anywhere. I'm not
sure why they were even added, and they sound like they are just for
compatibility with XvMC-style decoding, which sucks anyway.

Now that there's only a single vaapi format, remove the
IMGFMT_IS_VAAPI() macro. Also get rid of IMGFMT_IS_VDA(), which was
unused.
2013-11-29 14:19:29 +01:00
Natanael Copa ce1a511e22 video/filter: fix PIC compile on x86
When using PIC on x86 (eg with hardened toolchains) the ebx register is
reserverd and cannot be used in assembly code.

For vf_eq we allow the compiler to use memory as input.

For vf_noise we temoporarily borrow the ebp register.

This fixes #361.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2013-11-26 23:43:56 +01:00
wm4 4012c4a96e osd: remove mp_osd_res.video_par field
This is not needed anymore, because we decided that the PAR of the
decoded video matters, and not the PAR of the filtered video that
arrives at the VO.
2013-11-24 14:44:58 +01:00
wm4 e5311586ab Rename sub.c/.h to osd.c/.h
This was way too misleading. osd.c merely calls the subtitle renderers,
instead of actually dealing with subtitles.
2013-11-24 14:44:58 +01:00
wm4 057af4697c options: print lavfi filter list with --vf=lavfi=help 2013-11-23 21:35:52 +01:00
wm4 b5ed614839 options: implement --pphelp differently
Make it work via --vf=pp:help instead.
2013-11-23 21:34:24 +01:00
wm4 25855059af video: remove vf_pp auto-insertion
This drops the --pp option, which was probably broken for a while. The
option automatically inserted the "pp" filter. The value passed to it
was ignored (which is probably broken, it always selected maximal
quality).

Inserting this filter can be done simply with --vf=pp, so this is not
needed anymore.
2013-11-23 21:30:56 +01:00
wm4 4fa2babacc video: move struct mp_hwdec_info into its own header file
This means most code accessing this struct must now include hwdec.h
instead of dec_video.h. I just put it into dec_video.h at first because
I thought a separate file would be a waste, but it's more proper to do
it this way, as there are too many files which include dec_video.h only
to get the mp_hwdec_info definition.
2013-11-23 21:26:31 +01:00
wm4 de22d2b1ba vf_vavpp: make it work with vo_opengl and software decoding
vo_opengl always loads the hwdec backend lazily, so hwdec_request_api()
has to be called to possibly load it. This makes vf_vavpp work with
software decoding. (Hardware decoding loads the backend before the
filter is initialized, so this case is different.)

Also, the VFCTRL_GET_HWDEC_INFO call doesn't need to be checked. If it
fails, the info will be left blank.
2013-11-22 18:06:34 +01:00
Stefano Pigozzi 37388ebb0e configure: uniform the defines to #define HAVE_xxx (0|1)
The configure followed 5 different convetions of defines because the next guy
always wanted to introduce a new better way to uniform it[1]. For an
hypothetic feature 'hurr' you could have had:

  * #define HAVE_HURR 1   / #undef HAVE_DURR
  * #define HAVE_HURR     / #undef HAVE_DURR
  * #define CONFIG_HURR 1 / #undef CONFIG_DURR
  * #define HAVE_HURR 1   / #define HAVE_DURR 0
  * #define CONFIG_HURR 1 / #define CONFIG_DURR 0

All is now uniform and uses:
  * #define HAVE_HURR 1
  * #define HAVE_DURR 0

We like definining to 0 as opposed to `undef` bcause it can help spot typos
and is very helpful when doing big reorganizations in the code.

[1]: http://xkcd.com/927/ related
2013-11-03 21:59:54 +01:00
wm4 e0b6fdeb8d Fix some more -Wshadow warnings
These aren't printed with newer gcc or clang versions for some reason.

All of them seem to be about local variables shadowing global functions.
2013-11-01 17:35:38 +01:00
wm4 dd344b43e8 Enable -Wshadow
This one really did bite me hard (see previous commit), so enable it by
default.

Fix some cases of shadowing throughout the codebase. None of these
change behavior, and all of these were correct code, and just tripped up
the warning.
2013-11-01 13:00:15 +01:00
wm4 6d44a4dfd1 video/filter: remove useless vf_info fields
This time I didn't bother to move the contents of the author field to
the file headers. "git log" is your friend.
2013-10-23 19:30:01 +02:00
wm4 c8930e80a8 video/out: remove useless info struct and redundant fields
The author and comment fields were printed only in -v mode.
2013-10-23 19:30:01 +02:00
wm4 20e1c5f7d9 vf_scale: fix get/set confusion
This caused the equalizer controls to appear stuck.
2013-10-16 21:35:27 +02:00
wm4 ef9c5300ef cosmetics: replace "CTRL" defines by enums
Because why not.
2013-10-02 21:19:16 +02:00
wm4 00d41cc5b0 vf_scale: factor out libswscale equalizer control
Will be used by vo_x11.
2013-09-30 00:45:58 +02:00
wm4 f5bf6c0fb3 vd: move aspect calculation to a function
This function would probably be useful in other places too.

I'm not sure why vd.c doesn't apply the aspect if it changes size by
less than 4 pixels. Maybe it's supposed to avoid ugly results with bad
scalers if the difference is too small to be noticed normally.
2013-09-26 16:09:08 +02:00
xylosper 39d1ab82e5 vaapi: add vf_vavpp and use it for deinterlacing
Merged from pull request #246 by xylosper. Minor cosmetic changes, some
adjustments (compatibility with older libva versions), and manpage
additions by wm4.

Signed-off-by: wm4 <wm4@nowhere>
2013-09-25 13:53:42 +02:00
wm4 6c28524e0f vf: fix filter initialization error check
vf_open returns 0 on error, 1 on success. Oops. Accidentally broken
with 6629a95.
2013-09-20 14:01:00 +02:00
wm4 47e92b2f88 video: handle video output levels with mp_image_params
Until now, video output levels (obscure feature, like using TV screens
that require RGB output in limited range, similar to YUY) still required
handling of VOCTRL_SET_YUV_COLORSPACE. Simplify this, and use the new
mp_image_params code. This gets rid of some code. VOCTRL_SET_YUV_COLORSPACE
is not needed at all anymore in VOs that use the reconfig callback. The
result of VOCTRL_GET_YUV_COLORSPACE is now used only used for the
colormatrix related properties (basically, for display on OSD).  For
other VOs, VOCTRL_SET_YUV_COLORSPACE will be sent only once after config
instead of twice.
2013-08-24 19:40:18 +02:00
wm4 c3a0721d09 video/out: don't require VOs to handle screenshot aspect specially
This affects VOs which just reuse the mp_image from draw_image() to
return screenshots. The aspect of these images is never different
from the aspect the screenshots should be, so there's no reason to
adjust the aspect in these cases.

Other VOs still need it in order to restore the original image
attributes.

This requires some changes to the video filter code to make sure that
the aspect in the passed mp_images is consistent.

The changes in mplayer.c and vd_lavc.c are (probably) not strictly
needed for this commit, but contribute to consistency.
2013-08-24 17:03:06 +02:00
wm4 d69b39512d vf_eq: fix behavior when changing parameters
Using -vf eq and changing brightness, contrast, etc. using key bindings
with e.g. "add brightness 1" didn't work well: with step width 1, the
property gets easily "stuck". This is a rounding problem: e.g. setting
gamma to 3 would actually make it report that gamma is set to 2, so
the "add" command will obviously never reach 3 with a step width of 1.
Fix this by storing the parameters as integers.

This was broken in cac7702. This commit effectively changed these
properties to use the value as reported by vf_eq, instead of the
previously set value for the "add" command. This was more robust,
but not very correct either, so we keep the new behavior and make
vf_eq report its parameters more accurately.
2013-08-20 16:11:07 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 5accc5e7c1 vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").

Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)

Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.

Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)

Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.

Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.

Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 19:25:07 +02:00
wm4 ff0680c9b4 vf: fix unintended overwriting of image info
The symptom was that "-vf scale,format=rgba" broke the vsfilter
colorspace hack in sd_ass. vf->reconfig is allowed to overwrite its
input parameter for convenience (maybe that was a bad idea).
2013-07-28 18:44:20 +02:00
wm4 e83cbde1a4 Fix some -Wshadow warnings
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).
2013-07-23 00:45:23 +02:00
wm4 78ebb3c6fa options: make legacy hacks for AFs/VFs more explicit
This means that AOs/VOs with no options set do not take the legacy
option parsing path, but instead report that they have no options.
2013-07-22 23:07:23 +02:00
wm4 0b160e1257 vf_scale: actually respect param and param2 suboptions
This was forgotten in commit b81f5e2.
2013-07-22 14:41:33 +02:00
wm4 6629a95b92 options: use m_config for options instead of m_struct
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.
2013-07-21 23:27:31 +02:00
wm4 c50d5376f2 vf: remove unnecessary indirection 2013-07-21 23:27:30 +02:00
wm4 c4b08a9a11 video: remove fullscreen flags chaos
There was a MPOpts fullscreen field, a mp_vo_opts.fs field, and
VOFLAG_FULLSCREEN. Remove all these and introduce a
mp_vo_opts.fullscreen flag instead.

When VOs receive VOCTRL_FULLSCREEN, they are supposed to set the
current fullscreen mode to the state in mp_vo_opts.fullscreen. They
also should do this implicitly on config().

VOs which are capable of doing so can update the mp_vo_opts.fullscreen
if the actual fullscreen mode changes (e.g. if the user uses the
window manager controls). If fullscreen mode switching fails, they
can also set mp_vo_opts.fullscreen to the actual state.

Note that the X11 backend does almost none of this, and it has a
private fs flag to store the fullscreen flag, instead of getting it
from the WM. (Possibly because it has to deal with broken WMs.)

The fullscreen option has to be checked on config() to deal with
the -fs option, especially with something like:

   mpv --fs file1.mkv --{ --no-fs file2.mkv --}

(It should start in fullscreen mode, but go to windowed mode when
playing file2.mkv.)

Wayland changes by: Alexander Preisinger <alexander.preisinger@gmail.com>
Cocoa changes by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2013-07-18 14:07:21 +02:00
wm4 7f88e36911 sws_utils: don't recursively include libswscale header
Add libswscale includes where they are actually needed instead.
2013-07-18 13:46:05 +02:00
wm4 b81f5e2757 vf_scale: use new swscale wrapper 2013-07-18 13:41:38 +02:00
wm4 2134fa4e6b vf: make sure less important image params are set before/after filters
Image parameters like colorspace, color levels, and chroma location are
generally less important, and many filters don't set them correctly.
Force them instead in the generic VF code, which is probably better and
more convenient over all. So we designate this is a proper solution,
instead of a dirty hack.
2013-07-18 13:37:24 +02:00
wm4 48789b3546 vf_scale: remove rounding of sizes to 2 with 4:2:0
libswscale doesn't seem to require this (anymore?), and libavfiltert's
vf_scale doesn't do it either. Moreover, this wasn't done for most other
subsampled formats, not even very old ones. So just remove it.

(It'd be quite easy to align on chroma boundaries with all pixel
formats, though.)
2013-07-18 13:16:59 +02:00