Compare commits

...
230 Commits
Author SHA1 Message Date
Martin Herkt d1d6257731 Release 0.15.0 2016-01-18 07:28:12 +01:00
Martin Herkt ba9b2f1e49 Merge branch 'master' into release/current 2016-01-18 07:27:03 +01:00
wm4 7b4ccb3e9f image_writer: fix writing flipped images as jpg
next_scanline is usually an unsigned int.

Fixes #2635 (again).
2016-01-17 22:26:38 +01:00
wm4 4195a345a5 player: refactor: eliminate MPContext.d_video
Eventually we want the VO be driven by a A->V filter, so a decoder
doesn't even have to exist. Some features definitely require a decoder
though (like reporting the decoder in use, hardware decoding, etc.), so
for each thing which accessed d_video, it has to be redecided if and how
it can access decoder state.

At least the "framedrop" property slightly changes semantics: you can
now always set this property, even if no video is active.

Some untested changes in this commit, but our bio-based distributed
test suite has to take care of this.
2016-01-17 18:38:07 +01:00
wm4 004bc95263 player: refactor: eliminate MPContext.d_sub
The same is going to happen to d_video and d_audio later.
2016-01-17 16:57:22 +01:00
wm4 24fc176dfb command: modify OSD message when forcing original video aspect ratio
Not bothering with anything advanced, so we just show "(original)" if
the video-aspect property/option is reset.

Fixes #2722.
2016-01-16 23:23:44 +01:00
wm4 056901b2be video: refactor: disentangle decoding/filtering some more
This moves some code related to decoding from video.c to dec_video.c,
and also removes some accesses to dec_video.c from the filtering code.

dec_video.ch is starting to make sense, and simply returns video frames
from a demuxer stream. The API exposed is also somewhat intended to be
easily changeable to move decoding to a separate thread, if we ever want
this (due to libavcodec already being threaded, I don't see much of a
reason, but it might still be helpful).
2016-01-16 22:08:39 +01:00
wm4 20991a95b8 osd: make osd-width/height properties watchable 2016-01-15 22:54:08 +01:00
wm4 31adc87bde global: add client API pointer to library handle
Makes the next commit simpler. It's probably a bad idea to add more
fields to the global state, but on the other hand the client API state
is pretty much per-instance anyway. It also will help with things like
the proposed libmpv custom stream API.
2016-01-15 22:54:08 +01:00
wm4 2d4e8b623d video: refactor: slightly disentangle video filtering 2016-01-15 22:54:08 +01:00
Stefano Pigozzi bc1dce5d5b cocoa: get fps only from dislaylink
In my tests, CGDisplayModeGetRefreshRate returns 24.0 even though the nominal
one is set to 24000/1001. This is obviously not good for video.
2016-01-14 11:11:43 +01:00
Stefano Pigozzi 0fad73862c cocoa: add an observer for screenmode change 2016-01-14 11:11:43 +01:00
wm4 49690dd54b manpage: update win32 config path
Well, this probably depends on the exact Windows version.

Fixes #2611.
2016-01-14 10:34:48 +01:00
wm4 c9204fe3a5 video: fix interactively changing aspect ratio
The aspect ratio calculations are cached (mainly so that aspect ratio
related messages are not logged on every frame). The cache is not clared
anymore when video filters are reconfigured, but changing the
video-aspect-ratio property relied on it. Make it explicit.

Fixes #2714.
2016-01-14 09:46:11 +01:00
Oliver Freyermuth 24e7fac50b man: options: Clarify expected behaviour with --dvbin-full-transponder.
Since the streams are chosen from the full TS by the player frontend,
one should not expect that the program which is shown matches the chosen
channel which was used for tuning to the frequency.
Also, reformulate slightly to simplify reading.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 554c65e466 player: prefer "service_name" as media title.
If it is defined, which it rarely is (e.g. mpegts streams)
this is the preferred title information.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 8128b7c8e2 options: add "service_name" as display tag.
This is labeled as "name of the service in broadcasting (channel name)"
and exported as a generic tag by avformat-demuxers, notably lavf
when handling mpegts-streams from DVB.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 0c9b655477 demux_lavf: update metadata with information from AV_PROGRAM on switch.
Need to trigger demux_changed() manually since metadata
of tracks and streams is not changed, but demuxer-metadata
is still changed on program switch.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 9fb949b49a man: options: hint to cycling of program property.
Very helpful to switch between the different programs
on a transponder in full-transponder-mode for DVB.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 909b8f89d8 man: input: document new DVB bindings and properties.
There is now H and K for DVB-channel switching,
and the properties dvb-channel (W) and dvb-channel-name (RW).
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 77bac5b550 player: implement SWITCH for dvb-channel-name property, add binding.
The binding is similar to the tv-binding, just with capital letters.
Switching the dvb-channel-name property compared to dvb-channel
means the channel-name is shown on-screen when switching instead of
"dvb-channel (error)" otherwise,
and switching anyways happens without changing the card.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 64067a9b7c player: remove unused last_dvb_step member.
Channel switching is treated inside the global DVB state
by now. Anyways the last switching direction is not really useful
and of no interest inside the player.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 62acd315ad player, stream_dvb: implement dvb-channel-name property.
On read, it returns the name of the current DVB program,
on write, it triggers a channel-switch to the program
if it is found in the channel list of the currently active card.
Compared to the dvb-channel property which already exists
and is a pair of integers (card + channel number) this has the limitation
of not switching the card, but is probably of much more common use.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth c55b242b4e stream_dvb: global protection mutex and usage bit for global_dvb_state.
The mutex is used in dvbin_open and dvbin_close only since these are
the only entry / exit points to the stream.
When opening, it is first checked (mutexed) whether the state already exists
and is in use, then a STREAM_ERROR is returned,
since there may be only one stream_dvb active at a time.
State-creation itself is also protected by mutex.
In dvbin_close, the usage-bit is set to false (mutexed) in case
of channel switch.
In case of stream-teardown, the state is destructed
(also protected by mutex).
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 1e46bda0f8 stream_dvb: implement GET_METADATA and return program name.
Now title will be the current channel name also after channel switch.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 16723d4bb1 stream_dvb: persist state-information across channel-switches.
The state-structure is kept in a static pointer and reused on
recreation of the stream.
To not leak the state and the FDs within upon mpv shutdown,
the state-structure is still destructed gracefully in dvbin_close(),
unless a channel switch has been initiated directly before.
This fixes channel-switching for DVB which was broken since a609877.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 4c3f95708f dvb: rename dvb_config_t to dvb_state_t, keep config and state there.
The state-struct now contains everything which can be kept after initial initialization.
This includes the channel-lists, configuration, device-fds and also information like
current channel and current card.
The dvb_priv_t is kept containing the mp-options, a pointer to the state and to the logger.
After this restructuring, the state-struct contains all information which can be persisted
across channel switching.
2016-01-14 00:36:53 +01:00
wm4 9a88b118b4 video: decouple filtering/decoding slightly more
Lots of noise to remove the vfilter/vo fields from dec_video.

From now on, video filtering and output will still be done together,
summarized under struct vo_chain.

There is the question where exactly the vf_chain should go in such a
decoupled architecture. The end goal is being able to place a "complex"
filter between video decoders and output (which will culminate in
natural integration of A->V filters for natural integration of
libavfilter audio visualizations). The vf_chain is still useful for
"final" processing, such as format conversions and deinterlacing. Also,
there's only 1 VO and 1 --vf option. So having 1 vf_chain for a VO seems
ideal, since otherwise there would be no natural way to handle all these
existing options and mechanisms.

There is still some work required to truly decouple decoding.
2016-01-14 00:18:48 +01:00
wm4 785eacf4f3 player: remove stale declaration 2016-01-14 00:18:44 +01:00
wm4 5722f93a74 video: refactor: shuffle code around
struct dec_video should have nothing to do with video filters or
outputs, and this huge chunk of code was somehow stuck directly in
dec_video.c.
2016-01-14 00:18:36 +01:00
wm4 bf13bd0d47 video: refactor: handle video format fixups closer to decoder
Instead of handling this on filter chain reinit, do it directly after
the decoder. This makes the code less entangled. In particular, this
gets rid of the really weird "override params" concept in the video
filter code.

The last_format/fixed_formats have some redundance with decoder_output,
but unfortunately the latter has a slightly different use.
2016-01-14 00:18:31 +01:00
wm4 dd973da108 manpage: mention that image subtitles can not be repositioned etc.
Fixes #2707. (Not entirely following the suggestions there.)
2016-01-12 23:56:04 +01:00
wm4 cbda46370c stream: stream_read_complete() reads from current pos, not 0
(Well, I hope no caller really relied on this anyway.)
2016-01-12 23:50:17 +01:00
wm4 a4cdf1a727 demux_lavf: fix charset conversion with UTF-16 subtitles
UTF-16 subtitles are special in that they are usually read by
libavformat directly, even though they are not in UTF-8. This is
explicitly handled convert_charset() and skips conversion to UTF-8.

There was a bug due to not resetting the file position: if conversion
happens, the actual stream is replaced with a memory stream containing
the converted data, but if conversion is skipped, the original stream
with the wrong file position is kept.

Fix by always opening a memory stream. (We _could_ seek back, but there
is a slight possibility of additional failure due to unseekable
streams.)

Also, don't enter conversion if the subtitle is detected as UTF-8
either.

Fixes #2700.
2016-01-12 23:50:01 +01:00
wm4 e420464ba6 player: simplify backstepping
Basically reimplement it. The old implementation was quite stupid, and
was probably done this way because video filtering and output used to be
way less decoupled. Now we can reimplement it in a very simple way: when
backstepping, seek to current time, but keep the last frame that was
supposed to be discarded when reaching the target time. When the seek
finishes, prepend the saved frame to the video frame queue.

A disadvantage is that the new implementation fails to skip over
timeline boundaries (ordered chapters etc.), but this never worked
properly anyway. It's possible that this will be fixed some time in the
future.
2016-01-12 23:49:00 +01:00
wm4 6fc0fe4426 player: handle hrseek framedrop correctly
This was non-sense and checked the option instead of the actual flag.
Possibly could lead to incorrect hr-seeks.
2016-01-12 23:48:28 +01:00
wm4 671df54e4d demux: merge sh_video/sh_audio/sh_sub
This is mainly a refactor. I'm hoping it will make some things easier
in the future due to cleanly separating codec metadata and stream
metadata.

Also, declare that the "codec" field can not be NULL anymore. demux.c
will set it to "" if it's NULL when added. This gets rid of a corner
case everything had to handle, but which rarely happened.
2016-01-12 23:48:19 +01:00
wm4 81f3b3aafe TOOLS/stats-conv: slightly better color
pyqtgraph's intColor() is less than ideal, especially on white
background. Can't see anything.

Unfortunately the rendering of the legend can't be fixed, because
pyqtgraph is terrible and hardcodes its rendering, including colors.
2016-01-12 15:04:55 +01:00
wm4 796d5266f1 build: fix mpv.conf installation 2016-01-11 22:13:16 +01:00
Stefano Pigozzi 7c804cd796 build: add option to customize config files system path
Some packagers need to install default config files to some path but
automatically load system configuration files from another path.

See #2704
2016-01-11 21:11:10 +01:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 0915a8497b sub: read subtitles until their timestamps are past video
Change >= to >, because if the timestamps are equal, further subtitle
packets with the same timestamps could be required (e.g. ASS).
2016-01-11 20:37:16 +01:00
wm4 8135838018 player: eliminate demux_get_next_pts()
This slightly changes behavior when seeking with external audio/subtitle
tracks if transport streams and mpeg files are played, as well as
behavior when seeking with such external tracks.

get_main_demux_pts() is evil because it always blocks on the demuxer (if
there isn't already a packet queued). Thus it could lock up the player,
which is a shame because all other possible causes have been removed.

The reduced "precision" when seeking in the ts/mpeg cases (where
SEEK_FACTOR is used, resulting in byte seeks instead of timestamp seeks)
might lead to issues. We should probably drop this heuristic. (It was
introduced because there is no other way to seek in files with PTS
resets with libavformat, but its value is still questionable.)
2016-01-11 20:36:23 +01:00
wm4 f54ae2031e cache: remove useless return value
It was unused, and also returned the wrong value in some cases.
2016-01-11 20:34:34 +01:00
wm4 453ea2cb6c vaapi: replace VA_STR_FOURCC 2016-01-11 20:30:36 +01:00
wm4 9fee7077d4 ao_coreaudio: replace fourcc_repr()
Replace with the more general mp_tag_str().
2016-01-11 20:25:00 +01:00
Dmitrij D. Czarkoff 30fd858e5e etc: rename "example.conf" to "mpv.conf" 2016-01-11 20:23:13 +01:00
wm4 9acea8759b dxva2: log more debug infos
Dump the complete list of decoders and image formats. If it's a decoder
we know, add a stringified name.
2016-01-11 16:24:13 +01:00
wm4 31a4547187 ao_wasapi: move out some utility functions
Note that hresult_to_str() (coming from wasapi_explain_err()) is mostly
wasapi-specific, but since HRESULT error codes are unique, it can be
extended for any other use.
2016-01-11 16:24:13 +01:00
wm4 994459e4ce common: add mp_tag_str() utility function 2016-01-11 16:24:11 +01:00
Dmitrij D. Czarkoff a1f949d3b8 waf: add "lua51" ("51obsd") to list of possible lua names 2016-01-11 11:52:27 +01:00
Yen Chi Hsuan 459b40cc4b ytdl: Include Referer header as well
Some videos require correct Referer header for downloading, or 403
Forbidden is thrown.
2016-01-10 14:30:31 +01:00
wm4 9628edede0 TOOLS: remove old build system
I'll still use it privately, but nobody else should.
2016-01-10 14:29:06 +01:00
wm4 bd5a02d080 player: detect audio PTS jumps, make video PTS heuristic less aggressive
This is another attempt at making files with sparse video frames work
better.

The problem is that you generally can't know whether a jump in video
timestamps is just a (very) long video frame, or a timestamp reset. Due
to the existence of files with sparse video frames (new frame only every
few seconds or longer), every heuristic will be arbitrary (in general,
at least).

But we can use the fact that if video is continuous, audio should also
be continuous. Audio discontinuities can be easily detected, and if that
happens, reset some of the playback state.

The way the playback state is reset is rather radical (resets decoders
as well), but it's just better not to cause too much obscure stuff to
happen here. If the A/V sync code were to be rewritten, it should
probably strictly use PTS values (not this strange time_frame/delay
stuff), which would make it much easier to detect such situations and
to react to them.
2016-01-09 20:39:28 +01:00
wm4 2a80680d95 Fix build on older libavcodec versions
avcodec_profile_name() was added only a week ago or so.
2016-01-08 17:19:04 +01:00
wm4 8e87ddd7fe manpage: adjust documented screenshot file name
Fixes #2696.
2016-01-08 13:47:12 +01:00
wm4 e4a1086cfb img_format: fix padding calculation with P010
This was broken during refactoring commit e2d90b38 before pushing it.
2016-01-08 12:48:03 +01:00
wm4 12b4f177ec vd_lavc: log codec profile when attempting hardware decoding
Should be useful.
2016-01-08 09:22:25 +01:00
wm4 6a73fcc9ed common: allow "\/" as escape sequence
mp_parse_escape() is used by the JSON parser in json.c, and JSON allows
escaping "/" (solidus).

Although it makes no sense, apparently Javascript traditionally allowed
that as escape sequence for working around issues with embedding
Javascript in HTML. (Or something like this must have been the history
of this issue.) Since it's valid in Javascript, it had to be valid in
JSON as well, and JSON explicitly specifies it as valid escape.

Fixes #2694.
2016-01-08 09:22:25 +01:00
Oliver Freyermuth 2dd8982f73 dvb: cleanup dvb_params struct, remove some unneeded fds
One was just used as an alias, the other one (sec_fd) was not used at
all.

Signed-off-by: wm4 <wm4@nowhere>
2016-01-07 19:20:48 +01:00
wm4 6eccd4a573 img_format: fix compilation on older libavutil releases
AVComponentDescriptor.offset was introduced relatively recently. On
older releases, you have to use AVComponentDescriptor.offset_plus1,
which is now deprecated.

Instead of adding ifdeffery, assume AV_PIX_FMT_NV21 is the only format
for which this applies (and will remain the only case), which is
probably true enough.
2016-01-07 16:54:01 +01:00
wm4 27bc881cd8 vo_opengl: generic semi-planar support
Should take care of the planned FFmpeg AV_PIX_FMT_P010 addition. (This
will eventually be needed when doing HEVC Main 10 decoding with DXVA2
copyback.)
2016-01-07 16:31:52 +01:00
wm4 b0c1455aa4 img_format: add a generic flag for semi-planar formats 2016-01-07 16:30:34 +01:00
wm4 e2d90b383b img_format: take care of pixfmts that declare padding
A format could declare that some or all LSBs in a component are padding
bits by setting a non-0 AVComponentDescriptor.shift value. This means we
would interpret it incorrectly, because until now we always assumed all
regular formats have the padding in the MSBs.

Not a single format that does this actually exists, though. But a NV12
variant will be added later in FFmpeg.
2016-01-07 16:30:34 +01:00
James Ross-Gowan c19f634e6c win32: fix fd://
Windows definitely supports Unix-style fd inheritance. This mostly
worked when launched from mpv.exe, though mpv should change the file
mode to O_BINARY. When launched from mpv.com, the wrapper must pass the
list of handles (stored in the undocumented lpReserved2 and cbReserved2
fields) to the mpv process.
2016-01-07 23:37:06 +11:00
Niklas Haas 82e81421d7 filter_kernels: improve the gaussian function
Commit 3909e4cd ended up losing the ability to tune the gaussian window,
which this commit trivially reintroduces.

The constant scaling factor (present in the code copied from glumpy)
also goes against filter_kernels.c conventions, which is that f(0.0) = 1
(and the invoking code takes care of normalization), and has been
removed.

The values of this new gaussian function corresponds to different
functions when compared against the old version. To translate the old
values p1 to the new values p2 requires solving 2^(e/p1) = e^(2/p2) or
p2 = p1 * 2/(e * ln(2)) ≈ p1 * 1.0615

In other words, to get the old default in the new function requires
setting scale-param1 to 1.0615. (The new function is *slightly* sharper
by default)

(Though most users should probably not notice the change)
2016-01-07 12:17:34 +01:00
wm4 0d05038790 filter_kernels: relicense under BSD
To get a uniform license for this file, relicense the mpv parts to BSD
as well.

But leave the door open for a later change to LGPL. (All non-Glumpy code
was written within mpv, and all mpv authors have agreed to LGPL
relicensing.)

Closes #2688.
2016-01-07 11:27:18 +01:00
wm4 38636345b1 vo_opengl: hwdec_vdpau: relicense under LGPL
All code was written by myself.
2016-01-07 11:22:54 +01:00
wm4 9604c45e24 vo_opengl: video.h: fix license
This is a mistake coming from commit 6ef06aa1: it accidentally changed
the license from GPL/LGPL dual to GPL only.
2016-01-07 10:48:04 +01:00
wm4 e69d1f2780 vo_opengl: hwdec_vaegl: change license to LGPL 2.1
This file claims to be based on the "MPlayer VA-API patch", but this is
untrue. Only some glue code was copied from hwdec_vaglx.c, and this glue
code was never in MPlayer or the MPlayer VA-API patch in any form, and
instead part of the mpv-original way we do hardware decoding OpenGL
interop. The EGL interop method didn't exist at the time the MPlayer
VA-API patch was created either.
2016-01-07 10:46:15 +01:00
wm4 e9af0592d9 mpv.desktop: add audio/mp4 mime type
Who thought mime types were a good idea?
2016-01-07 09:32:11 +01:00
wm4 ce60c1adf7 player: reset playback abort when reloading a file
PT_RELOAD_FILE is a somewhat obscure case when using DVB or when
switching Matroska editions. Both cases were broken, because the
asynchronous playback abort mechanism was still triggered. This
mechanism is used to force the demuxer and stream layers to exit
immediately (instead of blocking on I/O possibly forever), and
is normally disabled on playback start. The reopen path is a bit
strange, and needs to reset it manually.

Pointed out in #2568.
2016-01-07 09:11:15 +01:00
wm4 35f43dfacb player: make watch later/resume work when "playing" directories
If you do "mpv /bla/", and then branch out into sub-directories using
playlist navigation, and then used quit and watch later, then playing
the same directory did not resume from the previous point. This was
because resuming is based on the path hash, so a path prefix can't be
detected when resuming the parent directory.

Solve this by writing each path prefix when playing directories is
involved. (This includes all parent paths, so interestingly, "mpv /"
would also resume in the above example.)

Something like this was requested multiple times, and I want it too.
2016-01-06 22:40:55 +01:00
wm4 b7e179f6d3 video: fix debug message
Should not be a warning, and the message text was also very useless.
2016-01-06 19:48:55 +01:00
wm4 3909e4cdfc filter_kernels: replace AGG-based code
This commit replaces code based on AGG, taken from this source file:

http://vector-agg.cvs.sourceforge.net/viewvc/vector-agg/agg-2.5/include/agg_image_filters.h

The intention is that filter_kernels.c can be relicensed to LGPL or BSD.
Because the AGG author died, full replacement is the only way to achieve
it.

This affects only some filter functions. These are exclusively
mathematical functions for computing filter coefficients. (Other parts
in filter_kernel.c were originally written by me, with heavy additions
and refactoring done by other mpv contributors.) While the code is
mostly just well-known mathematical formulas written down in C form,
AGG copyright could perhaps be claimed anyway.

To remove the AGG code, I replaced it with the filter functions from:

https://github.com/glumpy/glumpy/blob/master/glumpy/library/build-spatial-filters.py

These functions conveniently compute exactly the same thing in mpv,
Glumpy, AGG (and about anything that will filter images using the same
mathematical principles).

First I ported the Python code in the file to C. Then I replaced all
functions in filter_kernels.c with this code that could be replaced.
Then I investigated whether the remaining functions were based on AGG
code and took appropriate action:

hanning(), hamming(), quadric(), bicubic(), kaiser(), blackman(),
spline16(), spline36(), gaussian(), sinc() were taken straight from
Glumpy.

For sinc(), re-add the "fabs(x) < 1e-8" check, which was added in commit
586dc557 for unknown reasons.

gaussian() loses its filter parameter for some reason. (Well, who cares,
not my problem.)

The really awkward thing is that the text for hanning() and hamming()
does not change. In theory these functions are now based on Glumpy code,
but it seems like this can be neither proven nor denied. (The same
happened in some other cases with at least a few lines of code.)

sphinx() was added in commit 586dc557, and looks suspiciously like
sinc() as well. Replace the first 3 lines of the body with the ported
function (of which 2 lines do not change; the first uses code only in
mpv, and the second is just "return 1.0;"). The 4th line is only similar
on an abstract level (and that because of the mathematical relation
between these functions). Although the original sinc() was probably used
as template for it, with the other lines replaced, I don't think you
could make the claim that it falls under AGG copyright.

jinc() was added in commit 26baf5b9, but the code for it might be based
on sinc(). Rewrite it based on the "new" sinc(). Some of the same
remarks as with sphinx() apply.

cubic_bc() was ported from Glumpy's Mitchell(). (As far as I'm aware,
with the default parameters it's called "the" Mitchell-Netravali filter,
but in mpv this function is used to generate a whole group of filters.)

spline64() was added in commit a8b67c66, and was probably derived from
spline36(). Re-derive it from the "new" spline36().

triangle() could be considered derived from the original bilinear().
This is this in the original commit:

    static double bilinear(kernel *k, double x)
    {
        return 1.0 - x;
    }

This _might_ be based on AGG's image_filter_bilinear:

    struct image_filter_bilinear
    {
        static double radius() { return 1.0; }
        static double calc_weight(double x)
        {
            return 1.0 - x;
        }
    };

Considering that the "framework" was written by me, and the only part
from AGG taken is "return 1.0 - x;", and this part is trivial and was
later thoroughly replaced, this is probably not under the AGG copyright.

I'm hoping this doesn't introduce regressions. But the main focus is not
being productive anyway, and I didn't rigorously check unintended
changes in functionality.
2016-01-06 18:46:56 +01:00
wm4 3e90a5fe81 ao_dsound: remove this audio output
It existed for XP-compatibility only. There was also a time where
ao_wasapi caused issues, but we're relatively confident that ao_wasapi
works better or at least as good as ao_dsound on Windows Vista and
later.
2016-01-06 13:52:15 +01:00
Kevin Mitchell 27ccad541a ao_wasapi: remove unnecessary header file
All the wasapi files were including both ao_wasapi.h and ao_wasapi_utils.h.
Just merge them into a single file.
2016-01-05 17:47:55 -08:00
Kevin Mitchell bf611ff0f6 ao_wasapi: initialize change notify in main thread
This is something else that has nothing to do with audio rendering.
2016-01-05 17:47:55 -08:00
Kevin Mitchell 0c877d2fdc ao_wasapi: remove old vistablob prototype
this function was removed earlier, but the prototype was missed
2016-01-05 17:47:55 -08:00
Kevin Mitchell 8368ead1fa ao_wasapi: make find_deviceID read only wrt struct ao
This makes it clearer that state->device is being allocated.
2016-01-05 17:47:55 -08:00
Kevin Mitchell d22d24a6d5 ao_wasapi: move device selection to main thread
In attempt to simplify the audio event thread, this can now be moved out.
2016-01-05 17:47:55 -08:00
Kevin Mitchell fb84c6974d ao_wasapi: avoid some redundant error messages in device selection
If these error conditions are triggered, the called function will have already
output a sufficiently informantive error message.
2016-01-05 17:47:55 -08:00
Kevin Mitchell 92ded6c6fd ao_wasapi: alloc later to avoid free on error
In get_device_desc, don't alloc the return value until we know there
wasn't an error.
2016-01-05 17:47:55 -08:00
wm4 3d03298e86 audio: update outdated comment 2016-01-05 22:08:51 +01:00
wm4 c1002f6a28 ao_pulse: attempt to fall back to an arbitrary sample format
Normally, PulseAudio accepts any combination of sample format, sample
rate, channel count/map. Sometimes it does not. For example, the channel
rate or channel count have fixed maximum values. We should not fail
fatally in such cases, but attempt to fall back to a working format.

We could just send pass an "unset" format to Pulse, but this is not too
attractive. Pulse could use a format which we do not support, and also
doing so much for an obscure corner case is not reasonable. So just pick
a format that is very likely supported.

This still could fail at runtime (the stream could fail instead of going
to the ready state), but this sounds also too complicated. In
particular, it doesn't look like pulse will tell us the cause of the
stream failure. (Or maybe it does - but I didn't find anything.)

Last but not least, our fallback could be less dumb, and e.g. try to fix
only one of samplerate or channel count first to reduce the loss, but
this is also not particularly worthy the effort.

Fixes #2654.
2016-01-05 19:52:05 +01:00
wm4 861c126b08 ao_pulse: check for sample rate bounds
pa_format_info_valid() does not do this. (Although there is a proposed
patch on the PulseAudio mailing list.)

See #2654.
2016-01-05 19:37:08 +01:00
wm4 8fda7247ff ao_pulse: move format setting into a function
No real functional changes.
2016-01-05 19:34:34 +01:00
wm4 172ce98433 options: raise maximum value for --audio-samplerate
Helps with testing.
2016-01-05 19:15:21 +01:00
wm4 481d15ae60 vo_rpi: handle rotation
Since the MMAL video renderer component supports exactly what we need,
it's pretty simple.
2016-01-05 14:48:27 +01:00
wm4 0b5af5639b vo_rpi: work around firmware oddness leading to incorrect video rect
Apparently, the firmware will ignore pixel_x/pixel_y if the numeric
value of them gets too high (even if they indicate square pixel aspect
ratio). Even worse, the destination rectangle is ignored completely,
and the video frame is simply stretched to the screen. I suspect this
is an overflow or weird sanity check within the firmware.

Work it around by limiting the fields to 16000, which is an arbitrary
but apparently working limit.
2016-01-05 14:20:47 +01:00
Stefano Pigozzi 0015afd059 bundle: remove git sha from the Info.plist version
Fixes #2677
2016-01-05 12:27:04 +01:00
Chris Mayo d0cd7fa31b build: add option of html manual 2016-01-05 11:24:08 +01:00
fwr a655432bbe demux_lavf: re-enable codepage autodetection for .ass
There are a lot of incorrectly encoded subtitles with .ass extension
and non-ass subtitles (srt, ssa) with such extension, so we need to
try codepage detection even for .ass.

Signed-off-by: wm4 <wm4@nowhere>
2016-01-04 19:19:00 +01:00
wm4 09f0f68959 ao_wasapi: remove +x flag from files 2016-01-04 19:18:02 +01:00
wm4 dac5b598f5 chmap_sel: prefer inexact equivalents over perfect upmix
Given 5.1(side), this lets it pick 5.1 from [5.1, 7.1]. Which was
probably the original intention of this replacement stuff. Until now,
the opposite was done in some cases.

Keep the old heuristic if the replacement is not perfect. This would
mean that a subset of the channel layout is an inexact equivalent, but
not all of it.

(My conclusion is that audio output APIs should be designed to simply
take any channel layout, like the PulseAudio API does.)
2016-01-04 19:17:56 +01:00
Kevin Mitchell cb8b0cc329 ao_wasapi: just use a pointer to the deviceID in change_notify
Rather than creating a new string from the device instance. This will allow
moving the change_init to the main thread before the device is loaded.
2016-01-04 07:41:21 -08:00
Kevin Mitchell 029e31f1c5 ao_wasapi: correctly name the IMMNotificationClientVtbl 2016-01-04 07:41:21 -08:00
Kevin Mitchell efb9943637 ao_wasapi: make persistent enumerator local to change_notify
This is no longer required by anything else
2016-01-04 07:41:21 -08:00
Kevin Mitchell 243a2976a8 ao_wasapi: rewrite device listing and selection
Unify and clean up listing and selection. Use common enumerator code for both
operations to avoid duplication or inconsistencies.

Maintain, but significatnly simplify manual device selection by id, name or
number. This actually fixes loading by name which didn't really work before
since the "name" displayed by --audio-device=help differed from that used to
match the selection, which used the device "description" instead.

Save the selected deviceID in the private structure for later loading. This will
permit moving the device selection into the main thread in a future commit.
2016-01-04 07:41:21 -08:00
wm4 c725f39bae vo_opengl: fix operation on GLES 2.0
GLSL in GLES 2.0 did not have line continuation in its preprocessor.
This broke shader compilation. It also broke subtitle rendering in
vo_rpi, which reuses some of the OpenGL code.

Line continuation was finally added in GLES 3.0, which is perhaps the
reason why ANGLE accepted it.
2016-01-04 16:34:16 +01:00
wm4 1f38c2107d sd_ass: fix memory leaks with --sub-ass=no
This affects only the codepath which forcibly disables any ASS tags.
2016-01-04 15:29:29 +01:00
Bin Jin 2f4bd58f4a vo_opengl: reset nnedi3 weights properly
Fixes #2661
2016-01-03 23:33:54 +01:00
wm4 fa315705be x11: silence xdg-screensaver failure message 2016-01-03 15:50:00 +01:00
wm4 2c3f4850b8 player: make sure streams are selected with ordered chapters
When using --start with timeline/ordered chapters, then the
timeline_switch_to_time() function will look at playback_initialized
whether to rselect the currently selected streams on the demuxer level.
So we need to set this field to true at an earlier stage during
initialization, and in particular before the code for --start is called.
2016-01-03 15:48:47 +01:00
wm4 13ade4f1bc CONTRIBUTING: discourage reports against unmaintained releases
Seriously, why do users do this?
2016-01-03 15:42:02 +01:00
Kevin Mitchell 9163bdc38a ao_wasapi: fix delay calculation again
Apparently it's only wine where the qpc_position returned by
IAudioClock_GetPosition can be overflowed. So actually do the rescaling
correctly, but throw away the result if it looks unreasonable.

this fixes a regression in 5afa68835a
2016-01-02 08:10:52 -08:00
wm4 d5f29a3c36 options: exclude 360 from --video-rotate range
It's indeed completely useless. Pointed out in #2647.
2016-01-02 14:31:46 +01:00
wm4 de0523ba7b Update copyright year
Merry christmas, or whatever the fuck is going on right now.
2016-01-01 00:18:40 +01:00
wm4 ad072b17ce sub: do not check for duplicates if --sub-clear-on-seek is set 2015-12-31 16:43:57 +01:00
wm4 2059ba2c40 video: do not disable hr-seek framedrop too early
This didn't make too much sense, and just made seeking slower. Strictly
suggest the decoder to drop a frame if its PTS is before the seek
target.
2015-12-30 15:51:47 +01:00
Kagami Hiiragi 492e3deb95 demux_mkv: skip EBML void elements
EBML_ID_VOID might occur at any level, see:
https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown
This change prevents "Corrupt file detected" errors on completely valid
files.
2015-12-29 20:39:34 +01:00
Eric G fb185e4e79 TOOLS/zsh.pl: add .opus extension in zsh completions 2015-12-29 19:30:57 +01:00
wm4 dcffeaccf1 example.conf: minor changes
In particular, the player inserts af_scaletempo by default now when
changing speed, so the suggestion to add this was missleading and
counter-productive.
2015-12-29 01:42:31 +01:00
wm4 b5d0195023 manpage: lua: fix command names
Both variants work, but the ones with "-" are preferred now.
2015-12-29 01:36:43 +01:00
wm4 b47bf06f97 sub: change how subtitles are read
Slightly change how it is decided when a new packet should be read.
Switch to demux_read_packet_async(), and let the player "wait properly"
until required subtitle packets arrive, instead of blocking everything.
Move distinguishing the cases of passive and active reading into the
demuxer, where it belongs.
2015-12-29 01:35:52 +01:00
wm4 9b3daa4974 sub: remove packet list thing
Just a simplification. This packet list lost its function a dozen of
commits ago or so.
2015-12-28 23:31:23 +01:00
wm4 4c1deb680d sub: do charset conversion in demux_lavf.c
Just so I can remove a few lines from dec_sub.c.

This is slightly inelegant, as the whole subtitle file has to be read
into memory, converted at once in memory, and then provided to
libavformat in an awkward way by creating a memory stream instead of
using demuxer->stream. It also won't be possible to force the charset on
subtitles in binary container formats - but this wasn't exposed before,
and we just hope this won't be ever needed. (One motivation was fixing
broken files with non-UTF8 muxed.) It also won't be possible to change
the charset on the fly, but this was not exposed either.
2015-12-28 23:23:30 +01:00
wm4 97d50538cd demux_lavf: prepare for using wrapper stream instance
Preparation for the next commit.
2015-12-28 23:22:58 +01:00
Alessandro Ghedini 1f62f38106 wayland: fix typo in error message 2015-12-27 19:20:59 +01:00
wm4 d85753b79e sub: refactor initialization
Just simplify by removing parts not needed anymore. This includes
merging dec_sub allocation and initialization (since things making
initialization complicated were removed), or format support queries (it
simply tries to create a decoder, and if that fails, tries the next
one).
2015-12-27 02:13:06 +01:00
wm4 50c379e2d8 sub: minor refactor how video FPS for MicroDVD is set
So that the video FPs is not required at initialization, and can be set
later.

(As for whether this MicroDVD crap is worth the trouble to handle it
"correctly": MicroDVD files are unfortunately still around, and in at
least one case using the video FPS seemed to help indeed.)
2015-12-27 02:13:06 +01:00
wm4 d9f8b9f7b2 demux_mkv: adjust subtitle preroll defaults
Always preroll by default if the cue (index) information indicates
overlapping subtitles.

Increase the amount of maximum data it will skip to get such subtitles
to 10 seconds. Since the index information can reliably tell whether
reading earlier is needed, the maximum should be rarely actually used,
thus we can set it high. On the other hand, the "old" prerolling
mechanism always has to skip the maximum amount of data; thus the method
using the index gets its own option to control the maximum amount of
data to skip.

(As more and more files With newer mkvtoolnix versions are muxed, and
with this new and hopefully sane default established, these options can
probably be removed in the future.)
2015-12-27 02:13:06 +01:00
Stefano Pigozzi d804e7b903 README: remove pointer to homebrew-mpv 2015-12-26 23:04:04 +01:00
wm4 7df475f860 vo_rpi: fix previous commit
Meh. Fixes #2639.
2015-12-26 19:38:38 +01:00
wm4 aa587580c8 vo_rpi: fix compilation
Untested, but should be fine. Broken by commit 0a0bb905.

Also fix the include statement in context_rpi.c, which caused another
compilation failure. Also untested. (Because I'm lazy.)

Fixes #2638.
2015-12-26 19:18:47 +01:00
wm4 4d43a0c997 filter_kernels: use more precise parameters for robidoux filters
See #2637.
2015-12-26 18:37:03 +01:00
wm4 b637d6366c vo_opengl: fix gray playback
Commit f24ba544 wasn't an equivalent change.

(This shit needs some sort of automated tests.)
2015-12-26 18:36:55 +01:00
wm4 05444e8135 command: replace ROUND() with lrint()
lrint() pretty much does what ROUND() is supposed to do, but it's more
precise.
2015-12-26 18:36:45 +01:00
wm4 190dea149a sub: destroy/recreate ASS_Renderer when disabling/enablings subs
Keeping ASS_Renderers around for a potentially large number of subtitle
tracks could lead to excessive memory usage, especially since the libass
cache is broken (caches even unneeded data), and might consume up to
~500MB of memory for no reason.
2015-12-26 18:35:36 +01:00
wm4 8d4a179c14 sub: always recreate ASS_Renderer on subtitle decoder reinit
This includes the case of switching ordered chapter boundaries. It will
now be recreated on each timeline part switch. This shouldn't be much of
a problem with modern libass. (Older libass versions use fontconfig for
memory fonts, and will be very slow to reinitialize memory fonts.)
2015-12-26 18:34:18 +01:00
wm4 ce8524cb47 sub: cache subtitle state per track instead of per demuxer stream
Since commit 6d9cb893, subtitle state doesn't survive timeline switches
(ordered chapters etc.). So there is no point in caching the state per
sh_stream anymore (which would be required to deal with multiple
segments). Move the cache to struct track.

(Whether it's worth caching the subtitle state just for the situation
when subtitle tracks get reselected is questionable. But for now, it's
nice to have the subtitles immediately show up when reselecting a
subtitle.)
2015-12-26 18:32:27 +01:00
wm4 504286b006 vo_opengl: flip image if backend uses flipped rendering
Should fix #2635 (untested).
2015-12-25 15:08:41 +01:00
wm4 fb8285c7a7 command: change heuristic for files with 1 chapter
For files with only 1 chapter, the "cycle" command was ignored. Reenable
it, but don't let it terminate playback of the file.

For the full story, see #2550.

Fixes #2550.
2015-12-25 13:59:10 +01:00
wm4 7dff6a2842 player: fix previous commit
OK, this made the --sub-paths and --audio-file-paths synonyms, which is
not what we wanted. Actually restrict the type of file loaded as well.

Really fixes #2632.
2015-12-25 13:40:06 +01:00
wm4 0710ced079 options: add --audio-file-paths
Requested. It works like --sub-paths. This will also load audio files
from a "audio" sub directory in the config file (because the same code
as for subtitles is used, and it also had such a feature).

Fixes #2632.
2015-12-25 13:17:11 +01:00
wm4 6d9cb89333 sub: clear subtitle list when crossing timeline boundary
When crossing timeline boundaries (such as switching to a new segment or
chapter with ordered chapters), clear the internal text subtitle list.
This breaks the sub-seek command, but is otherwise not too harmful.
Fixes Sub-OC-test-final7.mkv. (The internal text subtitle list is
basically a cache to make subtitles show up at the right time when
seeking back.)

I suspect this was caused by 76fcef61. The sample file times subtitles
slightly before the video frame when it should show up. This is to avoid
problems with subtitles showing up a frame later than intended. It also
means that a subtitle which is supposed to show up on the start of a
timeline part boundary actually might first be shown in a different
part. Since we now manipulate the packet timestamps, instead of
manipulating timestamps after the subtitle decoder, this means this
subtitle event would have 2 timestamps, which our code of course does
not handle.

If the two parts come one after another, this would actually work (since
the subtitle would have the same timestamps in the old and new part),
but it breaks if the new part (which follows the old part in the
physical file) is has a completely different start time in the timeline.

Essentially, the trick used to time subtitles correctly is incompatible
with the way we cache subtitles (to make them survive seeks).

The simple solution is just clearing the cached subtitles when crossing
chapter boundaries.
2015-12-25 12:28:01 +01:00
wm4 940007cbf9 command: fix eof-reached property change notification in corner cases
See #2609:

"When eof is reached it would be shown on the OSD and in the console.
Next try seeking to the middle. Seeking to the middle of the file will
only result in the OSD message being updated. Lua seems to fail to
observe the change in the property until the video is unpaused."
2015-12-24 17:36:02 +01:00
wm4 bbb65ed84b sub: use macros to remove code duplication
Meh.
2015-12-24 17:32:10 +01:00
wm4 30074f8440 sub: merge bitmap render functions into one for each kind
Merge blend_src8_alpha and blend_src16_alpha into blend_src_alpha, and
the same for blend_const_alpha.

One thing that changes is that the vertical loop is now shared for both
code paths.

I think this is slightly easier to read, and it's a bit shorter as well.
2015-12-24 17:24:55 +01:00
wm4 a042dcc700 sub: remove "inaccurate" code path
The "accurate" one always has been enabled, and I can't find much
evidence that the "inaccurate" one is much faster on my particular
machine anyway.
2015-12-24 17:08:02 +01:00
wm4 3973a953df sub: find GBRP format automatically when rendering to RGB
This removes the need to define IMGFMT_GBRAP, which fixes compilation
with the current Libav release.

This also makes it automatically pick up a GBRP format with the same bit
width. (Unfortunately, it seems libswscale does not support conversion
to AV_PIX_FMT_GBRAP16, so our code falls back to 8 bit, removing
precision for video covered by subtitles in cases this code is used.)

Also, when the source video is e.g. 10 bit YUV, upsample to 16 bit.
Whether this is good or bad, it fixes behavior with alpha. Although I'm
not sure if the alpha range is really correct ([0,2^16-1] vs.
[0,255*256]). Keep in mind that libswscale doesn't even agree with the
way we do it.
2015-12-24 16:42:21 +01:00
wm4 082c23515f vo_opengl: fix operation on GLSL versions earlier than 1.30
GLSL below version 1.30 does not support mix() with a boolean
interpolation value. Use ?: instead. Untested, but probably works.
2015-12-24 14:44:46 +01:00
wm4 6bec6ac558 sub: better alpha blending when rendering to alpha surfaces
This actually treats destination alpha correctly, and gives much better
results than before. I don't know if this is perfectly correct yet,
though. Slight difference with vo_opengl behavior suggests it might not
be.

Note that this does not affect VOs with true alpha support. vo_opengl
does not use this code at all, and does the alpha calculations in OpenGL
instead.
2015-12-24 14:43:23 +01:00
wm4 946bd52a1d vo_opengl: fall back to gcc thread local storage (2)
Commit 1a6f3c56 added a fallback for the case when C11 TLS was not
available, but GCC TLS was. But it forget to enable VAAPI EGL interop in
the build system in this case.

Just remove the build system check. Should someone find a compiler that
works on Linux and does not support GCC extensions or C11, it will still
compile and just fail to init at runtime.

Actually fixes #2631 (hopefully).
2015-12-23 22:00:04 +01:00
wm4 25497226cf demux_mf: fix previous commit
It was total crap.
2015-12-23 21:58:01 +01:00
wm4 f9ba1a3ddf demux: remove weird tripple-buffering for the sh_stream list
The demuxer infrastructure was originally single-threaded. To make it
suitable for multithreading (specifically, demuxing and decoding on
separate threads), some sort of tripple-buffering was introduced. There
are separate "struct demuxer" allocations. The demuxer thread sets the
state on d_thread. If anything changes, the state is copied to d_buffer
(the copy is protected by a lock), and the decoder thread is notified.
Then the decoder thread copies the state from d_buffer to d_user (again
while holding a lock). This avoids the need for locking in the
demuxer/decoder code itself (only demux.c needs an internal, "invisible"
lock.)

Remove the streams/num_streams fields from this tripple-buffering
schema. Move them to the internal struct, and protect them with the
internal lock. Use accessors for read access outside of demux.c.

Other than replacing all field accesses with accessors, this separates
allocating and adding sh_streams. This is needed to avoid race
conditions. Before this change, this was awkwardly handled by first
initializing the sh_stream, and then sending a stream change event. Now
the stream is allocated, then initialized, and then declared as
immutable and added (at which point it becomes visible to the decoder
thread immediately).

This change is useful for PR #2626. And eventually, we should probably
get entirely of the tripple buffering, and this makes a nice first step.
2015-12-23 21:52:16 +01:00
wm4 b0381d27eb input: add a catch-all "unmapped" command
This can be used to grab all unmapped keys.

Fixes #2612.
2015-12-23 19:13:45 +01:00
wm4 3e1aed8f40 input: add key name to script-binding command response
The "script-binding" command is used by the Lua scripting wrapper to
register key bindings on the fly. It's also the only way to get fine-
grained information about key events (such as separate key up/down
events). This information is sent via a "key-binding" message when the
state of a key changes.

Extend it to send name of the mapped key itself. Previously, it was
assumed that the user just uses an unique identifier for the binding's
name, so it wasn't needed. With this change, a user can map exactly the
same command to multiple keys, which is useful especially with the next
commit.

Part of #2612.
2015-12-23 19:10:48 +01:00
wm4 ff520054c8 old-configure: add a missing define
(Why am I maintaining 2 build systems?)
2015-12-23 17:59:54 +01:00
wm4 1a6f3c56ea vo_opengl: fall back to gcc thread local storage
gcc 4.8 does not support C11 thread local storage. This is a bit
annoying, so add a hack to use the gcc specific __thread extension if
C11 TLS is not available.

(This is used for the extremely silly mpv-internal way hwdec modules
access some platform specific handles. Disabling it simply made
hwdec_vaegl.c always fail initialization.)

Fixes #2631.
2015-12-23 17:59:35 +01:00
wm4 af958221a1 CONTRIBUTING.md: add some more hints 2015-12-23 15:56:13 +01:00
wm4 2037426a65 player: minor simplification
This tmp thing had not much of a purpose anymore.
2015-12-23 15:49:20 +01:00
wm4 e8960c69e9 CONTRIBUTING.md: add missing words 2015-12-22 23:30:09 +01:00
wm4 23a5329690 stream_lavf: remove tabs
Death to tabs.
2015-12-22 23:18:46 +01:00
wm4 eac0665b8d vo_opengl: blend transparent video against tiles by default
Add a "blend-tiles" choice to the "alpha" sub-option. This is pretty
simplistic and uses the GL raster position to derive the tiles. A weird
consequence is that using --vo=opengl and --vo=opengl-hq gives different
scaling behavior (screenspace pixel size vs. source video pixel size
16x16 tiles), but it seems we don't have easy access to the original
texture coordinates. Using the rasterpos is probably simpler.

Make this option the default.
2015-12-22 23:18:46 +01:00
wm4 3de6c9aa42 Add a CONTRIBUTING.md file
Github will display a link to it when a user wants to create an issue or
pull request.

Also make some minor adjustments to DOCS/contribute.md, which is
developer oriented, and for which I see no reason to merge it with
the new file.
2015-12-22 23:18:46 +01:00
Ilya Tumaykin 8673343957 tests: fix #include 2015-12-22 15:18:50 +01:00
wm4 d1119cc069 input.conf: remove a redundant and a broken example
window-scale is now mapped to Alt+0 etc. by default (although these
bindings just use "set", not "cycle-values").

colormatrix can't be cycled anymore (would require using vf_format).
2015-12-22 14:22:54 +01:00
openingnow ad25de5903 input.conf: erase audio-delay from Not assigned by default
`ctrl+ +`is assigned as `add audio-delay` by default.
Tested by running `mpv --input-test --force-window --idle`

Signed-off-by: wm4 <wm4@nowhere>
2015-12-22 13:00:05 +01:00
Aman Gupta f8b09658f4 dec_sub: avoid segfault on sub_init_decoder failure
Broken by commit 687b552d.

Signed-off-by: wm4 <wm4@nowhere>
2015-12-22 13:00:05 +01:00
Aman Gupta d5274d9298 demux_lavf: rename to handle_new_stream to clarify intent 2015-12-22 13:00:05 +01:00
Kevin Mitchell 5afa68835a ao_wasapi: fix delay calculation
Make sure that subtraction of performance counters is done correctly.
Follow the *exact* instructions for converting performance counter to something
comparable to the QPCposition returned by IAudioClient::GetPosition
https://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx

Also make sure that subtraction of unsigned integers is stored into a signed
integer to avoid nastiness. Also be more careful about overflow in the
conversion of the device position into number of samples.

Avoid casting mp_time_us() to a double, and use llrint to convert the
double precision delay_us back to integer for ao_read_data.

Finally, actually check the return value of ao_read_data and add a verbose
message if it is not the expected value. Unfortunately,
there is no way to tell WASAPI when this happens since the frame_count in
ReleaseBuffer must match GetBuffer.
2015-12-21 16:58:51 -08:00
Aman Gupta 5360baa49e demux_lavf: make trace output for mp_seek easier to digest
Signed-off-by: wm4 <wm4@nowhere>
2015-12-21 22:29:38 +01:00
Aman Gupta fccc3d3894 Fix some typos in code comments
Signed-off-by: wm4 <wm4@nowhere>
2015-12-21 22:28:12 +01:00
wm4 7fa06e46c4 vf_yadif: change defaults
This is for the sake of command.c and the "deinterlace" option/property.
Instead of forcing certain "better" defaults when inserting yadif,
change the actual "yadif" defaults.

I pondered not changing vf_yadif, and instead adding a trivial "yadif-
auto" wrapper filter, which would merely have different defaults. But
thinking about it, it doesn't make any sense for "deinterlace" to have
different defaults from vf_yadif, with vf_yadif having the "worse"
defaults. If someone wants the old behavior, the old behavior can be
forced in a backward and forward compatible way by setting the
suboptions.

Fixes #2539 (kind of).
2015-12-21 22:05:40 +01:00
Kevin Mitchell 0afb1acab3 ao_wasapi: move volume control init to it's own function
also make failure non-fatal
2015-12-21 05:23:26 -08:00
Kevin Mitchell 05b6646d7a ao_wasapi: correctly handle audio session display failure
In particular, try and release/null the interface so that it won't be
marshalled.
2015-12-21 05:23:26 -08:00
Kevin Mitchell 35296c1f33 ao_wasapi: non-fatal error handling for COM marshalling
Also make sure that CoReleaseMarshalData is called if errors occur before
unmarshalling.
2015-12-21 05:23:22 -08:00
Kevin Mitchell 3ae726e8dd ao_wasapi: wrap long lines and use only c99 comment style
also remove a log message in AOCONTROL_UPDATE_STREAM_TITLE since
none of the other controls have one.
2015-12-21 05:03:09 -08:00
Kevin Mitchell c188240ab9 ao_wasapi: reorganize private structure 2015-12-21 05:03:09 -08:00
Kevin Mitchell 099fdde7a4 ao_wasapi: remove useless buffer_block_size
this was only ever used for a verbose message
2015-12-21 05:03:09 -08:00
Kevin Mitchell cbc951d491 ao_wasapi: move exclusive and shared-specific controls to functions 2015-12-21 05:03:03 -08:00
wm4 fc7212b214 charset_conv: check for UTF-8 if uchardet returns unknown
When libuchardet returns an empty string, it can be either ASCII, UTF-8,
or an unknown encoding. Try to distinguish it from the unknown case by
checking for UTF-8. This avoids an annoying message, and avoids
unnecessary processing (we convert invalid UTF-8 sequences to latin1 to
workaround libavcodec's braindead UTF-8 check).
2015-12-20 20:55:24 +01:00
wm4 f2187de8bb demux_disc: fix aspect ratio retrieval (again)
Commit 127da161 was not properly tested either - it did nothing, and
just made it use the video bitstream aspect ratio determined by
libavformat (which isn't always the correct one).
2015-12-20 20:50:54 +01:00
wm4 31c29495ca vo_opengl: x11: fix alpha windows
long is 64 bits on x86_64 on Linux, which means the check for the corner
case of computing the depth mask is wrong.

Also, X11 compositors seem to expect premultiplied alpha.
2015-12-20 13:26:25 +01:00
Kevin Mitchell a191712169 ao_wasapi: call the class-specific release functions
IUnknown_Release() might be alright, but stay on the safe
side.
2015-12-20 03:30:28 -08:00
Kevin Mitchell 517a35da94 ao_wasapi: check for proxy availability in control
Make sure that the proxy has been created before using it. This will be
used when a future commit makes proxy setup optional.
2015-12-20 03:30:28 -08:00
Kevin Mitchell 821e8fb9d0 ao_wasapi: actually use hw volume support information for exclusive mode
Do not try and set/get master volume in exclusive if there is no
hardware support. This would just uselessly change the master slider,
but have no effect on the actual volume.

Furthermore if getting hardware volume support information fails, then assume
it has none.
2015-12-20 03:30:28 -08:00
Kevin Mitchell 4b81398b4e ao_wasapi: don't cast control arg to something it isn't
the ao_control_vol_t cast was happening outside AOCONTROL_GET/SET_VOLUME
which is the only place that would be valid
2015-12-20 03:30:28 -08:00
Kevin Mitchell d1cbff37be ao_wasapi: remove volume "restore" on exit
It was complicated and not even very intuitive to the user.
If you are controlling the master volume, you just have to be
prepared to deal with the consequences.
2015-12-20 03:30:28 -08:00
Kevin Mitchell aa5f04c7a0 ao_wasapi: split exclusive/shared specific ao controls
this avoids having to check if we're exclusive or
shared for every control
2015-12-20 03:30:28 -08:00
Kevin Mitchell e15526153e ao_wasapi: add E_NOINTERFACE to error list
this is encountered trying to set up COM proxies in wine
2015-12-20 03:30:28 -08:00
Kevin Mitchell 48b103cad7 path-win: include initguid.h
cygwin was giving undefined reference to `FOLDERID_Desktop' at link time
2015-12-20 03:24:35 -08:00
wm4 7f313afd08 DOCS/compile-windows: pthreads is not needed anymore
Both mpv and ffmpeg have their own internal pthreads wrappers. The mpv
one has been recently enabled by default as well. (It didn't work on XP,
but we dropped XP support.)
2015-12-20 11:18:02 +01:00
James Ross-Gowan 7558d1ed7b win32: input: use Vista CancelIoEx
libwaio was added due to the complete inability to cancel synchronous
I/O cleanly using the public Windows API in Windows XP. Even calling
TerminateThread on the thread performing I/O was a bad solution, because
the TerminateThread function in XP would leak the thread's stack.

In Vista and up, however, this is no longer a problem. CancelIoEx can
cancel synchronous I/O running on other threads, allowing the thread to
exit cleanly, so replace libwaio usage with native Vista API functions.

It should be noted that this change also removes the hack added in
8a27025 for preventing a deadlock that only seemed to happen in Windows
XP. KB2009703 says that Vista and up are not affected by this, due to a
change in the implementation of GetFileType, so the hack should not be
needed anymore.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 0563eb914f win32: add Windows 10 compatibility GUID
This suppresses the Program Compatibility Assistant on Windows 10. mpv
is regularly tested on Windows 10, so this should be okay.
2015-12-20 21:06:02 +11:00
James Ross-Gowan abbb43759a win32: build: set subsystem version
This sets the minimum supported Windows version to Windows Vista. The
subsystem version also affects some Windows API functions, including
GetSystemMetrics(SM_CXPADDEDBORDER).
2015-12-20 21:06:02 +11:00
James Ross-Gowan 6205d87a7f win32: path: use Known Folder IDs
CSIDLs have been deprecated in Windows Vista and are not recommended for
use in new code. They have been replaced with Known Folder IDs, which
are pretty much the same thing, except they use GUIDs.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 491958a724 win32: use PIPE_REJECT_REMOTE_CLIENTS
This partially reverts c670488. mpv only supports Vista and up, so this
flag is fine.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 808653a9b6 win32: remove ProcThreadAttributeList dynamic loading
These are always available in supported Windows versions, as is the
EXTENDED_STARTUPINFO_PRESENT flag.
2015-12-20 21:06:02 +11:00
James Ross-Gowan d2013b3f50 win32: remove SetDllDirectoryW dynamic loading
All Windows versions we support have this API.
2015-12-20 21:06:02 +11:00
BtbN 5790bbba61 vaapi: add VP9 profile entires 2015-12-20 10:40:06 +01:00
wm4 f1a2610c4f sd_ass: handle --sub-clear-on-seek correctly with non-ASS subs
Converted subtitles use a different method to avoid adding repeated
packets as duplicate subtitle events. The state for this mechanism must
be cleared as well if --sub-clear-on-seek is used.
2015-12-20 10:14:14 +01:00
wm4 2da533bec3 vf_vapoursynth: fix everything
Broken by commit 0a0bb905. The changes to this filter were accidentally
simply not tested, and it was obviously broken in a bunch of ways.

Fixes #2616.
2015-12-20 09:55:26 +01:00
wm4 127da1613f demux_disc: fix aspect ratio
Broken by commit 0a0bb905. STREAM_CTRL_GET_ASPECT_RATIO returns a
display aspect ratio, not a pixel aspect ratio.
2015-12-20 09:36:56 +01:00
wm4 c01935986c lavc_conv: fix invalid write
Well shit. Restructure it such that the returned list is always NULL-
terminated with the same mechanism.
2015-12-19 21:21:36 +01:00
wm4 0a0bb9059f video: switch from using display aspect to sample aspect
MPlayer traditionally always used the display aspect ratio, e.g. 16:9,
while FFmpeg uses the sample (aka pixel) aspect ratio.

Both have a bunch of advantages and disadvantages. Actually, it seems
using sample aspect ratio is generally nicer. The main reason for the
change is making mpv closer to how FFmpeg works in order to make life
easier. It's also nice that everything uses integer fractions instead
of floats now (except --video-aspect option/property).

Note that there is at least 1 user-visible change: vf_dsize now does
not set the display size, only the display aspect ratio. This is
because the image_params d_w/d_h fields did not just set the display
aspect, but also the size (except in encoding mode).
2015-12-19 20:45:36 +01:00
wm4 1f7c099dc0 vf: remove old config() callback 2015-12-19 18:35:58 +01:00
wm4 78bfee53dd vf: flush before reconfig 2015-12-19 17:39:58 +01:00
wm4 cd24fdcd5a vo_opengl: disable pbo by defaults for opengl-hq
Too many problems.
2015-12-19 16:26:36 +01:00
wm4 47f2f554a3 vo_opengl: handle alpha with odd bit widths too
Since alpha isn't pulled through the colormatrix (maybe it should?), we
reject alpha formats with odd sizes, such as yuva444p10.

But the awful tex_mul path in vo_opengl does this anyway (at some points
even explicitly), which means there will be a subtle difference in
handling of 16 bit yuv alpha formats. Make it consistent and always
apply the range adjustment to the alpha component. This also means odd
sizes like 10 bit are supported now.

This assumes alpha uses the same "shifted" range as the yuv color
channels for depths larger than 8 bit. I'm not sure whether this is
actually the case.
2015-12-19 16:11:34 +01:00
wm4 a0519f1d18 vo_opengl: cocoa: output premultiplied alpha
Which is apparently what is expected here. (I'm pretty sure X11
compositors want stright alpha, so 2 code paths are needed.)
2015-12-19 14:14:12 +01:00
wm4 4cc1861378 vo_opengl: prefix per-backend source files with context_ 2015-12-19 14:14:12 +01:00
wm4 6154c1d06d vo_opengl: split backend code from common.c to context.c
Now common.c only contains the code for the function loader, while
context.c contains the backend loader/dispatcher.

Not calling it "backend.c", because the central struct is called
MPGLContext.
2015-12-19 14:14:12 +01:00
wm4 32cd85bc7e vo_opengl: x11egl: retrieve framebuffer depth
This is used for dithering, although I'm not aware of anyone who got
higher than 8 bit depth support to work on Linux.

Also put this into egl_helpers.c. Since EGL is pseudo-portable at best I
have no hope that the EGL context creation code in all the backends can
be fully shared. But some self-contained functionality can definitely be
shared.
2015-12-19 14:14:12 +01:00
wm4 3394d37b4e vo_opengl: refactor how framebuffer depth is passed from backends
Store the determined framebuffer depth in struct GL instead of
MPGLContext. This means gl_video_set_output_depth() can be removed, and
also justifies adding new fields describing framebuffer/backend
properties to struct GL instead of having to add more functions just to
shovel the information around.

Keep in mind that mpgl_load_functions() will wipe struct GL, so the
new fields must be set before calling it.
2015-12-19 14:14:12 +01:00
wm4 d2baaaa7df vo_opengl: cocoa: implement alpha window support
With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha
video without background.
2015-12-19 10:24:03 +01:00
Martin Herkt fc9eef3b81 man: fix grammar issues 2015-12-19 09:26:41 +01:00
wm4 58d45f7b3e vo_opengl: fix "win" backend name
Although the source file is named w32.c, the backend name was "win"
until recently. It was accidentally changed to "w32"; fix it.

Fixes #2608 (the manual is correct).
2015-12-19 08:39:14 +01:00
Paul B Mahol 8a9cde4999 csputils: update MP_STEREO3D_COUNT
This actually alows to playback alternating videos with mpv.
Tested with actual file found in wild remuxed to mkv and changed props
with following command:

mkvpropedit /tmp/o.mkv --edit track:1 -s stereo-mode=13

Signed-off-by: Paul B Mahol <[email protected]>
2015-12-19 08:34:46 +01:00
Paul B Mahol 3925dff2e6 csputils: let mpv recognise frame sequenced 3D matroska videos
Do actually such files exist?

Signed-off-by: Paul B Mahol <[email protected]>
2015-12-18 16:38:25 +01:00
Paul B Mahol f1909bc231 vf_stereo3d: add alternating modes
Signed-off-by: Paul B Mahol <[email protected]>
2015-12-18 15:35:06 +01:00
wm4 5dd5dc66c1 sub: remove unused video width/height headers
Apparently, this was replaced by the SD_CTRL_SET_VIDEO_PARAMS set
dimensions. But I can't find out when this happened - possibly, these
fields were never used by sd_lavc.c, and only by the (long removed)
MPlayer dvdsub decoder.
2015-12-18 03:59:52 +01:00
wm4 00135a87f0 sub: rename sd_lavc_conv.c to lavc_conv.c
The previous commit turned sd_lavc_conv from a sd_driver to
free-standing functions. Do the rename to reflect this change
separately to avoid confusing git's content tracking. (Or did
git solve this, making separating renames and content changes
unnecessary?)
2015-12-18 03:59:52 +01:00
wm4 687b552db1 sub: remove subtitle filter chain concept
It was stupid. The only thing that still effectively used it was
sd_lavc_conv - all other "filters" were the subtitle decoder/renderers
for text (sd_ass) and bitmap (sd_lavc) subtitles.

While having a subtitle filter chain was interesting (and actually
worked in almost the same way as the audio/video ones), I didn't
manage to use it in a meaningful way, and I couldn't e.g. factor
secondary features like fixing subtitle timing into filters.

Refactor the shit and drop unneeded things as it goes.
2015-12-18 03:52:57 +01:00
wm4 2c7db48195 sub: do not clear subtitle list on seeking
This affects non-ASS text subtitles (those which go through libavcodec's
subtitle converter), which are muxed with video/audio. (Typically srt
subs in mkv.)

The problem is that seeking in the file can send a subtitle packet to
the decoder multiple times. These packets are interlaved with video,
and thus can't be all read when opening the file. Rather, subtitle
packets can essentially be randomly skipped or repeated (by seeking).
Until recently, this was solved by scanning the libass event list for
duplicates. Then our builtin srt-to-ass converter was removed, and
the problem was handled by fully clearing the subtitle list on each
seek.

This resulted in sub-seek not working properly for this type of file.
Since the subtitle list was cleared on seek, it was not possible to
do e.g. sub-seeks to subtitles before the current playback position.

Fix this by not clearing the list, and intead explicitly rejecting
duplicate packets. We use the packet file position was unique ID for
subtitles; this is confirmed working for most file formats (although
it is slightly risky - new demuxers may not necessarily set the file
position to something unique, or at all).

The list of seen packets is sorted, and the lookup uses binary search.
This is to avoid quadratic complexity when subtitles are added in
bulks, such as when opening a text subtitle file.

In some places, the code has to be adjusted to pass through the packet
file position correctly.
2015-12-18 03:52:57 +01:00
Kevin Mitchell 7137afeb2c demux: check embedded cuesheet refers to only one file
If someone was "clever" enough to embed a cuesheet
referencing multiple files, mpv would create a bunch
of nonsense chapter markers.
2015-12-17 12:38:57 -08:00
Kevin Mitchell ad80cc4eee demux_cue: remove cue tracks which have a null filename.
This can happen if the file references a track, but does not specify
an INDEX 01 for it. This would cause mpv to just segfault due to
dereferencing the null pointer as a string.

A file causing this was observed in the wild by
ExactAudioCopy v0.99pb4 for a disk that contained a data track at the
end.
2015-12-17 12:38:53 -08:00
wm4 f36c17d715 demux_lavf: minor cleanups 2015-12-17 01:17:26 +01:00
wm4 04af005c35 sd_ass: remove dead code
With the FFmpeg subtitle decoder used for _all_ non-ASS text subtitle
format, this code is simply unused now.

Ironically, the FFmpeg subtitle decoder does not handle things correctly
in a bunch of cases. Should it turn out they actually matter, they will
have to hack back.

The extend_event one is a candidate, although even though there were
allegedly files which need it, I couldn't get samples from the user who
originally reported such files. As such, extend_event was only confirmed
to handle trailing events with no (endless) duration like with MicroDVD
and LRC, but FFmpeg "fudges" these anyway, so no special handling is
needed.

This code also had logic to handle seeking with muxed srt subtitles,
which made the sub-seek command work. But this has been broken before
this commit already. Currently, seeking with muxed srt subs will clear
all subtitles, as the broken FFmpeg ASS format output by the libavcodec
subtitle converters does not check for duplicates. Since the subtitles
are all cleared, ass_step_sub() can not work properly and sub-seek can
not seek to already seen subtitles.
2015-12-17 01:17:26 +01:00
wm4 74c11f0c84 sub: detect charset in demuxer
Slightly simpler, and removes the need to pre-read all subtitle packets.

This still does the subtitle charset conversion on the packet level
(instead converting when parsing the file), so in theory this still
could provide a way to change the charset at runtime. But maybe even
this should be removed, as FFmpeg is somewhat likely to get its own
charset detection and conversion mechanism in the future. (Would have
to keep the subtitle file in memory to allow changing the charset on
the fly, I guess.)
2015-12-17 01:17:23 +01:00
wm4 e798cf1ff6 sub: remove sd_srt.c
The FFmpeg subtitle converter does the same. There used to be some
deficiencies in FFmpeg's code, but it seems at least some of them have
been fixed. There also used to be the timestamp issue (see previous
commit messages), but this doesn't matter anymore. So no reason to
keep this code - get rid of it.
2015-12-15 21:05:48 +01:00
wm4 cab942acae sub: remove sd_microdvd.c
This can be dropped for the same reasons as in the previous commits. It
removes MicroDVD conversion support on Libav, although MicroDVD files
couldn't be read in the first place ever since demux_subreader.c was
removed.
2015-12-15 21:05:48 +01:00
wm4 c7985fe5f7 sub: remove sd_lavf_srt.c
This restored timestamps when demuxing srt subtitles in Libav, which
was important for avoiding slightly overlapping subtitles. Since the
way this works was changed, there is no real reason to maintain proper
timestamps anymore on this level - this can be dropped without issues.
2015-12-15 21:05:48 +01:00
wm4 29226e6a99 sub: remove sd_movtext.c
libavcodec's movtext-to-ass converter does the same and has more
features. On Libav, this commit disables mp4 subtitle display.
2015-12-15 21:05:48 +01:00
James Ross-Gowan d0fd68f6df vo_opengl: dxinterop: prevent crash after lost device
When a Direct3D 9Ex device fails to reset, it gets put into the lost
state, so set the lost_device flag and don't attempt to present until
the device moves out of that state. Failure to recreate the size-
dependent objects should set lost_device as well, since we shouldn't try
to present in that state.

Also, it looks like I was too eager to remove code that sets priv
members to NULL and I accidentally removed some that was needed.
2015-12-14 23:09:54 +11:00
James Ross-Gowan 8d0a6cd035 vo_opengl: dxinterop: prevent crash with 0-size window
Direct3D doesn't like 0-sized swapchain dimensions, even when those
dimensions are automatically set. Manually set them to a size that isn't
zero instead.
2015-12-14 01:11:56 +11:00
wm4 f24ba544cd vo_opengl: enable brightness/contrast controls for RGB
Why not.

Also, instead of disabling hue/saturation for RGB, just don't apply
them. (They don't make sense for conversion matrixes other than YUV, but
I can't be bothered to keep the fine-grained disabling of UI controls
either.)
2015-12-12 14:47:30 +01:00
wm4 000285ee8e mixer: fix volume initialization with --af=volume
A manually added af_volume could lead to muted audio when switching to a
new file. af_volume keeps the last volume set by AF_CONTROL_SET_VOLUME
to return it with AF_CONTROL_GET_VOLUME, but the initial value is 0. So
the mixer volume was forced to 0 when unintializing the filter chain and
reading back the previously set volume.
2015-12-11 20:52:37 +01:00
wm4 67a4892ee3 mixer: minor simplification
(Why is this code so complex?)
2015-12-11 20:52:37 +01:00
233 changed files with 4591 additions and 7430 deletions

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
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.
- 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.
+1 -38
View File
@@ -68,7 +68,7 @@ echo "MXE_TARGETS := i686-w64-mingw32.static" >> settings.mk
# Build required packages. The following provide a minimum required to build
# a reasonable mpv binary (though not an absolute minimum).
make gcc ffmpeg libass jpeg pthreads lua
make gcc ffmpeg libass jpeg lua
# Add MXE binaries to $PATH
export PATH=/opt/mxe/usr/bin/:$PATH
@@ -173,40 +173,3 @@ mv -f /mingw64/bin/libmpv.dll.a /mingw64/lib/
sed -i 's_/mingw64/bin_/mingw64/lib_' /mingw64/lib/pkgconfig/mpv.pc
rmdir /mingw64/bin/pkgconfig
```
Additional dependencies
=======================
pthreads
--------
mpv will use a pthreads wrapper by default. Either pthreads-win32 or
winpthreads should work. The latter is packaged with most MinGW-w64
environments, including MSYS2, so it shouldn't be a problem. If you don't have
a pthreads wrapper or you want to build mpv without one, configure with:
```bash
./waf configure --enable-win32-internal-pthreads
```
libwaio
-------
If you want to use ``--input-file``, you need libwaio. It's available from
git://midipix.org/waio
To compile libwaio in MSYS2, run:
```bash
git clone git://midipix.org/waio && cd waio
# 32-bit build, run from mingw32_shell.bat
./build-mingw-nt32 lib-static CC=gcc AR=ar
cp -r include/waio /mingw32/include
cp lib32/libwaio.a /mingw32/lib
# 64-bit build, run from mingw64_shell.bat
./build-mingw-nt64 lib-static CC=gcc AR=ar
cp -r include/waio /mingw64/include
cp lib64/libwaio.a /mingw64/lib
```
+11 -9
View File
@@ -14,9 +14,11 @@ Sending patches
``git format-patch``. diffs posted as pastebins (especially if the http link
returns HTML) just cause extra work for everyone, because they lack commit
message and authorship information.
- When creating pull requests, be sure to test your changes. If you didn't, please
say so in the pull request message.
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
repository root directory).
- When creating pull requests, be sure to test your changes. If you didn't,
please say so in the pull request message.
- Write informative commit messages. Use present tense to describe the
situation with the patch applied, and past tense for the situation before
the change.
@@ -27,8 +29,8 @@ Sending patches
For example, you fixed a crash in af_volume.c:
Bad: ``fixed the bug (wtf?)``
Good: ``af_volume: fix crash due to null pointer access``
- Bad: ``fixed the bug (wtf?)``
- Good: ``af_volume: fix crash due to null pointer access``
Having a prefix gives context, and is especially useful when trying to find
a specific change by looking at the history, or when running ``git blame``.
@@ -53,10 +55,10 @@ Sending patches
something like reformatting a whole file, and hiding an actual functional
change in the same commit.
- If you add a new command line option, document it in options.rst. If you
add a new input property, document it in input.rst.
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
repository root directory).
add a new input property, document it in input.rst. Changes to the user
interface (options, properties, commands) should be documented in
interface-changes.rst. Changes to libmpv should be documented in
client-api-changes.rst.
Code formatting
---------------
+2
View File
@@ -19,6 +19,8 @@ Interface changes
::
--- mpv 0.15.0 ---
- change "yadif" video filter defaults
--- mpv 0.14.0 ---
- vo_opengl interpolation now requires --video-sync=display-... to be set
- change some vo_opengl defaults (including changing tscale)
+6 -20
View File
@@ -20,10 +20,8 @@ normal driver parameters.
See ``--ao=help`` for a list of compiled-in audio output drivers. The
driver ``--ao=alsa`` is preferred. ``--ao=pulse`` is preferred on systems
where PulseAudio is used. On Windows, ``--ao=wasapi`` is preferred,
though it might cause trouble sometimes, in which case ``--ao=dsound``
should be used. On BSD systems, ``--ao=oss`` or `--ao=sndio`` may work
(the latter being experimental). On OS X systems, use ``--ao=coreaudio``.
where PulseAudio is used. On BSD systems, ``--ao=oss`` or ``--ao=sndio``
may work (the latter being experimental).
.. admonition:: Examples
@@ -165,7 +163,7 @@ Available audio output drivers are:
will actually work. The disadvantage is that it will change the
system-wide audio settings. This is equivalent to changing the ``Format``
setting in the ``Audio Devices`` dialog in the ``Audio MIDI Setup``
utility. Note that this does not effect the selected speaker setup.
utility. Note that this does not affect the selected speaker setup.
``exclusive``
Use exclusive mode access. This merely redirects to
@@ -205,19 +203,7 @@ Available audio output drivers are:
(it used to be required to get good behavior on old PulseAudio versions).
If you have stuttering video when using pulse, try to enable this
option. (Or alternatively, try to update PulseAudio.)
``dsound`` (Windows only)
DirectX DirectSound audio output driver
.. note:: This driver is for compatibility with old systems.
``device=<devicenum>``
Sets the device number to use. Playing a file with ``-v`` will show a
list of available devices.
``buffersize=<ms>``
DirectSound buffer size in milliseconds (default: 200).
option. (Or try to update PulseAudio.)
``sdl``
SDL 1.2+ audio output driver. Should work on any platform supported by SDL
@@ -256,7 +242,7 @@ Available audio output drivers are:
``speed``
Simulated audio playback speed as a multiplier. Usually, a real audio
device will not go exactly as fast as the system clock. It will deviate
just a little, and this option helps simulating this.
just a little, and this option helps to simulate this.
``latency``
Simulated device latency. This is additional to EOF.
@@ -325,7 +311,7 @@ Available audio output drivers are:
String are valid; the GUID string is guaranteed to not change
unless the driver is uninstalled.
Also supports searching active devices by human readable name. If more
Also supports searching active devices by human-readable name. If more
than one device matches the name, refuses loading it.
This option is mostly deprecated in favour of the more general
+4 -4
View File
@@ -93,8 +93,8 @@ You can encode files from one format/codec to another using this facility.
Completely empties the options list.
``--oafirst``
Force the audio stream to become the first stream in the output. By default
the order is unspecified.
Force the audio stream to become the first stream in the output.
By default, the order is unspecified.
``--ovc=<codec>``
Specifies the output video codec. This can be a comma separated list of
@@ -134,8 +134,8 @@ You can encode files from one format/codec to another using this facility.
Completely empties the options list.
``--ovfirst``
Force the video stream to become the first stream in the output. By default
the order is unspecified.
Force the video stream to become the first stream in the output.
By default, the order is unspecified.
``--ocopyts``
Copies input pts to the output video (not supported by some output
+36 -16
View File
@@ -418,7 +418,7 @@ List of Input Commands
<reselect> (default)
Select the default audio and subtitle streams, which typically selects
external files with highest preference. (The implementation is not
external files with the highest preference. (The implementation is not
perfect, and could be improved on request.)
<keep-selection>
@@ -546,6 +546,12 @@ Input Commands that are Possibly Subject to Change
Always bind a key. (The input section that was made active most recently
wins if there are ambiguities.)
This command can be used to dispatch arbitrary keys to a script or a client
API user. If the input section defines ``script-binding`` commands, it is
also possible to get separate events on key up/down, and relatively detailed
information about the key state. The special key name ``unmapped`` can be
used to match any unmapped key.
``overlay-add <id> <x> <y> "<file>" <offset> "<fmt>" <w> <h> <stride>``
Add an OSD overlay sourced from raw data. This might be useful for scripts
and applications controlling mpv, and which want to display things on top
@@ -647,14 +653,20 @@ Input Commands that are Possibly Subject to Change
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
included), where the first argument is the string ``key-binding``, the
second argument is the name of the binding, and the third argument is the
key state as string. The key state consists of a number of letters. The
first letter is one of ``d`` (key was pressed down), ``u`` (was released),
``r`` (key is still down, and was repeated; only if key repeat is enabled
for this binding), ``p`` (key was pressed; happens if up/down can't be
tracked). The second letter whether the event originates from the mouse,
either ``m`` (mouse button) or ``-`` (something else).
included), with the following arguments:
1. The string ``key-binding``.
2. The name of the binding (as established above).
3. The key state as string (see below).
4. The key name (since mpv 0.15.0).
The key state consists of 2 letters:
1. One of ``d`` (key was pressed down), ``u`` (was released), ``r`` (key
is still down, and was repeated; only if key repeat is enabled for this
binding), ``p`` (key was pressed; happens if up/down can't be tracked).
2. Whether the event originates from the mouse, either ``m`` (mouse button)
or ``-`` (something else).
``ab-loop``
Cycle through A-B loop states. The first command will set the ``A`` point
@@ -782,7 +794,7 @@ Input sections group a set of bindings, and enable or disable them at once.
In ``input.conf``, each key binding is assigned to an input section, rather
than actually having explicit text sections.
Also see ``enable_section`` and ``disable_section`` commands.
See also: ``enable_section`` and ``disable_section`` commands.
Predefined bindings:
@@ -961,9 +973,8 @@ Property list
``playback-time`` (RW)
Position in current file in seconds. Unlike ``time-pos``, the time is
clamped to the range of the file. (Inaccurate file durations etc. could
make it go out of range. Also helpful when the user attempts to seek
outside of the file, as the seek target time is considered the current
position during seeking.)
make it go out of range. Useful on attempts to seek outside of the file,
as the seek target time is considered the current position during seeking.)
``chapter`` (RW)
Current chapter number. The number of the first chapter is 0.
@@ -1109,13 +1120,13 @@ Property list
``vf-metadata/<filter-label>``
Metadata added by video filters. Accessed by the filter label,
which if not explicitly specified using the ``@filter-label:`` syntax,
which, if not explicitly specified using the ``@filter-label:`` syntax,
will be ``<filter-name>NN``.
Works similar to ``metadata`` property. It allows the same access
methods (using sub-properties).
An example of these kind of metadata are the cropping parameters
An example of this kind of metadata are the cropping parameters
added by ``--vf=lavfi=cropdetect``.
``af-metadata/<filter-label>``
@@ -1142,7 +1153,7 @@ Property list
``cache-size`` (RW)
Network cache size in KB. This is similar to ``--cache``. This allows
to set the cache size at runtime. Currently, it's not possible to enable
setting the cache size at runtime. Currently, it's not possible to enable
or disable the cache at runtime using this property, just to resize an
existing cache.
@@ -1531,6 +1542,15 @@ Property list
``program`` (W)
Switch TS program (write-only).
``dvb-channel`` (W)
Pair of integers: card,channel of current DVB stream.
Can be switched to switch to another channel on the same card.
``dvb-channel-name`` (RW)
Name of current DVB program.
On write, a channel-switch to the named channel on the same
card is performed. Can also be used for channel switching.
``sid`` (RW)
Current subtitle track (similar to ``--sid``).
+5 -3
View File
@@ -111,7 +111,7 @@ rely on this.
Commands
--------
Additionally to the commands described in `List of Input Commands`_, a few
In addition to the commands described in `List of Input Commands`_, a few
extra commands can also be used as part of the protocol:
``client_name``
@@ -189,7 +189,7 @@ extra commands can also be used as part of the protocol:
``unobserve_property``
Undo ``observe_property`` or ``observe_property_string``. This requires the
numeric id passed to the observe command as argument.
numeric id passed to the observed command as argument.
Example:
@@ -228,7 +228,9 @@ extra commands can also be used as part of the protocol:
``get_version``
Returns the client API version the C API of the remote mpv instance
provides. (Also see ``DOCS/client-api-changes.rst``.)
provides.
See also: ``DOCS/client-api-changes.rst``.
UTF-8
-----
+6 -6
View File
@@ -198,7 +198,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
be called (unless the user remapped the key with another binding).
The ``name`` argument should be a short symbolic string. It allows the user
to remap the key binding via input.conf using the ``script_message``
to remap the key binding via input.conf using the ``script-message``
command, and the name of the key binding (see below for
an example). The name should be unique across other bindings in the same
script - if not, the previous binding with the same name will be
@@ -220,8 +220,8 @@ The ``mp`` module is preloaded, although it can be loaded manually with
has an ``is_mouse`` entry, which tells whether the event was caused
by a mouse button.
Internally, key bindings are dispatched via the ``script_message_to`` or
``script_binding`` input commands and ``mp.register_script_message``.
Internally, key bindings are dispatched via the ``script-message-to`` or
``script-binding`` input commands and ``mp.register_script_message``.
Trying to map multiple commands to a key will essentially prefer a random
binding, while the other bindings are not called. It is guaranteed that
@@ -244,7 +244,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
::
y script_binding something
y script-binding something
This will print the message when the key ``y`` is pressed. (``x`` will
@@ -255,7 +255,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
::
y script_binding fooscript.something
y script-binding fooscript.something
``mp.add_forced_key_binding(...)``
This works almost the same as ``mp.add_key_binding``, but registers the
@@ -389,7 +389,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
``mp.get_script_name()``
Return the name of the current script. The name is usually made of the
filename of the script, with directory and file extension removed. If
there are several script which would have the same name, it's made unique
there are several scripts which would have the same name, it's made unique
by appending a number.
.. admonition:: Example
+17 -14
View File
@@ -50,7 +50,7 @@ UP and DOWN
Ctrl+LEFT and Ctrl+RIGHT
Seek to the previous/next subtitle. Subject to some restrictions and
might not work always; see ``sub_seek`` command.
might not always work; see ``sub_seek`` command.
[ and ]
Decrease/increase current playback speed by 10%.
@@ -222,7 +222,10 @@ PREVIOUS and NEXT
support.)
h and k
Select previous/next channel.
Select previous/next tv-channel.
H and K
Select previous/next dvb-channel.
Mouse Control
-------------
@@ -520,8 +523,9 @@ TAKING SCREENSHOTS
Screenshots of the currently played file can be taken using the 'screenshot'
input mode command, which is by default bound to the ``s`` key. Files named
``shotNNNN.jpg`` will be saved in the working directory, using the first
available number - no files will be overwritten.
``mpv-shotNNNN.jpg`` will be saved in the working directory, using the first
available number - no files will be overwritten. In pseudo-GUI mode, the
screenshot will be saved somewhere else. See `PSEUDO GUI MODE`_.
A screenshot will usually contain the unscaled video contents at the end of the
video filter chain and subtitles. By default, ``S`` takes screenshots without
@@ -571,7 +575,7 @@ listed.
certainty.
- Dropped frames, e.g. ``Dropped: 4``. Shows up only if the count is not 0. Can
grow if the video framerate is higher than that of the display, or if video
rendering is too slow. Also can be incremented on "hiccups" and when the video
rendering is too slow. May also be incremented on "hiccups" and when the video
frame couldn't be displayed on time. (``vo-drop-frame-count`` property.)
If the decoder drops frames, the number of decoder-dropped frames is appended
to the display as well, e.g.: ``Dropped: 4/34``. This happens only if
@@ -602,7 +606,7 @@ PROTOCOLS
Play a path from Samba share.
``bd://[title][/device]`` ``--bluray-device=PATH``
Play a Blu-Ray disc. Currently, this does not accept ISO files. Instead,
Play a Blu-ray disc. Currently, this does not accept ISO files. Instead,
you must mount the ISO file as filesystem, and point ``--bluray-device``
to the mounted directory directly.
@@ -654,9 +658,8 @@ PROTOCOLS
absolute path.
``fd://123``
Read data from the given UNIX FD (for example 123). This is similar to
piping data to stdin via ``-``, but can use an arbitrary file descriptor.
Will not work correctly on MS Windows.
Read data from the given file descriptor (for example 123). This is similar
to piping data to stdin via ``-``, but can use an arbitrary file descriptor.
``edl://[edl specification as in edl-mpv.rst]``
Stitch together parts of multiple files and play them.
@@ -728,7 +731,7 @@ EMBEDDING INTO OTHER PROGRAMS (LIBMPV)
======================================
mpv can be embedded into other programs as video/audio playback backend. The
recommended way to to so is using libmpv. See ``libmpv/client.h`` in the mpv
recommended way to do so is using libmpv. See ``libmpv/client.h`` in the mpv
source code repository. This provides a C API. Bindings for other languages
might be available (see wiki).
@@ -803,7 +806,7 @@ libdvdcss:
key
is the default method. libdvdcss will use a set of calculated
player keys to try and get the disc key. This can fail if the drive
player keys to try to get the disc key. This can fail if the drive
does not recognize any of the player keys.
disc
@@ -919,7 +922,7 @@ locations are different. They are generally located under ``%APPDATA%/mpv/``.
For example, the path to mpv.conf is ``%APPDATA%/mpv/mpv.conf``, which maps to
a system and user-specific path, for example
``C:\users\USERNAME\Application Data\mpv\mpv.conf``
``C:\users\USERNAME\AppData\Roaming\mpv\mpv.conf``
You can find the exact path by running ``echo %APPDATA%\mpv\mpv.conf`` in cmd.exe.
@@ -942,8 +945,8 @@ lower priority. Some config files are loaded only once, which means that
e.g. of 2 ``input.conf`` files located in two config directories, only the
one from the directory with higher priority will be loaded.
A third config directory with lowest priority is the directory named ``mpv``
in the same directory as ``mpv.exe``. This used to be the directory with
A third config directory with the lowest priority is the directory named ``mpv``
in the same directory as ``mpv.exe``. This used to be the directory with the
highest priority, but is now discouraged to use and might be removed in the
future.
+58 -29
View File
@@ -136,7 +136,9 @@ Playback Control
``--chapter=<start[-end]>``
Specify which chapter to start playing at. Optionally specify which
chapter to end playing at. Also see ``--start``.
chapter to end playing at.
See also: ``--start``.
``--playlist-pos=<no|index>``
Set which file on the internal playlist to start playback with. The index
@@ -321,7 +323,7 @@ Program Behavior
Files explicitly requested by command line options, like
``--include`` or ``--use-filedir-conf``, will still be loaded.
Also see ``--config-dir``.
See also: ``--config-dir``.
``--list-options``
Prints all available options.
@@ -558,7 +560,7 @@ Video
``--display-fps=<fps>``
Set the display FPS used with the ``--video-sync=display-*`` modes. By
default a detected value is used (X11 only, not correct on multi-monitor
default, a detected value is used (X11 only, not correct on multi-monitor
systems). Keep in mind that setting an incorrect value (even if slightly
incorrect) can ruin video playback.
@@ -613,7 +615,7 @@ Video
For ``opengl-cb``, if set, load the interop context as soon as the OpenGL
context is created. Since ``opengl-cb`` has no on-demand loading, this
allows enabling hardware decoding at runtime at all, without having to
allows enabling hardware decoding at runtime at all, without having
to temporarily set the ``hwdec`` option just during OpenGL context
initialization with ``mpv_opengl_cb_init_gl()``.
@@ -675,7 +677,7 @@ Video
example ``--video-zoom`` does nothing if this option is enabled.)
The video and monitor aspects aspect will be ignored. Aspect correction
would require to scale the video in the X or Y direction, but this option
would require scaling the video in the X or Y direction, but this option
disables scaling, disabling all aspect correction.
Note that the scaler algorithm may still be used, even if the video isn't
@@ -695,7 +697,7 @@ Video
This option is disabled if the ``--no-keepaspect`` option is used.
``--video-rotate=<0-360|no>``
``--video-rotate=<0-359|no>``
Rotate the video clockwise, in degrees. Currently supports 90° steps only.
If ``no`` is given, the video is never rotated, even if the file has
rotation metadata. (The rotation value is added to the rotation metadata,
@@ -820,7 +822,7 @@ Video
You can get the list of allowed codecs with ``mpv --vd=help``. Remove the
prefix, e.g. instead of ``lavc:h264`` use ``h264``.
By default this is set to ``h264,vc1,wmv3,hevc,mpeg2video``. Note that the
By default, this is set to ``h264,vc1,wmv3,hevc,mpeg2video``. Note that the
hardware acceleration special codecs like ``h264_vdpau`` are not relevant
anymore, and in fact have been removed from Libav in this form.
@@ -1027,7 +1029,9 @@ Audio
``--mute=<auto|yes|no>``
Set startup audio mute status. ``auto`` (default) will not change the mute
status. Also see ``--volume``.
status.
See also: ``--volume``.
``--softvol=<mode>``
Control whether to use the volume controls of the audio output driver or
@@ -1152,8 +1156,8 @@ Audio
point of file change. Default: ``weak``.
:no: Disable gapless audio.
:yes: The audio device is opened using parameters chosen according to the
first file played and is then kept open for gapless playback. This
:yes: The audio device is opened using parameters chosen for the first
file played and is then kept open for gapless playback. This
means that if the first file for example has a low sample rate, then
the following files may get resampled to the same low sample rate,
resulting in reduced sound quality. If you play files with different
@@ -1200,7 +1204,11 @@ 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 audio files in the current directory.
:all: Load all aufio files in the current and ``--audio-file-paths``
directories.
``--audio-file-paths=<path1:path2:...>``
Equivalent to ``--sub-paths`` option, but for auto-loaded audio files.
``--audio-client-name=<name>``
The application name the player reports to the audio API. Can be useful
@@ -1237,6 +1245,14 @@ Audio
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 in ASS format are normally not changed intentionally, but
overriding them can be controlled with ``--ass-style-override``.
``--no-sub``
Do not select any subtitle when the file is loaded.
@@ -1600,10 +1616,10 @@ Subtitles
``<rate>`` > video fps speeds the subtitles up for frame-based
subtitle files and slows them down for time-based ones.
Also see ``--sub-speed`` option.
See also: ``--sub-speed``.
``--sub-gauss=<0.0-3.0>``
Apply Gaussian blur to image subtitles (default: 0). This can help making
Apply Gaussian blur to image subtitles (default: 0). This can help to make
pixelated DVD/Vobsubs look nicer. A value other than 0 also switches to
software subtitle scaling. Might be slow.
@@ -1612,7 +1628,7 @@ Subtitles
Never applied to text subtitles.
``--sub-gray``
Convert image subtitles to grayscale. Can help making yellow DVD/Vobsubs
Convert image subtitles to grayscale. Can help to make yellow DVD/Vobsubs
look nicer.
.. note::
@@ -1984,8 +2000,8 @@ Window
always re-enabled when the player is paused.
This is not supported on all video outputs or platforms. Sometimes it is
implemented, but does not work (happens often on GNOME). You might be able
to to work this around using ``--heartbeat-cmd`` instead.
implemented, but does not work (known to happen with GNOME). You might be
able to work around this using ``--heartbeat-cmd`` instead.
``--wid=<ID>``
This tells mpv to attach to an existing window. If a VO is selected that
@@ -2004,7 +2020,7 @@ Window
parent, like with X11.
On OSX/Cocoa, the ID is interpreted as ``NSView*``. Pass it as value cast
to ``intptr_t``. mpv will creates its own sub-view. Because OSX does not
to ``intptr_t``. mpv will create its own sub-view. Because OSX does not
support window embedding of foreign processes, this works only with libmpv,
and will crash when used from the command line.
@@ -2213,7 +2229,7 @@ Demuxer
Encryption key the demuxer should use. This is the raw binary data of
the key converted to a hexadecimal string.
``--demuxer-mkv-subtitle-preroll``, ``--mkv-subtitle-preroll``
``--demuxer-mkv-subtitle-preroll=<yes|index|no>``, ``--mkv-subtitle-preroll``
Try harder to show embedded soft subtitles when seeking somewhere. Normally,
it can happen that the subtitle at the seek target is not shown due to how
some container file formats are designed. The subtitles appear only if
@@ -2245,7 +2261,11 @@ Demuxer
overlap with a seek target. In these cases, mpv will reduce the amount
of data read to a minimum. (Although it will still read *all* data between
the cluster that contains the first wanted subtitle packet, and the seek
target.)
target.) If the ``index`` choice (which is the default) is specified, then
prerolling will be done only if this information is actually available. If
this method is used, the maximum amount of data to skip can be additionally
controlled by ``--demuxer-mkv-subtitle-preroll-secs-index`` (it still uses
the value of the option without ``-index`` if that is higher).
See also ``--hr-seek-demuxer-offset`` option. This option can achieve a
similar effect, but only if hr-seek is active. It works with any demuxer,
@@ -2257,6 +2277,9 @@ Demuxer
``--demuxer-mkv-subtitle-preroll-secs=<value>``
See ``--demuxer-mkv-subtitle-preroll``.
``--demuxer-mkv-subtitle-preroll-secs-index=<value>``
See ``--demuxer-mkv-subtitle-preroll``.
``--demuxer-mkv-probe-video-duration=<yes|no|full>``
When opening the file, seek to the end of it, and check what timestamp the
last video packet has, and report that as file duration. This is strictly
@@ -2381,7 +2404,7 @@ Input
``--input-key-fifo-size=<2-65000>``
Specify the size of the FIFO that buffers key events (default: 7). If it
is too small some events may be lost. The main disadvantage of setting it
is too small, some events may be lost. The main disadvantage of setting it
to a very large value is that if you hold down a key triggering some
particularly slow command then the player may be unresponsive while it
processes all the queued commands.
@@ -2448,7 +2471,7 @@ Input
On X11, a sub-window with input enabled grabs all keyboard input as long
as it is 1. a child of a focused window, and 2. the mouse is inside of
the sub-window. The can steal away all keyboard input from the
the sub-window. It can steal away all keyboard input from the
application embedding the mpv window, and on the other hand, the mpv
window will receive no input if the mouse is outside of the mpv window,
even though mpv has focus. Modern toolkits work around this weird X11
@@ -2718,7 +2741,7 @@ Screenshot
Specify the filename template used to save screenshots. The template
specifies the filename without file extension, and can contain format
specifiers, which will be substituted when taking a screenshot.
By default the template is ``mpv-shot%n``, which results in filenames like
By default, the template is ``mpv-shot%n``, which results in filenames like
``mpv-shot0012.png`` for example.
The template can start with a relative or absolute path, in order to
@@ -2874,7 +2897,7 @@ Terminal
Particularly useful on slow terminals or broken ones which do not properly
handle carriage return (i.e. ``\r``).
Also see ``--really-quiet`` and ``--msg-level``.
See also: ``--really-quiet`` and ``--msg-level``.
``--really-quiet``
Display even less output and status messages than with ``--quiet``.
@@ -3007,8 +3030,9 @@ TV
maximum size of the capture buffer in megabytes (default: dynamical)
``--tv-norm=<value>``
See the console output for a list of all available norms, also see the
``normid`` option below.
See the console output for a list of all available norms.
See also: ``--tv-normid``.
``--tv-normid=<value> (v4l2 only)``
Sets the TV norm to the given numeric ID. The TV norm depends on the
@@ -3218,7 +3242,7 @@ Cache
multiple cache streams, and using the same file for them obviously
clashes.
Also see ``--cache-file-size``.
See also: ``--cache-file-size``.
``--cache-file-size=<kBytes>``
Maximum size of the file created with ``--cache-file``. For read accesses
@@ -3346,8 +3370,13 @@ DVB
``--dvbin-full-transponder=<yes|no>``
Apply no filters on program PIDs, only tune to frequency and pass full
transponder to demuxer. This is useful to record multiple programs
on a single transponder, or to work around issues in the ``channels.conf``.
transponder to demuxer.
The player frontend selects the streams from the full TS in this case,
so the program which is shown initially may not match the chosen channel.
Switching between the programs is possible by cycling the ``program``
property.
This is useful to record multiple programs on a single transponder,
or to work around issues in the ``channels.conf``.
It is also recommended to use this for channels which switch PIDs
on-the-fly, e.g. for regional news.
@@ -3380,7 +3409,7 @@ Miscellaneous
implement a perfect audio delay measurement. With this value, if large A/V
sync offsets occur, they will only take about 1 or 2 seconds to settle
out. This delay in reaction time to sudden A/V offsets should be the only
side-effect of turning this option on, for all sound drivers.
side effect of turning this option on, for all sound drivers.
``--video-sync=<audio|...>``
How the player synchronizes audio and video.
+17 -18
View File
@@ -151,15 +151,15 @@ Available filters are:
:yes: Enable accurate rounding.
``dsize[=w:h:aspect-method:r:aspect]``
Changes the intended display size/aspect at an arbitrary point in the
Changes the intended display aspect at an arbitrary point in the
filter chain. Aspect can be given as a fraction (4/3) or floating point
number (1.33). Alternatively, you may specify the exact display width and
height desired. Note that this filter does *not* do any scaling itself; it
number (1.33). Note that this filter does *not* do any scaling itself; it
just affects what later scalers (software or hardware) will do when
auto-scaling to the correct aspect.
``<w>,<h>``
New display width and height.
New aspect ratio given by a display width and height. Unlike older mpv
versions or MPlayer, this does not set the display size.
Can also be these special values:
@@ -438,9 +438,8 @@ Available filters are:
generating an occasional mismatched frame, but it may also cause an
excessive number of frames to be dropped during high motion sequences.
Conversely, setting it to -1 will make ``pullup`` match fields more
easily. This may help processing of video where there is slight
blurring between the fields, but may also cause there to be interlaced
frames in the output.
easily. This may help process video with slight blurring between the
fields, but may also cause interlaced frames in the output.
``mp`` (metric plane)
This option may be set to ``u`` or ``v`` to use a chroma plane instead of the
@@ -455,16 +454,15 @@ Available filters are:
``<mode>``
:frame: Output 1 frame for each frame.
:field: Output 1 frame for each field.
:field: Output 1 frame for each field (default).
:frame-nospatial: Like ``frame`` but skips spatial interlacing check.
:field-nospatial: Like ``field`` but skips spatial interlacing check.
``<interlaced-only>``
:no: Deinterlace all frames (default).
:yes: Only deinterlace frames marked as interlaced (default if this
filter is inserted via ``deinterlace`` property).
:no: Deinterlace all frames.
:yes: Only deinterlace frames marked as interlaced (default).
This filter, is automatically inserted when using the ``d`` key (or any
This filter is automatically inserted when using the ``d`` key (or any
other key that toggles the ``deinterlace`` property or when using the
``--deinterlace`` switch), assuming the video output does not have native
deinterlacing support.
@@ -473,7 +471,7 @@ Available filters are:
into ``--vf-defaults`` instead, and enable deinterlacing with ``d`` or
``--deinterlace``.
Also note that the ``d`` key is stupid enough to insert a deinterlacer twice
Also, note that the ``d`` key is stupid enough to insert a deinterlacer twice
when inserting yadif with ``--vf``, so using the above methods is
recommended.
@@ -645,10 +643,11 @@ Available filters are:
``buffered-frames``
Maximum number of decoded video frames that should be buffered before
the filter (default: 4). This specifies the maximum number of frames
the script can requests backwards. E.g. if ``buffered-frames=5``, and
the script just requested frame 15, it can still request frame 10, but
frame 9 is not available anymore. If it requests frame 30, mpv will
decode 15 more frames, and keep only frames 25-30.
the script can request in reverse direction.
E.g. if ``buffered-frames=5``, and the script just requested frame 15,
it can still request frame 10, but frame 9 is not available anymore.
If it requests frame 30, mpv will decode 15 more frames, and keep only
frames 25-30.
The actual number of buffered frames also depends on the value of the
``concurrent-frames`` option. Currently, both option values are
@@ -803,6 +802,6 @@ Available filters are:
``buffer=<num>``
Buffer ``<num>`` frames in the filter chain. This filter is probably pretty
useless, except for debugging. (Note that this won't help smoothing out
useless, except for debugging. (Note that this won't help to smooth out
latencies with decoding, because the filter will never output a frame if
the buffer isn't full, except on EOF.)
+17 -13
View File
@@ -447,10 +447,12 @@ Available video output drivers are:
Note that this option never affects ``cscale``.
``pbo``
Enable use of PBOs. This is slightly faster, but can sometimes lead to
sporadic and temporary image corruption (in theory, because reupload
is not retried when it fails), and perhaps actually triggers slower
paths with drivers that don't support PBOs properly.
Enable use of PBOs. On some drivers this can be faster, especially if
the source video size is huge (e.g. so called "4K" video). On other
drivers it might be slower or cause latency issues.
In theory, this can sometimes lead to sporadic and temporary image
corruption (because reupload is not retried when it fails).
``dither-depth=<N|no|auto>``
Set dither target depth to N. Default: no.
@@ -481,7 +483,7 @@ Available video output drivers are:
``temporal-dither``
Enable temporal dithering. (Only active if dithering is enabled in
general.) This changes between 8 different dithering pattern on each
general.) This changes between 8 different dithering patterns on each
frame by changing the orientation of the tiled dithering matrix.
Unfortunately, this can lead to flicker on LCD displays, since these
have a high reaction time.
@@ -492,7 +494,7 @@ Available video output drivers are:
video frame, 2 on every other frame, etc.
``debug``
Check for OpenGL errors, i.e. call ``glGetError()``. Also request a
Check for OpenGL errors, i.e. call ``glGetError()``. Also, request a
debug OpenGL context (which does nothing with current graphics drivers
as of this writing).
@@ -741,7 +743,7 @@ Available video output drivers are:
``glfinish``
Call ``glFinish()`` before and after swapping buffers (default: disabled).
Slower, but might help getting better results when doing framedropping.
Slower, but might improve results when doing framedropping.
Can completely ruin performance. The details depend entirely on the
OpenGL driver.
@@ -770,9 +772,9 @@ Available video output drivers are:
The value ``auto`` will try to determine whether the compositor is
active, and calls ``DwmFlush`` only if it seems to be.
This may help getting more consistent frame intervals, especially with
high-fps clips - which might also reduce dropped frames. Typically a
value of ``windowed`` should be enough since full screen may bypass the
This may help to get more consistent frame intervals, especially with
high-fps clips - which might also reduce dropped frames. Typically, a
value of ``windowed`` should be enough, since full screen may bypass the
DWM.
Windows only.
@@ -955,9 +957,11 @@ Available video output drivers are:
things like softsubbed ASS signs to match the video colors,
but may cause SRT subtitles or similar to look slightly off.
``alpha=<blend|yes|no>``
Decides what to do if the input has an alpha component (default: blend).
``alpha=<blend-tiles|blend|yes|no>``
Decides what to do if the input has an alpha component.
blend-tiles
Blend the frame against a 16x16 gray/white tiles background (default).
blend
Blend the frame against a black background.
yes
@@ -984,7 +988,7 @@ Available video output drivers are:
This is equivalent to::
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:correct-downscaling:sigmoid-upscaling:pbo:deband:es=no
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:correct-downscaling:sigmoid-upscaling:deband:es=no
Note that some cheaper LCDs do dithering that gravely interferes with
``opengl``'s dithering. Disabling dithering with ``dither-depth=no`` helps.
-4
View File
@@ -111,10 +111,6 @@ the separately available build wrapper ([mpv-build][mpv-build]) that first compi
libraries and libass, and then compiles the player statically linked against
those.
If you are running Mac OSX and using homebrew we provide [homebrew-mpv][homebrew-mpv], an up
to date formula that compiles mpv with sensible dependencies and defaults for
OSX.
If you want to build a Windows binary, you either have to use MSYS2 and MinGW,
or cross-compile from Linux with MinGW. See [Windows compilation][windows_compilation].
+78
View File
@@ -1,3 +1,81 @@
Release 0.15.0
==============
Build System Changes
--------------------
- OS X bundle: remove git sha from the Info.plist version (issue #2677)
- add "lua51" ("51obsd") to list of possible lua names
- add option to customize config files system path (issue #2704)
Features
--------
New
~~~
- vo_opengl: implement support for transparent video display on OS X (alpha=yes suboption)
- vo_opengl: use a checkerboard pattern as background for transparent video by default
Options and Commands
--------------------
Added
~~~~~
- add --audio-file-paths (issue #2632)
- player, stream_dvb: implement dvb-channel-name property, add switch binding
Changed
~~~~~~~
- vf_stereo3d: add alternating modes
- vo_opengl: disable pbo by default for opengl-hq due to driver problems
- vf_yadif: change defaults (issue #2539)
- command: change heuristic for files with 1 chapter (issue #2550)
- demux_mkv: adjust subtitle preroll defaults
- exclude 360 from --video-rotate range (issue #2647)
- osd: make osd-width/height properties watchable
Fixes and Minor Enhancements
----------------------------
- ao_pulse: check for sample rate bounds, attempt fallback (issue #2654)
- ao_wasapi: remove volume "restore" on exit
- demux_cue: better error resilience
- mixer: fix volume initialization with --af=volume
- mpv.desktop: add audio/mp4 mime type
- player: detect audio PTS jumps, make video PTS heuristic less aggressive
- player: make watch later/resume work when "playing" directories
- player: reset playback abort when reloading a file (issue #2568)
- recognize frame sequenced 3D Matroska video
- stream_dvb: fix channel switching
- vaapi: add VP9 profile (requires VA-API 0.38.1 or newer)
- vo_opengl: dxinterop: prevent crash after lost device
- vo_opengl: enable brightness/contrast controls for RGB
- vo_opengl: fix operation on GLES 2.0
- vo_opengl: fix operation on GLSL versions earlier than 1.30
- vo_opengl: flip screenshot image if backend uses flipped rendering (issue #2635)
- vo_opengl: reset nnedi3 weights properly (issue #2661)
- vo_rpi: handle rotation
- vo_rpi: work around firmware oddness leading to incorrect video rect
- windows: fix fd://
- ytdl: Include Referer header as well
- TOOLS/zsh.pl: add .opus extension in zsh completions
This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API. A complete changelog can be seen by running
`git log v0.14.0..v0.15.0` in the git repository or by visiting either
https://github.com/mpv-player/mpv/compare/v0.14.0...v0.15.0 or
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.14.0..v0.15.0
Release 0.14.0
==============
-1013
View File
File diff suppressed because it is too large. Load diff
-488
View File
@@ -1,488 +0,0 @@
# MPlayer Makefile
#
# copyright (c) 2008 Diego Biurrun
# Rewritten entirely from a set of Makefiles written by Arpi and many others.
#
# This file is part of MPlayer.
#
# MPlayer is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# MPlayer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with MPlayer; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include old_build/config.mak
###### variable declarations #######
SOURCES_AUDIO_INPUT-$(ALSA) += stream/ai_alsa1x.c
SOURCES_AUDIO_INPUT-$(OSS_AUDIO)+= stream/ai_oss.c
SOURCES_AUDIO_INPUT-$(SNDIO) += stream/ai_sndio.c
SOURCES-$(AUDIO_INPUT) += $(SOURCES_AUDIO_INPUT-yes)
SOURCES-$(CDDA) += stream/stream_cdda.c
SOURCES-$(DVBIN) += stream/dvb_tune.c \
stream/stream_dvb.c
SOURCES-$(DVDREAD) += stream/stream_dvd.c \
stream/stream_dvd_common.c
SOURCES-$(DVDNAV) += stream/stream_dvdnav.c \
stream/stream_dvd_common.c
SOURCES-$(RUBBERBAND) += audio/filter/af_rubberband.c
SOURCES-$(LIBASS) += sub/ass_mp.c sub/sd_ass.c
SOURCES-$(LIBBLURAY) += stream/stream_bluray.c
SOURCES-$(LIBSMBCLIENT) += stream/stream_smb.c
SOURCES-$(TV) += stream/stream_tv.c stream/tv.c \
stream/frequencies.c stream/tvi_dummy.c \
demux/demux_tv.c
SOURCES-$(TV_V4L2) += stream/tvi_v4l2.c stream/audio_in.c
SOURCES-$(DUMMY_OSD) += sub/osd_dummy.c
SOURCES-$(LIBASS_OSD) += sub/osd_libass.c
SOURCES-$(ALSA) += audio/out/ao_alsa.c
SOURCES-$(CACA) += video/out/vo_caca.c
SOURCES-$(SDL2) += audio/out/ao_sdl.c video/out/vo_sdl.c
SOURCES-$(GL) += video/out/opengl/common.c \
video/out/opengl/osd.c \
video/out/opengl/lcms.c \
video/out/opengl/video.c \
video/out/opengl/video_shaders.c \
video/out/dither.c \
video/out/opengl/hwdec.c \
video/out/opengl/utils.c \
video/out/opengl/superxbr.c \
video/out/opengl/nnedi3.c \
video/out/vo_opengl.c \
video/out/vo_opengl_cb.c
SOURCES-$(ENCODING) += video/out/vo_lavc.c audio/out/ao_lavc.c \
common/encode_lavc.c
SOURCES-$(GL_X11) += video/out/x11_common.c video/out/opengl/x11.c
SOURCES-$(EGL_X11) += video/out/x11_common.c video/out/opengl/x11egl.c
SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \
video/out/opengl/wayland.c
SOURCES-$(JACK) += audio/out/ao_jack.c
SOURCES-$(OPENAL) += audio/out/ao_openal.c
SOURCES-$(OSS_AUDIO) += audio/out/ao_oss.c
SOURCES-$(PULSE) += audio/out/ao_pulse.c
SOURCES-$(RSOUND) += audio/out/ao_rsound.c
SOURCES-$(SNDIO) += audio/out/ao_sndio.c
SOURCES-$(VDPAU) += video/vdpau.c video/vdpau_mixer.c \
video/out/vo_vdpau.c video/decode/vdpau.c \
video/filter/vf_vdpaupp.c \
video/filter/vf_vdpaurb.c
SOURCES-$(VDPAU_GL_X11) += video/out/opengl/hwdec_vdpau.c
SOURCES-$(VAAPI) += video/out/vo_vaapi.c \
video/decode/vaapi.c \
video/filter/vf_vavpp.c \
video/vaapi.c
SOURCES-$(VAAPI_GLX) += video/out/opengl/hwdec_vaglx.c
SOURCES-$(VAAPI_X_EGL) += video/out/opengl/hwdec_vaegl.c
SOURCES-$(X11) += video/out/vo_x11.c video/out/x11_common.c
SOURCES-$(XV) += video/out/vo_xv.c
SOURCES-$(WAYLAND) += video/out/vo_wayland.c \
video/out/wayland_common.c \
video/out/wayland/buffer.c \
video/out/wayland/memfile.c
SOURCES-$(LIBAVFILTER) += video/filter/vf_lavfi.c \
video/filter/vf_gradfun.c \
video/filter/vf_pullup.c \
video/filter/vf_rotate.c \
video/filter/vf_yadif.c \
audio/filter/af_lavfi.c
SOURCES-$(LUA) += player/lua.c
SOURCES-$(VAPOURSYNTH_CORE) += video/filter/vf_vapoursynth.c
SOURCES-$(LIBARCHIVE) += demux/demux_libarchive.c \
stream/stream_libarchive.c
SOURCES-$(DLOPEN) += video/filter/vf_dlopen.c
SOURCES = audio/audio.c \
audio/audio_buffer.c \
audio/chmap.c \
audio/chmap_sel.c \
audio/fmt-conversion.c \
audio/format.c \
audio/mixer.c \
audio/decode/ad_lavc.c \
audio/decode/ad_spdif.c \
audio/decode/dec_audio.c \
audio/filter/af.c \
audio/filter/af_channels.c \
audio/filter/af_delay.c \
audio/filter/af_equalizer.c \
audio/filter/af_format.c \
audio/filter/af_lavcac3enc.c \
audio/filter/af_lavrresample.c \
audio/filter/af_pan.c \
audio/filter/af_scaletempo.c \
audio/filter/af_drc.c \
audio/filter/af_volume.c \
audio/filter/tools.c \
audio/out/ao.c \
audio/out/ao_null.c \
audio/out/ao_pcm.c \
audio/out/pull.c \
audio/out/push.c \
common/av_common.c \
common/av_log.c \
common/codecs.c \
common/common.c \
common/msg.c \
common/playlist.c \
common/tags.c \
common/version.c \
demux/codec_tags.c \
demux/cue.c \
demux/demux.c \
demux/demux_edl.c \
demux/demux_cue.c \
demux/demux_disc.c \
demux/demux_lavf.c \
demux/demux_mf.c \
demux/demux_mkv.c \
demux/demux_mkv_timeline.c \
demux/demux_playlist.c \
demux/demux_rar.c \
demux/demux_raw.c \
demux/ebml.c \
demux/packet.c \
demux/timeline.c \
input/cmd_list.c \
input/cmd_parse.c \
input/event.c \
input/input.c \
input/ipc.c \
input/keycodes.c \
misc/bstr.c \
misc/charset_conv.c \
misc/dispatch.c \
misc/json.c \
misc/rendezvous.c \
misc/ring.c \
options/m_config.c \
options/m_option.c \
options/m_property.c \
options/options.c \
options/parse_commandline.c \
options/parse_configfile.c \
options/path.c \
osdep/io.c \
osdep/path-unix.c \
osdep/semaphore_osx.c \
osdep/subprocess.c \
osdep/subprocess-posix.c \
osdep/terminal-unix.c \
osdep/timer.c \
osdep/timer-linux.c \
osdep/threads.c \
player/audio.c \
player/client.c \
player/configfiles.c \
player/command.c \
player/external_files.c \
player/loadfile.c \
player/main.c \
player/misc.c \
player/osd.c \
player/playloop.c \
player/screenshot.c \
player/scripting.c \
player/sub.c \
player/video.c \
stream/cache.c \
stream/cache_file.c \
stream/cookies.c \
stream/rar.c \
stream/stream.c \
stream/stream_avdevice.c \
stream/stream_edl.c \
stream/stream_file.c \
stream/stream_lavf.c \
stream/stream_memory.c \
stream/stream_mf.c \
stream/stream_null.c \
stream/stream_rar.c \
sub/dec_sub.c \
sub/draw_bmp.c \
sub/img_convert.c \
sub/osd.c \
sub/sd_lavc.c \
sub/sd_lavc_conv.c \
sub/sd_lavf_srt.c \
sub/sd_microdvd.c \
sub/sd_movtext.c \
sub/sd_srt.c \
ta/ta.c \
ta/ta_utils.c \
ta/ta_talloc.c \
video/csputils.c \
video/fmt-conversion.c \
video/gpu_memcpy.c \
video/image_writer.c \
video/img_format.c \
video/mp_image.c \
video/mp_image_pool.c \
video/sws_utils.c \
video/decode/dec_video.c \
video/decode/vd_lavc.c \
video/filter/vf.c \
video/filter/vf_buffer.c \
video/filter/vf_crop.c \
video/filter/vf_dsize.c \
video/filter/vf_eq.c \
video/filter/vf_expand.c \
video/filter/vf_flip.c \
video/filter/vf_format.c \
video/filter/vf_mirror.c \
video/filter/vf_noformat.c \
video/filter/vf_scale.c \
video/filter/vf_stereo3d.c \
video/filter/vf_sub.c \
video/out/bitmap_packer.c \
video/out/aspect.c \
video/out/filter_kernels.c \
video/out/vo.c \
video/out/vo_null.c \
video/out/vo_image.c \
video/out/win_state.c \
$(SOURCES-yes)
OBJECTS += $(addsuffix .o, $(basename $(SOURCES)))
OBJECTS += $(OBJECTS-yes)
DEP_FILES = $(patsubst %.S,%.d,$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(SOURCES:.m=.d) $(SOURCES:.m=.d))))
ALL_TARGETS += mpv
INSTALL_BIN += install-mpv
INSTALL_BIN_STRIP += install-mpv-strip
INSTALL_MAN =
ifeq ($(BUILD_MAN),yes)
INSTALL_MAN += install-mpv-man
ALL_TARGETS += DOCS/man/mpv.1
endif
DIRS = . \
audio \
audio/decode \
audio/filter \
audio/out \
common \
compat \
input \
player/timeline \
demux \
misc \
options \
osdep \
osdep/ar \
player \
stream \
sub \
ta \
video \
video/decode \
video/filter \
video/out
ADDSUFFIXES = $(foreach suf,$(1),$(addsuffix $(suf),$(2)))
ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
###### brief build output #######
ifndef V
$(eval override CC = @printf "CC\t$$@\n"; $(CC))
$(eval override RM = @$(RM))
endif
###### generic rules #######
all: $(ALL_TARGETS)
%.1: %.rst
$(RST2MAN) $< $@
%.o: %.c
$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
mpv: $(OBJECTS) osdep/main-fn-unix.o
$(CC) -o $@ $^ $(EXTRALIBS)
input/input.c: input/input_conf.h
input/input_conf.h: TOOLS/file2string.pl etc/input.conf
./$^ >$@
MKVLIB_DEPS = TOOLS/lib/Parse/Matroska.pm \
TOOLS/lib/Parse/Matroska/Definitions.pm \
TOOLS/lib/Parse/Matroska/Element.pm \
TOOLS/lib/Parse/Matroska/Reader.pm \
TOOLS/lib/Parse/Matroska/Utils.pm \
demux/ebml.c demux/demux_mkv.c: demux/ebml_types.h
demux/ebml_types.h: TOOLS/matroska.pl $(MKVLIB_DEPS)
./$< --generate-header > $@
demux/ebml.c: demux/ebml_defs.c
demux/ebml_defs.c: TOOLS/matroska.pl $(MKVLIB_DEPS)
./$< --generate-definitions > $@
video/out/x11_common.c: video/out/x11_icon.inc
video/out/x11_icon.inc: TOOLS/file2string.pl video/out/x11_icon.bin
./$^ >$@
video/out/opengl/nnedi3.c: video/out/opengl/nnedi3_weights.inc
video/out/opengl/nnedi3_weights.inc: TOOLS/file2string.pl video/out/opengl/nnedi3_weights.bin
./$^ >$@
sub/osd_libass.c: sub/osd_font.h
sub/osd_font.h: TOOLS/file2string.pl sub/osd_font.otf
./$^ >$@
player/lua/%.inc: TOOLS/file2string.pl player/lua/%.lua
./$^ >$@
player/lua.c: player/lua/defaults.inc \
player/lua/assdraw.inc \
player/lua/osc.inc \
player/lua/ytdl_hook.inc \
player/lua/options.inc
etc/_mpv: TOOLS/zsh.pl ./mpv
./$< > $@
# ./configure must be rerun if it changed
config.mak: configure
@echo "############################################################"
@echo "####### Please run ./configure again - it's changed! #######"
@echo "############################################################"
old_build/version.h .version: version.sh
./version.sh --versionh=old_build/version.h
# Force version.sh to run to potentially regenerate version.h
-include .version
%: %.c
$(CC) $(CFLAGS) -o $@ $^
###### dependency declarations / specific CFLAGS ######
common/version.c: old_build/version.h
DOCS/man/mpv.1: DOCS/man/af.rst \
DOCS/man/ao.rst \
DOCS/man/changes.rst \
DOCS/man/encode.rst \
DOCS/man/input.rst \
DOCS/man/options.rst \
DOCS/man/vf.rst \
DOCS/man/vo.rst
###### installation / clean / generic rules #######
install: $(INSTALL_BIN) install-data $(INSTALL_MAN)
install-no-man: $(INSTALL_BIN) install-data
install-strip: $(INSTALL_BIN_STRIP) install-data $(INSTALL_MAN)
install-strip-no-man: $(INSTALL_BIN_STRIP) install-data
install-dirs:
if test ! -d $(BINDIR) ; then $(INSTALL) -d $(BINDIR) ; fi
install-%: % install-dirs
$(INSTALL) -m 755 $< $(BINDIR)
install-%-strip: % install-dirs
$(INSTALL) -m 755 -s $< $(BINDIR)
install-mpv-man: install-mpv-man-en
install-mpv-man-en: DOCS/man/mpv.1
if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi
$(INSTALL) -m 644 DOCS/man/mpv.1 $(MANDIR)/man1/
ICONSIZES = 16x16 32x32 64x64
define ICON_INSTALL_RULE
install-mpv-icon-$(size): etc/mpv-icon-8bit-$(size).png
$(INSTALL) -d $(prefix)/share/icons/hicolor/$(size)/apps
$(INSTALL) -m 644 etc/mpv-icon-8bit-$(size).png $(prefix)/share/icons/hicolor/$(size)/apps/mpv.png
endef
$(foreach size,$(ICONSIZES),$(eval $(ICON_INSTALL_RULE)))
install-mpv-icons: $(foreach size,$(ICONSIZES),install-mpv-icon-$(size))
install-mpv-desktop: etc/mpv.desktop
$(INSTALL) -d $(prefix)/share/applications
$(INSTALL) -m 644 etc/mpv.desktop $(prefix)/share/applications/
install-mpv-config: etc/encoding-profiles.conf
$(INSTALL) -d $(CONFDIR)
$(INSTALL) -m 644 etc/encoding-profiles.conf $(CONFDIR)
install-mpv-zsh: etc/_mpv
$(INSTALL) -d $(prefix)/share/zsh/vendor-completions
$(INSTALL) -m 644 etc/_mpv $(prefix)/share/zsh/vendor-completions/
install-data: install-mpv-icons install-mpv-desktop install-mpv-config install-mpv-zsh
uninstall:
$(RM) $(BINDIR)/mpv
$(RM) $(MANDIR)/man1/mpv.1 $(MANDIR)/man1/mpv.1
$(RM) $(prefix)/share/applications/mpv.desktop
$(RM) $(prefix)/share/zsh/vendor-completions/_mpv
$(RM) $(foreach size,$(ICONSIZES),$(prefix)/share/icons/hicolor/$(size)/apps/mpv.png)
clean:
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.d /*.a /*.ho /*~)
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.a /*.ho /*~)
-$(RM) mpv
-$(RM) DOCS/man/*/mpv.1
-$(RM) old_build/version.h version.h
-$(RM) input/input_conf.h
-$(RM) video/out/vdpau_template.c
-$(RM) demux/ebml_types.h demux/ebml_defs.c
-$(RM) video/out/x11_icon.inc
-$(RM) sub/osd_font.h
-$(RM) player/lua/defaults.inc
-$(RM) player/lua/assdraw.inc
-$(RM) player/lua/osc.inc
-$(RM) player/lua/ytdl_hook.inc
-$(RM) player/lua/options.inc
distclean: clean
-$(RM) config.log old_build/config.h old_build/config.mak Makefile
-rmdir old_build/
-include $(DEP_FILES)
.PHONY: all *install* *clean .version
# Disable suffix rules. Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:
# If a command returns failure but changed its target file, delete the
# (presumably malformed) file. Otherwise the file would be considered to
# be up to date if make is restarted.
.DELETE_ON_ERROR:
+10 -1
View File
@@ -39,8 +39,17 @@ def apply_plist_template(plist_file, version):
for line in fileinput.input(plist_file, inplace=1):
print (line.rstrip().replace('${VERSION}', version))
def bundle_version():
if os.path.exists('VERSION'):
x = open('VERSION')
version = x.read()
x.close()
else:
version = sh("./version.sh").strip()
return version
def main():
version = sh("./version.sh").strip()
version = bundle_version().rstrip()
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
+9 -3
View File
@@ -40,7 +40,7 @@ class G:
events = {}
start = None
markers = ["o", "s", "t", "d"]
curveno = 0
curveno = {}
def find_marker():
if len(G.markers) == 0:
@@ -66,6 +66,10 @@ def get_event(event, evtype):
G.events[event] = e
return G.events[event]
colors = [(0.0, 0.5, 0.0), (0.0, 0.0, 1.0), (0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.75, 0.75, 0), (0.0, 0.75, 0.75), (0.75, 0, 0.75)]
def mkColor(t):
return pg.mkColor(int(t[0] * 255), int(t[1] * 255), int(t[2] * 255))
SCALE = 1e6 # microseconds to seconds
for line in [line.split("#")[0].strip() for line in open(filename, "r")]:
@@ -152,8 +156,10 @@ for e in G.sevents:
args['symbol'] = e.marker
args['pen'] = None
else:
args['pen'] = pg.mkPen(pg.intColor(G.curveno), width=0)
G.curveno += 1
if not cur in G.curveno:
G.curveno[cur] = 0
args['pen'] = pg.mkPen(mkColor(colors[G.curveno[cur] % len(colors)]), width=0)
G.curveno[cur] += 1
n = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], **args)
QtGui.QApplication.instance().exec_()
+1 -1
View File
@@ -120,7 +120,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|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
"*.(#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)(-.)" && rc=0
if _requested urls; then
while _next_label urls expl URL; do
_urls "\$expl[@]" && rc=0
+1 -1
View File
@@ -1 +1 @@
0.14.0
0.15.0
+1 -1
View File
@@ -24,7 +24,7 @@
#include <libavutil/frame.h>
#include <libavutil/version.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/common.h"
#include "fmt-conversion.h"
#include "audio.h"
+15 -9
View File
@@ -274,19 +274,25 @@ static bool mp_chmap_is_better(struct mp_chmap *req, struct mp_chmap *old,
if (new_lost_r != old_lost_r)
return new_lost_r < old_lost_r;
int old_lost = mp_chmap_diffn(req, old);
int new_lost = mp_chmap_diffn(req, new);
// If the situation is equal with replaced speakers, but one of them loses
// less if no replacements are performed, pick the better one, even if it
// means an upmix. This prefers exact supersets over inexact equivalents.
if (new_lost != old_lost)
return new_lost < old_lost;
struct mp_chmap old_p = *old, new_p = *new;
mp_chmap_remove_na(&old_p);
mp_chmap_remove_na(&new_p);
// If the situation is equal with replaced speakers, but the replacement is
// perfect for only one of them, let the better one win. This prefers
// inexact equivalents over exact supersets.
bool perfect_r_new = !new_lost_r && new_p.num <= old_p.num;
bool perfect_r_old = !old_lost_r && old_p.num <= new_p.num;
if (perfect_r_new != perfect_r_old)
return perfect_r_new;
int old_lost = mp_chmap_diffn(req, old);
int new_lost = mp_chmap_diffn(req, new);
// If the situation is equal with replaced speakers, pick the better one,
// even if it means an upmix.
if (new_lost != old_lost)
return new_lost < old_lost;
// Some kind of upmix. If it's perfect, prefer the smaller one. Even if not,
// both have equal loss, so also prefer the smaller one.
// Drop padding channels (NA) for the sake of this check, as the number of
+16 -17
View File
@@ -26,7 +26,7 @@
#include <libavutil/common.h>
#include <libavutil/intreadwrite.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "config.h"
#include "common/av_common.h"
@@ -79,12 +79,12 @@ static int init(struct dec_audio *da, const char *decoder)
AVCodecContext *lavc_context;
AVCodec *lavc_codec;
struct sh_stream *sh = da->header;
struct sh_audio *sh_audio = sh->audio;
struct mp_codec_params *c = sh->codec;
struct priv *ctx = talloc_zero(NULL, struct priv);
da->priv = ctx;
ctx->force_channel_map = sh_audio->force_channels;
ctx->force_channel_map = c->force_channels;
lavc_codec = avcodec_find_decoder_by_name(decoder);
if (!lavc_codec) {
@@ -116,20 +116,20 @@ static int init(struct dec_audio *da, const char *decoder)
mp_set_avopts(da->log, lavc_context, opts->avopts);
lavc_context->codec_tag = sh->codec_tag;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->bitrate;
lavc_context->block_align = sh_audio->block_align;
lavc_context->bits_per_coded_sample = sh_audio->bits_per_coded_sample;
lavc_context->channels = sh_audio->channels.num;
if (!mp_chmap_is_unknown(&sh_audio->channels))
lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels);
lavc_context->codec_tag = c->codec_tag;
lavc_context->sample_rate = c->samplerate;
lavc_context->bit_rate = c->bitrate;
lavc_context->block_align = c->block_align;
lavc_context->bits_per_coded_sample = c->bits_per_coded_sample;
lavc_context->channels = c->channels.num;
if (!mp_chmap_is_unknown(&c->channels))
lavc_context->channel_layout = mp_chmap_to_lavc(&c->channels);
// demux_mkv
mp_lavc_set_extradata(lavc_context, sh->extradata, sh->extradata_size);
mp_lavc_set_extradata(lavc_context, c->extradata, c->extradata_size);
if (sh->lav_headers)
mp_copy_lav_codec_headers(lavc_context, sh->lav_headers);
if (c->lav_headers)
mp_copy_lav_codec_headers(lavc_context, c->lav_headers);
mp_set_avcodec_threads(da->log, lavc_context, opts->threads);
@@ -228,9 +228,8 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
if (lavc_chmap.num != avctx->channels)
mp_chmap_from_channels(&lavc_chmap, avctx->channels);
if (priv->force_channel_map) {
struct sh_audio *sh_audio = da->header->audio;
if (lavc_chmap.num == sh_audio->channels.num)
lavc_chmap = sh_audio->channels;
if (lavc_chmap.num == da->header->codec->channels.num)
lavc_chmap = da->header->codec->channels;
}
mp_audio_set_channels(mpframe, &lavc_chmap);
+14 -3
View File
@@ -88,7 +88,7 @@ struct mp_decoder_list *audio_decoder_list(void)
static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
{
struct MPOpts *opts = d_audio->opts;
const char *codec = d_audio->header->codec;
const char *codec = d_audio->header->codec->codec;
struct mp_decoder_list *list = audio_decoder_list();
struct mp_decoder_list *new =
@@ -146,7 +146,7 @@ int audio_init_best_codec(struct dec_audio *d_audio)
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
} else {
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
d_audio->header->codec ? d_audio->header->codec : "<unknown>");
d_audio->header->codec->codec);
}
talloc_free(list);
@@ -177,11 +177,21 @@ static int decode_new_frame(struct dec_audio *da)
da->pts += da->pts_offset / (double)da->waiting->rate;
da->pts_offset = 0;
}
double newpts = da->waiting->pts;
// Keep the interpolated timestamp if it doesn't deviate more
// than 1 ms from the real one. (MKV rounded timestamps.)
if (da->pts == MP_NOPTS_VALUE || da->pts_offset != 0 ||
fabs(da->pts - da->waiting->pts) > 0.001)
fabs(da->pts - newpts) > 0.001)
{
// Attempt to detect jumps in PTS. Even for the lowest
// sample rates and with worst container rounded timestamp,
// this should be a margin more than enough.
if (da->pts != MP_NOPTS_VALUE && fabs(newpts - da->pts) > 0.1)
{
MP_WARN(da, "Invalid audio PTS: %f -> %f\n",
da->pts, newpts);
da->pts_reset = true;
}
da->pts = da->waiting->pts;
da->pts_offset = 0;
}
@@ -274,6 +284,7 @@ void audio_reset_decoding(struct dec_audio *d_audio)
af_seek_reset(d_audio->afilter);
d_audio->pts = MP_NOPTS_VALUE;
d_audio->pts_offset = 0;
d_audio->pts_reset = false;
if (d_audio->waiting) {
talloc_free(d_audio->waiting);
d_audio->waiting = NULL;
+2
View File
@@ -45,6 +45,8 @@ struct dec_audio {
double pts;
// number of samples output by decoder after last known pts
int pts_offset;
// set every time a jump in timestamps is encountered
bool pts_reset;
// For free use by the ad_driver
void *priv;
};
+10 -5
View File
@@ -27,7 +27,7 @@
#include "audio/filter/af.h"
#include "common/global.h"
#include "common/msg.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "mixer.h"
struct mixer {
@@ -120,8 +120,11 @@ void mixer_getvolume(struct mixer *mixer, float *l, float *r)
*r = mixer->vol_r;
}
static void setvolume_internal(struct mixer *mixer, float l, float 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};
@@ -147,8 +150,8 @@ void mixer_setvolume(struct mixer *mixer, float l, float r)
float max = mixer_getmaxvolume(mixer);
mixer->vol_l = MPCLAMP(l, 0, max);
mixer->vol_r = MPCLAMP(r, 0, max);
if (mixer->ao && !(mixer->emulate_mute && mixer->muted))
setvolume_internal(mixer, mixer->vol_l, mixer->vol_r);
if (mixer->ao)
setvolume_internal(mixer);
}
void mixer_getbothvolume(struct mixer *mixer, float *b)
@@ -167,7 +170,7 @@ void mixer_setmute(struct mixer *mixer, bool mute)
mixer->muted = mute;
mixer->muted_by_us = mute;
if (mixer->emulate_mute) {
setvolume_internal(mixer, mixer->vol_l*!mute, mixer->vol_r*!mute);
setvolume_internal(mixer);
} else {
ao_control(mixer->ao, AOCONTROL_SET_MUTE, &mute);
}
@@ -293,6 +296,8 @@ static void restore_volume(struct mixer *mixer)
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.
+1 -5
View File
@@ -20,7 +20,7 @@
#include <string.h>
#include <assert.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "config.h"
#include "ao.h"
@@ -45,7 +45,6 @@ extern const struct ao_driver audio_out_jack;
extern const struct ao_driver audio_out_openal;
extern const struct ao_driver audio_out_null;
extern const struct ao_driver audio_out_alsa;
extern const struct ao_driver audio_out_dsound;
extern const struct ao_driver audio_out_wasapi;
extern const struct ao_driver audio_out_pcm;
extern const struct ao_driver audio_out_lavc;
@@ -65,9 +64,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
#if HAVE_WASAPI
&audio_out_wasapi,
#endif
#if HAVE_DSOUND
&audio_out_dsound,
#endif
#if HAVE_OSS_AUDIO
&audio_out_oss,
#endif
+4 -4
View File
@@ -384,8 +384,8 @@ static int hotplug_init(struct ao *ao)
err = AudioObjectAddPropertyListener(
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
if (err != noErr) {
char *c1 = fourcc_repr(hotplug_properties[i]);
char *c2 = fourcc_repr(err);
char *c1 = mp_tag_str(hotplug_properties[i]);
char *c2 = mp_tag_str(err);
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
goto coreaudio_error;
}
@@ -409,8 +409,8 @@ static void hotplug_uninit(struct ao *ao)
err = AudioObjectRemovePropertyListener(
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
if (err != noErr) {
char *c1 = fourcc_repr(hotplug_properties[i]);
char *c2 = fourcc_repr(err);
char *c1 = mp_tag_str(hotplug_properties[i]);
char *c2 = mp_tag_str(err);
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
}
}
+1 -1
View File
@@ -21,7 +21,7 @@
#include "audio/out/ao_coreaudio_properties.h"
#include "audio/out/ao_coreaudio_utils.h"
#include "talloc.h"
#include "mpv_talloc.h"
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
uint32_t size, void *data)
+3 -28
View File
@@ -136,36 +136,11 @@ coreaudio_error:
return err;
}
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code)
{
// Extract FourCC letters from the uint32_t and finde out if it's a valid
// code that is made of letters.
unsigned char fcc[4] = {
(code >> 24) & 0xFF,
(code >> 16) & 0xFF,
(code >> 8) & 0xFF,
code & 0xFF,
};
bool valid_fourcc = true;
for (int i = 0; i < 4; i++) {
if (fcc[i] < 32 || fcc[i] >= 128)
valid_fourcc = false;
}
if (valid_fourcc)
snprintf(buf, buf_size, "'%c%c%c%c'", fcc[0], fcc[1], fcc[2], fcc[3]);
else
snprintf(buf, buf_size, "%u", (unsigned int)code);
return buf;
}
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message)
{
if (code == noErr) return true;
mp_msg(ao->log, level, "%s (%s)\n", message, fourcc_repr(code));
mp_msg(ao->log, level, "%s (%s)\n", message, mp_tag_str(code));
return false;
}
@@ -258,7 +233,7 @@ void ca_print_asbd(struct ao *ao, const char *description,
const AudioStreamBasicDescription *asbd)
{
uint32_t flags = asbd->mFormatFlags;
char *format = fourcc_repr(asbd->mFormatID);
char *format = mp_tag_str(asbd->mFormatID);
int mpfmt = ca_asbd_to_mp_format(asbd);
MP_VERBOSE(ao,
@@ -470,7 +445,7 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device)
if (err == noErr) {
latency_frames += temp;
MP_VERBOSE(ao, "Latency property %s: %d frames\n",
fourcc_repr(latency_properties[n]), (int)temp);
mp_tag_str(latency_properties[n]), (int)temp);
}
}
-3
View File
@@ -31,9 +31,6 @@
CFStringRef cfstr_from_cstr(char *str);
char *cfstr_get_cstr(CFStringRef cfstr);
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code);
#define fourcc_repr(code) fourcc_repr_buf((char[40]){0}, 40, code)
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
#define CHECK_CA_ERROR_L(label, message) \
-707
View File
@@ -1,707 +0,0 @@
/*
* Windows DirectSound interface
*
* Copyright (c) 2004 Gabor Szecsi <deje@miki.hu>
*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
/**
\todo verify/extend multichannel support
*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#define DIRECTSOUND_VERSION 0x0600
#include <dsound.h>
#include <math.h>
#include <libavutil/avutil.h>
#include <libavutil/common.h>
#include "config.h"
#include "audio/format.h"
#include "ao.h"
#include "internal.h"
#include "common/msg.h"
#include "osdep/timer.h"
#include "osdep/io.h"
#include "options/m_option.h"
/**
\todo use the definitions from the win32 api headers when they define these
*/
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE
static const GUID KSDATAFORMAT_SUBTYPE_PCM = {
0x1, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
};
#if 0
#define DSSPEAKER_HEADPHONE 0x00000001
#define DSSPEAKER_MONO 0x00000002
#define DSSPEAKER_QUAD 0x00000003
#define DSSPEAKER_STEREO 0x00000004
#define DSSPEAKER_SURROUND 0x00000005
#define DSSPEAKER_5POINT1 0x00000006
#endif
#ifndef _WAVEFORMATEXTENSIBLE_
typedef struct {
WAVEFORMATEX Format;
union {
WORD wValidBitsPerSample; /* bits of precision */
WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */
WORD wReserved; /* If neither applies, set to zero. */
} Samples;
DWORD dwChannelMask; /* which channels are */
/* present in stream */
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
#endif
struct priv {
HINSTANCE hdsound_dll; ///handle to the dll
LPDIRECTSOUND hds; ///direct sound object
LPDIRECTSOUNDBUFFER hdspribuf; ///primary direct sound buffer
LPDIRECTSOUNDBUFFER hdsbuf; ///secondary direct sound buffer (stream buffer)
int buffer_size; ///size in bytes of the direct sound buffer
int write_offset; ///offset of the write cursor in the direct sound buffer
int min_free_space; ///if the free space is below this value get_space() will return 0
///there will always be at least this amout of free space to prevent
///get_space() from returning wrong values when buffer is 100% full.
///will be replaced with nBlockAlign in init()
int underrun_check; ///0 or last reported free space (underrun detection)
int device_num; ///wanted device number
GUID device; ///guid of the device
int audio_volume;
int device_index;
int outburst; ///play in multiple of chunks of this size
int cfg_device;
int cfg_buffersize;
struct ao_device_list *listing; ///temporary during list_devs()
};
/***************************************************************************************/
/**
\brief output error message
\param err error code
\return string with the error message
*/
static char * dserr2str(int err)
{
switch (err) {
case DS_OK: return "DS_OK";
case DS_NO_VIRTUALIZATION: return "DS_NO_VIRTUALIZATION";
case DSERR_ALLOCATED: return "DS_NO_VIRTUALIZATION";
case DSERR_CONTROLUNAVAIL: return "DSERR_CONTROLUNAVAIL";
case DSERR_INVALIDPARAM: return "DSERR_INVALIDPARAM";
case DSERR_INVALIDCALL: return "DSERR_INVALIDCALL";
case DSERR_GENERIC: return "DSERR_GENERIC";
case DSERR_PRIOLEVELNEEDED: return "DSERR_PRIOLEVELNEEDED";
case DSERR_OUTOFMEMORY: return "DSERR_OUTOFMEMORY";
case DSERR_BADFORMAT: return "DSERR_BADFORMAT";
case DSERR_UNSUPPORTED: return "DSERR_UNSUPPORTED";
case DSERR_NODRIVER: return "DSERR_NODRIVER";
case DSERR_ALREADYINITIALIZED: return "DSERR_ALREADYINITIALIZED";
case DSERR_NOAGGREGATION: return "DSERR_NOAGGREGATION";
case DSERR_BUFFERLOST: return "DSERR_BUFFERLOST";
case DSERR_OTHERAPPHASPRIO: return "DSERR_OTHERAPPHASPRIO";
case DSERR_UNINITIALIZED: return "DSERR_UNINITIALIZED";
case DSERR_NOINTERFACE: return "DSERR_NOINTERFACE";
case DSERR_ACCESSDENIED: return "DSERR_ACCESSDENIED";
}
return "unknown";
}
/**
\brief uninitialize direct sound
*/
static void UninitDirectSound(struct ao *ao)
{
struct priv *p = ao->priv;
// finally release the DirectSound object
if (p->hds) {
IDirectSound_Release(p->hds);
p->hds = NULL;
}
// free DSOUND.DLL
if (p->hdsound_dll) {
FreeLibrary(p->hdsound_dll);
p->hdsound_dll = NULL;
}
MP_VERBOSE(ao, "DirectSound uninitialized\n");
}
/**
\brief enumerate direct sound devices
\return TRUE to continue with the enumeration
*/
static BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCSTR desc, LPCSTR module,
LPVOID context)
{
struct ao *ao = context;
struct priv *p = ao->priv;
MP_VERBOSE(ao, "%i %s ", p->device_index, desc);
if (p->device_num == p->device_index) {
MP_VERBOSE(ao, "<--");
if (guid)
memcpy(&p->device, guid, sizeof(GUID));
}
char *guidstr = talloc_strdup(NULL, "");
if (guid) {
wchar_t guidwstr[80] = {0};
StringFromGUID2(guid, guidwstr, MP_ARRAY_SIZE(guidwstr));
char *nstr = mp_to_utf8(NULL, guidwstr);
if (nstr) {
talloc_free(guidstr);
guidstr = nstr;
}
}
if (p->device_num < 0 && ao->device) {
if (strcmp(ao->device, guidstr) == 0) {
MP_VERBOSE(ao, "<--");
p->device_num = p->device_index;
if (guid)
memcpy(&p->device, guid, sizeof(GUID));
}
}
if (p->listing) {
struct ao_device_desc e = {guidstr, desc};
ao_device_list_add(p->listing, ao, &e);
}
talloc_free(guidstr);
MP_VERBOSE(ao, "\n");
p->device_index++;
return TRUE;
}
static void EnumDevs(struct ao *ao)
{
struct priv *p = ao->priv;
p->device_index = 0;
p->device_num = p->cfg_device;
HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID);
OurDirectSoundEnumerate = (void *)GetProcAddress(p->hdsound_dll,
"DirectSoundEnumerateA");
if (OurDirectSoundEnumerate == NULL) {
MP_ERR(ao, "GetProcAddress FAILED\n");
return;
}
// Enumerate all directsound p->devices
MP_VERBOSE(ao, "Output Devices:\n");
OurDirectSoundEnumerate(DirectSoundEnum, ao);
}
static int LoadDirectSound(struct ao *ao)
{
struct priv *p = ao->priv;
// initialize directsound
p->hdsound_dll = LoadLibrary(L"DSOUND.DLL");
if (p->hdsound_dll == NULL) {
MP_ERR(ao, "cannot load DSOUND.DLL\n");
return 0;
}
return 1;
}
static void list_devs(struct ao *ao, struct ao_device_list *list)
{
struct priv *p = ao->priv;
bool need_init = !p->hdsound_dll;
if (need_init && !LoadDirectSound(ao))
return;
p->listing = list;
EnumDevs(ao);
p->listing = NULL;
if (need_init)
UninitDirectSound(ao);
}
/**
\brief initilize direct sound
\return 0 if error, 1 if ok
*/
static int InitDirectSound(struct ao *ao)
{
struct priv *p = ao->priv;
DSCAPS dscaps;
if (!LoadDirectSound(ao))
return 0;
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
OurDirectSoundCreate =
(void *)GetProcAddress(p->hdsound_dll, "DirectSoundCreate");
if (OurDirectSoundCreate == NULL) {
MP_ERR(ao, "GetProcAddress FAILED\n");
FreeLibrary(p->hdsound_dll);
return 0;
}
EnumDevs(ao);
// Create the direct sound object
if (FAILED(OurDirectSoundCreate((p->device_num > 0) ? &p->device : NULL,
&p->hds, NULL)))
{
MP_ERR(ao, "cannot create a DirectSound device\n");
FreeLibrary(p->hdsound_dll);
return 0;
}
/* Set DirectSound Cooperative level, ie what control we want over Windows
* sound device. In our case, DSSCL_EXCLUSIVE means that we can modify the
* settings of the primary buffer, but also that only the sound of our
* application will be audible when it will have the focus.
* !!! (this is not really working as intended yet because to set the
* cooperative level you need the window handle of your application, and
* I don't know of any easy way to get it. Especially since we might play
* sound without any video, and so what window handle should we use ???
* The hack for now is to use the Desktop window handle - it seems to be
* working */
if (IDirectSound_SetCooperativeLevel(p->hds, GetDesktopWindow(),
DSSCL_EXCLUSIVE))
{
MP_ERR(ao, "cannot set direct sound cooperative level\n");
IDirectSound_Release(p->hds);
FreeLibrary(p->hdsound_dll);
return 0;
}
MP_VERBOSE(ao, "DirectSound initialized\n");
memset(&dscaps, 0, sizeof(DSCAPS));
dscaps.dwSize = sizeof(DSCAPS);
if (DS_OK == IDirectSound_GetCaps(p->hds, &dscaps)) {
if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
MP_VERBOSE(ao, "DirectSound is emulated\n");
} else {
MP_VERBOSE(ao, "cannot get device capabilities\n");
}
return 1;
}
/**
\brief destroy the direct sound buffer
*/
static void DestroyBuffer(struct ao *ao)
{
struct priv *p = ao->priv;
if (p->hdsbuf) {
IDirectSoundBuffer_Release(p->hdsbuf);
p->hdsbuf = NULL;
}
if (p->hdspribuf) {
IDirectSoundBuffer_Release(p->hdspribuf);
p->hdspribuf = NULL;
}
}
/**
\brief fill sound buffer
\param data pointer to the sound data to copy
\param len length of the data to copy in bytes
\return number of copyed bytes
*/
static int write_buffer(struct ao *ao, unsigned char *data, int len)
{
struct priv *p = ao->priv;
HRESULT res;
LPVOID lpvPtr1;
DWORD dwBytes1;
LPVOID lpvPtr2;
DWORD dwBytes2;
p->underrun_check = 0;
// Lock the buffer
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
// If the buffer was lost, restore and retry lock.
if (DSERR_BUFFERLOST == res) {
IDirectSoundBuffer_Restore(p->hdsbuf);
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
}
if (SUCCEEDED(res)) {
memcpy(lpvPtr1, data, dwBytes1);
if (NULL != lpvPtr2)
memcpy(lpvPtr2, data + dwBytes1, dwBytes2);
p->write_offset += dwBytes1 + dwBytes2;
if (p->write_offset >= p->buffer_size)
p->write_offset = dwBytes2;
// Release the data back to DirectSound.
res = IDirectSoundBuffer_Unlock(p->hdsbuf, lpvPtr1, dwBytes1, lpvPtr2,
dwBytes2);
if (SUCCEEDED(res)) {
// Success.
DWORD status;
IDirectSoundBuffer_GetStatus(p->hdsbuf, &status);
if (!(status & DSBSTATUS_PLAYING))
res = IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
return dwBytes1 + dwBytes2;
}
}
// Lock, Unlock, or Restore failed.
return 0;
}
/***************************************************************************************/
/**
\brief handle control commands
\param cmd command
\param arg argument
\return CONTROL_OK or CONTROL_UNKNOWN in case the command is not supported
*/
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct priv *p = ao->priv;
DWORD volume;
switch (cmd) {
case AOCONTROL_GET_VOLUME: {
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
vol->left = vol->right = p->audio_volume;
return CONTROL_OK;
}
case AOCONTROL_SET_VOLUME: {
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
volume = p->audio_volume = vol->right;
if (volume < 1)
volume = 1;
volume = (DWORD)(log10(volume) * 5000.0) - 10000;
IDirectSoundBuffer_SetVolume(p->hdsbuf, volume);
return CONTROL_OK;
}
case AOCONTROL_HAS_SOFT_VOLUME:
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}
/**
\brief setup sound device
\param rate samplerate
\param channels number of channels
\param format format
\param flags unused
\return 0=success -1=fail
*/
static int init(struct ao *ao)
{
struct priv *p = ao->priv;
int res;
if (!InitDirectSound(ao))
return -1;
p->audio_volume = 100;
// ok, now create the buffers
WAVEFORMATEXTENSIBLE wformat;
DSBUFFERDESC dsbpridesc;
DSBUFFERDESC dsbdesc;
int format = af_fmt_from_planar(ao->format);
int rate = ao->samplerate;
if (!af_fmt_is_spdif(format)) {
struct mp_chmap_sel sel = {0};
mp_chmap_sel_add_waveext(&sel);
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
return -1;
}
switch (format) {
case AF_FORMAT_S24:
case AF_FORMAT_S16:
case AF_FORMAT_U8:
break;
default:
if (af_fmt_is_spdif(format))
break;
MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n",
af_fmt_to_str(format));
format = AF_FORMAT_S16;
}
//set our audio parameters
ao->samplerate = rate;
ao->format = format;
ao->bps = ao->channels.num * rate * af_fmt_to_bytes(format);
int buffersize = ao->bps * p->cfg_buffersize / 1000;
MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate,
ao->channels.num, af_fmt_to_str(format));
MP_VERBOSE(ao, "Buffersize:%d bytes (%f msec)\n",
buffersize, buffersize * 1000.0 / ao->bps);
//fill waveformatex
ZeroMemory(&wformat, sizeof(WAVEFORMATEXTENSIBLE));
wformat.Format.cbSize = (ao->channels.num > 2)
? sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) : 0;
wformat.Format.nChannels = ao->channels.num;
wformat.Format.nSamplesPerSec = rate;
if (af_fmt_is_spdif(format)) {
// Whether it also works with e.g. DTS is unknown, but probably does.
wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
wformat.Format.wBitsPerSample = 16;
wformat.Format.nBlockAlign = 4;
} else {
wformat.Format.wFormatTag = (ao->channels.num > 2)
? WAVE_FORMAT_EXTENSIBLE : WAVE_FORMAT_PCM;
int bps = af_fmt_to_bytes(format);
wformat.Format.wBitsPerSample = bps * 8;
wformat.Format.nBlockAlign = wformat.Format.nChannels * bps;
}
// fill in primary sound buffer descriptor
memset(&dsbpridesc, 0, sizeof(DSBUFFERDESC));
dsbpridesc.dwSize = sizeof(DSBUFFERDESC);
dsbpridesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbpridesc.dwBufferBytes = 0;
dsbpridesc.lpwfxFormat = NULL;
// fill in the secondary sound buffer (=stream buffer) descriptor
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 /** Better position accuracy */
| DSBCAPS_GLOBALFOCUS /** Allows background playing */
| DSBCAPS_CTRLVOLUME; /** volume control enabled */
if (ao->channels.num > 2) {
wformat.dwChannelMask = mp_chmap_to_waveext(&ao->channels);
wformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
wformat.Samples.wValidBitsPerSample = wformat.Format.wBitsPerSample;
// Needed for 5.1 on emu101k - shit soundblaster
dsbdesc.dwFlags |= DSBCAPS_LOCHARDWARE;
}
wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec *
wformat.Format.nBlockAlign;
dsbdesc.dwBufferBytes = buffersize;
dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat;
p->buffer_size = dsbdesc.dwBufferBytes;
p->write_offset = 0;
p->min_free_space = wformat.Format.nBlockAlign;
p->outburst = wformat.Format.nBlockAlign * 512;
// create primary buffer and set its format
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbpridesc, &p->hdspribuf, NULL);
if (res != DS_OK) {
UninitDirectSound(ao);
MP_ERR(ao, "cannot create primary buffer (%s)\n", dserr2str(res));
return -1;
}
res = IDirectSoundBuffer_SetFormat(p->hdspribuf, (WAVEFORMATEX *)&wformat);
if (res != DS_OK) {
MP_WARN(ao, "cannot set primary buffer format (%s), using "
"standard setting (bad quality)", dserr2str(res));
}
MP_VERBOSE(ao, "primary buffer created\n");
// now create the stream buffer
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
if (res != DS_OK) {
if (dsbdesc.dwFlags & DSBCAPS_LOCHARDWARE) {
// Try without DSBCAPS_LOCHARDWARE
dsbdesc.dwFlags &= ~DSBCAPS_LOCHARDWARE;
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
}
if (res != DS_OK) {
UninitDirectSound(ao);
MP_ERR(ao, "cannot create secondary (stream)buffer (%s)\n",
dserr2str(res));
return -1;
}
}
MP_VERBOSE(ao, "secondary (stream)buffer created\n");
return 0;
}
/**
\brief stop playing and empty buffers (for seeking/pause)
*/
static void reset(struct ao *ao)
{
struct priv *p = ao->priv;
IDirectSoundBuffer_Stop(p->hdsbuf);
// reset directsound buffer
IDirectSoundBuffer_SetCurrentPosition(p->hdsbuf, 0);
p->write_offset = 0;
p->underrun_check = 0;
}
/**
\brief stop playing, keep buffers (for pause)
*/
static void audio_pause(struct ao *ao)
{
struct priv *p = ao->priv;
IDirectSoundBuffer_Stop(p->hdsbuf);
}
/**
\brief resume playing, after audio_pause()
*/
static void audio_resume(struct ao *ao)
{
struct priv *p = ao->priv;
IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
}
/**
\brief close audio device
\param immed stop playback immediately
*/
static void uninit(struct ao *ao)
{
reset(ao);
DestroyBuffer(ao);
UninitDirectSound(ao);
}
// return exact number of free (safe to write) bytes
static int check_free_buffer_size(struct ao *ao)
{
struct priv *p = ao->priv;
int space;
DWORD play_offset;
IDirectSoundBuffer_GetCurrentPosition(p->hdsbuf, &play_offset, NULL);
space = p->buffer_size - (p->write_offset - play_offset);
// | | <-- const --> | | |
// buffer start play_cursor write_cursor p->write_offset buffer end
// play_cursor is the actual position of the play cursor
// write_cursor is the position after which it is assumed to be save to write data
// p->write_offset is the position where we actually write the data to
if (space > p->buffer_size)
space -= p->buffer_size; // p->write_offset < play_offset
// Check for buffer underruns. An underrun happens if DirectSound
// started to play old data beyond the current p->write_offset. Detect this
// by checking whether the free space shrinks, even though no data was
// written (i.e. no write_buffer). Doesn't always work, but the only
// reason we need this is to deal with the situation when playback ends,
// and the buffer is only half-filled.
if (space < p->underrun_check) {
// there's no useful data in the buffers
space = p->buffer_size;
reset(ao);
}
p->underrun_check = space;
return space;
}
/**
\brief find out how many bytes can be written into the audio buffer without
\return free space in bytes, has to return 0 if the buffer is almost full
*/
static int get_space(struct ao *ao)
{
struct priv *p = ao->priv;
int space = check_free_buffer_size(ao);
if (space < p->min_free_space)
return 0;
return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
}
/**
\brief play 'len' bytes of 'data'
\param data pointer to the data to play
\param len size in bytes of the data buffer, gets rounded down to outburst*n
\param flags currently unused
\return number of played bytes
*/
static int play(struct ao *ao, void **data, int samples, int flags)
{
struct priv *p = ao->priv;
int len = samples * ao->sstride;
int space = check_free_buffer_size(ao);
if (space < len)
len = space;
if (!(flags & AOPLAY_FINAL_CHUNK))
len = (len / p->outburst) * p->outburst;
return write_buffer(ao, data[0], len) / ao->sstride;
}
/**
\brief get the delay between the first and last sample in the buffer
\return delay in seconds
*/
static double get_delay(struct ao *ao)
{
struct priv *p = ao->priv;
int space = check_free_buffer_size(ao);
return (p->buffer_size - space) / (double)ao->bps;
}
#define OPT_BASE_STRUCT struct priv
const struct ao_driver audio_out_dsound = {
.description = "Windows DirectSound audio output",
.name = "dsound",
.init = init,
.uninit = uninit,
.control = control,
.get_space = get_space,
.play = play,
.get_delay = get_delay,
.pause = audio_pause,
.resume = audio_resume,
.reset = reset,
.list_devs = list_devs,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
OPT_INT("device", cfg_device, 0, OPTDEF_INT(-1)),
OPT_INTRANGE("buffersize", cfg_buffersize, 0, 1, 10000, OPTDEF_INT(200)),
{0}
},
};
+1 -1
View File
@@ -31,7 +31,7 @@
#include "common/common.h"
#include "audio/format.h"
#include "audio/fmt-conversion.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "ao.h"
#include "internal.h"
#include "common/msg.h"
+1 -1
View File
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <math.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "config.h"
#include "osdep/timer.h"
+1 -1
View File
@@ -27,7 +27,7 @@
#include <libavutil/common.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "options/m_option.h"
#include "audio/format.h"
+33 -22
View File
@@ -376,22 +376,8 @@ fail:
return -1;
}
static int init(struct ao *ao)
static bool set_format(struct ao *ao, pa_format_info *format)
{
struct pa_channel_map map;
pa_proplist *proplist = NULL;
pa_format_info *format = NULL;
struct priv *priv = ao->priv;
char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
if (pa_init_boilerplate(ao) < 0)
return -1;
pa_threaded_mainloop_lock(priv->mainloop);
if (!(format = pa_format_info_new()))
goto unlock_and_fail;
ao->format = af_fmt_from_planar(ao->format);
format->encoding = map_digital_format(ao->format);
@@ -411,8 +397,29 @@ static int init(struct ao *ao)
pa_format_info_set_sample_format(format, fmt_map->pa_format);
}
struct pa_channel_map map;
if (!select_chmap(ao, &map))
goto unlock_and_fail;
return false;
pa_format_info_set_rate(format, ao->samplerate);
pa_format_info_set_channels(format, ao->channels.num);
pa_format_info_set_channel_map(format, &map);
return ao->samplerate < PA_RATE_MAX && pa_format_info_valid(format);
}
static int init(struct ao *ao)
{
pa_proplist *proplist = NULL;
pa_format_info *format = NULL;
struct priv *priv = ao->priv;
char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
if (pa_init_boilerplate(ao) < 0)
return -1;
pa_threaded_mainloop_lock(priv->mainloop);
if (!(proplist = pa_proplist_new())) {
MP_ERR(ao, "Failed to allocate proplist\n");
@@ -420,13 +427,17 @@ static int init(struct ao *ao)
}
(void)pa_proplist_sets(proplist, PA_PROP_MEDIA_ICON_NAME, ao->client_name);
pa_format_info_set_rate(format, ao->samplerate);
pa_format_info_set_channels(format, ao->channels.num);
pa_format_info_set_channel_map(format, &map);
if (!pa_format_info_valid(format)) {
MP_ERR(ao, "Invalid audio format\n");
if (!(format = pa_format_info_new()))
goto unlock_and_fail;
if (!set_format(ao, format)) {
ao->channels = (struct mp_chmap) MP_CHMAP_INIT_STEREO;
ao->samplerate = 48000;
ao->format = AF_FORMAT_FLOAT;
if (!set_format(ao, format)) {
MP_ERR(ao, "Invalid audio format\n");
goto unlock_and_fail;
}
}
if (!(priv->stream = pa_stream_new_extended(priv->context, "audio stream",
+1 -1
View File
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <rsound.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "options/m_option.h"
#include "osdep/timer.h"
+1 -1
View File
@@ -20,7 +20,7 @@
#include "config.h"
#include "audio/format.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "ao.h"
#include "internal.h"
#include "common/common.h"
+192 -116
View File
@@ -17,49 +17,61 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <math.h>
#include <inttypes.h>
#include <process.h>
#include <initguid.h>
#include <audioclient.h>
#include <endpointvolume.h>
#include <mmdeviceapi.h>
#include <avrt.h>
#include <libavutil/mathematics.h>
#include "audio/out/ao_wasapi.h"
#include "audio/out/ao_wasapi_utils.h"
#include "audio/format.h"
#include "options/m_option.h"
#include "osdep/timer.h"
#include "osdep/io.h"
#include "ao_wasapi.h"
static HRESULT get_device_delay(struct wasapi_state *state, double *delay) {
// naive av_rescale for unsigned
static UINT64 uint64_scale(UINT64 x, UINT64 num, UINT64 den)
{
return (x / den) * num
+ ((x % den) * (num / den))
+ ((x % den) * (num % den)) / den;
}
static HRESULT get_device_delay(struct wasapi_state *state, double *delay_us) {
UINT64 sample_count = atomic_load(&state->sample_count);
UINT64 position, qpc_position;
HRESULT hr;
hr = IAudioClock_GetPosition(state->pAudioClock, &position, &qpc_position);
/* GetPosition succeeded, but the result may be inaccurate due to the length of the call */
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx */
// GetPosition succeeded, but the result may be
// inaccurate due to the length of the call
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx
if (hr == S_FALSE) {
MP_DBG(state, "Possibly inaccurate device position.\n");
MP_VERBOSE(state, "Possibly inaccurate device position.\n");
hr = S_OK;
}
EXIT_ON_ERROR(hr);
LARGE_INTEGER qpc_count;
QueryPerformanceCounter(&qpc_count);
double qpc_diff = (qpc_count.QuadPart * 1e7 / state->qpc_frequency.QuadPart) - qpc_position;
// convert position to number of samples careful to avoid overflow
UINT64 sample_position = uint64_scale(position,
state->format.Format.nSamplesPerSec,
state->clock_frequency);
INT64 diff = sample_count - sample_position;
*delay_us = diff * 1e6 / state->format.Format.nSamplesPerSec;
position += state->clock_frequency * (uint64_t) (qpc_diff / 1e7);
// Correct for any delay in IAudioClock_GetPosition above.
// This should normally be very small (<1 us), but just in case. . .
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
INT64 qpc_diff = av_rescale(qpc.QuadPart, 10000000, state->qpc_frequency.QuadPart)
- qpc_position;
// ignore the above calculation if it yeilds more than 10 seconds (due to
// possible overflow inside IAudioClock_GetPosition)
if (qpc_diff < 10 * 10000000) {
*delay_us -= qpc_diff / 10.0; // convert to us
} else {
MP_VERBOSE(state, "Insane qpc delay correction of %g seconds. "
"Ignoring it.\n", qpc_diff / 10000000.0);
}
/* convert position to the same base as sample_count */
position = position * state->format.Format.nSamplesPerSec / state->clock_frequency;
double diff = sample_count - position;
*delay = diff / state->format.Format.nSamplesPerSec;
MP_TRACE(state, "Device delay: %g samples (%g ms)\n", diff, *delay * 1000);
MP_TRACE(state, "Device delay: %g us\n", *delay_us);
return S_OK;
exit_label:
@@ -80,11 +92,14 @@ static void thread_feed(struct ao *ao)
EXIT_ON_ERROR(hr);
frame_count -= padding;
MP_TRACE(ao, "Frame to fill: %"PRIu32". Padding: %"PRIu32"\n", frame_count, padding);
MP_TRACE(ao, "Frame to fill: %"PRIu32". Padding: %"PRIu32"\n",
frame_count, padding);
}
double delay;
hr = get_device_delay(state, &delay);
double delay_us;
hr = get_device_delay(state, &delay_us);
EXIT_ON_ERROR(hr);
// add the buffer delay
delay_us += frame_count * 1e6 / state->format.Format.nSamplesPerSec;
BYTE *pData;
hr = IAudioRenderClient_GetBuffer(state->pRenderClient,
@@ -93,10 +108,11 @@ static void thread_feed(struct ao *ao)
BYTE *data[1] = {pData};
ao_read_data(ao, (void**)data, frame_count, (int64_t) (
mp_time_us() + delay * 1e6 +
frame_count * 1e6 / state->format.Format.nSamplesPerSec));
ao_read_data(ao, (void **)data, frame_count,
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
hr = IAudioRenderClient_ReleaseBuffer(state->pRenderClient,
frame_count, 0);
EXIT_ON_ERROR(hr);
@@ -124,17 +140,21 @@ static void thread_resume(struct ao *ao)
mp_HRESULT_to_str(hr));
}
/* Fill the buffer before starting, but only if there is no audio queued to play. */
/* This prevents overfilling the buffer, which leads to problems in exclusive mode */
// Fill the buffer before starting, but only if there is no audio queued to
// play. This prevents overfilling the buffer, which leads to problems in
// exclusive mode
if (padding < (UINT32) state->bufferFrameCount)
thread_feed(ao);
// start feeding next wakeup if something else hasn't been requested
int expected = WASAPI_THREAD_RESUME;
atomic_compare_exchange_strong(&state->thread_state, &expected, WASAPI_THREAD_FEED);
atomic_compare_exchange_strong(&state->thread_state, &expected,
WASAPI_THREAD_FEED);
hr = IAudioClient_Start(state->pAudioClient);
if (hr != S_OK)
MP_ERR(state, "IAudioClient_Start returned %s\n", mp_HRESULT_to_str(hr));
if (hr != S_OK) {
MP_ERR(state, "IAudioClient_Start returned %s\n",
mp_HRESULT_to_str(hr));
}
return;
}
@@ -145,11 +165,11 @@ static void thread_reset(struct ao *ao)
HRESULT hr;
MP_DBG(state, "Thread Reset\n");
hr = IAudioClient_Stop(state->pAudioClient);
/* we may get S_FALSE if the stream is already stopped */
// we may get S_FALSE if the stream is already stopped
if (hr != S_OK && hr != S_FALSE)
MP_ERR(state, "IAudioClient_Stop returned: %s\n", mp_HRESULT_to_str(hr));
/* we may get S_FALSE if the stream is already reset */
// we may get S_FALSE if the stream is already reset
hr = IAudioClient_Reset(state->pAudioClient);
if (hr != S_OK && hr != S_FALSE)
MP_ERR(state, "IAudioClient_Reset returned: %s\n", mp_HRESULT_to_str(hr));
@@ -157,7 +177,8 @@ static void thread_reset(struct ao *ao)
atomic_store(&state->sample_count, 0);
// start feeding next wakeup if something else hasn't been requested
int expected = WASAPI_THREAD_RESET;
atomic_compare_exchange_strong(&state->thread_state, &expected, WASAPI_THREAD_FEED);
atomic_compare_exchange_strong(&state->thread_state, &expected,
WASAPI_THREAD_FEED);
return;
}
@@ -173,11 +194,12 @@ static DWORD __stdcall AudioThread(void *lpParameter)
goto exit_label;
MP_DBG(ao, "Entering dispatch loop\n");
while (true) { /* watch events */
while (true) { // watch events
HANDLE events[] = {state->hWake};
switch (MsgWaitForMultipleObjects(MP_ARRAY_SIZE(events), events, FALSE, INFINITE,
switch (MsgWaitForMultipleObjects(MP_ARRAY_SIZE(events), events,
FALSE, INFINITE,
QS_POSTMESSAGE | QS_SENDMESSAGE)) {
/* AudioThread wakeup */
// AudioThread wakeup
case WAIT_OBJECT_0:
switch (atomic_load(&state->thread_state)) {
case WASAPI_THREAD_FEED:
@@ -198,7 +220,7 @@ static DWORD __stdcall AudioThread(void *lpParameter)
goto exit_label;
}
break;
/* messages to dispatch (COM marshalling) */
// messages to dispatch (COM marshalling)
case (WAIT_OBJECT_0 + MP_ARRAY_SIZE(events)):
wasapi_dispatch(ao);
break;
@@ -215,7 +237,8 @@ exit_label:
return 0;
}
static void set_thread_state(struct ao *ao, enum wasapi_thread_state thread_state)
static void set_thread_state(struct ao *ao,
enum wasapi_thread_state thread_state)
{
struct wasapi_state *state = ao->priv;
atomic_store(&state->thread_state, thread_state);
@@ -230,7 +253,7 @@ static void uninit(struct ao *ao)
if (state->hWake)
set_thread_state(ao, WASAPI_THREAD_SHUTDOWN);
/* wait up to 10 seconds */
// wait up to 10 seconds
if (state->hAudioThread &&
WaitForSingleObject(state->hAudioThread, 10000) == WAIT_TIMEOUT)
{
@@ -242,6 +265,10 @@ static void uninit(struct ao *ao)
SAFE_RELEASE(state->hWake, CloseHandle(state->hWake));
SAFE_RELEASE(state->hAudioThread,CloseHandle(state->hAudioThread));
wasapi_change_uninit(ao);
talloc_free(state->deviceID);
CoUninitialize();
MP_DBG(ao, "Uninit wasapi done\n");
}
@@ -254,6 +281,14 @@ static int init(struct ao *ao)
struct wasapi_state *state = ao->priv;
state->log = ao->log;
state->deviceID = find_deviceID(ao);
if (!state->deviceID) {
uninit(ao);
return -1;
}
wasapi_change_init(ao, false);
state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL);
state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL);
if (!state->hInitDone || !state->hWake) {
@@ -270,7 +305,7 @@ static int init(struct ao *ao)
return -1;
}
WaitForSingleObject(state->hInitDone, INFINITE); /* wait on init complete */
WaitForSingleObject(state->hInitDone, INFINITE); // wait on init complete
SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone));
if (state->init_ret != S_OK) {
if (!ao->probing)
@@ -279,89 +314,135 @@ static int init(struct ao *ao)
return -1;
}
wasapi_setup_proxies(state);
wasapi_receive_proxies(state);
MP_DBG(ao, "Init wasapi done\n");
return 0;
}
static int control_exclusive(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct wasapi_state *state = ao->priv;
switch (cmd) {
case AOCONTROL_GET_VOLUME:
case AOCONTROL_SET_VOLUME:
if (!state->pEndpointVolumeProxy ||
!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_VOLUME)) {
return CONTROL_FALSE;
}
float volume;
switch (cmd) {
case AOCONTROL_GET_VOLUME:
IAudioEndpointVolume_GetMasterVolumeLevelScalar(
state->pEndpointVolumeProxy,
&volume);
*(ao_control_vol_t *)arg = (ao_control_vol_t){
.left = 100.0f * volume,
.right = 100.0f * volume,
};
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
volume = ((ao_control_vol_t *)arg)->left / 100.f;
IAudioEndpointVolume_SetMasterVolumeLevelScalar(
state->pEndpointVolumeProxy,
volume, NULL);
return CONTROL_OK;
}
case AOCONTROL_GET_MUTE:
case AOCONTROL_SET_MUTE:
if (!state->pEndpointVolumeProxy ||
!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_MUTE)) {
return CONTROL_FALSE;
}
BOOL mute;
switch (cmd) {
case AOCONTROL_GET_MUTE:
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy,
&mute);
*(bool *)arg = mute;
return CONTROL_OK;
case AOCONTROL_SET_MUTE:
mute = *(bool *)arg;
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy,
mute, NULL);
return CONTROL_OK;
}
case AOCONTROL_HAS_PER_APP_VOLUME:
return CONTROL_FALSE;
default:
return CONTROL_UNKNOWN;
}
}
static int control_shared(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct wasapi_state *state = ao->priv;
if (!state->pAudioVolumeProxy)
return CONTROL_UNKNOWN;
float volume;
BOOL mute;
switch(cmd) {
case AOCONTROL_GET_VOLUME:
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
&volume);
*(ao_control_vol_t *)arg = (ao_control_vol_t){
.left = 100.0f * volume,
.right = 100.0f * volume,
};
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
volume = ((ao_control_vol_t *)arg)->left / 100.f;
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
volume, NULL);
return CONTROL_OK;
case AOCONTROL_GET_MUTE:
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
*(bool *)arg = mute;
return CONTROL_OK;
case AOCONTROL_SET_MUTE:
mute = *(bool *)arg;
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
return CONTROL_OK;
case AOCONTROL_HAS_PER_APP_VOLUME:
return CONTROL_TRUE;
default:
return CONTROL_UNKNOWN;
}
}
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct wasapi_state *state = ao->priv;
ao_control_vol_t *vol = arg;
BOOL mute;
// common to exclusive and shared
switch (cmd) {
case AOCONTROL_GET_VOLUME:
if (state->opt_exclusive)
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
&state->audio_volume);
else
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
&state->audio_volume);
case AOCONTROL_UPDATE_STREAM_TITLE:
if (!state->pSessionControlProxy)
return CONTROL_FALSE;
/* check to see if user manually changed volume through mixer;
this information is used in exclusive mode for restoring the mixer volume on uninit */
if (state->audio_volume != state->previous_volume) {
MP_VERBOSE(state, "Mixer difference: %.2g now, expected %.2g\n",
state->audio_volume, state->previous_volume);
state->initial_volume = state->audio_volume;
}
vol->left = vol->right = 100.0f * state->audio_volume;
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
state->audio_volume = vol->left / 100.f;
if (state->opt_exclusive)
IAudioEndpointVolume_SetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
state->audio_volume, NULL);
else
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
state->audio_volume, NULL);
state->previous_volume = state->audio_volume;
return CONTROL_OK;
case AOCONTROL_GET_MUTE:
if (state->opt_exclusive)
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy, &mute);
else
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
*(bool*)arg = mute;
return CONTROL_OK;
case AOCONTROL_SET_MUTE:
mute = *(bool*)arg;
if (state->opt_exclusive)
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy, mute, NULL);
else
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
return CONTROL_OK;
case AOCONTROL_HAS_PER_APP_VOLUME:
return state->share_mode == AUDCLNT_SHAREMODE_SHARED ?
CONTROL_TRUE : CONTROL_FALSE;
case AOCONTROL_UPDATE_STREAM_TITLE: {
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
wchar_t *tmp = NULL;
/* There is a weird race condition in the IAudioSessionControl itself --
it seems that *sometimes* the SetDisplayName does not take effect and it still shows
the old title. Use this loop to insist until it works. */
// There is a weird race condition in the IAudioSessionControl itself --
// it seems that *sometimes* the SetDisplayName does not take effect and
// it still shows the old title. Use this loop to insist until it works.
do {
IAudioSessionControl_SetDisplayName(state->pSessionControlProxy, title, NULL);
IAudioSessionControl_SetDisplayName(state->pSessionControlProxy,
title, NULL);
SAFE_RELEASE(tmp, CoTaskMemFree(tmp));
IAudioSessionControl_GetDisplayName(state->pSessionControlProxy, &tmp);
IAudioSessionControl_GetDisplayName(state->pSessionControlProxy,
&tmp);
} while (lstrcmpW(title, tmp));
SAFE_RELEASE(tmp, CoTaskMemFree(tmp));
talloc_free(title);
return CONTROL_OK;
}
default:
return CONTROL_UNKNOWN;
}
return state->opt_exclusive ?
control_exclusive(ao, cmd, arg) : control_shared(ao, cmd, arg);
}
static void audio_reset(struct ao *ao)
@@ -377,9 +458,7 @@ static void audio_resume(struct ao *ao)
static void hotplug_uninit(struct ao *ao)
{
MP_DBG(ao, "Hotplug uninit\n");
struct wasapi_state *state = ao->priv;
wasapi_change_uninit(ao);
SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator));
CoUninitialize();
}
@@ -389,10 +468,7 @@ static int hotplug_init(struct ao *ao)
struct wasapi_state *state = ao->priv;
state->log = ao->log;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
EXIT_ON_ERROR(hr);
hr = wasapi_change_init(ao, true);
HRESULT hr = wasapi_change_init(ao, true);
EXIT_ON_ERROR(hr);
return 0;
Executable → Regular
+63 -47
View File
@@ -20,17 +20,24 @@
#ifndef MP_AO_WASAPI_H_
#define MP_AO_WASAPI_H_
#include <stdlib.h>
#include <stdbool.h>
#include <windows.h>
#include <mmdeviceapi.h>
#include <audioclient.h>
#include <audiopolicy.h>
#include <mmdeviceapi.h>
#include <avrt.h>
#include <endpointvolume.h>
#include "common/msg.h"
#include "osdep/atomics.h"
#include "osdep/windows_utils.h"
#include "internal.h"
#include "ao.h"
typedef struct change_notify {
IMMNotificationClient client; /* this must be first in the structure! */
LPWSTR monitored; /* Monitored device */
IMMNotificationClient client; // this must be first in the structure!
IMMDeviceEnumerator *pEnumerator; // object where client is registered
LPWSTR monitored; // Monitored device
bool is_hotplug;
struct ao *ao;
} change_notify;
@@ -52,64 +59,73 @@ enum wasapi_thread_state {
typedef struct wasapi_state {
struct mp_log *log;
/* Init phase */
HRESULT init_ret;
HANDLE hInitDone;
int share_mode;
/* volume control */
DWORD vol_hw_support;
float audio_volume;
float previous_volume;
float initial_volume;
// Thread handles
HRESULT init_ret; // status of init phase
HANDLE hInitDone; // set when init is complete in audio thread
HANDLE hAudioThread; // the audio thread itself
HANDLE hWake; // thread wakeup event
atomic_int thread_state; // enum wasapi_thread_state (what to do on wakeup)
/* WASAPI handles, owned by audio thread */
// for setting the audio thread priority
HANDLE hTask;
// ID of the device to use
LPWSTR deviceID;
// WASAPI object handles owned and used by audio thread
IMMDevice *pDevice;
IAudioClient *pAudioClient;
IAudioRenderClient *pRenderClient;
ISimpleAudioVolume *pAudioVolume;
IAudioEndpointVolume *pEndpointVolume;
IAudioSessionControl *pSessionControl;
IMMDeviceEnumerator *pEnumerator;
/* thread handles */
HANDLE hAudioThread; /* the thread itself */
HANDLE hWake; /* thread wakeup event */
atomic_int thread_state; /* enum wasapi_thread_state */
/* for setting the audio thread priority */
HANDLE hTask; /* AV thread */
/* WASAPI proxy handles, for Single-Threaded Apartment communication.
One is needed for each audio thread object that's accessed from the main thread. */
ISimpleAudioVolume *pAudioVolumeProxy;
IAudioEndpointVolume *pEndpointVolumeProxy;
IAudioSessionControl *pSessionControlProxy;
/* Streams used to marshal the proxy objects. The thread owning the actual objects
needs to marshal proxy objects into these streams, and the thread that wants the
proxies unmarshals them from here. */
IStream *sAudioVolume;
IStream *sEndpointVolume;
IStream *sSessionControl;
/* WASAPI internal clock information, for estimating delay */
// WASAPI internal clock information, for estimating delay
IAudioClock *pAudioClock;
UINT64 clock_frequency; /* scale for the "samples" returned by the clock */
atomic_ullong sample_count; /* the amount of samples per channel written to a GetBuffer buffer */
LARGE_INTEGER qpc_frequency; /* frequency of windows' high resolution timer */
atomic_ullong sample_count; // samples per channel written by GetBuffer
UINT64 clock_frequency; // scale for position returned by GetPosition
LARGE_INTEGER qpc_frequency; // frequency of Windows' high resolution timer
/* ao options */
// WASAPI control (handles owned by audio thread but used by main thread)
IAudioSessionControl *pSessionControl; // setting the stream title
IAudioEndpointVolume *pEndpointVolume; // exclusive mode volume/mute
ISimpleAudioVolume *pAudioVolume; // shared mode volume/mute
DWORD vol_hw_support; // is hardware volume supported for exclusive-mode?
// Streams used to marshal the proxy objects. The thread owning the actual
// objects needs to marshal proxy objects into these streams, and the thread
// that wants the proxies unmarshals them from here.
IStream *sSessionControl;
IStream *sEndpointVolume;
IStream *sAudioVolume;
// WASAPI proxy handles, for Single-Threaded Apartment communication. One is
// needed for each audio thread object that's accessed from the main thread.
IAudioSessionControl *pSessionControlProxy;
IAudioEndpointVolume *pEndpointVolumeProxy;
ISimpleAudioVolume *pAudioVolumeProxy;
// ao options
int opt_exclusive;
int opt_list;
char *opt_device;
/* format info */
// format info
WAVEFORMATEXTENSIBLE format;
size_t buffer_block_size; /* Size of each block in bytes */
UINT32 bufferFrameCount; /* wasapi buffer block size, number of frames, frame size at format.nBlockAlign */
AUDCLNT_SHAREMODE share_mode; // AUDCLNT_SHAREMODE_EXCLUSIVE / SHARED
UINT32 bufferFrameCount; // number of frames in buffer
change_notify change;
} wasapi_state;
char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey);
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
LPWSTR find_deviceID(struct ao *ao);
void wasapi_dispatch(struct ao *ao);
HRESULT wasapi_thread_init(struct ao *ao);
void wasapi_thread_uninit(struct ao *ao);
void wasapi_receive_proxies(wasapi_state *state);
void wasapi_release_proxies(wasapi_state *state);
#endif
+33 -33
View File
@@ -17,20 +17,14 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <initguid.h>
#include <audioclient.h>
#include <endpointvolume.h>
#include <mmdeviceapi.h>
#include <wchar.h>
#include <stdlib.h>
#include "ao_wasapi.h"
#include "ao_wasapi_utils.h"
static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface(
IMMNotificationClient* This, REFIID riid, void **ppvObject)
{
/* Compatible with IMMNotificationClient and IUnknown */
// Compatible with IMMNotificationClient and IUnknown
if (IsEqualGUID(&IID_IMMNotificationClient, riid) ||
IsEqualGUID(&IID_IUnknown, riid))
{
@@ -42,14 +36,14 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface(
}
}
/* these are required, but not actually used */
// these are required, but not actually used
static ULONG STDMETHODCALLTYPE sIMMNotificationClient_AddRef(
IMMNotificationClient *This)
{
return 1;
}
/* MSDN says it should free itself, but we're static */
// MSDN says it should free itself, but we're static
static ULONG STDMETHODCALLTYPE sIMMNotificationClient_Release(
IMMNotificationClient *This)
{
@@ -65,7 +59,8 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceStateChanged(
struct ao *ao = change->ao;
if (change->is_hotplug) {
MP_VERBOSE(ao, "OnDeviceStateChanged triggered: sending hotplug event\n");
MP_VERBOSE(ao,
"OnDeviceStateChanged triggered: sending hotplug event\n");
ao_hotplug_event(ao);
} else if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
switch (dwNewState) {
@@ -99,7 +94,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 prefered device once it is plugged in?
static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceRemoved(
IMMNotificationClient *This,
LPCWSTR pwstrDeviceId)
@@ -129,29 +124,31 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
struct ao *ao = change->ao;
struct wasapi_state *state = ao->priv;
/* don't care about "eCapture" or non-"eMultimedia" roles */
// don't care about "eCapture" or non-"eMultimedia" roles
if (flow == eCapture || role != eMultimedia) return S_OK;
if (change->is_hotplug) {
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: sending hotplug event\n");
MP_VERBOSE(ao,
"OnDefaultDeviceChanged triggered: sending hotplug event\n");
ao_hotplug_event(ao);
} else {
/* stay on the device the user specified */
// stay on the device the user specified
if (state->opt_device) {
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
"staying on specified device %s\n", state->opt_device);
return S_OK;
}
/* don't reload if already on the new default */
// don't reload if already on the new default
if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
"already using default device, no reload required\n");
return S_OK;
}
/* if we got here, we need to reload */
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: requesting ao reload\n");
// if we got here, we need to reload
MP_VERBOSE(ao,
"OnDefaultDeviceChanged triggered: requesting ao reload\n");
ao_request_reload(ao);
}
@@ -184,7 +181,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnPropertyValueChanged(
return S_OK;
}
static CONST_VTBL IMMNotificationClientVtbl sIMMDeviceEnumeratorVtbl_vtbl = {
static CONST_VTBL IMMNotificationClientVtbl sIMMNotificationClientVtbl = {
.QueryInterface = sIMMNotificationClient_QueryInterface,
.AddRef = sIMMNotificationClient_AddRef,
.Release = sIMMNotificationClient_Release,
@@ -200,27 +197,30 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug)
{
struct wasapi_state *state = ao->priv;
struct change_notify *change = &state->change;
HRESULT hr;
/* COM voodoo to emulate c++ class */
change->client.lpVtbl = &sIMMDeviceEnumeratorVtbl_vtbl;
/* register the change notification client */
hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
state->pEnumerator, (IMMNotificationClient *)change);
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator,
(void **)&change->pEnumerator);
EXIT_ON_ERROR(hr);
/* so the callbacks can access the ao */
// COM voodoo to emulate c++ class
change->client.lpVtbl = &sIMMNotificationClientVtbl;
// register the change notification client
hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
change->pEnumerator, (IMMNotificationClient *)change);
EXIT_ON_ERROR(hr);
// so the callbacks can access the ao
change->ao = ao;
/* whether or not this is the hotplug instance */
// whether or not this is the hotplug instance
change->is_hotplug = is_hotplug;
if (is_hotplug) {
MP_DBG(ao, "Monitoring for hotplug events\n");
} else {
/* Get the device string to compare with the pwstrDeviceId */
hr = IMMDevice_GetId(state->pDevice, &change->monitored);
EXIT_ON_ERROR(hr);
// Get the device string to compare with the pwstrDeviceId
change->monitored = state->deviceID;
MP_VERBOSE(ao, "Monitoring changes in device %S\n", change->monitored);
}
@@ -237,10 +237,10 @@ void wasapi_change_uninit(struct ao *ao)
struct wasapi_state *state = ao->priv;
struct change_notify *change = &state->change;
if (state->pEnumerator && change->client.lpVtbl) {
if (change->pEnumerator && change->client.lpVtbl) {
IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
state->pEnumerator, (IMMNotificationClient *)change);
change->pEnumerator, (IMMNotificationClient *)change);
}
if (change->monitored) CoTaskMemFree(change->monitored);
SAFE_RELEASE(change->pEnumerator, IMMDeviceEnumerator_Release(change->pEnumerator));
}
Executable → Regular
+367 -458
View File
File diff suppressed because it is too large. Load diff
-49
View File
@@ -1,49 +0,0 @@
/*
* This file is part of mpv.
*
* Original author: Jonathan Yong <10walls@gmail.com>
*
* mpv is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MP_AO_WASAPI_UTILS_H_
#define MP_AO_WASAPI_UTILS_H_
#include "audio/out/ao_wasapi.h"
#include "options/m_option.h"
#include "common/msg.h"
#include "ao.h"
#include "internal.h"
char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid);
char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey);
char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr);
#define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid))
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
#define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[60]){0}, 60, (hr))
#define mp_LastError_to_str() mp_HRESULT_to_str(HRESULT_FROM_WIN32(GetLastError()))
bool wasapi_fill_VistaBlob(wasapi_state *state);
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
void wasapi_dispatch(struct ao *ao);
HRESULT wasapi_thread_init(struct ao *ao);
void wasapi_thread_uninit(struct ao *ao);
HRESULT wasapi_setup_proxies(wasapi_state *state);
void wasapi_release_proxies(wasapi_state *state);
#endif
+1 -1
View File
@@ -113,7 +113,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
// rest of the user-provided buffer with silence.
// This basically assumes that the audio device doesn't care about underruns.
// If this is called in paused mode, it will always return 0.
// The caller should set out_time_us to the expected delay the last sample
// The caller should set out_time_us to the expected delay until the last sample
// reaches the speakers, in microseconds, using mp_time_us() as reference.
int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_us)
{
+1 -1
View File
@@ -16,7 +16,7 @@
*/
#include <assert.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "misc/bstr.h"
#include "common/msg.h"
#include "codecs.h"
+20 -2
View File
@@ -21,8 +21,9 @@
#include <libavutil/common.h>
#include <libavutil/error.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "misc/bstr.h"
#include "misc/ctype.h"
#include "common/common.h"
#define appendf(ptr, ...) \
@@ -148,7 +149,7 @@ void mp_append_utf8_bstr(void *talloc_ctx, struct bstr *buf, uint32_t codepoint)
bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
}
// Parse a C-style escape beginning at code, and append the result to *str
// Parse a C/JSON-style escape beginning at code, and append the result to *str
// using talloc. The input string (*code) must point to the first character
// after the initial '\', and after parsing *code is set to the first character
// after the current escape.
@@ -161,6 +162,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
switch (code->start[0]) {
case '"': replace = '"'; break;
case '\\': replace = '\\'; break;
case '/': replace = '/'; break;
case 'b': replace = '\b'; break;
case 'f': replace = '\f'; break;
case 'n': replace = '\n'; break;
@@ -257,3 +259,19 @@ char *mp_strerror_buf(char *buf, size_t buf_size, int errnum)
av_strerror(AVERROR(errnum), buf, buf_size);
return buf;
}
char *mp_tag_str_buf(char *buf, size_t buf_size, uint32_t tag)
{
if (buf_size < 1)
return buf;
buf[0] = '\0';
for (int n = 0; n < 4; n++) {
uint8_t val = (tag >> (n * 8)) & 0xFF;
if (mp_isalnum(val) || val == '_' || val == ' ') {
mp_snprintf_cat(buf, buf_size, "%c", val);
} else {
mp_snprintf_cat(buf, buf_size, "[%d]", val);
}
}
return buf;
}
+4 -3
View File
@@ -24,7 +24,7 @@
#include <stdint.h>
#include "osdep/compiler.h"
#include "talloc.h"
#include "mpv_talloc.h"
// double should be able to represent this exactly
#define MP_NOPTS_VALUE (-0x1p+63)
@@ -32,8 +32,6 @@
#define MP_CONCAT_(a, b) a ## b
#define MP_CONCAT(a, b) MP_CONCAT_(a, b)
#define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5))
#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
@@ -92,4 +90,7 @@ bool mp_append_escaped_string(void *talloc_ctx, struct bstr *dst,
char *mp_strerror_buf(char *buf, size_t buf_size, int errnum);
#define mp_strerror(e) mp_strerror_buf((char[80]){0}, 80, e)
char *mp_tag_str_buf(char *buf, size_t buf_size, uint32_t tag);
#define mp_tag_str(t) mp_tag_str_buf((char[22]){0}, 22, t)
#endif /* MPLAYER_MPCOMMON_H */
+1 -1
View File
@@ -29,7 +29,7 @@
#include "options/options.h"
#include "osdep/timer.h"
#include "video/out/vo.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "stream/stream.h"
#define OPT_BASE_STRUCT struct encode_opts
+1
View File
@@ -7,6 +7,7 @@
struct mpv_global {
struct MPOpts *opts;
struct mp_log *log;
struct mp_client_api *client_api;
};
#endif
+1 -1
View File
@@ -24,7 +24,7 @@
#include <pthread.h>
#include <stdint.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "misc/bstr.h"
#include "osdep/atomics.h"
+13 -1
View File
@@ -21,7 +21,7 @@
#include "common/common.h"
#include "common/global.h"
#include "common/msg.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "options/path.h"
#include "demux/demux.h"
@@ -206,6 +206,18 @@ void playlist_add_base_path(struct playlist *pl, bstr base_path)
}
}
// Add redirected_from as new redirect entry to each item in pl.
void playlist_add_redirect(struct playlist *pl, const char *redirected_from)
{
for (struct playlist_entry *e = pl->first; e; e = e->next) {
if (e->num_redirects >= 10) // arbitrary limit for sanity
break;
char *s = talloc_strdup(e, redirected_from);
if (s)
MP_TARRAY_APPEND(e, e->redirects, e->num_redirects, s);
}
}
// Move all entries from source_pl to pl, appending them after the current entry
// of pl. source_pl will be empty, and all entries have changed ownership to pl.
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl)
+6
View File
@@ -36,6 +36,11 @@ struct playlist_entry {
char *title;
// If the user plays a playlist, then the playlist's URL will be appended
// as redirect to each entry. (Same for directories etc.)
char **redirects;
int num_redirects;
// Set to true if playback didn't seem to work, or if the file could be
// played only for a very short time. This is used to make playlist
// navigation just work in case the user has unplayable files in the
@@ -88,6 +93,7 @@ void playlist_add_file(struct playlist *pl, const char *filename);
void playlist_shuffle(struct playlist *pl);
struct playlist_entry *playlist_get_next(struct playlist *pl, int direction);
void playlist_add_base_path(struct playlist *pl, bstr base_path);
void playlist_add_redirect(struct playlist *pl, const char *redirected_from);
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl);
void playlist_append_entries(struct playlist *pl, struct playlist *source_pl);
+8 -8
View File
@@ -70,20 +70,20 @@ static const char *map_audio_pcm_tag(uint32_t tag, int bits)
}
}
void mp_set_codec_from_tag(struct sh_stream *sh)
void mp_set_codec_from_tag(struct mp_codec_params *c)
{
sh->codec = lookup_tag(sh->type, sh->codec_tag);
c->codec = lookup_tag(c->type, c->codec_tag);
if (sh->audio && sh->audio->bits_per_coded_sample) {
if (c->type == STREAM_AUDIO && c->bits_per_coded_sample) {
const char *codec =
map_audio_pcm_tag(sh->codec_tag, sh->audio->bits_per_coded_sample);
map_audio_pcm_tag(c->codec_tag, c->bits_per_coded_sample);
if (codec)
sh->codec = codec;
c->codec = codec;
}
}
void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
bool is_be)
void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
int bits, bool is_be)
{
// This uses libavcodec pcm codec names, e.g. "pcm_u16le".
char codec[64] = "pcm_";
@@ -95,7 +95,7 @@ void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
mp_snprintf_cat(codec, sizeof(codec), "%d", bits);
if (bits != 8)
mp_snprintf_cat(codec, sizeof(codec), is_be ? "be" : "le");
sh->codec = talloc_strdup(sh->audio, codec);
c->codec = talloc_strdup(c, codec);
}
static const char *const mimetype_to_codec[][2] = {
+4 -4
View File
@@ -21,12 +21,12 @@
#include <stdint.h>
#include <stdbool.h>
struct sh_stream;
struct mp_codec_params;
void mp_set_codec_from_tag(struct sh_stream *sh);
void mp_set_codec_from_tag(struct mp_codec_params *c);
void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
bool is_be);
void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
int bits, bool is_be);
const char *mp_map_mimetype_to_video_codec(const char *mimetype);
+16 -1
View File
@@ -20,7 +20,7 @@
#include <string.h>
#include <inttypes.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "misc/bstr.h"
#include "common/common.h"
@@ -218,3 +218,18 @@ struct cue_file *mp_parse_cue(struct bstr data)
return f;
}
int mp_check_embedded_cue(struct cue_file *f)
{
char *fn0 = f->tracks[0].filename;
for (int n = 1; n < f->num_tracks; n++) {
char *fn = f->tracks[n].filename;
// both filenames have the same address (including NULL)
if (fn0 == fn)
continue;
// only one filename is NULL, or the strings don't match
if (!fn0 || !fn || strcmp(fn0, fn) != 0)
return -1;
}
return 0;
}
+1
View File
@@ -38,5 +38,6 @@ struct cue_track {
bool mp_probe_cue(struct bstr data);
struct cue_file *mp_parse_cue(struct bstr data);
int mp_check_embedded_cue(struct cue_file *f);
#endif
+156 -95
View File
@@ -29,7 +29,7 @@
#include "config.h"
#include "options/options.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/msg.h"
#include "common/global.h"
#include "osdep/threads.h"
@@ -103,6 +103,11 @@ struct demux_internal {
void (*wakeup_cb)(void *ctx);
void *wakeup_cb_ctx;
struct sh_stream **streams;
int num_streams;
int events;
bool warned_queue_overflow;
bool last_eof; // last actual global EOF status
bool eof; // whether we're in EOF state (reset for retry)
@@ -198,42 +203,84 @@ void demux_set_ts_offset(struct demuxer *demuxer, double offset)
pthread_mutex_unlock(&in->lock);
}
struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
// Allocate a new sh_stream of the given type. It either has to be released
// with talloc_free(), or added to a demuxer with demux_add_sh_stream(). You
// cannot add or read packets from the stream before it has been added.
struct sh_stream *demux_alloc_sh_stream(enum stream_type type)
{
assert(demuxer == demuxer->in->d_thread);
if (demuxer->num_streams > MAX_SH_STREAMS) {
MP_WARN(demuxer, "Too many streams.\n");
return NULL;
}
int demuxer_id = 0;
for (int n = 0; n < demuxer->num_streams; n++) {
if (demuxer->streams[n]->type == type)
demuxer_id++;
}
struct sh_stream *sh = talloc_ptrtype(demuxer, sh);
struct sh_stream *sh = talloc_ptrtype(NULL, sh);
*sh = (struct sh_stream) {
.type = type,
.index = demuxer->num_streams,
.ff_index = demuxer->num_streams,
.demuxer_id = demuxer_id, // may be overwritten by demuxer
.ds = talloc(sh, struct demux_stream),
.index = -1,
.ff_index = -1, // may be overwritten by demuxer
.demuxer_id = -1, // ... same
.codec = talloc_zero(sh, struct mp_codec_params),
};
sh->codec->type = type;
return sh;
}
// Add a new sh_stream to the demuxer. Note that as soon as the stream has been
// added, it must be immutable, and must not be released (this will happen when
// the demuxer is destroyed).
void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh)
{
struct demux_internal *in = demuxer->in;
pthread_mutex_lock(&in->lock);
assert(!sh->ds); // must not be added yet
sh->ds = talloc(sh, struct demux_stream);
*sh->ds = (struct demux_stream) {
.in = demuxer->in,
.in = in,
.type = sh->type,
.selected = demuxer->in->autoselect,
.selected = in->autoselect,
};
MP_TARRAY_APPEND(demuxer, demuxer->streams, demuxer->num_streams, sh);
switch (sh->type) {
case STREAM_VIDEO: sh->video = talloc_zero(demuxer, struct sh_video); break;
case STREAM_AUDIO: sh->audio = talloc_zero(demuxer, struct sh_audio); break;
case STREAM_SUB: sh->sub = talloc_zero(demuxer, struct sh_sub); break;
if (!sh->codec->codec)
sh->codec->codec = "";
sh->index = in->num_streams;
if (sh->ff_index < 0)
sh->ff_index = sh->index;
if (sh->demuxer_id < 0) {
sh->demuxer_id = 0;
for (int n = 0; n < in->num_streams; n++) {
if (in->streams[n]->type == sh->type)
sh->demuxer_id += 1;
}
}
return sh;
MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
in->events |= DEMUX_EVENT_STREAMS;
if (in->wakeup_cb)
in->wakeup_cb(in->wakeup_cb_ctx);
pthread_mutex_unlock(&in->lock);
}
// Return a stream with the given index. Since streams can only be added during
// the lifetime of the demuxer, it is guaranteed that an index within the valid
// range [0, demux_get_num_stream()) always returns a valid sh_stream pointer,
// which will be valid until the demuxer is destroyed.
struct sh_stream *demux_get_stream(struct demuxer *demuxer, int index)
{
struct demux_internal *in = demuxer->in;
pthread_mutex_lock(&in->lock);
assert(index >= 0 && index < in->num_streams);
struct sh_stream *r = in->streams[index];
pthread_mutex_unlock(&in->lock);
return r;
}
// See demux_get_stream().
int demux_get_num_stream(struct demuxer *demuxer)
{
struct demux_internal *in = demuxer->in;
pthread_mutex_lock(&in->lock);
int r = in->num_streams;
pthread_mutex_unlock(&in->lock);
return r;
}
void free_demuxer(demuxer_t *demuxer)
@@ -247,8 +294,10 @@ void free_demuxer(demuxer_t *demuxer)
if (demuxer->desc->close)
demuxer->desc->close(in->d_thread);
for (int n = 0; n < demuxer->num_streams; n++)
ds_flush(demuxer->streams[n]->ds);
for (int n = in->num_streams - 1; n >= 0; n--) {
ds_flush(in->streams[n]->ds);
talloc_free(in->streams[n]);
}
pthread_mutex_destroy(&in->lock);
pthread_cond_destroy(&in->wakeup);
talloc_free(demuxer);
@@ -388,8 +437,8 @@ static bool read_packet(struct demux_internal *in)
// safe-guards against packet queue overflow.
bool active = false, read_more = false;
size_t packs = 0, bytes = 0;
for (int n = 0; n < in->d_buffer->num_streams; n++) {
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
active |= ds->active;
read_more |= ds->active && !ds->head;
packs += ds->packs;
@@ -404,16 +453,16 @@ static bool read_packet(struct demux_internal *in)
if (!in->warned_queue_overflow) {
in->warned_queue_overflow = true;
MP_ERR(in, "Too many packets in the demuxer packet queues:\n");
for (int n = 0; n < in->d_buffer->num_streams; n++) {
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
if (ds->selected) {
MP_ERR(in, " %s/%d: %zd packets, %zd bytes\n",
stream_type_name(ds->type), n, ds->packs, ds->bytes);
}
}
}
for (int n = 0; n < in->d_buffer->num_streams; n++) {
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
ds->eof |= !ds->head;
}
pthread_cond_signal(&in->wakeup);
@@ -433,8 +482,8 @@ static bool read_packet(struct demux_internal *in)
pthread_mutex_lock(&in->lock);
if (eof) {
for (int n = 0; n < in->d_buffer->num_streams; n++)
in->d_buffer->streams[n]->ds->eof = true;
for (int n = 0; n < in->num_streams; n++)
in->streams[n]->ds->eof = true;
// If we had EOF previously, then don't wakeup (avoids wakeup loop)
if (!in->last_eof) {
if (in->wakeup_cb)
@@ -478,8 +527,8 @@ static void start_refreshing(struct demux_internal *in)
in->start_refresh_seek = false;
double start_ts = MP_NOPTS_VALUE;
for (int n = 0; n < demux->num_streams; n++) {
struct demux_stream *ds = demux->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
}
@@ -488,8 +537,8 @@ static void start_refreshing(struct demux_internal *in)
demux->partially_seekable || !demux->allow_refresh_seeks)
return;
for (int n = 0; n < demux->num_streams; n++) {
struct demux_stream *ds = demux->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
// Streams which didn't read any packets yet can return all packets,
// or they'd be stuck forever; affects newly selected streams too.
if (ds->last_pos != -1)
@@ -635,15 +684,33 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh)
return pkt;
}
// Sparse packets (Subtitles) interleaved with other non-sparse packets (video,
// audio) should never be read actively, meaning the demuxer thread does not
// try to exceed default readahead in order to find a new packet.
static bool use_lazy_subtitle_reading(struct demux_stream *ds)
{
if (ds->type != STREAM_SUB)
return false;
for (int n = 0; n < ds->in->num_streams; n++) {
struct demux_stream *s = ds->in->streams[n]->ds;
if (s->type != STREAM_SUB && s->selected && !s->eof)
return true;
}
return false;
}
// Poll the demuxer queue, and if there's a packet, return it. Otherwise, just
// make the demuxer thread read packets for this stream, and if there's at
// least one packet, call the wakeup callback.
// Unlike demux_read_packet(), this always enables readahead (which means you
// must not use it on interleaved subtitle streams).
// Unlike demux_read_packet(), this always enables readahead (except for
// interleaved subtitles).
// Returns:
// < 0: EOF was reached, *out_pkt=NULL
// == 0: no new packet yet, but maybe later, *out_pkt=NULL
// > 0: new packet read, *out_pkt is set
// Note: when reading interleaved subtitles, the demuxer won't try to forcibly
// read ahead to get the next subtitle packet (as the next packet could be
// minutes away). In this situation, this function will just return -1.
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
{
struct demux_stream *ds = sh ? sh->ds : NULL;
@@ -653,10 +720,14 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
if (ds->in->threading) {
pthread_mutex_lock(&ds->in->lock);
*out_pkt = dequeue_packet(ds);
r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0);
ds->active = ds->selected; // enable readahead
ds->in->eof = false; // force retry
pthread_cond_signal(&ds->in->wakeup); // possibly read more
if (use_lazy_subtitle_reading(ds)) {
r = *out_pkt ? 1 : -1;
} else {
r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0);
ds->active = ds->selected; // enable readahead
ds->in->eof = false; // force retry
pthread_cond_signal(&ds->in->wakeup); // possibly read more
}
pthread_mutex_unlock(&ds->in->lock);
} else {
*out_pkt = demux_read_packet(sh);
@@ -666,22 +737,6 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
return r;
}
// Return the pts of the next packet that demux_read_packet() would return.
// Might block. Sometimes used to force a packet read, without removing any
// packets from the queue.
double demux_get_next_pts(struct sh_stream *sh)
{
double res = MP_NOPTS_VALUE;
if (sh) {
pthread_mutex_lock(&sh->ds->in->lock);
ds_get_packets(sh->ds);
if (sh->ds->head)
res = MP_ADD_PTS(sh->ds->head->pts, sh->ds->in->ts_offset);
pthread_mutex_unlock(&sh->ds->in->lock);
}
return res;
}
// Return whether a packet is queued. Never blocks, never forces any reads.
bool demux_has_packet(struct sh_stream *sh)
{
@@ -697,21 +752,22 @@ bool demux_has_packet(struct sh_stream *sh)
// Read and return any packet we find.
struct demux_packet *demux_read_any_packet(struct demuxer *demuxer)
{
assert(!demuxer->in->threading); // doesn't work with threading
struct demux_internal *in = demuxer->in;
assert(!in->threading); // doesn't work with threading
bool read_more = true;
while (read_more) {
for (int n = 0; n < demuxer->num_streams; n++) {
struct sh_stream *sh = demuxer->streams[n];
for (int n = 0; n < in->num_streams; n++) {
struct sh_stream *sh = in->streams[n];
sh->ds->active = sh->ds->selected; // force read_packet() to read
struct demux_packet *pkt = dequeue_packet(sh->ds);
if (pkt)
return pkt;
}
// retry after calling this
pthread_mutex_lock(&demuxer->in->lock);
read_more = read_packet(demuxer->in);
read_more &= !demuxer->in->eof;
pthread_mutex_unlock(&demuxer->in->lock);
pthread_mutex_lock(&in->lock); // lock only because read_packet unlocks
read_more = read_packet(in);
read_more &= !in->eof;
pthread_mutex_unlock(&in->lock);
}
return NULL;
}
@@ -795,13 +851,14 @@ static int decode_peak(demuxer_t *demuxer, const char *tag, float *out)
static void apply_replaygain(demuxer_t *demuxer, struct replaygain_data *rg)
{
for (int n = 0; n < demuxer->num_streams; n++) {
struct sh_stream *sh = demuxer->streams[n];
if (sh->audio && !sh->audio->replaygain_data) {
struct demux_internal *in = demuxer->in;
for (int n = 0; n < in->num_streams; n++) {
struct sh_stream *sh = in->streams[n];
if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
MP_VERBOSE(demuxer, "Replaygain: Track=%f/%f Album=%f/%f\n",
rg->track_gain, rg->track_peak,
rg->album_gain, rg->album_peak);
sh->audio->replaygain_data = talloc_memdup(demuxer, rg, sizeof(*rg));
sh->codec->replaygain_data = talloc_memdup(in, rg, sizeof(*rg));
}
}
}
@@ -853,11 +910,6 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src)
dst->start_time = src->start_time;
dst->priv = src->priv;
}
if (src->events & DEMUX_EVENT_STREAMS) {
// The stream structs themselves are immutable.
for (int n = dst->num_streams; n < src->num_streams; n++)
MP_TARRAY_APPEND(dst, dst->streams, dst->num_streams, src->streams[n]);
}
if (src->events & DEMUX_EVENT_METADATA) {
talloc_free(dst->metadata);
dst->metadata = mp_tags_dup(dst, src->metadata);
@@ -905,6 +957,8 @@ void demux_update(demuxer_t *demuxer)
pthread_mutex_lock(&in->lock);
demux_copy(demuxer, in->d_buffer);
demuxer->events |= in->events;
in->events = 0;
if (in->stream_metadata && (demuxer->events & DEMUX_EVENT_METADATA))
mp_tags_merge(demuxer->metadata, in->stream_metadata);
pthread_mutex_unlock(&in->lock);
@@ -926,10 +980,15 @@ static void demux_init_cuesheet(struct demuxer *demuxer)
if (cue && !demuxer->num_chapters) {
struct cue_file *f = mp_parse_cue(bstr0(cue));
if (f) {
for (int n = 0; n < f->num_tracks; n++) {
struct cue_track *t = &f->tracks[n];
int idx = demuxer_add_chapter(demuxer, "", t->start, -1);
mp_tags_merge(demuxer->chapters[idx].metadata, t->tags);
if (mp_check_embedded_cue(f) < 0) {
MP_WARN(demuxer, "Embedded cue sheet references more than one file. "
"Ignoring it.\n");
} else {
for (int n = 0; n < f->num_tracks; n++) {
struct cue_track *t = &f->tracks[n];
int idx = demuxer_add_chapter(demuxer, "", t->start, -1);
mp_tags_merge(demuxer->chapters[idx].metadata, t->tags);
}
}
}
talloc_free(f);
@@ -1108,8 +1167,8 @@ struct demuxer *demux_open_url(const char *url,
static void flush_locked(demuxer_t *demuxer)
{
for (int n = 0; n < demuxer->num_streams; n++)
ds_flush(demuxer->streams[n]->ds);
for (int n = 0; n < demuxer->in->num_streams; n++)
ds_flush(demuxer->in->streams[n]->ds);
demuxer->in->warned_queue_overflow = false;
demuxer->in->eof = false;
demuxer->in->last_eof = false;
@@ -1187,10 +1246,11 @@ void demux_set_enable_refresh_seeks(struct demuxer *demuxer, bool enabled)
struct sh_stream *demuxer_stream_by_demuxer_id(struct demuxer *d,
enum stream_type t, int id)
{
for (int n = 0; n < d->num_streams; n++) {
struct sh_stream *s = d->streams[n];
int num = demux_get_num_stream(d);
for (int n = 0; n < num; n++) {
struct sh_stream *s = demux_get_stream(d, n);
if (s->type == t && s->demuxer_id == id)
return d->streams[n];
return s;
}
return NULL;
}
@@ -1200,8 +1260,9 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
{
assert(!stream || stream->type == type);
for (int n = 0; n < demuxer->num_streams; n++) {
struct sh_stream *cur = demuxer->streams[n];
int num = demux_get_num_stream(demuxer);
for (int n = 0; n < num; n++) {
struct sh_stream *cur = demux_get_stream(demuxer, n);
if (cur->type == type)
demuxer_select_track(demuxer, cur, cur == stream);
}
@@ -1403,8 +1464,8 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
double *rates = arg;
for (int n = 0; n < STREAM_TYPE_COUNT; n++)
rates[n] = -1;
for (int n = 0; n < in->d_user->num_streams; n++) {
struct demux_stream *ds = in->d_user->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
if (ds->selected && ds->bitrate >= 0)
rates[ds->type] = MPMAX(0, rates[ds->type]) + ds->bitrate;
}
@@ -1418,8 +1479,8 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
.ts_duration = -1,
};
int num_packets = 0;
for (int n = 0; n < in->d_user->num_streams; n++) {
struct demux_stream *ds = in->d_user->streams[n]->ds;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
if (ds->active) {
r->underrun |= !ds->head && !ds->eof;
r->ts_range[0] = MP_PTS_MAX(r->ts_range[0], ds->base_ts);
+5 -7
View File
@@ -86,8 +86,6 @@ enum demux_event {
DEMUX_EVENT_ALL = 0xFFFF,
};
#define MAX_SH_STREAMS 256
struct demuxer;
struct timeline;
@@ -199,9 +197,6 @@ typedef struct demuxer {
// Bitmask of DEMUX_EVENT_*
int events;
struct sh_stream **streams;
int num_streams;
struct demux_edition *editions;
int num_editions;
int edition;
@@ -247,11 +242,14 @@ void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp);
struct demux_packet *demux_read_packet(struct sh_stream *sh);
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt);
bool demux_stream_is_selected(struct sh_stream *stream);
double demux_get_next_pts(struct sh_stream *sh);
bool demux_has_packet(struct sh_stream *sh);
struct demux_packet *demux_read_any_packet(struct demuxer *demuxer);
struct sh_stream *new_sh_stream(struct demuxer *demuxer, enum stream_type type);
struct sh_stream *demux_get_stream(struct demuxer *demuxer, int index);
int demux_get_num_stream(struct demuxer *demuxer);
struct sh_stream *demux_alloc_sh_stream(enum stream_type type);
void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh);
struct demuxer *demux_open(struct stream *stream, struct demuxer_params *params,
struct mpv_global *global);
+13 -3
View File
@@ -23,7 +23,7 @@
#include <dirent.h>
#include <inttypes.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "misc/bstr.h"
#include "common/msg.h"
@@ -150,8 +150,18 @@ static void build_timeline(struct timeline *tl)
add_source(tl, tl->demuxer);
struct cue_track *tracks = p->f->tracks;
size_t track_count = p->f->num_tracks;
struct cue_track *tracks = NULL;
size_t track_count = 0;
for (size_t n = 0; n < p->f->num_tracks; n++) {
struct cue_track *track = &p->f->tracks[n];
if (track->filename) {
MP_TARRAY_APPEND(ctx, tracks, track_count, *track);
} else {
MP_WARN(tl->demuxer, "No file specified for track entry %zd. "
"It will be removed\n", n + 1);
}
}
if (track_count == 0) {
MP_ERR(tl, "CUE: no tracks found!\n");
+24 -21
View File
@@ -23,6 +23,7 @@
#include "common/msg.h"
#include "stream/stream.h"
#include "video/mp_image.h"
#include "demux.h"
#include "stheader.h"
@@ -53,9 +54,10 @@ struct priv {
static void reselect_streams(demuxer_t *demuxer)
{
struct priv *p = demuxer->priv;
for (int n = 0; n < MPMIN(p->slave->num_streams, p->num_streams); n++) {
int num_slave = demux_get_num_stream(p->slave);
for (int n = 0; n < MPMIN(num_slave, p->num_streams); n++) {
if (p->streams[n]) {
demuxer_select_track(p->slave, p->slave->streams[n],
demuxer_select_track(p->slave, demux_get_stream(p->slave, n),
demux_stream_is_selected(p->streams[n]));
}
}
@@ -80,11 +82,9 @@ static void add_dvd_streams(demuxer_t *demuxer)
struct stream_dvd_info_req info;
if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) {
for (int n = 0; n < MPMIN(32, info.num_subs); n++) {
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_SUB);
if (!sh)
break;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_SUB);
sh->demuxer_id = n + 0x20;
sh->codec = "dvd_subtitle";
sh->codec->codec = "dvd_subtitle";
get_disc_lang(stream, sh);
// p->streams _must_ match with p->slave->streams, so we can't add
// it yet - it has to be done when the real stream appears, which
@@ -111,8 +111,10 @@ static void add_dvd_streams(demuxer_t *demuxer)
}
s = talloc_asprintf_append(s, "\n");
sh->extradata = s;
sh->extradata_size = strlen(s);
sh->codec->extradata = s;
sh->codec->extradata_size = strlen(s);
demux_add_sh_stream(demuxer, sh);
}
}
}
@@ -121,9 +123,9 @@ static void add_streams(demuxer_t *demuxer)
{
struct priv *p = demuxer->priv;
for (int n = p->num_streams; n < p->slave->num_streams; n++) {
struct sh_stream *src = p->slave->streams[n];
if (src->sub) {
for (int n = p->num_streams; n < demux_get_num_stream(p->slave); n++) {
struct sh_stream *src = demux_get_stream(p->slave, n);
if (src->type == STREAM_SUB) {
struct sh_stream *sub = NULL;
if (src->demuxer_id >= 0x20 && src->demuxer_id <= 0x3F)
sub = p->dvd_subs[src->demuxer_id - 0x20];
@@ -133,25 +135,26 @@ static void add_streams(demuxer_t *demuxer)
continue;
}
}
struct sh_stream *sh = new_sh_stream(demuxer, src->type);
if (!sh)
break;
struct sh_stream *sh = demux_alloc_sh_stream(src->type);
assert(p->num_streams == n); // directly mapped
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sh);
// Copy all stream fields that might be relevant
sh->codec = talloc_strdup(sh, src->codec);
sh->codec_tag = src->codec_tag;
sh->lav_headers = src->lav_headers;
*sh->codec = *src->codec;
sh->demuxer_id = src->demuxer_id;
if (src->video) {
if (src->type == STREAM_VIDEO) {
double ar;
if (stream_control(demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar)
== STREAM_OK)
sh->video->aspect = ar;
{
struct mp_image_params f = {.w = src->codec->disp_w,
.h = src->codec->disp_h};
mp_image_params_set_dsize(&f, 1728 * ar, 1728);
sh->codec->par_w = f.p_w;
sh->codec->par_h = f.p_h;
}
}
if (src->audio)
sh->audio = src->audio;
get_disc_lang(demuxer->stream, sh);
demux_add_sh_stream(demuxer, sh);
}
reselect_streams(demuxer);
}
+1 -1
View File
@@ -23,7 +23,7 @@
#include <inttypes.h>
#include <math.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "demux.h"
#include "timeline.h"
+107 -82
View File
@@ -40,6 +40,7 @@
#include "common/tags.h"
#include "common/av_common.h"
#include "misc/bstr.h"
#include "misc/charset_conv.h"
#include "stream/stream.h"
#include "demux.h"
@@ -108,6 +109,7 @@ struct format_hack {
bool no_stream : 1; // do not wrap struct stream as AVIOContext
bool use_stream_ids : 1; // export the native stream IDs
bool fully_read : 1; // set demuxer.fully_read flag
bool detect_charset : 1; // format is a small text file, possibly not UTF8
bool image_format : 1; // expected to contain exactly 1 frame
// Do not confuse player's position estimation (position is into external
// segment, with e.g. HLS, player knows about the playlist main file only).
@@ -115,8 +117,8 @@ struct format_hack {
};
#define BLACKLIST(fmt) {fmt, .ignore = true}
#define TEXTSUB(fmt) {fmt, .fully_read = true}
#define IMAGEFMT(fmt) {fmt, .image_format = true}
#define TEXTSUB(fmt) {fmt, .fully_read = true, .detect_charset = true}
#define TEXTSUB_UTF8(fmt) {fmt, .fully_read = true}
static const struct format_hack format_hacks[] = {
// for webradios
@@ -135,10 +137,12 @@ static const struct format_hack format_hacks[] = {
{"h264", .if_flags = AVFMT_NOTIMESTAMPS },
{"hevc", .if_flags = AVFMT_NOTIMESTAMPS },
TEXTSUB("aqtitle"), TEXTSUB("ass"), TEXTSUB("jacosub"), TEXTSUB("microdvd"),
TEXTSUB("aqtitle"), TEXTSUB("jacosub"), TEXTSUB("microdvd"),
TEXTSUB("mpl2"), TEXTSUB("mpsub"), TEXTSUB("pjs"), TEXTSUB("realtext"),
TEXTSUB("sami"), TEXTSUB("srt"), TEXTSUB("stl"), TEXTSUB("subviewer"),
TEXTSUB("subviewer1"), TEXTSUB("vplayer"), TEXTSUB("webvtt"),
TEXTSUB("subviewer1"), TEXTSUB("vplayer"), TEXTSUB("ass"),
TEXTSUB_UTF8("webvtt"),
// Useless non-sense, sometimes breaks MLP2 subreader.c fallback
BLACKLIST("tty"),
@@ -148,11 +152,12 @@ static const struct format_hack format_hacks[] = {
// Useless, does not work with custom streams.
BLACKLIST("image2"),
// Image demuxers ("<name>_pipe" is detected explicitly)
IMAGEFMT("image2pipe"),
{"image2pipe", .image_format = true},
{0}
};
typedef struct lavf_priv {
struct stream *stream;
char *filename;
struct format_hack format_hack;
AVInputFormat *avif;
@@ -187,7 +192,8 @@ static bool matches_avinputformat_name(struct lavf_priv *priv,
static int mp_read(void *opaque, uint8_t *buf, int size)
{
struct demuxer *demuxer = opaque;
struct stream *stream = demuxer->stream;
lavf_priv_t *priv = demuxer->priv;
struct stream *stream = priv->stream;
int ret;
ret = stream_read(stream, buf, size);
@@ -200,9 +206,13 @@ static int mp_read(void *opaque, uint8_t *buf, int size)
static int64_t mp_seek(void *opaque, int64_t pos, int whence)
{
struct demuxer *demuxer = opaque;
struct stream *stream = demuxer->stream;
lavf_priv_t *priv = demuxer->priv;
struct stream *stream = priv->stream;
int64_t current_pos;
MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %d)\n", stream, pos, whence);
MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %s)\n", stream, pos,
whence == SEEK_END ? "end" :
whence == SEEK_CUR ? "cur" :
whence == SEEK_SET ? "set" : "size");
if (whence == SEEK_END || whence == AVSEEK_SIZE) {
int64_t end = stream_get_size(stream);
if (end < 0)
@@ -230,7 +240,8 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags)
{
struct demuxer *demuxer = opaque;
struct stream *stream = demuxer->stream;
lavf_priv_t *priv = demuxer->priv;
struct stream *stream = priv->stream;
struct stream_avseek cmd = {
.stream_index = stream_idx,
@@ -253,6 +264,32 @@ static void list_formats(struct demuxer *demuxer)
MP_INFO(demuxer, "%15s : %s\n", fmt->name, fmt->long_name);
}
static void convert_charset(struct demuxer *demuxer)
{
lavf_priv_t *priv = demuxer->priv;
char *cp = demuxer->opts->sub_cp;
if (!cp || mp_charset_is_utf8(cp))
return;
bstr data = stream_read_complete(priv->stream, NULL, 128 * 1024 * 1024);
if (!data.start) {
MP_WARN(demuxer, "File too big (or error reading) - skip charset probing.\n");
return;
}
void *alloc = data.start;
cp = (char *)mp_charset_guess(priv, demuxer->log, data, cp, 0);
if (cp && !mp_charset_is_utf8(cp))
MP_INFO(demuxer, "Using subtitle charset: %s\n", cp);
// libavformat transparently converts UTF-16 to UTF-8
if (!mp_charset_is_utf16(cp) && !mp_charset_is_utf8(cp)) {
bstr conv = mp_iconv_to_utf8(demuxer->log, data, cp, MP_ICONV_VERBOSE);
if (conv.start)
data = conv;
}
if (data.start)
priv->stream = open_memory_stream(data.start, data.len);
talloc_free(alloc);
}
static char *remove_prefix(char *s, const char *const *prefixes)
{
for (int n = 0; prefixes[n]; n++) {
@@ -270,12 +307,8 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
{
struct MPOpts *opts = demuxer->opts;
struct demux_lavf_opts *lavfdopts = opts->demux_lavf;
struct stream *s = demuxer->stream;
lavf_priv_t *priv;
assert(!demuxer->priv);
demuxer->priv = talloc_zero(NULL, lavf_priv_t);
priv = demuxer->priv;
lavf_priv_t *priv = demuxer->priv;
struct stream *s = priv->stream;
priv->filename = remove_prefix(s->url, prefixes);
@@ -292,7 +325,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
priv->filename = sep + 1;
}
char *mime_type = demuxer->stream->mime_type;
char *mime_type = s->mime_type;
if (!lavfdopts->allow_mimetype || !mime_type)
mime_type = "";
@@ -393,6 +426,9 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
demuxer->filetype = priv->avif->name;
if (priv->format_hack.detect_charset)
convert_charset(demuxer);
return 0;
}
@@ -464,7 +500,8 @@ static void select_tracks(struct demuxer *demuxer, int start)
}
}
static void export_replaygain(demuxer_t *demuxer, sh_audio_t *sh, AVStream *st)
static void export_replaygain(demuxer_t *demuxer, struct mp_codec_params *c,
AVStream *st)
{
for (int i = 0; i < st->nb_side_data; i++) {
AVReplayGain *av_rgain;
@@ -489,7 +526,7 @@ static void export_replaygain(demuxer_t *demuxer, sh_audio_t *sh, AVStream *st)
rgain->album_peak = (av_rgain->album_peak != 0.0) ?
av_rgain->album_peak / 100000.0f : 1.0;
sh->replaygain_data = rgain;
c->replaygain_data = rgain;
}
}
@@ -506,7 +543,7 @@ static int dict_get_decimal(AVDictionary *dict, const char *entry, int def)
return def;
}
static void handle_stream(demuxer_t *demuxer, int i)
static void handle_new_stream(demuxer_t *demuxer, int i)
{
lavf_priv_t *priv = demuxer->priv;
AVFormatContext *avfc = priv->avfc;
@@ -516,27 +553,21 @@ static void handle_stream(demuxer_t *demuxer, int i)
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO: {
sh = new_sh_stream(demuxer, STREAM_AUDIO);
if (!sh)
break;
sh_audio_t *sh_audio = sh->audio;
sh = demux_alloc_sh_stream(STREAM_AUDIO);
// probably unneeded
mp_chmap_set_unknown(&sh_audio->channels, codec->channels);
mp_chmap_set_unknown(&sh->codec->channels, codec->channels);
if (codec->channel_layout)
mp_chmap_from_lavc(&sh_audio->channels, codec->channel_layout);
sh_audio->samplerate = codec->sample_rate;
sh_audio->bitrate = codec->bit_rate;
mp_chmap_from_lavc(&sh->codec->channels, codec->channel_layout);
sh->codec->samplerate = codec->sample_rate;
sh->codec->bitrate = codec->bit_rate;
export_replaygain(demuxer, sh_audio, st);
export_replaygain(demuxer, sh->codec, st);
break;
}
case AVMEDIA_TYPE_VIDEO: {
sh = new_sh_stream(demuxer, STREAM_VIDEO);
if (!sh)
break;
sh_video_t *sh_video = sh->video;
sh = demux_alloc_sh_stream(STREAM_VIDEO);
if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
sh->attached_picture = new_demux_packet_from(st->attached_pic.data,
@@ -548,8 +579,8 @@ static void handle_stream(demuxer_t *demuxer, int i)
}
}
sh_video->disp_w = codec->width;
sh_video->disp_h = codec->height;
sh->codec->disp_w = codec->width;
sh->codec->disp_h = codec->height;
/* Try to make up some frame rate value, even if it's not reliable.
* FPS information is needed to support subtitle formats which base
* timing on frame numbers.
@@ -564,39 +595,31 @@ static void handle_stream(demuxer_t *demuxer, int i)
fps = 1.0 / FFMAX(av_q2d(st->time_base),
av_q2d(st->codec->time_base) *
st->codec->ticks_per_frame);
sh_video->fps = fps;
sh->codec->fps = fps;
if (priv->format_hack.image_format)
sh_video->fps = demuxer->opts->mf_fps;
if (st->sample_aspect_ratio.num)
sh_video->aspect = codec->width * st->sample_aspect_ratio.num
/ (float)(codec->height * st->sample_aspect_ratio.den);
else
sh_video->aspect = codec->width * codec->sample_aspect_ratio.num
/ (float)(codec->height * codec->sample_aspect_ratio.den);
sh->codec->fps = demuxer->opts->mf_fps;
sh->codec->par_w = st->sample_aspect_ratio.num;
sh->codec->par_h = st->sample_aspect_ratio.den;
uint8_t *sd = av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
if (sd) {
double r = av_display_rotation_get((uint32_t *)sd);
if (!isnan(r))
sh_video->rotate = (((int)(-r) % 360) + 360) % 360;
sh->codec->rotate = (((int)(-r) % 360) + 360) % 360;
}
// This also applies to vfw-muxed mkv, but we can't detect these easily.
sh_video->avi_dts = matches_avinputformat_name(priv, "avi");
sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");
break;
}
case AVMEDIA_TYPE_SUBTITLE: {
sh_sub_t *sh_sub;
sh = new_sh_stream(demuxer, STREAM_SUB);
if (!sh)
break;
sh_sub = sh->sub;
sh = demux_alloc_sh_stream(STREAM_SUB);
if (codec->extradata_size) {
sh->extradata = talloc_size(sh, codec->extradata_size);
memcpy(sh->extradata, codec->extradata, codec->extradata_size);
sh->extradata_size = codec->extradata_size;
sh->codec->extradata = talloc_size(sh, codec->extradata_size);
memcpy(sh->codec->extradata, codec->extradata, codec->extradata_size);
sh->codec->extradata_size = codec->extradata_size;
}
if (matches_avinputformat_name(priv, "microdvd")) {
@@ -604,18 +627,14 @@ static void handle_stream(demuxer_t *demuxer, int i)
if (av_opt_get_q(avfc, "subfps", AV_OPT_SEARCH_CHILDREN, &r) >= 0) {
// File headers don't have a FPS set.
if (r.num < 1 || r.den < 1)
sh_sub->frame_based = av_q2d(av_inv_q(codec->time_base));
sh->codec->frame_based = av_q2d(av_inv_q(codec->time_base));
} else {
// Older libavformat versions. If the FPS matches the microdvd
// reader's default, assume it uses frame based timing.
if (codec->time_base.num == 125 && codec->time_base.den == 2997)
sh_sub->frame_based = 23.976;
sh->codec->frame_based = 23.976;
}
}
if (matches_avinputformat_name(priv, "ass"))
sh_sub->is_utf8 = true;
break;
}
case AVMEDIA_TYPE_ATTACHMENT: {
@@ -637,12 +656,11 @@ static void handle_stream(demuxer_t *demuxer, int i)
if (sh) {
sh->ff_index = st->index;
sh->codec = mp_codec_from_av_codec_id(codec->codec_id);
sh->codec_tag = codec->codec_tag;
sh->lav_headers = avcodec_alloc_context3(NULL);
if (!sh->lav_headers)
return;
mp_copy_lav_codec_headers(sh->lav_headers, codec);
sh->codec->codec = mp_codec_from_av_codec_id(codec->codec_id);
sh->codec->codec_tag = codec->codec_tag;
sh->codec->lav_headers = avcodec_alloc_context3(NULL);
if (sh->codec->lav_headers)
mp_copy_lav_codec_headers(sh->codec->lav_headers, codec);
if (st->disposition & AV_DISPOSITION_DEFAULT)
sh->default_track = true;
@@ -660,10 +678,10 @@ static void handle_stream(demuxer_t *demuxer, int i)
if (!sh->title && sh->hls_bitrate > 0)
sh->title = talloc_asprintf(sh, "bitrate %d", sh->hls_bitrate);
sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS);
demux_add_sh_stream(demuxer, sh);
}
select_tracks(demuxer, i);
demux_changed(demuxer, DEMUX_EVENT_STREAMS);
}
// Add any new streams that might have been added
@@ -671,7 +689,7 @@ static void add_new_streams(demuxer_t *demuxer)
{
lavf_priv_t *priv = demuxer->priv;
while (priv->num_streams < priv->avfc->nb_streams)
handle_stream(demuxer, priv->num_streams);
handle_new_stream(demuxer, priv->num_streams);
}
static void update_metadata(demuxer_t *demuxer, AVPacket *pkt)
@@ -697,7 +715,8 @@ static void update_metadata(demuxer_t *demuxer, AVPacket *pkt)
static int interrupt_cb(void *ctx)
{
struct demuxer *demuxer = ctx;
return mp_cancel_test(demuxer->stream->cancel);
lavf_priv_t *priv = demuxer->priv;
return mp_cancel_test(priv->stream->cancel);
}
static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
@@ -707,15 +726,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
AVFormatContext *avfc;
AVDictionaryEntry *t = NULL;
float analyze_duration = 0;
int i;
lavf_priv_t *priv = talloc_zero(NULL, lavf_priv_t);
demuxer->priv = priv;
priv->stream = demuxer->stream;
if (lavf_check_file(demuxer, check) < 0)
return -1;
lavf_priv_t *priv = demuxer->priv;
if (!priv)
return -1;
avfc = avformat_alloc_context();
if (!avfc)
return -1;
@@ -754,7 +771,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
AVDictionary *dopts = NULL;
if ((priv->avif_flags & AVFMT_NOFILE) ||
demuxer->stream->type == STREAMTYPE_AVDEVICE ||
priv->stream->type == STREAMTYPE_AVDEVICE ||
priv->format_hack.no_stream)
{
mp_setup_av_network_options(&dopts, demuxer->global, demuxer->log, opts);
@@ -773,7 +790,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
priv->pb->read_seek = mp_read_seek;
priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0;
avfc->pb = priv->pb;
if (stream_control(demuxer->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
if (stream_control(priv->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
demuxer->seekable = true;
}
@@ -813,9 +830,9 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
}
MP_VERBOSE(demuxer, "avformat_find_stream_info() finished after %"PRId64
" bytes.\n", stream_tell(demuxer->stream));
" bytes.\n", stream_tell(priv->stream));
for (i = 0; i < avfc->nb_chapters; i++) {
for (int i = 0; i < avfc->nb_chapters; i++) {
AVChapter *c = avfc->chapters[i];
t = av_dict_get(c->metadata, "title", NULL, 0);
int index = demuxer_add_chapter(demuxer, t ? t->value : "",
@@ -827,7 +844,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
// Often useful with OGG audio-only files, which have metadata in the audio
// track metadata instead of the main metadata.
if (demuxer->num_streams == 1) {
if (demux_get_num_stream(demuxer) == 1) {
priv->merge_track_metadata = true;
for (int n = 0; n < priv->num_streams; n++) {
if (priv->streams[n])
@@ -925,7 +942,7 @@ static void demux_seek_lavf(demuxer_t *demuxer, double rel_seek_secs, int flags)
avsflags = AVSEEK_FLAG_BACKWARD;
if (flags & SEEK_FACTOR) {
struct stream *s = demuxer->stream;
struct stream *s = priv->stream;
int64_t end = stream_get_size(s);
if (end > 0 && demuxer->ts_resets_possible &&
!(priv->avif_flags & AVFMT_NO_BYTE_SEEK))
@@ -1045,6 +1062,12 @@ redo:
goto redo;
}
priv->cur_program = prog->progid = program->id;
mp_tags_copy_from_av_dictionary(demuxer->metadata, priv->avfc->programs[p]->metadata);
update_metadata(demuxer, NULL);
// Enforce metadata update even if no explicit METADATA_UPDATED since we switched program.
demux_changed(demuxer, DEMUX_EVENT_METADATA);
return DEMUXER_CTRL_OK;
}
case DEMUXER_CTRL_RESYNC:
@@ -1061,10 +1084,10 @@ redo:
*/
// avio_flush() is designed for write-only streams, and does the wrong
// thing when reading. Flush it manually instead.
stream_drop_buffers(demuxer->stream);
stream_drop_buffers(priv->stream);
priv->avfc->pb->buf_ptr = priv->avfc->pb->buf_end = priv->avfc->pb->buffer;
priv->avfc->pb->pos = stream_tell(demuxer->stream);
av_seek_frame(priv->avfc, 0, stream_tell(demuxer->stream),
priv->avfc->pb->pos = stream_tell(priv->stream);
av_seek_frame(priv->avfc, 0, stream_tell(priv->stream),
AVSEEK_FLAG_BYTE);
return DEMUXER_CTRL_OK;
default:
@@ -1085,8 +1108,10 @@ static void demux_close_lavf(demuxer_t *demuxer)
av_freep(&priv->pb);
for (int n = 0; n < priv->num_streams; n++) {
if (priv->streams[n])
avcodec_free_context(&priv->streams[n]->lav_headers);
avcodec_free_context(&priv->streams[n]->codec->lav_headers);
}
if (priv->stream != demuxer->stream)
free_stream(priv->stream);
talloc_free(priv);
demuxer->priv = NULL;
}
+15 -14
View File
@@ -24,7 +24,7 @@
#include "osdep/io.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/msg.h"
#include "options/options.h"
#include "options/path.h"
@@ -39,7 +39,7 @@
typedef struct mf {
struct mp_log *log;
struct sh_video *sh;
struct sh_stream *sh;
int curr_frame;
int nr_of_files;
char **names;
@@ -165,7 +165,7 @@ static void demux_seek_mf(demuxer_t *demuxer, double rel_seek_secs, int flags)
if (flags & SEEK_FACTOR)
newpos += rel_seek_secs * (mf->nr_of_files - 1);
else
newpos += rel_seek_secs * mf->sh->fps;
newpos += rel_seek_secs * mf->sh->codec->fps;
if (newpos < 0)
newpos = 0;
if (newpos >= mf->nr_of_files)
@@ -199,9 +199,9 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer)
demux_packet_t *dp = new_demux_packet(data.len);
if (dp) {
memcpy(dp->buffer, data.start, data.len);
dp->pts = mf->curr_frame / mf->sh->fps;
dp->pts = mf->curr_frame / mf->sh->codec->fps;
dp->keyframe = true;
demux_add_packet(demuxer->streams[0], dp);
demux_add_packet(mf->sh, dp);
}
}
talloc_free(data.start);
@@ -291,7 +291,6 @@ static const char *probe_format(mf_t *mf, char *type, enum demux_check check)
static int demux_open_mf(demuxer_t *demuxer, enum demux_check check)
{
sh_video_t *sh_video = NULL;
mf_t *mf;
if (strncmp(demuxer->stream->url, "mf://", 5) == 0 &&
@@ -316,15 +315,17 @@ static int demux_open_mf(demuxer_t *demuxer, enum demux_check check)
mf->curr_frame = 0;
// create a new video stream header
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_VIDEO);
sh_video = sh->video;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
struct mp_codec_params *c = sh->codec;
sh->codec = codec;
sh_video->disp_w = 0;
sh_video->disp_h = 0;
sh_video->fps = demuxer->opts->mf_fps;
c->codec = codec;
c->disp_w = 0;
c->disp_h = 0;
c->fps = demuxer->opts->mf_fps;
mf->sh = sh_video;
demux_add_sh_stream(demuxer, sh);
mf->sh = sh;
demuxer->priv = (void *)mf;
demuxer->seekable = true;
@@ -344,7 +345,7 @@ static int demux_control_mf(demuxer_t *demuxer, int cmd, void *arg)
switch (cmd) {
case DEMUXER_CTRL_GET_TIME_LENGTH:
*((double *)arg) = (double)mf->nr_of_files / mf->sh->fps;
*((double *)arg) = (double)mf->nr_of_files / mf->sh->codec->fps;
return DEMUXER_CTRL_OK;
default:
+84 -68
View File
@@ -41,13 +41,14 @@
#include <zlib.h>
#endif
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/av_common.h"
#include "options/options.h"
#include "options/m_option.h"
#include "misc/bstr.h"
#include "stream/stream.h"
#include "video/csputils.h"
#include "video/mp_image.h"
#include "demux.h"
#include "stheader.h"
#include "ebml.h"
@@ -201,15 +202,19 @@ typedef struct mkv_demuxer {
struct demux_mkv_opts {
int subtitle_preroll;
double subtitle_preroll_secs;
double subtitle_preroll_secs_index;
int probe_duration;
int probe_start_time;
};
const struct m_sub_options demux_mkv_conf = {
.opts = (const m_option_t[]) {
OPT_FLAG("subtitle-preroll", subtitle_preroll, 0),
OPT_CHOICE("subtitle-preroll", subtitle_preroll, 0,
({"no", 0}, {"yes", 1}, {"index", 2})),
OPT_DOUBLE("subtitle-preroll-secs", subtitle_preroll_secs,
M_OPT_MIN, .min = 0),
OPT_DOUBLE("subtitle-preroll-secs-index", subtitle_preroll_secs_index,
M_OPT_MIN, .min = 0),
OPT_CHOICE("probe-video-duration", probe_duration, 0,
({"no", 0}, {"yes", 1}, {"full", 2})),
OPT_FLAG("probe-start-time", probe_start_time, 0),
@@ -217,7 +222,9 @@ const struct m_sub_options demux_mkv_conf = {
},
.size = sizeof(struct demux_mkv_opts),
.defaults = &(const struct demux_mkv_opts){
.subtitle_preroll = 2,
.subtitle_preroll_secs = 1.0,
.subtitle_preroll_secs_index = 10.0,
.probe_start_time = 1,
},
};
@@ -1192,11 +1199,9 @@ static void add_coverart(struct demuxer *demuxer)
const char *codec = mp_map_mimetype_to_video_codec(att->type);
if (!codec)
continue;
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_VIDEO);
if (!sh)
break;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
sh->demuxer_id = -1 - sh->index; // don't clash with mkv IDs
sh->codec = codec;
sh->codec->codec = codec;
sh->attached_picture = new_demux_packet_from(att->data, att->data_size);
if (sh->attached_picture) {
sh->attached_picture->pts = 0;
@@ -1204,6 +1209,7 @@ static void add_coverart(struct demuxer *demuxer)
sh->attached_picture->keyframe = true;
}
sh->title = att->name;
demux_add_sh_stream(demuxer, sh);
}
}
@@ -1265,18 +1271,16 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
{
unsigned char *extradata = NULL;
unsigned int extradata_size = 0;
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_VIDEO);
if (!sh)
return 1;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
init_track(demuxer, track, sh);
sh_video_t *sh_v = sh->video;
struct mp_codec_params *sh_v = sh->codec;
sh_v->bits_per_coded_sample = 24;
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")) { /* AVI compatibility mode */
// The private_data contains a BITMAPINFOHEADER struct
if (track->private_data == NULL || track->private_size < 40)
return 1;
goto done;
unsigned char *h = track->private_data;
if (track->v_width == 0)
@@ -1284,11 +1288,11 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
if (track->v_height == 0)
track->v_height = AV_RL32(h + 8); // biHeight
sh_v->bits_per_coded_sample = AV_RL16(h + 14); // biBitCount
sh->codec_tag = AV_RL32(h + 16); // biCompression
sh_v->codec_tag = AV_RL32(h + 16); // biCompression
extradata = track->private_data + 40;
extradata_size = track->private_size - 40;
mp_set_codec_from_tag(sh);
mp_set_codec_from_tag(sh_v);
sh_v->avi_dts = true;
} else if (track->private_size >= RVPROPERTIES_SIZE
&& (!strcmp(track->codec_id, "V_REAL/RV10")
@@ -1304,10 +1308,10 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
cnt = track->private_size - RVPROPERTIES_SIZE;
uint32_t t2 = AV_RB32(src - 4);
switch (t2 == 0x10003000 || t2 == 0x10003001 ? '1' : track->codec_id[9]) {
case '1': sh->codec = "rv10"; break;
case '2': sh->codec = "rv20"; break;
case '3': sh->codec = "rv30"; break;
case '4': sh->codec = "rv40"; break;
case '1': sh_v->codec = "rv10"; break;
case '2': sh_v->codec = "rv20"; break;
case '3': sh_v->codec = "rv30"; break;
case '4': sh_v->codec = "rv40"; break;
}
// copy type1 and type2 info from rv properties
extradata_size = cnt + 8;
@@ -1316,8 +1320,8 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
track->parse_timebase = 1e3;
} else if (strcmp(track->codec_id, "V_UNCOMPRESSED") == 0) {
// raw video, "like AVI" - this is a FourCC
sh->codec_tag = track->colorspace;
sh->codec = "rawvideo";
sh_v->codec_tag = track->colorspace;
sh_v->codec = "rawvideo";
} else if (strcmp(track->codec_id, "V_QUICKTIME") == 0) {
uint32_t fourcc1 = 0, fourcc2 = 0;
if (track->private_size >= 8) {
@@ -1327,14 +1331,14 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
if (fourcc1 == MP_FOURCC('S', 'V', 'Q', '3') ||
fourcc2 == MP_FOURCC('S', 'V', 'Q', '3'))
{
sh->codec = "svq3";
sh_v->codec = "svq3";
extradata = track->private_data;
extradata_size = track->private_size;
}
} else {
for (int i = 0; mkv_video_tags[i][0]; i++) {
if (!strcmp(mkv_video_tags[i][0], track->codec_id)) {
sh->codec = mkv_video_tags[i][1];
sh_v->codec = mkv_video_tags[i][1];
break;
}
}
@@ -1344,22 +1348,22 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
}
}
const char *codec = sh->codec ? sh->codec : "";
const char *codec = sh_v->codec ? sh_v->codec : "";
if (!strcmp(codec, "vp9")) {
track->parse = true;
track->parse_timebase = 1e9;
} else if (!strcmp(codec, "mjpeg")) {
sh->codec_tag = MP_FOURCC('m', 'j', 'p', 'g');
sh_v->codec_tag = MP_FOURCC('m', 'j', 'p', 'g');
}
if (extradata_size > 0x1000000) {
MP_WARN(demuxer, "Invalid CodecPrivate\n");
return 1;
goto done;
}
sh->extradata = talloc_memdup(sh_v, extradata, extradata_size);
sh->extradata_size = extradata_size;
if (!sh->codec) {
sh_v->extradata = talloc_memdup(sh_v, extradata, extradata_size);
sh_v->extradata_size = extradata_size;
if (!sh_v->codec) {
MP_WARN(demuxer, "Unknown/unsupported CodecID (%s) or missing/bad "
"CodecPrivate data (track %u).\n",
track->codec_id, track->tnum);
@@ -1367,12 +1371,19 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->fps = track->v_frate;
sh_v->disp_w = track->v_width;
sh_v->disp_h = track->v_height;
uint32_t dw = track->v_dwidth_set ? track->v_dwidth : track->v_width;
uint32_t dh = track->v_dheight_set ? track->v_dheight : track->v_height;
sh_v->aspect = (dw && dh) ? (double) dw / dh : 0;
MP_VERBOSE(demuxer, "Aspect: %f\n", sh_v->aspect);
int dw = track->v_dwidth_set ? track->v_dwidth : track->v_width;
int dh = track->v_dheight_set ? track->v_dheight : track->v_height;
struct mp_image_params p = {.w = track->v_width, .h = track->v_height};
mp_image_params_set_dsize(&p, dw, dh);
sh_v->par_w = p.p_w;
sh_v->par_h = p.p_h;
sh_v->stereo_mode = track->stereo_mode;
done:
demux_add_sh_stream(demuxer, sh);
return 0;
}
@@ -1464,11 +1475,9 @@ static const char *const mkv_audio_tags[][2] = {
static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
{
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_AUDIO);
if (!sh)
return 1;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO);
init_track(demuxer, track, sh);
sh_audio_t *sh_a = sh->audio;
struct mp_codec_params *sh_a = sh->codec;
if (track->private_size > 0x1000000)
goto error;
@@ -1483,7 +1492,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
for (int i = 0; mkv_audio_tags[i][0]; i++) {
if (!strcmp(mkv_audio_tags[i][0], track->codec_id)) {
sh->codec = mkv_audio_tags[i][1];
sh_a->codec = mkv_audio_tags[i][1];
break;
}
}
@@ -1494,7 +1503,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
goto error;
MP_VERBOSE(demuxer, "track with MS compat audio.\n");
unsigned char *h = track->private_data;
sh->codec_tag = AV_RL16(h + 0); // wFormatTag
sh_a->codec_tag = AV_RL16(h + 0); // wFormatTag
if (track->a_channels == 0)
track->a_channels = AV_RL16(h + 2); // nChannels
if (sh_a->samplerate == 0)
@@ -1506,15 +1515,15 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
extradata = track->private_data + 18;
extradata_len = track->private_size - 18;
sh_a->bits_per_coded_sample = track->a_bps;
mp_set_codec_from_tag(sh);
mp_set_codec_from_tag(sh_a);
} else if (!strcmp(track->codec_id, "A_PCM/INT/LIT")) {
bool sign = sh_a->bits_per_coded_sample > 8;
mp_set_pcm_codec(sh, sign, false, sh_a->bits_per_coded_sample, false);
mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, false);
} else if (!strcmp(track->codec_id, "A_PCM/INT/BIG")) {
bool sign = sh_a->bits_per_coded_sample > 8;
mp_set_pcm_codec(sh, sign, false, sh_a->bits_per_coded_sample, true);
mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, true);
} else if (!strcmp(track->codec_id, "A_PCM/FLOAT/IEEE")) {
sh->codec = sh_a->bits_per_coded_sample == 64 ? "pcm_f64le" : "pcm_f32le";
sh_a->codec = sh_a->bits_per_coded_sample == 64 ? "pcm_f64le" : "pcm_f32le";
} else if (!strncmp(track->codec_id, "A_REAL/", 7)) {
if (track->private_size < RAPROPERTIES4_SIZE)
goto error;
@@ -1554,29 +1563,29 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
extradata = src + offset;
if (!strcmp(track->codec_id, "A_REAL/ATRC")) {
sh->codec = "atrac3";
sh_a->codec = "atrac3";
if (flavor >= MP_ARRAY_SIZE(atrc_fl2bps))
goto error;
sh_a->bitrate = atrc_fl2bps[flavor] * 8;
sh_a->block_align = track->sub_packet_size;
} else if (!strcmp(track->codec_id, "A_REAL/COOK")) {
sh->codec = "cook";
sh_a->codec = "cook";
if (flavor >= MP_ARRAY_SIZE(cook_fl2bps))
goto error;
sh_a->bitrate = cook_fl2bps[flavor] * 8;
sh_a->block_align = track->sub_packet_size;
} else if (!strcmp(track->codec_id, "A_REAL/SIPR")) {
sh->codec = "sipr";
sh_a->codec = "sipr";
if (flavor >= MP_ARRAY_SIZE(sipr_fl2bps))
goto error;
sh_a->bitrate = sipr_fl2bps[flavor] * 8;
sh_a->block_align = track->coded_framesize;
} else if (!strcmp(track->codec_id, "A_REAL/28_8")) {
sh->codec = "ra_288";
sh_a->codec = "ra_288";
sh_a->bitrate = 3600 * 8;
sh_a->block_align = track->coded_framesize;
} else if (!strcmp(track->codec_id, "A_REAL/DNET")) {
sh->codec = "ac3";
sh_a->codec = "ac3";
} else {
goto error;
}
@@ -1586,7 +1595,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
track->audio_timestamp =
talloc_array(track, double, track->sub_packet_h);
} else if (!strncmp(track->codec_id, "A_AAC/", 6)) {
sh->codec = "aac";
sh_a->codec = "aac";
/* Recreate the 'private data' (not needed for plain A_AAC) */
int srate_idx = aac_get_sample_rate_index(track->a_sfreq);
@@ -1618,17 +1627,17 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
track->default_duration = 1024.0 / sh_a->samplerate;
}
} else if (!strncmp(track->codec_id, "A_AC3/", 6)) {
sh->codec = "ac3";
sh_a->codec = "ac3";
} else if (!strncmp(track->codec_id, "A_EAC3/", 7)) {
sh->codec = "eac3";
sh_a->codec = "eac3";
}
if (!sh->codec)
if (!sh_a->codec)
goto error;
mp_chmap_set_unknown(&sh_a->channels, track->a_channels);
const char *codec = sh->codec;
const char *codec = sh_a->codec;
if (!strcmp(codec, "mp3") || !strcmp(codec, "truehd")) {
track->parse = true;
} else if (!strcmp(codec, "flac")) {
@@ -1672,8 +1681,10 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
if (sh_a->samplerate == 8000 && strcmp(codec, "ac3") == 0)
track->default_duration = 0;
sh->extradata = extradata;
sh->extradata_size = extradata_len;
sh_a->extradata = extradata;
sh_a->extradata_size = extradata_len;
demux_add_sh_stream(demuxer, sh);
return 0;
@@ -1681,6 +1692,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
MP_WARN(demuxer, "Unknown/unsupported audio "
"codec ID '%s' for track %u or missing/faulty\n"
"private codec data.\n", track->codec_id, track->tnum);
demux_add_sh_stream(demuxer, sh); // add it anyway
return 1;
}
@@ -1712,12 +1724,10 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
if (track->private_size > 0x10000000)
return 1;
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_SUB);
if (!sh)
return 1;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_SUB);
init_track(demuxer, track, sh);
sh->codec = subtitle_type;
sh->codec->codec = subtitle_type;
bstr in = (bstr){track->private_data, track->private_size};
bstr buffer = demux_mkv_decode(demuxer->log, track, in, 2);
if (buffer.start && buffer.start != track->private_data) {
@@ -1726,8 +1736,10 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
track->private_data = buffer.start;
track->private_size = buffer.len;
}
sh->extradata = track->private_data;
sh->extradata_size = track->private_size;
sh->codec->extradata = track->private_data;
sh->codec->extradata_size = track->private_size;
demux_add_sh_stream(demuxer, sh);
if (!subtitle_type)
MP_ERR(demuxer, "Subtitle type '%s' is not supported.\n", track->codec_id);
@@ -2015,7 +2027,7 @@ static bool handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
if (!track->audio_buf || !track->audio_timestamp || !track->stream)
return false;
const char *codec = track->stream->codec ? track->stream->codec : "";
const char *codec = track->stream->codec->codec ? track->stream->codec->codec : "";
if (!strcmp(codec, "ra_288")) {
for (int x = 0; x < sph / 2; x++) {
uint64_t dst_offset = x * 2 * w + spc * (uint64_t)cfs;
@@ -2075,7 +2087,7 @@ static bool handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
if (++(track->sub_packet_cnt) == sph) {
track->sub_packet_cnt = 0;
// apk_usize has same range as coded_framesize in worst case
uint32_t apk_usize = track->stream->audio->block_align;
uint32_t apk_usize = track->stream->codec->block_align;
if (apk_usize > audiobuf_size)
goto error;
// Release all the audio packets
@@ -2210,7 +2222,7 @@ static void mkv_parse_and_add_packet(demuxer_t *demuxer, mkv_track_t *track,
if (stream->type == STREAM_AUDIO && handle_realaudio(demuxer, track, dp))
return;
if (stream->codec && strcmp(stream->codec, "wavpack") == 0) {
if (strcmp(stream->codec->codec, "wavpack") == 0) {
int size = dp->len;
uint8_t *parsed;
if (libav_parse_wavpack(track, dp->buffer, &parsed, &size) >= 0) {
@@ -2224,7 +2236,7 @@ static void mkv_parse_and_add_packet(demuxer_t *demuxer, mkv_track_t *track,
}
}
if (stream->codec && strcmp(stream->codec, "prores") == 0) {
if (strcmp(stream->codec->codec, "prores") == 0) {
size_t newlen = dp->len + 8;
struct demux_packet *new = new_demux_packet(newlen);
if (new) {
@@ -2239,7 +2251,7 @@ static void mkv_parse_and_add_packet(demuxer_t *demuxer, mkv_track_t *track,
}
if (track->parse && !track->av_parser) {
int id = mp_codec_to_av_codec_id(track->stream->codec);
int id = mp_codec_to_av_codec_id(track->stream->codec->codec);
const AVCodec *codec = avcodec_find_decoder(id);
track->av_parser = av_parser_init(id);
if (codec)
@@ -2435,7 +2447,7 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
* packets resulting from parsing. */
if (i == 0 || track->default_duration)
dp->pts = mkv_d->last_pts + i * track->default_duration;
if (stream->video && stream->video->avi_dts)
if (stream->codec->avi_dts)
MPSWAP(double, dp->pts, dp->dts);
if (i == 0)
dp->duration = block_duration / 1e9;
@@ -2597,7 +2609,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block)
}
// For the sake of robustness, consider even unknown level 1
// elements the same as unknown/broken IDs.
if (!ebml_is_mkv_level1_id(id) ||
if ((!ebml_is_mkv_level1_id(id) && id != EBML_ID_VOID) ||
ebml_read_skip(demuxer->log, -1, s) != 0)
{
ebml_resync_cluster(demuxer->log, s);
@@ -2718,6 +2730,8 @@ static struct mkv_index *seek_with_cues(struct demuxer *demuxer, int seek_id,
// Find the cluster with the highest filepos, that has a timestamp
// still lower than min_tc.
double secs = opts->demux_mkv->subtitle_preroll_secs;
if (mkv_d->index_has_durations)
secs = MPMAX(secs, opts->demux_mkv->subtitle_preroll_secs_index);
uint64_t pre = MPMIN(INT64_MAX, secs * 1e9 / mkv_d->tc_scale);
uint64_t min_tc = pre < index->timecode ? index->timecode - pre : 0;
uint64_t prev_target = 0;
@@ -2780,8 +2794,10 @@ static void demux_mkv_seek(demuxer_t *demuxer, double rel_seek_secs, int flags)
int cueflags = (flags & SEEK_BACKWARD) ? FLAG_BACKWARD : 0;
mkv_d->subtitle_preroll = NUM_SUB_PREROLL_PACKETS;
if (((flags & SEEK_HR) || demuxer->opts->demux_mkv->subtitle_preroll) &&
st_active[STREAM_SUB] && st_active[STREAM_VIDEO])
int preroll_opt = demuxer->opts->demux_mkv->subtitle_preroll;
if (((flags & SEEK_HR) || preroll_opt == 1 ||
(preroll_opt == 2 && mkv_d->index_has_durations))
&& st_active[STREAM_SUB] && st_active[STREAM_VIDEO])
cueflags |= FLAG_SUBPREROLL;
// Adjust the target a little bit to catch cases where the target position
+8 -6
View File
@@ -29,7 +29,7 @@
#include "osdep/io.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/msg.h"
#include "common/global.h"
@@ -458,8 +458,9 @@ static void check_track_compatibility(struct timeline *tl)
if (p->source == mainsrc)
continue;
for (int i = 0; i < p->source->num_streams; i++) {
struct sh_stream *s = p->source->streams[i];
int num_source_streams = demux_get_num_stream(p->source);
for (int i = 0; i < num_source_streams; i++) {
struct sh_stream *s = demux_get_stream(p->source, i);
if (s->attached_picture)
continue;
@@ -473,8 +474,9 @@ static void check_track_compatibility(struct timeline *tl)
}
}
for (int i = 0; i < mainsrc->num_streams; i++) {
struct sh_stream *m = mainsrc->streams[i];
int num_main_streams = demux_get_num_stream(mainsrc);
for (int i = 0; i < num_main_streams; i++) {
struct sh_stream *m = demux_get_stream(mainsrc, i);
if (m->attached_picture)
continue;
@@ -483,7 +485,7 @@ static void check_track_compatibility(struct timeline *tl)
if (s) {
// There are actually many more things that in theory have to
// match (though mpv's implementation doesn't care).
if (s->codec && m->codec && strcmp(s->codec, m->codec) != 0)
if (strcmp(s->codec->codec, m->codec->codec) != 0)
MP_WARN(tl, "Timeline segments have mismatching codec.\n");
} else {
MP_WARN(tl, "Source %s lacks %s stream with TID=%d, which "
+25 -23
View File
@@ -117,6 +117,7 @@ const struct m_sub_options demux_rawvideo_conf = {
};
struct priv {
struct sh_stream *sh;
int frame_size;
int read_frames;
double frame_rate;
@@ -125,29 +126,30 @@ struct priv {
static int demux_rawaudio_open(demuxer_t *demuxer, enum demux_check check)
{
struct demux_rawaudio_opts *opts = demuxer->opts->demux_rawaudio;
struct sh_stream *sh;
sh_audio_t *sh_audio;
if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
return -1;
sh = new_sh_stream(demuxer, STREAM_AUDIO);
sh_audio = sh->audio;
sh_audio->channels = opts->channels;
sh_audio->force_channels = true;
sh_audio->samplerate = opts->samplerate;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO);
struct mp_codec_params *c = sh->codec;
c->channels = opts->channels;
c->force_channels = true;
c->samplerate = opts->samplerate;
int f = opts->aformat;
// See PCM(): sign float bits endian
mp_set_pcm_codec(sh, f & 1, f & 2, f >> 3, f & 4);
// See PCM(): sign float bits endian
mp_set_pcm_codec(sh->codec, f & 1, f & 2, f >> 3, f & 4);
int samplesize = ((f >> 3) + 7) / 8;
demux_add_sh_stream(demuxer, sh);
struct priv *p = talloc_ptrtype(demuxer, p);
demuxer->priv = p;
*p = (struct priv) {
.frame_size = samplesize * sh_audio->channels.num,
.frame_rate = sh_audio->samplerate,
.read_frames = sh_audio->samplerate / 8,
.sh = sh,
.frame_size = samplesize * c->channels.num,
.frame_rate = c->samplerate,
.read_frames = c->samplerate / 8,
};
return 0;
@@ -156,8 +158,6 @@ static int demux_rawaudio_open(demuxer_t *demuxer, enum demux_check check)
static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
{
struct demux_rawvideo_opts *opts = demuxer->opts->demux_rawvideo;
struct sh_stream *sh;
sh_video_t *sh_video;
if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
return -1;
@@ -219,19 +219,21 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
imgsize = width * height * bpp / 8;
}
sh = new_sh_stream(demuxer, STREAM_VIDEO);
sh_video = sh->video;
sh->codec = decoder;
sh->codec_tag = imgfmt;
sh_video->fps = opts->fps;
sh_video->disp_w = width;
sh_video->disp_h = height;
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
struct mp_codec_params *c = sh->codec;
c->codec = decoder;
c->codec_tag = imgfmt;
c->fps = opts->fps;
c->disp_w = width;
c->disp_h = height;
demux_add_sh_stream(demuxer, sh);
struct priv *p = talloc_ptrtype(demuxer, p);
demuxer->priv = p;
*p = (struct priv) {
.sh = sh,
.frame_size = imgsize,
.frame_rate = sh_video->fps,
.frame_rate = c->fps,
.read_frames = 1,
};
@@ -256,7 +258,7 @@ static int raw_fill_buffer(demuxer_t *demuxer)
int len = stream_read(demuxer->stream, dp->buffer, dp->len);
demux_packet_shorten(dp, len);
demux_add_packet(demuxer->streams[0], dp);
demux_add_packet(p->sh, dp);
return 1;
}
+23 -22
View File
@@ -20,8 +20,6 @@
static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
{
tvi_handle_t *tvh;
sh_video_t *sh_video;
sh_audio_t *sh_audio = NULL;
const tvi_functions_t *funcs;
if (check > DEMUX_CHECK_REQUEST || demuxer->stream->type != STREAMTYPE_TV)
@@ -50,31 +48,30 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
funcs = tvh->functions;
demuxer->priv=tvh;
struct sh_stream *sh_v = new_sh_stream(demuxer, STREAM_VIDEO);
sh_video = sh_v->video;
struct sh_stream *sh_v = demux_alloc_sh_stream(STREAM_VIDEO);
/* get IMAGE FORMAT */
int fourcc;
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &fourcc);
if (fourcc == MP_FOURCC_MJPEG) {
sh_v->codec = "mjpeg";
sh_v->codec->codec = "mjpeg";
} else {
sh_v->codec = "rawvideo";
sh_v->codec_tag = fourcc;
sh_v->codec->codec = "rawvideo";
sh_v->codec->codec_tag = fourcc;
}
/* set FPS and FRAMETIME */
if(!sh_video->fps)
if(!sh_v->codec->fps)
{
float tmp;
if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &tmp) != TVI_CONTROL_TRUE)
sh_video->fps = 25.0f; /* on PAL */
else sh_video->fps = tmp;
sh_v->codec->fps = 25.0f; /* on PAL */
else sh_v->codec->fps = tmp;
}
if (tvh->tv_param->fps != -1.0f)
sh_video->fps = tvh->tv_param->fps;
sh_v->codec->fps = tvh->tv_param->fps;
/* If playback only mode, go to immediate mode, fail silently */
if(tvh->tv_param->immediate == 1)
@@ -84,10 +81,12 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
}
/* set width */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_v->codec->disp_w);
/* set height */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_v->codec->disp_h);
demux_add_sh_stream(demuxer, sh_v);
demuxer->seekable = 0;
@@ -115,21 +114,22 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
goto no_audio;
}
struct sh_stream *sh_a = new_sh_stream(demuxer, STREAM_AUDIO);
sh_audio = sh_a->audio;
struct sh_stream *sh_a = demux_alloc_sh_stream(STREAM_AUDIO);
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
&sh_audio->samplerate);
int nchannels = sh_audio->channels.num;
&sh_a->codec->samplerate);
int nchannels = sh_a->codec->channels.num;
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
&nchannels);
mp_chmap_from_channels(&sh_audio->channels, nchannels);
mp_chmap_from_channels(&sh_a->codec->channels, nchannels);
// s16ne
mp_set_pcm_codec(sh_a, true, false, 16, BYTE_ORDER == BIG_ENDIAN);
mp_set_pcm_codec(sh_a->codec, true, false, 16, BYTE_ORDER == BIG_ENDIAN);
demux_add_sh_stream(demuxer, sh_a);
MP_VERBOSE(tvh, " TV audio: %d channels, %d bits, %d Hz\n",
nchannels, 16, sh_audio->samplerate);
nchannels, 16, sh_a->codec->samplerate);
}
no_audio:
@@ -168,8 +168,9 @@ static int demux_tv_fill_buffer(demuxer_t *demux)
unsigned int len=0;
struct sh_stream *want_audio = NULL, *want_video = NULL;
for (int n = 0; n < demux->num_streams; n++) {
struct sh_stream *sh = demux->streams[n];
int num_streams = demux_get_num_stream(demux);
for (int n = 0; n < num_streams; n++) {
struct sh_stream *sh = demux_get_stream(demux, n);
if (!demux_has_packet(sh) && demux_stream_is_selected(sh)) {
if (sh->type == STREAM_AUDIO)
want_audio = sh;
+1 -1
View File
@@ -30,7 +30,7 @@
#include <libavutil/intfloat.h>
#include <libavutil/common.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "ebml.h"
#include "stream/stream.h"
#include "common/msg.h"
+26 -29
View File
@@ -37,23 +37,8 @@ struct sh_stream {
int demuxer_id;
// FFmpeg stream index (AVFormatContext.streams[index]), or equivalent.
int ff_index;
// One of these is non-NULL, the others are NULL, depending on the stream
// type.
struct sh_audio *audio;
struct sh_video *video;
struct sh_sub *sub;
// E.g. "h264" (usually corresponds to AVCodecDescriptor.name)
const char *codec;
// Usually a FourCC, exact meaning depends on codec.
unsigned int codec_tag;
unsigned char *extradata; // codec specific per-stream header
int extradata_size;
// Codec specific header data (set by demux_lavf.c only)
struct AVCodecContext *lav_headers;
struct mp_codec_params *codec;
char *title;
char *lang; // language code
@@ -70,31 +55,43 @@ struct sh_stream {
struct demux_stream *ds;
};
typedef struct sh_audio {
struct mp_codec_params {
enum stream_type type;
// E.g. "h264" (usually corresponds to AVCodecDescriptor.name)
const char *codec;
// Usually a FourCC, exact meaning depends on codec.
unsigned int codec_tag;
unsigned char *extradata; // codec specific per-stream header
int extradata_size;
// Codec specific header data (set by demux_lavf.c only)
struct AVCodecContext *lav_headers;
// STREAM_AUDIO
int samplerate;
struct mp_chmap channels;
bool force_channels;
int bitrate; // compressed bits/sec
int block_align;
int bits_per_coded_sample;
struct replaygain_data *replaygain_data;
} sh_audio_t;
typedef struct sh_video {
// STREAM_VIDEO
bool avi_dts; // use DTS timing; first frame and DTS is 0
float fps; // frames per second (set only if constant fps)
float aspect; // aspect ratio stored in the file (for prescaling)
int bits_per_coded_sample;
int par_w, par_h; // pixel aspect ratio (0 if unknown/square)
int disp_w, disp_h; // display size
int rotate; // intended display rotation, in degrees, [0, 359]
int stereo_mode; // mp_stereo3d_mode (0 if none/unknown)
} sh_video_t;
typedef struct sh_sub {
double frame_based; // timestamps are frame-based (and this is the
// fallback framerate used for timestamps)
bool is_utf8; // if false, subtitle packet charset is unknown
struct dec_sub *dec_sub; // decoder context
} sh_sub_t;
// STREAM_VIDEO + STREAM_AUDIO
int bits_per_coded_sample;
// STREAM_SUB
double frame_based; // timestamps are frame-based (and this is the
// fallback framerate used for timestamps)
};
#endif /* MPLAYER_STHEADER_H */
+4 -4
View File
@@ -166,6 +166,10 @@
#h cycle tv-channel -1 # previous channel
#k cycle tv-channel +1 # next channel
# For dvb://
#H cycle dvb-channel-name -1 # previous channel
#K cycle dvb-channel-name +1 # next channel
#
# Legacy bindings (may or may not be removed in the future)
#
@@ -181,10 +185,6 @@
# ? add sub-scale -0.1 # decrease subtitle font size
# ? sub-step -1 # immediately display next subtitle
# ? sub-step +1 # previous
# ? cycle-values window-scale 0.5 2 1 # switch between 1/2, 2x, unresized window size
# ? cycle colormatrix
# ? add audio-delay 0.100 # this changes audio/video sync
# ? add audio-delay -0.100
# ? cycle angle # switch DVD/Bluray angle
# ? add balance -0.1 # adjust audio balance in favor of left
# ? add balance 0.1 # right
+10 -12
View File
@@ -27,7 +27,7 @@
##################
# Specify default video driver (see --vo=help for a list).
#vo=vdpau
#vo=opengl-hq
# Start in fullscreen mode by default.
#fs=yes
@@ -54,9 +54,8 @@
# Disable softvol usage, and always use the system mixer if available.
#softvol=no
# Scale audio tempo by playback speed without altering pitch. (By default does
# nothing if playback speed is not changed. May introduce artifacts.)
#af=scaletempo
# Do not filter audio to keep pitch when changing playback speed.
audio-pitch-correction=no
# Output 5.1 audio natively, and upmix/downmix audio with a different format.
#audio-channels=5.1
@@ -75,15 +74,11 @@
# cache settings
#
# Use 8MB input cache by default. The cache is enabled for network streams only.
#cache-default=8192
# Use 150MB input cache by default. The cache is enabled for network streams only.
#cache-default=153600
#
# Use 8MB input cache for everything, even local files.
#cache=8192
#
# If a seek is issued, and the target is 1024KB past the cached range, then
# keep reading until the seek target is hit, instead of doing a real seek.
#cache-seek-min=1024
# Use 150MB input cache for everything, even local files.
#cache=153600
#
# Disable the behavior that the player will pause if the cache goes below a
# certain fill size.
@@ -91,6 +86,9 @@
#
# Read ahead about 5 seconds of audio and video packets.
#demuxer-readahead-secs=5.0
#
# Raise readahead from demuxer-readahead-secs to this value if a cache is active.
#cache-secs=50.0
# Display English subtitles if available.
#slang=en
+1 -1
View File
@@ -27,5 +27,5 @@ TryExec=mpv
Exec=mpv --profile=pseudo-gui -- %U
Terminal=false
Categories=AudioVideo;Audio;Video;Player;TV;
MimeType=application/ogg;application/x-ogg;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/x-mpeg;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/ogg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg;video/x-mpeg2;video/mp4;video/msvideo;video/x-msvideo;video/ogg;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/x-fli;video/x-flv;video/x-theora;video/x-matroska;video/webm;audio/x-flac;audio/x-vorbis+ogg;video/x-ogm+ogg;audio/x-shorten;audio/x-ape;audio/x-wavpack;audio/x-tta;audio/AMR;audio/ac3;video/mp2t;audio/flac;
MimeType=application/ogg;application/x-ogg;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/x-mpeg;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/ogg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg;video/x-mpeg2;video/mp4;video/msvideo;video/x-msvideo;video/ogg;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/x-fli;video/x-flv;video/x-theora;video/x-matroska;video/webm;audio/x-flac;audio/x-vorbis+ogg;video/x-ogm+ogg;audio/x-shorten;audio/x-ape;audio/x-wavpack;audio/x-tta;audio/AMR;audio/ac3;video/mp2t;audio/flac;audio/mp4;
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb
+1
View File
@@ -417,6 +417,7 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
m_option_copy(ret->args[i].type, &ret->args[i].v, &cmd->args[i].v);
}
ret->original = bstrdup(ret, cmd->original);
ret->key_name = talloc_strdup(ret, ret->key_name);
if (cmd->id == MP_CMD_COMMAND_LIST) {
struct mp_cmd *prev = NULL;
+7 -12
View File
@@ -48,7 +48,7 @@
#include "options/m_config.h"
#include "options/m_option.h"
#include "options/path.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "options/options.h"
#include "misc/bstr.h"
#include "stream/stream.h"
@@ -446,7 +446,9 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section,
return handle_test(ictx, code);
struct cmd_bind *cmd = find_any_bind_for_key(ictx, force_section, code);
if (cmd == NULL) {
if (!cmd)
cmd = find_any_bind_for_key(ictx, force_section, MP_KEY_UNMAPPED);
if (!cmd) {
if (code == MP_KEY_CLOSE_WIN)
return mp_input_parse_cmd_strv(ictx->log, (const char*[]){"quit", 0});
int msgl = MSGL_WARN;
@@ -460,12 +462,9 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section,
mp_cmd_t *ret = mp_input_parse_cmd(ictx, bstr0(cmd->cmd), cmd->location);
if (ret) {
ret->input_section = cmd->owner->section;
if (mp_msg_test(ictx->log, MSGL_DEBUG)) {
char *keyname = mp_input_get_key_combo_name(&code, 1);
MP_DBG(ictx, "key '%s' -> '%s' in '%s'\n",
keyname, cmd->cmd, ret->input_section);
talloc_free(keyname);
}
ret->key_name = talloc_steal(ret, mp_input_get_key_combo_name(&code, 1));
MP_DBG(ictx, "key '%s' -> '%s' in '%s'\n",
ret->key_name, cmd->cmd, ret->input_section);
ret->is_mouse_button = code & MP_KEY_EMIT_ON_UP;
} else {
char *key_buf = mp_input_get_key_combo_name(&code, 1);
@@ -1265,11 +1264,7 @@ void mp_input_load(struct input_ctx *ictx)
#if defined(__MINGW32__)
if (ictx->global->opts->input_file && *ictx->global->opts->input_file)
#if HAVE_WAIO
mp_input_pipe_add(ictx, ictx->global->opts->input_file);
#else
MP_ERR(ictx, "Pipes not available.\n");
#endif
#endif
}
+1
View File
@@ -86,6 +86,7 @@ typedef struct mp_cmd {
double scale; // for scaling numeric arguments
const struct mp_cmd_def *def;
char *sender; // name of the client API user which sent this
char *key_name; // string representation of the key binding
} mp_cmd_t;
struct mp_input_src {
+2
View File
@@ -171,6 +171,8 @@ static const struct key_name key_names[] = {
{ MP_KEY_MOUSE_LEAVE, "MOUSE_LEAVE" },
{ MP_KEY_MOUSE_ENTER, "MOUSE_ENTER" },
{ MP_KEY_UNMAPPED, "UNMAPPED" },
{ 0, NULL }
};
+3
View File
@@ -200,6 +200,9 @@
#define MP_KEY_IS_MOUSE(code) \
(MP_KEY_IS_MOUSE_CLICK(code) || MP_KEY_IS_MOUSE_MOVE(code))
// No input source should generate this.
#define MP_KEY_UNMAPPED (MP_KEY_INTERN+4)
// Emit a command even on key-up (normally key-up is ignored). This means by
// default they binding will be triggered on key-up instead of key-down.
// This is a fixed part of the keycode, not a modifier than can change.
+65 -56
View File
@@ -1,98 +1,107 @@
#include <pthread.h>
#include <stdio.h>
/*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include <io.h>
#include <stdint.h>
#include <waio/waio.h>
#include "common/msg.h"
#include "osdep/atomics.h"
#include "osdep/io.h"
#include "input.h"
struct priv {
atomic_bool cancel_requested;
int fd;
bool close_fd;
HANDLE file;
HANDLE thread;
};
static void request_cancel(struct mp_input_src *src)
{
HANDLE terminate = src->priv;
struct priv *p = src->priv;
MP_VERBOSE(src, "Exiting...\n");
SetEvent(terminate);
atomic_store(&p->cancel_requested, true);
// The thread might not be peforming I/O at the exact moment when
// CancelIoEx is called, so call it in a loop until it succeeds or the
// thread exits
do {
if (CancelIoEx(p->file, NULL))
break;
} while (WaitForSingleObject(p->thread, 1) != WAIT_OBJECT_0);
}
static void uninit(struct mp_input_src *src)
{
HANDLE terminate = src->priv;
struct priv *p = src->priv;
CloseHandle(p->thread);
if (p->close_fd)
close(p->fd);
CloseHandle(terminate);
MP_VERBOSE(src, "Exited.\n");
}
static void read_pipe_thread(struct mp_input_src *src, void *param)
{
char *filename = talloc_strdup(src, param);
struct priv *p = talloc_zero(src, struct priv);
struct waio_cx_interface *waio = NULL;
int mode = O_RDONLY;
int fd = -1;
bool close_fd = true;
p->fd = -1;
p->close_fd = true;
if (strcmp(filename, "/dev/stdin") == 0) { // for symmetry with unix
fd = STDIN_FILENO;
close_fd = false;
p->fd = STDIN_FILENO;
p->close_fd = false;
}
if (fd < 0)
fd = open(filename, mode);
if (fd < 0) {
if (p->fd < 0)
p->fd = open(filename, O_RDONLY);
if (p->fd < 0) {
MP_ERR(src, "Can't open %s.\n", filename);
goto done;
return;
}
// If we're reading from stdin, unset it. All I/O on synchronous handles is
// serialized, so stupid DLLs that call GetFileType on stdin can hang the
// process if they do it while we're reading from it. At least, the
// VirtualBox OpenGL ICD is affected by this, but only on Windows XP.
// GetFileType works differently in later versions of Windows. See:
// https://support.microsoft.com/kb/2009703
// http://blogs.msdn.com/b/oldnewthing/archive/2011/12/02/10243553.aspx
if ((void*)_get_osfhandle(fd) == GetStdHandle(STD_INPUT_HANDLE))
SetStdHandle(STD_INPUT_HANDLE, NULL);
waio = waio_alloc((void *)_get_osfhandle(fd), 0, NULL, NULL);
if (!waio) {
MP_ERR(src, "Can't initialize win32 file reader.\n");
goto done;
p->file = (HANDLE)_get_osfhandle(p->fd);
if (!p->file || p->file == INVALID_HANDLE_VALUE) {
MP_ERR(src, "Can't open %s.\n", filename);
return;
}
HANDLE terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!terminate)
goto done;
atomic_store(&p->cancel_requested, false);
if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
GetCurrentProcess(), &p->thread, SYNCHRONIZE, FALSE, 0))
return;
src->priv = terminate;
src->priv = p;
src->cancel = request_cancel;
src->uninit = uninit;
mp_input_src_init_done(src);
char buffer[128];
struct waio_aiocb cb = {
.aio_buf = buffer,
.aio_nbytes = sizeof(buffer),
.hsignal = terminate,
};
while (1) {
if (waio_read(waio, &cb)) {
MP_ERR(src, "Read operation failed.\n");
char buffer[4096];
while (!atomic_load(&p->cancel_requested)) {
DWORD r;
if (!ReadFile(p->file, buffer, 4096, &r, NULL)) {
if (GetLastError() != ERROR_OPERATION_ABORTED)
MP_ERR(src, "Read operation failed.\n");
break;
}
if (waio_suspend(waio, (const struct waio_aiocb *[]){&cb}, 1, NULL))
break;
ssize_t r = waio_return(waio, &cb);
if (r <= 0)
break; // EOF or error
mp_input_src_feed_cmd_text(src, buffer, r);
}
done:
waio_free(waio);
if (close_fd)
close(fd);
}
void mp_input_pipe_add(struct input_ctx *ictx, const char *filename)
+1 -1
View File
@@ -602,7 +602,7 @@ typedef enum mpv_format {
* Example for writing:
*
* int flag = 1;
* mpv_set_property(ctx, "property", MPV_FORMAT_STRING, &flag);
* mpv_set_property(ctx, "property", MPV_FORMAT_FLAG, &flag);
*/
MPV_FORMAT_FLAG = 3,
/**
+1 -1
View File
@@ -24,7 +24,7 @@
#include <libavutil/common.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/common.h"
#include "misc/ctype.h"
+1 -1
View File
@@ -24,7 +24,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "osdep/compiler.h"
/* NOTE: 'len' is size_t, but most string-handling functions below assume
+9
View File
@@ -52,6 +52,13 @@ bool mp_charset_is_utf8(const char *user_cp)
strcasecmp(user_cp, "utf-8") == 0);
}
bool mp_charset_is_utf16(const char *user_cp)
{
bstr s = bstr0(user_cp);
return bstr_case_startswith(s, bstr0("utf16")) ||
bstr_case_startswith(s, bstr0("utf-16"));
}
// Split the string on ':' into components.
// out_arr is at least max entries long.
// Return number of out_arr entries filled.
@@ -179,6 +186,8 @@ static const char *mp_uchardet(void *talloc_ctx, struct mp_log *log, bstr buf)
iconv_close(icdsc);
}
}
if (!res && bstr_validate_utf8(buf) >= 0)
res = "utf-8";
uchardet_delete(det);
return res;
}
+1
View File
@@ -13,6 +13,7 @@ enum {
};
bool mp_charset_is_utf8(const char *user_cp);
bool mp_charset_is_utf16(const char *user_cp);
bool mp_charset_requires_guess(const char *user_cp);
const char *mp_charset_guess(void *talloc_ctx, struct mp_log *log, bstr buf,
const char *user_cp, int flags);
+1 -1
View File
@@ -20,7 +20,7 @@
#include <inttypes.h>
#include <libavutil/common.h>
#include <assert.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "osdep/atomics.h"
#include "ring.h"
View File
File renamed without changes.
+1 -1
View File
@@ -30,7 +30,7 @@
#include "libmpv/client.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "m_config.h"
#include "options/m_option.h"
+1 -1
View File
@@ -36,7 +36,7 @@
#include "libmpv/client.h"
#include "player/client.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/common.h"
#include "common/msg.h"
#include "common/msg_control.h"
+1 -1
View File
@@ -30,7 +30,7 @@
#include "libmpv/client.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "m_option.h"
#include "m_property.h"
#include "common/msg.h"
+4 -3
View File
@@ -271,7 +271,7 @@ const m_option_t mp_opts[] = {
// force video/audio rate:
OPT_DOUBLE("fps", force_fps, CONF_MIN, .min = 0),
OPT_INTRANGE("audio-samplerate", force_srate, 0, 1000, 8*48000),
OPT_INTRANGE("audio-samplerate", force_srate, 0, 1000, 16*48000),
OPT_CHMAP("audio-channels", audio_output_channels, CONF_MIN, .min = 0),
OPT_AUDIOFORMAT("audio-format", audio_output_format, 0),
OPT_DOUBLE("speed", playback_speed, M_OPT_RANGE | M_OPT_FIXED,
@@ -332,6 +332,7 @@ const m_option_t mp_opts[] = {
OPT_STRING_APPEND_LIST("sub-file", sub_name, M_OPT_FILE),
OPT_PATHLIST("sub-paths", sub_paths, 0),
OPT_PATHLIST("audio-file-paths", audiofile_paths, 0),
OPT_STRING("sub-codepage", sub_cp, 0),
OPT_FLOAT("sub-delay", sub_delay, 0),
OPT_FLOAT("sub-fps", sub_fps, 0),
@@ -437,7 +438,7 @@ const m_option_t mp_opts[] = {
OPT_FLOATRANGE("video-align-y", vo.align_y, 0, -1.0, 1.0),
OPT_FLAG("video-unscaled", vo.unscaled, 0),
OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0),
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 360,
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359,
({"no", -1})),
OPT_CHOICE_C("video-stereo-mode", video_stereo_mode, 0, mp_stereo3d_names),
@@ -824,7 +825,7 @@ const struct MPOpts mp_default_opts = {
.display_tags = (char **)(const char*[]){
"Artist", "Album", "Album_Artist", "Comment", "Composer", "Genre",
"Performer", "Title", "Track", "icy-title",
"Performer", "Title", "Track", "icy-title", "service_name",
NULL
},
};
+1
View File
@@ -237,6 +237,7 @@ typedef struct MPOpts {
int field_dominance;
char **sub_name;
char **sub_paths;
char **audiofile_paths;
int sub_auto;
int audiofile_auto;
int osd_bar_visible;
+16 -1
View File
@@ -39,7 +39,7 @@
#include "common/msg.h"
#include "options/options.h"
#include "options/path.h"
#include "talloc.h"
#include "mpv_talloc.h"
#include "osdep/io.h"
#include "osdep/path.h"
@@ -213,6 +213,21 @@ struct bstr mp_dirname(const char *path)
return ret;
}
#if HAVE_DOS_PATHS
static const char mp_path_separators[] = "\\/";
#else
static const char mp_path_separators[] = "/";
#endif
// Mutates path and removes a trailing '/' (or '\' on Windows)
void mp_path_strip_trailing_separator(char *path)
{
size_t len = strlen(path);
if (len > 0 && strchr(mp_path_separators, path[len - 1]))
path[len - 1] = '\0';
}
char *mp_splitext(const char *path, bstr *root)
{
assert(path);
+2
View File
@@ -65,6 +65,8 @@ char *mp_splitext(const char *path, bstr *root);
*/
struct bstr mp_dirname(const char *path);
void mp_path_strip_trailing_separator(char *path);
/* Join two path components and return a newly allocated string
* for the result. '/' is inserted between the components if needed.
* If p2 is an absolute path then the value of p1 is ignored.
+1 -1
View File
@@ -19,7 +19,7 @@
#include <stdbool.h>
#include <string.h>
#include "osdep/io.h"
#include "talloc.h"
#include "mpv_talloc.h"
static wchar_t *talloc_wcsdup(void *ctx, const wchar_t *wcs)
{
+1 -1
View File
@@ -23,7 +23,7 @@
#include <errno.h>
#include <assert.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "config.h"
#include "osdep/io.h"
+1 -1
View File
@@ -17,7 +17,7 @@
#include <stdio.h>
#include <pthread.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "common/msg.h"
#include "input/input.h"
+1 -1
View File
@@ -25,7 +25,7 @@
#import <IOKit/hidsystem/ev_keymap.h>
#import <Cocoa/Cocoa.h>
#include "talloc.h"
#include "mpv_talloc.h"
#include "input/event.h"
#include "input/input.h"
#include "input/keycodes.h"
+1 -4
View File
@@ -38,15 +38,12 @@ static void microsoft_nonsense(void)
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
WINBOOL (WINAPI *pSetDllDirectory)(LPCWSTR lpPathName) =
(WINBOOL (WINAPI *)(LPCWSTR))GetProcAddress(kernel32, "SetDllDirectoryW");
WINBOOL (WINAPI *pSetSearchPathMode)(DWORD Flags) =
(WINBOOL (WINAPI *)(DWORD))GetProcAddress(kernel32, "SetSearchPathMode");
// Always use safe search paths for DLLs and other files, ie. never use the
// current directory
if (pSetSearchPathMode)
pSetDllDirectory(L"");
SetDllDirectoryW(L"");
if (pSetSearchPathMode)
pSetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE);
}
+2
View File
@@ -24,6 +24,8 @@
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
+1 -1
View File
@@ -34,7 +34,7 @@ FILETYPE VFT_APP
VALUE "CompanyName", "mpv\000"
VALUE "FileDescription", "mpv\000"
VALUE "FileVersion",VERSION
VALUE "LegalCopyright", " (C) 2000-2015 mpv/mplayer2/MPlayer\000"
VALUE "LegalCopyright", " (C) 2000-2016 mpv/mplayer2/MPlayer\000"
//VALUE "LegalTrademarks"," \000";
VALUE "OriginalFilename", "mpv.exe\000"
VALUE "ProductName", "mpv\000"
Loaded 100 of 233 files, more files were not shown because too many files have changed in this diff. Show more