Commit Graph

42200 Commits

Author SHA1 Message Date
Bin Jin 7438f208c3 vo_opengl: make image size dynamic during rendering
This commit marks the image size variables temporary, and renames them
in order to prevent any potential confusion in the future.
2015-11-05 17:38:20 +01:00
wm4 017f3d0674 options: enable mpeg2 hw decoding by default if hw decoding is requested
We didn't include this codec in the whitelist because of past problems
with vdpau and interlacing. (I can't reproduce any problems anymore.)
2015-11-05 17:31:07 +01:00
wm4 2cf9ee989c rpi: add support for codecs other than h264
FFmpeg now supports h264 and mpeg2. At least vc-1 will probably follow.
2015-11-05 17:24:35 +01:00
wm4 66ed50aa00 vo_vdpau: check VDP_RGBA_FORMAT_A8 support
Apparently not all vdpau drivers in the wild support this format (VDPAU
SUNXI can't). Revert to RGB in these cases.
2015-11-04 21:49:54 +01:00
wm4 179d7317e7 player: use input instead of output format for spdif check
This check disables the display-sync resample method. If the filters
convert PCM to AC3, we can still insert a filter to change speed. This
is because filters are inserted at the beginning of the filter chain.
2015-11-04 21:49:54 +01:00
wm4 3108a3a001 audio: do not require full audio chain reinit for speed changes
Actually, it didn't really require that before (most work was avoided),
but some bits had to be run anyway. Separate the speed change into a
light-weight function, which merely updates already created filters, and
a heavy-weight one which messes with filter insertion.

This also happens to fix the case where the filters would "forget" the
current speed (force resampling, change speed, hit a volume control to
force af_volume insertion - it will reset speed and desync).

Since we now always run the light-weight function, remove the
af_scaletempo verbose message that is printed on speed setting. Other
than that, all setters are cheap.
2015-11-04 21:49:54 +01:00
wm4 8f7cf9443f player: move audio speed adjustment code
Move it (in a cosmetic sense), and also move its invocation to below all
the video handling.

All other changes remain cosmetic, including moving the framedrop
calculation code, and getting rid of the video_speed_correction
variable.
2015-11-04 21:49:54 +01:00
wm4 e3db686e87 af_lavcac3enc: simplify/fix AVPacket handling
For some reason, the encoder didn't like that the AVPacket already had
fields set. I'm not quite sure, but this might just be invalid API
usage. Do it as it's recommended.
2015-11-04 21:49:54 +01:00
wm4 db1fc3628f audio: strictly align audio on spdif frames
We still have a sample-based buffer between filters and audio outputs.
In order to avoid cutting frames into half (which can upset receivers),
we strictly need to align the boundaries on which we cut the audio.
2015-11-04 21:49:54 +01:00
wm4 3ad03f6673 options: handle terminal/logging settings eagerly
Update msg.c state immediately if a terminal or logging setting is set.
Until now, this was delayed until mp[v]_initialize() was called. When
using the client API, you could easily miss logged error messages, even
when logging was initialized early on by calling
mpv_request_log_messages().

(Properties can't be used for this either, because properties do not
work before mpv_initialize().)
2015-11-04 21:49:54 +01:00
wm4 f00edfd9c5 vo_opengl_cb: log some events
The noframe event is logged whenever there is no new frame. This can
happen due to normal redraws, but also due to video frame queue
underflow.

The mpv_opengl_cb_report_flip() API function is currently pretty
useless, because blocking on the video frame queue is more reliable and
simpler. But at least we can log the actual vsync.
2015-11-04 21:49:54 +01:00
wm4 e6a395c297 vo_opengl, vo_opengl_cb: drop unneeded vo_frame fields
next_vsync/prev_vsync was only used to retrieve the vsync duration. We
can get this in a simpler way.

This also removes the vsync duration estimation from vo_opengl_cb.c,
which is probably worthless anyway. (And once interpolation is made
display-sync only, this won't matter at all.)
2015-11-04 21:49:54 +01:00
wm4 be49da72ea ao_alsa: fix 7.1 over HDMI
We need to effectively swap the last channel pair. See commit 4e358a96
and 5a18c5ea for details.

Doing this seems rather strange, as 7.1 just extends 5.1 with 2 new
speakers, and 5.1 doesn't need this change. Going by the HDMI standard
and the Intel HDA sources (cited in the referenced commits), it also
looks like 7.1 should simply append two channels to 5.1 as well. But
swapping them is apparently correct. This is also what XBMC does. (I
didn't find any other applications doing 7.1 PCM using the ALSA channel
map API. VLC seems to ignore the 7.1 case.) Testing reveals that at
least the end result is correct.

"Normal" ALSA 7.1 is unaffected by this, as it reports a different
(and saner) channel layout.
2015-11-04 21:48:37 +01:00
wm4 46f59f25c2 ao_alsa: map mp_chmaps back to ALSA in a different way
Instead of constructing an ALSA channel map from mpv ones from scratch,
try to find the original ALSA channel map again. Th result is that we
need to convert channel maps only in one direction. If we need to map
a mp_chmap to ALSA, we fetch the device's channel map list, convert
each entry to mp_chmap, and find the first one which fits.

This seems helpful for the following commit. For now, this only gets rid
of mapping back the trivial MONO mapping, which alone would still be
acceptable, but with other channel layout mogrifications it gets messy
fast. While we need to do something awkward to keep our channel map
reordering for VAR chmaps (which basically gives nicer output and
possibly slightly better performance), this is still the better
solution.
2015-11-04 21:48:37 +01:00
wm4 0ca8b290a4 ao_alsa: print more chmap info at debug verbosity 2015-11-04 21:48:37 +01:00
wm4 5a18c5ea91 Revert "af_lavrresample: don't drop sl/sr channels for 7.1 on ALSA"
This reverts commit 4e358a9636.

Testing shows the channel pairs must indeed be swapped (details see
commit message of the reverted commit). Making the downmix code move
sl/sr to sdl/sdr is not an appropriate solution anymore, and it's
better to fix the unusual channel layout in ao_alsa.c directly.

(Not reverting the change in chmap.c; this is still correct.)
2015-11-04 21:48:37 +01:00
James Ross-Gowan a9833a71ce TOOLS/gen-x11-icon.sh: fix for recent ImageMagick
Apparently ImageMagick no longer appends a newline to the format. This
also sets the execute bit on the script.
2015-11-04 21:48:27 +01:00
wm4 350d902799 player: fix display-sync adrop speed limiting
Commit 49d94853 worked only at the start of playback.
2015-11-04 10:57:29 +01:00
wm4 e187de7eed vo: do not go to sleep if there's a new frame queued
This affects only the display-sync code path, as for normal timing the
wakeup_pts stuff handles proper wakeup. It's probably mostly a
theoretical issue.
2015-11-03 20:47:15 +01:00
wm4 49d94853b5 player: limit speed change in display-sync adrop mode
Discontinuities (like toggling fullscreen) can cause multiple frames to
be dropped in succession, which sounds very weird. It's better to drop
some video frames instead to compensate for larger desyncs.

We roughly base it on the maximum allowed speed changes (audio change is
"additional" to the video change to account for deviations when playing
at max. video speed change).
2015-11-03 20:29:25 +01:00
wm4 163c6ad862 vd_lavc: make hwdec fallback more tolerant
A hw decoder might fail to decode a frame for multiple reasons, and not
always just because decoding is impossible. We can't generally
distinguish these reasons well. Make it more tolerant by accepting
failures of 3 frames, but not more. The threshold can be adjusted by the
repurposed --vd-lavc-software-fallback option.

(This behavior was suggested much earlier in some PR, but at the time
the "proper" hwdec fallback was indistinguishable from decoding error.
With the current situation, "proper" fallback is still instantious.)
2015-11-03 14:03:02 +01:00
wm4 4058b418bf vo: fix display-sync frame drop accounting again
Commit acd5816a fixed this, except when vo_opengl interpolation was
active. (And again, the old interpolation code path should be removed.)
2015-11-03 13:33:38 +01:00
wm4 4e358a9636 af_lavrresample: don't drop sl/sr channels for 7.1 on ALSA
ao_alsa: attempt to fix 7.1 over HDMI

The last 2 channels of 7.1 (RLC/RRC in ALSA) were exported as sdl/sdr
instead of sl/sr (I don't even know why I chose sdl/sdr, but SL/SR
and RLC/RRC are different in the ALSA API). libsw/avresample do not
move the sl/sr channels to sdl/sdr when rematrixing, so silence was
sent for 2 channels. If my selection of sdl/sdr is essentially API
abuse, there's no reason why they should do this differently.

The mess here is really that ALSa doesn't map the HDMI layouts cleanly.
Most ALSA drivers export 7.1 in a way compatible to our expectations,
but Intel HDA/HDMI does not:

mpv/ffmpeg:   fl-fr-fc-lfe-bl-br-sl-sr
ALSA/generic: FL FR FC LFE RL RR SL  SR  [1]
ALSA/HDMI:    FL FR LFE FC RL RR RLC RRC [2]

The HDMI layout is layout 0x13 (going by CEA-861-B). The comment in
the kernel code has to be correct too. The early standard defines only
1 other layout, which replaces RLC/RRC with FRC/FLC - this probably
corresponds to what we call "7.1(wide)".

So it appears when ALSA requests RLC/RRC, we should feed it sl/sr.

To make it more complicated, Kodi/xbmc apparently also have to deal with
ALSA being special, but instead of sending sl/sr to RLC/RRC, they swap
the last two pairs of the layout, and send sl/sr to RL/RR and bl/br to
RLC/RRC. Or I might have misunderstood their code. I don't have a
7.1-capable A/V receiver, so I can't test this.

For now, go with the simpler solution, and wait until someone tests it.
If the speakers end up swapped, a completely different solution will be
needed.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/core/pcm_lib.c?id=refs/tags/v4.3#n2434
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_hdmi.c?id=refs/tags/v4.3#n307
2015-11-03 00:28:00 +01:00
wm4 9d4aff8ac7 ao_alsa: minor cleanups 2015-11-03 00:23:28 +01:00
wm4 e162a5bf04 ao_alsa: simplify dmix non-NA hack
There's really no need to do this deep in the chmap sslection code. This
will setup the device further than before, but that doesn't matter.
2015-11-03 00:23:28 +01:00
wm4 8d415b2e01 ao_alsa: move channel map setting code out of main init function
This grew way too large.
2015-11-03 00:23:28 +01:00
wm4 d634394da6 ao_alsa: make failure of buffer parameter setting non-fatal
These calls actually can leave the ALSA configuration space empty (how
very useful), which is why snd_pcm_hw_params() can fail. An earlier
change intended to make this non-fatal, but it didn't work for this
reason.

Backup the old parameters, so we can retry with the non-empty
configuration space. (It has to be non-empty, because the previous
setters didn't fail.)

Note that the buffer settings are not very important to us. They're
a leftover from MPlayer, which needed to write enough data to the
audio device to not underrun while decoding and displaying a video
frame. In mpv, most of these things happen asynchronously, _and_
there is a dedicated thread just for feeding the audio device, so
we should be pretty imune even against extreme buffer settings. But
I suppose it's still useful to prevent PulseAudio from making the
buffer too large, so still keep this code.
2015-11-03 00:23:28 +01:00
wm4 609de236a9 ao_alsa: disable resampling first thing
Again, this could have bad access, is unlikely, and has no bad
consequences. It's noteworthy that vlc and the ALSA PCM example both do
this first, even if they set the sample rate later.
2015-11-03 00:23:28 +01:00
wm4 3f0d831af0 ao_alsa: set access type before format
I'm worried that not restricting the access type before restricting the
format will cause problems. While it's unlikely, it might prevent
failures in some corner cases. Also, since we by default always use
interleaved access (buggy ALSA plugins), this will have no effects at
all.
2015-11-03 00:23:28 +01:00
wm4 587bb5e811 ao_alsa: handle channel count mismatch safeguard after chmap negotiation
If the API doesn't list padded channel maps, but the final device
channel map is padded, and if unpadded output is not possible (unlike in
the somewhat similar dmix case), then we shouldn't apply the channel
count mismatch fallback in the beginning. Do it after channel map
negotiation instead.
2015-11-03 00:23:28 +01:00
wm4 c2220c526d ao_alsa: apply non-NA fallback only if input is stereo
Doesn't matter much; effectively this prevents just log spam in some
cases where the map is legitimately padded. Normally this is really
only needed for the dmix ALSA case. (See git blame for details.)
2015-11-03 00:23:28 +01:00
wm4 b58e4abc01 ao_alsa: treat SND_CHMAP_UNKNOWN as NA channel too
Apparently required by nVidia HDMI. It should not be, and NA would
definitely be more correct here, so this could be considered a driver
bug. Maybe.
2015-11-03 00:23:28 +01:00
wm4 3fb161ecd2 ao_alsa: remove log message on pausing
This was annoying.
2015-11-03 00:23:27 +01:00
wm4 1d2d649281 vdpau: fix uninit when init fails
The uninit() function was called twice if the uninit() function failed
(once by init(), once by vd_lavc.c code), which caused crashes due to
double-free. (This failure is a corner case, and all other hwdec
backends appear to handle this case gracefully.)

I do not think this code should be able to deal with uninit() being
called other than once. Guarantee that it's called exactly once.
2015-11-01 23:03:02 +01:00
wm4 8e8b420c9d vo_opengl: win32: fix cross-compilation
MXE uses an all-lowercase convention for MS headers.
2015-11-01 21:50:41 +01:00
wm4 9de8730dc9 vo_opengl: win32: always request MMCSS for DWM
Quoting MSDN: "Notifies the Desktop Window Manager (DWM) to opt in to or
out of Multimedia Class Schedule Service (MMCSS) scheduling while the
calling process is alive.". Whatever this means. (An application can
change the scheduling priority of the window manager?)

Does this improve anything? I have no idea. Certainly this is a program
that does multimedia and graphics, so we seem to be a good match for
this.

Is it bad if we enable this even while playback is inactive or paused? I
have no idea either.

Is there a magic cargo cult function that will mark our renderer thread
as multimedia thing? I have no idea. (We use a function to enable MMCSS
for our audio thread in ao_wasapi.)
2015-11-01 20:50:41 +01:00
wm4 30a6106477 vo_opengl: win32: try to enable DwmFlush by default
Enable it by default, but not unconditionally. Add an "auto" mode, which
disable DwmFlush if the compositor is (probably) inactive. Let's see how
this goes.

Since I accidentally enabled DwmFlush always by default (more or less)
in a previous commit touching this code, this is probably mostly just
cargo-culting, and it's uncertain whether it does anything.

Note that I still got bad vsync behavior when fullscreening mpv, and
making another window visible on the same screen. This happens even if
forcing DWM.
2015-11-01 20:47:57 +01:00
wm4 f1e767b6a2 player: another fix to A/V difference calculation in display-sync mode
update_av_diff() works on the timestamps, while time_left is in real
time. When playing at not-1 speed, these are very different, and cause
the A/V difference to jitter. Fix this by scaling the expected A/V
desync to the correct range.
2015-11-01 19:53:48 +01:00
wm4 8581835161 vo: fix no-audio mode with interpolation enabled/display-sync disabled
Commit acd5816a broke this. It was stopping playback occasionally.
Another case where the non-display-sync interpolation mode
(in->vsync_timed==true) is causing a lot of subtle issues and will be
removed soon.
2015-11-01 14:19:22 +01:00
wm4 cdeb0e4c72 video: fix playback of pal8
PAL8 is the only format that is RGB, has only 1 component, is byte-
aligned. It was accidentally detected by the GBRP case as planar RGB.
(It would have been ok if it were gray; what ruins it is that it's
actually paletted, and the color values do not correspond to colors (but
palette entries).

Pseudo-pal formats are ok; in fact AV_PIX_FMT_GRAY is rightfully marked
as MP_IMGFLAG_YUV_P.
2015-11-01 14:11:43 +01:00
wm4 8fd63c8f0c video: fix another A/V difference bug in display-sync mode
This didn't show up with cases where the frame pattern has a cycle of 1
or 2 like it is the case with 24-on-24 fps, or 24-on-60 fps. It did show
up with 25-on-60 fps. (We don't slow down 25 fps video to 24 on default
settings.)

In this case, we must not add the timing error of the next frame to the
A/V difference estimation of the current frame. Use the previous timing
error instead.

This is another bug resulting from the confusion about whether we
calculate parameters for the currently playing frame, or the one we're
about to queue.
2015-10-31 13:21:16 +01:00
wm4 b92fd602ce vo_direct3d: fix operation
Regression since commit 93db4233. I think the bit that was forgotten
here was to remove the vo_w32_config() return value completely. The VO
failed to init because that function always returned 0. This commit
removes these bits and fixes the VO.

Fixes #2434.
2015-10-31 12:52:02 +01:00
Evgeny Kolesnikov 7984d25ceb SVG version of the icon (with symbolic counterpart) 2015-10-30 20:29:55 +01:00
wm4 2b6241a09a vo_opengl: add vsync-fences option
Yet another relatively useless option that tries to make OpenGL's sync
behavior somewhat sane. The results are not too encouraging. With a
value of 1, vsync jitter is gone on nVidia, but there are frame drops
(less than with glfinish). With 2, I get the usual vsync jitter _and_
frame drops.

There's still some hope that it might prevent too deep queuing with some
GPUs, I guess.

The timeout for the wait call is 1 second. The value is pretty
arbitrary; it should just not be too high to freeze the process (if
the GPU is un-nice), and not too low to trigger the timeout in normal
cases, even if the GPU load is very high. So I guess 1 second is ok
as a timeout.

The idea to use fences this way to control the queue depth was stolen
from RetroArch:

df01279cf3/gfx/drivers/gl.c (L1856)
2015-10-30 20:26:51 +01:00
wm4 93f748e77f vo_opengl: cosmetics: flip the order of 2 functions
draw_frame() is called first, then flip_page(). Order them in the order
they're called.
2015-10-30 20:26:43 +01:00
rr- 7c6d7017bd vo_drm: uninstall signal handlers after quitting 2015-10-30 20:26:37 +01:00
rr- 344b65c4db vo_drm: handle possible errors from sigaction 2015-10-30 20:26:37 +01:00
rr- 03cf69f0a8 vo_drm: check if signal already used 2015-10-30 20:26:37 +01:00
wm4 05e39ec513 stream/audio: fix unchecked strdups
See #2435. It's literally a waste of time trying to fix minor memory
leaks in this old, unused, and crappy code.
2015-10-30 15:51:26 +01:00
wm4 7aba3a5d96 command: add mistimed-frame-count property
Does what the manpage says. This is a replacement incrementing the
dropped frame counter (see previous commit).
2015-10-30 14:05:41 +01:00