summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* command: add property to return text subtitles in ASSwm42020-05-142-8/+23
| | | | | | | | | See manpage additions. This was requested, sort of. Although what has been requested might be something completely different. So this is speculative. This also changes sub_get_text() to return an allocated copy, because the buffer shit was too damn messy.
* js: mp.set_osd_ass: ignore identical inputs (match ccbb8b1c)Avi Halachmi (:avih)2020-05-101-0/+5
|
* lua: do not use Lua filesystem functions for loading scriptswm42020-05-101-3/+6
| | | | | | | | | | | Bill Gates did not only create COVID, he's also responsible for the world's worst OS, where you have to literally jump through hoops of fire to open files with Unicode file names. Lua did not care to implement any jumping, so it's our turn to jump. Untested (on win32). Fixes: #7701
* player: make external subtitle auto-loading stricterwm42020-05-091-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | By default --sub-auto uses "exact". This was far from an "exact" match, because it added anything that started with the video filename (without extension), and seemed to end in something that looked like a language code. Make this stricter. "exact" still tolerate a language code, but the video's filename must come before it without any unknown extra characters. This may not load subtitles in some situations where it previously did, and where the user might think that the naming convention is such that it should be considered an exact match. The subtitle priority sorting seems a bit worthless. I suppose it may have some value in higher "fuzz" modes (like --sub-auto=fuzzy). Also remove the mysterious "prio += prio;" line. I probably shouldn't have checked, but it goes back to commit f16fa9d31 (2003), where someone wanted to "refine" the priority without changing the rest of the code or something. Mostly untested, so have fun. Fixes: #7702
* player: round position percentage to the nearest integerRicardo Garcia2020-05-011-1/+1
| | | | | | This brings the displayed percentage closer to the exact number and allows mpv to more frequently display 100% when it finishes playing a typical video or audio file.
* lua: restore change detection with legacy OSD functionwm42020-05-011-4/+9
| | | | | | | | | | mp.set_osd_ass() (which was undocumented, or in other words, was not supposed to be used by external scripts) used to do change detection in the mpv C code. If the resolution or payload did not change, it was not re-rendered on the lower levels. Apparently this made some people sad, so fix it. (But only after I told them to fuck off.) (Well I didn't put it this way, but still.)
* video: make OSD/subtitle bitmaps refcounted (sort of)wm42020-04-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Making OSD/subtitle bitmaps refcounted was planend a longer time ago, e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap data) was added in 2016. But nothing benefited much from it, because struct sub_bitmaps was usually stack allocated, and there was this weird callback stuff through osd_draw(). Make it possible to get actually refcounted subtitle bitmaps on the OSD API level. For this, we just copy all subtitle data other than the bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy refcount shit, but when that was a big mess and hard to debug and just boiled to emulating malloc(), I made it a full allocation+copy. This affects mostly the parts array. With crazy ASS subtitles, this parts array can get pretty big (thousands of elements or more), in which case the extra alloc/copy could become performance relevant. But then again this is just pure bullshit, and I see no need to care. In practice, this extra work most likely gets drowned out by libass murdering a single core (while mpv is waiting for it) anyway. So fuck it. I just wanted this so draw_bmp.c requires only a single call to render everything. VOs also can benefit from this, because the weird callback shit isn't necessary anymore (simpler code), but I haven't done anything about it yet. In general I'd hope this will work towards simplifying the OSD layer, which is prerequisite for making actual further improvements. I haven't tested some cases such as the "overlay-add" command. Maybe it crashes now? Who knows, who cares. In addition, it might be worthwhile to reduce the code duplication between all the things that output subtitle bitmaps (with repacking, image allocation, etc.), but that's orthogonal.
* stats.lua: don't disable terminal escape sequences on windowsAvi Halachmi (:avih)2020-04-231-22/+4
| | | | | | | | | | | | | | | | | | | | | When stats.lua is used without a video window then it uses the terminal. On Windows, however, so far it disabled ansi escape sequences and used plaintext unless ANSICON env is set. It's unclear why it's disabled on windows, because at the time it was added it only used bold by default and mpv ansi emulation on windows already supported bold at that time. We can guess that it was disabled because if the same config is used on both linux and Windows, and it had complex escape sequences for stats.lue, then it would be emulated incorrectly on Windows. This shouldn't be an issue anymore, as the last two commits both enhance the emulation to be quite complete (and graceful where it's not), and also enable the much-more complete native VT terminal when possible (Windows 10). Just remove this windows exception at stats.lua.
* stats: move chapter/edition info below titleLaserEyess2020-04-161-3/+3
| | | | | | | | It is more consistent for editions/chapters to go below either the title or filename. They are all descriptive strings about the media itself and not file metadata like filesize. Suggested by Argon-
* stats: add edition information to page 1LaserEyess2020-04-161-1/+13
| | | | | | Edition information is conditional based on there being more than one edition present. It is printed on the same line as Chapters to save vertical space.
* player: remove duplicated track option setter codewm42020-04-153-17/+11
| | | | Well whatever.
* player: slightly improve use of secondary track selection limitswm42020-04-155-20/+27
| | | | | | Apparently, this was a bit of a mess, which caused the bug fixed by commit ec7f2388af2df. Try to improve this, and only use track selection entries that exist.
* player: remove mysterious declarationwm42020-04-151-2/+0
| | | | ??????????
* player: don't segfault when unloading tracksNiklas Haas2020-04-151-0/+2
| | | | | | | | | e1e714ccc introduced a regression here when unloading a track (e.g. on VO/AO initilization error), due to no corresponding option existing for video/audio tracks with orders above 0, but the loop in `mp_deselect_track` being hard-coded to clear tracks up to NUM_PTRACKS. Introduce the simplest possible hackaround.
* player: do not fall back to a default track with explicit selectionswm42020-04-131-0/+2
| | | | | | | | | | | | | | | | | | Consider e.g. --aid=2 with a file that has only 1 track. Then it would fall back to selecting track 1. Stop doing this. If no matching track is found, this will not select any track now. Note that the fingerprint stuff (track_layout_hash in the source) prevents softens the impact of this change. Without the fingerprint, playing a dual-audio file with the second track selected, and then a single-audio file, would play the second file without audio. But the fingerprint resets it due to differences in the track list. Try to exhaustively document this and tricky interactions between the other features. What a damn mess, I think it's simply cursed. Of course it's still my fault. See: #7608
* player: mess with track selection details againwm42020-04-131-12/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some time ago, properties and options were mostly unified. However, the track selection properties/options semantics are incompatible to this change. I'm still trying to handle the fallout. There are two things that are in the way: 1. Track properties somehow return the runtime selection, not the option value (all while properties are supposed to be aliases to options with the same name). 2. The user's track options are not supposed to be changed without interaction. If a track is auto-selected, the property should return its ID, but the option value should remain at "auto". Only if the user actually writes to the property the option should change. E.g. playing e.g. an audio-only file and then a normal video file not play the video file with --vid=no just because the audio file had no video track. In addition to each of them being in conflict with the property/option unification, attempt to fix one of them breaks the other one. Today, we're trying to fix parts of this and avoiding an unfortunate case where you can get a conflicting option/property value, and where trying to select a track does nothing if the track to select has the same ID as the option value. This breaks 2. from above in certain situations. See manpage additions. See: #7608
* player, ta: remove use of an old macrowm42020-04-131-1/+1
| | | | | I thought that would make a nice idiom, but it ended up being useless or clunky.
* command: print edition title to OSD when cyclingLaserEyess2020-04-131-5/+26
| | | | | | Edition title is already exposed in demux_edition, it was just never added to the display. If no edition title exists it will fall back to the edition number.
* stats: support UP/DOWN to scroll at page 4 (perf)Avi Halachmi (:avih)2020-04-111-12/+68
| | | | | | | | | | | | | | Keys and lines-to-scroll are configurabe, and the scroll keys are only bound on pages which support scrolling (currently only page 4) - also during oneshot (like the page-switching keys). Scroll offset is reset for all pages on any key - except scroll keys, so that entering or switching to a page resets the scroll, as well as when "re-entering" the same page or "re-activating" the stats oneshot view. TODO: print_page(..) is highly associated with extending the oneshot timer if required. The timer handling can probably move into print_page and removed from all the places which boilerplate its management.
* console: reduce memory usage in default modewm42020-04-101-73/+82
| | | | | | | | | | | | | | | This used 1 MB due to building the complete command and property list when starting the script. These are needed only for auto-completion, so build them only on demand. Since building them is fast enough, rebuild them every time. The key bindings table is not that much, but saves some KBs. Oddly, the code to build it uses less memory than the table at runtime (???), so build it at runtime as well. Add 2 tactic collectgarbage() calls as well. This frees unused heap when it is known that the script is going to be completely inactive until re-enabled by the user.
* video: remove another redundant wakeupwm42020-04-101-1/+3
| | | | | | | | | | | | | | | The wakeup at the end of VO frame rendering seems redundant, because after rendering almost no state changes. The player core can queue a new frame once frame rendering begins, and there's a separate wakeup for this. The only thing that actually changes is in->rendering. The only thing that seems to depend on it and can trigger a wakeup is the vo_still_displaying() function. Change it so that it needs an explicit call to a new API function, so we can avoid wakeups in the common case. The vo_still_displaying() code is mostly just moved around due to locking and for avoiding forward declarations. Also a somewhat risky change (tasty new bugs).
* video: avoid redundant self-wakeup on each queued framewm42020-04-101-1/+2
| | | | | | | | | This should be unnecessary, since the VO itself performs wakeups once a new frame can be queued. The only situation I can think of where this might be required are EOF situations (which are always strange). If I'm wrong, there'll be fun new bugs, probably causing frame drops or temporary stalls.
* player, stats: more silly debug stuffwm42020-04-104-2/+7
| | | | | In addition to stats.c being gross, I don't think master branch code should be littered with debug code. But it's a helpful abomination.
* stats: fix crash if both plot_vsync_* options are disabledwm42020-04-091-3/+6
| | | | | | | | | | | In this case, init_buffers() was not called, and the unrelated cache sample buffers were not initialized. It appears they are indeed completely unrelated, so move their initialization away. Not sure what exactly the purpose of calling init_buffers() is, maybe clearing old data when displaying stats again. The new place for initializing the cache sample buffers should achieve the same anyway. Fixes: #7597
* player: do not deinitialize AO on track switchingwm42020-04-091-1/+2
| | | | | | | | This should make it behave roughly like when switching from a file to the next (clearing audio buffers, keeping AO, but closing AO if the audio format seems to have changed and gapless mode is "weak"). Not necessarily useful, but harmless and may help with #7579 (untested).
* lua: wrap existing allocator instead of reimplementing itNiklas Haas2020-04-091-16/+12
| | | | | | | | This is the proper fix for 1e7802. Turns out the solution is dead simple: we can still set the allocator with lua_getallocf / lua_setalloc. This commit makes memory accounting work on luajit as well.
* lua: disable memory accounting for luajitNiklas Haas2020-04-091-0/+7
| | | | | | | | This is a stopgap measure. In theory we could maybe poll the memory usage on luajit, but for now, simply reverting this part of fd3caa26 makes Lua work again. (And we can still collect cpu usage metrics) Proper solution pending (tm)
* ipc: add --input-ipc-client optionwm42020-04-091-1/+1
| | | | | | | | | While --input-file was removed for justified reasons, wanting to pass down socket FDs this way is legitimate, useful, and easy to implement. One odd thing is that Fixes: #7592
* stats: some more performance graphswm42020-04-095-7/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an infrastructure for collecting performance-related data, use it in some places. Add rendering of them to stats.lua. There were two main goals: minimal impact on the normal code and normal playback. So all these stats_* function calls either happen only during initialization, or return immediately if no stats collection is going on. That's why it does this lazily adding of stats entries etc. (a first iteration made each stats entry an API thing, instead of just a single stats_ctx, but I thought that was getting too intrusive in the "normal" code, even if everything gets worse inside of stats.c). You could get most of this information from various profilers (including the extremely primitive --dump-stats thing in mpv), but this makes it easier to see the most important information at once (at least in theory), partially because we know best about the context of various things. Not very happy with this. It's all pretty primitive and dumb. At this point I just wanted to get over with it, without necessarily having to revisit it later, but with having my stupid statistics. Somehow the code feels terrible. There are a lot of meh decisions in there that could be better or worse (but mostly could be better), and it just sucks but it's also trivial and uninteresting and does the job. I guess I hate programming. It's so tedious and the result is always shit. Anyway, enjoy.
* stats: fix previous commitwm42020-04-031-2/+2
| | | | | The previous commit included a rendering error of the "Speed:" line, caused by incorrect copy&paste.
* stats: move input speed to cache page, make it a graphwm42020-04-031-13/+12
| | | | | | | I think that makes more sense. And also remove the graph from the total cache usage, since that wasn't very interesting. So there's still a total of 2 graphs.
* command: make input speed available as part of cache statge propertywm42020-04-031-0/+2
| | | | | | That's where it comes from after all. The other property does not have much of a reason to exist anymore, but there's no real reason to remove it either.
* player: make a function staticwm42020-04-032-2/+1
|
* ytdl_hook: enable runtime changes of script optionssfan52020-03-291-1/+4
|
* input: remove deprecated --input-file optionwm42020-03-281-1/+1
| | | | | This was deprecated 2 releases ago. The deprecation changelog entry says that there are no plans to remove it short-term, but I guess I lied.
* client API: report IDs of inserted playlist entries on loading playlistwm42020-03-272-6/+15
| | | | | | May or may not help when dealing with playlist loading in scripts. It's supposed to help with the mean fact that loading a recursive playlist will essentially edit the playlist behind the API user's back.
* scripting: remove race condition when toggling internal scriptswm42020-03-265-31/+27
| | | | | | | | | | Scripts such as the OSC can be loaded and unloaded at runtime by toggling the option that enables them. (It even works, although normally it's only used to control initial loading.) Unloading was racy because it used the client name; fix this. The load-script change is an accidental feature. And probably useless.
* command: use client IDs for hookswm42020-03-264-12/+24
| | | | | Removes weird potential race conditions when a client is removed and a new one with the same name is created.
* client API: add a per client unique IDwm42020-03-261-0/+27
| | | | | | I mostly intend this for internal purposes. Probably pretty useless for external API users, but on the other hand trivial to expose. While it makes a lot of sense internally, I'll probably regret exposing it.
* command: make revert seek command use time from end of seekwm42020-03-261-0/+3
| | | | | | | | | This time is set on every seek (but when initiating it). A new seek longer than 2 seconds after this is counted as separate seek for the sake of the revert seek command. If a seek takes a bit longer, this removes time from these 2 seconds. This commits resets it on the end of the seek. (Doing anything special for seeks that take longer than 2 seconds is out of scope of this commit.)
* lua: mp.get_property[_osd] don't need special handling anymoreAvi Halachmi (:avih)2020-03-231-11/+2
| | | | Because they recently became normal autofree functions.
* lua: readdir: fix double closedir, use one more autofreeAvi Halachmi (:avih)2020-03-221-3/+1
| | | | | The double closedir is a regression from the previous commit, which also forgot to use the autofree context with the fullpath string.
* lua: autofree: use in few more places where it could leakAvi Halachmi (:avih)2020-03-221-14/+49
| | | | | | | This also uses talloc destructors- like the JS autofree does. The lua autofree is now used at the same places where the JS autofree is used.
* lua: autofree: the ctx is now an argumentAvi Halachmi (:avih)2020-03-221-40/+41
| | | | | | | | | | | There's no more need to call mp_lua_PITA to get the ctx, and the autofree prototype is now enforced at the C level at compile time. Also remove the redundant talloc_free_children at these functions since it's now freed right after the function completes. Also, rename auto_free_node to steal_node_allocations to be more explicit and to avoid confusion with the autofree terminology.
* lua: use an autofree wrapper instead of mp_lua_PITAAvi Halachmi (:avih)2020-03-221-38/+51
| | | | | | | | | | | | | | | | | | | Advantages of this approach: - All the resources are released right after the function ends regardless if it threw an error or not, without having to wait for GC. - Simpler code. - Simpler lua setup which most likely uses less memory allocation and as a result should be quicker, though it wasn't measured. This commit adds the autofree wrapper and uses it where mp_lua_PITA was used. It's not yet enforced at the C level, there are still redundant talloc_free_children leftovers, and there are few more places which could also use autofree. The next commits will address those.
* lua: restore recent end-file event, and deprecate itwm42020-03-222-2/+11
| | | | | | | | | | | | Lua changed behavior for this specific event. I considered the change minor enough that it would not need to go through deprecation, but someone hit it immediately and ask on the -dev channel. It's probably better to restore the behavior. But mark it as deprecated, since it's problematic (mismatch with the C API). Unfortunately, no automatic warning is possible. (Or maybe it is, by playing sophisticated Lua tricks such as setting a metatable and overriding indexing, but let's not.)
* js: make wait_event autofreeAvi Halachmi (:avih)2020-03-221-6/+5
| | | | | | | | | | | | The VM could throw at pushnode and before mpv_free_node_contents, which would have resulted in leaked content. Now this case is handled without leaks. Note: the lua code still leaks on such case, but mp_lua_PITA doesn't have destructors like the JS autofree has, which, specifically here, can do mpv_free_node_contents. So TODO: enhance the lua PITA code to behave more similar to the JS autofree.
* js: use unified events (match 218d6643, 8a58a699)Avi Halachmi (:avih)2020-03-211-98/+4
|
* lua: simplify furtherwm42020-03-211-8/+1
| | | | As suggested by avih. Obviously this was unnecessarily convoluted.
* client API, lua: unify event code furtherwm42020-03-212-52/+18
| | | | | | | | | Move some parts that can be generic to the client API code. It turns out lua.c doesn't need anything special. This adds the "id" field. I think this was actually missing from the JSON IPC code (i.e. it's a very recent regression that is fixed with this commit).
* command: fix accidental stack dumpingwm42020-03-211-1/+1
|
* client API, lua, ipc: unify event struct returnwm42020-03-212-50/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both Lua and the JSON IPC code need to convert the mpv_event struct (and everything it points to) to Lua tables or JSON. I was getting sick of having to make the same changes to Lua and IPC. Do what has been done everywhere else, and let the core handle this by going through mpv_node (which is supposed to serve both Lua tables and JSON, and potentially other scripting language backends). Expose it as new libmpv API function. The new API is still a bit "rough" and support for other event types might be added in the future. This silently adds support for the playlist_entry_id fields to both Lua and JSON IPC. There is a small API change for Lua; I don't think this matters, so I didn't care about compatibility. The new code in client.c is mashed up from the Lua and the IPC code. The manpage additions are moved from the Lua docs, and made slightly more "general". Some danger for unintended regressions both in Lua and IPC. Also damn these node functions suck, expect crashes due to UB. Not sure why this became more code instead of less compared to before (according to the diff stat), even though some code duplication across Lua and IPC was removed. Software development sucks.
* client API: add a playlist entry unique IDwm42020-03-212-2/+22
| | | |</