Commit Graph

40452 Commits

Author SHA1 Message Date
Niklas Haas 61f5a80f10
vo_opengl: get rid of approx-gamma and make it the default as per BT.1886
After finding out more about how video mastering is done in the real
world it dawned upon me why the "hack" we figured out in #534 looks so
much better.

Since mastering studios have historically been using only CRTs, the
practice adopted for backwards compatibility was to simulate CRT
responses even on modern digital monitors, a practice so ubiquitous that
the ITU-R formalized it in R-Rec BT.1886 to be precisely gamma 2.40.

As such, we finally have enough proof to get rid of the option
altogether and just always do that.

The value 1.961 is a rounded version of my experimentally obtained
approximation of the BT.709 curve, which resulted in a value of around
1.9610336. This is the closest average match to the source brightness
while preserving the nonlinear response of the BT.1886 ideal monitor.

For playback in dark environments, it's expected that the gamma shift
should be reproduced by a user controlled setting, up to a maximum of
1.224 (2.4/1.961) for a pitch black environment.

More information:
https://developer.apple.com/library/mac/technotes/tn2257/_index.html
2015-01-16 02:17:19 +01:00
wm4 4e419b2b7b player: don't fall asleep on audio decoding errors
This makes it retry later.

Fixes #1474.
2015-01-15 21:57:09 +01:00
Niklas Haas 7aaf71861e
manpage: changes.rst: document vo_opengl's placebo features 2015-01-15 21:32:19 +01:00
Niklas Haas 26baf5b9da
vo_opengl: add ewa_lanczos upscaler (aka jinc)
This is the polar (elliptic weighted average) version of lanczos.
This introduces a general new form of polar filters.
2015-01-15 21:20:27 +01:00
wm4 93e0d6f3b3 player: fix --stop-playback-on-init-failure on audio init failure
This was forgotten when the option was implemented, and makes this
option work as advertised.

Fixes #1473 (though the default behavior is probably still stupid).
2015-01-15 20:13:15 +01:00
wm4 ae641d200a af: remove old filter compatibility hack 2015-01-15 20:13:15 +01:00
wm4 388cf6dc96 audio/filter: switch remaining filters to refcounting
All of these filters are very similar in frame management, and copy data
to a new frame during filtering.
2015-01-15 20:13:14 +01:00
wm4 87fe7d8788 audio/filter: switch remaining in-place filters to refcounting
Adds about 7 lines of boilerplate per filter. This could be avoided by
providing a different entrypoint (something like af->filter_inplace),
which would basically mirror the old interface exactly for this kind of
filter. But I feel like it would just be a hack to support all those
old, useless filters better. (The ideal solution would be using a
language that can do closures to provide a compat. wrapper, but
whatever.)

af_bs2b has terribly repetitious code for setting up filter functions
for each format (most of them useless, in addition to bs2b being
useless), so I did something terrible with macros.

af_sinesuppress had commented code for float filtering (maybe it was
broken; it has been commented every since it was added in 2006). Remove
this code.
2015-01-15 20:13:12 +01:00
wm4 ba0e8b754c af: verify filter input formats
Just to make sure all filters get the correct format. Together wih the
check in af_add_output_frame(), this asserts that

    af->prev->fmt_out == af->fmt_in

This also requires setting the "in" pseudo-filter (s->first) formats
correctly. Before this commit, the fmt_in/fmt_out fields weren't used
for this filter.
2015-01-15 20:10:46 +01:00
wm4 66c8a87485 vo_opengl_cb: initial screenshot support
Support for taking screenshots when doing hardware decoding needs to be
added later.

This takes the last image queued to the VO, which is logically the image
the player thinks is on screen (so e.g. subtitles will match).

forget_frames() does not clear this, because seeking does not remove the
current image from the screen (until the next one is drawn).
2015-01-15 20:10:11 +01:00
wm4 c118d8f6cc image_writer: check for conversion errors
This can happen when e.g. a VO returns a screenshot in an unsupported
format.
2015-01-15 20:10:08 +01:00
wm4 a6997be61b osc: fix disabling OSC
Upon the "DEL" key binding or the "disable-osc" message, the OSC should
stay permanently invisible. This was recently broken (not sure by what),
because other code accidentally reenables it anyway, which resulted in
the OSC appearing again when moving the mouse.
2015-01-15 20:09:32 +01:00
wm4 c88b535c46 DOCS/client_api_examples: fix locale nonsense in qml examples
The Qt example already does this. I hoped this was restricted to
QApplication only, but apparently Qt repeated this mistake with
QGuiApplication (QGuiApplication was specifically added for QtQuick at a
much later point, even though QApplication inherits from it).
2015-01-15 20:08:57 +01:00
wm4 c757a06845 ao_alsa: fix a small memory leak 2015-01-14 22:16:36 +01:00
wm4 e865d255d0 af_lavcac3enc: use refcounted frames 2015-01-14 22:16:30 +01:00
wm4 5d972491bb af_lavfi: use refcounted frames 2015-01-14 22:15:56 +01:00
wm4 9c974b2a1b audio/filter: actually set fmt_in/fmt_out fields 2015-01-14 22:15:51 +01:00
wm4 f6a0a1554c af_scaletempo: use refcounted frames 2015-01-14 22:15:39 +01:00
wm4 218c749a16 af_lavrresample: use refcounted frames 2015-01-14 22:15:31 +01:00
wm4 7b8862760d audio: add missing declaration 2015-01-14 22:15:00 +01:00
wm4 c8ecb66269 ao_pcm: add append mode
Pretty useful for debugging, although a bit useless or possibly
misleading too (see comments in the manpage).
2015-01-14 22:14:56 +01:00
wm4 4cabd08e8a audio: fix initial audio PTS
Commit 5e25a3d2 broke handling of the initial frame (the one decoded
with initial_audio_decode()). It didn't update the pts_offset field,
leading to a shift in timestamps by one audio frame.

Fix by calling the actual decode function in a single place. This
requires slightly more changes than what would be necessary to fix the
bug, but it also somewhat simplifies the data flow.
2015-01-14 22:14:46 +01:00
wm4 1a522f2976 player: fallback to seek time for percent-pos property
The percent-pos property normally goes by time, except for file formats
like .ts or .ogg, where you can't trust the timestamps and duration info
to compute the position in the overall files. These use the byte
position and size instead.

When the file position was unavailable (e.g. due to an ongoing seek),
the percent-pos was unknown. Change it to use the time position instead.
In most cases, it's actually accurate enough, and the temporary
unavailability of the property can be annoying, e.g. on the terminal
status line.
2015-01-14 22:14:20 +01:00
wm4 3cb2add636 audio: fix assertion failure on audio decoding
There are several cases in which a decoder may need several packets to
produce some output audio. Commit 5e25a3d2 broke this.

Fixes #1471.
2015-01-14 07:58:01 +01:00
wm4 ecca64e182 af_convert24: use refcounted frames
This requires allocating a fully new frame. 32->24 could be in-place,
but this is not possible for 24->32.
2015-01-13 20:17:08 +01:00
wm4 983f5efa3c audio/filters: use refcounted frames for some in-place filters
These are also quite simple, but require requesting write access to the
frames. The error handling (for OOM) is a bit annoying.
2015-01-13 20:17:03 +01:00
wm4 1fde40732e audio/filters: use refcounted frames for some simple filters
These are read-only, and very trivial to convert.
2015-01-13 20:16:59 +01:00
wm4 772c42a95c af_volume: use refcounted frames 2015-01-13 20:15:53 +01:00
wm4 5e25a3d216 audio: use refcounted frames in the filter chain
The goal is switching the whole audio chain to using refcounted frames.
This brings the architecture closer to FFmpeg, enables better
integration with libavfilter, will reduce useless copying somewhat, and
will probably allow better timestamp tracking.

For now, every filter goes through a semi-awful wrapper in
af_do_filter(), though. This will be fixed step by step, and the wrapper
should eventually be removed. Another thing that will have to be done is
improving the timestamp handling and avoiding extra copies for the AO.

Some of the new code is rather similar to the video filter code (the
core filter code basically just has types replaced). Such code
duplication is normally very unwanted, but in this case there's probably
no other choice. On the other hand, this code is pretty simple (even if
somewhat tricky). Maybe there will be unified filter code in the future,
but this is still far away.
2015-01-13 20:15:43 +01:00
wm4 97becbc31b audio: add some utility functions for refcounted frames
Used in the following commits.
2015-01-13 20:14:25 +01:00
wm4 0bbd65b09c audio/filter: remove unused af_calc_filter_multiplier()
The purpose of this function was to filter only as much audio input as
needed to produce a certain amount of audio output. This could (in
theory) avoid excessive buffering when e.g. changing playback speed with
resampling.

Use of this was already removed in commit 5fd8a1e0. No problems were
experienced, so let's assume this feature is practically worthless.
(Though it's possible that it was quite useful over a decade ago, or in
some cornercases with evil files.)
2015-01-13 20:14:02 +01:00
wm4 9418f88475 client API: fix log buffer overflow case
It just crashed. The prefix and text fields point to static strings in
this case. Oops.

Fixes the issue mentioned in #838.
2015-01-13 19:33:16 +01:00
wm4 53a5923ba1 manpage: fix references to vf_pp
It was removed, but is still available through FFmpeg.

Fixes #1468.
2015-01-13 16:54:59 +01:00
wm4 206cfd964c vf: make message less confusing
Well, probably still not very good, but now at least accounts for the
case the decoder or a filter outputs nonsense values.
2015-01-13 14:40:37 +01:00
wm4 77b488b4a2 mp_image: reject invalid display aspect ratio
Having any of these set to 0 makes no sense.

I think some code might still be using 0/0 aspect ratio to signal unset
aspect ratio, but I didn't find it. If there is still code like this, it
should be fixed instead.

Fixes #1467.
2015-01-13 14:26:25 +01:00
wm4 b2cc0fb1ae player: fix crash wtih --secondary-sid
Fises #1463.
2015-01-13 02:45:51 +01:00
Oliver Freyermuth 794804725d cache: cache-position needs to be int64_t
Both max_filepos and offset are int64_t,
so pos can overflow, e.g. causing endless loops
in stream implementation.
2015-01-13 02:39:16 +01:00
Oliver Freyermuth 3d1b9ba4bd stream_dvb: Add MP_ERR if polling worked, but read fails.
Read can still fail, e.g. if the buffer is invalid.
2015-01-13 02:37:12 +01:00
wm4 460ef9c7a4 wayland: implement key modifiers
Includes shift, ctrl, alt, meta.
2015-01-12 16:41:00 +01:00
wm4 10532b99e5 wayland: don't compute absurd window size
For some reason, schedule_resize() can be called with everything set to
0. The code couldn't handle wl->window.aspect set to 0, converting NaNs
to integers. Just work this around.

(I have no idea what I'm doing. This is probably a corner case caused
by my broken-ish wayland setup.)
2015-01-12 15:21:26 +01:00
wm4 4a7c6aaedf bstr: fix possible undefined behavior with length 0 strings
BSTR_P() passes the string length and start pointer to printf-like
functions. If the lenfth is 0, the pointer can be NULL, but we're
actually still not allowed to pass a NULL pointer in any case.

This is mostly a technically, because nobody in their right mind would
attempt to specifically break such cases. But it's still undefined
behavior, and some libcs might be strict about this.
2015-01-12 14:43:52 +01:00
wm4 8144d142e4 player: don't set tag strings to NULL
bstr is a bounded string type, consisting of a pointer and a length
value. If the length is 0, the pointer can be NULL. This is somewhat
logical due to how this abstraction works, but it can leak when
converting to C strings.

talloc_strndup() returns NULL instead of "" in this case, which broke
some other code. Use bstrto0() instead, which is the "proper" function
to convert bstr to char*.

Fixes #1462.
2015-01-12 14:33:56 +01:00
wm4 da2dbd74da demux_mkv: fix EBML parsing checks
Reading IDs must be checked too. This was basically forgotten in commit
f3a978cd. Also set the *length parameter for ebml_parse_length() in some
error cases, which _really_ should happen.

Fixes #1461.
2015-01-12 14:31:31 +01:00
wm4 ab185a2d42 manpage: improve --title description
It might be rather surprising that --title also sets the audio stream
title (for PulseAudio and wasapi), so it certainly should be mentioned.
2015-01-12 14:21:16 +01:00
wm4 fcdbaf78f2 tl_matroska: fix minor memory leak in error case
Going the way of least resistance. Fixes #1460.
2015-01-12 13:20:56 +01:00
wm4 8336563d23 player: check sufficient track selection before destroying VO
mpv needs at least an audio or video track to play something. If the
track selection is basically insufficient, the player will immediately
skip to the next file (or quit).

One slightly annoying thing might be that trying to play a subtitle file
will close the VO window, and then go to the next file immediately (so
"mpv 1.mkv 2.srt 3.mkv" would flash the video window when 2.srt is
skipped). Move the check to before the video window is possibly closed.

This is a minor cosmetic issue; one can use --force-window to avoid
closing the video window at all.

Fixes #1459.
2015-01-12 13:04:21 +01:00
wm4 3459130e5c client API: reasonable behavior if window is closed
Closing the video window sends CLOSE_WIN, which is normally mapped to
the "quit" command. The client API normally disables all key bindings,
and closing the window does nothing. It's simply left to the application
to handle this. This is fine - an embedded window can not be destroyed
by user interaction.

But sometimes, the window might be destroyed anyway, for example because
the containing window is destroyed. If this happens, CLOSE_WIN should
better not be ignored. We can't expect client API users to handle this
specially (by providing their own input.conf), so provide some fallback
for this pseudo key binding. The "quit" command might be too intrusive
(not every client necessarily handles "unexpected" MPV_EVENT_SHUTDOWN),
but I think it's still reasonable.
2015-01-12 12:53:49 +01:00
wm4 a8df0bbf22 x11: explicitly query map status when waiting for map event
For some reason, mpv sometimes does not get a MapNotify event with
GtkSocket embedding. This happens maybe 1 out of 10 times. I'm not sure
how this can happen - it certainly shouldn't. Since I was not able to
find the cause, and causes an apparent "deadlock", here's a lazy hack to
fix the misbehavior.
2015-01-12 12:15:27 +01:00
wm4 fc95678d8d x11: support XEmbed
Seems to work with GtkSocket and passing the gtk_socket_get_id() value
via "wid" option to mpv.

One caveat is that using <tab> to move input focus from mpv to GTK does
not work. It seems we would have to interpret <tab> ourselves in this
case. I'm not sure if we really should do this - it would probably
require emulating some other typical conventions too. I'm not sure if an
embedder could do something about this on the toolkit level, but in
theory it would be possible, so leave it as is for now.
2015-01-12 12:08:48 +01:00
wm4 2e531aaf14 vo: don't synchronize when seeking
Don't use vo_control() for sending VOCTRL_RESET when starting a seek.
This means vo_seek_reset() won't wait until the VO actually processed
VOCTRL_RESET. It happens asynchronously instead.

The impact of this change should be minimal, unless the VO is somehow
too busy (like blocking on vsync).
2015-01-12 05:14:41 +01:00