Compare commits

...
442 Commits
Author SHA1 Message Date
Martin Herkt 1e00bcc14c Release 0.18.1 2016-07-10 02:20:08 +02:00
Martin Herkt 7635438592 Merge branch 'master' into release/current 2016-07-10 01:06:17 +02:00
wm4 e518bf2c72 audio: insert audio-inserted filters at end of chain
This happens to be better for the af_volume filter (for softvol), and
saves some code too. It's "better" because you want to affect the
final filtered audio, such as after a manually inserted drc filter.
2016-07-09 20:23:15 +02:00
wm4 d47b708f00 audio: don't crash when changing volume if no audio is initialized
Oversight.
2016-07-09 19:34:45 +02:00
wm4 2fb2f9b93a man: fix typo 2016-07-09 18:55:14 +02:00
wm4 995c47da9a audio: drop --softvol=no and --softvol=auto
Drop the code for switching the volume options and properties between
af_volume and AO volume controls. interface-changes.rst mentions the
changes in detail.

Do this because this was exceedingly complex and had other problems as
well. It was also very hard to test. It's just not worth the trouble.

Some leftovers like AOCONTROL_HAS_PER_APP_VOLUME will be removed at a
later point.

Fixes #3322.
2016-07-09 18:31:18 +02:00
Jakub Wilk da9590d368 man: fix typos 2016-07-09 16:27:42 +02:00
Jakub Wilk 34a33ebd4d vo_xv, vo_x11: fix typos in warnings 2016-07-09 14:35:41 +02:00
wm4 e58ecc3630 man: fix botched sentence
Fixes #3323.
2016-07-08 19:34:52 +02:00
wm4 6d83455a95 vd_d3d11vpp: remove nonsensical flush call
I made this call up because I sort of thought this makes senssssse. I'm
now convinced that it does not, and even is actively harmful. I'm still
quite in the dark how the DirectD 11 video API is supposed to work with
synchronization, but at least for normal graphics this call would not
make much sense.
2016-07-08 19:34:24 +02:00
wm4 35be389031 x11: add missing FocusChangeMask
So we actually get FocusOut events. Disables key repeat when losing
focus while a key is down.
2016-07-08 16:36:53 +02:00
wm4 885e991312 ao_coreaudio: error out when selecting invalid device
When selecting a device that simply doesn't exist with --audio-device,
AudioUnit will still initialize and start playback without complaining.
But it will never call the audio render callback, which leads to audio
playback simply not progressing.

I couldn't find a way to get AudioUnit to report an error at all, so
here's a crappy hack that takes care of this in most cases. We assume
that all devices have a kAudioDevicePropertyDeviceIsAlive property.
Invalid devices will error when querying the property (with 'obj!' as
status code).

This is not the correct fix, because we try to double-guess AudioUnit's
behavior by accessing a lower label API. Suggestions welcome.
2016-07-08 16:11:03 +02:00
wm4 26b6873ffd client API: remove "status" log level from mpv_request_event docs
Although it appears to be accepted by the function, MSGL_STATUS messages
are never passed to the client API. Consequently "status" has the same
meaning as "v" and is useless.
2016-07-08 16:10:57 +02:00
wm4 71a8aa2e9a command: don't delay progress updates to next video frame 2016-07-08 13:46:15 +02:00
wm4 16b48a429d video: fix midstream video configuration changes
Commit 771a8bf5 added code to avoid unnecessary vf_reconfig() calls for
unrelated reasons, but forget to consider that it has to be called at
least once if the input format changes. As a consequence it got "stuck"
due to not being able to decode more frames.
2016-07-08 08:22:51 +02:00
wm4 f2110f582d vo_vdpau: minor simplification
Remove some indirections that aren't needed anymore.
2016-07-07 16:10:53 +02:00
wm4 8660b4c9f0 video: limit number of frames sent to VO to the VO requested amount
vo_frame can have more than 1 frame - the extra frames are future
references, which are sometimes useful for filtering (vo_opengl
interpolation). There's no harm in reducing the number of frames sent to
the VO requested amount of future frames, so do that.

Doesn't actually reduce the number of concurrently in use frames in
practice.
2016-07-07 16:10:13 +02:00
wm4 ab6fac43b4 player: cut off status line on terminal width
If the status line is wider than the reported terminal size, then cut it
off instead of causing the terminal to scroll down for the next line.

This is done in the most primitive way possible, assuming ASCII.

This was actually done in the past as far as I'm aware; do it again.
(Probably differently.)
2016-07-06 19:52:09 +02:00
wm4 5d2f1da7c5 vf, af: print filter labels in verbose mode 2016-07-06 14:13:03 +02:00
wm4 771a8bf5c6 video: fix deinterlace filter handling for VFCTRL_SET_DEINTERLACE filters
Some filters support VFCTRL_SET_DEINTERLACE. This affects most hardware
deinterlace filters. They can be inserted by the user manually, or auto-
inserted by vf.c itself as conversion filter (vf_d3d11vpp). In these
cases, we shouldn't insert or remove filters outselves, and instead
VFCTRL_SET_DEINTERLACE should be invoked to switch the mode.

This wasn't done correctly in the recently refactored code and could
have broken with --deinterlace. (The refactor only considered switching
via property in this case.) Fix it by making it a proper part of the
filter_reconfig() function, and making set_deinterlacing() (which is
called by the property handler) merely call filter_reconfig() in all
cases to do the real work.

We can even avoid rebuilding the filter chain - though only if no other
auto-filters are inserted. It probably also provides a slightly cleaner
way to implement functionality in the VO while still inserting video
filter fallbacks correctly if required.
2016-07-06 14:08:47 +02:00
wm4 08cd50b84b vf: mark filter chain as uninitialized when mutating it
Sounds fair. Can be used to determine if the filter chain was mutated at
all, and avoiding unconditional reinit if it wasn't.
2016-07-06 13:47:58 +02:00
wm4 0b1ef81498 video: fix deinterlace filter handling on pixel format changes
The test scenario at hand was hardware decoding a file with d3d11 and
with deinterlacing enabled. The file switches to a non-hardware
dedocdeable format mid-stream. This failed, because it tried to call
vf_reconfig() with the old filters inserted, with was fatal due to
vf_d3d11vpp accepting only hardware input formats.

Fix this by always strictly removing all auto-inserted filters
(including the deinterlacing one), and reconfiguring only after that.

Note that this change is good for other situations too, because we
generally don't want to use a hardware deinterlacer for software
decoding by default. They're not necessarily optimal, and VAAPI VPP even
has incomprehensible deinterlacer bugs specifically with software frames
not coming from a hardware decoder.
2016-07-06 13:38:43 +02:00
wm4 fc76966d9e vf: don't clobber input params on reconfigure failure
I think this is more robust, and future commits will rely on it.
2016-07-06 13:27:20 +02:00
wm4 0fe62bc1d2 player: it's not --force-seeking but --force-seekable
Oops. Fuck.
2016-07-06 00:11:57 +02:00
wm4 d72bcc8041 player: rewrite deinterlace filter auto-insertion
Instead of using the "vf" command code (which changes filters at runtime
on user input), use the general filter-insertion code. The latter was
added later, and is more suitable for automatically inserted filters.

The old code failed in particular when using watch-later saving, which
stored the filter list in the resume config file. If a user changed the
hardware decoding mode via command line, the stored filter chain was out
of date and could cause failure due to not working with hardware or
software decoding mode. Storing the deinterlace filter in the filter
list was unavoidable, because it was part of the user state. (The new
code only edits the actually instantiated filters.)
2016-07-05 21:10:26 +02:00
Niklas Haas 329a7147d0 csp: document deviations from the references where they occur
These mostly happen in situations where the correct behavior is
relatively new and not found in the wild (therefore not worth
implementing) and/or extremely complicated (and thus not worth worrying
about the potential edge cases and UI changes).

Still, it's best to document these where they happen to guide the poor
souls maintaining these files in the future.
2016-07-05 19:16:49 +02:00
Ben Boeckel 4f4eea6b44 x11_common: silence xdg-screensaver
Some screen lockers have a habit of dumping output to the terminal when
their output is reset. Ignore its output to keep the TTY output clean.
2016-07-05 19:16:01 +02:00
Ben Boeckel 33e72ed451 subprocess: add a callback to ignore output
This callback is equivalent to shoving data into /dev/null.
2016-07-05 19:15:59 +02:00
James Ross-Gowan 6a3da439cd vo_opengl: angle: update the swapchain on resize
This uses eglPostSubBufferNV to trigger ANGLE to check the window size
and update the size of the swapchain to match, which is recommended
here: https://groups.google.com/d/msg/angleproject/RvyVkjRCQGU/gfKfT64IAgAJ

With the D3D11 backend, using eglPostSubBufferNV with a 0-sized update
region will even skip the Present() call, meaning it won't block for a
vsync period. Hopefully ANGLE will have a less hacky way of doing this
in future. See the relevant ANGLE issue: http://anglebug.com/1438

Fixes #3301
2016-07-04 22:04:37 +10:00
wm4 f98e1b0b96 vo_opengl: error out gracefully when trying to use FBOs without FBO API
This can for example happen with vo_opengl_cb, if it is used with a GL
implementation that does not supports FBOs. (mpv itself should never
attempt to use FBOs if they're not available.)

Without this check it would trigger an assert() in our dummy
glBindFramebuffer wrapper.

Suspected cause of #3308, although it's still unlikely.
2016-07-04 13:34:31 +02:00
wm4 7cd1a3c766 vf_d3d11vpp: fix output image format if not doing any filtering
For example it should be set to IMGFMT_D3D11NV12 if it isn't already.
Otherwise, an assertion in vf.c could trigger.

This probably couldn't be provoked yet.
2016-07-04 11:54:02 +02:00
wm4 46f1ce1e2f input: remove redundant log message 2016-07-04 10:50:00 +02:00
Niklas Haas be230d16e5 vo_opengl: move eval_szexpr to user_shaders.c
This moves some of the bulky user-shader specific logic into the file
dedicated to it. Rather than expose video.c state, variable lookup is
now done via a simulated closure.
2016-07-03 19:42:52 +02:00
Niklas Haas 5b6cce2b73 vd_lavc: expose mastering display side data reference peak
This greatly improves the result when decoding typical (ST.2084) HDR
content, since the job of tone mapping gets significantly easier when
you're only mapping from 1000 to 250, rather than 10000 to 250.

The difference is so drastic that we can now even reasonably use
`hdr-tone-mapping=linear` and get a very perceptually uniform result
that is only slightly darker than normal. (To compensate for the extra
dynamic range)

Due to weird implementation details, this only seems to be present on
keyframes (or something like that), so we have to cache the last seen
value for the frames in between.

Also, in some files the metadata is just completely broken /
nonsensical, so I decided to apply a simple heuristic to detect
completely broken metadata.
2016-07-03 19:42:52 +02:00
Niklas Haas 923e3c7b20 vo_opengl: generalize HDR tone mapping mechanism
This involves multiple changes:

1. Brightness metadata is split into nominal peak and signal peak.

For a quick and dirty explanation: nominal peak is the brightest value
that your color space can represent (i.e. the brightness of an encoded
1.0), and signal peak is the brightest value that actually occurs in
the video (i.e. the brightest thing that's displayed).

2. vo_opengl uses a new decision logic to figure out the right nom_peak
and sig_peak for all situations. It also does a better job of picking
the right target gamut/colorspace to use for the OSD. (Which still is
and still should be treated as sRGB). This change in logic also
fixes #3293 en passant.

3. Since it was growing rapidly, the logic for auto-guessing / inferring
the right colorimetry configuration (in pass_colormanage) was split from
the logic for actually performing the adaptation (now pass_color_map).

Right now, the new logic doesn't do a whole lot since HDR metadata is
still ignored (but not for long).
2016-07-03 19:42:52 +02:00
Niklas Haas d81fb97f45 mp_image: split colorimetry metadata into its own struct
This has two reasons:

1. I tend to add new fields to this metadata, and every time I've done
so I've consistently forgotten to update all of the dozens of places in
which this colorimetry metadata might end up getting used. While most
usages don't really care about most of the metadata, sometimes the
intend was simply to “copy” the colorimetry metadata from one struct to
another. With this being inside a substruct, those lines of code can now
simply read a.color = b.color without having to care about added or
removed fields.

2. It makes the type definitions nicer for upcoming refactors.

In going through all of the usages, I also expanded a few where I felt
that omitting the “young” fields was a bug.
2016-07-03 19:42:52 +02:00
Niklas Haas 3abf9c9204 vo_opengl: don't constantly resize the output FBO
Commit 883d3114 seems to have (accidentally?) dropped the FBOTEX_FUZZY
from the output_fbo resize, which means that current master will keep
resizing and resizing the FBO as you change the window size, introducing
severe memory leaking after a while. (Not sure why that would cause
memory leaks, but I blame nvidia)

Either way, it's bad for performance too, so it's worth fixing.
2016-07-03 19:42:52 +02:00
wm4 ea23a86f49 sub: remove unused sub_bitmaps.scaled field 2016-07-03 19:32:43 +02:00
wm4 8ed32e90c9 sub: move RGBA scaling to vo_vaapi
vo_vaapi is the only thing which can't scale RGBA on the GPU. (Other
cases of RGBA scaling are handled in draw_bmp.c for some reason.)

Move this code and get rid of the osd_conv_cache thing.

Functionally, nothing changes.
2016-07-03 19:32:43 +02:00
wm4 37cf92c07a sub: change how libass output is converted to RGBA in some cases
This affects VOs (or other code which render OSD) which does not support
the LIBASS format, but only RGBA. Instead of having a converter stage in
osd.c, make mp_ass_packer_pack() output directly in RGBA.

In general, this is work towards refcounted subtitle images.

Although we could keep the "converter" design, doing it this way seems
simpler, at least considering the current situation with only 2 OSD
formats. It also prevents copying & packing the data twice, which will
lead to better performance. (Although I guess this case is not important
at all.)

It also fixes --force-rgba-osd-rendering when used with vo_opengl,
vo_vdpau, and vo_direct3d.
2016-07-03 19:32:31 +02:00
wm4 59972fbfe1 sub: move around some code
Put the packing code into separate functions. Preparation for the
following commit.
2016-07-03 19:32:00 +02:00
wm4 f110552898 sub: pass preferred OSD format to subtitle renderers
The intention is to let mp_ass_packer_pack() produce different output
for the RGBA and LIBASS formats. VOs (or whatever generates the OSD)
currently do not signal a preferred format, and this mechanism just
exists to switch between RGBA and LIBASS formats correctly, preferring
LIBASS if the VO supports it.
2016-07-03 19:31:56 +02:00
wm4 315e2e3da8 vo_opengl: remove caching GL_MAX_TEXTURE_SIZE value
No real need to cache this, and we need fewer fields in the OSD part
struct.

Also add logging for when the OSD texture is reallocated.
2016-07-03 17:33:59 +02:00
wm4 b57debe5b3 vo_opengl: use ringbuffer of PBOs
This is how PBOs are normally supposed to be used.

Unfortunately I can't see an any absolute improvement on nVidia binary
drivers and playing 4K material. Compared to the "old" PBO path with 1
buffer, the measured GL time decreases significantly, though.
2016-07-03 16:34:32 +02:00
wm4 8c7f9dc1a8 vo_opengl: support inconsistent negative strides per plane
GL generally does not support flipping the image on upload, meaning
negative strides are not supported. vo_opengl handles this by flipping
rendering if the stride is inverted, and gl_pbo_upload() "ignores"
negative strides by uploading without flipping the image.

If individual planes had strides with different signs, this broke. The
flipping affected the entire image, and only the sign of the first plane
was respected.

This is just a crazy corner case that will never happen, but it turns
out this is quite simple to support, and actually improves the code
somewhat.
2016-07-03 16:34:32 +02:00
wm4 823c353faa vo_opengl: move PBO upload handling to shared code
This introduces a gl_pbo_upload_tex() function, which works almost like
our gl_upload_tex() glTexSubImage2D() wrapper, except it takes a struct
which caches the PBO handles. It also takes the full texture size (to
make allocating an ideal buffer size easier), and a parameter to disable
PBOs (so that the caller doesn't have to duplicate the gl_upload_tex()
call if PBOs are disabled or unavailable).

This also removes warnings and fallbacks on PBO failure. We just
silently try using PBOs on every frame, and if that fails at some point,
revert to normal texture uploads. Probably doesn't matter.
2016-07-03 16:34:32 +02:00
James Ross-Gowan 06219c7f88 w32_common: make WM_NCHITTEST simpler and more accurate
This makes the geometry of the sizing borders more like the ones in
Windows 10. It also fixes an off-by-one error that made the right and
bottom borders thinner than the left and top borders, which made it
difficult to resize the window when using the Windows 7 classic theme
(because it has pretty thin sizing borders to begin with.)
2016-07-03 21:58:29 +10:00
wm4 5d47f9a565 manpage: document confusing "vf clr" command usage 2016-07-03 13:45:18 +02:00
wm4 1298c29dc7 player: add missing space to error message 2016-07-02 18:26:55 +02:00
Ben Boeckel 76a73a0a5d vd_lavc: hide structs behind platform flags
Otherwise, warnings about them being unused appear.
2016-07-01 19:12:34 -04:00
Ben Boeckel b2ce00ed56 readme: fix typo 2016-07-01 19:12:26 -04:00
wm4 d057e7a142 player: fatal error if linked and compiled FFmpeg versions mismatch
We don't support this anymore.

This tries to exit in a controlled way after command line options are
applied in order to honor logging options and, in case of libmpv, not to
kill the host. Not sure if it would be better to just vomit text to
stderr and call abort().
2016-07-01 20:56:59 +02:00
wm4 3738bfb451 bitmap_packer: remove some unused functions 2016-07-01 20:29:45 +02:00
wm4 8523e1fd95 sub: set ASS sub bitmap data to correct pointer
Point it to the copied data. Doesn't really matter at this point, but
later it might have left dangling pointers.
2016-07-01 20:28:49 +02:00
wm4 fd5098a409 vo_direct3d: remove bitmap packer
See previous comments.
2016-07-01 20:28:49 +02:00
wm4 c0f272fcd1 vo_vdpau: remove bitmap packer use
See previous commit.
2016-07-01 20:28:49 +02:00
wm4 1b71cfccba vo_opengl: remove OSD bitmap packing
It's packed in the OSD common layer already.
2016-07-01 20:28:49 +02:00
wm4 549a9ea6fa command: pack sub image data in overlay-add command
Working towards refcounted sub images, and also for removing bitmap
packers from VOs.

I'm not sure why we even have this overlay-add command. It was sort of
"needed" before opengl-cb was introduced, and before Lua scripts could
put ASS drawings on OSD without conflicting with the OSC. But now trying
to use it doesn't make too much sense anymore.

Still keep it because we're trying to be nice, but throw performance out
of the window. Now image data is copied 2 more times before displaying
it. This also makes using the command a bit simpler.
2016-07-01 20:22:09 +02:00
wm4 614efea3e6 ad_lavc: work around braindead ffmpeg behavior
The libavcodec wmapro decoder will skip some bytes at the start of the
first packet and return each time. It will not return any audio data in
this state.

Our own code as well as libavcodec's new API handling
(avcodec_send_packet() etc.) discard the PTS on the first return, which
means the PTS is never known for the first packet. This results in a
"Failed audio resync." message.

Fixy it by remember the PTS in next_pts. This field is used only if the
decoder outputs no PTS, and is updated after each frame - and thus
should be safe to set.

(Possibly this should be fixed in libavcodec new API handling by not
setting the PTS to NOPTS as long as no real data has been output. It
could even interpolate the PTS if the timebase is known.)

Fixes the failure message seen in #3297.
2016-07-01 15:51:34 +02:00
wm4 c57304a591 sub: pack libass bitmaps directly in sd_ass.c and osd_libass.c
Change all producer of libass images to packing the bitmaps into a
single larger bitmap directly when they're output. This is supposed to
help working towards refcounted sub bitmaps.

This will reduce performance for VOs like vo_xv, but not for vo_opengl.
vo_opengl simply will pick up the pre-packed sub bitmaps, and skip
packing them again. vo_xv will copy and pack the sub bitmaps
unnecessarily - but if we want sub bitmap refcounting, they'd have to be
copied anyway.

The packing code cannot be removed yet from vo_opengl, because there are
certain corner cases that still produce unpackad other sub bitmaps.
Actual refcounting will also require more work.
2016-06-30 21:38:50 +02:00
wm4 2d6da37b6b README: declare that we do not respect FFmpeg ABI rules 2016-06-29 21:16:42 +02:00
wm4 e40851ea22 options: deprecate --heartbeat-cmd
It's useless. --heartbeat-interval is also considered deprecated, but
this is not made explicit.
2016-06-29 18:10:15 +02:00
wm4 9ed5dae480 options: add a deprecation warning printing mechanism
We have a warning mechanism for removed and for replaced options, but
none yet for options which have been simply deprecated.

For the following commit.

(Fun fact: just adding the m_option field increases binary size by
14KB.)
2016-06-29 18:09:30 +02:00
wm4 c6953bfa8c ao_oss: do not add an entry to audio-device-list if device file missing
This effectively makes it go away on Linux (unless you have OSS
emulation loaded).
2016-06-29 17:40:04 +02:00
wm4 deb1c3c7a8 audio: don't add default entry to audio-device-list if AO support listing
In such cases there isn't really a reason to do so, and using such an
entry would probably fail anyway.

Also convenient for the following commit.
2016-06-29 17:38:57 +02:00
wm4 9ca1592f3f d3d: implement screenshots for --hwdec=d3d11va
No method of taking a screenshot was implemented at all. vo_opengl
lacked window screenshotting, because ANGLE doesn't allow reading the
frontbuffer. There was no way to read back from a D3D11 texture either.

Implement reading image data from D3D11 textures. This is a low-quality
effort to get basic screenshots done. Eventually there will be a better
implementation: once we use AVHWFramesContext natively, the readback
implementation will be in libavcodec, and will be able to cache the
staging texture correctly. Hopefully. (For now it doesn't even have a
AVHWFramesContext for D3D11 yet. But the abstraction is more appropriate
for this purpose.)
2016-06-28 20:38:53 +02:00
wm4 17c5738cb4 d3d: merge angle_common.h into d3d.h
OK, this was dumb. The file didn't have much to do with ANGLE, and the
functionality can simply be moved to d3d.c. That file contains helpers
for decoding, but can always be present (on Windows) since it doesn't
access any D3D specific libavcodec APIs. Thus it doesn't need to be
conditionally built like the actual hwaccel wrappers.
2016-06-28 20:07:56 +02:00
Muhammad Faiz d5615102d5 vo_opengl: add output_size uniform to custom shader
logically, scaler should know its input and output size

Signed-off-by: wm4 <wm4@nowhere>
2016-06-28 19:52:55 +02:00
wm4 40c9b38023 vo_opengl: minor typo and coding style fixes 2016-06-28 19:48:29 +02:00
Niklas Haas dc9a5cbfd7 vo_opengl: revise the transfer curve logic
Instead of hard-coding a big list, move some of the functionality
to csputils. Affects both the auto-guess blacklist and the peak
estimation.

Also update the comments.
2016-06-28 19:48:29 +02:00
Niklas Haas 65499d863a csputils: adjust whitespace
All these blank lines felt sort of weird, especially since the functions
were semantically related.
2016-06-28 19:48:29 +02:00
Niklas Haas 6e6c32ed6c vo_opengl: revise the logic for picking the default color space
Too many "exceptions" these days, it's easier to just hard-code a
whitelist instead of a blacklist. And besides, it only really makes
sense to avoid adaptation for BT.601 specifically, since that's the one
we auto-guess based on the resolution.
2016-06-28 19:48:29 +02:00
Niklas Haas f9fe5d06ad vo_opengl: use image_params instead of *_src for autoconfig
I'm not even sure why we ever consulted *_src to begin with, since that
just describes the current image format - and not the original metadata.
(And in fact, we specifically had logic to work around the impliciations
this had on linear scaling)

image_params is *the* authoritative source on the intended (i.e.
reference) image metadata, whereas *_src may be changed by previous
passes already. So only consult image_params for picking auto-generated
values.

Also, add some more missing "wide gamut" and "non-gamma" curves to the
autoconfig blacklist. (Maybe it would make sense to move this list to
csputils in the future? Or perhaps even auto-detect it based on the
associated primaries)
2016-06-28 19:48:29 +02:00
Niklas Haas f3b6966d14 vo_opengl: implement the Panasonic V-Log function
User request and not that hard. Closes #3157.

Note that FFmpeg doesn't support this and there's no signalling in HEVC
etc., so the only way users can access it is by using vf_format
manually.

Mind: This encoding uses full range values, not TV range.
2016-06-28 19:48:29 +02:00
Niklas Haas 740fdc139f manpage: add missing documentation for vf_format:gamma=dci-p3 2016-06-28 19:48:29 +02:00
Niklas Haas 247ec0cb84 csputils: add Panasonic V-Gamut primaries
This is actually not entirely trivial since it involves negative Yxy
coordinates, so the CMM has to be capable of full floating point
operation. Fortunately, LittleCMS is, so we can just blindly implement
it.
2016-06-28 19:48:29 +02:00
Niklas Haas 13a63331b6 manpage: warn about the use of HDR functions for target-trc
Most devices seems to require special signalling (e.g. via HDMI
metadata) to actually decode HDR signals and treat them as such, so it's
probably worth warning the potential user about the fact that mpv pretty
definitely does *not* set any of this metadata signalling.
2016-06-28 19:48:29 +02:00
Niklas Haas 9278ce98f7 vo_opengl: implement ARIB STD-B68 (HLG) HDR TRC
This HDR function is unique in that it's still display-referred, it just
allows for values above the reference peak (super-highlights). The
official standard doesn't actually document this very well, but the
nominal peak turns out to be exactly 12.0 - so we normalize to this
value internally in mpv. (This lets us preserve the property that the
textures are encoded in the range [0,1], preventing clipping and making
the best use of an integer texture's range)

This was grouped together with SMPTE ST2084 when checking libavutil
compatibility since they were added in the same release window, in a
similar timeframe.
2016-06-28 19:48:29 +02:00
wm4 4ce53025cb audio: add a helper for getting frame end PTS
Although I don't see any use for it yet, why not.
2016-06-27 15:12:21 +02:00
wm4 3e58ce96ac dec_audio: fix segment boudnary switching
Some bugs in this code are exposed by e.g. playing lossless audio files
with --ad-lavc-threads=16. (libavcodec doesn't really support threaded
audio decoding, except for lossless files.) In these cases, a major
amount of audio can be buffered, which makes incorrect handling of this
buffering obvious.

For one, draining the decoder can take a while, so if there's a new
segment, we shouldn't read audio.

The segment end check was completely wrong, and used the start value.
2016-06-27 15:12:21 +02:00
Rudolf Polzer acb74236ac ao_lavc, vo_lavc: Migrate to new encoding API.
Also marked some places for possible later refactoring, as they became
quite similar in this commit.
2016-06-27 08:33:12 -04:00
stepshal c5094206ce Fix misspellings 2016-06-26 13:47:21 +02:00
quilloss 24478a8a72 vo_opengl utils: use gl->main_fb when reading window content
The main framebuffer is not the default framebuffer for the dxinterop
backend. Bind the main framebuffer and use the appropriate attachment
when reading the window content.

Fix #3284
2016-06-26 13:17:39 +02:00
wm4 e081e46950 manpage: fix typo 2016-06-26 12:33:16 +02:00
wm4 22c76e85db vo_xv: fix behavior with odd sizes
The size check introduced in commit d941a57b did not consider that Xv
can round up the image size to the next chroma boundary. Doing that
makes sense, so it can't certainly be considered server misbehavior.

Do 2 things against this: allow if the server returns a larger image (we
just crop it then), and also allocate a properly aligned image in the
first place.
2016-06-25 12:44:42 +02:00
wm4 d1d864546c DOCS: change version references from 0.17.1 to 0.18.0
0.17.1 was never released, so the actual 0.18.0 release takes its place.
2016-06-25 12:39:08 +02:00
Martin Herkt 69e7b0d3ea Release 0.18.0 2016-06-25 03:23:40 +02:00
Martin Herkt ad56f2c46a Merge branch 'master' into release/current 2016-06-25 02:25:44 +02:00
wm4 393bb2a565 image_writer: port to new encode API 2016-06-24 18:20:36 +02:00
wm4 ea098d3462 ass_mp.h: remove conditional inclusion guards
This file is only used when libass is enabled. (It used to be different,
when code was more entangled.)
2016-06-24 18:05:34 +02:00
wm4 1c3bbd9318 af_lavcac3enc: use av_err2str() call (fixes Libav build)
I added this call because I thought it'd be nice, but Libav doesn't have
this function (macro, actually).
2016-06-23 12:41:41 +02:00
wm4 e911e208b8 af_lavcac3enc: make encoder configurable 2016-06-23 12:14:45 +02:00
wm4 5c74da4503 af_lavcac3enc: implement flushing on seek
There's a lot of data that could have been buffered, and which has to be
discarded.
2016-06-23 12:07:05 +02:00
wm4 c071c30bcd af_lavcac3enc: port to new encode API 2016-06-23 12:04:04 +02:00
wm4 b01855714b af_lavcac3enc: automatically configure most encoder parameters
Instead of hardcoding what the libavcodec ac3 encoder expects, configure
it based on the AVCodec fields.

Unfortunately, it doesn't export the list of sample rates, so that is
done manually. This commit actually fixes the rate always to 48Khz. I
don't even know whether the other rates worked. (Possibly did, but
they'd still change the spdif parameters, and would work differently
from ad_spdif.c.)
2016-06-23 12:02:36 +02:00
wm4 5a60f594e5 af_lavcac3enc: drop log message prefixes
MPlayer leftover. They're already added by the logging code.
2016-06-23 10:45:56 +02:00
wm4 31b73d5ca0 af_lavcac3enc: fix custom bitrates
Probably has been broken for ages.

(Not sure why anyone would use this feature, though.)
2016-06-23 10:43:54 +02:00
wm4 b753c229f7 vo_opengl: improve missing function warning
Mostly a cosmetic change. Handling bultin and extension functions
separaterly makes more sense here too.
2016-06-22 21:55:00 +02:00
wm4 7ea22fe889 ad_lavc: resume from mid-stream EOF conditions with new decode API
Workaround for an awful corner-case. The new decode API "locks" the
decoder into the EOF state once a drain packet has been sent. The
problem starts with a file containing a 0-sized packet, which is
interpreted as drain packet.

This should probably be changed in libavcodec (not treating 0-sized
packets as drain packets with the new API) or in libavformat (discard
0-sized packets as invalid), but efforts to do so have been fruitless.

Note that vd_lavc.c already does something similar, but originally for
other reasons.

Fixes #3106.
2016-06-22 21:37:36 +02:00
dirb 9d0af06811 vo_opengl: add scaler name to the 'Disabling scaler' message
Print to the user the name of the scaler that gets disabled rather than
just printing its number.
2016-06-22 18:16:43 +02:00
wm4 6f9973618c vf_vdpaurb: use new common nv12 download code
See previous commit. (The mixing case was never supported, so this has
equivalent functionality.)

This also implicitly fixes a bug: the old code allocated image data for
the cropped surface size only, which means the
video_surface_get_bits_y_cb_cr call could write beyond the allocated
image memory.
2016-06-21 21:44:13 +02:00
wm4 b40d8fdfa3 vdpau: get surface data as nv12 if possible
For now, this affects taking screenshots only.

If the video mixer is actually needed, we want to go through the video
mixer for screenshots too - which is why this function simply always
used the video mixer, and then copied the surface to RAM as RGBA.

Add reading the surface as nv12 if possible. If the format is correct,
and no special video processing (like deinterlacing) is used, then it's
read directly without going through the video mixer.

There's no particular reason for doing this, other than avoiding the
video mixer (like vo_opengl can do it now). Also, the next commit will
make use of this in vf_vdpaurb.c.
2016-06-21 21:31:58 +02:00
wm4 22291a2587 command: improve playlist* properties change notifications
Until now, only the "playlist" property itself had proper change
notification. Extend it to all other properties as well.

Fixes #3267 (hopefully).
2016-06-20 21:35:59 +02:00
wm4 fc50f3772c github: move "reproduction steps" before behavior sections 2016-06-20 20:06:54 +02:00
Floens 65280e47cd vo_opengl: manually add the GL_BACK_LEFT constant for GLES
GLES doesn't have this constant. It's not used on GLES.
I'm starting to think we need some better way to do this.
2016-06-20 19:24:42 +02:00
Floens 30adf280fd vo_opengl: GL_ARB_timer_query compile fix for GLES
The GL_ARB_timer_query extension and thus the GL_TIME_ELAPSED constant
don't exist for GLES.
For ES the EXT_disjoint_timer_query is used so take the constant from
that else provide the constant manually.
See pr #3216 which introduced this error.
2016-06-20 19:24:42 +02:00
wm4 9bac0ea421 vf_vdpaurb: fix operation
The hw_subfmt field remained set, while it has to be unset for non-hwdec
formats.
2016-06-20 19:10:58 +02:00
wm4 761eeacf54 vo_opengl: unmap hwdec images once rendering is done
Instead of keeping them for a while. While keeping the mapping was
perfectly ok, nothing speaks against reducing the time they're mapped.
2016-06-20 13:57:46 +02:00
wm4 7be37337f4 vo_opengl: vdpau interop without RGB conversion
Until now, we've always converted vdpau video surfaces to RGB, and then
mapped the resulting RGB texture. Change this so that the surface is
mapped as NV12 plane textures.

The reason this wasn't done until now is because vdpau surfaces are
mapped in an "interlaced" way as separate fields, even for progressive
video. This requires messy reinterleraving. It turns out that even
though it's an extra processing step, the result can be faster than
going through the video mixer for RGB conversion.

Other than some potential speed-gain, doing this has multiple other
advantages. We can apply our own color conversion, which is important in
more complex cases. We can correctly apply debanding and potentially
other processing that requires chroma-specific or in-YUV handling.

If deinterlacing is enabled, this switches back to the old RGB
conversion method. Until we have at least a primitive deinterlacer in
vo_opengl, this will stay this way. The d3d11 and vaapi code paths are
similar. (Of course these don't require any crazy field reinterleaving.)
2016-06-19 19:58:40 +02:00
wm4 754ad1d730 refqueue: free referenced images on free
Otherwise stale references will survive forever. Could leak hardware
video surfaces.

In particular, the mpv vdpau code crashed with an assertion when exiting
after toggling deinterlacing, because not all references were released.
2016-06-19 19:52:49 +02:00
wm4 0cf187caca bitmap_packet: let max=0 mean unlimited
And remove the strange PACKER_MAX_WH define. This is more convenient for
users which don't care about limits, such as sd_lavc.c.
2016-06-18 19:31:23 +02:00
wm4 07c11656e3 sd_lavc: fix sub-bitmap alignment
Ooops.
2016-06-18 19:30:38 +02:00
Bin Jin 67a6203ce0 vo_opengl: remove prescaling framework with superxbr prescaler
Signed-off-by: wm4 <wm4@nowhere>
2016-06-18 19:17:28 +02:00
Bin Jin 3df95ee57a vo_opengl: remove uniform buffer object routines 2016-06-18 19:16:31 +02:00
Bin Jin 61bc96518a vo_opengl: remove nnedi3 prescaler 2016-06-18 19:16:27 +02:00
Akemi 47d9fbd133 cocoa: fix display refresh rate retrieval on multi monitor setups
1. this basically reverts commit de4c74e5a4.
even with CVDisplayLinkCreateWithActiveCGDisplays and
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext we still have to
explicitly set the current display ID, otherwise it will just always
choose the display with the lowest refresh rate. another weird thing is,
we still have to set the display ID another time with
CVDisplayLinkSetCurrentCGDisplay after the link was started. otherwise
the display period is 0 and the fallback will be used.
if we ever use the callback method for something useful it's probably
better to use CVDisplayLinkCreateWithActiveCGDisplays since we will need
to keep the display link around instead of releasing it at the end.
in that case we have to call CVDisplayLinkSetCurrentCGDisplay two times,
once before and once after LinkStart.
2. add windowDidChangeScreen delegate to update the display refresh rate
when mpv is moved to a different screen.
2016-06-18 19:15:36 +02:00
Akemi fb7c5804bb cocoa: fix actual display refresh rate retrieval
We have two problems here.
1. CVDisplayLinkGetActualOutputVideoRefreshPeriod, like the name suggests,
returns a frame period and not a refresh rate. using this as screen_fps
just leads to a slideshow. why didn't this break video playback on OS X
completely? the answer to this leads us to the second problem.
2. it seems that CVDisplayLinkGetActualOutputVideoRefreshPeriod always
returns 0 if used without CVDisplayLinkSetOutputCallback and hence always
fell back to CVDisplayLinkGetNominalOutputVideoRefreshPeriod. adding a
callback to CVDisplayLink solves this problem. the callback function at
this moment doesn't do anything but could possibly used in the future.
2016-06-18 19:15:34 +02:00
James Ross-Gowan 0fd5a24ecb vo_opengl: dxinterop: render to gl->main_fb
This can also remove all the stuff for lazily attaching the texture. It
doesn't matter if the dxinterop backend changes the bound framebuffer
during a VOCTRL, since the renderer does not rely on the GL state being
preserved.
2016-06-18 23:51:57 +10:00
wm4 4a15bc6d73 vo_opengl: add ability to render to an arbitrary backing framebuffer
Most of the functionality already exists for the sake of vo_opengl_cb.
We only have to use it.

This will be used by dxinterop in the following commit.
2016-06-18 15:16:29 +02:00
wm4 9215a9e598 sd_lavc: align sub-bitmaps for the sake of libswscale
Since there are not many sub-rectangles, this doesn't cost too much. On
the other hand, it avoids frequent warnings with vo_xv.

Also, the second copy in mp_blur_rgba_sub_bitmap() can be dropped.
2016-06-18 12:08:17 +02:00
wm4 689cf04571 sd_lavc: fix typo 2016-06-18 10:49:41 +02:00
wm4 8e6704acdb sub, vo_opengl: use packed sub-bitmaps directly if available
The previous few commits changed sd_lavc.c's output to packed RGB sub-
images. In particular, this means all sub-bitmaps are part of a larger,
single bitmap. Change the vo_opengl OSD code such that it can make use
of this, and upload the pre-packed image, instead of packing and copying
them again.

This complicates the upload code a bit (4 code paths due to messy PBO
handling). The plan is to make sub-bitmaps always packed, but some more
work is required to reach this point. The plan is to pack libass images
as well. Since this implies a copy, this will make it easy to refcount
the result.

(This is all targeted towards vo_opengl. Other VOs, vo_xv, vo_x11, and
vo_wayland in particular, will become less efficient. Although at least
vo_vdpau and vo_direct3d could be switched to the new method as well.)
2016-06-17 23:15:50 +02:00
wm4 28c7dec157 sd_lavc: change hack against vobsubs with wrong resolution
The sub-bitmaps get extended by --sub-gauss, so we have to compute the
bounding box on the original subs. Not sure if this is really
eqauivalent to what the code did before, and I don't have the sample
anymore. (But this approach sure is a _shitty_ hack.)
2016-06-17 23:15:39 +02:00
wm4 56058a95e5 sub: fix --sub-gauss
Implement it directly in sd_lavc.c as well. Blurring requires extending
the size of the sub-images by the blur radius. Since we now want
sub_bitmaps to be packed into a single image, and we don't want to
repack for blurring, we add some extra padding to each sub-bitmap in the
initial packing, and then extend their size later. This relies on the
previous bitmap_packer commit, which always adds the padding in all
cases.

Since blurring is now done on parts of a large bitmap, the data pointers
can become unaligned, depending on their position. To avoid shitty
libswscale printing a dumb warning, allocate an extra image, so that the
blurring pass is done on two newly allocated images. (I don't find this
feature important enough to waste more time on it.)

The previous refactor accidentally broke this feature due to a logic bug
in osd.c. It didn't matter before it happened to break, and doesn't
matter now since the code paths are different.
2016-06-17 23:14:26 +02:00
wm4 f72eb5b394 sub: move paletted image handling completely to sd_lavc.c
Until now, subtitle renderers could export SUBBITMAP_INDEXED, which is a
8 bit per pixel with palette format. sd_lavc.c was the only renderer
doing this, and the result was converted to RGBA in every use-case
(except maybe when the subtitles were hidden.)

Change it so that sd_lavc.c converts to RGBA on its own. This simplifies
everything a bit, and the palette handling can be removed from the
common code.

This is also preparation for making subtitle images refcounted. The
"caching" in img_convert.c is a PITA in this respect, and needs to be
redone. So getting rid of some img_convert.c code is a positive side-
effect. Also related to refcounted subtitles is packing them into a
single mp_image. Fewer objects to refcount is easier, and for the libass
format the same will be done. The plan is to remove manual packing from
the VOs which need single images entirely.
2016-06-17 23:13:14 +02:00
wm4 454fff39ad bitmap_packer: make manual use slightly more convenient
Apply the padding internally to each input bitmap, instead of requiring
this for the semi-public API.

Right now, everything still uses packer_pack_from_subbitmaps() to fill
the input bitmap sizes, but that's going to change with the following
commit. Since bitmap_packer.in is mutated during packing anyway, it's
more convenient to add the padding automatically.

Also, guarantee that every sub-bitmap has a padding border around it.
Don't let the padding overlap. Add padding even on the containing
borders.

This is simpler, doesn't cost much in memory usage, and is convenient
for one of the following commits.
2016-06-17 23:12:43 +02:00
wm4 8986b37fe7 sd_lavc: move AVSubtitle bitmap setup code into its own function
No functional changes.
2016-06-17 23:12:34 +02:00
wm4 d0bd39eb90 Add github issue and pull request templates
I do not understand why github requires adding this crap to source code
repositories themselves, instead of making them part of the repository
configuration. Remove CONTRIBUTING.md to compensate for github crap
accumulating.
2016-06-17 16:16:03 +02:00
wm4 7ecac3ae6f d3d11va: remove unused d3d11va_surface.subindex field
This is now stored within the AVFrame/mp_image.
2016-06-16 18:13:46 +02:00
wm4 a6074a3375 vf_d3d11vpp: flush device context only when using shared textures
Reduces interference with pass-through case, where this is not needed.
2016-06-16 17:29:53 +02:00
wm4 36f8d41702 vf_d3d11vpp: make missing deinterlacing caps non-fatal
Instead, warn.
2016-06-16 17:17:54 +02:00
wm4 1878a4655d vf_d3d11vpp: log some video processor creation parameters 2016-06-16 16:34:51 +02:00
James Ross-Gowan 5700da4a8f vo_opengl: use EXT_disjoint_timer_query for timers
This is the ES equivalent to ARB_timer_query. It enables the performance
timers on ANGLE. All the added functions should be identical in
semantics to their desktop GL equivalents.
2016-06-15 20:32:47 +10:00
wm4 43e964e2d6 vo_opengl: fix framebuffer object name
The OpenGL 3.0+ and ES specs are quite clear on what values are
accepted for the attachment object name parameter. And there's no
overlap for the default framebuffer. Sigh.

Probably fixes Mesa raising an error in this case and might fix #3251.
Regression by the previous vo_opengl change.
2016-06-15 00:55:27 +02:00
wm4 a30e727266 demux_mkv: support Matroska webvtt
They're different from the Google/WebM subtitle types, and use a new
codec ID.

Fixes #3247.
2016-06-14 16:43:07 +02:00
wm4 788929e4e0 vo_opengl: use standard functions to retrieve display depth
Until now, we've used system-specific API (GLX, EGL, etc.) to retrieve
the depth of the default framebuffer. (We equal this to display depth
and use the determined depth for dithering.)

We can actually retrieve this value through standard GL API, and it
works everywhere (except GLES 2 of course). This simplifies everything a
great deal.

egl_helpers.c is empty now. But I expect that some EGL boilerplate will
be moved to it, so don't remove it yet.
2016-06-14 10:35:43 +02:00
wm4 3682df2dd5 vo_opengl: hwdec_d3d11egl: remove ES2 swizzle special-case
This was somehow done under the assumption that ANGLE would somehow
always use RG in ES2 mode. But there's no basis for this. Even if ANGLE
supports NV12 textures with drivers that do not allow for texture_rg,
this cas eis too obscure to worry about. So do the robust and correct
thing instead, and disable this code if texture_rg is not available.
2016-06-13 16:15:57 +02:00
Gusar321 81ec9cf596 vo_rpi: fix destroying overlays
Commit 74e3d11 resulted in the background overlay not getting destroyed
when mpv quits. Add back a piece of code that was removed in that commit
to restore correct functionality.

Fixes issue #3100
2016-06-13 14:48:11 +02:00
wm4 b00eab525a audio: apply an upper bound timeout when draining
This helps with shitty APIs and even shittier drivers (I'm looking at
you, ALSA). Sometimes they won't send proper wakeups. This can be fine
during playback, when for example playing video, because mpv still will
wakeup the AO outside of its own wakeup mechanisms when sending new data
to it. But when draining, it entirely relies on the driver's wakeup
mechanism. So when the driver wakeup mechanism didn't work, it could
hard freeze while waiting for the audio thread to play the rest of the
data.

Avoid this by waiting for an upper bound. We set this upper bound at the
total mpv audio buffer size plus 1 second. We don't use the get_delay
value, because the audio API could return crap for it, and we're being
paranoid here. I couldn't confirm whether this works correctly, because
my driver issue fixed itself.

(In the case that happened to me, the driver somehow stopped getting
interrupts. aplay froze instead of playing audio, and playing audio-only
files resulted in a chop party. Video worked, for reasons mentioned
above, but drainign froze hard. The driver problem was solved when
closing all audio output streams in the system. Might have been a dmix
related problem too.)
2016-06-12 21:05:10 +02:00
wm4 972ea9ca59 audio: do not wake up core during EOF
When we're draining, don't wakeup the core on every buffer fill, since
unlike during normal playback, we won't actually get more data. The
wakeup here conceptually works like wakeups with condition variables, so
redundant wakeups do not hurt, so this is just a minor change and
nothing of consequence.

(Final EOF also requires waking up the core, but there is separate code
to send this notification.)

Also dump the p->still_playing field in trace logging.
2016-06-12 20:59:11 +02:00
Bin Jin 3d844cddf8 vo_opengl: make size of OUTPUT available to user shaders 2016-06-12 17:51:50 +02:00
wm4 0b082b2086 player: fix previous commit
Of course we can't just skip updating the OSD if the playloop was woken
up for the purpose of removing OSD after an OSD timer expired.

Fixes e.g. OSD bars sometimes sticking along when seeking while paused.
2016-06-12 12:52:35 +02:00
wm4 bb9aad097a player: do not update OSD all the time when paused
Normally, OSD is updated every time the playloop is run. This has to be
done, because the OSD may implicitly reference various properties,
without knowing whether they really need to be updated or not. (There's
a property update mechanism, but it's mostly unavailable, because OSD is
special-cased and can not use the client API mechanism properly.)

Normally, these updates are no problem, because the OSD is only actually
printed when the OSD text actually changes.

But commit d23ffd24 added a rate-limiting mechanism, which tries to
limit OSD updates at most every 50ms (or the next video frame). Since it
can't know in advance whether the OSD is going to change or not, this
simply waked up the player every 50ms.

Change this so that the player is updated only as part of general
updates determined through mp_notify(). (This function also notifies the
client API of changed properties.) The desired result is that the player
will not wake up at all in normal idle mode, but still update properties
that can change when paused, such as the cache.

This is mostly a cosmetic change (in the sense of making runtime
behavior just slightly better). It has the slightly more negative
consequence that properties which update implicitly (such as "clock")
will not update periodically anymore.
2016-06-11 18:40:08 +02:00
James Ross-Gowan 9fcc517cee win32: use HINST_THISCOMPONENT
This is a common idiom used in MSDN docs and Raymond Chen's example
programs to get a HINSTANCE for the current module, regardless of
whether it's an .exe or a .dll. Using GetModuleHandle(NULL) for this is
technically incorrect, since it always gets a handle to the .exe, even
when the executing code (in libmpv) is running in a .dll. In this case,
using the wrong HINSTANCE could cause namespace issues with window
classes, since CreateWindowEx uses the HINSTANCE to search for the
matching window class name.

See:
https://blogs.msdn.microsoft.com/oldnewthing/20050418-59/?p=35873
https://blogs.msdn.microsoft.com/oldnewthing/20041025-00/?p=37483
2016-06-11 15:35:17 +02:00
Stefano Pigozzi de4c74e5a4 cocoa: use displaylink without manually tracking the display id
Maybe it partially helps with #2392 (on dual display setups). Either way, it
makes the code simpler.
2016-06-11 11:58:07 +02:00
Rudolf Polzer 9cc5507079 vo_sdl: fix pixel formats.
There were two mistakes:

- SDL's RGB565 is always equivalent to ffmpeg's RGB565 (both are packed 16bit
  native-endian integers in RGB=565 form) - this was wrongly reversed on
  big endian platforms.
- SDL's RGB888 doesn't actually mean RGB24, but XRGB8888 (i.e. 32bit
  packed integer, top 8 bits unused).
- Use RGB0 not RGBA when there is no alpha.
2016-06-10 16:30:12 -04:00
wm4 bea2e39721 vo_opengl: request core profile on X11/EGL too
Avoids that some OpenGL implementation will pin it to 3.0.
2016-06-10 20:31:28 +02:00
Bin Jin 2b1656b1ac vo_opengl: increase the size limit for cached file
This is mainly for the nnedi3 user shader. With all whose NN weights
hardcoded into the shader source code, the shader file could be as
large as 300 kB.
2016-06-10 17:08:54 +02:00
wm4 1c5fd2d901 Revert "wscript: Require recent FFmpeg by default"
This reverts commit b51957fab5.

Breaks big time. It appears to ignore explicitly configured paths within
the libav* .pc files, which for example breaks mpv-build.
2016-06-09 21:05:33 +02:00
wm4 d38d26057a vo_opengl: hwdec_d3d11eglrgb: remove some more unused fields
Not sure what/if I was thinking there.
2016-06-09 18:43:40 +02:00
wm4 262ceca731 vo_opengl: fix d3d11 hardware decoding probing on Windows 7
Although D3D11 video decoding is unuspported on Windows 7, the
associated APIs almost work. Where they fail is texture creation, where
we try to create D3D11_BIND_DECODER surfaces. So specifically try to
detect this situation.

One issue is that once the hwdec interop is created, the damage is done,
and it can't use another backend (because currently only 1 hwdec backend
is supported). So that's where we prevent attempts to use it.

It still can fail when trying to use d3d11va-copy (since that doesn't
require an interop backend), but at that point we don't care anymore -
dxva2(-copy) is tried before that anyway.
2016-06-09 11:18:36 +02:00
wm4 6fd7f5a111 vo_opengl: hwdec_d3d11eglrgb: remove unused fields
Leftovers.
2016-06-09 10:51:04 +02:00
Martin Herkt b51957fab5 wscript: Require recent FFmpeg by default
Distros and users alike should be made aware of the fact that old
FFmpeg versions are bad. When users come to us with FFmpeg-related
trouble, the answer is “update FFmpeg” more often than not
(and no further support will be provided until they have done so),
so instead we just nag them about it here.
2016-06-09 01:41:53 +02:00
wm4 4123c9642d vo_opengl: hwdec_vdpau: remove minor code duplication
Move unmap() to the top of the function, and replace some duplicated
code with a call to it.
2016-06-08 22:16:32 +02:00
Niklas Haas ff37d7efec vo_opengl: refactor performance data properties
Instead of having 9 different properties, requiring 18 different
VOCTRLs to read them all, they are now exposed as a single property.
This is not only cleaner (since they're all together) but also allows
querying all 9 of them with only a single VOCTRL (by using
mp.get_property_native).

(The extra factor of 2 was due to an extra query being needed to get the
type, which is now also unnecessary)

This makes it much easier to access performance metrics from within a
lua script, and also makes it easier to just show a readable, formatted
version via show-text.
2016-06-08 22:11:38 +02:00
Niklas Haas 54c48bd801 vo_opengl: make user hook passes optional
User hooks can now use an extra WHEN expression to specify when the
shader should be run. For example, this can be used to only run a chroma
scaling shader `WHEN CHROMA.w LUMA.w <`.

There's a slight semantics change to user shaders: When trying to bind a
texture that does not exist, a shader will now be silently skipped
(similar to when the condition is false) instead of generating an error.

This allows shader stages to depend on an optional earlier stage without
having to copy/paste the same condition everywhere.

(In other words: there's an implicit condition on all of the bound
textures existing)
2016-06-08 20:50:19 +02:00
wm4 a15181e5df vo_opengl: do not leak previous FBO when reallocating it
WTF of the day.
2016-06-08 17:49:23 +02:00
James Ross-Gowan b906eb37ed hwdec_d3d11eglrgb: reduce log level when probing
When using --hwdec=auto, systems that don't provide
D3D11_CREATE_DEVICE_VIDEO_SUPPORT, which probably includes all Windows
Vista and 7 systems, will print an error message. Reduce the log level
to verbose when probing and skip the error message entirely if d3d11.dll
is not present.

This commit is in a similar spirit to 991af7d.
2016-06-09 00:24:49 +10:00
wm4 7373158703 vo_opengl: hwdec_d3d11egl: remove broken code on error path
If ID3D11Device_QueryInterface fails, "multithread" will be set to NULL.
The _Release would just make it crash with a null pointer deref.
2016-06-08 12:57:14 +02:00
wm4 69d5be1ee9 player: remove unused return value 2016-06-08 12:04:56 +02:00
wm4 bd9bba40ee player: tell user about --force-seeking if demuxer is not seekable
This comes up often, see e.g. #3220. The issue is that if the stream
input is not seekable, the demuxer is marked as not seekable. But if the
stream cache is enabled, the file still _might_ be seekable to a degree.
We recently disabled seeking in this mode because it can cause very
weird issues, mostly because if stream-layer seeking fails, the demuxers
will arbitrarily misbehave. On the other hand, it can work if the seek
is within the cached range, which is why the user can still enable it
with --force-seeking. There is a weird trade-off between allowing this
and not crapping up too easily, so just informing the user about the
possibility seems best.
2016-06-08 12:02:06 +02:00
wm4 aeb3df0e2c demux_lavf: assume fully read files (subtitles) are always seekable
Since the libavformat API is crap, we have to apply tons of heuristics
to check whether seeking will work. (No, checking it at seek time isn't
going to work either, because if a seek fails, the demuxer will be in an
undefined state. Because the libavformat API is crap.)
2016-06-08 12:02:06 +02:00
stepshal 9c286d7472 waftools: remove trailing newline 2016-06-08 12:01:57 +02:00
wm4 68796fbdf5 demux: fix memory leak when loading of ordered chapter file is aborted 2016-06-07 21:56:09 +02:00
Niklas Haas 5b5db336e9 build: silence -Wunused-result
For clang, it's enough to just put (void) around usages we are
intentionally ignoring the result of.

Since GCC does not seem to want to respect this decision, we are forced
to disable the warning globally.
2016-06-07 14:12:33 +02:00
Niklas Haas 38ac5d5e7b vo_opengl: avoid outputting ultra-wide-gamut by default
The default behavior of vo_opengl has pretty much always been 'show the
source colors as-is, without caring to adapt it to the target device'.
This decision is mostly based on the fact that if we do anything else,
lots of people will complain.

With the rise of content like BT.2020, however, it turns out more people
complain about this content being very desaturated than people complain
about this content not matching VLC - so let's just map ultra-wide gamut
content back down to standard gamut by default.
2016-06-07 12:18:39 +02:00
Niklas Haas 9bd886f449 vo_opengl: also collect upload perfdata for hwdec
Instead of measuring the actual upload time, this instead measures the
time needed to render + map the texture via vdpau. These numbers are
still useful, since they're part of the critical path.
2016-06-07 12:18:05 +02:00
Niklas Haas 393a069112 vo_opengl: expose performance timers as properties
This is plumbed through a new VOCTRL, VOCTRL_PERFORMANCE_DATA, and
exposed as properties render-time-last, render-time-avg etc.

All of these numbers are in microseconds, which gives a good precision
range when just outputting them via show-text. (Lua scripts can
obviously still do their own formatting etc.)

Signed-off-by: wm4 <wm4@nowhere>
2016-06-07 12:17:25 +02:00
Niklas Haas 8ceb935bd8 vo_opengl: add time queries
To avoid blocking the CPU, we use 8 time objects and rotate through
them, only blocking until the last possible moment (before we need
access to them on the next iteration through the ring buffer). I tested
it out on my machine and 4 query objects were enough to guarantee
block-free querying, but the extra margin shouldn't hurt.

Frame render times are just output at the end of each frame, via MP_DBG.
This might be improved in the future. (In particular, I want to expose
these numbers as properties so that users get some more visible feedback
about render times)

Currently, we measure pass_render_frame and pass_draw_to_screen
separately because the former might be called multiple times due to
interpolation. Doing it this way gives more faithful numbers. Same goes
for frame upload times.
2016-06-07 12:16:15 +02:00
James Ross-Gowan 88b584656d dxva2: remove dead code in failure case
This was made unnecessary by a02d77b, since the only way the function
could fail was by failing to add a reference to the DirectX DLLs.
2016-06-07 18:53:05 +10:00
James Ross-Gowan a9150a49d7 vo_opengl: angle: prevent DXGI hooking Alt+Enter
When ANGLE is using D3D11 and not running in DirectComposition mode,
DXGI will hook the video window's message loop and override Alt+Enter to
trigger a transition to exclusive fullscreen mode (which doesn't even
work with mpv's renderer for some reason.) This behaviour can be
disabled by getting a pointer to the IDXGIFactory associated with the
D3D11 device and calling MakeWindowAssociation with the appropriate
flags.
2016-06-07 18:41:47 +10:00
Kevin Mitchell b3e74f652b ao_wasapi: initialize COM in main thread with MTA
Since the main thread is shared by other things in the player, using STA (single
threaded aparement) may have caused problems. Instead initialize in MTA
(multithreaded apartment).
2016-06-05 16:31:03 -07:00
wm4 c1cb04b6a3 vo_opengl: apply vo-cmdline command incrementally
Instead of implicitly resetting the options to defaults and then
applying the options, they're always applied on top of the current
options (in the same way adding new options to the CLI command line
will).

This does not apply to vo_opengl_cb, because that has an even worse mess
which I refuse to deal with.
2016-06-05 16:56:34 +02:00
wm4 ee337b47be vo_opengl_cb: icc-profile-auto does not and will not work
In theory we could probably make icc-profile-auto a vo_opengl-specific
option, but I won't bother with this. Logging an error is simpler.
2016-06-05 15:00:07 +02:00
wm4 b3a3ed00f0 vo_opengl: possibly update icc profile after changing options
Changing the options can enable icc-profile-auto, and in this case the
profile has to be reteieved again from the system.
2016-06-05 12:21:47 +02:00
wm4 65f5fbc5d4 vo_opengl: somewhat simplify suboption handling mess
Enable m_sub_options_copy() to copy nested sub-options, and also enable
it to create an option struct from defaults. We can get rid of most of
the crap in assign_options() now.

Calling handle_scaler_opt() to get a static allocation for scaler name
is still needed. It's moved to reinit_scaler(), which seems to be a
better place for it. Without it, dangling pointers could be created when
options are changed. (And in fact, this fixes possible dangling pointers
for window.name.) In theory we could create a dynamic copy, but that
seemed even more messy.

Chance of regressions.
2016-06-04 20:48:56 +02:00
wm4 352904fd03 vo_opengl: cleanup icc + runtime option changing behavior
Commit 026b75e7 actually enabled changing icc options at runtime (via
vo_cmdline), but it didn't quite work. In particular, changing the icc-
profile option just kept the old profile, because it was cached
accordingly.

As part of this, change gl_lcms.opts from a struct to a pointer to a
struct. We properly copy it, instead of allowing possibly dangling
strings, like it was done in a working but unclean way before.

Also, reinit the whole rendering chain when the auto icc profile
changes, just like it's done when icc options are changed.
2016-06-04 17:52:10 +02:00
wm4 2dfea67f3b vo_opengl: minor simplification to gl_lcms_set_memory_profile()
Passing the bstr thing as pointer makes no sense. Everywhere else bstr
structs are passed by value because they're so small. Only when it's
supposed to receive a return value they're not.
2016-06-04 14:50:32 +02:00
wm4 a9ffe38aa1 vo_opengl: remove pointless NULL-check
It's never NULL.
2016-06-04 13:44:46 +02:00
wm4 026b75e7f5 vo_opengl: move all icc handling from vo_opengl.c to video.c
Originally, video.c did not access any CMS things (other than lut3d
being set on it), but this has changed. In practice, almost all accesses
to it have moved to video.c. vo_opengl only created it, and set the auto
icc profile path.

Complete the move.

Some things wrt. option handling are a bit fishy. (But when is this not
the case.)

icc-profile-auto was not tested, but the distributed human CI will take
care of it.
2016-06-03 20:35:22 +02:00
wm4 2179879172 vo_opengl: move struct lut3d definition
This was dumb. Also, lcms.h has actually no need to include video.h
besides this and csputils.h (makes it slightly less entangled).
2016-06-03 20:06:29 +02:00
wm4 2d76c145c3 vo_opengl: fix giant memory leaks with icc profiles
Well this was dumb.
2016-06-03 20:03:49 +02:00
wm4 645a0d7791 client API: fully document opengl-cb hardware decoding interop
Document it exhaustively. Most of these issues were basically burried in
the code.
2016-06-01 22:33:36 +02:00
wm4 62acbd795f manpage: update --hwdec=d3d11va remarks 2016-05-31 18:32:06 +02:00
Rostislav Pehlivanov e44882d792 wayland: mark existing dnd entry print as debug rather than an error
It gets printed on every alt+tab or desktop switch under mutter and
weston, and offers no useful information since it's handled by
destroying the previous entry.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-31 11:22:57 +02:00
Rostislav Pehlivanov 29ea6e5e4a wayland: correctly report display refresh rate
This commit will cause the wayland backend and vo to correctly report
the display frame rate. This didn't work as VOCTRL_GET_DISPLAY_FPS was
received way too early, before the window was created (and thus
current_output set).

The VO will now signal VO_EVENT_WIN_STATE after window initialization
and upon a resize.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-31 11:22:55 +02:00
Niklas Haas 68c77d955f vo_opengl: default hdr-tone-mapping to hable
This algorithm works really well. Setting it is a much better
"out-of-the-box" experience than just clipping, which will always look
ugly.

In other words, with this default, users of mpv will just be able to
play HDR content without even realizing it's HDR (pretty much).
2016-05-30 20:17:35 +02:00
Niklas Haas 45c3e0f0d0 vo_opengl: refactor HDR mechanism
Instead of doing HDR tone mapping on an ad-hoc basis inside
pass_colormanage, the reference peak of an image is now part of the
image params (alongside colorspace, gamma, etc.) and tone mapping is
done whenever peak_src != peak_dst.

To get sensible behavior when mixing HDR and SDR content and displays,
target-brightness is a generic filler for "the assumed brightness of SDR
content".

This gets rid of the weird display_scaled hack, sets the framework
for multiple HDR functions with difference reference peaks, and allows
us to (in a future commit) autodetect the right source peak from
the HDR metadata.

(Apart from metadata, the source peak can also be controlled via
vf_format. For HDR content this adjusts the overall image brightness,
for SDR content it's like simulating a different exposure)
2016-05-30 20:17:33 +02:00
Rostislav Pehlivanov 098ff4174c wayland: implement HIDPI support
The wayland protocol exposes scaling done by the compositor to
compensate for small window sizes on small high DPI displays. If the
program ignores the scaling done, what'll happen is the compositor is
going to ask the program to be scaled down by N times the window size and
then it'll upscale the program's surface by N times. The scaling
algorithm seems to be bilinear so the scaling is quite obvious.

This commit sets up callbacks to listen for the scaling factor of each
output and, on rescale events, notifies the compositor that the
surface's scale is what the compositor asked for and changes the
player's surface to the appropriate size, causing no scaling to be done
by the compositor.

Compositors not supporting this interface will ignore the callbacks and do
nothing, keeping program behaviour the same. For compositors supporting
and using this interface (mutter), this will fix the rendering to be pixel
precise as it should be.

Both the opengl wayland backend and the wayland vo have been fixed to support
this. Verified to not break either on weston and mutter.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-30 20:17:26 +02:00
wm4 9009601c2d vf: fix filter auto-insertion
Commit 0348cd08 was too naive/simple, and always inserted the d3d11vpp
filter if any d3d11 output image formats were supported, even if it
makes no sense. For example --vf=format=rgb8 already breaks it.

It needs to take the set of supported input formats into account. the
weird format negotiation makes this hard. As a simple and cheap
solution, make some assumptions about the supported formats of a filter.

I hope to simplify this one day by using another format negotiation
algorithm, but this can probably wait.
2016-05-30 20:03:01 +02:00
wm4 4853eca8c6 mp_image: properly communicate aspect ratio through AVFrame
No idea why this wasn't done before. In particular, this fixes playing
anamorphic video through --lavfi-complex.
2016-05-30 19:12:41 +02:00
wm4 079f67268f mp_image: don't reset pixel aspect with mp_image_set_size()
No reason to do so. See also commit 240ba92b.

Since now many mp_images will never have a pixel aspect ratio set,
redefine a 0/0 aspect ratio to "undefined" instead invalid. This also
brings it more in line with how decoder vs. container aspect ratios are
handled.

Most callers seem to be fine with the new behavior.

mp_image_params_valid() in particular has to be adjusted, or some things
stop working due to mp_images not becoming valid after setting size and
format.
2016-05-30 19:07:22 +02:00
Niklas Haas 15bb05d2fe vo_opengl: add hable tone-mapping algorithm
Developed by John Hable for use in Uncharted 2. Also used by Frictional
Games in SOMA. Originally inspired by a filmic tone mapping algorithm
created by Kodak.

From http://frictionalgames.blogspot.de/2012/09/tech-feature-hdr-lightning.html
2016-05-30 16:58:25 +02:00
Niklas Haas 48015009b7 vo_opengl: rename tone-mapping=simple to reinhard
This is the canonical name for the algorithm. I simply didn't know it
before.
2016-05-30 16:58:22 +02:00
maniak1349 899d3e55b3 w32_common: center window on original window center on video resize
Position the window around the original window center on video size change
(when switching to the next file with different resolution, for example)
instead of keeping the position of its top-left corner fixed.
2016-05-30 16:58:07 +02:00
Ricardo Constantino 256d9d2b89 ytdl: fix brightcove urls 2016-05-30 16:57:43 +02:00
Ilya Tumaykin b1dd3beda9 build: don't install tests, only build them
Considering tests are usually executed right after a successful build,
there's no reason to keep them around for later.
2016-05-29 20:02:47 +02:00
wm4 240ba92bed mp_image: don't lose pixel aspect ratio when setting format
This is quite unexpected. It's caused by mp_image_set_size(), which is
used to update certain fields which can be format-dependent, but which
is actually also supposed to reset the pixel aspect ratio.
2016-05-29 19:00:55 +02:00
wm4 0348cd080f video: remove d3d11 video processor use from OpenGL interop
We now have a video filter that uses the d3d11 video processor, so it
makes no sense to have one in the VO interop code. The VO uses it for
formats not directly supported by ANGLE (so the video data is converted
to a RGB texture, which ANGLE can take in).

Change this so that the video filter is automatically inserted if
needed. Move the code that maps RGB surfaces to its own inteorp backend.
Add a bunch of new image formats, which are used to enforce the new
constraints, and to automatically insert the filter only when needed.

The added vf mechanism to auto-insert the d3d11vpp filter is very dumb
and primitive, and will work only for this specific purpose. The format
negotiation mechanism in the filter chain is generally not very pretty,
and mostly broken as well. (libavfilter has a different mechanism, and
these mechanisms don't match well, so vf_lavfi uses some sort of hack.
It only works because hwaccel and non-hwaccel formats are strictly
separated.)

The RGB interop is now only used with older ANGLE versions. The only
reason I'm keeping it is because it's relatively isolated (uses only
existing mechanisms and adds no new concepts), and because I want to be
able to compare the behavior of the old code with the new one for
testing. It will be removed eventually.

If ANGLE has NV12 interop, P010 is now handled by converting to NV12
with the video processor, instead of converting it to RGB and using the
old mechanism to import that as a texture.
2016-05-29 19:00:55 +02:00
wm4 49f73eaf7b vf_d3d11vpp: add a D3D11 video processor filter
Main use: deinterlacing.

I'm not sure how to select the deinterlacing mode at all. You can
enumate the available video processors, but at least on Intel, all of
them either signal support for all deinterlacers, or none (the latter is
apparently used for IVTC). I haven't found anything that actually tells
the processor _which_ algorithm to use.

Another strange detail is how to select top/bottom fields and field
dominance. At least I'm getting quite similar results to vavpp on Linux,
so I'm content with it for now.

Future plans include removing the D3D11 video processor use from the
ANGLE interop code.
2016-05-28 19:28:08 +02:00
James Ross-Gowan 9eccedf447 vo_opengl: angle: enable DirectComposition
This avoids a copy of the video image and lowers vsync jitter. Since
there are now two options to add to the window_attribs list, it has been
made dynamic.
2016-05-29 01:55:10 +10:00
wm4 9f42760538 vf_vdpaupp: use refqueue helper
This makes vf_vdpaupp use the deinterlacer helper code already used by
vf_vavpp. I nice side-effect is that this also removes some traces of
code originating from vo_vdpau.c, so we can switch it to LGPL.

Extend the refqueue helper with a deint setting. If not set,
mp_refqueue_should_deint() always returns false, which slightly
simplifies vf_vdpaupp. It's of no consequence to vf_vavpp (other than it
has to set it to get expected behavior).
2016-05-27 17:03:00 +02:00
Niklas Haas f8df0528b5 vo_opengl: skip junk before first user shader pass
A lot of real-world shaders start off with comments explaining the usage
or license, generating lots of "empty" passes. This simply change allows
us to skip them, which silences the warning spam and prevents us from
having to store and copy around these empty passes.

It also adds a more useful failure check: Attempting to use a user
shader that doesn't define any passes at all.
2016-05-27 17:03:00 +02:00
Yen Chi Hsuan 72e94941c9 TOOLS/zsh.pl: add .f4v extension in zsh completions 2016-05-27 17:03:00 +02:00
James Ross-Gowan 84fba1df21 vo_opengl: enable color management on GLES
This requires the GL_EXT_texture_norm16 extension and works in ANGLE.
A default precision had to be set for sampler3Ds, otherwise the shaders
would fail to compile.
2016-05-27 23:02:26 +10:00
wm4 ca87e623b5 command: add playlist-pos-1 property
This has often been requested for use on OSD. I don't really like having
such "special" properties, but whatever. Hopefully this will be the only
case.

Untested because I'm too damn lazy.

Fixes #2828.
2016-05-26 18:44:01 +02:00
wm4 306c554376 vo_opengl: fix superxbr shader compilation on ES
ES shaders do not allow implicit conversion from int to float, which
is the most annoying ES anti-feature ever.
2016-05-26 08:21:10 +02:00
wm4 e5f49d9685 vo_opengl: always autoselect ANGLE as backend if available
Remove the opengl-hq option default that caused it not to autoselect
ANGLE (unlike --vo=opengl). Details see commit d5df90a2.

Back then the intention was to use ANGLE by default, since it integrates
much nicer with the Windows compositor (instead of native OpenGL, which
tends to cause crazy glitches). On the other hand, many opengl-hq
capabilities are not available with older ANGLE builds, so it didn't
make any sense to autoselect ANGLE for it.

With the GL_EXT_texture_norm16 extension recently added to ANGLE, it has
essentially reached feature parity to desktop GL for the subset we are
using. (Even the integer texture hack for high bit depth input could be
dropped now.)

It (probably) still does not support nnedi3, due to the weird way the NN
coefficients are imported. Also, it uses half-floats instead of 16 bit
fixed-point textures for technical reasons, which implies about 5 bits
of precision loss. If anyone actually manages to distinguish the two
dithering texture formats in a double-blind test, I will fix it.
2016-05-26 00:07:10 +02:00
wm4 5c9f164caf vf_vavpp: make refqueue logic field-based
Abstracts the annoying framerate-doubling behavior.

Same deal as with refqueue introduction: the code size blows up, but at
least it can be reused for other filters.
2016-05-25 23:51:24 +02:00
wm4 fc18e1df62 vf_vavpp: minor simplification 2016-05-25 23:51:24 +02:00
wm4 68191fdca7 vf_vavpp: simplify update_pipeline() usage
Calling this right at start of filter_ext() also fixes a small
regression from previous commit. The change in reference surfaces due to
the first update_pipeline() with deinterlacing enabled changed behavior
of mp_refqueue_next() and mp_refqueue_has_output(). Since
update_pipeline() was called between those, the frame output logic got
inconsistent, and the first deinterlaced frame was duplicated from the
previous non-deinterlaced frame.

Also reset the number of ref-frames when switching back to non-deint
mode.
2016-05-25 23:51:24 +02:00
wm4 5353571de0 vf_vavpp: use future instead of past PTS to determine field duration
If the deinterlacer separates fields, the framerate must be doubled.
Since we have no stable and reliably framerate anywhere, we've been
calculating it by taking the time halfway to the next frame.

vf_vavpp actually used the past frame to calculate the frame duration,
which is sort of ok, but will skip the 2nd field in a stream (since the
first frame has no past PTS). This is annoying for testing, so use the
future frame PTS instead, which means the last field of the stream will
be dropped instead.
2016-05-25 23:51:24 +02:00
wm4 15a5d33b79 vf_vavpp: move frame handling to separate file
Move the handling of the future/past frames and the associated dataflow
rules to a separate source file.

While this on its own seems rather questionable and just inflates the
code, I intend to reuse it for other filters. The logic is annoying
enough that it shouldn't be duplicated a bunch of times.

(I considered other ways of sharing this logic, such as an uber-
deinterlace filter, which would access the hardware deinterlacer via a
different API. Although that sounds like kind of the right approach,
this would have other problems, so let's not, at least for now.)
2016-05-25 23:51:24 +02:00
wm4 b9cc33de58 win32: pthread: use SRW locks by default
SRW locks are available since Windows Vista. They work essentially like
Linux futexes. In particular, they can be statically initialized, and do
not require deinitialization. This makes them ideal for implementing
PTHREAD_MUTEX_INITIALIZER.

We still need CRITICAL_SECTION for recursive mutexes.
2016-05-24 19:02:22 +02:00
wm4 8ff96f0216 hwdec_d3d11egl: call ID3D11DeviceContext::Flush
This must be called if a texture shared between D3D devices is updated.

Often enough, the shared devices will be the same device, but ANGLE
forces using shared surfaces. I suppose there is no guarantee the driver
will do the expected thing. Internally, the driver could for example not
insert the required barriers before the shared texture is used.
2016-05-24 14:30:15 +02:00
dequis d941a57bd3 vo_xv: Handle incorrect size returned by Xv(Shm)CreateImage
Fixes #320 (which is closed as 'not our problem' but eh)

Relevant xorg bug: https://bugs.freedesktop.org/show_bug.cgi?id=70931

For me this happened when (accidentally) trying to play a 8460x2812 jpg
file with mpv. Like the referenced bug, xvinfo reports "maximum XvImage
size: 8192 x 8192". So the returned XvImage is 8192x2812 and memory
corruption happens.

Only after handling this BadShmSeg X11 errors are shown.
2016-05-24 10:25:39 +02:00
wm4 6bd021e4ee manpage: adjust dxva2 description 2016-05-23 23:46:58 +02:00
wm4 e293e411b5 etc/mpv.conf: add missing comment
The config file is an example, and is not supposed to actually define
anything by default.
2016-05-23 23:41:58 +02:00
wm4 335278b86e manpage: document how hardware decoding might cause quality loss 2016-05-23 22:55:30 +02:00
wm4 c4707cdee6 vo_opengl: fix other minor namespace issues
See previous commit.
2016-05-23 21:27:18 +02:00
wm4 e76aa7e8db vo_opengl: rename glUploadTex, drop unused parameter
Rename it to get out of OpenGL's namespace. The gl_ prefix is used by
other mpv functions, but no OpenGL ones.

The "slice" parameter was never actually used, and all callers passed 0
for it.
2016-05-23 21:27:18 +02:00
wm4 66079048ea vo_opengl: unify PBO and normal OSD texture upload path
The main change is actually that e first copy to a "staging" memory
frame, and then upload this at once. The old non-PBO code called
glTexsubImage2D for each OSD sub-bitmap.

The new non-PBO code path is a bit faster now if there are many small
sub-bitmaps (on Linux/nVidia). It's also a bit simpler, so this is a
win.

(Although I don't particularly appreciate the mixed normal/PBO texture
code.)
2016-05-23 21:27:18 +02:00
wm4 049e3ccb65 vo_opengl: make ES float texture format checks stricter
Some of these checks became pointless after dropping ES 2.0 support for
extended filtering.

GL_EXT_texture_rg is part of core in ES 3.0, and we already check for
this version, so testing for the extension is redundant.

GL_OES_texture_half_float_linear is also always available, at least as
far as our needs go.

The functionality we need from GL_EXT_color_buffer_half_float is always
available in ES 3.2, and we explicitly check for ES 3.2, so reject this
extension if the ES version is new enough.
2016-05-23 21:27:18 +02:00
wm4 80d702dce8 vo_opengl: make PBOs work on GLES 3.x
For some reason, GLES has no glMapBuffer, only glMapBufferRange.

GLES 2 has no buffer mapping at all, and GL 2.1 does not always have
glMapBufferRange. On those PBOs remain unsupported (there's no reason to
care about GL 2.1 without the extension).

This doesn't actually work on ANGLE, and I have no idea why. (There are
artifacts on OSD, as if parts of the OSD data weren't copied.) It works
on desktop OpenGL and at least 1 other ES 3 implementation. Don't enable
it on ANGLE, I guess.
2016-05-23 21:27:18 +02:00
Ben Boeckel afcef4c25b docs: fix some typos 2016-05-23 21:27:18 +02:00
wm4 75f373cc46 vo_opengl: remove unused glDrawBuffer 2016-05-23 21:27:18 +02:00
wm4 cc72a4e8c3 vo_opengl: support framebuffer invalidation
Not sure how much can be gained with this, as we can't use it properly
yet. For now, this is used only before rendering, which probably does
overwhelmingly nothing.

In the future, this should be used after temporary passes, which could
possibly reduce memory usage and even memory bandwidth usage, depending
on the drivers.
2016-05-23 21:27:18 +02:00
wm4 cc4a0571fa vo_opengl: slightly improve logging of loaded extensions
Only log when actual extensions are loaded, never log anything about
builtins.
2016-05-23 21:27:18 +02:00
wm4 c06a92e09e demux_edl: adjust warnings and variable names
Don't warn against unknown sourve length if the segment length is
explicitly provided.

Rename "len" to "end_time", because that's what it actually is.
2016-05-23 15:23:27 +02:00
Ricardo Constantino 4ff2a60632 ytdl_hook: support multi-arc subtitles
While at it, pass durations of segments from ytdl if available.
2016-05-23 15:14:14 +02:00
Josh de Kock 4aa017e301 ao_opensles: remove 32bit audio
It's unsupported by android, and can cause problems when trying to play 32bit audio. Removing 32bit fixes it by forcing 16 bit or 8 bit audio.
2016-05-22 14:31:37 +02:00
maniak1349 c4e8c36071 options: --geometry: center window position after applying size
Center window position after applying W and H parameters of the --geometry
option. Passing valid X and Y values will still override the position.

Fixes #2397.
2016-05-22 14:31:37 +02:00
maniak1349 5a3c299ca1 w32_common: make VOCTRL_SET_UNFS_WINDOW_SIZE resize the window around its center
Before that position of the window top-left corner was remaining the same
when the window was scaled.

Right now VOCTRL_SET_UNFS_WINDOW_SIZE is called only by window-scale. This
change will not affect resizes made by the user (dragging window edge).

Fixes #3164.
2016-05-22 14:31:37 +02:00
maniak1349 364af7c630 w32_common: center window on original window center on resize to fit screen
Center the window on the original window center instead of the screen center
when the window has been resized due to requested window size exceeding the
size of the screen.

If user moved the window, he probably did it for the reason and he probably
don't want it to get back to the center of the screen when he is resizing it
(with window-scale for example).
2016-05-22 14:31:37 +02:00
maniak1349 981048e041 w32_common: update stored client area size on window resize
Properly update stored client area size when the window is resized in
reinit_window_state due to window size exceeding the size of the screen.

This was causing wrong behavior with window-scale - when window size was
becoming too big the window was resized but the video was not.
2016-05-22 14:31:37 +02:00
wm4 035297212a demux_mkv: better resync behavior for broken google-created webms
I've got a broken webm that fails to seek correctly with "--start=0".
The problem is that every index entry points to 1 byte before cluster
start (!!!). demux_mkv tries to resync to the next cluster, but since it
already has read 2 bytes with ebml_read_id(), it doesn't get the first
cluster, but the following one. Actually, it can be any amount of bytes
from 1-4, whatever happens to look valid at this essentially random byte
position.

Improve this by resyncing from the original position, instead of the one
after the EBML element ID has been attempted to be read.

The file shows the following headers:

| + Muxing application: google at 177
| + Writing application: google at 186

Indeed, the file was downloaded with youtube-dl. I can only guess that
Google got it completely wrong.
2016-05-21 16:39:44 +02:00
wm4 79afa347cc vo_opengl: remove non-working rgb/rgba FBO formats
Following commit 84ccebd9, the internal helpers don't allow GL_RGB and
GL_RGBA as internal formats for FBO attachments anymore.

While OpenGL itself is perfectly fine with it, I don't see much of a
reason to bother, and mixing sized and unsized internal formats is
confusing anyway.

Just remove these formats.
2016-05-20 23:21:43 +02:00
wm4 3deedef195 stream: separate posix/win32 cancellation code
This code evolved into an ifdef mess as support for cancellation on
Windows was added. Make the Windows-specific code completely separate.
It looks cleaner, and it also means that some of the posix code is not
uselessly enabled on Windows. The latter made msvcrt.dll output warnings
because it does not like -1 passed as FD to read/write. (The same would
be harmless on POSIX.)
2016-05-20 15:51:50 +02:00
Quentin Glidic f0d7437412 build: Do not link to libGL for egl-drm
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-05-20 14:15:44 +02:00
wm4 e431a7bbfd vf_crop: support opaque hardware decoding formats
Cropping usually happens by adjusting the plane start pointers and the
image size. The former is obviously not possible for opaque hwaccel
formats, but the latter must work.

Since the code already takes care of aligning the top/left crop origin
to chroma alignment, simply set the crop origin to 0/0 in the hwaccel
case. Also add a message if such an adjustment happens.

Supporting this isn't worth much; the main usefulness is with debugging.
2016-05-19 22:56:11 +02:00
wm4 05b3a8cd14 vo_opengl: require at least ES 3.0 for float textures
ES 2.0 has this weird rule that not the internalformat parameter
determines the internal format, but the combination of all texture
parameters. GL_OES_texture_half_float thus does not specify e.g. a
GL_RGBA16F format, but requires passing GL_RGBA as format and
GL_HALF_FLOAT_OES as type. We won't bother with this, since ES 2.0 is a
lost cause anyway.

This also removes the OpenGL error when the code is trying to create a
f16 FBO for testing whether FBOs work.
2016-05-19 17:52:09 +02:00
wm4 561630cb01 vo_opengl: change error state handling and fix hwdec crashes on errors
gl_video_upload_image() can fail in the hardware decoding case. In this
case rendering continued "normally", which meant that pass_get_img_tex()
would kill the process with an assertion failure.

Fix this by allowing gl_video_upload_image() to fail, and exit rendering
early enough to skip code which requires an image to be present. (Maybe
this is still a bit too subtle, but better than before.)

Set an error flag, and render the blue screen we introduced for shader
errors. (For this purpose also move the rendering of it to final output,
to ensure it's visible at all.) The error flag is temporary, because the
associated failure might also be temporary, unlike shader compilation
errors.
2016-05-19 12:18:48 +02:00
wm4 4e5f1ec00e vo_opengl: d3d11egl: enable "required" GLSL extensions
ANGLE doesn't handle this very strictly. But if they change this in the
future, it shouldn't brick us.

Not quite happy with this glsl_extensions fields, but it is quite
unintrusive after all.
2016-05-19 12:02:08 +02:00
wm4 b0d3c2ede7 vo_opengl: make gl_sc_enable_extension() permanent/idempotent
No reason not to, and makes the following commit slightly simpler.

In fact, this makes the shaders more correct too. Normally, "#extension"
must come before any normal shader text, including the "precision"
directive. Not sure why this worked before. (Probably didn't.)
2016-05-19 12:01:59 +02:00
wm4 b46eaa3b43 vo_opengl: d3d11egl: enable direct nv12 sampling on ES 3.x
ANGLE was missing texture() overloads in the shader compiler for
GL_TEXTURE_EXTERNAL_OES textures. Support has been added upstream,
so we can use it now.
2016-05-19 10:43:57 +02:00
wm4 5f7bd411fb vo_opengl: remove unused field 2016-05-18 18:22:27 +02:00
wm4 0b911792ca vo_opengl: fix/simplify reinitialization on dynamic reconfiguration
With the new hooks mechanism, user shaders and such are actually loaded
before rendering starts, instead of being loaded during rendering. This
is used to cache them (instead of e.g. reparsing them every frame).

The cached state wasn't cleared correctly in some situations. Namely,
resizing didn't correctly enable/disable prescale hooks.

Reorganize how these reinitializations are handled. Get rid of
reinit_rendering(), whose meaning was pretty unclear. Call the required
functions to reset or recreate state directly wherever they are needed.
2016-05-18 17:47:10 +02:00
wm4 26b6d74484 demux_playlist: recognize m3u8 as playlist extension
Whatever. As mentioned in #3154.
2016-05-17 18:18:00 +02:00
wm4 a02d77ba0d d3d: simplify DLL loading
For some reason, the d3d9/dxva2/d3d11 DLLs are still optional. But we
don't need to try so hard to keep exact references. In fact, there's no
reason to unload them at all.

So load them once in a central place. For simplicity, the d3d9/d3d11
backends both load all DLLs. (They will error out only if the required
DLLs could not be loaded.)

In theory, we could just call LoadLibrary multiple times (without
calling FreeLibrary), but I'm slightly worried that this could be
detected as a "bug", or that the reference count could even have a low
static limit that could be hit soon.
2016-05-17 11:59:54 +02:00
wm4 39b64fb176 video: merge dxva2 source files
video/dxva2.c exported only 2 functions, both used only by
video/decode/dxva2.c.

The same was already done for d3d11.
2016-05-17 11:05:51 +02:00
wm4 9b56bbecdf vo_opengl: hwdec: remove build-dependency on dxva2
wscript builds hwdec_dxva2gldx.c if gl-dxinterop is enabled, while
video/dxva2.c depends on d3d-hwaccel. If d3d-hwaccel is disabled, then
hwdec_dxva2gldx.c will fail to link, because it uses
d3d9_surface_in_mp_image(), defined in dxva2.c.

Fix this by removing the use of this function. It has barely any value
at this point anyway. Just use the libavcodec documented way to get the
surface directly.

Fixes #3150.
2016-05-17 10:59:11 +02:00
wm4 b18a598444 ta: remove old and redundant macro 2016-05-17 10:53:14 +02:00
wm4 a2d58d9986 vo_opengl: move UT_buffer to switch handling
No reason to make it a special case.
2016-05-17 10:48:05 +02:00
wm4 f00040b9fc vo_opengl: make number of cached shaders/uniform dynamic
Use dynamic memory allocation, as the static allocation is starting to
get annoying.

Currently, SC_MAX_ENTRIES is essentially still a static upper limit on
the number of shaders. But in future we could try a more clever cache
replacement strategy, which does not keep stale entries forever if the
maximum happens not to be reached.
2016-05-17 10:45:01 +02:00
wm4 09763bef83 vo_opengl: move cached uniforms to a separate struct 2016-05-17 10:33:45 +02:00
Niklas Haas 8262a4dd52 vo_opengl: increase shader limits
The new uniforms introduced by 362015c have exceeded the uniform limit
when using high-radius tscale. In addition, the SC limit of 32 entries
might be pushing it with user shaders.

Just make these value a bigger to delay the onset of this same failure
mode. Maybe in the future it should be reworked to grow dynamically?
Either way, we *can* always predict a static upper bound on the number
of uniforms and shader cache entries, it's just that we forgot to do so.

Fixes #3151
2016-05-17 10:09:01 +02:00
Niklas Haas ca09cd68c8 DOCS/mplayer-changes: document HDR support
Marketing told me to do so.
2016-05-16 19:29:15 +02:00
Niklas Haas e73c83d3df vo_opengl: skip tonemapping if the output trc is HDR
This makes it so that users with actual HDR displays can just set their
config to target-trc=st2084 and get native HDR output. This will look a
bit silly for SDR content (everything will be really bright), but for
lack of a better tone mapping situation (including reverse tone mapping)
this is the easiest thing to do for now.

Ideally the brightness metadata should be part of the colorspace struct
or something (with mpv always adapting where necessary), but it depends
on the TRC and not the primaries so it's a bit more complicated than
that.
2016-05-16 14:42:45 +02:00
Niklas Haas e6f6ae94f3 vo_opengl: copy over HDR parameters to dumb_mode
Since dumb mode is affected by tone mapping (which I'll call a feature,
not a bug), we need to copy over the configuration - in particular, the
defaults. (To prevent a render failure)
2016-05-16 14:20:48 +02:00
Niklas Haas 3bdbf6274c vo_opengl: fall back to gamma2.2 by default for HDR content
Since HDR content is now auto-detected as such, we should probably do
something smarter in the "no configuration" case, such as outputting
gamma 2.2 instead.

This decision will affect the majority of users of stock configurations
who just play back appropriately tagged HDR files, so having a good
default behavior is important. "Output the HDR content as-is" is
definitely not likely to give the user a good result.
2016-05-16 14:07:39 +02:00
Niklas Haas b6c40953cb csputils: add AVCOL_TRC_SMPTEST2084 support
This now lets us auto-detect appropriately tagged HDR content using
FFmpeg's new TRC entries (when available).

Hidden behind an #if because Libav stable doesn't have it yet.
2016-05-16 13:59:57 +02:00
wm4 887b2cc30f vo_opengl: remove unnecessary casts 2016-05-16 12:58:09 +02:00
wm4 1bc902336a vo_opengl: remove another unneeded allocation 2016-05-16 12:54:45 +02:00
wm4 51307e9f18 vo_opengl: remove possibly undefined behavior 2016-05-16 12:53:45 +02:00
wm4 70df6aa375 vo_opengl: free to-be-added hook on hook array overflow
Seems sensible.

Untested.
2016-05-16 12:51:36 +02:00
wm4 155857dbe6 vo_opengl: never clear file cache
Make it dynamic and never remove entries from it.

For now, this is better than possibly creating dangling pointers all
over the place in the gl_user_shader struct.

Untested.
2016-05-16 12:51:26 +02:00
wm4 0c40eee479 vo_opengl: use proper include statement 2016-05-16 12:44:12 +02:00
wm4 dd99c1e3b4 vo_opengl: remove unnecessary allocation 2016-05-16 12:42:08 +02:00
wm4 56ed5bf1c7 vo_opengl: remove unused global variable
?
2016-05-16 12:41:55 +02:00
wm4 320627d600 manpage: declare user-shader syntax for not stable 2016-05-16 12:41:08 +02:00
wm4 51603e472d vo_opengl: fix bicubic_fast in ES mode
GLES shaders disallow implicit conversion from int to float.

This has been broken for quite a while.
2016-05-16 12:10:47 +02:00
Niklas Haas e047cc0931 vo_opengl: implement more HDR tonemapping algorithms
This is now a configurable option, with tunable parameters.

I got inspiration for these algorithms off wikipedia. "simple" seems to
work pretty well, but not well enough to make it a reasonable default.

Some other notable candidates:

- Local functions (e.g. based on local contrast or gradient)
- Clamp with soft knee (linear up to a point)
- Mapping in CIE L*Ch. Map L smoothly, clamp C and h.
- Color appearance models

These will have to be implemented some other time.

Note that the parameter "peak_src" to pass_tone_map should, in
principle, be auto-detected from the SEI information of the source file
where available. This will also have to be implemented in a later
commit.
2016-05-16 02:49:49 +02:00
Niklas Haas 3cfe98c684 vo_opengl: avoid redundant double-gamma conversion
Due to the way color management in mpv worked historically, the subtitle
blending function was written to preserve the linearity of the input.
(In the past, the 3DLUT function required linear inputs)

Since the 3DLUT was refactored to accept the video color directly, the
re-linearization after blending is now virtually always redundant.
(Notably, it's also redundant when CMS is turned off, so this way of
writing the code stopped making sense a long time ago. It is a remnant
from before the pass_colormanage function was as flexible as it is now)
2016-05-16 02:45:39 +02:00
Niklas Haas f81f486c68 vo_opengl: implement HDR (SMPTE ST2084)
Currently, this relies on the user manually entering their display
brightness (since we have no way to detect this at runtime or from ICC
metadata). The default value of 250 was picked by looking at ~10 reviews
on tftcentral.co.uk and realizing they all come with around 250 cd/m^2
out of the box. (In addition, ITU-R Rec. BT.2022 supports this)

Since there is no metadata in FFmpeg to indicate usage of this TRC, the
only way to actually play HDR content currently is to set
``--vf=format=gamma=st2084``. (It could be guessed based on SEI, but
this is not implemented yet)

Incidentally, since SEI is ignored, it's currently assumed that all
content is scaled to 10,000 cd/m^2 (and hard-clipped where out of
range). I don't see this assumption changing much, though.

As an unfortunate consequence of the fact that we don't know the display
brightness, mixed with the fact that LittleCMS' parametric tone curves
are not flexible enough to support PQ, we have to build the 3DLUT
against gamma 2.2 if it's used. This might be a good thing, though,
consdering the PQ source space is probably not fantastic for
interpolation either way.

Partially addresses #2572.
2016-05-16 02:45:39 +02:00
Niklas Haas 965031ccd5 vo_opengl: use enums for choice options internally
This is much more readable than hard-coding magic IDs all over the file,
and removes the need for all the explanatory comments that were a direct
result of this.
2016-05-16 02:45:39 +02:00
Niklas Haas 362015cd77 vo_opengl: abstract hook texture access behind macro
This macro takes care of rotation, swizzling, integer conversion and
normalization automatically. I found the performance impact to be
nonexistant for superxbr and debanding, although rotation *did* have an
impact due to the extra matrix multiplication. (So it gets skipped where
possible)

All of the internal hooks have been rewritten to use this new mechanism,
and the prescaler hooks have finally been separated from each other.
This also means the prescale FBO kludge is no longer required.

This fixes image corruption for image formats like 0bgr, and also fixes
prescaling under rotation. (As well as other user hooks that have
orientation-dependent access)

The "raw" attributes (tex, tex_pos, pixel_size) are still un-rotated, in
case something needs them, but ideally the hooks should be rewritten to
use the new API as much as possible. The hooked texture has been renamed
from just NAME to NAME_raw to make script authors notice the change (and
also deemphasize direct texture access).

This is also a step towards getting rid of the use_integer pass.
2016-05-15 20:42:08 +02:00
Niklas Haas dfc7b59909 vo_opengl: make the screen blue on shader errors
This helps visually signify that somthing went wrong, and prevents
confusing shader compilation errors with other types of bugs.
2016-05-15 20:42:02 +02:00
Niklas Haas 034faaa9d8 vo_opengl: use RPN expressions for user hook sizes
This replaces the previous TRANSFORM by WIDTH, HEIGHT and OFFSET where
WIDTH and HEIGHT are RPN expressions. This allows for more fine-grained
control over the output size, and also makes sure that overwriting
existing textures works more cleanly.

(Also add some more useful bstr functions)
2016-05-15 20:42:02 +02:00
Niklas Haas 7c3d78fd82 vo_opengl: support external user hooks
This allows users to add their own near-arbitrary hooks to the vo_opengl
processing pipeline, greatly enhancing the flexibility of user shaders.
This enables, among other things, user shaders such as CrossBilateral,
SuperRes, LumaSharpen and many more.

To make parsing the user shaders easier, shaders are now loaded as
bstrs, and the hooks are set up during video reconfig instead of on
every single frame.
2016-05-15 20:42:02 +02:00
Niklas Haas d53142f9ba vo_opengl: add optional hook points
These are "sequence points" where the image could be rendered out to an
FBO, hooked, and re-loaded if any such hook exists. This is perfect for
things like the current user shaders system, as well as optional effects
like unsharp masking.

Note that since we have to pick *some* FBO to store the optionally
hooked texture, we just store it in an array indexed by an increasing
counter. Since we only ever store as many as MAX_TEXTURE_HOOKS + all
internal hook points entries, this is guaranteed to be enough space.

This commit also removes some of the now unused FBOs.
2016-05-15 20:42:02 +02:00
Niklas Haas 070edd7300 vo_opengl: add hooks and rework pass_read_video
The hook mechanism allows arbitrary processing stages to get dispatched
whenever certain named textures have been "finalized" by the code.

This is mostly meant to serve as a change that opens up the internal
processing in pass_read_video to user scripts, but as a side benefit all
of the code dealing with offsets and plane alignment and other such
confusing things has been rewritten.

This hook mechanism is powerful enough to cover the needs of both
debanding and prescaling (and more), so as a result they can be removed
from pass_read_video entirely and implemented through hooks.

Some avenues for optimization:

- The prescale hook is currently somewhat distributed code-wise. It might be
  cleaner to split it into superxbr and NNEDI3 hooks which can each be
  self-contained.

- It might be possible to move a large part of the hook code out to an
  external file (including the hook definitions for debanding and
  prescaling), which would be very much desired.

- Currently, some stages (chroma merging, integer conversion) will
  *always* run even if unnecessary. I'm planning another series of
  refactors (deferred img_tex) to allow dropping unnecessary shader
  stages like these, but that's probably some ways away. In the meantime
  it would be doable to re-add some of the logic to skip these stages if
  we know we don't need them.

- More hook locations could be added (?)
2016-05-15 20:42:02 +02:00
Niklas Haas 3d4889e91e vo_opengl: minor change to scaler_resizes_only
Instead of rounding down, we round to the nearest float. This reduces
the maximum possible error introduced by this rounding operation. Also
clarify the comment.
2016-05-15 20:42:02 +02:00
wm4 32c10956e0 vaapi: avoid forward declaration of variable
Why is everything so horrible.
2016-05-15 18:37:51 +02:00
Julian 6ae7a555bf lua: add timer:is_enabled() function
Allows to query if some timer is currently running or was
stopped/killed.
2016-05-14 20:49:28 +02:00
wm4 449b948ee8 vo_opengl: remove some pointless compatibility
Remove non-texture_rg compatibility from LUT sampling. OpenGL without
texture_rg support will always trigger dumb-mode, and dumb-mode does not
use LUTs. It used not to, and that was when this made sense.
2016-05-14 12:02:02 +02:00
Ricardo Constantino 77d50cb3cf ytdl_hook: Just check if protocol is rtmp
Partial fix to #3090
2016-05-14 11:22:25 +02:00
wm4 3858d37b61 vo_opengl: partially fix 0bgr format support
Fixes broken colors with --vf=format=0bgr (but only if deband is
disabled).

0bgr means the first byte is padding, while the following three bytes
are bgr. From the vo_opengl perspective, it has 4 physical components
with 3 logical components. copy_img_tex() simply copied 3 components
from the physical representation, which means the last component (r) was
sliced off.

Fix this by not using p->color_swizzle for packed formats, and instead
let packed formats set the per-plane swizzle in texplane.swizzle. The
latter applies the swizzle as part of operation in copy_img_tex(), which
essentially moves physical to logical representations.

Unfortunately, debanding (and thus with opengl-hq defaults) is still
broken.
2016-05-13 22:35:42 +02:00
wm4 09e07e92c5 vo_opengl: drop duplicate LUMINANCE_ALPHA handling
This was supposed to handle the absence of GL_ARB_texture_rg. But it's
already handled elsewhere. (init_format() sets texplane.swizzle
accordingly.)
2016-05-13 22:07:25 +02:00
wm4 7d2c6d60da vo_opengl: minor simplification
Make the find_plane_format function take a bit count.

This also makes the function's comment true for the first time the
function and its comment exist. (It was commented as taking bits, but
always took bytes.)
2016-05-13 21:46:08 +02:00
wm4 c9d8bc088c vo_opengl: restrict ES2 FBO formats
Only a few very low bit depth internal formats can be rendered to in
pure ES2 (GL_RGB565 is the "best" one).

Seems like the only potentially reasonable renderable formats in ES2
could be provided via GL_OES_rgb8_rgba8, or half-floats, so don't
bother with this at all.
2016-05-13 18:50:38 +02:00
wm4 f7c81c03b2 vo_opengl: angle: log extension string 2016-05-13 15:39:11 +02:00
wm4 5bd6b76f5c cache: simplify speed calculations
Remove the attempted cleverness; keep it dumb.

This strictly calculates the average speed over an at least 1 second
window (longer if I/O blocks it).

Since this doesn't reset the speed anymore when reading stops by going
idle, the results might actually be more accurate now.
2016-05-12 22:37:45 +02:00
wm4 ee85473d4a travis: move travis-deps script to TOOLS
Don't let it clutter the top level directory.
2016-05-12 21:24:32 +02:00
wm4 a228bf54c8 vo_opengl: slightly better FBO format check
Now that we know in advance whether an implementation should support a
specific format, we have more flexibility when determining which format
to use.

In particular, we can drop the roundabout ES logic.

I'm not sure if actually trying to create the FBO for probing still has
any value. But it might, so leave it for now.
2016-05-12 21:22:28 +02:00
wm4 0cd217b039 vo_opengl: disable scalers on ES2
Even if everything else is available, the need for first class arrays
breaks it. In theory we could fix this since we don't strictly need
them, but I guess it's not worth bothering.

Also give the misnamed have_mix variable a slightly better name.
2016-05-12 21:22:28 +02:00
wm4 bd41a3ab62 vo_opengl: add detection for the ES texture_rg extension 2016-05-12 21:22:28 +02:00
wm4 84ccebd9b9 vo_opengl: reorganize texture format handling
This merges all knowledge about texture format into a central table.

Most of the work done here is actually identifying which formats exactly
are supported by OpenGL(ES) under which circumstances, and keeping this
information in the format table in a somewhat declarative way. (Although
only to the extend needed by mpv.) In particular, ES and float formats
are a horrible mess.

Again this is a big refactor that might cause regression on "obscure"
configurations.
2016-05-12 21:22:28 +02:00
wm4 e68b510a94 vo_opengl: correctly disable interpolation if tscale can't be used
It'll fail with an assertion in the interpolation code otherwise.
2016-05-12 21:22:28 +02:00
James Ross-Gowan c160e5f31d Add Appveyor CI integration for Windows builds 2016-05-12 23:34:06 +10:00
wm4 d4712af5af vo_opengl: angle: dump translated shaders
Helpful for debugging and such.
2016-05-12 11:17:49 +02:00
wm4 809d235208 manpage: document missing sub-properties
This is the client-API part; the normal descriptions are present in the
text above.
2016-05-11 19:14:31 +02:00
wm4 01d04b100f vo_opengl: don't use dumb-mode with 10 bit integer texture hack
Recent regression. Caused it to use dumb-mode with integer textures,
which on ANGLE leads to nearest scaling.
2016-05-11 17:41:00 +02:00
wm4 fe540f4477 vo_opengl: fix NULL deref on certain init failures 2016-05-11 17:12:59 +02:00
wm4 70b3561270 video: add --hwdec=auto-copy mode
This uses the normal autoprobing rules like "auto", but rejects anything
that isn't flagged as copying data back to system memory.

The chunk in command.c was dead code, so remove it instead of updating
it.
2016-05-11 16:20:13 +02:00
wm4 2ec26b8396 manpage: unmark d3d11va as "experimental"
Also add missing mediacodec entry.
2016-05-11 16:18:05 +02:00
wm4 cb694ffd8e vo_opengl: d3d11egl: support full range YUV
MSDN documents this as "Introduced in Windows 8.1.". I assume on Windows
7 this field will simply be ignored. Too bad for Windows 7 users.

Also, I'm not using D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235 and
D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255, because these are apparently
completely missing from the MinGW headers. (Such a damn pain.)
2016-05-11 15:40:31 +02:00
wm4 7983cda5bf vo_opengl: d3d11egl: don't require EGL_EXT_device_query
Older ANGLE builds don't export this.

This change is really only for convenience, and I might revert it at
some later point.
2016-05-11 15:40:31 +02:00
wm4 fd82e14888 build: merge d3d11va and dxva2 hwaccel checks
We don't have any reason to disable either. Both are loaded dynamically
at runtime anyway. There is also no reason why dxva2 would disappear
from libavcodec any time soon.
2016-05-11 15:40:31 +02:00
wm4 fde20d10bc vo_opengl: angle: dynamically load ANGLE
ANGLE is _really_ annoying to build. (Requires special toolchain and a
recent MSVC version.) This results in various issues with people
having trouble to build mpv against ANGLE (apparently linking it
against a prebuilt binary doesn't count, or using binaries from
potentially untrusted sources is not wanted).

Dynamically loading ANGLE is going to be a huge convenience. This commit
implements this, with special focus on keeping it source compatible to
a normal build with ANGLE linked at build-time.
2016-05-11 15:39:29 +02:00
q66 bea7675307 build: also use the iconv check on freebsd
This is necessary to make mpv build out of box on FreeBSD.
2016-05-10 23:03:53 +02:00
wm4 1f6e71c7fa vo_opengl: fix passing along swizzle from hwdec interop
In theory this was needed for the previous commit (but wasn't in
practice, since for hwdec the LUMINANCE_ALPHA mangling is not applied
anymore, and ANGLE uses RG textures in absence of GL_ARB_texture_rg for
whatever crazy reasons).

In practice this caused funky colors on OSX with the uyvy422 format,
which is also fixed in this commit.
2016-05-10 21:12:57 +02:00
wm4 a3d416c3d3 vo_opengl: d3d11egl: native NV12 sampling support
This uses EGL_ANGLE_stream_producer_d3d_texture_nv12 and related
extensions to map the D3D textures coming from the hardware decoder
directly in GL.

In theory this would be trivial to achieve, but unfortunately ANGLE does
not have a mechanism to "import" D3D textures as GL textures. Instead,
an awkward mechanism via EGL_KHR_stream was implemented, which involves
at least 5 extensions and a lot of glue code. (Even worse than VAAPI EGL
interop, and very far from the simplicity you get on OSX.)

The ANGLE mechanism so far supports only the NV12 texture format, which
means 10 bit won't work. It also does not work in ES3 mode yet. For
these reasons, the "old" ID3D11VideoProcessor code is kept and used as a
fallback.
2016-05-10 21:06:34 +02:00
wm4 4b3faf9dc1 vo_opengl: add an angle-es2 backend
It forces es2 mode on ANGLE. Only useful for testing. Since the normal
"angle" backend already falls back to es2 if es3 does not work, this new
backend always exit when autoprobing it.
2016-05-10 20:19:25 +02:00
wm4 12ae19c449 vo_opengl: cosmetics: rename variables
"p" is used for the private context everywhere in the source file, but
renaming it also requires renaming some local variables.
2016-05-10 18:49:49 +02:00
wm4 b0b01aa250 vo_opengl: refactor how hwdec interop exports textures
Rename gl_hwdec_driver.map_image to map_frame, and let it fill out a
struct gl_hwdec_frame describing the exact texture layout. This gives
more flexibility to what the hwdec interop can export. In particular, it
can export strange component orders/permutations and textures with
padded size. (The latter originating from cropped video.)

The way gl_hwdec_frame works is in the spirit of the rest of the
vo_opengl video processing code, which tends to put as much information
in immediate state (as part of the dataflow), instead of declaring it
globally. To some degree this duplicates the texplane and img_tex
structs, but until we somehow unify those, it's better to give the hwdec
state its own struct. The fact that changing the hwdec struct would
require changes and testing on at least 4 platform/GPU combinations
makes duplicating it almost a requirement to avoid pain later.

Make gl_hwdec_driver.reinit set the new image format and remove the
gl_hwdec.converted_imgfmt field.

Likewise, gl_hwdec.gl_texture_target is replaced with
gl_hwdec_plane.gl_target.

Split out a init_image_desc function from init_format. The latter is not
called in the hwdec case at all anymore. Setting up most of struct
texplane is also completely separate in the hwdec and normal cases.

video.c does not check whether the hwdec "mapped" image format is
supported. This should not really happen anyway, and if it does, the
hwdec interop backend must fail at creation time, so this is not an
issue.
2016-05-10 18:42:42 +02:00
wm4 7e6e47b8c4 sd_lavc: work around bug in older ffmpeg releases
Older ffmpeg releases don't have ffmpeg git commit
50401f5fb7d778583b03a13bc4440f71063d319d, which fixes ffmpeg's
pkt_timebase check to reject its default "unset" timebase as invalid.
The consequence was that all non-PGS bitmap subtitle timestamps were
forced to 0.

Of course this hit _only_ shitty distros using outdated/badly maintained
ffmpeg releases, so this is not worth working around. I've already
wasted a lot of time on analyzing this dumb issue, and it could be
useful for bisecting, so don't drop pre-3.0 ffmpeg just yet.

Fixes #3109.
2016-05-10 11:48:43 +02:00
wm4 013d63b081 stream_cdda: enable cache by default
Requested.
2016-05-10 11:17:52 +02:00
wm4 5d8d8618c4 manpage: document -- and some issues passing filenames 2016-05-10 11:15:45 +02:00
Richard H Lee da0bf27930 ass_process_chunk: Use llrint, not lrint
libass's ass_process_chunk expects long long int for the timecode and
durations arguments, thus should use llrint instead of lrint.

This does not cause any problems on most platforms, but on cygwin, it
causes strange subtitle behaviour, like subtitles not showing, getting
stuck or old subtitles showing at the same time as new subtitles.
2016-05-10 00:41:57 +02:00
wm4 af0a8d7478 player: restore usual seeking behavior
Commit 786f37ae accidentally changed seeking behavior such that
continuous seeking (holding the seek button down) would use the previous
seek target timestamp, instead of the new video timestamp. (This is for
the default mode, seeking to keyframes.)

The result is that the movement on the seekbar is smooth, but the way
the video updates is awkward. Some might actually prefer the new
behavior (and some players effectively show similar bahavior), but I
don't. So restore the old behavior.

This is done in two steps:

First: strictly wait for the entire seek process to finish, which will
effectively make the seeking code pick up the new video timestamp
correctly.

This would play audio immediately, which would result in noise during
continuous seeking, which leads to second: explicitly abort the playback
restarting process if this case is detected, and never play audio.
2016-05-09 22:54:49 +02:00
Mantas Mikulėnas 00c9bdf3f7 x11: tell GNOME to use dark window decorations 2016-05-09 20:39:59 +02:00
wm4 73aa7484f2 manpage: fix some script_message references to preferred name 2016-05-09 20:39:33 +02:00
wm4 46fff8d31a video: refactor how VO exports hwdec device handles
The main change is with video/hwdec.h. mp_hwdec_info is made opaque (and
renamed to mp_hwdec_devices). Its accessors are mainly thread-safe (or
documented where not), which makes the whole thing saner and cleaner. In
particular, thread-safety rules become less subtle and more obvious.

The new internal API makes it easier to support multiple OpenGL interop
backends. (Although this is not done yet, and it's not clear whether it
ever will.)

This also removes all the API-specific fields from mp_hwdec_ctx and
replaces them with a "ctx" field. For d3d in particular, we drop the
mp_d3d_ctx struct completely, and pass the interfaces directly.

Remove the emulation checks from vaapi.c and vdpau.c; they are
pointless, and the checks that matter are done on the VO layer.

The d3d hardware decoders might slightly change behavior: dxva2-copy
will not use the VO device anymore if the VO supports proper interop.
This pretty much assumes that any in such cases the VO will not use any
form of exclusive mode, which makes using the VO device in copy mode
unnecessary.

This is a big refactor. Some things may be untested and could be broken.
2016-05-09 20:03:22 +02:00
wm4 ee4c00698f vo_direct3d: remove passing device to decoder
This was never really used anyway. Removing it for the sake of the
following commit.
2016-05-09 18:59:10 +02:00
Emmanuel Gil Peyrot f99e48ae6a wayland: use the advertised size in fullscreen
When we receive the wl_shell_surface::configure event, it makes sense
to respect the aspect ratio of the video in windowed mode, but in
fullscreen it forces compositing and wastes resources (until atomic
modesetting is available everywhere and we can stop having
desynchronised planes).

Weston mitigates a resolution mismatch by creating black surfaces and
compositing them around the fullscreen surface, placed at the middle,
while GNOME puts it at the top-left and leaves the rest of the desktop
composited below, both of them producing a subpar experience.

Fixes #3021, #2657.
2016-05-08 19:47:08 +02:00
maniak1349 7d9eab15f0 win32: make taskbar progress indication optional
Add --taskbar-progress command line option and property which controls taskbar
progress indication rendering in Windows 7+. This option is on by default and
can be toggled during playback.

This option does not affect the creation process of ITaskbarList3. When the
option is turned off the progress bar is just hidden with TBPF_NOPROGRESS.

Closes #2535
2016-05-08 17:05:20 +02:00
wm4 2f8b4dd480 demux_lavf: fix a minor memory leak 2016-05-08 13:24:22 +02:00
wm4 ababfcbfe3 manpage: document --x11-bypass-compositor=no
Requested.
2016-05-08 11:05:01 +02:00
wm4 8fe33a11e2 x11: slightly safer X11 error handler behavior
The X11 error handler is global, and not per-display. If another Xlib
user exists in the process, they can conflict. In theory, it might
happen that e.g. another library sets an error handler (overwriting the
mpv one), and some time after mpv closes its display, restores the error
handler to mpv's one. To mitigate this, check if the error log instance
is actually set, instead of possibly crashing.

The change in vo_x11_uninit() is mostly cosmetic.
2016-05-08 11:04:44 +02:00
Rahul Kalkani 11406b9215 manpage: change gnome-screensaver-command example
Correct options to deactivate is -d or --deactivate.

Signed-off-by: wm4 <wm4@nowhere>
2016-05-07 12:17:28 +02:00
wm4 062493fa7e x11: rename inappropriate --x11-bypass-compositor=never option
This obviously made no sense.
2016-05-07 12:14:56 +02:00
wm4 55846641ea x11: add --x11-bypass-compositor=always
Also add missing documentation for fs-only, and correct the default.
2016-05-06 19:57:17 +02:00
Niklas Haas 7c5188c27e DOCS: update documentation related to color management
Some of this documentation was left woefully inaccurate as color
management in mpv evolved. This commit updates all of the wording and
adds notes and comments where appropriate.
2016-05-06 18:09:17 +02:00
wm4 a93fb460cd ao_alsa: add more shitty workarounds
This reportedly makes it work on ODROID-C2. The idea for this hack is
taken from kodi; they unconditionally set some or all of those flags.
I don't trust ALSA enough to hope that setting these flags couldn't
break something else, so we try without them first.

It's not clear whether this is a driver bug or a bug in the ALSA libs.
There is no ALSA bug tracker (the ALSA website has had a dead link to
a deleted bug tracker fo years). There's not much we can do other than
piling up ridiculous hacks. At least I think that at this point invalid
API usage by mpv can be excluded as a cause.

ALSA might be the worst audio API ever.
2016-05-06 17:20:02 +02:00
wm4 eef271c8f4 manpage: minor fixes to --lavfi-complex 2016-05-06 10:15:33 +02:00
wm4 7a75e7c002 vo_opengl: angle: avoid fullscreen FBO copy for flipping
In order to honor the differences between OpenGL and Direct3D coordinate
systems, ANGLE uses a full FBO copy merely to flip the final frame
vertically. This can be avoided with the EGL_ANGLE_surface_orientation
extension.
2016-05-05 18:44:41 +02:00
wm4 605dd928d3 vo_opengl: angle: call eglTerminate()
I hope that this does what we expect it does: destroy the EGLDisplay
specific to our HDC. (Some implementations will terminate all EGL
contexts in the whole process.)

eglReleaseThread() merely calls eglMakeCurrent(0, 0, 0, 0), which is
not enough.

This commit also fixes the problem fixed with the previous commit,
but I think both changes are needed to make our API usage clean.
2016-05-05 13:46:18 +02:00
wm4 f56555b514 vo_opengl: EGL: fix hwdec probing
If ANGLE was probed before (but rejected), the ANGLE API can remain
"initialized", and eglGetCurrentDisplay() will return a non-NULL
EGLDisplay. Then if a native GL context is used, the ANGLE/EGL API will
then (apparently) keep working alongside native OpenGL API. Since GL
objects are just numbers, they'll simply fail to interact, and OpenGL
will get invalid textures. For some reason this will result in black
textures.

With VAAPI-EGL, something similar could happen in theory, but didn't in
practice.
2016-05-05 13:38:08 +02:00
wm4 e5e1088c92 command: use NBSP for spacing after current marker for OSD lists
Requested. Will prevent odd layout for playlists with URLs longer than
the screen.
2016-05-04 21:51:35 +02:00
wm4 b2646911a9 client API: access choices as flags if appropriate
Options/properties that are choices, and which include "yes" or "no"
values (or both) can now be read and written as MPV_FORMAT_FLAG.

For write access, rejecting flags in these cases was obnoxiously
unintuitive and inconvenient.

For read access, the value of this is less convincing, and actually it's
a major API change. At this point I probably have to admit that the
finer details of the client API are very unstable.
2016-05-04 17:37:54 +02:00
wm4 833375f88d command: change some hwdec properties
Introduce hwdec-current and hwdec-interop properties.

Deprecate hwdec-detected, which never made a lot of sense, and which is
replaced by the new properties. hwdec-active also becomes useless, as
hwdec-current is a superset, so it's deprecated too (for now).
2016-05-04 16:55:26 +02:00
Niklas Haas 86b5f1463c lcms: don't warn/error on 3dlut cache misses
Cache misses are a normal and expected part of the operation of a cache.
It doesn't really make sense to show a user-visible warning for them.

To work-around this, just skip trying to open the cache if it doesn't
exist yet.
2016-05-04 12:10:55 +02:00
Niklas Haas 9054460bba lcms: improve black point handling (especially BT.1886)
First of all, black point compensation is now on by default. This is
really rather harmless and only improves the result (where "improvement"
means "less black clipping").

Second, this adds an option to limit the ICC profile's contrast, which
helps for untagged matrix profiles that are implicitly black scaled even
in colorimetric intent. (Note that this relies on BPC being enabled to
work properly, which is why the two changes are tied together)

Third, this uses the LittleCMS built in black point estimator instead of
relying on the presence of accurate A2B tables. This also checks tags
and does some amounts of noise elimination.

If the option is unspecified and the profile is missing black point
information, print a warning instructing the user to set the option, and
fall back to 1000 otherwise.
2016-05-04 12:10:45 +02:00
wm4 05c398fb6c command: slightly nicer OSD list formatting
For "current" markers on OSD properties like chapter-list. The marker is
now an actual arrow instead of "> ", and non-current entries will have
the same indentation as the current entry.

While I'm not entirely sure about the new look of those lists, it's a
bit better than the visual mess that was before.
2016-05-03 22:41:53 +02:00
wm4 485ae095f7 osd: make osd_ass_0/1 defines
So we can concatenate them with strings at compile time.
2016-05-03 22:29:12 +02:00
wm4 5be40f035b d3d: DXVA2_ModeMPEG2_VLD supports all profiles
Fixes hardware decoding of most mpeg2 things.
2016-05-03 15:46:16 +02:00
wm4 eefe7ad28b vo_opengl: vdpau: fix certain cases of preemption recovery failures
The vdpau_mixer could fail to be recreated properly if preemption
occured at some point before playback initialization (like when using
--hwdec-preload and the opengl-cb API).

Normally, the vdpau_mixer was supposed to be marked invalid when the
components using it detect a preemption, e.g. in hwdec_vdpau.c. This one
didn't mark the vdpau_mixer as invalid if preemption was detected in
reinit(), only in map_image().

It's cleaner to detect preemption directly in the vdpau_mixer, which
ensures it's always recreated correctly.
2016-05-03 13:56:11 +02:00
wm4 51e4c065ff ao_alsa: log final hwparams too
snd_pcm_hw_params() updates them.
2016-05-03 11:24:47 +02:00
wm4 8a26e139af x11: extend --x11-bypass-compositor with fs-only option
The "fs-only" choice sets the _NET_WM_BYPASS_COMPOSITOR to 1 if the
window is fullscreened, and 0 otherwise. (0 is specified to be the
implicit default - i.e. no change is requested in windowed mode.)

In particular, change the default to "fs-only".

Fixes #2582.
2016-05-02 21:21:53 +02:00
wm4 f54e555d27 wscript: make at least 1 OpenGL output mandatory
You have to explicitly disable it if you really want to compile without
it (like with libass).
2016-05-01 20:15:53 +02:00
wm4 3ff3749b7d av_log: readd ffmpeg library runtime version mismatch warning
It just happens far too often.
2016-05-01 20:11:15 +02:00
James Ross-Gowan 622bcb0e37 win32: replace libuuid.a usage with initguid.h
Including initguid.h at the top of a file that uses references to GUIDs
causes the GUIDs to be declared globally with __declspec(selectany). The
'selectany' attribute tells the linker to consolidate multiple
definitions of each GUID, which would be great except that, in Cygwin
and MinGW GCC 6.1, this method of linking makes the GUIDs conflict with
the ones declared in libuuid.a.

Since initguid.h obsoletes libuuid.a in modern compilers that support
__declspec(selectany), add initguid.h to all files that use GUIDs and
remove libuuid.a from the build.

Fixes #3097
2016-05-01 21:10:24 +10:00
Vaidas Kascėnas 9fda504d18 manpage: fix typo
Signed-off-by: wm4 <wm4@nowhere>
2016-04-30 18:58:34 +02:00
Nyx0uf ed695ce689 os x: handle multiple dropped files on the window
Should fix #3076 (partially).

Signed-off-by: wm4 <wm4@nowhere>
2016-04-30 18:58:06 +02:00
maniak1349 949247d6e6 w32_common: respect --fit-border on size check
Fit whole window or just a client area in accord with value of --fit-border option.

Fixes #2935.
2016-04-30 18:55:09 +02:00
maniak1349 70f64f3ca9 options: add --fit-border video option
Flag that is set by default. Reseting it will result in mpv trying to fit
client area with video instead of the whole window with border and
decorations on the screen.
Marked as (Windows only) for now until it's implemented on other platforms.
2016-04-30 18:55:09 +02:00
maniak1349 5c90352ae6 w32_common: fix size calculations for window resize
Substraction of 1 is not necessary due to .right and .bottom values of RECT
struct describing a point one pixel outside of the rectangle.

Fixes #2935. (2.b)
2016-04-30 18:55:09 +02:00
wm4 0826b78bc5 sd_ass: minor consistency adjustment 2016-04-30 14:26:08 +02:00
wm4 3a8058658d sd_add: replace --sub-ass=no with --ass-style-override=strip
--sub-ass=no / --ass=no still work, but --ass-style-override=strip is
preferred now. With this change, --ass-style-override can control all
the types of style overriding.
2016-04-30 14:25:23 +02:00
Kevin Mitchell 8d51f08010 d3d11va: fix invalid deref on decoder init failure
fixes #3092
2016-04-29 23:36:01 -07:00
wm4 64f9e48bf1 d3d11va, dxva2: return the format struct directly
Slight simplification, IMHO.
2016-04-29 23:30:01 +02:00
wm4 016eab2209 d3d11va, dxva2: simplify decoder selection
In particular, this moves the depth test to common code.

Should be functionally equivalent, except that for DXVA2, the
IDirectXVideoDecoderService_GetDecoderRenderTargets API is called
more often potentially.
2016-04-29 23:24:28 +02:00
wm4 bda111018c video: add IMGFMT_P010 alias
Gets rid of some silliness, and might be useful in the future.
2016-04-29 22:38:54 +02:00
wm4 0ed206abd9 command: don't seek immediately when setting a-b loop when paused
Because it's annoying and feels unnatural.

If the B point is set while paused, don't seek. If not paused, it should
properly loop immediately.

In theory there's a chance that it will show at least 1 frame after the
loop point when setting the B point. But let's not care about that.
2016-04-28 22:46:49 +02:00
wm4 d30634b104 ao_alsa: log hwparams while restricting them
They can sometimes fail, so I want logging to determine what's going on.

Most of them are at debug log-level, except the final hwparams.
2016-04-28 13:31:13 +02:00
wm4 304d9d58dd vo_opengl: fix build with GLES3 headers
Legacy desktop GL only symbols. Broken by the previous commit.
2016-04-27 20:26:08 +02:00
wm4 9d16837c99 vo_opengl: support GL_EXT_texture_norm16 on GLES
This gives us 16 bit fixed-point integer texture formats, including
ability to sample from them with linear filtering, and using them as FBO
attachments.

The integer texture format path is still there for the sake of ANGLE,
which does not support GL_EXT_texture_norm16 yet.

The change to pass_dither() is needed, because the code path using
GL_R16 for the dither texture relies on glTexImage2D being able to
convert from GL_FLOAT to GL_R16. GLES does not allow this. This could be
trivially fixed by doing the conversion ourselves, but I'm too lazy to
do this now.
2016-04-27 19:19:56 +02:00
wm4 757c8baf8c vo_opengl: always use sized internal formats
This shouldn't make much of a difference, but should make the following
commit simpler.
2016-04-27 19:02:04 +02:00
wm4 5df4ee55f1 player: strictly wait until done when backstepping
This fixes backstepping getting "stuck" when e.g. holding down a key
bound to the backstep command. The reason is that even if the backstep
itself is finished, the next backstep might not take the new video PTS
as reference if the hr-seek itself isn't finished yet.

The intention of not waiting for the hr-seek to finish was faster
backstepping by possibly skipping audio decoding. But it probably
doesn't matter enough to make the rest of the code more complex.
2016-04-27 17:02:00 +02:00
wm4 9cb036f297 vo_opengl: d3d11egl: minor simplification
This should be ok. eglBindTexImage() just associates the texture, and
does not make a copy (not even a conceptual one).
2016-04-27 14:35:24 +02:00
wm4 0b1ba577b1 vo_opengl: d3d11egl: print warning on unsupported colorspaces
Not much we can do about. If there are many complaints, a mechanism to
automatically disable interop in such cases could be added.
2016-04-27 14:34:46 +02:00
wm4 dff33893f2 d3d11va: store texture/subindex in IMGFMT_D3D11VA plane pointers
Basically this gets rid of the need for the accessors in d3d11va.h, and
the code can be cleaned up a little bit.

Note that libavcodec only defines a ID3D11VideoDecoderOutputView pointer
in the last plane pointers, but it tolerates/passes through the other
plane pointers we set.
2016-04-27 14:06:50 +02:00
wm4 9896994688 vd_lavc: adjust D3D11VA autoprobe order
We want to prefer d3d11va over dxva2 anything. But since dxva2 copyback
is more efficient than d3d11va's currently, d3d11va-copy should come
last.
2016-04-27 13:54:20 +02:00
wm4 3706918311 vo_opengl: D3D11VA + ANGLE interop
This uses ID3D11VideoProcessor to convert the video to a RGBA surface,
which is then bound to ANGLE. Currently ANGLE does not provide any way
to bind nv12 surfaces directly, so this will have to do.

ID3D11VideoContext1 would give us slightly more control about the
colorspace conversion, though it's still not good, and not available
in MinGW headers yet.

The video processor is created lazily, because we need to have the coded
frame size, of which AVFrame and mp_image have no concept of. Doing the
creation lazily is less of a pain than somehow hacking the coded frame
size into mp_image.

I'm not really sure how ID3D11VideoProcessorInputView is supposed to
work. We recreate it on every frame, which is simple and hopefully
doesn't affect performance.
2016-04-27 13:49:47 +02:00
wm4 cf9b415173 hwdec: remove numbers from enum
They don't actually mean anything.

Just HWDEC_NONE should remain 0, because it's the default init value for
structs etc.
2016-04-27 13:37:55 +02:00
wm4 d3a26272cd vo_opengl: print error if opengl hwdec interop fails 2016-04-27 13:32:49 +02:00
wm4 0c6c62cb17 lavfi: shut up false positive compiler warnings
As a positive side-effect, this also errors out gracefully for the
extremely unlikely but possible case certain builtin filters are not
available. (This could happen only with crippled libavfilter builds that
can't be used by anything using its public API.)
2016-04-26 19:38:51 +02:00
wm4 da59726776 vd_lavc: hack against videotoolbox crash on failure
I guess this won't ever be fixed properly in FFmpeg. Too hairy, and the
alternative (using VideoToolbox as "full decoder") is too attractive.
2016-04-26 18:53:58 +02:00
wm4 66a958bb4f ao_coreaudio: remove detected_device
Setting this here is a race condition. It's called from a CoreAudio
callbacks, and there are no locks. It's a string, so this can be
potentially severe.

It's hard to fix and only CoreAudio supported it, so remove it.

This causes the "audio-out-detected-device" property to return nothing
on all platforms.
2016-04-26 18:35:37 +02:00
wm4 dfe40f770d vo_rpi: rename mutex/cond variables
They're now used for the TV callback too, not just vsync.
2016-04-26 17:12:01 +02:00
wm4 6798525251 vo_rpi: wait for vsync with a timeout
Sucks, but better than freezing forever given the (to me) unpredictable
RPI behavior. This will be good enough to drop out of vsync timing mode,
or to abort playback.
2016-04-26 17:11:16 +02:00
wm4 74e3d11f21 vo_rpi: attempt to survive display mode changes
Recreate all dispmanx objects after mode changes signalled by the TV
callback. This is needed since dispmanx objects are marked as invalid
and cease working.

One important point is that the vsync callbacks will stop coming when
this happens, so restoring the callback is important.

Note that the MMAL renderer itself does not get trashed by the firmware
on such events, but we completely reconfigure it anyway when it happens.
2016-04-26 16:47:53 +02:00
wm4 dfa88271a2 vp_rpi: fix indentation
This also moves the p->background check into the top if (the code
effectively didn't do anything when this false).
2016-04-26 13:59:06 +02:00
wm4 8ffd2f1dd4 vd_lavc: simplify some unneeded ifdeffery
These were for ancient libavcodec versions.
2016-04-25 19:11:16 +02:00
wm4 6a1814dfb8 vd_lavc: make image_format hwdec field optional
For Mediacodec in particular we don't care about the format. It can just
decode to whatever it wants. The only case we would care about is it not
returning an opaque format if we don't have proper interop, but
libavcodec always returns non-opaque formats by default.
2016-04-25 12:23:38 +02:00
wm4 7e3d8e7134 vd_lavc: simplify RPI and Mediacodec wrappers
Use the recently added lavc_suffix mechanism to select the wrapper
decoder.

With all hwdec callbacks being optional, and RPI/Mediacodec having only
dummy callbacks, all the callbacks can be removed as well.

The result is that the vd_lavc_hwdec struct for both of them is tiny.
It's better to move them to vd_lavc.c directly, because they are so
trivial and small.
2016-04-25 12:23:38 +02:00
wm4 46e49a37be vd_lavc: make all hwdec callbacks optional 2016-04-25 12:23:37 +02:00
wm4 bb17df1f07 vd_lavc: set AVCodecContext.time_base to forced time base
This is a bit sketchy, as there isn't a truly standard way to
communicate the timebase.
2016-04-25 12:23:37 +02:00
wm4 4f5509e1dd vd_lavc: better hwdec wrapper decoder selection
This is intended for cases when --hwdec needs to override the decoder
implementation in use, like for example on the RPI.

It does two things:
1. Allow the hwdec to indicate a decoder suffix. libavcodec by
   convention adds a suffix to all wrapper decoders, and here we start
   relying on it. While not necessarily the best idea, it's the only
   thing we got. libavcodec's hwaccel list is useless, because it only
   has the codec ID, not the associated decoder's name.
2. Make --hwdec=auto work properly. It shouldn't fail anymore, and hwdec
   probing should reliably work, even if a different decoder is selected
   with --vd. The semantics of --hwdec should dictate that it overrides
   the default decoder.
2016-04-25 12:13:12 +02:00
wm4 85416bc36a vd_lavc: allow process_image() to return NULL
In case of errors or whatever.
2016-04-25 11:30:07 +02:00
wm4 021cb2c387 mp_image: allow passing NULL to mp_image_new_custom_ref()
A minor simplification. Most callers don't need this, and there's no
good reason why the caller should provide an "initializer" like this.
(This function calls mp_image_new_dummy_ref(), which has no reason
for an initializer either.)
2016-04-25 11:28:49 +02:00
trUSTssc e232f1a731 player: fix memleak when using video-frame-info 2016-04-24 20:44:01 +02:00
wm4 5800d1845f player: always show the first frame in DS mode
Fixes bogus frame drop counter in cover art mode.
2016-04-24 20:14:51 +02:00
wm4 5f97bd4223 player: assume video forwards timestamps jumps only with some formats
Another crappy fix for timestamp reset issues. This time, we try to fix
files which have very weird but legitimate frame durations, such as
cdgraphics. It can have many short frames, but once in a while there are
potentially very long frames.

Fixes #3027.
2016-04-24 18:24:46 +02:00
wm4 649e155938 manpage: fix --autofit example
Fixes #3069.
2016-04-24 17:58:39 +02:00
wm4 47e7676e7e player: force VO reconfig when unselecting video track
Switches to a black window if --force-window is used while coverart
"video" is playing.
2016-04-23 18:55:24 +02:00
wm4 786f37ae1c player: cleaner determination of current playback PTS
In particular, this won't overwrite the playback PTS in coverart mode,
which actually fixes relative seeks.
2016-04-23 18:55:24 +02:00
wm4 abb3f80998 player: eagerly redraw OSD when seeking with coverart 2016-04-23 16:39:46 +02:00
wm4 b1a8e8dba6 vd_lavc: fix hwdec fallback if hwdec pre-initialization fails
Damn.
2016-04-22 15:52:16 +02:00
wm4 244eff9201 vo_opengl: always reset some GL state when leaving renderer
The active texture and some pixelstore parameters are now always reset
to defaults when entering and leaving the renderer. Could be important
for libmpv.
2016-04-22 12:08:21 +02:00
wm4 2b4123f078 player: fix OSD bar chapter marks
Truly dumb bug introduced with the previous commit.
2016-04-22 09:31:21 +02:00
wm4 1944a34c23 command: if only ab-loop-b is set, loop from start of file
Commit 382bafcb changed the behavior for ab-loop-a. This commit changes
ab-loop-b so that the behavior is symmetric.

Adjust the OSD rendering accordingly to the two changes.

Also fix mentions of the "ab_loop" command to the now preferred
"ab-loop".
2016-04-21 22:15:36 +02:00
wm4 78346e9c9a ad_spdif: take care of deprecated libavcodec API usage 2016-04-20 19:37:45 +02:00
wm4 60664bc00b stream_memory: add hex:// protocol
Completely useless, expect for some special purposes.
2016-04-20 18:00:20 +02:00
wm4 834a236514 player: force wakeup on playback restart
Just a theoretical issue, most likely.
2016-04-20 13:11:11 +02:00
wm4 cd9ee1a853 player: really start audio only once video is ready
The check whether video is ready yet was done only in STATUS_FILLING.
But it also switched to STATUS_READY, which means the next time
fill_audio_out_buffers() was called, audio would actually be started
before video.

In most situations, this bug didn't show up, because it was only
triggered if the demuxer didn't provide video packets quickly enough,
but did for audio packets.

Also log when audio is started.

(I hate fill_audio_out_buffers(), why did I write it?)
2016-04-20 13:08:06 +02:00
wm4 61ac156d47 player: reduce some timer calls 2016-04-20 10:50:22 +02:00
wm4 8dbc93a94c player: minor simplification to buffering property updates
Strictly schedule an update in regular intervals as long as either
stream cache or demuxer are prefetching. Don't update just always
because the stream cache is enabled ("idle != -1") or cache-related
properties are observed (mp_client_event_is_registered()).

Also, the "idle" variable was awkard; get rid of it with equivalent
code.
2016-04-20 10:41:09 +02:00
wm4 8db9206c54 player: simplify an aspect of buffering determination
Calculate the buffering percentage in the same code which determines
whether the player is or should be buffering. In particular it can't
happen that percentage and buffering state are slightly out of sync due
to calling DEMUXER_CTRL_GET_READER_STATE and reusing it with the
previously determined buffering state.

Now it's also easier to guarantee that the buffering state is updated
properly.

Add some more verbose output as well.

(Damn I hate this code, why did I write it?)
2016-04-19 22:01:30 +02:00
wm4 503dada42f demux_playlist: read directories recursive
demux_playlist.c recognizes if the source stream points to a directory,
and adds its directory entries. Until now, only 1 level was added.
During playback, further directory entries could be resolved as
directory paths were "played".

While this worked fine, it lead to frequent user confusion, because
playlist resuming and other things didn't work as expected. So just
recursively scan everything.

I'm unsure whether it's a good fix, but at least it gets rid of the
complaints. (And probably will add others.)
2016-04-18 22:08:44 +02:00
wm4 382bafcb13 player: loop on end of file if ab-loop-b is unset
Possibly slightly more useful/intuitive.
2016-04-18 21:33:19 +02:00
Kevin Mitchell ce153bdb42 d3dva: move Intel_H264_NoFGT_ClearVideo to lower priority
This seems to cause problems, so only use it if H264_E is not available.

fixes #3059
2016-04-18 02:00:50 -07:00
Kevin Mitchell 2f5c7af914 dxva2: fix missing newline in error message 2016-04-18 01:58:18 -07:00
Kevin Mitchell 611594e7e8 d3dva: include selected decoder and format in verbose output 2016-04-17 18:28:14 -07:00
Philip Sequeira 1f1117d0dd input: fix parsing multiple input command prefixes 2016-04-17 12:53:30 +02:00
Philip Sequeira d797f7def9 TOOLS/zsh.pl: complete --audio-device 2016-04-16 18:47:15 +02:00
wm4 44644e69f0 vo_opengl: fix an outdated comment
This wasn't updated over multiple iterations.
2016-04-16 16:16:50 +02:00
wm4 8e96e04999 command: fix cycling certain properties
Commit a9bd4535 generally changed properties are set to string values.
This actually broke the fallback for non-string properties, because the
set string action was redirected directly to the property, instead of
the generic handler and its fallback code.
2016-04-15 22:10:19 +02:00
wm4 9db1b7a001 vo_lavc: fix build on Libav
OF COURSE Libav doesn't have AV_PICTURE_TYPE_NONE. Why the fuck would
it?
2016-04-15 19:35:29 +02:00
wm4 050b17ca9c mp_image: make mp_image_copy_fields_* private
Future code should always use mp_image_{to,from}_av_frame(). Everything
else is way too messy and fragile.
2016-04-15 15:48:02 +02:00
wm4 a77cbc504a vo_lavc: unsupport deprecated AVFMT_RAWPICTURE
As of ffmpeg git master, only the libavdevice decklink wrapper supports
this. Everything else has dropped support.

You're now supposed to use AV_CODEC_ID_WRAPPED_AVFRAME, which works a
bit differently. Normal AVFrames should still work for these encoders.
2016-04-15 15:45:38 +02:00
wm4 798188cb33 vo_lavc: send refcounted AVFrame to encoder
This potentially makes it more efficient, and actually makes it simpler.

Yes, AV_PICTURE_TYPE_NONE is the default for pict_type.
2016-04-15 15:43:46 +02:00
wm4 d04aa5ef4e mp_image: add mp_image_to_av_frame()
What mp_image_to_av_frame_and_unref() should have been. (The _unref
variant is still useful though.)
2016-04-15 15:33:53 +02:00
wm4 e6cdfdfa74 mp_image: simplify mp_image_steal_data()
Why was this so complex.
2016-04-15 15:31:23 +02:00
wm4 bbaedfd0c5 mp_image: pass through AVHWFramesContext
In both directions.
2016-04-15 15:07:02 +02:00
wm4 607ba5f235 ao_coreaudio_exclusive: list formats when searching substream
Should help debug problems with AC3 passthrough not working.
2016-04-15 14:19:22 +02:00
wm4 1aa943d8ab ao_coreaudio: remove unused function 2016-04-15 14:14:42 +02:00
wm4 b735c0e207 lcms: include math.h
Fixes #3053.
2016-04-15 13:58:41 +02:00
wm4 fbb5da0010 command: log property set calls
And remove the same thing from the client API code.

The command.c code has to deal with many specialized M_PROPERTY_SET_*
actions, and we bother with a subset only.
2016-04-15 13:20:05 +02:00
wm4 177f5d9e9c command: allow setting panscan etc. properties if no video is active
In that case, it merely changes the underlying option value.
2016-04-15 11:32:40 +02:00
wm4 a9bd4535d2 client API: improve mpv_set_property() handling of MPV_FORMAT_NODE
If a mpv_node wrapped a string, the behavior was different from calling
mpv_set_property() with MPV_FORMAT_STRING directly. Change this.

The original intention was to be strict about types if MPV_FORMAT_NODE
is used. But I think the result was less than ideal, and the same change
towards less strict behavior was made to mpv_set_option() ages ago.
2016-04-15 11:32:40 +02:00
wm4 8c02c92ab9 vo_opengl: rpi: don't include x11 header file
Copy & paste bug.
2016-04-15 09:45:15 +02:00
wm4 4ebac1e936 player: fix use-after-free with --screenshot-directory
Probably fixes #3049.
2016-04-14 22:48:12 +02:00
wm4 e13cc25a2c build: add check for AVHWFramesContext API
It's not used yet anywhere. Pushing this now so switching between
branches is less bothersome.
2016-04-14 18:20:13 +02:00
wm4 0467f5287d m_option: slightly improve --msg-level=help output
In particular get rid of the semi-deprecated ":" separator.
2016-04-13 22:25:51 +02:00
wm4 9a4120f21f m_option: add string conversion for --audio-channels
Requested in #3040.
2016-04-13 22:22:53 +02:00
Niklas Haas e3e03d0f34 vo_opengl: simplify and improve up scale=oversample
Since what we're doing is a linear blend of the four colors, we can just
do it for free by using GPU sampling.

This requires significantly fewer texture fetches and calculations to
compute the final color, making it much more efficient. The code is also
much shorter and simpler.
2016-04-12 16:26:53 +02:00
wm4 f4142ab9ad demux_mkv: fix seeking with files that miss the first index entry
Now it will always be able to seek back to the start, even if the index
is sparse or misses the first entry.

This can be achieved by reusing the logic for incremental index
generation (for files with no index), and start time probing (for making
sure the first block is always indexed).
2016-04-12 15:41:44 +02:00
wm4 837b865c7f vf_vavpp: reindent 2016-04-11 22:03:26 +02:00
wm4 f5ff2656e0 vaapi: determine surface format in decoder, not in renderer
Until now, we have made the assumption that a driver will use only 1
hardware surface format. the format is dictated by the driver (you
don't create surfaces with a specific format - you just pass a
rt_format and get a surface that will be in a specific driver-chosen
format).

In particular, the renderer created a dummy surface to probe the format,
and hoped the decoder would produce the same format. Due to a driver
bug this required a workaround to actually get the same format as the
driver did.

Change this so that the format is determined in the decoder. The format
is then passed down as hw_subfmt, which allows the renderer to configure
itself with the correct format. If the hardware surface changes its
format midstream, the renderer can be reconfigured using the normal
mechanisms.

This calls va_surface_init_subformat() each time after the decoder
returns a surface. Since libavcodec/AVFrame has no concept of sub-
formats, this is unavoidable. It creates and destroys a derived
VAImage, but this shouldn't have any bad performance effects (at
least I didn't notice any measurable effects).

Note that vaDeriveImage() failures are silently ignored as some
drivers (the vdpau wrapper) support neither vaDeriveImage, nor EGL
interop. In addition, we still probe whether we can map an image
in the EGL interop code. This is important as it's the only way
to determine whether EGL interop is supported at all. With respect
to the driver bug mentioned above, it doesn't matter which format
the test surface has.

In vf_vavpp, also remove the rt_format guessing business. I think the
existing logic was a bit meaningless anyway. It's not even a given
that vavpp produces the same rt_format for output.
2016-04-11 22:03:26 +02:00
Rudolf Polzer 49431626cb Revert "build: disable encoding mode by default"
Reverting because the use of deprecated API has been fixed.

This reverts commit d0238711dc.
2016-04-11 14:59:33 -04:00
Rudolf Polzer 160497b8ff encode_lavc: Migrate to codecpar API. 2016-04-11 14:57:20 -04:00
236 changed files with 10481 additions and 6130 deletions

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
### mpv version and platform
If you're not using git master or the latest release, update.
### Reproduction steps
### Expected behavior
### Actual behavior
### Log files
Make a log file made with -v or --log-file=output.txt, paste it to sprunge.us,
and replace this text with a link to it.
+7
View File
@@ -0,0 +1,7 @@
Ideally, you shouldn't need enter any text here, and your commit messages should
explain your changes sufficiently (especially why they are needed). Read
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md for coding
style and development conventions. Remove this text block, but if you haven't
agreed to it before, leave the following sentence in place:
I agree that my changes can be relicensed to LGPL 2.1 or later.
-1
View File
@@ -15,7 +15,6 @@
/tags
/TAGS
/video/out/x11_icon.inc
/video/out/opengl/nnedi3_weights.inc
/demux/ebml_defs.c
/demux/ebml_types.h
/sub/osd_font.h
+1 -1
View File
@@ -37,7 +37,7 @@ matrix:
- os: linux
compiler: clang
before_install: ./travis-deps libass-stable $LIBAV
before_install: TOOLS/travis-deps libass-stable $LIBAV
script:
- ./bootstrap.py
- ./waf configure
-32
View File
@@ -1,32 +0,0 @@
Reporting bugs
==============
- State your platform and mpv version.
- Make sure you're actually using the latest mpv release. Linux distributions
in particular love redistributing ancient and unmaintained mpv releases.
- Attach a log file made with ``-v`` or ``--log-file=output.txt``.
- Avoid attaching text files packed in archive files (zip/rar/...), unless
explicitly asked so. There are better means, such as using http://sprunge.us
- If you think this is file specific, upload a sample file and link it.
- Don't report multiple unrelated/barely related bugs in one issue.
- If you don't get a reply after days, be sure to post a new message to the
issue - it could have been overlooked or forgotten.
- Read: https://mpv.io/bug-reports/
Asking questions
================
Preferably, asking questions should be done via IRC (#mpv on irc.freenode.net),
but asking questions by opening a github issue is also barely tolerated.
When asking on IRC (#mpv on irc.freenode.net), don't ask to ask, just state
your problem. Stay long enough until someone gets a chance to reply. Sometimes
it can take hours.
Sending patches
===============
See: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md
In particular, be aware that all changes to GPL code must come with the
implicit agreement that they might be LGPLv2.1+ relicensed at a later point.
-3
View File
@@ -12,9 +12,6 @@ the code to LGPLv2.1+ at a later point without asking the contributor. (This
is a safeguard for making potential relicensing of the project to LGPLv2.1+
easier.) Using a more liberal license compatible to LGPLv2.1+ is also ok.
Some GPLv3 or LGPLv3 code in mpv can be enabled by building with --enable-gpl3,
and in this case, the resulting binaries must be distributed under GPLv3.
For information about authors and contributors, consult the git log, which
contains the complete SVN and CVS history as well.
+23
View File
@@ -32,6 +32,29 @@ API changes
::
--- mpv 0.18.1 ---
---- - remove "status" log level from mpv_request_log_messages() docs. This
is 100% equivalent to "v". The behavior is still the same, thus no
actual API change.
--- mpv 0.18.0 ---
1.21 - mpv_set_property() changes behavior with MPV_FORMAT_NODE. Before this
change it rejected mpv_nodes with format==MPV_FORMAT_STRING if the
property was not a string or did not have special mechanisms in place
the function failed. Now it always invokes the option string parser,
and mpv_node with a basic data type works exactly as if the function
is invoked with that type directly. This new behavior is equivalent
to mpv_set_option().
This also affects the mp.set_property_native() Lua function.
- generally, setting choice options/properties with "yes"/"no" options
can now be set as MPV_FORMAT_FLAG
- reading a choice property as MPV_FORMAT_NODE will now return a
MPV_FORMAT_FLAG value if the choice is "yes" (true) or "no" (false)
This implicitly affects Lua and JSON IPC interfaces as well.
- big changes to vo-cmdline on vo_opengl and vo_opengl_hq (but not
vo_opengl_cb): options are now normally not reset, but applied on top
of the current options. The special undocumented value "-" still
works, but now resets all options to before any vo-cmdline command
has been called.
--- mpv 0.12.0 ---
1.20 - deprecate "GL_MP_D3D_interfaces"/"glMPGetD3DInterface", and introduce
"GL_MP_MPGetNativeDisplay"/"glMPGetNativeDisplay" (this is a
+35
View File
@@ -19,6 +19,41 @@ Interface changes
::
--- mpv 0.18.1 ---
- deprecate --heartbeat-cmd
- remove --softvol=no capability:
- deprecate --softvol, it now does nothing
- --volume, --mute, and the corrsponding properties now always control
softvol, and behave as expected without surprises (e.g. you can set
them normally while no audio is initialized)
- rename --softvol-max to --volume-max (deprecated alias is added)
- the --volume-restore-data option and property are removed without
replacement. They were _always_ internal, and used for watch-later
resume/restore. Now --volume/--mute are saved directly instead.
- the previous point means resuming files with older watch-later configs
will print an error about missing --volume-restore-data (which you can
ignore), and will not restore the previous value
- as a consequence, volume controls will no longer control PulseAudio
per-application value, or use the system mixer's per-application
volume processing
- system or per-application volume can still be controlled with the
ao-volume and ao-mute properties (there are no command line options)
--- mpv 0.18.0 ---
- now ab-loops are active even if one of the "ab-loop-a"/"-b" properties is
unset ("no"), in which case the start of the file is used if the A loop
point is unset, and the end of the file for an unset B loop point
- deprecate --sub-ass=no option by --ass-style-override=strip
(also needs --embeddedfonts=no)
- add "hwdec-interop" and "hwdec-current" properties
- deprecated "hwdec-active" and "hwdec-detected" properties (to be removed
in mpv 0.20.0)
- choice option/property values that are "yes" or "no" will now be returned
as booleans when using the mpv_node functions in the client API, the
"native" property accessors in Lua, and the JSON API. They can be set as
such as well.
- the VO opengl fbo-format sub-option does not accept "rgb" or "rgba"
anymore
- all VO opengl prescalers have been removed (replaced by user scripts)
--- mpv 0.17.0 ---
- deprecate "track-list/N/audio-channels" property (use
"track-list/N/demux-channel-count" instead)
+5 -1
View File
@@ -70,7 +70,7 @@ Available filters are:
Set AVOptions on the SwrContext or AVAudioResampleContext. These should
be documented by FFmpeg or Libav.
``lavcac3enc[=tospdif[:bitrate[:minch]]]``
``lavcac3enc[=options]``
Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports
16-bit native-endian input format, maximum 6 channels. The output is
big-endian when outputting a raw AC-3 stream, native-endian when
@@ -103,6 +103,10 @@ Available filters are:
If the input channel number is less than ``<minch>``, the filter will
detach itself (default: 3).
``encoder=<name>``
Select the libavcodec encoder used. Currently, this should be an AC-3
encoder, and using another codec will fail horribly.
``equalizer=g1:g2:g3:...:g10``
10 octave band graphic equalizer, implemented using 10 IIR band-pass
filters. This means that it works regardless of what type of audio is
+112 -47
View File
@@ -459,6 +459,8 @@ Input Commands that are Possibly Subject to Change
Remove all filters. Note that like the other sub-commands, this does
not control automatically inserted filters.
The argument is always needed. E.g. in case of ``clr`` use ``vf clr ""``.
You can assign labels to filter by prefixing them with ``@name:`` (where
``name`` is a user-chosen arbitrary identifier). Labels can be used to
refer to filters by name in all of the filter chain modification commands.
@@ -561,29 +563,20 @@ Input Commands that are Possibly Subject to Change
the resolution is reduced to that of the video's. You can read the
``osd-width`` and ``osd-height`` properties. At least with ``--vo-xv`` and
anamorphic video (such as DVD), ``osd-par`` should be read as well, and the
overlay should be aspect-compensated. (Future directions: maybe mpv should
take care of some of these things automatically, but it's hard to tell
where to draw the line.)
overlay should be aspect-compensated.
``id`` is an integer between 0 and 63 identifying the overlay element. The
ID can be used to add multiple overlay parts, update a part by using this
command with an already existing ID, or to remove a part with
``overlay-remove``. Using a previously unused ID will add a new overlay,
while reusing an ID will update it. (Future directions: there should be
something to ensure different programs wanting to create overlays don't
conflict with each others, should that ever be needed.)
while reusing an ID will update it.
``x`` and ``y`` specify the position where the OSD should be displayed.
``file`` specifies the file the raw image data is read from. It can be
either a numeric UNIX file descriptor prefixed with ``@`` (e.g. ``@4``),
or a filename. The file will be mapped into memory with ``mmap()``. Some VOs
will pass the mapped pointer directly to display APIs (e.g. opengl or
vdpau), so no actual copying is involved. Truncating the source file while
the overlay is active will crash the player. You shouldn't change the data
while the overlay is active, because the data is essentially accessed at
random points. Instead, call ``overlay-add`` again (preferably with a
different memory region to prevent tearing).
or a filename. The file will be mapped into memory with ``mmap()``,
copied, and unmapped before the command returns (changed in mpv 0.18.1).
It is also possible to pass a raw memory address for use as bitmap memory
by passing a memory address as integer prefixed with an ``&`` character.
@@ -616,15 +609,14 @@ Input Commands that are Possibly Subject to Change
(Technically, the minimum size would be ``stride * (h - 1) + w * 4``, but
for simplicity, the player will access all ``stride * h`` bytes.)
.. admonition:: Warning
.. note::
When updating the overlay, you should prepare a second shared memory
region (e.g. make use of the offset parameter) and add this as overlay,
instead of reusing the same memory every time. Otherwise, you might
get the equivalent of tearing, when your application and mpv write/read
the buffer at the same time. Also, keep in mind that mpv might access
an overlay's memory at random times whenever it feels the need to do
so, for example when redrawing the screen.
Before mpv 0.18.1, you had to do manual "double buffering" when updating
an overlay by replacing it with a different memory buffer. Since mpv
0.18.1, the memory is simply copied and doesn't reference any of the
memory indicated by the command's arguments after the commend returns.
If you want to use this command before mpv 0.18.1, reads the old docs
to see how to handle this correctly.
``overlay-remove <id>``
Remove an overlay added with ``overlay-add`` and the same ID. Does nothing
@@ -634,10 +626,10 @@ Input Commands that are Possibly Subject to Change
Send a message to all clients, and pass it the following list of arguments.
What this message means, how many arguments it takes, and what the arguments
mean is fully up to the receiver and the sender. Every client receives the
message, so be careful about name clashes (or use ``script_message_to``).
message, so be careful about name clashes (or use ``script-message-to``).
``script-message-to "<target>" "<arg1>" "<arg2>" ...``
Same as ``script_message``, but send it only to the client named
Same as ``script-message``, but send it only to the client named
``<target>``. Each client (scripts etc.) has a unique name. For example,
Lua scripts can get their name via ``mp.get_script_name()``.
@@ -651,8 +643,8 @@ Input Commands that are Possibly Subject to Change
separator, e.g. ``script_binding scriptname/bindingname``.
For completeness, here is how this command works internally. The details
could change any time. On any matching key event, ``script_message_to``
or ``script_message`` is called (depending on whether the script name is
could change any time. On any matching key event, ``script-message-to``
or ``script-message`` is called (depending on whether the script name is
included), with the following arguments:
1. The string ``key-binding``.
@@ -1081,8 +1073,8 @@ Property list
"default" MPV_FORMAT_FLAG
``ab-loop-a``, ``ab-loop-b`` (RW)
Set/get A-B loop points. See corresponding options and ``ab_loop`` command.
The special value ``no`` on either of these properties disables looping.
Set/get A-B loop points. See corresponding options and ``ab-loop`` command
for details.
``angle`` (RW)
Current DVD angle.
@@ -1242,29 +1234,31 @@ Property list
See ``--hr-seek``.
``mixer-active``
Return ``yes`` if the audio mixer is active, ``no`` otherwise. This has
implications for ``--softvol=no`` mode: if the mixer is inactive, changing
``volume`` doesn't actually change anything on the system mixer. If the
``--volume`` or ``--mute`` option are used, these might not be applied
properly until the mixer becomes active either. (The options, if set, will
just overwrite the mixer state at audio initialization.)
Return ``yes`` if the audio mixer is active, ``no`` otherwise.
While the behavior with ``mixer-active==yes`` is relatively well-defined,
the ``no`` case will provide possibly wrong or insignificant values.
Note that an active mixer does not necessarily imply active audio output,
although this is implied in the current implementation.
This option is relatively useless. Before mpv 0.18.1, it could be used to
infer behavior of the ``volume`` property.
``volume`` (RW)
Current volume (see ``--volume`` for details). Also see ``mixer-active``
property.
Current volume (see ``--volume`` for details).
``volume-max``
Current maximum value the volume property can be set to. (This may depend
on the ``--softvol-max`` option.)
``volume-max`` (RW)
Current maximum value the volume property can be set to. (Equivalent to the
``--volume-max`` option.)
``mute`` (RW)
Current mute status (``yes``/``no``). Also see ``mixer-active`` property.
Current mute status (``yes``/``no``).
``ao-volume`` (RW)
System volume. This property is available only if mpv audio output is
currently active, and only if the underlying implementation supports volume
control. What this option does depends on the API. For example, on ALSA
this usually changes system-wide audio, while with PulseAudio this controls
per-application volume.
``ao-mute`` (RW)
Similar to ``ao-volume``, but controls the mute state. May be unimplemented
even if ``ao-volume`` works.
``audio-delay`` (RW)
See ``--audio-delay``.
@@ -1349,6 +1343,9 @@ Property list
``colormatrix-primaries`` (R)
See ``colormatrix``.
``taskbar-progress`` (RW)
See ``--taskbar-progress``.
``ontop`` (RW)
See ``--ontop``.
@@ -1385,14 +1382,39 @@ Property list
properties to see whether this was successful.
Unlike in mpv 0.9.x and before, this does not return the currently active
hardware decoder.
hardware decoder. Since mpv 0.18.0, ``hwdec-current`` is available for
this purpose.
``hwdec-current``
Return the current hardware decoding in use. If decoding is active, return
one of the values used by the ``hwdec`` option/property. ``no`` indicates
software decoding. If no decoder is loaded, the property is unavailable.
``hwdec-interop``
This returns the currently loaded hardware decoding/output interop driver.
This is known only once the VO has opened (and possibly later). With some
VOs (like ``opengl``), this might be never known in advance, but only when
the decoder attempted to create the hw decoder successfully. (Using
``--hwdec-preload`` can load it eagerly.) If there are multiple drivers
loaded, they will be separated by ``,``.
If no VO is active or no interop driver is known, this property is
unavailable.
This does not necessarily use the same values as ``hwdec``. There can be
multiple interop drivers for the same hardware decoder, depending on
platform and VO.
``hwdec-active``
Deprecated. To be removed in mpv 0.20.0. Use ``hwdec-current`` instead.
Return ``yes`` or ``no``, depending on whether any type of hardware decoding
is actually in use.
``hwdec-detected``
If software decoding is active, this returns the hardware decoder in use.
Deprecated. To be removed in mpv 0.20.0.
If hardware decoding is active, this returns the hardware decoder in use.
Otherwise, it returns either ``no``, or if applicable, the currently loaded
hardware decoding API. This is known only once the VO has opened (and
possibly later). With some VOs (like ``opengl``), this is never known in
@@ -1646,6 +1668,9 @@ Property list
Current position on playlist. The first entry is on position 0. Writing
to the property will restart playback at the written entry.
``playlist-pos-1`` (RW)
Same as ``playlist-pos``, but 1-based.
``playlist-count``
Number of total playlist entries.
@@ -1787,9 +1812,11 @@ Property list
"albumart" MPV_FORMAT_FLAG
"default" MPV_FORMAT_FLAG
"forced" MPV_FORMAT_FLAG
"selected" MPV_FORMAT_FLAG
"external" MPV_FORMAT_FLAG
"external-filename" MPV_FORMAT_STRING
"codec" MPV_FORMAT_STRING
"ff-index" MPV_FORMAT_INT64
"decoder-desc" MPV_FORMAT_STRING
"demux-w" MPV_FORMAT_INT64
"demux-h" MPV_FORMAT_INT64
@@ -1904,6 +1931,44 @@ Property list
whether the video window is visible. If the ``--force-window`` option is
used, this is usually always returns ``yes``.
``vo-performance``
Some video output performance metrics. Not implemented by all VOs. This has
a number of sup-properties, of the form ``vo-performance/<metric>-<value>``,
all of them in milliseconds.
``<metric>`` refers to one of:
``upload``
Time needed to make the frame available to the GPU (if necessary).
``render``
Time needed to perform all necessary video postprocessing and rendering
passes (if necessary).
``present``
Time needed to present a rendered frame on-screen.
When a step is unnecessary or skipped, it will have the value 0.
``<value>`` refers to one of:
``last``
Last measured value.
``avg``
Average over a fixed number of past samples. (The exact timeframe
varies, but it should generally be a handful of seconds)
``peak``
The peak (highest value) within this averaging range.
When querying the property with the client API using ``MPV_FORMAT_NODE``,
or with Lua ``mp.get_property_native``, this will return a mpv_node with
the following contents:
::
MPV_FORMAT_NODE_MAP
"<metric>-<value>" MPV_FORMAT_INT64
(One entry for each ``<metric>`` and ``<value>`` combination)
``video-bitrate``, ``audio-bitrate``, ``sub-bitrate``
Bitrate values calculated on the packet level. This works by dividing the
bit size of all packets between two keyframes by their presentation
@@ -2063,7 +2128,7 @@ Property list
(Note that if an option is marked as file-local, even ``options/`` will
access the local value, and the ``old`` value, which will be restored on
end of playback, can not be read or written until end of playback.)
end of playback, cannot be read or written until end of playback.)
``option-info/<name>``
Additional per-option information.
+8 -4
View File
@@ -175,7 +175,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
Similar to ``mp.set_property``, but set the given property using its native
type.
Since there are several data types which can not represented natively in
Since there are several data types which cannot represented natively in
Lua, this might not always work as expected. For example, while the Lua
wrapper can do some guesswork to decide whether a Lua table is an array
or a map, this would fail with empty tables. Also, there are not many
@@ -350,6 +350,10 @@ The ``mp`` module is preloaded, although it can be loaded manually with
with ``add_timeout()``), this starts the timer from the beginning,
using the initially configured timeout.
``is_enabled()``
Whether the timer is currently enabled or was previously disabled
(e.g. by ``stop()`` or ``kill()``).
``timeout`` (RW)
This field contains the current timeout period. This value is not
updated as time progresses. It's only used to calculate when the
@@ -454,9 +458,9 @@ are useful only in special situations.
The level is a string, see ``msg.log`` for allowed log levels.
``mp.register_script_message(name, fn)``
This is a helper to dispatch ``script_message`` or ``script_message_to``
invocations to Lua functions. ``fn`` is called if ``script_message`` or
``script_message_to`` (with this script as destination) is run
This is a helper to dispatch ``script-message`` or ``script-message-to``
invocations to Lua functions. ``fn`` is called if ``script-message`` or
``script-message-to`` (with this script as destination) is run
with ``name`` as first parameter. The other parameters are passed to ``fn``.
If a message with the given name is already registered, it's overwritten.
+15 -1
View File
@@ -320,11 +320,22 @@ example, paths starting with ``-`` will be interpreted as options. Likewise,
if a path contains the sequence ``://``, the string before that might be
interpreted as protocol prefix, even though ``://`` can be part of a legal
UNIX path. To avoid problems with arbitrary paths, you should be sure that
absolute paths passed to mpv start with ``/``, and relative paths with ``./``.
absolute paths passed to mpv start with ``/``, and prefix relative paths with
``./``.
Using the ``file://`` pseudo-protocol is discouraged, because it involves
strange URL unescaping rules.
The name ``-`` itself is interpreted as stdin, and will cause mpv to disable
console controls. (Which makes it suitable for playing data piped to stdin.)
The special argument ``--`` can be used to stop mpv from interpreting the
following arguments as options.
When using the client API, you should strictly avoid using ``mpv_command_string``
for invoking the ``loadfile`` command, and instead prefer e.g. ``mpv_command``
to avoid the need for filename escaping.
For paths passed to suboptions, the situation is further complicated by the
need to escape special characters. To work this around, the path can be
additionally wrapped in the fixed-length syntax, e.g. ``%n%string_of_length_n``
@@ -715,6 +726,9 @@ PROTOCOLS
``memory://data``
Use the ``data`` part as source data.
``hex://data``
Like ``memory://``, but the string is interpreted as hexdump.
PSEUDO GUI MODE
===============
+125 -41
View File
@@ -261,8 +261,13 @@ Playback Control
``--ab-loop-a=<time>``, ``--ab-loop-b=<time>``
Set loop points. If playback passes the ``b`` timestamp, it will seek to
the ``a`` timestamp. Seeking past the ``b`` point doesn't loop (this is
intentional). The loop-points can be adjusted at runtime with the
corresponding properties. See also ``ab_loop`` command.
intentional).
If both options are set to ``no``, looping is disabled. Otherwise, the
start/end of the file is used if one of the options is set to ``no``.
The loop-points can be adjusted at runtime with the corresponding
properties. See also ``ab-loop`` command.
``--ordered-chapters``, ``--no-ordered-chapters``
Enabled by default.
@@ -576,6 +581,7 @@ Video
:no: always use software decoding (default)
:auto: see below
:auto-copy: see below
:vdpau: requires ``--vo=vdpau`` or ``--vo=opengl`` (Linux only)
:vaapi: requires ``--vo=opengl`` or ``--vo=vaapi`` (Linux only)
:vaapi-copy: copies video back into system RAM (Linux with Intel GPUs only)
@@ -583,7 +589,9 @@ Video
:dxva2: requires ``--vo=opengl:backend=angle`` or
``--vo=opengl:backend=dxinterop`` (Windows only)
:dxva2-copy: copies video back to system RAM (Windows only)
:d3d11va-copy: experimental (Windows only)
:d3d11va: requires ``--vo=opengl:backend=angle`` (Windows only)
:d3d11va-copy: copies video back to system RAM (Windows only)
:mediacodec: copies video back to system RAM (Android only)
:rpi: requires ``--vo=rpi`` (Raspberry Pi only - default if available)
``auto`` tries to automatically enable hardware decoding using the first
@@ -593,6 +601,13 @@ Video
work, it will always fall back to software decoding, instead of trying the
next method (might matter on some Linux systems).
``auto-copy`` selects only modes that copy the video data back to system
memory after decoding. Currently, this selects only one of the following
modes: ``vaapi-copy``, ``dxva2-copy``, ``d3d11va-copy``, ``mediacodec``.
If none of these work, hardware decoding is disabled. This mode is always
guaranteed to incur no additional loss compared to software decoding, and
will allow CPU processing with video filters.
The ``vaapi`` mode, if used with ``--vo=opengl``, requires Mesa 11 and most
likely works with Intel GPUs only. It also requires the opengl EGL backend
(automatically used if available). You can also try the old GLX backend by
@@ -614,6 +629,46 @@ Video
codecs. See ``--hwdec-codecs`` to enable hardware decoding for more
codecs.
.. admonition:: Quality reduction with hardware decoding
Normally, hardware decoding does not reduce video quality (at least for
the codecs h264 and HEVC). However, due to restrictions in video output
APIs, there can be some loss, or blatantly incorrect results.
In some cases, RGB conversion is forced, which means the RGB conversion
is performed by the hardware decoding API, instead of the OpenGL code
used by ``--vo=opengl``. This means certain obscure colorspaces may
not display correctly, not certain filtering (such as debanding)
cannot be applied in an ideal way.
``vdpau`` is usually safe. If deinterlacing enabled (or the ``vdpaupp``
video filter is active in general), it forces RGB conversion. The latter
currently does not treat certain colorspaces like BT.2020 correctly
(which is mostly a mpv-specific restriction). The ``vdpauprb`` video
filter retrieves image data without RGB conversion and is safe (but
precludes use of vdpau postprocessing).
``vaapi`` is safe if the ``vaapi-egl`` backend is indicated in the logs.
If ``vaapi-glx`` is indicated, and the video colorspace is either BT.601
or BT.709, a forced but correct RGB conversion is performed. Otherwise,
the result will be incorrect.
``d3d11va`` is usually safe (if used with ANGLE builds that support
``EGL_KHR_stream path`` - otherwise, it converts to RGB), except that
10 bit input (HEVC main 10 profiles) will be rounded down to 8 bits.
``dxva2`` is not safe. It appears to always use BT.601 for forced RGB
conversion, but actual behavior depends on the GPU drivers. Some drivers
appear to convert to limited range RGB, which gives a faded appearance.
In addition to driver-specific behavior, global system settings might
affect this additionally. This can give incorrect results even with
completely ordinary video sources.
All other methods, in particular the copy-back methods (like
``dxva2-copy`` etc.) are either fully safe, or not worse than software
decoding. In particular, ``auto-copy`` will only select safe modes
(although potentially slower than other methods).
``--hwdec-preload=<api>``
This is useful for the ``opengl`` and ``opengl-cb`` VOs for creating the
hardware decoding OpenGL interop context, but without actually enabling
@@ -1017,14 +1072,10 @@ Audio
``--volume=<value>``
Set the startup volume. 0 means silence, 100 means no volume reduction or
amplification. A value of -1 (the default) will not change the volume. See
also ``--softvol``.
amplification. Negative values can be passed for compatibility, but are
treated as 0.
.. note::
This was changed after the mpv 0.9 release. Before that, 100 actually
meant maximum volume. At the same time, the volume scale was made cubic,
so the old values won't match up with the new ones anyway.
Since mpv 0.18.1, this always controls the internal mixer (aka "softvol").
``--audio-delay=<sec>``
Audio delay in seconds (positive or negative float value). Positive values
@@ -1039,20 +1090,17 @@ Audio
See also: ``--volume``.
``--softvol=<mode>``
Control whether to use the volume controls of the audio output driver or
the internal mpv volume filter.
``--softvol=<no|yes|auto>``
Deprecated/unfunctional. Before mpv 0.18.1, this used to control whether
to use the volume controls of the audio output driver or the internal mpv
volume filter.
:no: prefer audio driver controls, use the volume filter only if
absolutely needed
:yes: always use the volume filter
:auto: prefer the volume filter if the audio driver uses the system mixer
(default)
The current behavior is as if this option was set to ``yes``. The other
behaviors are not available anymore, although ``auto`` almost matches
current behavior in most cases.
The intention of ``auto`` is to avoid changing system mixer settings from
within mpv with default settings. mpv is a video player, not a mixer panel.
On the other hand, mixer controls are enabled for sound servers like
PulseAudio, which provide per-application volume.
The ``no`` behavior is still partially available through the ``ao-volume``
and ``ao-mute`` properties. But there are no options to reset these.
``--audio-demuxer=<[+]name>``
Use this audio demuxer type when using ``--audio-file``. Use a '+' before
@@ -1209,10 +1257,12 @@ Audio
their start timestamps differ, and then video timing is gradually adjusted
if necessary to reach correct synchronization later.
``--softvol-max=<100.0-1000.0>``
``--volume-max=<100.0-1000.0>``, ``--softvol-max=<...>``
Set the maximum amplification level in percent (default: 130). A value of
130 will allow you to adjust the volume up to about double the normal level.
``--softvol-max`` is a deprecated alias and should not be used.
``--audio-file-auto=<no|exact|fuzzy|all>``, ``--no-audio-file-auto``
Load additional audio files matching the video filename. The parameter
specifies how external audio files are matched. ``exact`` is enabled by
@@ -1221,7 +1271,7 @@ Audio
:no: Don't automatically load external audio files.
:exact: Load the media filename with audio file extension (default).
:fuzzy: Load all audio files containing media filename.
:all: Load all aufio files in the current and ``--audio-file-paths``
:all: Load all audio files in the current and ``--audio-file-paths``
directories.
``--audio-file-paths=<path1:path2:...>``
@@ -1265,7 +1315,7 @@ Subtitles
.. note::
Changing styling and position does not work with all subtitles. Image-based
subtitles (DVD, Bluray/PGS, DVB) can not changed for fundamental reasons.
subtitles (DVD, Bluray/PGS, DVB) cannot changed for fundamental reasons.
Subtitles in ASS format are normally not changed intentionally, but
overriding them can be controlled with ``--ass-style-override``.
@@ -1423,7 +1473,7 @@ Subtitles
Using this option may lead to incorrect subtitle rendering.
``--ass-style-override=<yes|no|force>``
``--ass-style-override=<yes|no|force|signfs|strip>``
Control whether user style overrides should be applied.
:yes: Apply all the ``--ass-*`` style override options. Changing the default
@@ -1433,6 +1483,8 @@ Subtitles
:no: Render subtitles as forced by subtitle scripts.
:force: Try to force the font style as defined by the ``--sub-text-*``
options. Can break rendering easily.
:strip: Radically strip all ASS tags and styles from the subtitle. This
is equivalent to the old ``--no-ass`` / ``--no-sub-ass`` options.
``--ass-force-margins``
Enables placing toptitles and subtitles in black borders when they are
@@ -1529,6 +1581,13 @@ Subtitles
``--sub-ass``, ``--no-sub-ass``
Render ASS subtitles natively (enabled by default).
.. note::
This has been deprecated by ``--ass-style-override=strip``. You also
may need ``--embeddedfonts=no`` to get the same behavior. Also,
using ``--ass-style-override=force`` should give better results
without breaking subtitles too much.
If ``--no-sub-ass`` is specified, all tags and style declarations are
stripped and ignored on display. The subtitle renderer uses the font style
as specified by the ``--sub-text-`` options instead.
@@ -1539,10 +1598,6 @@ Subtitles
rendering of ASS/SSA subtitles. It can sometimes be useful to forcibly
override the styling of ASS subtitles, but should be avoided in general.
.. note::
Try using ``--ass-style-override=force`` instead.
``--sub-auto=<no|exact|fuzzy|all>``, ``--no-sub-auto``
Load additional subtitle files matching the video filename. The parameter
specifies how external subtitle files are matched. ``exact`` is enabled by
@@ -1783,6 +1838,12 @@ Window
mode can be used to create the window always on program start, but this
may cause other issues.
``--taskbar-progress``, ``--no-taskbar-progress``
(Windows only)
Enable/disable playback progress rendering in taskbar (Windows 7 and above).
Enabled by default.
``--ontop``
Makes the player window stay on top of other windows.
@@ -1794,6 +1855,12 @@ Window
Play video with window border and decorations. Since this is on by
default, use ``--no-border`` to disable the standard window decorations.
``--fit-border``, ``--no-fit-border``
(Windows only) Fit the whole window with border and decorations on the
screen. Since this is on by default, use ``--no-fit-border`` to make mpv
try to only fit client area with video on the screen. This behavior only
applied to window/video with size exceeding size of the screen.
``--on-all-workspaces``
(X11 only)
Show the video window on all virtual desktops.
@@ -1885,7 +1952,7 @@ Window
Make the window width 70% of the screen size, keeping aspect ratio.
``1000``
Set the window width to 1000 pixels, keeping aspect ratio.
``70%:60%``
``70%x60%``
Make the window as large as possible, without being wider than 70%
of the screen width, or higher than 60% of the screen height.
@@ -1947,6 +2014,14 @@ Window
be the default behavior. Currently only affects X11 VOs.
``--heartbeat-cmd=<command>``
.. warning::
This option is redundant with Lua scripting. Further, it shouldn't be
needed for disabling screensaver anyway, since mpv will call
``xdg-screensaver`` when using X11 backend. As a consequence this
option has been deprecated with no direct replacement.
Command that is executed every 30 seconds during playback via *system()* -
i.e. using the shell. The time between the commands can be customized with
the ``--heartbeat-interval`` option. The command is not run while playback
@@ -1972,7 +2047,7 @@ Window
.. admonition:: Example for GNOME screensaver
``mpv --heartbeat-cmd="gnome-screensaver-command -p" file``
``mpv --heartbeat-cmd="gnome-screensaver-command --deactivate" file``
``--heartbeat-interval=<sec>``
@@ -2068,9 +2143,17 @@ Window
This option might be removed in the future.
``--x11-bypass-compositor=<yes|no>``
``--x11-bypass-compositor=<yes|no|fs-only|never>``
If set to ``yes``, then ask the compositor to unredirect the mpv window
(default: no). This uses the ``_NET_WM_BYPASS_COMPOSITOR`` hint.
(default: ``fs-only``). This uses the ``_NET_WM_BYPASS_COMPOSITOR`` hint.
``fs-only`` asks the window manager to disable the compositor only in
fullscreen mode.
``no`` sets ``_NET_WM_BYPASS_COMPOSITOR`` to 0, which is the default value
as declared by the EWMH specification, i.e. no change is done.
``never`` asks the window manager to never disable the compositor.
Disc Devices
@@ -2358,7 +2441,7 @@ Demuxer
stop reading additional packets as soon as one of the limits is reached.
(The limits still can be slightly overstepped due to technical reasons.)
Set these limits highher if you get a packet queue overflow warning, and
Set these limits higher if you get a packet queue overflow warning, and
you think normal playback would be possible with a larger packet queue.
See ``--list-options`` for defaults and value range.
@@ -2383,7 +2466,7 @@ Demuxer
``--force-seekable=<yes|no>``
If the player thinks that the media is not seekable (e.g. playing from a
pipe, or it's a http stream with a server that doesn't support range
pipe, or it's an http stream with a server that doesn't support range
requests), seeking will be disabled. This option can forcibly enable it.
For seeks within the cache, there's a good chance of success.
@@ -3210,7 +3293,7 @@ Cache
With ``auto``, the cache will usually be enabled for network streams,
using the size set by ``--cache-default``. With ``yes``, the cache will
always be enabled with the size set by ``--cache-default`` (unless the
stream can not be cached, or ``--cache-default`` disables caching).
stream cannot be cached, or ``--cache-default`` disables caching).
May be useful when playing files from slow media, but can also have
negative effects, especially with file formats that require a lot of
@@ -3524,7 +3607,7 @@ Miscellaneous
frame dropping due to the audio "overshooting" and skipping multiple video
frames before the sync logic can react.
``--video-sync-adrop-size=<value``
``--video-sync-adrop-size=<value>``
For the ``--video-sync=display-adrop`` mode. This mode duplicates/drops
audio data to keep audio in sync with video. To avoid audio artifacts on
jitter (which would add/remove samples all the time), this is done in
@@ -3597,7 +3680,7 @@ Miscellaneous
- A label of the form ``aidN`` selects audio track N as input (e.g.
``aid1``).
- A label of the form ``vidN`` selects video track N as input.
- A label named ``ao`` will be connected to the audio input.
- A label named ``ao`` will be connected to the audio output.
- A label named ``vo`` will be connected to the video output.
Each label can be used only once. If you want to use e.g. an audio stream
@@ -3605,7 +3688,7 @@ Miscellaneous
video or audio outputs are not possible, but you can use filters to merge
them into one.
The complex filter can not be changed yet during playback. It's also not
The complex filter cannot be changed yet during playback. It's also not
possible to change the tracks connected to the filter at runtime. Other
tracks, as long as they're not connected to the filter, and the
corresponding output is not connected to the filter, can still be freely
@@ -3634,4 +3717,5 @@ Miscellaneous
- ``null:// --lavfi-complex='life [vo]'``
Conways' Life Game.
See the FFmpeg libavfilter documentation for details on the filter.
See the FFmpeg libavfilter documentation for details on the available
filters.
+2 -2
View File
@@ -266,6 +266,6 @@ Example
You could put this into ``input.conf`` to hide the OSC with the ``a`` key and
to set auto mode (the default) with ``b``::
a script_message osc-visibility never
b script_message osc-visibility auto
a script-message osc-visibility never
b script-message osc-visibility auto
+24 -2
View File
@@ -214,7 +214,7 @@ Available filters are:
Format name, e.g. rgb15, bgr24, 420p, etc. (default: don't change).
``<outfmt>``
Format name that should be substituted for the output. If they do not
have the same bytes per pixel and chroma subsamplimg, it will fail.
have the same bytes per pixel and chroma subsampling, it will fail.
``<colormatrix>``
Controls the YUV to RGB color space conversion when playing video. There
are various standards. Normally, BT.601 should be used for SD video, and
@@ -288,6 +288,8 @@ Available filters are:
:adobe: Adobe RGB (1998)
:prophoto: ProPhoto RGB (ROMM)
:cie1931: CIE 1931 RGB
:dci-p3: DCI-P3 (Digital Cinema)
:v-gamut: Panasonic V-Gamut primaries
``<gamma>``
Gamma function the source file was encoded with. Normally this should be set
@@ -303,13 +305,24 @@ Available filters are:
Available gamma functions are:
:auto: automatic selection (default)
:bt.1886: ITU-R BT.1886 (approximation of BT.601/BT.709/BT.2020 curve)
:bt.1886: ITU-R BT.1886 (EOTF corresponding to BT.601/BT.709/BT.2020)
:srgb: IEC 61966-2-4 (sRGB)
:linear: Linear light
:gamma1.8: Pure power curve (gamma 1.8)
:gamma2.2: Pure power curve (gamma 2.2)
:gamma2.8: Pure power curve (gamma 2.8)
:prophoto: ProPhoto RGB (ROMM) curve
:st2084: SMPTE ST2084 (HDR) curve
:std-b67: ARIB STD-B67 (Hybrid Log-gamma) curve
:v-log: Panasonic V-Log transfer curve
``<peak>``
Reference peak illumination for the video file. This is mostly
interesting for HDR, but it can also be used tone map SDR content
to a darker or brighter exposure.
The default of 0.0 will default to the display's reference brightness
for SDR and the source's reference brightness for HDR.
``<stereo-in>``
Set the stereo mode the video is assumed to be encoded in. Takes the
@@ -800,6 +813,15 @@ Available filters are:
This filter must be specified before ``vdpaupp`` in the filter chain if
``vdpaupp`` is used.
``d3d11vpp``
Direct3D 11 video post processing. Currently requires D3D11 hardware
decoding for use.
``deint=<yes|no>``
Whether deinterlacing is enabled (default: no).
``interlaced-only=<yes|no>``
If ``yes`` (default), only deinterlace frames marked as interlaced.
``buffer=<num>``
Buffer ``<num>`` frames in the filter chain. This filter is probably pretty
useless, except for debugging. (Note that this won't help to smooth out
+227 -72
View File
@@ -465,7 +465,7 @@ Available video output drivers are:
8
Dither to 8 bit output.
Note that the depth of the connected video display device can not be
Note that the depth of the connected video display device cannot be
detected. Often, LCD panels will do dithering on their own, which
conflicts with ``opengl``'s dithering and leads to ugly output.
@@ -582,68 +582,6 @@ Available video output drivers are:
better than without it) since it will extend the size to match only the
milder of the scale factors between the axes.
``prescale-luma=<filter>``
Apply additional pre-scaling (image doubling) on the luma plane
(if present). As the name implies, these will run before the main
upscaling pass.
``none``
Disable all prescalers. This is the default.
``superxbr``
A relatively fast prescaler originally developed for pixel art.
Some parameters can be tuned with ``superxbr-sharpness`` and
``superxbr-edge-strength`` options.
``nnedi3``
An artificial neural network based deinterlacer, which can be used
to upscale images.
Extremely slow and requires a recent mid or high end graphics card
to work smoothly (as of 2015).
``prescale-passes=<1..5>``
The number of passes to apply the prescaler (defaults to be 1). Setting
it to 2 will perform a 4x upscaling.
``prescale-downscaling-threshold=<0..32>``
This option prevents "overkill" use of prescalers, which can be caused
by misconfiguration, or user trying to play a video with much larger
size. With this option, user can specify the maximal allowed downscaling
ratio in both dimension. To satisfy it, the number of passes for
prescaler will be reduced, and if necessary prescaler could also be
disabled.
The default value is 2.0, and should be able to prevent most seemingly
unreasonable use of prescalers. Most user would probably want to set it
to a smaller value between 1.0 and 1.5 for better performance.
A value less than 1.0 will disable the check.
``nnedi3-neurons=<16|32|64|128>``
Specify the neurons for nnedi3 prescaling (defaults to be 32). The
rendering time is expected to be linear to the number of neurons.
``nnedi3-window=<8x4|8x6>``
Specify the size of local window for sampling in nnedi3 prescaling
(defaults to be ``8x4``). The ``8x6`` window produces sharper images,
but is also slower.
``nnedi3-upload=<ubo|shader>``
Specify how to upload the NN weights to GPU. Depending on the graphics
card, driver, shader compiler and nnedi3 settings, both method can be
faster or slower.
``ubo``
Upload these weights via uniform buffer objects. This is the
default. (requires OpenGL 3.1 / GLES 3.0)
``shader``
Hard code all the weights into the shader source code. (requires
OpenGL 3.3 / GLES 3.0)
``pre-shaders=<files>``, ``post-shaders=<files>``, ``scale-shader=<file>``
Custom GLSL fragment shaders.
@@ -691,6 +629,9 @@ Available video output drivers are:
never resets (regardless of seeks).
vec2 image_size
The size in pixels of the input image.
vec2 target_size
The size in pixels of the visible part of the scaled (and possibly
cropped) image.
For example, a shader that inverts the colors could look like this::
@@ -700,6 +641,152 @@ Available video output drivers are:
return vec4(1.0 - color.rgb, color.a);
}
``user-shaders=<files>``
Custom GLSL hooks. These are similar to ``post-shaders`` etc., but more
flexible: They can be injected at almost arbitrary points in the
rendering pipeline, and access all previous intermediate textures.
.. admonition:: Warning
The syntax is not stable yet and may change any time.
The general syntax of a user shader looks like this::
//!METADATA ARGS...
//!METADATA ARGS...
vec4 hook() {
...
return something;
}
//!METADATA ARGS...
//!METADATA ARGS...
...
Each block of metadata, along with the non-metadata lines after it,
defines a single pass. Each pass can set the following metadata:
HOOK <name> (required)
The texture which to hook into. May occur multiple times within a
metadata block, up to a predetermined limit. See below for a list
of hookable textures.
BIND <name>
Loads a texture and makes it available to the pass, and sets up
macros to enable accessing it. See below for a list of set macros.
By default, no textures are bound. The special name HOOKED can be
used to refer to the texture that triggered this pass.
SAVE <name>
Gives the name of the texture to save the result of this pass
into. By default, this is set to the special name HOOKED which has
the effect of overwriting the hooked texture.
WIDTH <szexpr>, HEIGHT <szexpr>
Specifies the size of the resulting texture for this pass.
``szexpr`` refers to an expression in RPN (reverse polish
notation), using the operators + - * / > < !, floating point
literals, and references to sizes of existing texture and OUTPUT
(such as MAIN.width or CHROMA.height). By default, these are set to
HOOKED.w and HOOKED.h, respectively.
WHEN <szexpr>
Specifies a condition that needs to be true (non-zero) for the
shader stage to be evaluated. If it fails, it will silently be
omitted. (Note that a shader stage like this which has a dependency
on an optional hook point can still cause that hook point to be
saved, which has some minor overhead)
OFFSET ox oy
Indicates a pixel shift (offset) introduced by this pass. These
pixel offsets will be accumulated and corrected during the
next scaling pass (``cscale`` or ``scale``). The default values
are 0 0 which correspond to no shift. Note that offsets are ignored
when not overwriting the hooked texture.
COMPONENTS n
Specifies how many components of this pass's output are relevant
and should be stored in the texture, up to 4 (rgba). By default,
this value is equal to the number of components in HOOKED.
Each bound texture (via ``BIND``) will make available the following
definitions to that shader pass, where NAME is the name of the bound
texture:
vec4 NAME_tex(vec2 pos)
The sampling function to use to access the texture at a certain
spot (in texture coordinate space, range [0,1]). This takes care
of any necessary normalization conversions.
vec4 NAME_texOff(vec2 offset)
Sample the texture at a certain offset in pixels. This works like
NAME_tex but additionally takes care of necessary rotations, so
that sampling at e.g. vec2(-1,0) is always one pixel to the left.
vec2 NAME_pos
The local texture coordinate of that texture, range [0,1].
vec2 NAME_size
The (rotated) size in pixels of the texture.
mat2 NAME_rot
The rotation matrix associated with this texture. (Rotates
pixel space to texture coordinates)
vec2 NAME_pt
The (unrotated) size of a single pixel, range [0,1].
sampler NAME_raw
The raw bound texture itself. The use of this should be
avoided unless absolutely necessary.
In addition, the global uniforms described in ``post-shaders`` are
also available.
Internally, vo_opengl may generate any number of the following
textures. Whenever a texture is rendered and saved by vo_opengl, all of
the passes that have hooked into it will run, in the order they were
added by the user. This is a list of the legal hook points:
RGB, LUMA, CHROMA, ALPHA, XYZ (resizable)
Source planes (raw). Which of these fire depends on the image
format of the source.
CHROMA_SCALED, ALPHA_SCALED (fixed)
Source planes (upscaled). These only fire on subsampled content.
NATIVE (resizable)
The combined image, in the source colorspace, before conversion
to RGB.
MAINPRESUB (resizable)
The image, after conversion to RGB, but before
``blend-subtitles=video`` is applied.
MAIN (resizable)
The main image, after conversion to RGB but before upscaling.
LINEAR (fixed)
Linear light image, before scaling. This only fires when
``linear-scaling`` is in effect.
SIGMOID (fixed)
Sigmoidized light, before scaling. This only fires when
``sigmoid-upscaling`` is in effect.
PREKERNEL (fixed)
The image immediately before the scaler kernel runs.
POSTKERNEL (fixed)
The image immediately after the scaler kernel runs.
SCALED (fixed)
The final upscaled image, before color management.
OUTPUT (fixed)
The final output image, after color management but before
dithering and drawing to screen.
Only the textures labelled with ``resizable`` may be transformed by the
pass. When overwriting a texture marked ``fixed``, the WIDTH, HEIGHT
and OFFSET must be left at their default values.
``deband``
Enable the debanding algorithm. This greatly reduces the amount of
visible banding, blocking and other quantization artifacts, at the
@@ -807,8 +894,8 @@ Available video output drivers are:
Win32/WGL
angle
Direct3D11 through the OpenGL ES translation layer ANGLE. This
supports almost everything the ``win`` backend does, except ICC
profiles, and the ``nnedi3`` prescaler.
supports almost everything the ``win`` backend does (if the ANGLE
build is new enough).
dxinterop (experimental)
Win32, using WGL for rendering and Direct3D 9Ex for presentation.
Works on Nvidia and AMD. Newer Intel chips with the latest drivers
@@ -835,10 +922,11 @@ Available video output drivers are:
``fbo-format=<fmt>``
Selects the internal format of textures used for FBOs. The format can
influence performance and quality of the video output.
``fmt`` can be one of: rgb, rgba, rgb8, rgb10, rgb10_a2, rgb16, rgb16f,
``fmt`` can be one of: rgb8, rgb10, rgb10_a2, rgb16, rgb16f,
rgb32f, rgba12, rgba16, rgba16f, rgba32f.
Default: ``auto``, which maps to rgba16 on desktop GL, and rgba16f or
rgb10_a2 on GLES (e.g. ANGLE).
rgb10_a2 on GLES (e.g. ANGLE), unless GL_EXT_texture_norm16 is
available.
``gamma=<0.1..2.0>``
Set a gamma value (default: 1.0). If gamma is adjusted in other ways
@@ -854,6 +942,10 @@ Available video output drivers are:
0.8
Pitch black room
NOTE: Typical movie content (Blu-ray etc.) already contains a gamma
drop of about 0.8, so specifying it here as well will result in even
even darker image than intended!
``gamma-auto``
Automatically corrects the gamma value depending on ambient lighting
conditions (adding a gamma boost for dark rooms).
@@ -864,8 +956,9 @@ Available video output drivers are:
NOTE: Only implemented on OS X.
``target-prim=<value>``
Specifies the primaries of the display. Video colors will be adapted
to this colorspace if necessary. Valid values are:
Specifies the primaries of the display. Video colors will be adapted to
this colorspace when ICC color management is not being used. Valid
values are:
auto
Disable any adaptation (default)
@@ -889,15 +982,18 @@ Available video output drivers are:
CIE 1931 RGB (not to be confused with CIE XYZ)
dci-p3
DCI-P3 (Digital Cinema Colorspace), SMPTE RP431-2
v-gamut
Panasonic V-Gamut (VARICAM) primaries
``target-trc=<value>``
Specifies the transfer characteristics (gamma) of the display. Video
colors will be adjusted to this curve. Valid values are:
colors will be adjusted to this curve when ICC color management is
not being used. Valid values are:
auto
Disable any adaptation (default)
bt.1886
ITU-R BT.1886 curve, without the brightness drop (approx. 1.961)
ITU-R BT.1886 curve (assuming infinite contrast)
srgb
IEC 61966-2-4 (sRGB)
linear
@@ -910,9 +1006,61 @@ Available video output drivers are:
Pure power curve (gamma 2.8), also used for BT.470-BG
prophoto
ProPhoto RGB (ROMM)
st2084
SMPTE ST2084 (HDR) curve, PQ OETF
std-b67
ARIB STD-B67 (Hybrid Log-gamma) curve, also known as BBC/NHK HDR
v-log
Panasonic V-Log (VARICAM) curve
NOTE: When using HDR output formats, mpv will encode to the specified
curve but it will not set any HDMI flags or other signalling that
might be required for the target device to correctly display the
HDR signal. The user should independently guarantee this before
using these signal formats for display.
``target-brightness=<1..100000>``
Specifies the display's approximate brightness in cd/m^2. When playing
HDR content on a SDR display (or SDR content on an HDR display), video
colors will be tone mapped to this target brightness using the
algorithm specified by ``hdr-tone-mapping``. The default of 250 cd/m^2
corresponds to a typical consumer display.
``hdr-tone-mapping=<value>``
Specifies the algorithm used for tone-mapping HDR images onto the
target display. Valid values are:
clip
Hard-clip any out-of-range values.
reinhard
Reinhard tone mapping algorithm. Very simple continuous curve.
Preserves dynamic range and peak but uses nonlinear contrast.
hable
Similar to ``reinhard`` but preserves dark contrast better
(slightly sigmoidal). Developed by John Hable for use in video
games. (default)
gamma
Fits a logarithmic transfer between the tone curves.
linear
Linearly stretches the entire reference gamut to (a linear multiple
of) the display.
``tone-mapping-param=<value>``
Set tone mapping parameters. Ignored if the tone mapping algorithm is
not tunable. This affects the following tone mapping algorithms:
reinhard
Specifies the local contrast coefficient at the display peak.
Defaults to 0.5, which means that in-gamut values will be about
half as bright as when clipping.
gamma
Specifies the exponent of the function. Defaults to 1.8.
linear
Specifies the scale factor to use while stretching. Defaults to
1.0.
``icc-profile=<file>``
Load an ICC profile and use it to transform linear RGB to screen output.
Load an ICC profile and use it to transform video RGB to screen output.
Needs LittleCMS 2 support compiled in. This option overrides the
``target-prim``, ``target-trc`` and ``icc-profile-auto`` options.
@@ -950,6 +1098,13 @@ Available video output drivers are:
Default is 128x256x64.
Sizes must be a power of two, and 512 at most.
``icc-contrast=<0-100000>``
Specifies an upper limit on the target device's contrast ratio.
This is detected automatically from the profile if possible, but for
some profiles it might be missing, causing the contrast to be assumed
as infinite. As a result, video may appear darker than intended. This
only affects BT.1886 content. The default of 0 means no limit.
``blend-subtitles=<yes|video|no>``
Blend subtitles directly onto upscaled video frames, before
interpolation and/or color management (default: no). Enabling this
+2 -1
View File
@@ -79,7 +79,8 @@ Video
using most of FFmpeg's filters, which improve greatly on the old MPlayer
filters in features, performance, and correctness.
* More correct color reproduction (color matrix generation), including support
for BT.2020 (Ultra HD) and linear XYZ (Digital Cinema) inputs.
for BT.2020 (Ultra HD). linear XYZ (Digital Cinema) and SMPTE ST2084 (HDR)
inputs.
* Support for color managed displays, via ICC profiles.
* High-quality image resamplers (see the ``opengl`` ``scale`` suboption).
* Support for scaling in (sigmoidized) linear light.
+1 -1
View File
@@ -123,7 +123,7 @@ options/options.h, options/options.c
parser-mpcmd.c, and uses the option table in options.c.
input/input.c:
This translates keyboard input comming from VOs and other sources (such
This translates keyboard input coming from VOs and other sources (such
as remote control devices like Apple IR or client API commands) to the
key bindings listed in the user's (or the builtin) input.conf and turns
them into items of type struct mp_cmd. These commands are queued, and read
+14
View File
@@ -137,6 +137,20 @@ most likely the best maintenance out of all stable releases. Older releases
are for distros, and at best receive basic changes like fixing critical security
issues or build fixes, and at worst are completely abandoned.
## FFmpeg ABI compatibility
mpv does not support linking against FFmpeg versions it was not built with, even
if the linked version is supposedly ABI-compatible with the version it was
compiled against. Expect malfunctions, crashes, and security issues if you
do it anyway.
The reason for not supporting this is because it creates far too much complexity
with little to no benefit, coupled with absurd and unusable FFmpeg API
artifacts.
Newer mpv versions will refuse to start if runtime and compile time FFmpeg
library versions mismatch.
## Release cycle
Every other month, an arbitrary git snapshot is made, and is assigned
+236
View File
@@ -1,3 +1,239 @@
Release 0.18.1
==============
Note: Running mpv with different versions of the FFmpeg/Libav libraries than
it was compiled with is no longer supported. Even supposedly ABI-compatible
versions have been a source of trouble, and it creates far too much
complexity with little to no benefit, coupled with absurd and unusable FFmpeg
API artifacts.
Instead, mpv will exit with an error when such a situation is detected.
This simply means that mpv needs to be rebuilt whenever FFmpeg libraries change.
Features
--------
New
~~~
- d3d: implement screenshots for --hwdec=d3d11va
- vo_opengl: add output_size uniform to custom shader
- vo_opengl: implement the Panasonic V-Log function (#3157)
- vo_opengl: implement ARIB STD-B68 (HLG) HDR TRC
Options and Commands
--------------------
Changed
~~~~~~~
- command: pack sub image data in overlay-add command
Deprecated
~~~~~~~~~~
- options: deprecate --heartbeat-cmd
- audio: deprecate --softvol
Removed
~~~~~~~
- audio: drop --softvol=no and --softvol=auto (#3322)
Fixes and Minor Enhancements
----------------------------
- video: fix deinterlace filter handling on pixel format changes
- x11: silence xdg-screensaver
- vo_opengl: angle: update the swapchain on resize (#3301)
- vo_opengl: error out gracefully when trying to use FBOs without FBO API
- vd_lavc: expose mastering display side data reference peak (improves results with HDR content)
- vo_opengl: generalize HDR tone mapping mechanism (#3293)
- vo_opengl: don't constantly resize the output FBO
- vo_opengl: use ringbuffer of PBOs
- Windows: make WM_NCHITTEST simpler and more accurate
- ao_oss: do not add an entry to audio-device-list if device file missing
- dec_audio: fix segment boudnary switching
- ao_lavc, vo_lavc: Migrate to new FFmpeg encoding API
- vo_opengl: explicitly use main framebuffer when reading window content (#3284)
- vo_xv: fix behavior with odd sizes
- audio: insert auto-inserted filters at end of chain
- x11: add missing FocusChangeMask (disables key repeat when losing focus while a key is down)
- ao_coreaudio: error out when selecting invalid device
- ad_lavc: work around misbehavior of some FFmpeg decoders like wmapro (#3297)
- player: cut off status line on terminal width
This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API, and DOCS/interface-changes.rst for a history
of changes to other user-visible interfaces.
A complete changelog can be seen by running `git log v0.18.0..v0.18.1`
in the git repository or by visiting either
https://github.com/mpv-player/mpv/compare/v0.18.0...v0.18.1 or
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.18.0..v0.18.1
Release 0.18.0
==============
Build System Changes
--------------------
- build: Do not link to libGL for egl-drm
- build: also use the iconv check on FreeBSD
- build: don't install tests, only build them
- build: re-enable encoding mode by default
- vo_opengl: hwdec: remove build-dependency on dxva2 (#3150)
- wscript: make at least 1 OpenGL output mandatory
Features
--------
New
~~~
- csputils: add SMPTE ST2084 support
- demux_mkv: support Matroska webvtt (#3247)
- demux_playlist: read directories recursively
- stream_memory: add hex:// protocol
- vf_crop: support opaque hardware decoding formats
- vf_d3d11vpp: add a D3D11 video processor filter
- vo_opengl: D3D11VA + ANGLE interop
- vo_opengl: add an angle-es2 backend
- vo_opengl: angle: dynamically load ANGLE
- vo_opengl: d3d11egl: native NV12 sampling support
- vo_opengl: enable color management on GLES
- vo_opengl: implement HDR (SMPTE ST2084)
- vo_opengl: implement tone mapping algorithms
- vo_opengl: make PBOs work on GLES 3.x
- vo_opengl: support external user hooks, enhancing the flexibility of user shaders
- vo_opengl: vdpau interop without RGB conversion
- wayland: implement HIDPI support
Removed
~~~~~~~
- vo_opengl: remove nnedi3 prescaler (replaced by user shaders)
- vo_opengl: remove prescaling framework with superxbr prescaler (replaced by user shaders)
Options and Commands
--------------------
Added
~~~~~
- Windows: make taskbar progress indication optional (#2535)
- af_lavcac3enc: make encoder configurable
- command: add playlist-pos-1 property (#2828)
- command: introduce hwdec-current and hwdec-interop properties.
- options: add --fit-border video option (currently Windows only)
- video: add --hwdec=auto-copy mode
- vo_opengl: always autoselect ANGLE as backend if available
- vo_opengl: expose performance timers as properties
- x11: add --x11-bypass-compositor=never
- x11: extend --x11-bypass-compositor with fs-only option (#2582)
Changed
~~~~~~~
- command: allow setting panscan etc. properties if no video is active
- command: don't seek immediately when setting a-b loop while paused
- command: if only ab-loop-b is set, loop from start of file
- options: --geometry: center window position after applying size (#2397)
- player: loop on end of file if ab-loop-b is unset
- sd_add: replace --sub-ass=no with --ass-style-override=strip
Removed
~~~~~~~
- vo_opengl: remove non-working rgb/rgba FBO formats
Fixes and Minor Enhancements
----------------------------
- TOOLS/zsh.pl: add .f4v extension in zsh completions
- TOOLS/zsh.pl: complete --audio-device
- Windows: center window on original window center on resize to fit screen
- Windows: fix size calculations for window resize (#2935)
- Windows: fix wrong behavior with window-scale when window size exceeds screen size
- Windows: make VOCTRL_SET_UNFS_WINDOW_SIZE resize the window around its center (#3164)
- af_lavcac3enc: fix custom bitrates
- ao_alsa: add more workarounds for hardware with broken drivers (e.g. ODROID-C2)
- ao_opensles: remove 32-bit audio formats (not supported by Android)
- cocoa: fix actual display refresh rate retrieval
- cocoa: use displaylink without manually tracking the display id (#2392)
- command: improve playlist* properties change notifications (#3267)
- command: slightly nicer OSD list formatting
- compatibility with recent FFmpeg APIs
- d3d: fix hardware decoding of most MPEG2 things
- d3dva: move Intel_H264_NoFGT_ClearVideo to lower priority (#3059)
- demux_mkv: better resync behavior for broken google-created webms
- demux_mkv: fix seeking with files that miss the first index entry
- demux_playlist: recognize m3u8 as playlist extension (#3154)
- input: fix parsing multiple input command prefixes
- lcms: don't warn/error on 3dlut cache misses
- lcms: improve black point handling (especially BT.1886)
- macOS: handle multiple dropped files on the window (#3076)
- player: always show the first frame in DS mode
- player: assume video forwards timestamps jumps only with some formats (#3027)
- player: do not update OSD all the time when paused
- player: eagerly redraw OSD when seeking with coverart
- player: fix use-after-free with --screenshot-directory (#3049)
- player: force VO reconfig when unselecting video track
- player: really start audio only once video is ready
- sd_lavc: work around bug in older FFmpeg releases (#3109)
- stream_cdda: enable cache by default
- sub: fix --sub-gauss
- vd_lavc: better hwdec wrapper decoder selection
- vo_opengl: EGL: fix hwdec probing
- vo_opengl: angle: avoid fullscreen FBO copy for flipping
- vo_opengl: angle: enable DirectComposition (lowers vsync jitter)
- vo_opengl: angle: prevent DXGI hooking Alt+Enter
- vo_opengl: avoid outputting ultra-wide-gamut by default
- vo_opengl: correctly disable interpolation if tscale can't be used
- vo_opengl: fix bicubic_fast in ES mode
- vo_opengl: fix d3d11 hardware decoding probing on Windows 7
- vo_opengl: improve scale=oversample performance
- vo_opengl: make the screen blue on shader errors
- vo_opengl: partially fix 0bgr format support
- vo_opengl: possibly update icc profile after changing options
- vo_opengl: request core profile on X11/EGL too
- vo_opengl: require at least ES 3.0 for float textures
- vo_opengl: vdpau: fix certain cases of preemption recovery failures
- vo_rpi: attempt to survive display mode changes
- vo_rpi: fix destroying overlays (#3100)
- vo_rpi: wait for vsync with a timeout
- vo_sdl: fix pixel formats.
- vo_xv: Handle incorrect size returned by Xv(Shm)CreateImage (#320)
- wayland: correctly report display refresh rate
- wayland: use the advertised size in fullscreen (#3021, #2657)
- x11: tell GNOME to use dark window decorations
- ytdl_hook: fix brightcove urls
- ytdl_hook: just check if protocol is rtmp (#3090)
- ytdl_hook: support multi-arc subtitles
This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API, and DOCS/interface-changes.rst for a history
of changes to other user-visible interfaces.
A complete changelog can be seen by running `git log v0.17.0..v0.18.0`
in the git repository or by visiting either
https://github.com/mpv-player/mpv/compare/v0.17.0...v0.18.0 or
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.17.0..v0.18.0
Release 0.17.0
==============
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/bash
set -e
export DEST_OS=win32
export CC=gcc
export PKG_CONFIG=/usr/bin/pkg-config
export PERL=/usr/bin/perl
export PYTHON=/usr/bin/python3
"$PYTHON" bootstrap.py
"$PYTHON" waf configure \
--check-c-compiler=gcc \
--disable-cdda \
--enable-egl-angle \
--enable-jpeg \
--enable-lcms2 \
--enable-libarchive \
--enable-libass \
--enable-lua \
--enable-rubberband \
--enable-uchardet
"$PYTHON" waf build
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/bash
set -e
case $MSYSTEM in
MINGW32)
export MINGW_PACKAGE_PREFIX=mingw-w64-i686
;;
MINGW64)
export MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
;;
esac
# Write an empty fonts.conf to speed up fc-cache
export FONTCONFIG_FILE=/dummy-fonts.conf
cat >"$FONTCONFIG_FILE" <<EOF
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig></fontconfig>
EOF
# Install build dependencies for mpv
pacman -S --noconfirm --needed \
$MINGW_PACKAGE_PREFIX-gcc \
$MINGW_PACKAGE_PREFIX-angleproject-git \
$MINGW_PACKAGE_PREFIX-ffmpeg \
$MINGW_PACKAGE_PREFIX-lcms2 \
$MINGW_PACKAGE_PREFIX-libarchive \
$MINGW_PACKAGE_PREFIX-libass \
$MINGW_PACKAGE_PREFIX-libjpeg-turbo \
$MINGW_PACKAGE_PREFIX-lua51 \
$MINGW_PACKAGE_PREFIX-rubberband \
$MINGW_PACKAGE_PREFIX-uchardet-git
# Delete unused packages to reduce space used in the Appveyor cache
pacman -Sc --noconfirm
View File
File renamed without changes.
+23 -7
View File
@@ -36,7 +36,8 @@ chomp $vf_str;
$protos_str = join(' ', @protos);
my $profile_comp = <<'EOS';
my $runtime_completions = <<'EOS';
profile|show-profile)
local -a profiles
local current
for current in "${(@f)$($words[1] --profile=help)}"; do
@@ -63,8 +64,25 @@ my $profile_comp = <<'EOS';
profiles=($profiles 'help[list profiles]')
_values -s , 'profile(s)' $profiles && rc=0
fi
;;
audio-device)
local -a audio_devices
local current
for current in "${(@f)$($words[1] --audio-device=help)}"; do
current=${current//\*/\\\*}
current=${current//\:/\\\:}
current=${current//\[/\\\[}
current=${current//\]/\\\]}
if [[ $current =~ ' '\'([^\']*)\'' \('(.*)'\)' ]]; then
audio_devices=($audio_devices "$match[1][$match[2]]")
fi
done
audio_devices=($audio_devices 'help[list audio devices]')
_values 'audio device' $audio_devices && rc=0
;;
EOS
chomp $profile_comp;
chomp $runtime_completions;
my $tmpl = <<"EOS";
#compdef mpv
@@ -111,9 +129,7 @@ $vf_str
&& rc=0
;;
profile|show-profile)
$profile_comp
;;
$runtime_completions
files)
compset -P '*,'
@@ -126,7 +142,7 @@ $profile_comp
_tags files urls
while _tags; do
_requested files expl 'media file' _files -g \\
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv|wv)(-.)" && rc=0
"*.(#i)(asf|asx|avi|f4v|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv|wv)(-.)" && rc=0
if _requested urls; then
while _next_label urls expl URL; do
_urls "\$expl[@]" && rc=0
@@ -189,7 +205,7 @@ sub parse_main_opts {
}
} elsif ($line =~ /\[file\]/) {
$entry .= '->files';
} elsif ($name =~ /^--(ao|vo|af|vf|profile|show-profile)$/) {
} elsif ($name =~ /^--(ao|vo|af|vf|profile|show-profile|audio-device)$/) {
$entry .= "->$1";
}
push @list, $entry;
+1 -1
View File
@@ -1 +1 @@
0.17.0
0.18.1
+29
View File
@@ -0,0 +1,29 @@
branches:
only:
- master
- appveyor
environment:
matrix:
- MSYSTEM: MINGW64
- MSYSTEM: MINGW32
shallow_clone: true
test: off
install:
# Update core packages
- C:\msys64\usr\bin\pacman -Syyuu --noconfirm
# Update non-core packages
- C:\msys64\usr\bin\pacman -Suu --noconfirm
# Install required MSYS2 packages
- C:\msys64\usr\bin\pacman -S --noconfirm --needed perl python pkg-config
# Now MSYS2 is up to date, do the rest of the install from a bash script
- C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./TOOLS/appveyor-install.sh"
build_script:
- C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./TOOLS/appveyor-build.sh"
on_failure:
- type "%APPVEYOR_BUILD_FOLDER%\build\config.log"
cache:
- C:\msys64\var\cache\pacman\pkg
+10 -2
View File
@@ -257,13 +257,21 @@ void mp_audio_skip_samples(struct mp_audio *data, int samples)
data->pts += samples / (double)data->rate;
}
// Return the timestamp of the sample just after the end of this frame.
double mp_audio_end_pts(struct mp_audio *f)
{
if (f->pts == MP_NOPTS_VALUE || f->rate < 1)
return MP_NOPTS_VALUE;
return f->pts + f->samples / (double)f->rate;
}
// Clip the given frame to the given timestamp range. Adjusts the frame size
// and timestamp.
void mp_audio_clip_timestamps(struct mp_audio *f, double start, double end)
{
if (f->pts == MP_NOPTS_VALUE || f->rate < 1)
double f_end = mp_audio_end_pts(f);
if (f_end == MP_NOPTS_VALUE)
return;
double f_end = f->pts + f->samples / (double)f->rate;
if (end != MP_NOPTS_VALUE) {
if (f_end >= end) {
if (f->pts >= end) {
+1
View File
@@ -73,6 +73,7 @@ void mp_audio_copy(struct mp_audio *dst, int dst_offset,
void mp_audio_copy_attributes(struct mp_audio *dst, struct mp_audio *src);
void mp_audio_skip_samples(struct mp_audio *data, int samples);
void mp_audio_clip_timestamps(struct mp_audio *f, double start, double end);
double mp_audio_end_pts(struct mp_audio *data);
bool mp_audio_is_writeable(struct mp_audio *data);
int mp_audio_make_writeable(struct mp_audio *data);
+13
View File
@@ -45,6 +45,7 @@ struct priv {
uint32_t skip_samples, trim_samples;
bool preroll_done;
double next_pts;
bool needs_reset;
AVRational codec_timebase;
};
@@ -173,6 +174,7 @@ static int control(struct dec_audio *da, int cmd, void *arg)
ctx->trim_samples = 0;
ctx->preroll_done = false;
ctx->next_pts = MP_NOPTS_VALUE;
ctx->needs_reset = false;
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
@@ -184,6 +186,12 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
struct priv *priv = da->priv;
AVCodecContext *avctx = priv->avctx;
// If the decoder discards the timestamp for some reason, we use the
// interpolated PTS. Initialize it so that it works for the initial
// packet as well.
if (mpkt && priv->next_pts == MP_NOPTS_VALUE)
priv->next_pts = mpkt->pts;
int in_len = mpkt ? mpkt->len : 0;
AVPacket pkt;
@@ -192,6 +200,9 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
int got_frame = 0;
av_frame_unref(priv->avframe);
if (priv->needs_reset)
control(da, ADCTRL_RESET, NULL);
#if HAVE_AVCODEC_NEW_CODEC_API
int ret = avcodec_send_packet(avctx, &pkt);
if (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
@@ -200,6 +211,8 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
ret = avcodec_receive_frame(avctx, priv->avframe);
if (ret >= 0)
got_frame = 1;
if (ret == AVERROR_EOF)
priv->needs_reset = true;
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
}
+7
View File
@@ -116,9 +116,16 @@ static int determine_codec_profile(struct dec_audio *da, AVPacket *pkt)
goto done;
}
#if HAVE_AVCODEC_NEW_CODEC_API
if (avcodec_send_packet(ctx, pkt) < 0)
goto done;
if (avcodec_receive_frame(ctx, frame) < 0)
goto done;
#else
int got_frame = 0;
if (avcodec_decode_audio4(ctx, frame, &got_frame, pkt) < 1 || !got_frame)
goto done;
#endif
profile = ctx->profile;
+6 -3
View File
@@ -200,7 +200,9 @@ void audio_work(struct dec_audio *da)
if (da->current_frame)
return;
if (!da->packet && demux_read_packet_async(da->header, &da->packet) == 0) {
if (!da->packet && !da->new_segment &&
demux_read_packet_async(da->header, &da->packet) == 0)
{
da->current_state = DATA_WAIT;
return;
}
@@ -211,6 +213,7 @@ void audio_work(struct dec_audio *da)
da->packet = NULL;
}
bool had_input_packet = !!da->packet;
bool had_packet = da->packet || da->new_segment;
int ret = da->ad_driver->decode_packet(da, da->packet, &da->current_frame);
@@ -233,12 +236,12 @@ void audio_work(struct dec_audio *da)
fix_audio_pts(da);
bool segment_end = true;
bool segment_end = !da->current_frame && !had_input_packet;
if (da->current_frame) {
mp_audio_clip_timestamps(da->current_frame, da->start, da->end);
if (da->current_frame->pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE)
segment_end = da->current_frame->pts >= da->start;
segment_end = da->current_frame->pts >= da->end;
if (da->current_frame->samples == 0) {
talloc_free(da->current_frame);
da->current_frame = NULL;
+4 -35
View File
@@ -210,29 +210,6 @@ static struct af_instance *af_prepend(struct af_stream *s,
return new;
}
/* Create and insert a new filter of type name after the filter in the
argument. This function can be called during runtime, the return
value is the new filter */
static struct af_instance *af_append(struct af_stream *s,
struct af_instance *af,
char *name, char **args)
{
if (!af)
af = s->first;
if (af == s->last)
af = s->last->prev;
// Create the new filter and make sure it is OK
struct af_instance *new = af_create(s, name, args);
if (!new)
return NULL;
// Update pointers
new->prev = af;
new->next = af->next;
af->next = new;
new->next->prev = new;
return new;
}
// Uninit and remove the filter "af"
static void af_remove(struct af_stream *s, struct af_instance *af)
{
@@ -275,6 +252,8 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
while (af) {
char b[128] = {0};
mp_snprintf_cat(b, sizeof(b), " [%s] ", af->info->name);
if (af->label)
mp_snprintf_cat(b, sizeof(b), "\"%s\" ", af->label);
if (af->data)
mp_snprintf_cat(b, sizeof(b), "%s", mp_audio_config_to_str(af->data));
if (af == at)
@@ -287,11 +266,6 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
MP_MSG(s, msg_level, " [ao] %s\n", mp_audio_config_to_str(&s->output));
}
static bool af_is_conversion_filter(struct af_instance *af)
{
return af && strcmp(af->info->name, "lavrresample") == 0;
}
// in is what af can take as input - insert a conversion filter if the actual
// input format doesn't match what af expects.
// Returns:
@@ -557,7 +531,7 @@ void af_destroy(struct af_stream *s)
format of the preferred output respectively. The function is
reentrant i.e. if called with an already initialized stream the
stream will be reinitialized.
If one of the prefered output parameters is 0 the one that needs
If one of the preferred output parameters is 0 the one that needs
no conversion is used (i.e. the output format in the last filter).
The return value is 0 if success and -1 if failure */
int af_init(struct af_stream *s)
@@ -602,12 +576,7 @@ struct af_instance *af_add(struct af_stream *s, char *name, char *label,
if (af_find_by_label(s, label))
return NULL;
struct af_instance *new;
// Insert the filter somewhere nice
if (af_is_conversion_filter(s->first->next))
new = af_append(s, s->first->next, name, args);
else
new = af_prepend(s, s->first->next, name, args);
struct af_instance *new = af_prepend(s, s->last, name, args);
if (!new)
return NULL;
new->label = talloc_strdup(new, label);
+134 -50
View File
@@ -31,9 +31,12 @@
#include <libavutil/bswap.h>
#include <libavutil/mem.h>
#include "config.h"
#include "common/common.h"
#include "af.h"
#include "audio/audio_buffer.h"
#include "audio/chmap_sel.h"
#include "audio/fmt-conversion.h"
@@ -54,13 +57,50 @@ typedef struct af_ac3enc_s {
struct mp_audio *pending; // unconsumed input data
int in_samples; // samples of input per AC3 frame
int out_samples; // upper bound on encoded output per AC3 frame
int in_sampleformat;
int cfg_add_iec61937_header;
int cfg_bit_rate;
int cfg_min_channel_num;
char *cfg_encoder;
} af_ac3enc_t;
// fmt carries the input format. Change it to the best next-possible format
// the encoder likely accepts.
static void select_encode_format(AVCodecContext *c, struct mp_audio *fmt)
{
int formats[AF_FORMAT_COUNT];
af_get_best_sample_formats(fmt->format, formats);
for (int n = 0; formats[n]; n++) {
const enum AVSampleFormat *lf = c->codec->sample_fmts;
for (int i = 0; lf && lf[i] != AV_SAMPLE_FMT_NONE; i++) {
int mpfmt = af_from_avformat(lf[i]);
if (mpfmt && mpfmt == formats[n]) {
mp_audio_set_format(fmt, mpfmt);
goto done_fmt;
}
}
}
done_fmt: ;
int rate =
af_select_best_samplerate(fmt->rate, c->codec->supported_samplerates);
if (rate > 0)
fmt->rate = rate;
struct mp_chmap_sel sel = {0};
const uint64_t *lch = c->codec->channel_layouts;
for (int n = 0; lch && lch[n]; n++) {
struct mp_chmap chmap = {0};
mp_chmap_from_lavc(&chmap, lch[n]);
mp_chmap_sel_add_map(&sel, &chmap);
}
struct mp_chmap res = fmt->channels;
mp_chmap_sel_adjust(&sel, &res);
if (!mp_chmap_is_empty(&res))
mp_audio_set_channels(fmt, &res);
}
// Initialization and runtime control
static int control(struct af_instance *af, int cmd, void *arg)
{
@@ -76,23 +116,17 @@ static int control(struct af_instance *af, int cmd, void *arg)
if (!af_fmt_is_pcm(in->format) || in->nch < s->cfg_min_channel_num)
return AF_DETACH;
mp_audio_set_format(in, s->in_sampleformat);
// At least currently, the AC3 encoder doesn't export sample rates.
in->rate = 48000;
select_encode_format(s->lavc_actx, in);
if (in->rate != 48000 && in->rate != 44100 && in->rate != 32000)
in->rate = 48000;
af->data->rate = in->rate;
mp_chmap_reorder_to_lavc(&in->channels);
if (in->nch > AC3_MAX_CHANNELS)
mp_audio_set_num_channels(in, AC3_MAX_CHANNELS);
mp_audio_set_format(af->data, AF_FORMAT_S_AC3);
mp_audio_set_num_channels(af->data, 2);
if (!mp_audio_config_equals(in, &orig_in))
return AF_FALSE;
s->in_samples = AC3_FRAME_SIZE;
if (s->cfg_add_iec61937_header) {
s->out_samples = AC3_FRAME_SIZE;
} else {
@@ -100,14 +134,11 @@ static int control(struct af_instance *af, int cmd, void *arg)
}
mp_audio_copy_config(s->input, in);
mp_audio_realloc(s->input, s->in_samples);
s->input->samples = 0;
talloc_free(s->pending);
s->pending = NULL;
MP_DBG(af, "af_lavcac3enc reinit: %d, %d, %d.\n",
in->nch, in->rate, s->in_samples);
MP_DBG(af, "reinit: %d, %d, %d.\n", in->nch, in->rate, s->in_samples);
int bit_rate = s->bit_rate ? s->bit_rate : default_bit_rate[in->nch];
@@ -118,6 +149,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
avcodec_close(s->lavc_actx);
// Put sample parameters
s->lavc_actx->sample_fmt = af_to_avformat(in->format);
s->lavc_actx->channels = in->nch;
s->lavc_actx->channel_layout = mp_chmap_to_lavc(&in->channels);
s->lavc_actx->sample_rate = in->rate;
@@ -127,14 +159,24 @@ static int control(struct af_instance *af, int cmd, void *arg)
MP_ERR(af, "Couldn't open codec %s, br=%d.\n", "ac3", bit_rate);
return AF_ERROR;
}
if (s->lavc_actx->frame_size < 1) {
MP_ERR(af, "encoder didn't specify input frame size\n");
return AF_ERROR;
}
}
if (s->lavc_actx->frame_size != AC3_FRAME_SIZE) {
MP_ERR(af, "lavcac3enc: unexpected ac3 "
"encoder frame size %d\n", s->lavc_actx->frame_size);
return AF_ERROR;
}
s->in_samples = s->lavc_actx->frame_size;
mp_audio_realloc(s->input, s->in_samples);
s->input->samples = 0;
return AF_OK;
}
case AF_CONTROL_RESET:
if (avcodec_is_open(s->lavc_actx))
avcodec_flush_buffers(s->lavc_actx);
talloc_free(s->pending);
s->pending = NULL;
s->input->samples = 0;
return AF_OK;
}
return AF_UNKNOWN;
}
@@ -199,12 +241,33 @@ static bool fill_buffer(struct af_instance *af)
return s->input->samples >= s->in_samples;
}
static int filter_out(struct af_instance *af)
// Return <0 on error, 0 on need more input, 1 on success (and *frame set).
// To actually advance the read pointer, set s->input->samples=0 afterwards.
static int read_input_frame(struct af_instance *af, AVFrame *frame)
{
af_ac3enc_t *s = af->priv;
if (!fill_buffer(af))
return 0; // need more input
frame->nb_samples = s->in_samples;
frame->format = s->lavc_actx->sample_fmt;
frame->channel_layout = s->lavc_actx->channel_layout;
#if LIBAVUTIL_VERSION_MICRO >= 100
frame->channels = s->lavc_actx->channels;
#endif
assert(s->input->num_planes <= AV_NUM_DATA_POINTERS);
frame->extended_data = frame->data;
for (int n = 0; n < s->input->num_planes; n++)
frame->data[n] = s->input->planes[n];
frame->linesize[0] = s->input->samples * s->input->sstride;
return 1;
}
static int filter_out(struct af_instance *af)
{
af_ac3enc_t *s = af->priv;
AVFrame *frame = av_frame_alloc();
if (!frame) {
MP_FATAL(af, "Could not allocate memory \n");
@@ -212,18 +275,41 @@ static int filter_out(struct af_instance *af)
}
int err = -1;
frame->nb_samples = s->in_samples;
frame->format = s->lavc_actx->sample_fmt;
frame->channel_layout = s->lavc_actx->channel_layout;
assert(s->input->num_planes <= AV_NUM_DATA_POINTERS);
frame->extended_data = frame->data;
for (int n = 0; n < s->input->num_planes; n++)
frame->data[n] = s->input->planes[n];
frame->linesize[0] = s->input->samples * s->input->sstride;
AVPacket pkt = {0};
av_init_packet(&pkt);
#if HAVE_AVCODEC_NEW_CODEC_API
// Send input as long as it wants.
while (1) {
err = read_input_frame(af, frame);
if (err < 0)
goto done;
if (err == 0)
break;
err = -1;
int lavc_ret = avcodec_send_frame(s->lavc_actx, frame);
// On EAGAIN, we're supposed to read remaining output.
if (lavc_ret == AVERROR(EAGAIN))
break;
if (lavc_ret < 0) {
MP_FATAL(af, "Encode failed.\n");
goto done;
}
s->input->samples = 0;
}
int lavc_ret = avcodec_receive_packet(s->lavc_actx, &pkt);
if (lavc_ret == AVERROR(EAGAIN)) {
// Need to buffer more input.
err = 0;
goto done;
}
#else
err = read_input_frame(af, frame);
if (err < 0)
goto done;
if (err == 0)
goto done;
err = -1;
int ok;
int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &pkt, frame, &ok);
av_frame_free(&frame);
@@ -232,9 +318,10 @@ static int filter_out(struct af_instance *af)
MP_FATAL(af, "Encode failed.\n");
goto done;
}
#endif
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
pkt.size, s->pending->samples);
pkt.size, s->pending->samples);
struct mp_audio *out =
mp_audio_pool_get(af->out_pool, af->data, s->out_samples);
@@ -287,9 +374,9 @@ static int af_open(struct af_instance* af){
af->filter_frame = filter_frame;
af->filter_out = filter_out;
s->lavc_acodec = avcodec_find_encoder_by_name("ac3");
s->lavc_acodec = avcodec_find_encoder_by_name(s->cfg_encoder);
if (!s->lavc_acodec) {
MP_ERR(af, "Audio LAVC, couldn't find encoder for codec %s.\n", "ac3");
MP_ERR(af, "Couldn't find encoder %s.\n", s->cfg_encoder);
return AF_ERROR;
}
@@ -298,35 +385,30 @@ static int af_open(struct af_instance* af){
MP_ERR(af, "Audio LAVC, couldn't allocate context!\n");
return AF_ERROR;
}
const enum AVSampleFormat *fmts = s->lavc_acodec->sample_fmts;
for (int i = 0; fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
s->in_sampleformat = af_from_avformat(fmts[i]);
if (s->in_sampleformat) {
s->lavc_actx->sample_fmt = fmts[i];
break;
}
}
if (!s->in_sampleformat) {
MP_ERR(af, "Audio LAVC, encoder doesn't "
"support expected sample formats!\n");
// For this one, we require the decoder to expert lists of all supported
// parameters. (Not all decoders do that, but the ones we're interested
// in do.)
if (!s->lavc_acodec->sample_fmts ||
!s->lavc_acodec->channel_layouts)
{
MP_ERR(af, "Audio encoder doesn't list supported parameters.\n");
return AF_ERROR;
}
MP_VERBOSE(af, "[af_lavcac3enc]: in sample format: %s\n",
af_fmt_to_str(s->in_sampleformat));
s->input = talloc_zero(s, struct mp_audio);
if (s->cfg_bit_rate) {
int i;
for (i = 0; i < 19; i++) {
if (ac3_bitrate_tab[i] == s->cfg_bit_rate)
if (ac3_bitrate_tab[i] == s->cfg_bit_rate) {
s->bit_rate = ac3_bitrate_tab[i] * 1000;
break;
}
}
if (i >= 19) {
MP_WARN(af, "af_lavcac3enc unable set unsupported "
"bitrate %d, use default bitrate (check manpage to see "
"supported bitrates).\n", s->cfg_bit_rate);
s->cfg_bit_rate = 0;
MP_WARN(af, "unable set unsupported bitrate %d, use default "
"bitrate (check manpage to see supported bitrates).\n",
s->cfg_bit_rate);
}
}
@@ -344,12 +426,14 @@ const struct af_info af_info_lavcac3enc = {
.cfg_add_iec61937_header = 1,
.cfg_bit_rate = 640,
.cfg_min_channel_num = 3,
.cfg_encoder = "ac3",
},
.options = (const struct m_option[]) {
OPT_FLAG("tospdif", cfg_add_iec61937_header, 0),
OPT_CHOICE_OR_INT("bitrate", cfg_bit_rate, 0, 32, 640,
({"auto", 0}, {"default", 0})),
OPT_INTRANGE("minch", cfg_min_channel_num, 0, 2, 6),
OPT_STRING("encoder", cfg_encoder, 0),
{0}
},
};
+13 -264
View File
@@ -35,18 +35,6 @@ struct mixer {
struct MPOpts *opts;
struct ao *ao;
struct af_stream *af;
// Static, dependent on ao/softvol settings
bool softvol; // use AO (false) or af_volume (true)
bool persistent_volume; // volume does not need to be restored
bool emulate_mute; // if true, emulate mute with volume=0
// Last known values (possibly out of sync with reality)
float vol_l, vol_r;
bool muted;
// Used to decide whether we should unmute on uninit
bool muted_by_us;
/* Contains ao driver name or "softvol" if volume is not persistent
* and needs to be restored after the driver is reinitialized. */
const char *driver;
// Other stuff
float balance;
};
@@ -57,82 +45,25 @@ struct mixer *mixer_init(void *talloc_ctx, struct mpv_global *global)
*mixer = (struct mixer) {
.log = mp_log_new(mixer, global->log, "mixer"),
.opts = global->opts,
.vol_l = 100,
.vol_r = 100,
.driver = "",
};
return mixer;
}
bool mixer_audio_initialized(struct mixer *mixer)
{
return !!mixer->ao;
return !!mixer->af;
}
float mixer_getmaxvolume(struct mixer *mixer)
// Called when opts->softvol_volume or opts->softvol_mute were changed.
void mixer_update_volume(struct mixer *mixer)
{
// gain == 1
return mixer->softvol ? mixer->opts->softvol_max : 100;
}
static void checkvolume(struct mixer *mixer)
{
if (!mixer->ao)
if (!mixer->af)
return;
ao_control_vol_t vol = {mixer->vol_l, mixer->vol_r};
if (mixer->softvol) {
float gain;
if (!af_control_any_rev(mixer->af, AF_CONTROL_GET_VOLUME, &gain))
gain = 1.0;
vol.left = gain * 100.0;
vol.right = gain * 100.0;
} else {
MP_DBG(mixer, "Reading volume from AO.\n");
// Rely on the values not changing if the query is not supported
ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol);
ao_control(mixer->ao, AOCONTROL_GET_MUTE, &mixer->muted);
}
float l = mixer->vol_l;
float r = mixer->vol_r;
if (mixer->emulate_mute && mixer->muted)
l = r = 0;
/* Try to detect cases where the volume has been changed by some external
* action (such as something else changing a shared system-wide volume).
* We don't test for exact equality, as some AOs may round the value
* we last set to some nearby supported value. 3 has been the default
* volume step for increase/decrease keys, and is apparently big enough
* to step to the next possible value in most setups.
*/
if (FFABS(vol.left - l) >= 3 || FFABS(vol.right - r) >= 3) {
mixer->vol_l = vol.left;
mixer->vol_r = vol.right;
if (mixer->emulate_mute)
mixer->muted = false;
}
mixer->muted_by_us &= mixer->muted;
}
float gain = MPMAX(mixer->opts->softvol_volume / 100.0, 0);
if (mixer->opts->softvol_mute == 1)
gain = 0.0;
void mixer_getvolume(struct mixer *mixer, float *l, float *r)
{
checkvolume(mixer);
*l = mixer->vol_l;
*r = mixer->vol_r;
}
static void setvolume_internal(struct mixer *mixer)
{
float l = mixer->vol_l, r = mixer->vol_r;
if (mixer->emulate_mute && mixer->muted)
l = r = 0;
if (!mixer->softvol) {
MP_DBG(mixer, "Setting volume on AO.\n");
struct ao_control_vol vol = {.left = l, .right = r};
if (ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
MP_ERR(mixer, "Failed to change audio output volume.\n");
return;
}
float gain = (l + r) / 2.0 / 100.0;
if (!af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain)) {
if (gain == 1.0)
return;
@@ -143,57 +74,6 @@ static void setvolume_internal(struct mixer *mixer)
}
}
void mixer_setvolume(struct mixer *mixer, float l, float r)
{
checkvolume(mixer); // to check mute status
float max = mixer_getmaxvolume(mixer);
mixer->vol_l = MPCLAMP(l, 0, max);
mixer->vol_r = MPCLAMP(r, 0, max);
if (mixer->ao)
setvolume_internal(mixer);
}
void mixer_getbothvolume(struct mixer *mixer, float *b)
{
float mixer_l, mixer_r;
mixer_getvolume(mixer, &mixer_l, &mixer_r);
*b = (mixer_l + mixer_r) / 2;
}
void mixer_setmute(struct mixer *mixer, bool mute)
{
checkvolume(mixer);
if (mute == mixer->muted)
return;
if (mixer->ao) {
mixer->muted = mute;
mixer->muted_by_us = mute;
if (mixer->emulate_mute) {
setvolume_internal(mixer);
} else {
ao_control(mixer->ao, AOCONTROL_SET_MUTE, &mute);
}
checkvolume(mixer);
} else {
mixer->muted = mute;
mixer->muted_by_us = mute;
}
}
bool mixer_getmute(struct mixer *mixer)
{
checkvolume(mixer);
return mixer->muted;
}
void mixer_addvolume(struct mixer *mixer, float step)
{
float vol_l, vol_r;
mixer_getvolume(mixer, &vol_l, &vol_r);
mixer_setvolume(mixer, vol_l + step, vol_r + step);
}
void mixer_getbalance(struct mixer *mixer, float *val)
{
if (mixer->af)
@@ -242,130 +122,18 @@ void mixer_setbalance(struct mixer *mixer, float val)
af_pan_balance->control(af_pan_balance, AF_CONTROL_SET_PAN_BALANCE, &val);
}
char *mixer_get_volume_restore_data(struct mixer *mixer)
{
if (!mixer->driver[0])
return NULL;
return talloc_asprintf(NULL, "%s:%f:%f:%d", mixer->driver, mixer->vol_l,
mixer->vol_r, mixer->muted_by_us);
}
static void probe_softvol(struct mixer *mixer)
{
bool ao_perapp = ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) == 1;
bool ao_softvol = ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
assert(!(ao_perapp && ao_softvol));
mixer->persistent_volume = !ao_softvol;
if (mixer->opts->softvol == SOFTVOL_AUTO) {
// No system-wide volume => fine with AO volume control.
mixer->softvol = !ao_softvol && !ao_perapp;
} else {
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
}
if (mixer->softvol)
mixer->persistent_volume = false;
MP_DBG(mixer, "Will use af_volume: %s\n", mixer->softvol ? "yes" : "no");
// If we can't use real volume control => force softvol.
if (!mixer->softvol) {
ao_control_vol_t vol;
if (ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK) {
mixer->softvol = true;
MP_WARN(mixer, "Hardware volume control unavailable.\n");
}
}
// Probe native mute support.
mixer->emulate_mute = true;
if (!mixer->softvol) {
if (ao_control(mixer->ao, AOCONTROL_GET_MUTE, &(bool){0}) == CONTROL_OK)
mixer->emulate_mute = false;
}
}
static void restore_volume(struct mixer *mixer)
{
struct MPOpts *opts = mixer->opts;
struct ao *ao = mixer->ao;
float force_vol_l = -1, force_vol_r = -1;
int force_mute = -1;
const char *prev_driver = mixer->driver;
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
if (!prev_driver[0])
prev_driver = mixer->driver;
// Restore old parameters if volume won't survive reinitialization.
// But not if volume scale is possibly different.
if (!mixer->persistent_volume && strcmp(mixer->driver, prev_driver) == 0) {
force_vol_l = mixer->vol_l;
force_vol_r = mixer->vol_r;
}
// Set mute if we disabled it on uninit last time.
if (mixer->muted_by_us)
force_mute = 1;
// Set parameters from command line.
if (opts->mixer_init_volume >= 0)
force_vol_l = force_vol_r = opts->mixer_init_volume;
if (opts->mixer_init_mute >= 0)
force_mute = opts->mixer_init_mute;
// Set parameters from playback resume.
char *data = mixer->opts->mixer_restore_volume_data;
if (!mixer->persistent_volume && data && data[0]) {
char drv[40];
float v_l, v_r;
int m;
if (sscanf(data, "%39[^:]:%f:%f:%d", drv, &v_l, &v_r, &m) == 4) {
if (strcmp(mixer->driver, drv) == 0) {
force_vol_l = v_l;
force_vol_r = v_r;
force_mute = !!m;
MP_DBG(mixer, "Restoring volume from resume config.\n");
}
}
talloc_free(mixer->opts->mixer_restore_volume_data);
mixer->opts->mixer_restore_volume_data = NULL;
}
// Using --volume should not reset the volume on every file (i.e. reinit),
// OTOH mpv --{ --volume 10 f1.mkv --} --{ --volume 20 f2.mkv --} must work.
// Resetting the option volumes to "auto" (-1) is easiest. If file local
// options (as shown above) are used, the option handler code will reset
// them to other values, and force the volume to be reset as well.
opts->mixer_init_volume = -1;
opts->mixer_init_mute = -1;
checkvolume(mixer);
if (force_vol_l >= 0 && force_vol_r >= 0) {
MP_DBG(mixer, "Restoring previous volume.\n");
mixer_setvolume(mixer, force_vol_l, force_vol_r);
}
if (force_mute >= 0) {
MP_DBG(mixer, "Restoring previous mute toggle.\n");
mixer_setmute(mixer, force_mute);
}
}
// Called after the audio filter chain is built or rebuilt.
// (Can be called multiple times, even without mixer_uninit() in-between.)
void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af)
void mixer_reinit_audio(struct mixer *mixer, struct af_stream *af)
{
if (!ao || !af)
return;
mixer->ao = ao;
mixer->af = af;
if (!af)
return;
MP_DBG(mixer, "Reinit...\n");
if (mixer->opts->softvol == SOFTVOL_NO)
MP_ERR(mixer, "--softvol=no is not supported anymore.\n");
probe_softvol(mixer);
restore_volume(mixer);
mixer_update_volume(mixer);
if (mixer->balance != 0)
mixer_setbalance(mixer, mixer->balance);
@@ -380,24 +148,5 @@ void mixer_uninit_audio(struct mixer *mixer)
if (!mixer->ao)
return;
MP_DBG(mixer, "Uninit...\n");
checkvolume(mixer);
if (mixer->muted_by_us && mixer->persistent_volume) {
MP_DBG(mixer, "Draining.\n");
/* Current audio output API combines playing the remaining buffered
* audio and uninitializing the AO into one operation, even though
* ideally unmute would happen between those two steps. We can't do
* volume changes after uninitialization, but we don't want the
* remaining audio to play at full volume either. Thus this
* workaround to drop remaining audio first. */
ao_reset(mixer->ao);
mixer_setmute(mixer, false);
/* We remember mute status and re-enable it if we play more audio
* in the same process. */
mixer->muted_by_us = true;
}
mixer->ao = NULL;
mixer->af = NULL;
mixer->softvol = false;
}
+2 -9
View File
@@ -33,18 +33,11 @@ struct af_stream;
struct mixer;
struct mixer *mixer_init(void *talloc_ctx, struct mpv_global *global);
void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af);
void mixer_reinit_audio(struct mixer *mixer, struct af_stream *af);
void mixer_uninit_audio(struct mixer *mixer);
bool mixer_audio_initialized(struct mixer *mixer);
void mixer_getvolume(struct mixer *mixer, float *l, float *r);
void mixer_setvolume(struct mixer *mixer, float l, float r);
void mixer_addvolume(struct mixer *mixer, float step);
void mixer_getbothvolume(struct mixer *mixer, float *b);
void mixer_setmute(struct mixer *mixer, bool mute);
bool mixer_getmute(struct mixer *mixer);
void mixer_update_volume(struct mixer *mixer);
void mixer_getbalance(struct mixer *mixer, float *bal);
void mixer_setbalance(struct mixer *mixer, float bal);
float mixer_getmaxvolume(struct mixer *mixer);
char *mixer_get_volume_restore_data(struct mixer *mixer);
#endif /* MPLAYER_MIXER_H */
+2 -3
View File
@@ -490,10 +490,9 @@ struct ao_hotplug *ao_hotplug_create(struct mpv_global *global,
static void get_devices(struct ao *ao, struct ao_device_list *list)
{
int num = list->num_devices;
if (ao->driver->list_devs)
if (ao->driver->list_devs) {
ao->driver->list_devs(ao, list);
// Add at least a default entry
if (list->num_devices == num) {
} else {
char name[80] = "Default";
if (num > 1)
mp_snprintf_cat(name, sizeof(name), " (%s)", ao->driver->name);
+69 -9
View File
@@ -58,6 +58,8 @@ struct priv {
snd_pcm_uframes_t buffersize;
snd_pcm_uframes_t outburst;
snd_output_t *output;
char *cfg_device;
char *cfg_mixer_device;
char *cfg_mixer_name;
@@ -477,6 +479,22 @@ static int set_chmap(struct ao *ao, struct mp_chmap *dev_chmap, int num_channels
#endif /* else HAVE_CHMAP_API */
static void dump_hw_params(struct ao *ao, int msglevel, const char *msg,
snd_pcm_hw_params_t *hw_params)
{
struct priv *p = ao->priv;
int err;
err = snd_pcm_hw_params_dump(hw_params, p->output);
CHECK_ALSA_WARN("Dump hwparams error");
char *tmp = NULL;
size_t tmp_s = snd_output_buffer_string(p->output, &tmp);
if (tmp)
mp_msg(ao->log, msglevel, "%s---\n%.*s---\n", msg, (int)tmp_s, tmp);
snd_output_flush(p->output);
}
static int map_iec958_srate(int srate)
{
switch (srate) {
@@ -520,7 +538,7 @@ static char *append_params(void *ta_parent, const char *device, const char *p)
abort();
}
static int try_open_device(struct ao *ao, const char *device)
static int try_open_device(struct ao *ao, const char *device, int mode)
{
struct priv *p = ao->priv;
int err;
@@ -534,7 +552,7 @@ static int try_open_device(struct ao *ao, const char *device)
map_iec958_srate(ao->samplerate));
const char *ac3_device = append_params(tmp, device, params);
MP_VERBOSE(ao, "opening device '%s' => '%s'\n", device, ac3_device);
err = snd_pcm_open(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0);
err = snd_pcm_open(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, mode);
if (err < 0) {
// Some spdif-capable devices do not accept the AES0 parameter,
// and instead require the iec958 pseudo-device (they will play
@@ -547,13 +565,13 @@ static int try_open_device(struct ao *ao, const char *device)
MP_VERBOSE(ao, "got error %d; opening iec fallback device '%s'\n",
err, ac3_device);
err = snd_pcm_open
(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0);
(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, mode);
}
}
talloc_free(tmp);
} else {
MP_VERBOSE(ao, "opening device '%s'\n", device);
err = snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, 0);
err = snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, mode);
}
return err;
@@ -563,6 +581,10 @@ static void uninit(struct ao *ao)
{
struct priv *p = ao->priv;
if (p->output)
snd_output_close(p->output);
p->output = NULL;
if (p->alsa) {
int err;
@@ -574,20 +596,35 @@ static void uninit(struct ao *ao)
alsa_error: ;
}
static int init_device(struct ao *ao)
#define INIT_DEVICE_ERR_GENERIC -1
#define INIT_DEVICE_ERR_HWPARAMS -2
static int init_device(struct ao *ao, int mode)
{
struct priv *p = ao->priv;
int ret = INIT_DEVICE_ERR_GENERIC;
char *tmp;
size_t tmp_s;
int err;
err = snd_output_buffer_open(&p->output);
CHECK_ALSA_ERROR("Unable to create output buffer");
const char *device = "default";
if (ao->device)
device = ao->device;
if (p->cfg_device && p->cfg_device[0])
device = p->cfg_device;
err = try_open_device(ao, device);
err = try_open_device(ao, device, mode);
CHECK_ALSA_ERROR("Playback open error");
err = snd_pcm_dump(p->alsa, p->output);
CHECK_ALSA_WARN("Dump PCM error");
tmp_s = snd_output_buffer_string(p->output, &tmp);
if (tmp)
MP_DBG(ao, "PCM setup:\n---\n%.*s---\n", (int)tmp_s, tmp);
snd_output_flush(p->output);
err = snd_pcm_nonblock(p->alsa, 0);
CHECK_ALSA_WARN("Unable to set blocking mode");
@@ -597,12 +634,15 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams);
CHECK_ALSA_ERROR("Unable to get initial parameters");
dump_hw_params(ao, MSGL_DEBUG, "Start HW params:\n", alsa_hwparams);
// Some ALSA drivers have broken delay reporting, so disable the ALSA
// resampling plugin by default.
if (!p->cfg_resample) {
err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0);
CHECK_ALSA_ERROR("Unable to disable resampling");
}
dump_hw_params(ao, MSGL_DEBUG, "HW params after rate:\n", alsa_hwparams);
snd_pcm_access_t access = af_fmt_is_planar(ao->format)
? SND_PCM_ACCESS_RW_NONINTERLEAVED
@@ -614,6 +654,7 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
}
CHECK_ALSA_ERROR("Unable to set access type");
dump_hw_params(ao, MSGL_DEBUG, "HW params after access:\n", alsa_hwparams);
bool found_format = false;
int try_formats[AF_FORMAT_COUNT];
@@ -637,6 +678,7 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
CHECK_ALSA_ERROR("Unable to set format");
dump_hw_params(ao, MSGL_DEBUG, "HW params after format:\n", alsa_hwparams);
struct mp_chmap dev_chmap = ao->channels;
if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) {
@@ -656,6 +698,7 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_set_channels_near
(p->alsa, alsa_hwparams, &num_channels);
CHECK_ALSA_ERROR("Unable to set channels");
dump_hw_params(ao, MSGL_DEBUG, "HW params after channels:\n", alsa_hwparams);
if (num_channels > MP_NUM_CHANNELS) {
MP_FATAL(ao, "Too many audio channels (%d).\n", num_channels);
@@ -665,6 +708,7 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_set_rate_near
(p->alsa, alsa_hwparams, &ao->samplerate, NULL);
CHECK_ALSA_ERROR("Unable to set samplerate-2");
dump_hw_params(ao, MSGL_DEBUG, "HW params after rate-2:\n", alsa_hwparams);
snd_pcm_hw_params_t *hwparams_backup;
snd_pcm_hw_params_alloca(&hwparams_backup);
@@ -682,9 +726,14 @@ static int init_device(struct ao *ao)
if (err < 0)
snd_pcm_hw_params_copy(alsa_hwparams, hwparams_backup);
dump_hw_params(ao, MSGL_V, "Going to set final HW params:\n", alsa_hwparams);
/* finally install hardware parameters */
err = snd_pcm_hw_params(p->alsa, alsa_hwparams);
ret = INIT_DEVICE_ERR_HWPARAMS;
CHECK_ALSA_ERROR("Unable to set hw-parameters");
ret = INIT_DEVICE_ERR_GENERIC;
dump_hw_params(ao, MSGL_DEBUG, "Final HW params:\n", alsa_hwparams);
if (set_chmap(ao, &dev_chmap, num_channels) < 0)
goto alsa_error;
@@ -740,7 +789,7 @@ static int init_device(struct ao *ao)
alsa_error:
uninit(ao);
return -1;
return ret;
}
static int init(struct ao *ao)
@@ -751,7 +800,18 @@ static int init(struct ao *ao)
MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version());
int r = init_device(ao);
int mode = 0;
int r = init_device(ao, mode);
if (r == INIT_DEVICE_ERR_HWPARAMS) {
// With some drivers, ALSA appears to be unable to set valid hwparams,
// but they work if at least SND_PCM_NO_AUTO_FORMAT is set. Also, it
// appears you can set this flag only on opening a device, thus there
// is the need to retry opening the device.
MP_WARN(ao, "Attempting to work around even more ALSA bugs...\n");
mode |= SND_PCM_NO_AUTO_CHANNELS | SND_PCM_NO_AUTO_FORMAT |
SND_PCM_NO_AUTO_RESAMPLE;
r = init_device(ao, mode);
}
// Sometimes, ALSA will advertise certain chmaps, but it's not possible to
// set them. This can happen with dmix: as of alsa 1.0.29, dmix can do
@@ -773,7 +833,7 @@ static int init(struct ao *ao)
MP_VERBOSE(ao, "Working around braindead dmix multichannel behavior.\n");
uninit(ao);
ao->channels = without_na;
r = init_device(ao);
r = init_device(ao, mode);
}
}
-5
View File
@@ -133,11 +133,6 @@ static bool reinit_device(struct ao *ao) {
OSStatus err = ca_select_device(ao, ao->device, &p->device);
CHECK_CA_ERROR("failed to select device");
char *uid;
err = CA_GET_STR(p->device, kAudioDevicePropertyDeviceUID, &uid);
CHECK_CA_ERROR("failed to get device UID");
ao->detected_device = talloc_steal(ao, uid);
return true;
coreaudio_error:
+10 -24
View File
@@ -114,6 +114,13 @@ OSStatus ca_select_device(struct ao *ao, char* name, AudioDeviceID *device)
kAudioObjectSystemObject, &p_addr, 0, 0, &size, &v);
CFRelease(uid);
CHECK_CA_ERROR("unable to query for device UID");
uint32_t is_alive = 1;
err = CA_GET(*device, kAudioDevicePropertyDeviceIsAlive, &is_alive);
CHECK_CA_ERROR("could not check whether device is alive (invalid device?)");
if (!is_alive)
MP_WARN(ao, "device is not alive!\n");
} else {
// device not set by user, get the default one
err = CA_GET(kAudioObjectSystemObject,
@@ -323,6 +330,9 @@ bool ca_stream_supports_compressed(struct ao *ao, AudioStreamID stream)
for (int i = 0; i < n_formats; i++) {
AudioStreamBasicDescription asbd = formats[i].mFormat;
ca_print_asbd(ao, "- ", &asbd);
if (ca_formatid_is_compressed(asbd.mFormatID)) {
talloc_free(formats);
return true;
@@ -334,30 +344,6 @@ coreaudio_error:
return false;
}
bool ca_device_supports_compressed(struct ao *ao, AudioDeviceID device)
{
AudioStreamID *streams = NULL;
size_t n_streams;
/* Retrieve all the output streams. */
OSStatus err =
CA_GET_ARY_O(device, kAudioDevicePropertyStreams, &streams, &n_streams);
CHECK_CA_ERROR("could not get number of streams.");
for (int i = 0; i < n_streams; i++) {
if (ca_stream_supports_compressed(ao, streams[i])) {
talloc_free(streams);
return true;
}
}
talloc_free(streams);
coreaudio_error:
return false;
}
OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid)
{
*pid = getpid();
-1
View File
@@ -65,7 +65,6 @@ bool ca_asbd_is_better(AudioStreamBasicDescription *req,
int64_t ca_frames_to_us(struct ao *ao, uint32_t frames);
int64_t ca_get_latency(const AudioTimeStamp *ts);
bool ca_device_supports_compressed(struct ao *ao, AudioDeviceID device);
bool ca_stream_supports_compressed(struct ao *ao, AudioStreamID stream);
OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid);
OSStatus ca_unlock_device(AudioDeviceID device, pid_t *pid);
+155 -110
View File
@@ -39,9 +39,8 @@
#include "common/encode_lavc.h"
struct priv {
uint8_t *buffer;
size_t buffer_size;
AVStream *stream;
AVCodecContext *codec;
int pcmhack;
int aframesize;
int aframecount;
@@ -98,15 +97,14 @@ static int init(struct ao *ao)
pthread_mutex_lock(&ao->encode_lavc_ctx->lock);
ac->stream = encode_lavc_alloc_stream(ao->encode_lavc_ctx,
AVMEDIA_TYPE_AUDIO);
if (!ac->stream) {
MP_ERR(ao, "could not get a new audio stream\n");
goto fail;
if (encode_lavc_alloc_stream(ao->encode_lavc_ctx,
AVMEDIA_TYPE_AUDIO,
&ac->stream, &ac->codec) < 0) {
MP_ERR(ao, "could not get a new audio stream\n");
goto fail;
}
codec = encode_lavc_get_codec(ao->encode_lavc_ctx, ac->stream);
codec = ao->encode_lavc_ctx->ac;
int samplerate = af_select_best_samplerate(ao->samplerate,
codec->supported_samplerates);
@@ -118,46 +116,38 @@ static int init(struct ao *ao)
// Using codec->time_bvase is deprecated, but needed for older lavf.
ac->stream->time_base.num = 1;
ac->stream->time_base.den = ao->samplerate;
ac->stream->codec->time_base.num = 1;
ac->stream->codec->time_base.den = ao->samplerate;
ac->codec->time_base.num = 1;
ac->codec->time_base.den = ao->samplerate;
ac->stream->codec->sample_rate = ao->samplerate;
ac->codec->sample_rate = ao->samplerate;
struct mp_chmap_sel sel = {0};
mp_chmap_sel_add_any(&sel);
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
goto fail;
mp_chmap_reorder_to_lavc(&ao->channels);
ac->stream->codec->channels = ao->channels.num;
ac->stream->codec->channel_layout = mp_chmap_to_lavc(&ao->channels);
ac->codec->channels = ao->channels.num;
ac->codec->channel_layout = mp_chmap_to_lavc(&ao->channels);
ac->stream->codec->sample_fmt = AV_SAMPLE_FMT_NONE;
ac->codec->sample_fmt = AV_SAMPLE_FMT_NONE;
select_format(ao, codec);
ac->sample_size = af_fmt_to_bytes(ao->format);
ac->stream->codec->sample_fmt = af_to_avformat(ao->format);
ac->stream->codec->bits_per_raw_sample = ac->sample_size * 8;
ac->codec->sample_fmt = af_to_avformat(ao->format);
ac->codec->bits_per_raw_sample = ac->sample_size * 8;
if (encode_lavc_open_codec(ao->encode_lavc_ctx, ac->stream) < 0)
if (encode_lavc_open_codec(ao->encode_lavc_ctx, ac->codec) < 0)
goto fail;
ac->pcmhack = 0;
if (ac->stream->codec->frame_size <= 1)
ac->pcmhack = av_get_bits_per_sample(ac->stream->codec->codec_id) / 8;
if (ac->codec->frame_size <= 1)
ac->pcmhack = av_get_bits_per_sample(ac->codec->codec_id) / 8;
if (ac->pcmhack) {
if (ac->pcmhack)
ac->aframesize = 16384; // "enough"
ac->buffer_size =
ac->aframesize * ac->pcmhack * ao->channels.num * 2 + 200;
} else {
ac->aframesize = ac->stream->codec->frame_size;
ac->buffer_size =
ac->aframesize * ac->sample_size * ao->channels.num * 2 + 200;
}
if (ac->buffer_size < FF_MIN_BUFFER_SIZE)
ac->buffer_size = FF_MIN_BUFFER_SIZE;
ac->buffer = talloc_size(ac, ac->buffer_size);
else
ac->aframesize = ac->codec->frame_size;
// enough frames for at least 0.25 seconds
ac->framecount = ceil(ao->samplerate * 0.25 / ac->aframesize);
@@ -182,7 +172,7 @@ fail:
}
// close audio device
static int encode(struct ao *ao, double apts, void **data);
static void encode(struct ao *ao, double apts, void **data);
static void uninit(struct ao *ao)
{
struct priv *ac = ao->priv;
@@ -199,12 +189,12 @@ static void uninit(struct ao *ao)
return;
}
if (ac->buffer) {
if (ac->stream) {
double outpts = ac->expected_next_pts;
if (!ectx->options->rawts && ectx->options->copyts)
outpts += ectx->discontinuity_pts_offset;
outpts += encode_lavc_getoffset(ectx, ac->stream);
while (encode(ao, outpts, NULL) > 0) ;
outpts += encode_lavc_getoffset(ectx, ac->codec);
encode(ao, outpts, NULL);
}
pthread_mutex_unlock(&ectx->lock);
@@ -220,24 +210,130 @@ static int get_space(struct ao *ao)
return ac->aframesize * ac->framecount;
}
static void write_packet(struct ao *ao, AVPacket *packet)
{
// TODO: Can we unify this with the equivalent video code path?
struct priv *ac = ao->priv;
packet->stream_index = ac->stream->index;
if (packet->pts != AV_NOPTS_VALUE) {
packet->pts = av_rescale_q(packet->pts,
ac->codec->time_base,
ac->stream->time_base);
} else {
// Do we need this at all? Better be safe than sorry...
MP_WARN(ao, "encoder lost pts, why?\n");
if (ac->savepts != MP_NOPTS_VALUE) {
packet->pts = av_rescale_q(ac->savepts,
ac->codec->time_base,
ac->stream->time_base);
}
}
if (packet->dts != AV_NOPTS_VALUE) {
packet->dts = av_rescale_q(packet->dts,
ac->codec->time_base,
ac->stream->time_base);
}
if (packet->duration > 0) {
packet->duration = av_rescale_q(packet->duration,
ac->codec->time_base,
ac->stream->time_base);
}
ac->savepts = AV_NOPTS_VALUE;
if (encode_lavc_write_frame(ao->encode_lavc_ctx,
ac->stream, packet) < 0) {
MP_ERR(ao, "error writing at %d %d/%d\n",
(int) packet->pts,
ac->stream->time_base.num,
ac->stream->time_base.den);
return;
}
}
static void encode_audio_and_write(struct ao *ao, AVFrame *frame)
{
// TODO: Can we unify this with the equivalent video code path?
struct priv *ac = ao->priv;
AVPacket packet = {0};
#if HAVE_AVCODEC_NEW_CODEC_API
int status = avcodec_send_frame(ac->codec, frame);
if (status < 0) {
MP_ERR(ao, "error encoding at %d %d/%d\n",
frame ? (int) frame->pts : -1,
ac->codec->time_base.num,
ac->codec->time_base.den);
return;
}
for (;;) {
av_init_packet(&packet);
status = avcodec_receive_packet(ac->codec, &packet);
if (status == AVERROR(EAGAIN)) { // No more packets for now.
if (frame == NULL) {
MP_ERR(ao, "sent flush frame, got EAGAIN");
}
break;
}
if (status == AVERROR_EOF) { // No more packets, ever.
if (frame != NULL) {
MP_ERR(ao, "sent audio frame, got EOF");
}
break;
}
if (status < 0) {
MP_ERR(ao, "error encoding at %d %d/%d\n",
frame ? (int) frame->pts : -1,
ac->codec->time_base.num,
ac->codec->time_base.den);
break;
}
if (frame) {
if (ac->savepts == AV_NOPTS_VALUE)
ac->savepts = frame->pts;
}
encode_lavc_write_stats(ao->encode_lavc_ctx, ac->codec);
write_packet(ao, &packet);
av_packet_unref(&packet);
}
#else
av_init_packet(&packet);
int got_packet = 0;
int status = avcodec_encode_audio2(ac->codec, &packet, frame, &got_packet);
if (status < 0) {
MP_ERR(ao, "error encoding at %d %d/%d\n",
frame ? (int) frame->pts : -1,
ac->codec->time_base.num,
ac->codec->time_base.den);
return;
}
if (!got_packet) {
return;
}
if (frame) {
if (ac->savepts == AV_NOPTS_VALUE)
ac->savepts = frame->pts;
}
encode_lavc_write_stats(ao->encode_lavc_ctx, ac->codec);
write_packet(ao, &packet);
av_packet_unref(&packet);
#endif
}
// must get exactly ac->aframesize amount of data
static int encode(struct ao *ao, double apts, void **data)
static void encode(struct ao *ao, double apts, void **data)
{
AVPacket packet;
struct priv *ac = ao->priv;
struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
double realapts = ac->aframecount * (double) ac->aframesize /
ao->samplerate;
int status, gotpacket;
ac->aframecount++;
if (data)
ectx->audio_pts_offset = realapts - apts;
av_init_packet(&packet);
packet.data = ac->buffer;
packet.size = ac->buffer_size;
if(data) {
AVFrame *frame = av_frame_alloc();
frame->format = af_to_avformat(ao->format);
@@ -252,82 +348,29 @@ static int encode(struct ao *ao, double apts, void **data)
if (ectx->options->rawts || ectx->options->copyts) {
// real audio pts
frame->pts = floor(apts * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
frame->pts = floor(apts * ac->codec->time_base.den / ac->codec->time_base.num + 0.5);
} else {
// audio playback time
frame->pts = floor(realapts * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
frame->pts = floor(realapts * ac->codec->time_base.den / ac->codec->time_base.num + 0.5);
}
int64_t frame_pts = av_rescale_q(frame->pts, ac->stream->codec->time_base, ac->worst_time_base);
int64_t frame_pts = av_rescale_q(frame->pts, ac->codec->time_base, ac->worst_time_base);
if (ac->lastpts != AV_NOPTS_VALUE && frame_pts <= ac->lastpts) {
// this indicates broken video
// (video pts failing to increase fast enough to match audio)
MP_WARN(ao, "audio frame pts went backwards (%d <- %d), autofixed\n",
(int)frame->pts, (int)ac->lastpts);
frame_pts = ac->lastpts + 1;
frame->pts = av_rescale_q(frame_pts, ac->worst_time_base, ac->stream->codec->time_base);
frame->pts = av_rescale_q(frame_pts, ac->worst_time_base, ac->codec->time_base);
}
ac->lastpts = frame_pts;
frame->quality = ac->stream->codec->global_quality;
status = avcodec_encode_audio2(ac->stream->codec, &packet, frame, &gotpacket);
if (!status) {
if (ac->savepts == AV_NOPTS_VALUE)
ac->savepts = frame->pts;
}
frame->quality = ac->codec->global_quality;
encode_audio_and_write(ao, frame);
av_frame_free(&frame);
}
else
{
status = avcodec_encode_audio2(ac->stream->codec, &packet, NULL, &gotpacket);
}
if(status) {
MP_ERR(ao, "error encoding\n");
return -1;
}
if(!gotpacket)
return 0;
MP_DBG(ao, "got pts %f (playback time: %f); out size: %d\n",
apts, realapts, packet.size);
encode_lavc_write_stats(ao->encode_lavc_ctx, ac->stream);
packet.stream_index = ac->stream->index;
// Do we need this at all? Better be safe than sorry...
if (packet.pts == AV_NOPTS_VALUE) {
MP_WARN(ao, "encoder lost pts, why?\n");
if (ac->savepts != MP_NOPTS_VALUE)
packet.pts = ac->savepts;
}
if (packet.pts != AV_NOPTS_VALUE)
packet.pts = av_rescale_q(packet.pts, ac->stream->codec->time_base,
ac->stream->time_base);
if (packet.dts != AV_NOPTS_VALUE)
packet.dts = av_rescale_q(packet.dts, ac->stream->codec->time_base,
ac->stream->time_base);
if(packet.duration > 0)
packet.duration = av_rescale_q(packet.duration, ac->stream->codec->time_base,
ac->stream->time_base);
ac->savepts = AV_NOPTS_VALUE;
if (encode_lavc_write_frame(ao->encode_lavc_ctx, &packet) < 0) {
MP_ERR(ao, "error writing at %f %f/%f\n",
realapts, (double) ac->stream->time_base.num,
(double) ac->stream->time_base.den);
return -1;
}
return packet.size;
encode_audio_and_write(ao, NULL);
}
// this should round samples down to frame sizes
@@ -377,22 +420,22 @@ static int play(struct ao *ao, void **data, int samples, int flags)
}
if (ac->worst_time_base.den == 0) {
//if (ac->stream->codec->time_base.num / ac->stream->codec->time_base.den >= ac->stream->time_base.num / ac->stream->time_base.den)
if (ac->stream->codec->time_base.num * (double) ac->stream->time_base.den >=
ac->stream->time_base.num * (double) ac->stream->codec->time_base.den) {
//if (ac->codec->time_base.num / ac->codec->time_base.den >= ac->stream->time_base.num / ac->stream->time_base.den)
if (ac->codec->time_base.num * (double) ac->stream->time_base.den >=
ac->stream->time_base.num * (double) ac->codec->time_base.den) {
MP_VERBOSE(ao, "NOTE: using codec time base (%d/%d) for pts "
"adjustment; the stream base (%d/%d) is not worse.\n",
(int)ac->stream->codec->time_base.num,
(int)ac->stream->codec->time_base.den,
(int)ac->codec->time_base.num,
(int)ac->codec->time_base.den,
(int)ac->stream->time_base.num,
(int)ac->stream->time_base.den);
ac->worst_time_base = ac->stream->codec->time_base;
ac->worst_time_base = ac->codec->time_base;
ac->worst_time_base_is_stream = 0;
} else {
MP_WARN(ao, "NOTE: not using codec time base (%d/%d) for pts "
"adjustment; the stream base (%d/%d) is worse.\n",
(int)ac->stream->codec->time_base.num,
(int)ac->stream->codec->time_base.den,
(int)ac->codec->time_base.num,
(int)ac->codec->time_base.den,
(int)ac->stream->time_base.num,
(int)ac->stream->time_base.den);
ac->worst_time_base = ac->stream->time_base;
@@ -437,7 +480,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
}
// Shift pts by the pts offset first.
outpts += encode_lavc_getoffset(ectx, ac->stream);
outpts += encode_lavc_getoffset(ectx, ac->codec);
while (samples - bufpos >= ac->aframesize) {
void *start[MP_NUM_CHANNELS] = {0};
@@ -492,3 +535,5 @@ const struct ao_driver audio_out_lavc = {
.play = play,
.drain = drain,
};
// vim: sw=4 ts=4 et tw=80
-1
View File
@@ -46,7 +46,6 @@ struct priv {
static const int fmtmap[][2] = {
{ AF_FORMAT_U8, SL_PCMSAMPLEFORMAT_FIXED_8 },
{ AF_FORMAT_S16, SL_PCMSAMPLEFORMAT_FIXED_16 },
{ AF_FORMAT_S32, SL_PCMSAMPLEFORMAT_FIXED_32 },
{ 0 }
};
+8 -1
View File
@@ -462,7 +462,7 @@ static int init(struct ao *ao)
p->buffersize = 0;
memset(data, 0, p->outburst);
while (p->buffersize < 0x40000 && device_writable(ao) > 0) {
write(p->audio_fd, data, p->outburst);
(void)write(p->audio_fd, data, p->outburst);
p->buffersize += p->outburst;
}
free(data);
@@ -612,6 +612,12 @@ static int audio_wait(struct ao *ao, pthread_mutex_t *lock)
return r;
}
static void list_devs(struct ao *ao, struct ao_device_list *list)
{
if (stat(PATH_DEV_DSP, &(struct stat){0}) == 0)
ao_device_list_add(list, ao, &(struct ao_device_desc){"", "Default"});
}
#define OPT_BASE_STRUCT struct priv
const struct ao_driver audio_out_oss = {
@@ -629,6 +635,7 @@ const struct ao_driver audio_out_oss = {
.drain = drain,
.wait = audio_wait,
.wakeup = ao_wakeup_poll,
.list_devs = list_devs,
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.audio_fd = -1,
+3 -3
View File
@@ -132,7 +132,7 @@ static bool thread_feed(struct ao *ao)
mp_time_us() + (int64_t)llrint(delay_us));
// note, we can't use ao_read_data return value here since we already
// commited to frame_count above in the GetBuffer call
// committed to frame_count above in the GetBuffer call
hr = IAudioRenderClient_ReleaseBuffer(state->pRenderClient,
frame_count, 0);
EXIT_ON_ERROR(hr);
@@ -270,7 +270,7 @@ static void uninit(struct ao *ao)
static int init(struct ao *ao)
{
MP_DBG(ao, "Init wasapi\n");
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CoInitializeEx(NULL, COINIT_MULTITHREADED);
struct wasapi_state *state = ao->priv;
state->log = ao->log;
@@ -469,7 +469,7 @@ static int hotplug_init(struct ao *ao)
MP_DBG(ao, "Hotplug init\n");
struct wasapi_state *state = ao->priv;
state->log = ao->log;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT hr = wasapi_change_init(ao, true);
EXIT_ON_ERROR(hr);
+2 -1
View File
@@ -17,6 +17,7 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <initguid.h>
#include <wchar.h>
#include "ao_wasapi.h"
@@ -94,7 +95,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceAdded(
return S_OK;
}
// maybe MPV can go over to the prefered device once it is plugged in?
// maybe MPV can go over to the preferred device once it is plugged in?
static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceRemoved(
IMMNotificationClient *This,
LPCWSTR pwstrDeviceId)
+19 -8
View File
@@ -142,6 +142,7 @@ static void resume(struct ao *ao)
static void drain(struct ao *ao)
{
struct ao_push_state *p = ao->api_priv;
double maxbuffer = ao->buffer / (double)ao->samplerate + 1;
MP_VERBOSE(ao, "draining...\n");
@@ -151,14 +152,23 @@ static void drain(struct ao *ao)
p->final_chunk = true;
wakeup_playthread(ao);
while (p->still_playing && mp_audio_buffer_samples(p->buffer) > 0)
pthread_cond_wait(&p->wakeup, &p->lock);
// Wait until everything is done. Since the audio API (especially ALSA)
// can't be trusted to do this right, and we're hard-blocking here, apply
// an upper bound timeout.
struct timespec until = mp_rel_time_to_timespec(maxbuffer);
while (p->still_playing && mp_audio_buffer_samples(p->buffer) > 0) {
if (pthread_cond_timedwait(&p->wakeup, &p->lock, &until)) {
MP_WARN(ao, "Draining is taking too long, aborting.\n");
goto done;
}
}
if (ao->driver->drain) {
ao->driver->drain(ao);
} else {
double time = unlocked_get_delay(ao);
mp_sleep_us(MPMIN(time, ao->buffer / (double)ao->samplerate + 1) * 1e6);
mp_sleep_us(MPMIN(time, maxbuffer) * 1e6);
}
done:
@@ -292,11 +302,12 @@ static void ao_play_data(struct ao *ao)
// If we just filled the AO completely (r == space), don't refill for a
// while. Prevents wakeup feedback with byte-granular AOs.
int needed = unlocked_get_space(ao);
bool more = needed >= (r == space ? ao->device_buffer / 4 : 1) && !stuck;
bool more = needed >= (r == space ? ao->device_buffer / 4 : 1) && !stuck &&
!(flags & AOPLAY_FINAL_CHUNK);
if (more)
mp_input_wakeup(ao->input_ctx); // request more data
MP_TRACE(ao, "in=%d flags=%d space=%d r=%d wa=%d needed=%d more=%d\n",
max, flags, space, r, p->wait_on_ao, needed, more);
MP_TRACE(ao, "in=%d flags=%d space=%d r=%d wa/pl=%d/%d needed=%d more=%d\n",
max, flags, space, r, p->wait_on_ao, p->still_playing, needed, more);
}
static void *playthread(void *arg)
@@ -489,7 +500,7 @@ int ao_wait_poll(struct ao *ao, struct pollfd *fds, int num_fds,
// flush the wakeup pipe contents - might "drown" some wakeups, but
// that's ok for our use-case
char buf[100];
read(p->wakeup_pipe[0], buf, sizeof(buf));
(void)read(p->wakeup_pipe[0], buf, sizeof(buf));
}
return (r >= 0 || r == -EINTR) ? wakeup : -1;
}
@@ -499,7 +510,7 @@ void ao_wakeup_poll(struct ao *ao)
assert(ao->api == &ao_api_push);
struct ao_push_state *p = ao->api_priv;
write(p->wakeup_pipe[1], &(char){0}, 1);
(void)write(p->wakeup_pipe[1], &(char){0}, 1);
}
#endif
+7 -2
View File
@@ -189,7 +189,7 @@ struct lib {
unsigned runv;
};
void print_libav_versions(struct mp_log *log, int v)
bool print_libav_versions(struct mp_log *log, int v)
{
const struct lib libs[] = {
{"libavutil", LIBAVUTIL_VERSION_INT, avutil_version()},
@@ -207,17 +207,22 @@ void print_libav_versions(struct mp_log *log, int v)
mp_msg(log, v, "%s library versions:\n", LIB_PREFIX);
bool mismatch = false;
for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) {
const struct lib *l = &libs[n];
mp_msg(log, v, " %-15s %d.%d.%d", l->name, V(l->buildv));
if (l->buildv != l->runv)
if (l->buildv != l->runv) {
mp_msg(log, v, " (runtime %d.%d.%d)", V(l->runv));
mismatch = true;
}
mp_msg(log, v, "\n");
}
#if HAVE_AV_VERSION_INFO
mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info());
#endif
return !mismatch;
}
#undef V
+4 -1
View File
@@ -1,8 +1,11 @@
#ifndef MP_AV_LOG_H
#define MP_AV_LOG_H
#include <stdbool.h>
struct mpv_global;
struct mp_log;
void init_libav(struct mpv_global *global);
void uninit_libav(struct mpv_global *global);
void print_libav_versions(struct mp_log *log, int v);
bool print_libav_versions(struct mp_log *log, int v);
#endif
+176 -148
View File
@@ -21,6 +21,7 @@
#include <libavutil/avutil.h>
#include "config.h"
#include "encode_lavc.h"
#include "common/global.h"
#include "common/msg.h"
@@ -291,32 +292,20 @@ int encode_lavc_start(struct encode_lavc_context *ctx)
CHECK_FAIL(ctx, 0);
if (ctx->expect_video) {
unsigned i;
for (i = 0; i < ctx->avc->nb_streams; ++i)
if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
if (i >= ctx->avc->nb_streams) {
if (ctx->avc->oformat->video_codec != AV_CODEC_ID_NONE ||
ctx->options->vcodec) {
encode_lavc_fail(ctx,
"no video stream succeeded - invalid codec?\n");
return 0;
}
if (ctx->expect_video && ctx->vcc == NULL) {
if (ctx->avc->oformat->video_codec != AV_CODEC_ID_NONE ||
ctx->options->vcodec) {
encode_lavc_fail(ctx,
"no video stream succeeded - invalid codec?\n");
return 0;
}
}
if (ctx->expect_audio) {
unsigned i;
for (i = 0; i < ctx->avc->nb_streams; ++i)
if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
break;
if (i >= ctx->avc->nb_streams) {
if (ctx->avc->oformat->audio_codec != AV_CODEC_ID_NONE ||
ctx->options->acodec) {
encode_lavc_fail(ctx,
"no audio stream succeeded - invalid codec?\n");
return 0;
}
if (ctx->expect_audio && ctx->acc == NULL) {
if (ctx->avc->oformat->audio_codec != AV_CODEC_ID_NONE ||
ctx->options->acodec) {
encode_lavc_fail(ctx,
"no audio stream succeeded - invalid codec?\n");
return 0;
}
}
@@ -387,33 +376,38 @@ void encode_lavc_finish(struct encode_lavc_context *ctx)
if (ctx->header_written > 0)
av_write_trailer(ctx->avc); // this is allowed to fail
for (i = 0; i < ctx->avc->nb_streams; i++) {
switch (ctx->avc->streams[i]->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (ctx->twopass_bytebuffer_v) {
char *stats = ctx->avc->streams[i]->codec->stats_out;
if (stats)
stream_write_buffer(ctx->twopass_bytebuffer_v,
stats, strlen(stats));
}
break;
case AVMEDIA_TYPE_AUDIO:
if (ctx->twopass_bytebuffer_a) {
char *stats = ctx->avc->streams[i]->codec->stats_out;
if (stats)
stream_write_buffer(ctx->twopass_bytebuffer_a,
stats, strlen(stats));
}
break;
default:
break;
if (ctx->vcc) {
if (ctx->twopass_bytebuffer_v) {
char *stats = ctx->vcc->stats_out;
if (stats)
stream_write_buffer(ctx->twopass_bytebuffer_v,
stats, strlen(stats));
}
avcodec_close(ctx->avc->streams[i]->codec);
talloc_free(ctx->avc->streams[i]->codec->stats_in);
av_free(ctx->avc->streams[i]->codec);
avcodec_close(ctx->vcc);
talloc_free(ctx->vcc->stats_in);
av_free(ctx->vcc);
ctx->vcc = NULL;
}
if (ctx->acc) {
if (ctx->twopass_bytebuffer_a) {
char *stats = ctx->acc->stats_out;
if (stats)
stream_write_buffer(ctx->twopass_bytebuffer_a,
stats, strlen(stats));
}
avcodec_close(ctx->acc);
talloc_free(ctx->acc->stats_in);
av_free(ctx->acc);
ctx->acc = NULL;
}
for (i = 0; i < ctx->avc->nb_streams; i++) {
av_free(ctx->avc->streams[i]->info);
av_free(ctx->avc->streams[i]);
}
ctx->vst = NULL;
ctx->ast = NULL;
if (ctx->twopass_bytebuffer_v) {
free_stream(ctx->twopass_bytebuffer_v);
@@ -437,6 +431,7 @@ void encode_lavc_finish(struct encode_lavc_context *ctx)
}
av_free(ctx->avc);
ctx->avc = NULL;
}
ctx->finished = true;
@@ -461,7 +456,9 @@ void encode_lavc_set_audio_pts(struct encode_lavc_context *ctx, double pts)
static void encode_2pass_prepare(struct encode_lavc_context *ctx,
AVDictionary **dictp,
AVStream *stream, struct stream **bytebuf,
AVStream *stream,
AVCodecContext *codec,
struct stream **bytebuf,
const char *prefix)
{
if (!*bytebuf) {
@@ -476,7 +473,7 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
if (!(*bytebuf = stream_open(buf, ctx->global))) {
MP_WARN(ctx, "%s: could not open '%s', "
"disabling 2-pass encoding at pass 2\n", prefix, buf);
stream->codec->flags &= ~CODEC_FLAG_PASS2;
codec->flags &= ~CODEC_FLAG_PASS2;
set_to_avdictionary(ctx, dictp, "flags", "-pass2");
} else {
struct bstr content = stream_read_complete(*bytebuf, NULL,
@@ -487,7 +484,7 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
prefix, ctx->avc->filename);
} else {
content.start[content.len] = 0;
stream->codec->stats_in = content.start;
codec->stats_in = content.start;
}
free_stream(*bytebuf);
*bytebuf = NULL;
@@ -506,43 +503,55 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
}
}
AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
enum AVMediaType mt)
int encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
enum AVMediaType mt,
AVStream **stream_out,
AVCodecContext **codec_out)
{
AVDictionaryEntry *de;
AVStream *stream = NULL;
char **p;
int i;
CHECK_FAIL(ctx, NULL);
*stream_out = NULL;
*codec_out = NULL;
CHECK_FAIL(ctx, -1);
if (ctx->header_written)
return NULL;
for (i = 0; i < ctx->avc->nb_streams; ++i)
if (ctx->avc->streams[i]->codec->codec_type == mt)
// already have a stream of that type, this cannot really happen
return NULL;
return -1;
if (ctx->avc->nb_streams == 0) {
// if this stream isn't stream #0, allocate a dummy stream first for
// the next loop to use
// the next call to use
if (mt == AVMEDIA_TYPE_VIDEO && ctx->audio_first) {
MP_INFO(ctx, "vo-lavc: preallocated audio stream for later use\n");
avformat_new_stream(ctx->avc, NULL); // this one is AVMEDIA_TYPE_UNKNOWN for now
ctx->ast = avformat_new_stream(
ctx->avc, NULL); // this one is AVMEDIA_TYPE_UNKNOWN for now
}
if (mt == AVMEDIA_TYPE_AUDIO && ctx->video_first) {
MP_INFO(ctx, "ao-lavc: preallocated video stream for later use\n");
avformat_new_stream(ctx->avc, NULL); // this one is AVMEDIA_TYPE_UNKNOWN for now
ctx->vst = avformat_new_stream(
ctx->avc, NULL); // this one is AVMEDIA_TYPE_UNKNOWN for now
}
} else {
// find possibly preallocated stream
for (i = 0; i < ctx->avc->nb_streams; ++i)
if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_UNKNOWN) // preallocated stream
stream = ctx->avc->streams[i];
}
if (!stream)
stream = avformat_new_stream(ctx->avc, NULL);
// already have a stream of that type (this cannot really happen)?
switch (mt) {
case AVMEDIA_TYPE_VIDEO:
if (ctx->vcc != NULL)
return -1;
if (ctx->vst == NULL)
ctx->vst = avformat_new_stream(ctx->avc, NULL);
break;
case AVMEDIA_TYPE_AUDIO:
if (ctx->acc != NULL)
return -1;
if (ctx->ast == NULL)
ctx->ast = avformat_new_stream(ctx->avc, NULL);
break;
default:
encode_lavc_fail(ctx, "requested invalid stream type\n");
return -1;
}
if (ctx->timebase.den == 0) {
AVRational r;
@@ -584,13 +593,18 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
ctx->options->vcodec) {
encode_lavc_fail(ctx, "vo-lavc: encoder not found\n");
}
return NULL;
return -1;
}
avcodec_get_context_defaults3(stream->codec, ctx->vc);
#if HAVE_AVCODEC_HAS_CODECPAR
ctx->vcc = avcodec_alloc_context3(ctx->vc);
#else
avcodec_get_context_defaults3(ctx->vst->codec, ctx->vc);
ctx->vcc = ctx->vst->codec;
#endif
// Using codec->time_base is deprecated, but needed for older lavf.
stream->time_base = ctx->timebase;
stream->codec->time_base = ctx->timebase;
ctx->vst->time_base = ctx->timebase;
ctx->vcc->time_base = ctx->timebase;
ctx->voptions = NULL;
@@ -606,10 +620,12 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
if (ctx->avc->oformat->flags & AVFMT_GLOBALHEADER)
set_to_avdictionary(ctx, &ctx->voptions, "flags", "+global_header");
encode_2pass_prepare(ctx, &ctx->voptions, stream,
encode_2pass_prepare(ctx, &ctx->voptions, ctx->vst, ctx->vcc,
&ctx->twopass_bytebuffer_v,
"vo-lavc");
break;
*stream_out = ctx->vst;
*codec_out = ctx->vcc;
return 0;
case AVMEDIA_TYPE_AUDIO:
if (!ctx->ac) {
@@ -617,15 +633,20 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
ctx->options->acodec) {
encode_lavc_fail(ctx, "ao-lavc: encoder not found\n");
}
return NULL;
return -1;
}
avcodec_get_context_defaults3(stream->codec, ctx->ac);
#if HAVE_AVCODEC_HAS_CODECPAR
ctx->acc = avcodec_alloc_context3(ctx->ac);
#else
avcodec_get_context_defaults3(ctx->ast->codec, ctx->ac);
ctx->acc = ctx->ast->codec;
#endif
// Using codec->time_base is deprecated, but needed for older lavf.
stream->time_base = ctx->timebase;
stream->codec->time_base = ctx->timebase;
ctx->ast->time_base = ctx->timebase;
ctx->acc->time_base = ctx->timebase;
ctx->aoptions = NULL;
ctx->aoptions = 0;
if (ctx->options->aopts)
for (p = ctx->options->aopts; *p; ++p)
@@ -639,49 +660,34 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
if (ctx->avc->oformat->flags & AVFMT_GLOBALHEADER)
set_to_avdictionary(ctx, &ctx->aoptions, "flags", "+global_header");
encode_2pass_prepare(ctx, &ctx->aoptions, stream,
encode_2pass_prepare(ctx, &ctx->aoptions, ctx->ast, ctx->acc,
&ctx->twopass_bytebuffer_a,
"ao-lavc");
break;
default:
encode_lavc_fail(ctx, "requested invalid stream type\n");
return NULL;
*stream_out = ctx->ast;
*codec_out = ctx->acc;
return 0;
}
return stream;
// Unreachable.
return -1;
}
AVCodec *encode_lavc_get_codec(struct encode_lavc_context *ctx,
AVStream *stream)
{
CHECK_FAIL(ctx, NULL);
switch (stream->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
return ctx->vc;
case AVMEDIA_TYPE_AUDIO:
return ctx->ac;
default:
break;
}
return NULL;
}
int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream)
int encode_lavc_open_codec(struct encode_lavc_context *ctx,
AVCodecContext *codec)
{
AVDictionaryEntry *de;
int ret;
CHECK_FAIL(ctx, -1);
switch (stream->codec->codec_type) {
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
MP_INFO(ctx, "Opening video encoder: %s [%s]\n",
ctx->vc->long_name, ctx->vc->name);
if (ctx->vc->capabilities & CODEC_CAP_EXPERIMENTAL) {
stream->codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
MP_WARN(ctx, "\n\n"
" ********************************************\n"
" **** Experimental VIDEO codec selected! ****\n"
@@ -701,7 +707,11 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream)
ctx->vc->name);
}
ret = avcodec_open2(stream->codec, ctx->vc, &ctx->voptions);
ret = avcodec_open2(codec, ctx->vc, &ctx->voptions);
#if HAVE_AVCODEC_HAS_CODECPAR
if (ret >= 0)
ret = avcodec_parameters_from_context(ctx->vst->codecpar, codec);
#endif
// complain about all remaining options, then free the dict
for (de = NULL; (de = av_dict_get(ctx->voptions, "", de,
@@ -716,7 +726,7 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream)
ctx->ac->long_name, ctx->ac->name);
if (ctx->ac->capabilities & CODEC_CAP_EXPERIMENTAL) {
stream->codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
MP_WARN(ctx, "\n\n"
" ********************************************\n"
" **** Experimental AUDIO codec selected! ****\n"
@@ -735,7 +745,12 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream)
"If none of this helps you, try another codec in place of %s.\n\n",
ctx->ac->name);
}
ret = avcodec_open2(stream->codec, ctx->ac, &ctx->aoptions);
ret = avcodec_open2(codec, ctx->ac, &ctx->aoptions);
#if HAVE_AVCODEC_HAS_CODECPAR
if (ret >= 0)
ret = avcodec_parameters_from_context(ctx->ast->codecpar, codec);
#endif
// complain about all remaining options, then free the dict
for (de = NULL; (de = av_dict_get(ctx->aoptions, "", de,
@@ -757,36 +772,43 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream)
return ret;
}
void encode_lavc_write_stats(struct encode_lavc_context *ctx, AVStream *stream)
void encode_lavc_write_stats(struct encode_lavc_context *ctx,
AVCodecContext *codec)
{
CHECK_FAIL(ctx, );
switch (stream->codec->codec_type) {
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (ctx->twopass_bytebuffer_v)
if (stream->codec->stats_out)
if (codec->stats_out)
stream_write_buffer(ctx->twopass_bytebuffer_v,
stream->codec->stats_out,
strlen(stream->codec->stats_out));
codec->stats_out,
strlen(codec->stats_out));
break;
case AVMEDIA_TYPE_AUDIO:
if (ctx->twopass_bytebuffer_a)
if (stream->codec->stats_out)
if (codec->stats_out)
stream_write_buffer(ctx->twopass_bytebuffer_a,
stream->codec->stats_out,
strlen(stream->codec->stats_out));
codec->stats_out,
strlen(codec->stats_out));
break;
default:
break;
}
}
int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVPacket *packet)
int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVStream *stream,
AVPacket *packet)
{
int r;
CHECK_FAIL(ctx, -1);
if (stream->index != packet->stream_index) {
MP_ERR(ctx, "Called encode_lavc_write_frame on the wrong stream\n");
return -1;
}
if (ctx->header_written <= 0)
return -1;
@@ -795,27 +817,32 @@ int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVPacket *packet)
(int)packet->stream_index,
(int)packet->pts,
packet->pts
* (double)ctx->avc->streams[packet->stream_index]->time_base.num
/ (double)ctx->avc->streams[packet->stream_index]->time_base.den,
* (double)stream->time_base.num
/ (double)stream->time_base.den,
(int)packet->dts,
packet->dts
* (double)ctx->avc->streams[packet->stream_index]->time_base.num
/ (double)ctx->avc->streams[packet->stream_index]->time_base.den,
* (double)stream->time_base.num
/ (double)stream->time_base.den,
(int)packet->size);
switch (ctx->avc->streams[packet->stream_index]->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ctx->vbytes += packet->size;
++ctx->frames;
break;
case AVMEDIA_TYPE_AUDIO:
ctx->abytes += packet->size;
ctx->audioseconds += packet->duration
* (double)ctx->avc->streams[packet->stream_index]->time_base.num
/ (double)ctx->avc->streams[packet->stream_index]->time_base.den;
break;
default:
break;
#if HAVE_AVCODEC_HAS_CODECPAR
switch (stream->codecpar->codec_type) {
#else
switch (stream->codec->codec_type) {
#endif
case AVMEDIA_TYPE_VIDEO:
ctx->vbytes += packet->size;
++ctx->frames;
break;
case AVMEDIA_TYPE_AUDIO:
ctx->abytes += packet->size;
ctx->audioseconds += packet->duration
* (double)stream->time_base.num
/ (double)stream->time_base.den;
break;
default:
break;
}
r = av_interleaved_write_frame(ctx->avc, packet);
@@ -1062,11 +1089,12 @@ bool encode_lavc_showhelp(struct mp_log *log, struct encode_opts *opts)
return help_output;
}
double encode_lavc_getoffset(struct encode_lavc_context *ctx, AVStream *stream)
double encode_lavc_getoffset(struct encode_lavc_context *ctx,
AVCodecContext *codec)
{
CHECK_FAIL(ctx, 0);
switch (stream->codec->codec_type) {
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
return ctx->options->voffset;
case AVMEDIA_TYPE_AUDIO:
@@ -1151,49 +1179,49 @@ void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...)
}
bool encode_lavc_set_csp(struct encode_lavc_context *ctx,
AVStream *stream, enum mp_csp csp)
AVCodecContext *codec, enum mp_csp csp)
{
CHECK_FAIL(ctx, NULL);
if (ctx->header_written) {
if (stream->codec->colorspace != mp_csp_to_avcol_spc(csp))
if (codec->colorspace != mp_csp_to_avcol_spc(csp))
MP_WARN(ctx, "can not change color space during encoding\n");
return false;
}
stream->codec->colorspace = mp_csp_to_avcol_spc(csp);
codec->colorspace = mp_csp_to_avcol_spc(csp);
return true;
}
bool encode_lavc_set_csp_levels(struct encode_lavc_context *ctx,
AVStream *stream, enum mp_csp_levels lev)
AVCodecContext *codec, enum mp_csp_levels lev)
{
CHECK_FAIL(ctx, NULL);
if (ctx->header_written) {
if (stream->codec->color_range != mp_csp_levels_to_avcol_range(lev))
if (codec->color_range != mp_csp_levels_to_avcol_range(lev))
MP_WARN(ctx, "can not change color space during encoding\n");
return false;
}
stream->codec->color_range = mp_csp_levels_to_avcol_range(lev);
codec->color_range = mp_csp_levels_to_avcol_range(lev);
return true;
}
enum mp_csp encode_lavc_get_csp(struct encode_lavc_context *ctx,
AVStream *stream)
AVCodecContext *codec)
{
CHECK_FAIL(ctx, 0);
return avcol_spc_to_mp_csp(stream->codec->colorspace);
return avcol_spc_to_mp_csp(codec->colorspace);
}
enum mp_csp_levels encode_lavc_get_csp_levels(struct encode_lavc_context *ctx,
AVStream *stream)
AVCodecContext *codec)
{
CHECK_FAIL(ctx, 0);
return avcol_range_to_mp_csp_levels(stream->codec->color_range);
return avcol_range_to_mp_csp_levels(codec->color_range);
}
// vim: ts=4 sw=4 et
+22 -11
View File
@@ -46,8 +46,14 @@ struct encode_lavc_context {
float vo_fps;
// these are processed from the options
// FFmpeg contexts.
AVFormatContext *avc;
AVStream *vst;
AVStream *ast;
AVCodecContext *vcc;
AVCodecContext *acc;
// these are processed from the options
AVRational timebase;
AVCodec *vc;
AVCodec *ac;
@@ -88,26 +94,31 @@ struct encode_lavc_context {
};
// interface for vo/ao drivers
AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx, enum AVMediaType mt);
void encode_lavc_write_stats(struct encode_lavc_context *ctx, AVStream *stream);
int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVPacket *packet);
int encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
enum AVMediaType mt, AVStream **stream_out,
AVCodecContext **codec_out);
void encode_lavc_write_stats(struct encode_lavc_context *ctx,
AVCodecContext *stream);
int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVStream *stream,
AVPacket *packet);
int encode_lavc_supports_pixfmt(struct encode_lavc_context *ctx, enum AVPixelFormat format);
AVCodec *encode_lavc_get_codec(struct encode_lavc_context *ctx, AVStream *stream);
int encode_lavc_open_codec(struct encode_lavc_context *ctx, AVStream *stream);
int encode_lavc_open_codec(struct encode_lavc_context *ctx,
AVCodecContext *codec);
int encode_lavc_available(struct encode_lavc_context *ctx);
int encode_lavc_timesyncfailed(struct encode_lavc_context *ctx);
int encode_lavc_start(struct encode_lavc_context *ctx); // returns 1 on success
int encode_lavc_oformat_flags(struct encode_lavc_context *ctx);
double encode_lavc_getoffset(struct encode_lavc_context *ctx, AVStream *stream);
double encode_lavc_getoffset(struct encode_lavc_context *ctx,
AVCodecContext *codec);
void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...); // report failure of encoding
bool encode_lavc_set_csp(struct encode_lavc_context *ctx,
AVStream *stream, enum mp_csp csp);
AVCodecContext *codec, enum mp_csp csp);
bool encode_lavc_set_csp_levels(struct encode_lavc_context *ctx,
AVStream *stream, enum mp_csp_levels lev);
AVCodecContext *codec, enum mp_csp_levels lev);
enum mp_csp encode_lavc_get_csp(struct encode_lavc_context *ctx,
AVStream *stream);
AVCodecContext *codec);
enum mp_csp_levels encode_lavc_get_csp_levels(struct encode_lavc_context *ctx,
AVStream *stream);
AVCodecContext *codec);
#endif
+1
View File
@@ -1129,6 +1129,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
&params2, DEMUX_CHECK_FORCE);
if (sub)
return sub;
timeline_destroy(tl);
}
return demuxer;
}
+14 -14
View File
@@ -213,25 +213,25 @@ static void build_timeline(struct timeline *tl, struct tl_parts *parts)
resolve_timestamps(part, source);
double len = source_get_length(source);
if (len > 0) {
len += source->start_time;
} else {
MP_WARN(tl, "EDL: source file '%s' has unknown duration.\n",
part->filename);
}
double end_time = source_get_length(source);
if (end_time >= 0)
end_time += source->start_time;
// Unknown length => use rest of the file. If duration is unknown, make
// something up.
if (part->length < 0)
part->length = (len < 0 ? 1 : len) - part->offset;
if (len > 0) {
double partlen = part->offset + part->length;
if (partlen > len) {
if (part->length < 0) {
if (end_time < 0) {
MP_WARN(tl, "EDL: source file '%s' has unknown duration.\n",
part->filename);
end_time = 1;
}
part->length = end_time - part->offset;
} else if (end_time >= 0) {
double end_part = part->offset + part->length;
if (end_part > end_time) {
MP_WARN(tl, "EDL: entry %d uses %f "
"seconds, but file has only %f seconds.\n",
n, partlen, len);
n, end_part, end_time);
}
}
+6 -1
View File
@@ -795,6 +795,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
avfc->pb = priv->pb;
if (stream_control(priv->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
demuxer->seekable = true;
demuxer->seekable |= priv->format_hack.fully_read;
}
if (matches_avinputformat_name(priv, "rtsp")) {
@@ -1101,8 +1102,12 @@ static void demux_close_lavf(demuxer_t *demuxer)
av_freep(&priv->pb->buffer);
av_freep(&priv->pb);
for (int n = 0; n < priv->num_streams; n++) {
if (priv->streams[n])
if (priv->streams[n]) {
avcodec_free_context(&priv->streams[n]->codec->lav_headers);
#if HAVE_AVCODEC_HAS_CODECPAR
avcodec_parameters_free(&priv->streams[n]->codec->lav_codecpar);
#endif
}
}
if (priv->stream != demuxer->stream)
free_stream(priv->stream);
+9 -3
View File
@@ -773,8 +773,9 @@ static int demux_mkv_read_cues(demuxer_t *demuxer)
if (cues.n_cue_point <= 3) // probably too sparse and will just break seeking
goto done;
// Discard incremental index.
mkv_d->num_indexes = 0;
// Discard incremental index. (Keep the first entry, which must be the
// start of the file - helps with files that miss the first index entry.)
mkv_d->num_indexes = MPMIN(1, mkv_d->num_indexes);
mkv_d->index_has_durations = false;
for (int i = 0; i < cues.n_cue_point; i++) {
@@ -1719,6 +1720,7 @@ static const char *const mkv_sub_tag[][2] = {
{ "S_HDMV/PGS", "hdmv_pgs_subtitle"},
{ "D_WEBVTT/SUBTITLES", "webvtt-webm"},
{ "D_WEBVTT/CAPTIONS", "webvtt-webm"},
{ "S_TEXT/WEBVTT", "webvtt"},
{ "S_DVBSUB", "dvb_subtitle"},
{0}
};
@@ -2609,6 +2611,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block)
find_next_cluster:
mkv_d->cluster_end = 0;
for (;;) {
stream_peek(s, 4); // guarantee we can undo ebml_read_id() below
mkv_d->cluster_start = stream_tell(s);
uint32_t id = ebml_read_id(s);
if (id == MATROSKA_ID_CLUSTER)
@@ -2627,6 +2630,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block)
if ((!ebml_is_mkv_level1_id(id) && id != EBML_ID_VOID) ||
ebml_read_skip(demuxer->log, -1, s) != 0)
{
stream_seek(s, mkv_d->cluster_start);
ebml_resync_cluster(demuxer->log, s);
}
}
@@ -2963,8 +2967,10 @@ static void probe_first_timestamp(struct demuxer *demuxer)
return;
struct block_info block;
if (read_next_block(demuxer, &block) > 0)
if (read_next_block(demuxer, &block) > 0) {
index_block(demuxer, &block);
mkv_d->tmp_block = block;
}
demuxer->start_time = mkv_d->cluster_tc / 1e9;
+66 -19
View File
@@ -20,6 +20,7 @@
#include <strings.h>
#include <dirent.h>
#include "config.h"
#include "common/common.h"
#include "options/options.h"
#include "common/msg.h"
@@ -105,14 +106,21 @@ static int parse_m3u(struct pl_parser *p)
if (p->check_level == DEMUX_CHECK_UNSAFE) {
char *ext = mp_splitext(p->real_stream->url, NULL);
bstr data = stream_peek(p->real_stream, PROBE_SIZE);
if (ext && !strcmp(ext, "m3u") && data.len > 10 && maybe_text(data))
goto ok;
if (ext && data.len > 10 && maybe_text(data)) {
const char *exts[] = {"m3u", "m3u8", NULL};
for (int n = 0; exts[n]; n++) {
if (strcasecmp(ext, exts[n]) == 0)
goto ok;
}
}
}
return -1;
}
ok:
if (p->probing)
return 0;
char *title = NULL;
while (line.len || !pl_eof(p)) {
if (bstr_eatstart0(&line, "#EXTINF:")) {
@@ -209,6 +217,59 @@ static int parse_txt(struct pl_parser *p)
return 0;
}
#define MAX_DIR_STACK 20
static bool same_st(struct stat *st1, struct stat *st2)
{
return HAVE_POSIX && st1->st_dev == st2->st_dev && st1->st_ino == st2->st_ino;
}
// Return true if this was a readable directory.
static bool scan_dir(struct pl_parser *p, char *path,
struct stat *dir_stack, int num_dir_stack,
char ***files, int *num_files)
{
if (strlen(path) >= 8192 || num_dir_stack == MAX_DIR_STACK)
return false; // things like mount bind loops
DIR *dp = opendir(path);
if (!dp) {
MP_ERR(p, "Could not read directory.\n");
return false;
}
struct dirent *ep;
while ((ep = readdir(dp))) {
if (ep->d_name[0] == '.')
continue;
if (mp_cancel_test(p->s->cancel))
break;
char *file = mp_path_join(p, path, ep->d_name);
struct stat st;
if (stat(file, &st) == 0 && S_ISDIR(st.st_mode)) {
for (int n = 0; n < num_dir_stack; n++) {
if (same_st(&dir_stack[n], &st)) {
MP_VERBOSE(p, "Skip recursive entry: %s\n", file);
goto skip;
}
}
dir_stack[num_dir_stack] = st;
scan_dir(p, file, dir_stack, num_dir_stack + 1, files, num_files);
} else {
MP_TARRAY_APPEND(p, *files, *num_files, file);
}
skip: ;
}
closedir(dp);
return true;
}
static int cmp_filename(const void *a, const void *b)
{
return strcmp(*(char **)a, *(char **)b);
@@ -222,32 +283,18 @@ static int parse_dir(struct pl_parser *p)
return 0;
char *path = mp_file_get_path(p, bstr0(p->real_stream->url));
if (strlen(path) >= 8192)
return -1; // things like mount bind loops
DIR *dp = opendir(path);
if (!dp) {
MP_ERR(p, "Could not read directory.\n");
return -1;
}
char **files = NULL;
int num_files = 0;
struct stat dir_stack[MAX_DIR_STACK];
struct dirent *ep;
while ((ep = readdir(dp))) {
if (ep->d_name[0] == '.')
continue;
MP_TARRAY_APPEND(p, files, num_files, talloc_strdup(p, ep->d_name));
}
scan_dir(p, path, dir_stack, 0, &files, &num_files);
if (files)
qsort(files, num_files, sizeof(files[0]), cmp_filename);
for (int n = 0; n < num_files; n++)
playlist_add_file(p->pl, mp_path_join(p, path, files[n]));
closedir(dp);
playlist_add_file(p->pl, files[n]);
p->add_base = false;
+1 -1
View File
@@ -142,7 +142,7 @@
#CLOSE_WIN quit
#CLOSE_WIN {encode} quit 4
#E cycle edition # next edition
#l ab_loop # Set/clear A-B loop points
#l ab-loop # Set/clear A-B loop points
#L cycle-values loop "inf" "no" # toggle infinite looping
#ctrl+c quit 4
+1 -1
View File
@@ -79,7 +79,7 @@
#softvol=no
# Do not filter audio to keep pitch when changing playback speed.
audio-pitch-correction=no
#audio-pitch-correction=no
# Output 5.1 audio natively, and upmix/downmix audio with a different format.
#audio-channels=5.1
-1
View File
@@ -273,7 +273,6 @@ static struct mp_cmd *parse_cmd_str(struct mp_log *log, void *tmp,
break;
if (pctx_read_token(ctx, &cur_token) < 0)
goto error;
break;
}
if (!find_cmd(ctx->log, cmd, cur_token))
+1 -4
View File
@@ -1247,12 +1247,9 @@ void mp_input_load(struct input_ctx *ictx)
void *tmp = talloc_new(NULL);
char **files = mp_find_all_config_files(tmp, ictx->global, "input.conf");
for (int n = 0; files && files[n]; n++)
config_ok = config_ok | parse_config_file(ictx, files[n], false);
parse_config_file(ictx, files[n], false);
talloc_free(tmp);
}
if (!config_ok) {
MP_VERBOSE(ictx, "Falling back on default (hardcoded) input config\n");
}
if (input_conf->use_alt_gr) {
ictx->using_alt_gr = true;
+2 -2
View File
@@ -134,7 +134,7 @@ static void *client_thread(void *p)
if (fds[0].revents & POLLIN) {
char discard[100];
read(pipe_fd, discard, sizeof(discard));
(void)read(pipe_fd, discard, sizeof(discard));
while (1) {
mpv_event *event = mpv_wait_event(arg->client, 0);
@@ -413,7 +413,7 @@ void mp_uninit_ipc(struct mp_ipc_ctx *arg)
if (!arg)
return;
write(arg->death_pipe[1], &(char){0}, 1);
(void)write(arg->death_pipe[1], &(char){0}, 1);
pthread_join(arg->thread, NULL);
close(arg->death_pipe[0]);
+13 -3
View File
@@ -215,7 +215,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 20)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 21)
/**
* Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with.
@@ -780,6 +780,10 @@ void mpv_free_node_contents(mpv_node *node);
* mpv_set_property() to change settings during playback, because the property
* mechanism guarantees that changes take effect immediately.
*
* Using a format other than MPV_FORMAT_NODE is equivalent to constructing a
* mpv_node with the given format and data, and passing the mpv_node to this
* function.
*
* @param name Option name. This is the same as on the mpv command line, but
* without the leading "--".
* @param format see enum mpv_format.
@@ -877,7 +881,13 @@ int mpv_command_node_async(mpv_handle *ctx, uint64_t reply_userdata,
* usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data
* is automatically converted and access succeeds. For example, MPV_FORMAT_INT64
* is always converted to MPV_FORMAT_DOUBLE, and access using MPV_FORMAT_STRING
* usually invokes a string parser.
* usually invokes a string parser. The same happens when calling this function
* with MPV_FORMAT_NODE: the underlying format may be converted to another
* type if possible.
*
* Using a format other than MPV_FORMAT_NODE is equivalent to constructing a
* mpv_node with the given format and data, and passing the mpv_node to this
* function. (Before API version 1.21, this was different.)
*
* @param name The property name. See input.rst for a list of properties.
* @param format see enum mpv_format.
@@ -1436,7 +1446,7 @@ int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable);
* required log level for a message to be received with MPV_EVENT_LOG_MESSAGE.
*
* @param min_level Minimal log level as string. Valid log levels:
* no fatal error warn info status v debug trace
* no fatal error warn info v debug trace
* The value "no" disables all messages. This is the default.
* An exception is the value "terminal-default", which uses the
* log level as set by the "--msg-level" option. This works
+40 -3
View File
@@ -108,6 +108,28 @@ extern "C" {
* context must have been uninitialized. If this doesn't happen, undefined
* behavior will result.
*
* Hardware decoding
* -----------------
*
* Hardware decoding via opengl_cb is fully supported, but requires some
* additional setup. (At least if direct hardware decoding modes are wanted,
* instead of copying back surface data from GPU to CPU RAM.)
*
* While "normal" mpv loads the OpenGL hardware decoding interop on demand,
* this can't be done with opengl_cb for internal technical reasons. Instead,
* make it load the interop at load time by setting the "hwdec-preload"="auto"
* option before calling mpv_opengl_cb_init_gl().
*
* There may be certain requirements on the OpenGL implementation:
* - Windows: ANGLE is required (although in theory GL/DX interop could be used)
* - Intel/Linux: EGL is required, and also a glMPGetNativeDisplay() callback
* must be provided (see sections below)
* - nVidia/Linux: GLX is required
* - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL)
*
* Once these things are setup, hardware decoding can be enabled/disabled at
* any time by setting the "hwdec" property.
*
* Special windowing system interop considerations
* ------------------------------------------------
*
@@ -126,19 +148,34 @@ extern "C" {
* up until mpv_opengl_cb_uninit_gl() is called. If the name is not anything
* you know/expected, return NULL from the function.
*
* Windowing system interop on Linux
* ---------------------------------
* Windowing system interop on Intel/Linux with VAAPI
* --------------------------------------------------
*
* The new VAAPI OpenGL interop requires an EGL context. EGL provides no way
* to query the X11 Display associated to a specific EGL context, so this API
* is used to pass it through.
*
* glMPGetNativeDisplay("x11") should return a X11 "Display*", which then will
* be used to create the hardware decoder state. (On GLX, this is not needed.)
* be used to create the hardware decoder state.
*
* glMPGetNativeDisplay("wl") should return a Wayland "struct wl_display *".
*
* glMPGetNativeDisplay("drm") should return a DRM FD casted to intptr_t (note
* that a 0 FD is not supported - if this can happen in your case, you must
* dup2() it to a non-0 FD).
*
* nVidia/Linux via VDPAU requires GLX, which does not have this problem (the
* GLX API can return the current X11 Display).
*
* Windowing system interop on MS win32
* ------------------------------------
*
* Warning: the following is only required if native OpenGL instead of ANGLE
* is used. ANGLE is recommended, because it also allows direct
* hardware decoding interop without further setup by the libmpv
* API user, while the same with native OpenGL is either very hard
* to do (via GL/DX interop with D3D9), or not implemented.
*
* If OpenGL switches to fullscreen, most players give it access GPU access,
* which means DXVA2 hardware decoding in mpv won't work. This can be worked
* around by giving mpv access to Direct3D device, which it will then use to
+10 -2
View File
@@ -215,9 +215,9 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str)
return r;
}
struct bstr bstr_getline(struct bstr str, struct bstr *rest)
struct bstr bstr_splitchar(struct bstr str, struct bstr *rest, const char c)
{
int pos = bstrchr(str, '\n');
int pos = bstrchr(str, c);
if (pos < 0)
pos = str.len;
if (rest)
@@ -243,6 +243,14 @@ bool bstr_eatstart(struct bstr *s, struct bstr prefix)
return true;
}
bool bstr_eatend(struct bstr *s, struct bstr prefix)
{
if (!bstr_endswith(*s, prefix))
return false;
s->len -= prefix.len;
return true;
}
void bstr_lower(struct bstr str)
{
for (int i = 0; i < str.len; i++)
+18 -6
View File
@@ -116,10 +116,15 @@ int bstr_validate_utf8(struct bstr s);
// talloc, with talloc_ctx as parent.
struct bstr bstr_sanitize_utf8_latin1(void *talloc_ctx, struct bstr s);
// Return the text before the next line break, and return it. Change *rest to
// point to the text following this line break. (rest can be NULL.)
// Line break characters are not stripped.
struct bstr bstr_getline(struct bstr str, struct bstr *rest);
// Return the text before the occurrence of a character, and return it. Change
// *rest to point to the text following this character. (rest can be NULL.)
struct bstr bstr_splitchar(struct bstr str, struct bstr *rest, const char c);
// Like bstr_splitchar. Trailing newlines are not stripped.
static inline struct bstr bstr_getline(struct bstr str, struct bstr *rest)
{
return bstr_splitchar(str, rest, '\n');
}
// Strip one trailing line break. This is intended for use with bstr_getline,
// and will remove the trailing \n or \r\n sequence.
@@ -131,8 +136,10 @@ void bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...)
void bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, va_list va)
PRINTF_ATTRIBUTE(3, 0);
// If s starts with prefix, return true and return the rest of the string in s.
// If s starts/ends with prefix, return true and return the rest of the string
// in s.
bool bstr_eatstart(struct bstr *s, struct bstr prefix);
bool bstr_eatend(struct bstr *s, struct bstr prefix);
bool bstr_case_startswith(struct bstr s, struct bstr prefix);
bool bstr_case_endswith(struct bstr s, struct bstr suffix);
@@ -200,11 +207,16 @@ static inline int bstr_find0(struct bstr haystack, const char *needle)
return bstr_find(haystack, bstr0(needle));
}
static inline int bstr_eatstart0(struct bstr *s, const char *prefix)
static inline bool bstr_eatstart0(struct bstr *s, const char *prefix)
{
return bstr_eatstart(s, bstr0(prefix));
}
static inline bool bstr_eatend0(struct bstr *s, const char *prefix)
{
return bstr_eatend(s, bstr0(prefix));
}
// create a pair (not single value!) for "%.*s" printf syntax
#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
+44 -14
View File
@@ -358,6 +358,18 @@ static void add_options(struct m_config *config,
m_config_add_option(config, parent_name, optstruct, optstruct_def, &defs[i]);
}
// Initialize a field with a given value. In case this is dynamic data, it has
// to be allocated and copied. src can alias dst, also can be NULL.
static void init_opt_inplace(const struct m_option *opt, void *dst,
const void *src)
{
union m_option_value temp = {0};
if (src)
memcpy(&temp, src, opt->type->size);
memset(dst, 0, opt->type->size);
m_option_copy(opt, dst, &temp);
}
static void m_config_add_option(struct m_config *config,
const char *parent_name,
void *optstruct,
@@ -418,11 +430,7 @@ static void m_config_add_option(struct m_config *config,
assert(0);
}
}
// In case this is dynamic data, it has to be allocated and copied.
union m_option_value temp = {0};
memcpy(&temp, co.default_data, arg->type->size);
memset(co.data, 0, arg->type->size);
m_option_copy(arg, co.data, &temp);
init_opt_inplace(arg, co.data, co.default_data);
}
}
@@ -491,6 +499,13 @@ struct m_config_option *m_config_get_co(const struct m_config *config,
co->warning_was_printed = true;
}
return NULL;
} else if (co->opt->deprecation_message) {
if (!co->warning_was_printed) {
MP_WARN(config, "Warning: option %s%s is deprecated "
"and might be removed in the future (%s).\n",
prefix, co->name, co->opt->deprecation_message);
co->warning_was_printed = true;
}
}
return co;
}
@@ -942,24 +957,39 @@ static void free_substruct(void *ptr)
}
}
// Passing ptr==NULL initializes it from proper defaults.
void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts,
const void *ptr)
{
void *new = talloc_zero_size(talloc_ctx, opts->size);
void *new = m_config_alloc_struct(talloc_ctx, opts);
struct dtor_info *dtor = talloc_ptrtype(new, dtor);
*dtor = (struct dtor_info){opts, new};
talloc_set_destructor(dtor, free_substruct);
// also fill/initialize members not described by opts
if (opts->defaults)
memcpy(new, opts->defaults, opts->size);
for (int n = 0; opts->opts && opts->opts[n].type; n++) {
const struct m_option *opt = &opts->opts[n];
// not implemented, because it adds lots of complexity
assert(!(opt->type->flags & M_OPT_TYPE_HAS_CHILD));
void *src = (char *)ptr + opt->offset;
if (opt->offset < 0)
continue;
void *src = ptr ? (char *)ptr + opt->offset : NULL;
void *dst = (char *)new + opt->offset;
memset(dst, 0, opt->type->size);
m_option_copy(opt, dst, src);
if (opt->type->flags & M_OPT_TYPE_HAS_CHILD) {
// Specifying a default struct for a sub-option field in the
// containing struct's default struct is not supported here.
// (Out of laziness. Could possibly be supported.)
assert(!substruct_read_ptr(dst));
const struct m_sub_options *subopts = opt->priv;
const void *sub_src = NULL;
if (src)
sub_src = substruct_read_ptr(src);
if (!sub_src)
sub_src = subopts->defaults;
void *sub_dst = m_sub_options_copy(new, subopts, sub_src);
substruct_write_ptr(dst, sub_dst);
} else {
init_opt_inplace(opt, dst, src);
}
}
return new;
}
+43 -3
View File
@@ -106,6 +106,21 @@ const m_option_t *m_option_list_find(const m_option_t *list, const char *name)
return m_option_list_findb(list, bstr0(name));
}
int m_option_set_node_or_string(struct mp_log *log, const m_option_t *opt,
const char *name, void *dst, struct mpv_node *src)
{
if (src->format == MPV_FORMAT_STRING) {
// The af and vf option unfortunately require this, because the
// option name includes the "action".
bstr optname = bstr0(name), a, b;
if (bstr_split_tok(optname, "/", &a, &b))
optname = b;
return m_option_parse(log, opt, optname, bstr0(src->u.string), dst);
} else {
return m_option_set_node(opt, dst, src);
}
}
// Default function that just does a memcpy
static void copy_opt(const m_option_t *opt, void *dst, const void *src)
@@ -657,6 +672,8 @@ static int choice_set(const m_option_t *opt, void *dst, struct mpv_node *src)
src_str = buf;
} else if (src->format == MPV_FORMAT_STRING) {
src_str = src->u.string;
} else if (src->format == MPV_FORMAT_FLAG) {
src_str = src->u.flag ? "yes" : "no";
}
if (!src_str)
return M_OPT_UNKNOWN;
@@ -698,8 +715,19 @@ static int choice_get(const m_option_t *opt, void *ta_parent,
alt = NULL;
}
if (alt) {
dst->format = MPV_FORMAT_STRING;
dst->u.string = talloc_strdup(ta_parent, alt->name);
int b = -1;
if (strcmp(alt->name, "yes") == 0) {
b = 1;
} else if (strcmp(alt->name, "no") == 0) {
b = 0;
}
if (b >= 0) {
dst->format = MPV_FORMAT_FLAG;
dst->u.flag = b;
} else {
dst->format = MPV_FORMAT_STRING;
dst->u.string = talloc_strdup(ta_parent, alt->name);
}
} else {
dst->format = MPV_FORMAT_INT64;
dst->u.int64 = ival;
@@ -1654,7 +1682,7 @@ static int parse_msglevels(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst)
{
if (bstr_equals0(param, "help")) {
mp_info(log, "Syntax: --msglevel=module1=level:module2=level:...\n"
mp_info(log, "Syntax:\n\n --msglevel=module1=level,module2=level,...\n\n"
"'module' is output prefix as shown with -v, or a prefix\n"
"of it. level is one of:\n\n"
" fatal error warn info status v debug trace\n\n"
@@ -2061,6 +2089,10 @@ void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
} else if (!(gm->w > 0) && gm->h > 0) {
*widw = *widh * asp;
}
// Center window after resize. If valid x:y values are passed to
// geometry, then those values will be overriden.
*xpos += prew / 2 - *widw / 2;
*ypos += preh / 2 - *widh / 2;
}
if (gm->xy_valid) {
@@ -2287,10 +2319,18 @@ static int parse_chmap(struct mp_log *log, const m_option_t *opt,
return 1;
}
static char *print_chmap(const m_option_t *opt, const void *val)
{
const struct mp_chmap *chmap = val;
return talloc_strdup(NULL, mp_chmap_to_str(chmap));
}
const m_option_type_t m_option_type_chmap = {
.name = "Audio channels or channel map",
.size = sizeof(struct mp_chmap),
.parse = parse_chmap,
.print = print_chmap,
.copy = copy_opt,
};
+9 -1
View File
@@ -333,6 +333,10 @@ struct m_option {
// Initialize variable to given default before parsing options
const void *defval;
// Print a warning when this option is used (for options with no direct
// replacement.)
const char *deprecation_message;
};
@@ -394,7 +398,7 @@ struct m_option {
// Dynamic data type.
/** This flag indicates that the data is dynamically allocated (m_option::p
* points to a pointer). It enables a little hack in the \ref Config wich
* points to a pointer). It enables a little hack in the \ref Config which
* replaces the initial value of such variables with a dynamic copy in case
* the initial value is statically allocated (pretty common with strings).
*/
@@ -504,6 +508,10 @@ static inline int m_option_set_node(const m_option_t *opt, void *dst,
return M_OPT_UNKNOWN;
}
// Call m_option_parse for strings, m_option_set_node otherwise.
int m_option_set_node_or_string(struct mp_log *log, const m_option_t *opt,
const char *name, void *dst, struct mpv_node *src);
// see m_option_type.get
static inline int m_option_get_node(const m_option_t *opt, void *ta_parent,
struct mpv_node *dst, void *src)
+5 -12
View File
@@ -104,16 +104,8 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
return str != NULL;
}
case M_PROPERTY_SET_STRING: {
if (!log)
return M_PROPERTY_ERROR;
bstr optname = bstr0(name), a, b;
if (bstr_split_tok(optname, "/", &a, &b))
optname = b;
if (m_option_parse(log, &opt, optname, bstr0(arg), &val) < 0)
return M_PROPERTY_ERROR;
r = do_action(prop_list, name, M_PROPERTY_SET, &val, ctx);
m_option_free(&opt, &val);
return r;
struct mpv_node node = { .format = MPV_FORMAT_STRING, .u.string = arg };
return m_property_do(log, prop_list, name, M_PROPERTY_SET_NODE, &node, ctx);
}
case M_PROPERTY_SWITCH: {
if (!log)
@@ -163,11 +155,12 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
return r;
}
case M_PROPERTY_SET_NODE: {
if (!log)
return M_PROPERTY_ERROR;
if ((r = do_action(prop_list, name, M_PROPERTY_SET_NODE, arg, ctx)) !=
M_PROPERTY_NOT_IMPLEMENTED)
return r;
struct mpv_node *node = arg;
int err = m_option_set_node(&opt, &val, node);
int err = m_option_set_node_or_string(log, &opt, name, &val, arg);
if (err == M_OPT_UNKNOWN) {
r = M_PROPERTY_NOT_IMPLEMENTED;
} else if (err < 0) {
+2
View File
@@ -184,6 +184,8 @@ struct m_sub_property {
// Convenience macros which can be used as part of a sub_property entry.
#define SUB_PROP_INT(i) \
.type = {.type = CONF_TYPE_INT}, .value = {.int_ = (i)}
#define SUB_PROP_INT64(i) \
.type = {.type = CONF_TYPE_INT64}, .value = {.int64 = (i)}
#define SUB_PROP_STR(s) \
.type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
#define SUB_PROP_FLOAT(f) \
+19 -10
View File
@@ -82,12 +82,14 @@ extern const struct m_obj_list ao_obj_list;
const struct m_opt_choice_alternatives mp_hwdec_names[] = {
{"no", HWDEC_NONE},
{"auto", HWDEC_AUTO},
{"auto-copy", HWDEC_AUTO_COPY},
{"vdpau", HWDEC_VDPAU},
{"videotoolbox",HWDEC_VIDEOTOOLBOX},
{"vaapi", HWDEC_VAAPI},
{"vaapi-copy", HWDEC_VAAPI_COPY},
{"dxva2", HWDEC_DXVA2},
{"dxva2-copy", HWDEC_DXVA2_COPY},
{"d3d11va", HWDEC_D3D11VA},
{"d3d11va-copy",HWDEC_D3D11VA_COPY},
{"rpi", HWDEC_RPI},
{"mediacodec", HWDEC_MEDIACODEC},
@@ -373,7 +375,7 @@ const m_option_t mp_opts[] = {
OPT_CHOICE("ass-shaper", ass_shaper, 0,
({"simple", 0}, {"complex", 1})),
OPT_CHOICE("ass-style-override", ass_style_override, 0,
({"no", 0}, {"yes", 1}, {"force", 3}, {"signfs", 4})),
({"no", 0}, {"yes", 1}, {"force", 3}, {"signfs", 4}, {"strip", 5})),
OPT_FLAG("sub-scale-by-window", sub_scale_by_window, 0),
OPT_FLAG("sub-scale-with-window", sub_scale_with_window, 0),
OPT_FLAG("ass-scale-with-window", ass_scale_with_window, 0),
@@ -396,8 +398,10 @@ const m_option_t mp_opts[] = {
OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0),
OPT_CHOICE("force-window", force_vo, 0,
({"no", 0}, {"yes", 1}, {"immediate", 2})),
OPT_FLAG("taskbar-progress", vo.taskbar_progress, 0),
OPT_FLAG("ontop", vo.ontop, M_OPT_FIXED),
OPT_FLAG("border", vo.border, M_OPT_FIXED),
OPT_FLAG("fit-border", vo.fit_border, M_OPT_FIXED),
OPT_FLAG("on-all-workspaces", vo.all_workspaces, M_OPT_FIXED),
OPT_FLAG("window-dragging", allow_win_drag, CONF_GLOBAL),
@@ -406,13 +410,13 @@ const m_option_t mp_opts[] = {
({"no", SOFTVOL_NO},
{"yes", SOFTVOL_YES},
{"auto", SOFTVOL_AUTO})),
OPT_FLOATRANGE("softvol-max", softvol_max, 0, 100, 1000),
OPT_FLOATRANGE("volume", mixer_init_volume, 0, -1, 1000),
OPT_CHOICE("mute", mixer_init_mute, 0,
OPT_FLOATRANGE("volume-max", softvol_max, 0, 100, 1000),
// values <0 for volume and mute are legacy and ignored
OPT_FLOATRANGE("volume", softvol_volume, 0, -1, 1000),
OPT_CHOICE("mute", softvol_mute, 0,
({"auto", -1},
{"no", 0},
{"yes", 1})),
OPT_STRING("volume-restore-data", mixer_restore_volume_data, 0),
OPT_CHOICE("gapless-audio", gapless_audio, 0,
({"no", 0},
{"yes", 1},
@@ -458,13 +462,15 @@ const m_option_t mp_opts[] = {
#if HAVE_X11
OPT_CHOICE("x11-netwm", vo.x11_netwm, 0,
({"auto", 0}, {"no", -1}, {"yes", 1})),
OPT_FLAG("x11-bypass-compositor", vo.x11_bypass_compositor, 0),
OPT_CHOICE("x11-bypass-compositor", vo.x11_bypass_compositor, 0,
({"no", 0}, {"yes", 1}, {"fs-only", 2}, {"never", 3})),
#endif
#if HAVE_WIN32
OPT_STRING("vo-mmcss-profile", vo.mmcss_profile, M_OPT_FIXED),
#endif
OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0),
OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0,
.deprecation_message = "use Lua scripting instead"),
OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0),
OPT_CHOICE_OR_INT("screen", vo.screen_id, 0, 0, 32,
@@ -679,6 +685,7 @@ const m_option_t mp_opts[] = {
OPT_REPLACED("ass-use-margins", "sub-use-margins"),
OPT_REPLACED("media-title", "force-media-title"),
OPT_REPLACED("input-unix-socket", "input-ipc-server"),
OPT_REPLACED("softvol-max", "volume-max"),
{0}
};
@@ -692,8 +699,8 @@ const struct MPOpts mp_default_opts = {
.deinterlace = -1,
.softvol = SOFTVOL_AUTO,
.softvol_max = 130,
.mixer_init_volume = -1,
.mixer_init_mute = -1,
.softvol_volume = 100,
.softvol_mute = 0,
.gapless_audio = -1,
.audio_buffer = 0.2,
.audio_device = "auto",
@@ -706,10 +713,12 @@ const struct MPOpts mp_default_opts = {
.panscan = 0.0f,
.keepaspect = 1,
.keepaspect_window = 1,
.taskbar_progress = 1,
.border = 1,
.fit_border = 1,
.WinID = -1,
.window_scale = 1.0,
.x11_bypass_compositor = 0,
.x11_bypass_compositor = 2,
.mmcss_profile = "Playback",
},
.allow_win_drag = 1,
+4 -3
View File
@@ -9,9 +9,11 @@
typedef struct mp_vo_opts {
struct m_obj_settings *video_driver_list, *vo_defs;
int taskbar_progress;
int ontop;
int fullscreen;
int border;
int fit_border;
int all_workspaces;
int screen_id;
@@ -87,9 +89,8 @@ typedef struct MPOpts {
int ao_null_fallback;
int force_vo;
int softvol;
float mixer_init_volume;
int mixer_init_mute;
char *mixer_restore_volume_data;
float softvol_volume;
int softvol_mute;
float softvol_max;
int gapless_audio;
double audio_buffer;
+2 -2
View File
@@ -74,7 +74,7 @@
typedef enum
{
kHIDRemoteModeNone = 0L,
kHIDRemoteModeShared, // Share the remote with others - let's you listen to the remote control events as long as noone has an exclusive lock on it
kHIDRemoteModeShared, // Share the remote with others - let's you listen to the remote control events as long as no one has an exclusive lock on it
// (RECOMMENDED ONLY FOR SPECIAL PURPOSES)
kHIDRemoteModeExclusive, // Try to acquire an exclusive lock on the remote (NOT RECOMMENDED)
@@ -182,7 +182,7 @@ typedef enum
- (BOOL)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware is inspected
inspectNewHardwareWithService:(io_service_t)service //
prematchResult:(BOOL)prematchResult; // Return YES if HIDRemote should go on with this hardware and try
// to use it, or NO if it should not be persued further.
// to use it, or NO if it should not be pursued further.
// Exlusive lock lending
- (BOOL)hidRemote:(HIDRemote *)hidRemote
+3 -3
View File
@@ -293,7 +293,7 @@ static HIDRemote *sHIDRemote = nil;
}while(0);
// An error occured. Do necessary clean up.
// An error occurred. Do necessary clean up.
if (matchDict!=NULL)
{
CFRelease(matchDict);
@@ -1422,7 +1422,7 @@ static HIDRemote *sHIDRemote = nil;
[((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self failedNewHardwareWithError:error];
}
// An error occured or this device is not of interest .. cleanup ..
// An error occurred or this device is not of interest .. cleanup ..
if (serviceNotification!=0)
{
IOObjectRelease(serviceNotification);
@@ -1615,7 +1615,7 @@ static HIDRemote *sHIDRemote = nil;
switch (buttonCode)
{
case kHIDRemoteButtonCodeIDChanged:
// Do nothing, this is handled seperately
// Do nothing, this is handled separately
break;
case kHIDRemoteButtonCodeUp:
+4
View File
@@ -45,6 +45,10 @@ static void *run_subprocess(void *ptr)
return NULL;
}
void mp_devnull(void *ctx, char *data, size_t size)
{
}
void mp_subprocess_detached(struct mp_log *log, char **args)
{
struct subprocess_args *p = talloc_zero(NULL, struct subprocess_args);
+2
View File
@@ -24,6 +24,8 @@ struct mp_cancel;
typedef void (*subprocess_read_cb)(void *ctx, char *data, size_t size);
void mp_devnull(void *ctx, char *data, size_t size);
// Start a subprocess. Uses callbacks to read from stdout and stderr.
int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx,
subprocess_read_cb on_stdout, subprocess_read_cb on_stderr,
+3 -3
View File
@@ -275,7 +275,7 @@ static void enable_kx(bool enable)
// shouldn't be relied on here either.
if (isatty(STDOUT_FILENO)) {
char *cmd = enable ? "\033=" : "\033>";
write(STDOUT_FILENO, cmd, strlen(cmd));
(void)write(STDOUT_FILENO, cmd, strlen(cmd));
}
}
@@ -378,7 +378,7 @@ static void quit_request_sighandler(int signum)
{
do_deactivate_getch2();
write(death_pipe[1], &(char){0}, 1);
(void)write(death_pipe[1], &(char){0}, 1);
}
static void *terminal_thread(void *ptr)
@@ -450,7 +450,7 @@ void terminal_uninit(void)
do_deactivate_getch2();
if (input_ctx) {
write(death_pipe[1], &(char){0}, 1);
(void)write(death_pipe[1], &(char){0}, 1);
pthread_join(input_thread, NULL);
close(death_pipe[0]);
close(death_pipe[1]);
+9 -7
View File
@@ -25,19 +25,21 @@
int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
typedef struct {
char static_mutex;
INIT_ONCE static_init;
CRITICAL_SECTION cs;
char use_cs;
union {
SRWLOCK srw;
CRITICAL_SECTION cs;
} lock;
} pthread_mutex_t;
#define PTHREAD_MUTEX_INITIALIZER {1, INIT_ONCE_STATIC_INIT}
// Assume SRWLOCK_INIT is {0} so we can easily remain C89-compatible.
#define PTHREAD_MUTEX_INITIALIZER {0}
#define pthread_mutexattr_t int
#define pthread_mutexattr_destroy(attr) (void)0
#define pthread_mutexattr_init(attr) (*(attr) = 0)
#define pthread_mutexattr_settype(attr, type) (void)0
// CRITICAL_SECTION is always recursive
#define PTHREAD_MUTEX_RECURSIVE 0
#define pthread_mutexattr_settype(attr, type) (*(attr) = (type))
#define PTHREAD_MUTEX_RECURSIVE 1
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_init(pthread_mutex_t *restrict mutex,
+24 -13
View File
@@ -32,35 +32,40 @@ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
DeleteCriticalSection(&mutex->cs);
if (mutex->use_cs)
DeleteCriticalSection(&mutex->lock.cs);
return 0;
}
int pthread_mutex_init(pthread_mutex_t *restrict mutex,
const pthread_mutexattr_t *restrict attr)
{
InitializeCriticalSection(&mutex->cs);
mutex->use_cs = attr && (*attr & PTHREAD_MUTEX_RECURSIVE);
if (mutex->use_cs) {
InitializeCriticalSection(&mutex->lock.cs);
} else {
InitializeSRWLock(&mutex->lock.srw);
}
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
if (mutex->static_mutex) {
BOOL pending;
if (!InitOnceBeginInitialize(&mutex->static_init, 0, &pending, NULL))
abort();
if (pending) {
InitializeCriticalSection(&mutex->cs);
InitOnceComplete(&mutex->static_init, 0, NULL);
}
if (mutex->use_cs) {
EnterCriticalSection(&mutex->lock.cs);
} else {
AcquireSRWLockExclusive(&mutex->lock.srw);
}
EnterCriticalSection(&mutex->cs);
return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
LeaveCriticalSection(&mutex->cs);
if (mutex->use_cs) {
LeaveCriticalSection(&mutex->lock.cs);
} else {
ReleaseSRWLockExclusive(&mutex->lock.srw);
}
return 0;
}
@@ -68,7 +73,13 @@ static int cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
DWORD ms)
{
return SleepConditionVariableCS(cond, &mutex->cs, ms) ? 0 : ETIMEDOUT;
BOOL res;
if (mutex->use_cs) {
res = SleepConditionVariableCS(cond, &mutex->lock.cs, ms);
} else {
res = SleepConditionVariableSRW(cond, &mutex->lock.srw, ms, 0);
}
return res ? 0 : ETIMEDOUT;
}
int pthread_cond_timedwait(pthread_cond_t *restrict cond,
+11 -6
View File
@@ -132,7 +132,7 @@ static int recreate_audio_filters(struct MPContext *mpctx)
if (afs->initialized < 1 && af_init(afs) < 0)
goto fail;
mixer_reinit_audio(mpctx->mixer, mpctx->ao, afs);
mixer_reinit_audio(mpctx->mixer, afs);
mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
@@ -886,13 +886,18 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
assert(mpctx->audio_status >= STATUS_FILLING);
// We already have as much data as the audio device wants, and can start
// writing it any time.
if (mpctx->audio_status == STATUS_FILLING)
mpctx->audio_status = STATUS_READY;
// Even if we're done decoding and syncing, let video start first - this is
// required, because sending audio to the AO already starts playback.
if (mpctx->audio_status == STATUS_FILLING && mpctx->vo_chain &&
!mpctx->vo_chain->is_coverart && mpctx->video_status <= STATUS_READY)
{
mpctx->audio_status = STATUS_READY;
return;
if (mpctx->audio_status == STATUS_READY) {
if (mpctx->vo_chain && !mpctx->vo_chain->is_coverart &&
mpctx->video_status <= STATUS_READY)
return;
MP_VERBOSE(mpctx, "starting audio playback\n");
}
bool audio_eof = status == AD_EOF;
+12 -36
View File
@@ -280,7 +280,7 @@ static void wakeup_client(struct mpv_handle *ctx)
if (ctx->wakeup_cb)
ctx->wakeup_cb(ctx->wakeup_cb_ctx);
if (ctx->wakeup_pipe[0] != -1)
write(ctx->wakeup_pipe[1], &(char){0}, 1);
(void)write(ctx->wakeup_pipe[1], &(char){0}, 1);
}
pthread_mutex_unlock(&ctx->wakeup_lock);
}
@@ -1071,42 +1071,18 @@ static void setproperty_fn(void *arg)
struct setproperty_request *req = arg;
const struct m_option *type = get_mp_type(req->format);
int err;
switch (req->format) {
case MPV_FORMAT_STRING: {
// Go through explicit string conversion. M_PROPERTY_SET_NODE doesn't
// do this, because it tries to be somewhat type-strict. But the client
// needs a way to set everything by string.
char *s = *(char **)req->data;
MP_VERBOSE(req->mpctx, "Set property string: %s='%s'\n", req->name, s);
err = mp_property_do(req->name, M_PROPERTY_SET_STRING, s, req->mpctx);
break;
}
case MPV_FORMAT_NODE:
case MPV_FORMAT_FLAG:
case MPV_FORMAT_INT64:
case MPV_FORMAT_DOUBLE: {
struct mpv_node node;
if (req->format == MPV_FORMAT_NODE) {
node = *(struct mpv_node *)req->data;
} else {
// These are basically emulated via mpv_node.
node.format = req->format;
memcpy(&node.u, req->data, type->type->size);
}
if (mp_msg_test(req->mpctx->log, MSGL_V)) {
struct m_option ot = {.type = &m_option_type_node};
char *t = m_option_print(&ot, &node);
MP_VERBOSE(req->mpctx, "Set property: %s=%s\n", req->name, t ? t : "?");
talloc_free(t);
}
err = mp_property_do(req->name, M_PROPERTY_SET_NODE, &node, req->mpctx);
break;
}
default:
abort();
struct mpv_node *node;
struct mpv_node tmp;
if (req->format == MPV_FORMAT_NODE) {
node = req->data;
} else {
tmp.format = req->format;
memcpy(&tmp.u, req->data, type->type->size);
node = &tmp;
}
int err = mp_property_do(req->name, M_PROPERTY_SET_NODE, node, req->mpctx);
req->status = translate_property_error(err);
if (req->reply_ctx) {
@@ -1583,7 +1559,7 @@ int mpv_get_wakeup_pipe(mpv_handle *ctx)
pthread_mutex_lock(&ctx->wakeup_lock);
if (ctx->wakeup_pipe[0] == -1) {
if (mp_make_wakeup_pipe(ctx->wakeup_pipe) >= 0)
write(ctx->wakeup_pipe[1], &(char){0}, 1);
(void)write(ctx->wakeup_pipe[1], &(char){0}, 1);
}
int fd = ctx->wakeup_pipe[0];
pthread_mutex_unlock(&ctx->wakeup_lock);
+367 -212
View File
@@ -60,6 +60,7 @@
#include "audio/filter/af.h"
#include "video/decode/dec_video.h"
#include "audio/decode/dec_audio.h"
#include "video/out/bitmap_packer.h"
#include "options/path.h"
#include "screenshot.h"
@@ -88,7 +89,8 @@ struct command_ctx {
// One of these is in use by the OSD; the other one exists so that the
// bitmap list can be manipulated without additional synchronization.
struct sub_bitmaps overlay_osd[2];
struct sub_bitmaps *overlay_osd_current;
int overlay_osd_current;
struct bitmap_packer *overlay_packer;
struct hook_handler **hooks;
int num_hooks;
@@ -98,9 +100,8 @@ struct command_ctx {
};
struct overlay {
void *map_start;
size_t map_size;
struct sub_bitmap osd;
struct mp_image *source;
int x, y;
};
struct hook_handler {
@@ -112,6 +113,13 @@ struct hook_handler {
bool active; // hook is currently in progress (only 1 at a time for now)
};
// U+279C HEAVY ROUND-TIPPED RIGHTWARDS ARROW
// U+00A0 NO-BREAK SPACE
#define ARROW_SP "\342\236\234\302\240"
const char list_current[] = OSD_ASS_0 ARROW_SP OSD_ASS_1;
const char list_normal[] = OSD_ASS_0 "{\\alpha&HFF}" ARROW_SP "{\\r}" OSD_ASS_1;
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
enum stream_type mediatype,
const char *cmd, const char *arg);
@@ -870,10 +878,8 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop,
char* time = mp_format_time(t, false);
res = talloc_asprintf_append(res, "%s", time);
talloc_free(time);
char *m1 = "> ", *m2 = " <";
if (n != cur)
m1 = m2 = "";
res = talloc_asprintf_append(res, " %s%s%s\n", m1, name, m2);
const char *m = n == cur ? list_current : list_normal;
res = talloc_asprintf_append(res, " %s%s\n", m, name);
talloc_free(name);
}
@@ -964,16 +970,13 @@ static int property_list_editions(void *ctx, struct m_property *prop,
for (int n = 0; n < num_editions; n++) {
struct demux_edition *ed = &editions[n];
if (n == current)
res = talloc_asprintf_append(res, "> ");
res = talloc_strdup_append(res, n == current ? list_current
: list_normal);
res = talloc_asprintf_append(res, "%d: ", n);
char *title = mp_tags_get_str(ed->metadata, "title");
if (!title)
title = "unnamed";
res = talloc_asprintf_append(res, "'%s' ", title);
if (n == current)
res = talloc_asprintf_append(res, "<");
res = talloc_asprintf_append(res, "\n");
res = talloc_asprintf_append(res, "'%s'\n", title);
}
*(char **)arg = res;
@@ -1518,10 +1521,10 @@ static int mp_property_cache_buffering(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
double state = get_cache_buffering_percentage(mpctx);
int state = get_cache_buffering_percentage(mpctx);
if (state < 0)
return M_PROPERTY_UNAVAILABLE;
return m_property_int_ro(action, arg, state * 100);
return m_property_int_ro(action, arg, state);
}
static int mp_property_clock(void *ctx, struct m_property *prop,
@@ -1566,44 +1569,29 @@ static int mp_property_volume(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct MPOpts *opts = mpctx->opts;
switch (action) {
case M_PROPERTY_GET:
mixer_getbothvolume(mpctx->mixer, arg);
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){
.type = CONF_TYPE_FLOAT,
.flags = M_OPT_RANGE,
.min = 0,
.max = mixer_getmaxvolume(mpctx->mixer),
.max = opts->softvol_max,
};
return M_PROPERTY_OK;
case M_PROPERTY_GET_NEUTRAL:
*(float *)arg = 100;
return M_PROPERTY_OK;
case M_PROPERTY_PRINT: {
float val;
mixer_getbothvolume(mpctx->mixer, &val);
*(char **)arg = talloc_asprintf(NULL, "%i", (int)val);
case M_PROPERTY_PRINT:
*(char **)arg = talloc_asprintf(NULL, "%i", (int)opts->softvol_volume);
return M_PROPERTY_OK;
}
case M_PROPERTY_SET:
mixer_setvolume(mpctx->mixer, *(float *) arg, *(float *) arg);
return M_PROPERTY_OK;
case M_PROPERTY_SWITCH: {
struct m_property_switch_arg *sarg = arg;
mixer_addvolume(mpctx->mixer, sarg->inc);
return M_PROPERTY_OK;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_volume_max(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
return m_property_float_ro(action, arg, mixer_getmaxvolume(mpctx->mixer));
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET)
mixer_update_volume(mpctx->mixer);
return r;
}
/// Mute (RW)
@@ -1611,34 +1599,76 @@ static int mp_property_mute(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
switch (action) {
case M_PROPERTY_SET:
mixer_setmute(mpctx->mixer, *(int *) arg);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
*(int *)arg = mixer_getmute(mpctx->mixer);
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE:
if (action == M_PROPERTY_GET_TYPE) {
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLAG};
return M_PROPERTY_OK;
}
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET)
mixer_update_volume(mpctx->mixer);
return r;
}
static int mp_property_ao_volume(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct ao *ao = mpctx->ao;
if (!ao)
return M_PROPERTY_NOT_IMPLEMENTED;
switch (action) {
case M_PROPERTY_SET: {
float value = *(float *)arg;
ao_control_vol_t vol = {value, value};
if (ao_control(ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
return M_PROPERTY_OK;
}
case M_PROPERTY_GET: {
ao_control_vol_t vol = {0};
if (ao_control(ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
*(float *)arg = (vol.left + vol.right) / 2.0f;
return M_PROPERTY_OK;
}
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLOAT};
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_volrestore(void *ctx, struct m_property *prop,
int action, void *arg)
static int mp_property_ao_mute(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
switch (action) {
case M_PROPERTY_GET: {
char *s = mixer_get_volume_restore_data(mpctx->mixer);
*(char **)arg = s;
return s ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
}
case M_PROPERTY_SET:
struct ao *ao = mpctx->ao;
if (!ao)
return M_PROPERTY_NOT_IMPLEMENTED;
switch (action) {
case M_PROPERTY_SET: {
bool value = *(int *)arg;
if (ao_control(ao, AOCONTROL_SET_MUTE, &value) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);
case M_PROPERTY_GET: {
bool value = false;
if (ao_control(ao, AOCONTROL_GET_MUTE, &value) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
*(int *)arg = value;
return M_PROPERTY_OK;
}
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLAG};
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int get_device_entry(int item, int action, void *arg, void *ctx)
@@ -2033,8 +2063,8 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
res = talloc_asprintf_append(res, "%s: ",
track_type_name(track->type));
if (track->selected)
res = talloc_asprintf_append(res, "> ");
res = talloc_strdup_append(res,
track->selected ? list_current : list_normal);
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
if (track->title)
res = talloc_asprintf_append(res, "'%s' ", track->title);
@@ -2042,8 +2072,6 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
res = talloc_asprintf_append(res, "(%s) ", track->lang);
if (track->is_external)
res = talloc_asprintf_append(res, "(external) ");
if (track->selected)
res = talloc_asprintf_append(res, "<");
res = talloc_asprintf_append(res, "\n");
}
@@ -2166,6 +2194,49 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
static int mp_property_hwdec_current(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
struct dec_video *vd = track ? track->d_video : NULL;
if (!vd)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_GET_TYPE: {
// Abuse another hwdec option to resolve the value names
struct m_property dummy = {.name = "hwdec"};
return mp_property_generic_option(mpctx, &dummy, action, arg);
}
case M_PROPERTY_GET: {
int current = HWDEC_NONE;
video_vd_control(vd, VDCTRL_GET_HWDEC, &current);
*(int *)arg = current;
return M_PROPERTY_OK;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_hwdec_interop(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (!mpctx->video_out || !mpctx->video_out->hwdec_devs)
return M_PROPERTY_UNAVAILABLE;
struct mp_hwdec_ctx *hwctx =
hwdec_devices_get_first(mpctx->video_out->hwdec_devs);
const char *name = hwctx ? hwctx->driver_name : NULL;
if (!name && hwctx)
name = m_opt_choice_str(mp_hwdec_names, hwctx->type);
return m_property_strdup_ro(action, arg, name);
}
static int mp_property_hwdec_active(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -2199,8 +2270,11 @@ static int mp_property_detected_hwdec(void *ctx, struct m_property *prop,
if (vd)
video_vd_control(vd, VDCTRL_GET_HWDEC, &current);
if (current <= 0 && vd && vd->hwdec_info && vd->hwdec_info->hwctx)
current = vd->hwdec_info->hwctx->type;
if (current <= 0 && vd && vd->hwdec_devs) {
struct mp_hwdec_ctx *hwctx = hwdec_devices_get_first(vd->hwdec_devs);
if (hwctx)
current = hwctx->type;
}
// In case of the "-copy" ones, which are "detected" every time the
// decoder is opened, return "no" if no decoding is active.
@@ -2211,84 +2285,6 @@ static int mp_property_detected_hwdec(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
#define VF_DEINTERLACE_LABEL "deinterlace"
static bool probe_deint_filter(struct MPContext *mpctx, const char *filt)
{
char filter[80];
// add a label so that removing the filter is easier
snprintf(filter, sizeof(filter), "@%s:%s", VF_DEINTERLACE_LABEL, filt);
return edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "pre", filter) >= 0;
}
static bool check_output_format(struct MPContext *mpctx, int imgfmt)
{
struct vo_chain *vo_c = mpctx->vo_chain;
if (!vo_c)
return false;
return vo_c->vf->allowed_output_formats[imgfmt - IMGFMT_START];
}
static int probe_deint_filters(struct MPContext *mpctx)
{
if (check_output_format(mpctx, IMGFMT_VDPAU)) {
char filter[80] = "vdpaupp:deint=yes";
int pref = 0;
vo_control(mpctx->video_out, VOCTRL_GET_PREF_DEINT, &pref);
pref = pref < 0 ? -pref : pref;
if (pref > 0 && pref <= 4) {
const char *types[] =
{"", "first-field", "bob", "temporal", "temporal-spatial"};
mp_snprintf_cat(filter, sizeof(filter), ":deint-mode=%s",
types[pref]);
}
probe_deint_filter(mpctx, filter);
return 0;
}
if (check_output_format(mpctx, IMGFMT_VAAPI) &&
probe_deint_filter(mpctx, "vavpp"))
return 0;
if (probe_deint_filter(mpctx, "yadif"))
return 0;
return -1;
}
static int get_deinterlacing(struct MPContext *mpctx)
{
struct vo_chain *vo_c = mpctx->vo_chain;
int enabled = 0;
if (video_vf_vo_control(vo_c, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK)
enabled = -1;
if (enabled < 0) {
// vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE
if (vf_find_by_label(vo_c->vf, VF_DEINTERLACE_LABEL))
enabled = 1;
}
return enabled;
}
void remove_deint_filter(struct MPContext *mpctx)
{
edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL);
}
void set_deinterlacing(struct MPContext *mpctx, bool enable)
{
struct vo_chain *vo_c = mpctx->vo_chain;
if (vf_find_by_label(vo_c->vf, VF_DEINTERLACE_LABEL)) {
if (!enable)
remove_deint_filter(mpctx);
} else {
if ((get_deinterlacing(mpctx) > 0) != enable) {
int arg = enable;
if (video_vf_vo_control(vo_c, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK)
probe_deint_filters(mpctx);
}
}
mpctx->opts->deinterlace = get_deinterlacing(mpctx) > 0;
}
static int mp_property_deinterlace(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -2324,12 +2320,9 @@ static int panscan_property_helper(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (!mpctx->video_out
|| vo_control(mpctx->video_out, VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
return M_PROPERTY_UNAVAILABLE;
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET)
if (mpctx->video_out && action == M_PROPERTY_SET)
vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
return r;
}
@@ -2367,6 +2360,23 @@ static int mp_property_fullscreen(void *ctx, struct m_property *prop,
return r;
}
/// Show playback progress in Windows 7+ taskbar (RW)
static int mp_property_taskbar_progress(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (action == M_PROPERTY_SET) {
int desired = !!*(int *) arg;
if (mpctx->opts->vo.taskbar_progress == desired)
return M_PROPERTY_OK;
mpctx->opts->vo.taskbar_progress = desired;
if (mpctx->video_out)
update_vo_playback_state( mpctx );
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);
}
/// Window always on top (RW)
static int mp_property_ontop(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -2504,13 +2514,13 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg)
{"aspect", SUB_PROP_FLOAT(d_w / (double)d_h)},
{"par", SUB_PROP_FLOAT(p.p_w / (double)p.p_h)},
{"colormatrix",
SUB_PROP_STR(m_opt_choice_str(mp_csp_names, p.colorspace))},
SUB_PROP_STR(m_opt_choice_str(mp_csp_names, p.color.space))},
{"colorlevels",
SUB_PROP_STR(m_opt_choice_str(mp_csp_levels_names, p.colorlevels))},
SUB_PROP_STR(m_opt_choice_str(mp_csp_levels_names, p.color.levels))},
{"primaries",
SUB_PROP_STR(m_opt_choice_str(mp_csp_prim_names, p.primaries))},
SUB_PROP_STR(m_opt_choice_str(mp_csp_prim_names, p.color.primaries))},
{"gamma",
SUB_PROP_STR(m_opt_choice_str(mp_csp_trc_names, p.gamma))},
SUB_PROP_STR(m_opt_choice_str(mp_csp_trc_names, p.color.gamma))},
{"chroma-location",
SUB_PROP_STR(m_opt_choice_str(mp_chroma_names, p.chroma_location))},
{"stereo-in",
@@ -2584,6 +2594,7 @@ static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
{0}
};
talloc_free(f);
return m_property_read_sub(props, action, arg);
}
@@ -2722,6 +2733,39 @@ static int mp_property_vo_configured(void *ctx, struct m_property *prop,
mpctx->video_out && mpctx->video_out->config_ok);
}
static int mp_property_vo_performance(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (!mpctx->video_out)
return M_PROPERTY_UNAVAILABLE;
// Return the type right away if requested, to avoid having to
// go through a completely unnecessary VOCTRL
if (action == M_PROPERTY_GET_TYPE) {
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
return M_PROPERTY_OK;
}
struct voctrl_performance_data data = {0};
if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, &data) <= 0)
return M_PROPERTY_UNAVAILABLE;
#define SUB_PROP_PERFDATA(N) \
{#N "-last", SUB_PROP_INT64(data.N.last)}, \
{#N "-avg", SUB_PROP_INT64(data.N.avg)}, \
{#N "-peak", SUB_PROP_INT64(data.N.peak)}
struct m_sub_property props[] = {
SUB_PROP_PERFDATA(upload),
SUB_PROP_PERFDATA(render),
SUB_PROP_PERFDATA(present),
{0}
};
return m_property_read_sub(props, action, arg);
}
static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg)
{
MPContext *mpctx = ctx;
@@ -2766,8 +2810,8 @@ static int mp_property_osd_ass(void *ctx, struct m_property *prop,
int action, void *arg)
{
struct m_sub_property props[] = {
{"0", SUB_PROP_STR(osd_ass_0)},
{"1", SUB_PROP_STR(osd_ass_1)},
{"0", SUB_PROP_STR(OSD_ASS_0)},
{"1", SUB_PROP_STR(OSD_ASS_1)},
{0}
};
return m_property_read_sub(props, action, arg);
@@ -3075,8 +3119,8 @@ static int mp_property_dvb_channel_name(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
int action, void *arg)
static int mp_property_playlist_pos_x(void *ctx, struct m_property *prop,
int action, void *arg, int base)
{
MPContext *mpctx = ctx;
struct playlist *pl = mpctx->playlist;
@@ -3088,11 +3132,12 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
int pos = playlist_entry_to_index(pl, pl->current);
if (pos < 0)
return M_PROPERTY_UNAVAILABLE;
*(int *)arg = pos;
*(int *)arg = pos + base;
return M_PROPERTY_OK;
}
case M_PROPERTY_SET: {
struct playlist_entry *e = playlist_entry_from_index(pl, *(int *)arg);
int pos = *(int *)arg - base;
struct playlist_entry *e = playlist_entry_from_index(pl, pos);
if (!e)
return M_PROPERTY_ERROR;
mp_set_playlist_entry(mpctx, e);
@@ -3102,8 +3147,8 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
struct m_option opt = {
.type = CONF_TYPE_INT,
.flags = CONF_RANGE,
.min = 0,
.max = playlist_entry_count(pl) - 1,
.min = base,
.max = playlist_entry_count(pl) - 1 + base,
};
*(struct m_option *)arg = opt;
return M_PROPERTY_OK;
@@ -3112,6 +3157,18 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
int action, void *arg)
{
return mp_property_playlist_pos_x(ctx, prop, action, arg, 0);
}
static int mp_property_playlist_pos_1(void *ctx, struct m_property *prop,
int action, void *arg)
{
return mp_property_playlist_pos_x(ctx, prop, action, arg, 1);
}
static int get_playlist_entry(int item, int action, void *arg, void *ctx)
{
struct MPContext *mpctx = ctx;
@@ -3147,11 +3204,9 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
if (s[0])
p = s;
}
if (mpctx->playlist->current == e) {
res = talloc_asprintf_append(res, "> %s <\n", p);
} else {
res = talloc_asprintf_append(res, "%s\n", p);
}
const char *m = mpctx->playlist->current == e ?
list_current : list_normal;
res = talloc_asprintf_append(res, "%s%s\n", m, p);
}
*(char **)arg = res;
@@ -3222,11 +3277,8 @@ static int mp_property_ab_loop(void *ctx, struct m_property *prop,
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (r > 0 && action == M_PROPERTY_SET) {
if (strcmp(prop->name, "ab-loop-b") == 0) {
double now = mpctx->playback_pts;
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE &&
opts->ab_loop[1] != MP_NOPTS_VALUE && now >= opts->ab_loop[1])
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0],
MPSEEK_EXACT, false);
struct command_ctx *cctx = mpctx->command_ctx;
cctx->prev_pts = opts->ab_loop[0];
}
// Update if visible
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
@@ -3639,13 +3691,16 @@ static const struct m_property mp_properties[] = {
{"playlist", mp_property_playlist},
{"playlist-pos", mp_property_playlist_pos},
{"playlist-pos-1", mp_property_playlist_pos_1},
M_PROPERTY_ALIAS("playlist-count", "playlist/count"),
// Audio
{"mixer-active", mp_property_mixer_active},
{"volume", mp_property_volume},
{"volume-max", mp_property_volume_max},
{"volume-max", mp_property_generic_option},
{"mute", mp_property_mute},
{"ao-volume", mp_property_ao_volume},
{"ao-mute", mp_property_ao_mute},
{"audio-delay", mp_property_audio_delay},
{"audio-codec-name", mp_property_audio_codec_name},
{"audio-codec", mp_property_audio_codec},
@@ -3655,7 +3710,6 @@ static const struct m_property mp_properties[] = {
M_PROPERTY_DEPRECATED_ALIAS("audio-channels", "audio-params/channel-count"),
{"aid", mp_property_audio},
{"balance", mp_property_balance},
{"volume-restore-data", mp_property_volrestore},
{"audio-device", mp_property_audio_device},
{"audio-device-list", mp_property_audio_devices},
{"current-ao", mp_property_ao},
@@ -3665,6 +3719,7 @@ static const struct m_property mp_properties[] = {
{"fullscreen", mp_property_fullscreen},
{"deinterlace", mp_property_deinterlace},
{"field-dominance", mp_property_generic_option},
{"taskbar-progress", mp_property_taskbar_progress},
{"ontop", mp_property_ontop},
{"border", mp_property_border},
{"on-all-workspaces", mp_property_all_workspaces},
@@ -3695,6 +3750,7 @@ static const struct m_property mp_properties[] = {
M_PROPERTY_ALIAS("height", "video-params/h"),
{"window-scale", mp_property_window_scale},
{"vo-configured", mp_property_vo_configured},
{"vo-performance", mp_property_vo_performance},
{"current-vo", mp_property_vo},
{"fps", mp_property_fps},
{"estimated-vf-fps", mp_property_vf_fps},
@@ -3703,6 +3759,8 @@ static const struct m_property mp_properties[] = {
{"program", mp_property_program},
{"hwdec", mp_property_hwdec},
{"hwdec-active", mp_property_hwdec_active},
{"hwdec-current", mp_property_hwdec_current},
{"hwdec-interop", mp_property_hwdec_interop},
{"hwdec-detected", mp_property_detected_hwdec},
{"estimated-frame-count", mp_property_frame_count},
@@ -3829,7 +3887,7 @@ static const char *const *const mp_event_property_change[] = {
"colormatrix-output-range", "colormatrix-primaries", "video-aspect"),
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
"samplerate", "channels", "audio", "volume", "mute", "balance",
"volume-restore-data", "current-ao", "audio-codec-name", "audio-params",
"current-ao", "audio-codec-name", "audio-params",
"audio-out-params", "volume-max", "mixer-active"),
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
@@ -3839,7 +3897,10 @@ static const char *const *const mp_event_property_change[] = {
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
"demuxer-cache-time", "cache-buffering-state", "cache-speed"),
E(MP_EVENT_WIN_RESIZE, "window-scale", "osd-width", "osd-height", "osd-par"),
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps", "fullscreen"),
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps",
"fullscreen"),
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
"playlist-count", "playlist/count"),
};
#undef E
@@ -3907,6 +3968,23 @@ int mp_property_do(const char *name, int action, void *val,
int r = m_property_do(ctx->log, mp_properties, name, action, val, ctx);
if (r == M_PROPERTY_OK && is_property_set(action, val))
mp_notify_property(ctx, (char *)name);
if (mp_msg_test(ctx->log, MSGL_V) && is_property_set(action, val)) {
struct m_option ot = {0};
void *data = val;
switch (action) {
case M_PROPERTY_SET_NODE:
ot.type = &m_option_type_node;
break;
case M_PROPERTY_SET_STRING:
ot.type = &m_option_type_string;
data = &val;
break;
}
char *t = ot.type ? m_option_print(&ot, data) : NULL;
MP_VERBOSE(ctx, "Set property: %s%s%s -> %d\n",
name, t ? "=" : "", t ? t : "", r);
talloc_free(t);
}
return r;
}
@@ -3979,6 +4057,7 @@ static const struct property_osd_display {
{ "balance", "Balance", .osd_progbar = OSD_BALANCE },
// video
{ "panscan", "Panscan", .osd_progbar = OSD_PANSCAN },
{ "taskbar-progress", "Progress in taskbar" },
{ "ontop", "Stay on top" },
{ "border", "Border" },
{ "framedrop", "Framedrop" },
@@ -4182,20 +4261,85 @@ static int edit_filters_osd(struct MPContext *mpctx, enum stream_type mediatype,
static void recreate_overlays(struct MPContext *mpctx)
{
struct command_ctx *cmd = mpctx->command_ctx;
struct sub_bitmaps *new = &cmd->overlay_osd[0];
if (new == cmd->overlay_osd_current)
new += 1; // pick the unused one
int overlay_next = !cmd->overlay_osd_current;
struct sub_bitmaps *new = &cmd->overlay_osd[overlay_next];
new->format = SUBBITMAP_RGBA;
new->change_id = 1;
// overlay array can have unused entries, but parts list must be "packed"
bool valid = false;
new->num_parts = 0;
for (int n = 0; n < cmd->num_overlays; n++) {
struct overlay *o = &cmd->overlays[n];
if (o->osd.bitmap)
MP_TARRAY_APPEND(cmd, new->parts, new->num_parts, o->osd);
if (o->source) {
struct mp_image *s = o->source;
struct sub_bitmap b = {
.bitmap = s->planes[0],
.stride = s->stride[0],
.w = s->w, .dw = s->w,
.h = s->h, .dh = s->h,
.x = o->x,
.y = o->y,
};
MP_TARRAY_APPEND(cmd, new->parts, new->num_parts, b);
}
}
cmd->overlay_osd_current = new;
osd_set_external2(mpctx->osd, cmd->overlay_osd_current);
if (!cmd->overlay_packer)
cmd->overlay_packer = talloc_zero(cmd, struct bitmap_packer);
cmd->overlay_packer->padding = 1; // assume bilinear scaling
packer_set_size(cmd->overlay_packer, new->num_parts);
for (int n = 0; n < new->num_parts; n++)
cmd->overlay_packer->in[n] = (struct pos){new->parts[n].w, new->parts[n].h};
if (packer_pack(cmd->overlay_packer) < 0 || new->num_parts == 0)
goto done;
struct pos bb[2];
packer_get_bb(cmd->overlay_packer, bb);
new->packed_w = bb[1].x;
new->packed_h = bb[1].y;
if (!new->packed || new->packed->w < new->packed_w ||
new->packed->h < new->packed_h)
{
talloc_free(new->packed);
new->packed = mp_image_alloc(IMGFMT_BGRA, cmd->overlay_packer->w,
cmd->overlay_packer->h);
if (!new->packed)
goto done;
}
// clear padding
mp_image_clear(new->packed, 0, 0, new->packed->w, new->packed->h);
for (int n = 0; n < new->num_parts; n++) {
struct sub_bitmap *b = &new->parts[n];
struct pos pos = cmd->overlay_packer->result[n];
int stride = new->packed->stride[0];
void *pdata = (uint8_t *)new->packed->planes[0] + pos.y * stride + pos.x * 4;
memcpy_pic(pdata, b->bitmap, b->w * 4, b->h, stride, b->stride);
b->bitmap = pdata;
b->stride = stride;
b->src_x = pos.x;
b->src_y = pos.y;
}
valid = true;
done:
if (!valid) {
new->format = SUBBITMAP_EMPTY;
new->num_parts = 0;
}
osd_set_external2(mpctx->osd, new);
cmd->overlay_osd_current = overlay_next;
}
// Set overlay with the given ID to the contents as described by "new".
@@ -4210,17 +4354,11 @@ static void replace_overlay(struct MPContext *mpctx, int id, struct overlay *new
}
struct overlay *ptr = &cmd->overlays[id];
struct overlay old = *ptr;
if (!ptr->osd.bitmap && !new->osd.bitmap)
return; // don't need to recreate or unmap
talloc_free(ptr->source);
*ptr = *new;
recreate_overlays(mpctx);
// Do this afterwards, so we never unmap while the OSD is using it.
if (old.map_start && old.map_size)
munmap(old.map_start, old.map_size);
recreate_overlays(mpctx);
}
static int overlay_add(struct MPContext *mpctx, int id, int x, int y,
@@ -4236,18 +4374,17 @@ static int overlay_add(struct MPContext *mpctx, int id, int x, int y,
MP_ERR(mpctx, "overlay_add: invalid id %d\n", id);
goto error;
}
if (w < 0 || h < 0 || stride < w * 4 || (stride % 4)) {
if (w <= 0 || h <= 0 || stride < w * 4 || (stride % 4)) {
MP_ERR(mpctx, "overlay_add: inconsistent parameters\n");
goto error;
}
struct overlay overlay = {
.osd = {
.stride = stride,
.x = x, .y = y,
.w = w, .h = h,
.dw = w, .dh = h,
},
.source = mp_image_alloc(IMGFMT_BGRA, w, h),
.x = x,
.y = y,
};
if (!overlay.source)
goto error;
int fd = -1;
bool close_fd = true;
void *p = NULL;
@@ -4266,21 +4403,25 @@ static int overlay_add(struct MPContext *mpctx, int id, int x, int y,
} else {
fd = open(file, O_RDONLY | O_BINARY | O_CLOEXEC);
}
int map_size = 0;
if (fd >= 0) {
overlay.map_size = offset + h * stride;
void *m = mmap(NULL, overlay.map_size, PROT_READ, MAP_SHARED, fd, 0);
map_size = offset + h * stride;
void *m = mmap(NULL, map_size, PROT_READ, MAP_SHARED, fd, 0);
if (close_fd)
close(fd);
if (m && m != MAP_FAILED) {
overlay.map_start = m;
if (m && m != MAP_FAILED)
p = m;
}
}
if (!p) {
MP_ERR(mpctx, "overlay_add: could not open or map '%s'\n", file);
talloc_free(overlay.source);
goto error;
}
overlay.osd.bitmap = (char *)p + offset;
memcpy_pic(overlay.source->planes[0], (char *)p + offset, w * 4, h,
overlay.source->stride[0], stride);
if (map_size)
munmap(p, map_size);
replace_overlay(mpctx, id, &overlay);
r = 0;
error:
@@ -4302,6 +4443,8 @@ static void overlay_uninit(struct MPContext *mpctx)
for (int id = 0; id < cmd->num_overlays; id++)
overlay_remove(mpctx, id);
osd_set_external2(mpctx->osd, NULL);
for (int n = 0; n < 2; n++)
mp_image_unrefp(&cmd->overlay_osd[n].packed);
}
struct cycle_counter {
@@ -4740,7 +4883,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
mp_write_watch_later_conf(mpctx);
mp_set_playlist_entry(mpctx, entry);
}
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}
@@ -4759,7 +4902,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (!append && mpctx->playlist->first)
mp_set_playlist_entry(mpctx, new ? new : mpctx->playlist->first);
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
} else {
MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
return -1;
@@ -4780,7 +4923,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
}
playlist_remove(mpctx->playlist, e);
}
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}
@@ -4795,7 +4938,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (mpctx->playlist->current == e && !mpctx->stop_play)
mpctx->stop_play = PT_CURRENT_ENTRY;
playlist_remove(mpctx->playlist, e);
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}
@@ -4807,7 +4950,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (!e1)
return -1;
playlist_move(mpctx->playlist, e1, e2);
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}
@@ -4826,6 +4969,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
mpctx->add_osd_seek_info |=
(msg_osd ? OSD_SEEK_INFO_TEXT : 0) |
(bar_osd ? OSD_SEEK_INFO_BAR : 0);
mpctx->osd_force_update = true;
break;
case MP_CMD_TV_LAST_CHANNEL: {
@@ -5230,16 +5374,24 @@ void handle_ab_loop(struct MPContext *mpctx)
struct command_ctx *ctx = mpctx->command_ctx;
struct MPOpts *opts = mpctx->opts;
if (opts->pause)
return;
double now = mpctx->restart_complete ? mpctx->playback_pts : MP_NOPTS_VALUE;
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE &&
opts->ab_loop[1] != MP_NOPTS_VALUE)
if (now != MP_NOPTS_VALUE && (opts->ab_loop[0] != MP_NOPTS_VALUE ||
opts->ab_loop[1] != MP_NOPTS_VALUE))
{
if (ctx->prev_pts >= opts->ab_loop[0] &&
ctx->prev_pts < opts->ab_loop[1] &&
(now >= opts->ab_loop[1] || mpctx->stop_play == AT_END_OF_FILE))
double start = opts->ab_loop[0];
if (start == MP_NOPTS_VALUE)
start = 0;
double end = opts->ab_loop[1];
if (end == MP_NOPTS_VALUE)
end = INFINITY;
if (ctx->prev_pts >= start && ctx->prev_pts < end &&
(now >= end || mpctx->stop_play == AT_END_OF_FILE))
{
mark_seek(mpctx);
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0],
queue_seek(mpctx, MPSEEK_ABSOLUTE, start,
MPSEEK_EXACT, false);
}
}
@@ -5260,6 +5412,9 @@ void handle_command_updates(struct MPContext *mpctx)
void mp_notify(struct MPContext *mpctx, int event, void *arg)
{
// The OSD can implicitly reference some properties.
mpctx->osd_idle_update = true;
command_event(mpctx, event, arg);
mp_client_broadcast_event(mpctx, event, arg);
+1 -3
View File
@@ -51,6 +51,7 @@ enum {
MP_EVENT_CACHE_UPDATE,
MP_EVENT_WIN_RESIZE,
MP_EVENT_WIN_STATE,
MP_EVENT_CHANGE_PLAYLIST,
};
bool mp_hook_test_completion(struct MPContext *mpctx, char *type);
@@ -58,7 +59,4 @@ void mp_hook_run(struct MPContext *mpctx, char *client, char *type);
void handle_ab_loop(struct MPContext *mpctx);
void remove_deint_filter(struct MPContext *mpctx);
void set_deinterlacing(struct MPContext *mpctx, bool enable);
#endif /* MPLAYER_COMMAND_H */
+2 -1
View File
@@ -208,7 +208,8 @@ static const char *const backup_properties[] = {
"options/speed",
"options/edition",
"options/pause",
"volume-restore-data",
"volume",
"mute",
"options/audio-delay",
//"balance",
"options/fullscreen",
+6 -3
View File
@@ -153,7 +153,7 @@ struct track {
struct vo_chain {
struct mp_log *log;
struct mp_hwdec_info *hwdec_info;
struct mp_hwdec_devices *hwdec_devs;
double container_fps;
struct vf_chain *vf;
@@ -243,7 +243,7 @@ typedef struct MPContext {
double osd_msg_visible;
double osd_msg_next_duration;
double osd_last_update;
bool osd_force_update;
bool osd_force_update, osd_idle_update;
char *osd_msg_text;
bool osd_show_pos;
struct osd_progbar_state osd_progbar;
@@ -398,6 +398,7 @@ typedef struct MPContext {
bool paused_for_cache;
double cache_stop_time, cache_wait_time;
int cache_buffer;
// Set after showing warning about decoding being too slow for realtime
// playback rate. Used to avoid showing it multiple times.
@@ -515,7 +516,7 @@ char *chapter_display_name(struct MPContext *mpctx, int chapter);
char *chapter_name(struct MPContext *mpctx, int chapter);
double chapter_start_time(struct MPContext *mpctx, int chapter);
int get_chapter_count(struct MPContext *mpctx);
double get_cache_buffering_percentage(struct MPContext *mpctx);
int get_cache_buffering_percentage(struct MPContext *mpctx);
void execute_queued_seek(struct MPContext *mpctx);
void run_playloop(struct MPContext *mpctx);
void mp_idle(struct MPContext *mpctx);
@@ -554,5 +555,7 @@ void uninit_video_out(struct MPContext *mpctx);
void uninit_video_chain(struct MPContext *mpctx);
double calc_average_frame_duration(struct MPContext *mpctx);
int init_video_decoder(struct MPContext *mpctx, struct track *track);
int get_deinterlacing(struct MPContext *mpctx);
void set_deinterlacing(struct MPContext *mpctx, bool enable);
#endif /* MPLAYER_MP_CORE_H */
+1 -1
View File
@@ -176,7 +176,7 @@ static void append_dir_subtitles(struct mpv_global *global,
prio += prio;
char *subpath = mp_path_join_bstr(*slist, path, dename);
if (mp_path_exists(subpath)) {
MP_GROW_ARRAY(*slist, *nsub);
MP_TARRAY_GROW(NULL, *slist, *nsub);
struct subfn *sub = *slist + (*nsub)++;
// annoying and redundant
+8 -2
View File
@@ -339,7 +339,7 @@ static bool init_pads(struct lavfi *c)
goto error; // can happen if pad reassociation fails
if (pad->dir == LAVFI_OUT) {
AVFilter *dst_filter;
AVFilter *dst_filter = NULL;
if (pad->type == STREAM_AUDIO) {
dst_filter = avfilter_get_by_name("abuffersink");
} else if (pad->type == STREAM_VIDEO) {
@@ -348,6 +348,9 @@ static bool init_pads(struct lavfi *c)
assert(0);
}
if (!dst_filter)
goto error;
char name[256];
snprintf(name, sizeof(name), "mpv_sink_%s", pad->name);
@@ -359,7 +362,7 @@ static bool init_pads(struct lavfi *c)
goto error;
} else {
char src_args[256];
AVFilter *src_filter;
AVFilter *src_filter = NULL;
pad->input_eof |= !pad->connected;
@@ -410,6 +413,9 @@ static bool init_pads(struct lavfi *c)
assert(0);
}
if (!src_filter)
goto error;
char name[256];
snprintf(name, sizeof(name), "mpv_src_%s", pad->name);
+2 -1
View File
@@ -452,7 +452,7 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type
if (type == STREAM_VIDEO) {
uninit_video_chain(mpctx);
if (!track)
handle_force_window(mpctx, false);
handle_force_window(mpctx, true);
} else if (type == STREAM_AUDIO) {
clear_audio_output_buffers(mpctx);
uninit_audio_chain(mpctx);
@@ -973,6 +973,7 @@ static void play_current_file(struct MPContext *mpctx)
mpctx->last_chapter = -2;
mpctx->paused = false;
mpctx->paused_for_cache = false;
mpctx->cache_buffer = -1;
mpctx->playing_msg_shown = false;
mpctx->max_frames = -1;
mpctx->video_speed = mpctx->audio_speed = opts->playback_speed;
+4
View File
@@ -275,6 +275,10 @@ function timer_mt.resume(t)
end
end
function timer_mt.is_enabled(t)
return timers[t] ~= nil
end
-- Return the timer that expires next.
local function get_next_timer()
local best = nil
+26 -5
View File
@@ -153,13 +153,18 @@ mp.add_hook("on_load", 10, function ()
-- some funky guessing to detect multi-arc videos
if not (json.entries[1]["webpage_url"] == nil)
and (json.entries[1]["webpage_url"] == json["webpage_url"]) then
if (not (json.entries[1]["_type"] == "url_transparent")) and
(not (json.entries[1]["webpage_url"] == nil)
and (json.entries[1]["webpage_url"] == json["webpage_url"])) then
msg.verbose("multi-arc video detected, building EDL")
local playlist = "edl://"
for i, entry in pairs(json.entries) do
playlist = playlist .. edl_escape(entry.url) .. ";"
playlist = playlist .. edl_escape(entry.url)
if not (entry.duration == nil) then
playlist = playlist..",start=0,length="..entry.duration
end
playlist = playlist .. ";"
end
msg.debug("EDL: " .. playlist)
@@ -175,6 +180,21 @@ mp.add_hook("on_load", 10, function ()
json.title)
end
if not (json.entries[1].requested_subtitles == nil) then
for j, req in pairs(json.entries[1].requested_subtitles) do
local subfile = "edl://"
for i, entry in pairs(json.entries) do
subfile = subfile..edl_escape(entry.requested_subtitles[j].url)
if not (entry.duration == nil) then
subfile = subfile..",start=0,length="..entry.duration
end
subfile = subfile .. ";"
end
msg.debug(j.." sub EDL: "..subfile)
mp.commandv("sub-add", subfile, "auto", req.ext, j)
end
end
else
local playlist = "#EXTM3U\n"
@@ -186,7 +206,8 @@ mp.add_hook("on_load", 10, function ()
-- directly to the file in that case, which we don't
-- want so get the webpage URL instead, which is what
-- we want
if not (entry["webpage_url"] == nil) then
if not (json.entries[1]["_type"] == "url_transparent")
and not (entry["webpage_url"] == nil) then
site = entry["webpage_url"]
end
@@ -253,7 +274,7 @@ mp.add_hook("on_load", 10, function ()
end
-- for rtmp
if not (json.play_path == nil) then
if (json.protocol == "rtmp") then
local rtmp_prop = append_rtmp_prop(nil,
"rtmp_tcurl", streamurl)
rtmp_prop = append_rtmp_prop(rtmp_prop,
+12
View File
@@ -418,6 +418,18 @@ int mp_initialize(struct MPContext *mpctx, char **options)
if (handle_help_options(mpctx))
return -2;
if (!print_libav_versions(mp_null_log, 0)) {
// Using mismatched libraries can be legitimate, but even then it's
// a bad idea. We don't acknowledge its usefulness and stability.
print_libav_versions(mpctx->log, MSGL_FATAL);
MP_FATAL(mpctx, "\nmpv was compiled against a different version of "
"FFmpeg/Libav than the shared\nlibrary it is linked against. "
"This is most likely a broken build and could\nresult in "
"misbehavior and crashes.\n\nmpv does not support this "
"configuration and will not run - rebuild mpv instead.\n");
return -1;
}
if (opts->dump_stats && opts->dump_stats[0]) {
if (mp_msg_open_stats_file(mpctx->global, opts->dump_stats) < 0)
MP_ERR(mpctx, "Failed to open stats file '%s'\n", opts->dump_stats);
+12 -4
View File
@@ -116,16 +116,24 @@ void update_vo_playback_state(struct MPContext *mpctx)
if (mpctx->video_out) {
struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
struct voctrl_playback_state newstate = {
.taskbar_progress = mpctx->opts->vo.taskbar_progress,
.playing = mpctx->playing,
.paused = mpctx->paused,
.percent_pos = get_percent_pos(mpctx),
};
if (oldstate.playing != newstate.playing ||
if (oldstate.taskbar_progress != newstate.taskbar_progress ||
oldstate.playing != newstate.playing ||
oldstate.paused != newstate.paused ||
oldstate.percent_pos != newstate.percent_pos) {
vo_control(mpctx->video_out,
VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
oldstate.percent_pos != newstate.percent_pos)
{
// Don't update progress bar if it was and still is hidden
if ((oldstate.playing && oldstate.taskbar_progress) ||
(newstate.playing && newstate.taskbar_progress))
{
vo_control(mpctx->video_out,
VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
}
mpctx->vo_playback_state = newstate;
}
} else {
+19 -4
View File
@@ -129,6 +129,12 @@ static void term_osd_set_status(struct MPContext *mpctx, const char *text)
{
talloc_free(mpctx->term_osd_status);
mpctx->term_osd_status = talloc_strdup(mpctx, text);
int w = 80, h = 24;
terminal_get_size(&w, &h);
if (strlen(mpctx->term_osd_status) > w)
mpctx->term_osd_status[w] = '\0';
term_osd_update(mpctx);
}
@@ -362,14 +368,15 @@ void set_osd_bar_chapters(struct MPContext *mpctx, int type)
mpctx->osd_progbar.num_stops = 0;
double len = get_time_length(mpctx);
if (len > 0) {
if (opts->ab_loop[0] != MP_NOPTS_VALUE &&
opts->ab_loop[1] != MP_NOPTS_VALUE)
{
if (opts->ab_loop[0] != MP_NOPTS_VALUE) {
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
mpctx->osd_progbar.num_stops, opts->ab_loop[0] / len);
}
if (opts->ab_loop[1] != MP_NOPTS_VALUE) {
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
mpctx->osd_progbar.num_stops, opts->ab_loop[1] / len);
} else {
}
if (mpctx->osd_progbar.num_stops == 0) {
int num = get_chapter_count(mpctx);
for (int n = 0; n < num; n++) {
double time = chapter_start_time(mpctx, n);
@@ -491,6 +498,10 @@ void update_osd_msg(struct MPContext *mpctx)
double now = mp_time_sec();
if (!mpctx->osd_force_update) {
// Assume nothing is going on at all.
if (!mpctx->osd_idle_update)
return;
double delay = 0.050; // update the OSD at most this often
double diff = now - mpctx->osd_last_update;
if (diff < delay) {
@@ -499,12 +510,14 @@ void update_osd_msg(struct MPContext *mpctx)
}
}
mpctx->osd_force_update = false;
mpctx->osd_idle_update = false;
mpctx->osd_last_update = now;
if (mpctx->osd_visible) {
double sleep = mpctx->osd_visible - now;
if (sleep > 0) {
mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleep);
mpctx->osd_idle_update = true;
} else {
mpctx->osd_visible = 0;
mpctx->osd_progbar.type = -1; // disable
@@ -516,6 +529,7 @@ void update_osd_msg(struct MPContext *mpctx)
double sleep = mpctx->osd_function_visible - now;
if (sleep > 0) {
mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleep);
mpctx->osd_idle_update = true;
} else {
mpctx->osd_function_visible = 0;
mpctx->osd_function = 0;
@@ -533,6 +547,7 @@ void update_osd_msg(struct MPContext *mpctx)
double sleep = mpctx->osd_msg_visible - now;
if (sleep > 0) {
mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleep);
mpctx->osd_idle_update = true;
} else {
talloc_free(mpctx->osd_msg_text);
mpctx->osd_msg_text = NULL;
+81 -49
View File
@@ -141,7 +141,7 @@ void add_step_frame(struct MPContext *mpctx, int dir)
mpctx->step_frames += 1;
unpause_player(mpctx);
} else if (dir < 0) {
if (!mpctx->hrseek_backstep || !mpctx->hrseek_active) {
if (!mpctx->hrseek_active) {
queue_seek(mpctx, MPSEEK_BACKSTEP, 0, MPSEEK_VERY_EXACT, true);
pause_player(mpctx);
}
@@ -180,17 +180,17 @@ void reset_playback_state(struct MPContext *mpctx)
#endif
}
// return -1 if seek failed (non-seekable stream?), 0 otherwise
static int mp_seek(MPContext *mpctx, struct seek_params seek)
static void mp_seek(MPContext *mpctx, struct seek_params seek)
{
struct MPOpts *opts = mpctx->opts;
if (!mpctx->demuxer || seek.type == MPSEEK_NONE || seek.amount == MP_NOPTS_VALUE)
return -1;
return;
if (!mpctx->demuxer->seekable) {
MP_ERR(mpctx, "Can't seek in this file.\n");
return -1;
MP_ERR(mpctx, "Cannot seek in this file.\n");
MP_ERR(mpctx, "You can forcibly enable it with '--force-seekable=yes'.\n");
return;
}
bool hr_seek_very_exact = seek.exact == MPSEEK_VERY_EXACT;
@@ -291,8 +291,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek)
mp_notify(mpctx, MPV_EVENT_SEEK, NULL);
mp_notify(mpctx, MPV_EVENT_TICK, NULL);
return 0;
}
// This combines consecutive seek requests.
@@ -343,7 +341,7 @@ void execute_queued_seek(struct MPContext *mpctx)
/* If the user seeks continuously (keeps arrow key down)
* try to finish showing a frame from one location before doing
* another seek (which could lead to unchanging display). */
if (!mpctx->seek.immediate && mpctx->video_status < STATUS_READY &&
if (!mpctx->seek.immediate && mpctx->video_status < STATUS_PLAYING &&
mp_time_sec() - mpctx->start_timestamp < 0.3)
return;
mp_seek(mpctx, mpctx->seek);
@@ -504,7 +502,8 @@ static void handle_osd_redraw(struct MPContext *mpctx)
return;
}
// Don't redraw immediately during a seek (makes it significantly slower).
if (mpctx->vo_chain && mp_time_sec() - mpctx->start_timestamp < 0.1) {
bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_coverart;
if (use_video && mp_time_sec() - mpctx->start_timestamp < 0.1) {
mpctx->sleeptime = MPMIN(mpctx->sleeptime, 0.1);
return;
}
@@ -518,23 +517,27 @@ static void handle_osd_redraw(struct MPContext *mpctx)
static void handle_pause_on_low_cache(struct MPContext *mpctx)
{
bool force_update = false;
struct MPOpts *opts = mpctx->opts;
if (!mpctx->demuxer)
return;
struct stream_cache_info info = {0};
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info);
int idle = info.size > 0 ? info.idle : -1;
double now = mp_time_sec();
struct stream_cache_info c = {.idle = true};
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &c);
struct demux_ctrl_reader_state s = {.idle = true, .ts_duration = -1};
demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
if (mpctx->restart_complete && idle != -1) {
int cache_buffer = 100;
if (mpctx->restart_complete && c.size > 0) {
if (mpctx->paused && mpctx->paused_for_cache) {
if (!opts->cache_pausing || s.ts_duration >= mpctx->cache_wait_time
|| s.idle)
{
double elapsed_time = mp_time_sec() - mpctx->cache_stop_time;
double elapsed_time = now - mpctx->cache_stop_time;
if (elapsed_time > mpctx->cache_wait_time) {
mpctx->cache_wait_time *= 1.5 + 0.1;
} else {
@@ -543,7 +546,7 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
mpctx->paused_for_cache = false;
if (!opts->pause)
unpause_player(mpctx);
mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
force_update = true;
}
mpctx->sleeptime = MPMIN(mpctx->sleeptime, 0.2);
} else {
@@ -552,45 +555,52 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
pause_player(mpctx);
mpctx->paused_for_cache = true;
opts->pause = prev_paused_user;
mpctx->cache_stop_time = mp_time_sec();
mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
mpctx->cache_stop_time = now;
force_update = true;
}
}
mpctx->cache_wait_time = MPCLAMP(mpctx->cache_wait_time, 1, 10);
if (mpctx->paused_for_cache) {
cache_buffer =
100 * MPCLAMP(s.ts_duration / mpctx->cache_wait_time, 0, 0.99);
}
}
// Also update cache properties.
bool busy = idle == 0;
if (!s.idle) {
busy |= idle != -1;
busy |= mp_client_event_is_registered(mpctx, MP_EVENT_CACHE_UPDATE);
}
bool busy = !s.idle || !c.idle;
if (busy || mpctx->next_cache_update > 0) {
double now = mp_time_sec();
if (mpctx->next_cache_update <= now) {
mpctx->next_cache_update = busy ? now + 0.25 : 0;
mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
force_update = true;
}
if (mpctx->next_cache_update > 0) {
mpctx->sleeptime =
MPMIN(mpctx->sleeptime, mpctx->next_cache_update - now);
}
}
if (mpctx->cache_buffer != cache_buffer) {
if (mpctx->cache_buffer >= 0 &&
(mpctx->cache_buffer == 100) != (cache_buffer == 100))
{
if (cache_buffer < 100) {
MP_VERBOSE(mpctx, "Enter buffering.\n");
} else {
double t = now - mpctx->cache_stop_time;
MP_VERBOSE(mpctx, "End buffering (waited %f secs).\n", t);
}
}
mpctx->cache_buffer = cache_buffer;
force_update = true;
}
if (force_update)
mp_notify(mpctx, MP_EVENT_CACHE_UPDATE, NULL);
}
double get_cache_buffering_percentage(struct MPContext *mpctx)
int get_cache_buffering_percentage(struct MPContext *mpctx)
{
if (mpctx->demuxer && mpctx->paused_for_cache && mpctx->cache_wait_time > 0) {
struct demux_ctrl_reader_state s = {.idle = true, .ts_duration = -1};
demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
if (s.ts_duration < 0)
s.ts_duration = 0;
return MPCLAMP(s.ts_duration / mpctx->cache_wait_time, 0.0, 1.0);
}
if (mpctx->demuxer && !mpctx->paused_for_cache)
return 1.0;
return -1;
return mpctx->demuxer ? mpctx->cache_buffer : -1;
}
static void handle_heartbeat_cmd(struct MPContext *mpctx)
@@ -600,7 +610,7 @@ static void handle_heartbeat_cmd(struct MPContext *mpctx)
double now = mp_time_sec();
if (mpctx->next_heartbeat <= now) {
mpctx->next_heartbeat = now + opts->heartbeat_interval;
system(opts->heartbeat_cmd);
(void)system(opts->heartbeat_cmd);
}
mpctx->sleeptime = MPMIN(mpctx->sleeptime, mpctx->next_heartbeat - now);
}
@@ -826,6 +836,21 @@ static void handle_dummy_ticks(struct MPContext *mpctx)
}
}
// Update current playback time.
static void handle_playback_time(struct MPContext *mpctx)
{
if (mpctx->vo_chain && !mpctx->vo_chain->is_coverart &&
mpctx->video_status >= STATUS_PLAYING &&
mpctx->video_status < STATUS_EOF)
{
mpctx->playback_pts = mpctx->video_pts;
} else if (mpctx->audio_status >= STATUS_PLAYING &&
mpctx->audio_status < STATUS_EOF)
{
mpctx->playback_pts = playing_audio_pts(mpctx);
}
}
// We always make sure audio and video buffers are filled before actually
// starting playback. This code handles starting them at the same time.
static void handle_playback_restart(struct MPContext *mpctx)
@@ -842,8 +867,17 @@ static void handle_playback_restart(struct MPContext *mpctx)
mpctx->sleeptime = 0;
}
if (mpctx->audio_status == STATUS_READY)
if (mpctx->audio_status == STATUS_READY) {
// If a new seek is queued while the current one finishes, don't
// actually play the audio, but resume seeking immediately.
if (mpctx->seek.type && mpctx->video_status == STATUS_PLAYING) {
handle_playback_time(mpctx);
execute_queued_seek(mpctx);
return;
}
fill_audio_out_buffers(mpctx); // actually play prepared buffer
}
if (!mpctx->restart_complete) {
mpctx->hrseek_active = false;
@@ -866,6 +900,7 @@ static void handle_playback_restart(struct MPContext *mpctx)
}
}
mpctx->playing_msg_shown = true;
mpctx->sleeptime = 0;
MP_VERBOSE(mpctx, "playback restart complete\n");
}
}
@@ -942,9 +977,6 @@ void run_playloop(struct MPContext *mpctx)
handle_heartbeat_cmd(mpctx);
handle_command_updates(mpctx);
fill_audio_out_buffers(mpctx);
write_video(mpctx);
if (mpctx->lavfi) {
if (lavfi_process(mpctx->lavfi))
mpctx->sleeptime = 0;
@@ -952,15 +984,12 @@ void run_playloop(struct MPContext *mpctx)
mpctx->stop_play = AT_END_OF_FILE;
}
fill_audio_out_buffers(mpctx);
write_video(mpctx);
handle_playback_restart(mpctx);
// Use the audio timestamp if no video, or video is enabled, but has ended.
if (mpctx->video_status == STATUS_EOF &&
mpctx->audio_status >= STATUS_PLAYING &&
mpctx->audio_status < STATUS_EOF)
{
mpctx->playback_pts = playing_audio_pts(mpctx);
}
handle_playback_time(mpctx);
handle_dummy_ticks(mpctx);
@@ -978,6 +1007,9 @@ void run_playloop(struct MPContext *mpctx)
handle_sstep(mpctx);
if (mpctx->stop_play == AT_END_OF_FILE && mpctx->seek.type)
mpctx->stop_play = KEEP_PLAYING;
if (mpctx->stop_play)
return;
+5 -3
View File
@@ -287,9 +287,10 @@ static char *gen_fname(screenshot_ctx *ctx, const char *file_ext)
void *t = fname;
dir = mp_get_user_path(t, ctx->mpctx->global, dir);
fname = mp_path_join(NULL, dir, fname);
talloc_free(t);
mp_mkdirp(dir);
talloc_free(t);
}
if (!mp_path_exists(fname))
@@ -345,8 +346,9 @@ static struct mp_image *screenshot_get(struct MPContext *mpctx, int mode)
}
}
if (image && mpctx->vo_chain && mpctx->vo_chain->hwdec_info) {
struct mp_hwdec_ctx *ctx = mpctx->vo_chain->hwdec_info->hwctx;
if (image && mpctx->vo_chain && mpctx->vo_chain->hwdec_devs) {
struct mp_hwdec_ctx *ctx =
hwdec_devices_get_first(mpctx->vo_chain->hwdec_devs);
struct mp_image *nimage = NULL;
if (ctx && ctx->download_image && (image->fmt.flags & MP_IMGFLAG_HWACCEL))
nimage = ctx->download_image(ctx, image, NULL);
+100 -35
View File
@@ -49,6 +49,8 @@
#include "command.h"
#include "screenshot.h"
#define VF_DEINTERLACE_LABEL "deinterlace"
enum {
// update_video() - code also uses: <0 error, 0 eof, >0 progress
VD_ERROR = -1,
@@ -153,8 +155,45 @@ static int try_filter(struct vo_chain *vo_c, char *name, char *label, char **arg
return 0;
}
static bool check_output_format(struct vo_chain *vo_c, int imgfmt)
{
return vo_c->vf->output_params.imgfmt == imgfmt;
}
static int probe_deint_filters(struct vo_chain *vo_c)
{
// Usually, we prefer inserting/removing deint filters. But If there's VO
// support, or the user inserted a filter that supports swichting deint and
// that has no VF_DEINTERLACE_LABEL, or if the filter was auto-inserted
// for other reasons and supports switching deint (like vf_d3d11vpp), then
// use the runtime switching method.
if (video_vf_vo_control(vo_c, VFCTRL_SET_DEINTERLACE, &(int){1}) == CONTROL_OK)
return 0;
if (check_output_format(vo_c, IMGFMT_VDPAU)) {
char *args[5] = {"deint", "yes"};
int pref = 0;
vo_control(vo_c->vo, VOCTRL_GET_PREF_DEINT, &pref);
pref = pref < 0 ? -pref : pref;
if (pref > 0 && pref <= 4) {
const char *types[] =
{"", "first-field", "bob", "temporal", "temporal-spatial"};
args[2] = "deint-mode";
args[3] = (char *)types[pref];
}
return try_filter(vo_c, "vdpaupp", VF_DEINTERLACE_LABEL, args);
}
if (check_output_format(vo_c, IMGFMT_VAAPI))
return try_filter(vo_c, "vavpp", VF_DEINTERLACE_LABEL, NULL);
if (check_output_format(vo_c, IMGFMT_D3D11VA) ||
check_output_format(vo_c, IMGFMT_D3D11NV12))
return try_filter(vo_c, "d3d11vpp", VF_DEINTERLACE_LABEL, NULL);
return try_filter(vo_c, "yadif", VF_DEINTERLACE_LABEL, NULL);
}
// Reconfigure the filter chain according to the new input format.
static void filter_reconfig(struct vo_chain *vo_c)
static void filter_reconfig(struct MPContext *mpctx, struct vo_chain *vo_c)
{
struct mp_image_params params = vo_c->input_format;
if (!params.imgfmt)
@@ -162,19 +201,21 @@ static void filter_reconfig(struct vo_chain *vo_c)
set_allowed_vo_formats(vo_c);
if (vf_reconfig(vo_c->vf, &params) < 0)
return;
char *filters[] = {"autorotate", "autostereo3d", NULL};
char *filters[] = {"autorotate", "autostereo3d", "deinterlace", NULL};
for (int n = 0; filters[n]; n++) {
struct vf_instance *vf = vf_find_by_label(vo_c->vf, filters[n]);
if (vf) {
if (vf)
vf_remove_filter(vo_c->vf, vf);
if (vf_reconfig(vo_c->vf, &params) < 0)
return;
}
}
if (vo_c->vf->initialized < 1) {
if (vf_reconfig(vo_c->vf, &params) < 0)
return;
}
// Make sure to reset this even if runtime deint switching is used.
video_vf_vo_control(vo_c, VFCTRL_SET_DEINTERLACE, &(int){0});
if (params.rotate && (params.rotate % 90 == 0)) {
if (!(vo_c->vo->driver->caps & VO_CAP_ROTATE90)) {
// Try to insert a rotation filter.
@@ -194,6 +235,42 @@ static void filter_reconfig(struct vo_chain *vo_c)
MP_ERR(vo_c, "Can't insert 3D conversion filter.\n");
}
}
if (mpctx->opts->deinterlace == 1)
probe_deint_filters(vo_c);
}
static void recreate_auto_filters(struct MPContext *mpctx)
{
filter_reconfig(mpctx, mpctx->vo_chain);
mp_force_video_refresh(mpctx);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
}
int get_deinterlacing(struct MPContext *mpctx)
{
struct vo_chain *vo_c = mpctx->vo_chain;
int enabled = 0;
if (video_vf_vo_control(vo_c, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK)
enabled = -1;
if (enabled < 0) {
// vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE
if (vf_find_by_label(vo_c->vf, VF_DEINTERLACE_LABEL))
enabled = 1;
}
return enabled;
}
void set_deinterlacing(struct MPContext *mpctx, bool enable)
{
if (enable == (get_deinterlacing(mpctx) > 0))
return;
mpctx->opts->deinterlace = enable;
recreate_auto_filters(mpctx);
mpctx->opts->deinterlace = get_deinterlacing(mpctx) > 0;
}
static void recreate_video_filters(struct MPContext *mpctx)
@@ -204,7 +281,7 @@ static void recreate_video_filters(struct MPContext *mpctx)
vf_destroy(vo_c->vf);
vo_c->vf = vf_new(mpctx->global);
vo_c->vf->hwdec = vo_c->hwdec_info;
vo_c->vf->hwdec_devs = vo_c->hwdec_devs;
vo_c->vf->wakeup_callback = wakeup_playloop;
vo_c->vf->wakeup_callback_ctx = mpctx;
vo_c->vf->container_fps = vo_c->container_fps;
@@ -230,7 +307,7 @@ int reinit_video_filters(struct MPContext *mpctx)
recreate_video_filters(mpctx);
if (need_reconfig)
filter_reconfig(vo_c);
filter_reconfig(mpctx, vo_c);
mp_force_video_refresh(mpctx);
@@ -314,7 +391,6 @@ void uninit_video_chain(struct MPContext *mpctx)
mpctx->video_status = STATUS_EOF;
remove_deint_filter(mpctx);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
}
}
@@ -334,7 +410,7 @@ int init_video_decoder(struct MPContext *mpctx, struct track *track)
d_video->codec = track->stream->codec;
d_video->fps = d_video->header->codec->fps;
if (mpctx->vo_chain)
d_video->hwdec_info = mpctx->vo_chain->hwdec_info;
d_video->hwdec_devs = mpctx->vo_chain->hwdec_devs;
MP_VERBOSE(d_video, "Container reported FPS: %f\n", d_video->fps);
@@ -404,7 +480,7 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src)
vo_c->vo = mpctx->video_out;
vo_c->vf = vf_new(mpctx->global);
vo_control(vo_c->vo, VOCTRL_GET_HWDEC_INFO, &vo_c->hwdec_info);
vo_c->hwdec_devs = vo_c->vo->hwdec_devs;
vo_c->filter_src = src;
if (!vo_c->filter_src) {
@@ -522,22 +598,6 @@ static int decode_image(struct MPContext *mpctx)
}
}
// Called after video reinit. This can be generally used to try to insert more
// filters using the filter chain edit functionality in command.c.
static void init_filter_params(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
// Note that the filter chain is already initialized. This code might
// recreate the chain a second time, which is not very elegant, but allows
// us to test whether enabling deinterlacing works with the current video
// format and other filters.
if (opts->deinterlace >= 0) {
remove_deint_filter(mpctx);
set_deinterlacing(mpctx, opts->deinterlace != 0);
}
}
// Feed newly decoded frames to the filter, take care of format changes.
// If eof=true, drain the filter chain, and return VD_EOF if empty.
static int video_filter(struct MPContext *mpctx, bool eof)
@@ -564,7 +624,8 @@ static int video_filter(struct MPContext *mpctx, bool eof)
return VD_PROGRESS;
// The filter chain is drained; execute the filter format change.
filter_reconfig(mpctx->vo_chain);
vf->initialized = 0;
filter_reconfig(mpctx, mpctx->vo_chain);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
@@ -586,7 +647,6 @@ static int video_filter(struct MPContext *mpctx, bool eof)
MP_FATAL(mpctx, "Cannot initialize video filters.\n");
return VD_ERROR;
}
init_filter_params(mpctx);
return VD_RECONFIG;
}
@@ -685,7 +745,7 @@ static void handle_new_frame(struct MPContext *mpctx)
double pts = mpctx->next_frames[0]->pts;
if (mpctx->video_pts != MP_NOPTS_VALUE) {
frame_time = pts - mpctx->video_pts;
double tolerance = 15;
double tolerance = mpctx->demuxer->ts_resets_possible ? 5 : 1e4;
if (frame_time <= 0 || frame_time >= tolerance) {
// Assume a discontinuity.
MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n",
@@ -1130,6 +1190,10 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
drop_repeat = MPCLAMP(drop_repeat, -num_vsyncs, num_vsyncs * 10);
num_vsyncs += drop_repeat;
// Always show the first frame.
if (mpctx->num_past_frames <= 1 && num_vsyncs < 1)
num_vsyncs = 1;
// Estimate the video position, so we can calculate a good A/V difference
// value below. This is used to estimate A/V drift.
double time_left = vo_get_delay(vo);
@@ -1356,11 +1420,13 @@ void write_video(struct MPContext *mpctx)
};
calculate_frame_duration(mpctx);
int req = vo_get_num_req_frames(mpctx->video_out);
assert(req >= 1 && req <= VO_MAX_REQ_FRAMES);
struct vo_frame dummy = {
.pts = pts,
.duration = -1,
.still = mpctx->step_frames > 0,
.num_frames = MPMIN(mpctx->num_next_frames, VO_MAX_REQ_FRAMES),
.num_frames = MPMIN(mpctx->num_next_frames, req),
.num_vsyncs = 1,
};
for (int n = 0; n < dummy.num_frames; n++)
@@ -1380,7 +1446,6 @@ void write_video(struct MPContext *mpctx)
mpctx->video_pts = mpctx->next_frames[0]->pts;
mpctx->last_vo_pts = mpctx->video_pts;
mpctx->playback_pts = mpctx->video_pts;
shift_frames(mpctx);
+7 -19
View File
@@ -159,11 +159,11 @@ static void cache_drop_contents(struct priv *s)
static void update_speed(struct priv *s)
{
int64_t now = mp_time_us();
s->speed = 0;
if (s->speed_start && s->speed_start < now)
if (s->speed_start + 1000000 <= now) {
s->speed = s->speed_amount * 1e6 / (now - s->speed_start);
s->speed_amount = 0;
s->speed_start = now;
s->speed_amount = 0;
s->speed_start = now;
}
}
// Copy at most dst_size from the cache at the given absolute file position pos.
@@ -232,11 +232,6 @@ static void cache_fill(struct priv *s)
if (mp_cancel_test(s->cache->cancel))
goto done;
if (!s->speed_start) {
s->speed_start = mp_time_us();
s->speed_amount = 0;
}
// number of buffer bytes which should be preserved in backwards direction
int64_t back = MPCLAMP(read - s->min_filepos, 0, s->back_size);
@@ -300,20 +295,12 @@ done: ;
s->eof = len <= 0;
if (!prev_eof && s->eof) {
s->eof_pos = stream_tell(s->stream);
s->speed_start = 0;
MP_VERBOSE(s, "EOF reached.\n");
}
s->idle = s->eof || !read_attempted;
s->reads++;
if (s->idle) {
update_speed(s);
s->speed_start = 0;
}
int64_t now = mp_time_us();
if (s->speed_start && s->speed_start + 1000000 <= now)
update_speed(s);
update_speed(s);
pthread_cond_signal(&s->wakeup);
}
@@ -366,7 +353,6 @@ static int resize_cache(struct priv *s, int64_t size)
s->buffer_size = buffer_size;
s->buffer = buffer;
s->idle = false;
s->speed_start = 0;
s->eof = false;
//make sure that we won't wait from cache_fill
@@ -661,6 +647,8 @@ int stream_cache_init(stream_t *cache, stream_t *stream,
cache_drop_contents(s);
s->speed_start = mp_time_us();
s->seek_limit = opts->seek_min * 1024ULL;
s->back_size = opts->back_buffer * 1024ULL;
+59 -31
View File
@@ -952,20 +952,15 @@ struct bstr stream_read_file(const char *filename, void *talloc_ctx,
return res;
}
#ifndef __MINGW32__
struct mp_cancel {
atomic_bool triggered;
#ifdef __MINGW32__
HANDLE event;
#endif
int wakeup_pipe[2];
};
static void cancel_destroy(void *p)
{
struct mp_cancel *c = p;
#ifdef __MINGW32__
CloseHandle(c->event);
#endif
close(c->wakeup_pipe[0]);
close(c->wakeup_pipe[1]);
}
@@ -975,9 +970,6 @@ struct mp_cancel *mp_cancel_new(void *talloc_ctx)
struct mp_cancel *c = talloc_ptrtype(talloc_ctx, c);
talloc_set_destructor(c, cancel_destroy);
*c = (struct mp_cancel){.triggered = ATOMIC_VAR_INIT(false)};
#ifdef __MINGW32__
c->event = CreateEventW(NULL, TRUE, FALSE, NULL);
#endif
mp_make_wakeup_pipe(c->wakeup_pipe);
return c;
}
@@ -986,19 +978,13 @@ struct mp_cancel *mp_cancel_new(void *talloc_ctx)
void mp_cancel_trigger(struct mp_cancel *c)
{
atomic_store(&c->triggered, true);
#ifdef __MINGW32__
SetEvent(c->event);
#endif
write(c->wakeup_pipe[1], &(char){0}, 1);
(void)write(c->wakeup_pipe[1], &(char){0}, 1);
}
// Restore original state. (Allows reusing a mp_cancel.)
void mp_cancel_reset(struct mp_cancel *c)
{
atomic_store(&c->triggered, false);
#ifdef __MINGW32__
ResetEvent(c->event);
#endif
// Flush it fully.
while (1) {
int r = read(c->wakeup_pipe[0], &(char[256]){0}, 256);
@@ -1018,27 +1004,12 @@ bool mp_cancel_test(struct mp_cancel *c)
// Wait until the even is signaled. If the timeout (in seconds) expires, return
// false. timeout==0 polls, timeout<0 waits forever.
#ifdef __MINGW32__
bool mp_cancel_wait(struct mp_cancel *c, double timeout)
{
return WaitForSingleObject(c->event, timeout < 0 ? INFINITE : timeout * 1000)
== WAIT_OBJECT_0;
}
#else
bool mp_cancel_wait(struct mp_cancel *c, double timeout)
{
struct pollfd fd = { .fd = c->wakeup_pipe[0], .events = POLLIN };
poll(&fd, 1, timeout * 1000);
return fd.revents & POLLIN;
}
#endif
#ifdef __MINGW32__
void *mp_cancel_get_event(struct mp_cancel *c)
{
return c->event;
}
#endif
// The FD becomes readable if mp_cancel_test() would return true.
// Don't actually read from it, just use it for poll().
@@ -1047,6 +1018,63 @@ int mp_cancel_get_fd(struct mp_cancel *c)
return c->wakeup_pipe[0];
}
#else
struct mp_cancel {
atomic_bool triggered;
HANDLE event;
};
static void cancel_destroy(void *p)
{
struct mp_cancel *c = p;
CloseHandle(c->event);
}
struct mp_cancel *mp_cancel_new(void *talloc_ctx)
{
struct mp_cancel *c = talloc_ptrtype(talloc_ctx, c);
talloc_set_destructor(c, cancel_destroy);
*c = (struct mp_cancel){.triggered = ATOMIC_VAR_INIT(false)};
c->event = CreateEventW(NULL, TRUE, FALSE, NULL);
return c;
}
void mp_cancel_trigger(struct mp_cancel *c)
{
atomic_store(&c->triggered, true);
SetEvent(c->event);
}
void mp_cancel_reset(struct mp_cancel *c)
{
atomic_store(&c->triggered, false);
ResetEvent(c->event);
}
bool mp_cancel_test(struct mp_cancel *c)
{
return c ? atomic_load_explicit(&c->triggered, memory_order_relaxed) : false;
}
bool mp_cancel_wait(struct mp_cancel *c, double timeout)
{
return WaitForSingleObject(c->event, timeout < 0 ? INFINITE : timeout * 1000)
== WAIT_OBJECT_0;
}
void *mp_cancel_get_event(struct mp_cancel *c)
{
return c->event;
}
int mp_cancel_get_fd(struct mp_cancel *c)
{
return -1;
}
#endif
char **stream_get_proto_list(void)
{
char **list = NULL;
+2
View File
@@ -384,6 +384,8 @@ static int open_cdda(stream_t *st)
st->control = control;
st->close = close_cdda;
st->streaming = true;
st->type = STREAMTYPE_CDDA;
st->demuxer = "+disc";
+35 -2
View File
@@ -55,6 +55,32 @@ static int control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
static int h_to_i(unsigned char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return -1;
}
static bool bstr_to_hex_inplace(bstr *h)
{
if (h->len % 2)
return false;
for (int n = 0; n < h->len / 2; n++) {
int hi = h_to_i(h->start[n * 2 + 0]);
int lo = h_to_i(h->start[n * 2 + 1]);
if (hi < 0 || lo < 0)
return false;
h->start[n] = (hi << 4) | lo;
}
h->len /= 2;
return true;
}
static int open_f(stream_t *stream)
{
stream->fill_buffer = fill_buffer;
@@ -68,14 +94,21 @@ static int open_f(stream_t *stream)
// Initial data
bstr data = bstr0(stream->url);
bstr_eatstart0(&data, "memory://");
bool use_hex = bstr_eatstart0(&data, "hex://");
if (!use_hex)
bstr_eatstart0(&data, "memory://");
stream_control(stream, STREAM_CTRL_SET_CONTENTS, &data);
if (use_hex && !bstr_to_hex_inplace(&p->data)) {
MP_FATAL(stream, "Invalid data.\n");
return STREAM_ERROR;
}
return STREAM_OK;
}
const stream_info_t stream_info_memory = {
.name = "memory",
.open = open_f,
.protocols = (const char*const[]){ "memory", NULL },
.protocols = (const char*const[]){ "memory", "hex", NULL },
};
+1 -1
View File
@@ -1352,7 +1352,7 @@ static int start(priv_t *priv)
if (priv->map[i].buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC)
MP_WARN(priv, "compiled without clock_gettime() that is needed to handle monotone video timestamps from the kernel. Expect desync.\n");
#endif
/* count up to make sure this is correct everytime */
/* count up to make sure this is correct every time */
priv->mapcount++;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
Loaded 100 of 236 files, more files were not shown because too many files have changed in this diff. Show more