summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* common: clang supports __builtin_clz also in non-GNU modesKacper Michajłow5 days1-1/+1
|
* stream: implement get_protocols method for stream_lavfDudemanguy2024-05-222-0/+13
| | | | | | | | | | | | | | | Previously, all stream protocols were a static list in mpv. This is okay for own builtin stuff, but for protocols that depend on ffmpeg it's not so great. Support for certain protocols may or may not be enabled in a user's ffmpeg and the protocol list that mpv generates should ideally match this. Fix this by implementing a get_protocols method for stream_lavf that will have different results depending on the ffmpeg mpv is built against. We keep the safe and unsafe protocols separation. The former is essentially a whitelist. Any protocol that is found in ffmpeg but is not in the safe whitelist is considered unsafe. In the stream list, ffmpeg is moved to the bottom so any possible protocols that are added in the future don't automatically take precedence over any builtin mpv ones.
* av_common: parent mp_get_lavf_demuxer contents to the listDudemanguy2024-05-221-1/+1
| | | | | The only usage of this function is freed in mpv's generic property code, so no other changes are needed.
* msg: clear status line only if neededKacper Michajłow2024-05-191-1/+15
|
* msg: split mp_msg_flush_status_line into private and public variantKacper Michajłow2024-05-191-12/+17
|
* msg: check target stream before printingKacper Michajłow2024-05-191-9/+14
| | | | | After f18ce7eca00a2ea384a5244c6b01e82e5ede0630 status is not always printed to stderr.
* av_common: fix integer overflow when adjusting timebaseKacper Michajłow2024-05-151-3/+5
| | | | Found by OSS-Fuzz.
* msg: print all messages to one streamKacper Michajłow2024-05-061-2/+1
| | | | | | This reverts commit 4939570e17d4659944924ed6012793b433109ab1 and makes it more strict about the output stream. Status message is also on the same stream now.
* player/main: select msg output stream earlyKacper Michajłow2024-05-062-6/+15
| | | | | | | | This avoids printing any stray messages in encode output stream. --o is already pre-parse cli option which is designed to be parsed before anything else is printed to output. So we can use that to force stderr output if needed for encode mode.
* osdep/mpv.rc: fix encoding of MPVCOPYRIGHTKacper Michajłow2024-05-061-1/+3
| | | | llvm-rc doesn't allow multi-byte codes in narrow utf-8.
* common: define some bits for Windows SDKKacper Michajłow2024-05-061-0/+21
|
* various: move strings.h inclusion to common.hKacper Michajłow2024-05-062-1/+2
|
* various: move unistd.h inclusion to common.hKacper Michajłow2024-05-063-2/+6
|
* player/command: add track-list/N/decoderKacper Michajłow2024-04-181-0/+2
|
* player/command: add video-codec-info and audio-codec-infoKacper Michajłow2024-04-152-0/+10
| | | | | | | | | | | Adds support for extracting codec profile. Old properties are redirected to new one and removed from docs. Likely will stay like that forever as there is no reason to remove them. As a effect of unification of properties between audio and video, video-codec will now print codec (format) descriptive name, not decoder long name as it were before. In practice this change fixes what docs says. If you really need decoder name, use the `track-list/N/decoder-desc`.
* msg: use fwriteKacper Michajłow2024-04-131-6/+3
| | | | No need to recalc string length.
* msg: use defines for hide/restore cursor codeKacper Michajłow2024-04-131-2/+2
|
* msg: don't keep status line in partialKacper Michajłow2024-04-131-2/+2
| | | | | Noticed while looking at this code, we shouldn't append status line to partial when !print_term.
* m_property: add `>` for fixed precision floating-point expansionKacper Michajłow2024-03-212-0/+25
| | | | | | | | | | | | | | This enhancement makes it easier to create constant width property expansions, useful for the `--term-status-msg`. Additionally, it changes to `%f` printing with manual zero trimming, which is easier to control than `%g`. With this method, we can directly specify precision, not just significant numbers. This approach also avoids overly high precision for values less than 1, which is not necessary for a generic floating-point print function. A new print helper function is added, which can be used with adjusted precision for specific cases where a different default is needed. This also unifies the code slightly.
* msg: clear buffered status_line on flushKacper Michajłow2024-03-211-0/+1
| | | | It shouldn't be used after flush anymore.
* msg: simplify the line_skip calculationKacper Michajłow2024-03-211-13/+7
| | | | | | | | | | | Make it more straightforward by always calculating top offset first instead of having two branches, that tries to calc it directly. This also fixes missing negative check before `\033[%dA` which was in practice only problem on macOS which was handling negative values, while in fact it shouldn't. Fixes: #13484
* common/msg: fix warning: void function should not return void expressionnanahi2024-03-191-4/+7
|
* common/msg: fix warning: use of non-standard escape character '\e'nanahi2024-03-191-1/+1
|
* input/player: add loadfile/loadlist insert-at commandDavid Vaughan2024-02-262-2/+4
|
* player: change insert_next to insert_atDavid Vaughan2024-02-262-21/+10
| | | | | | | | | | Change the `playlist_insert_next` function to `playlist_insert_at` (ie, insert at the location of an entry, rather than after it, and rename to be clearer that it doesn't have anything to do with the currently-playing entry). Also, replace calls to `playlist_add` with calls to `playlist_insert_at`, since the former has become redundant.
* player: add loadfile insert-next commandsDavid Vaughan2024-02-262-0/+23
| | | | | | | | | | | | | This commit adds two new commands (`insert-next` and `insert-next-play`) which mirror the existing commands, `append` and `append-play` in functionality, with the difference that they insert directly after the current playlist entry, rather than at the end of the playlist. This change gives MPV a piece of functionality already found in (for example) Spotify's media player: "play next". Additionally, using the new `insert-next` command, users can trivially write a script to play a new piece of media immediately without otherwise clearing or altering the remainder of the playlist.
* encode_lavc: don't use deprecated `avcodec_close`llyyr2024-02-191-1/+1
| | | | Deprecated upstream https://github.com/FFmpeg/FFmpeg/commit/1cc24d749569a42510399a29b034f7a77bdec34e
* common: don't force terminal log buffer to small sizesfan52024-01-272-5/+41
| | | | | | | | | | | | Using the 'terminal-default' log level a client can request to get all messages that would normally appear on the terminal. 8c2d73f112055a9e52e5bda4934c2ac90e31def7 changed the size of the relevant buffer to 100 lines, which was prone to quickly overflowing once you enable verbose or debug output. This size is kept for the early terminal buffer but now enlarged once a client actually requests this log level. This fixes the overflow risk while not consuming more resources if this feature is unused.
* version.h.in: bump copyright yearnanahi2024-01-271-1/+1
|
* msg: reset status_lines when setting --really-quietGuido Cella2024-01-211-0/+6
| | | | | | | | | | This prevents mp_msg_flush_status_line() from printing an unnecessary newline when changing file after setting --really-quiet at runtime. If mpv is backgrounded, this newline garbles the output of TUI programs. With this change the cursor is not re-enabled after setting --really-quiet at runtime and quitting with mpv in the foreground, so enable it on uninit.
* common: stream: don't mention Libav in errors/warningsllyyr2024-01-202-3/+3
|
* terminal: don't print escape sequence if not ttyKacper Michajłow2024-01-151-1/+3
|
* msg: return zero length if bstr_split_utf8 failsKacper Michajłow2024-01-101-1/+1
| | | | | | | | | | In theory bstr_split_utf8 should skip invalid sequence and move further, but it doesn't do that currently, so just the string if unsuported code if found. Fixes infinite loop on code.len == 0 condition. Fixes: 5864b72d1a0aecd7e2d56e546fb615d291c88274
* msg: improve term_disp_width to support unicodeKacper Michajłow2024-01-041-13/+12
| | | | | | | All characters are assumed to be single-width. This is consistent with the rest of the code and documentation. Fixes: #13150
* msg: reduce nesting in mp_msg_flush_status_lineKacper Michajłow2023-12-271-18/+22
| | | | Cosmetic change only.
* msg: keep status line on the end of fileKacper Michajłow2023-12-272-3/+10
| | | | | | Apparently found useful by some users. Fixes: #13092
* common/av_log: do not assume AVClass.item_name is always setKacper Michajłow2023-12-241-1/+6
| | | | | | After recent change in FFmpeg it is not longer safe to call item_name. Ref: https://github.com/FFmpeg/FFmpeg/commit/0c6203c97a99f69dbaa6e4011d48c331e1111f5e
* playlist: correctly populate playlist-path with the --playlist optionDudemanguy2023-12-131-0/+1
| | | | | | | | | | When using the --playlist option on the commandline, it would mark all entries on the command as having the playlist-path of the value of that passed option, not just the ones that were expanded from it. Fix this by moving the playlist_populate_playlist_path to the same place where the playlist file gets expanded. Ref https://github.com/mpv-player/mpv/issues/13075#issuecomment-1852179164
* common/av_log: use bstr for log callbackKacper Michajłow2023-11-281-10/+14
| | | | | | - don't use 4KiB stack array - keep one bstr allocation for lifetime of the log - avoid dummy strlen
* build: restrict git describe to top level source directoryJan Palus2023-11-271-1/+4
| | | | | fix version determination when building mpv from release tarball extracted within another git repository
* common/msg: remove redundant checkKacper Michajłow2023-11-181-1/+1
| | | | It is already strcmp above, so cannot be NULL.
* msg: ensure status line is always visibleKacper Michajłow2023-11-081-1/+27
| | | | Restore last status line if it has been cleared by another message.
* msg: factor out print codeKacper Michajłow2023-11-081-52/+61
| | | | Will be useful for next commit.
* msg: convert dump_stats to bstrKacper Michajłow2023-11-081-5/+3
|
* msg: use bstr for partial msgKacper Michajłow2023-11-081-11/+6
|
* msg: check isatty separately per each streamKacper Michajłow2023-11-081-12/+29
|
* msg: refactor how terminal messages are printedKacper Michajłow2023-11-081-99/+156
| | | | | | | | | | | | - prepare string before printing - reduce amount of fflush(), especially for multiline messages - clear status line and keep it always at the bottom - indent module name to the longest value - disable cursor for status line - properly support wrapped status line Overall makes status line less flickering and remove stray status instead of scrolling them up.
* msg: don't mix partial log messages, with unrelated log levelsKacper Michajłow2023-11-081-9/+11
|
* mp_thread: add win32 implementationKacper Michajłow2023-11-051-1/+0
|
* mp_thread: prefer tracking threads with idKacper Michajłow2023-11-052-6/+6
| | | | | | | | | | | | | | This change essentially removes mp_thread_self() and instead add mp_thread_id to track threads and have ability to query current thread id during runtime. This will be useful for upcoming win32 implementation, where accessing thread handle is different than on pthreads. Greatly reduces complexity. Otherweis locked map of tid <-> handle is required which is completely unnecessary for all mpv use-cases. Note that this is the mp_thread_id, not to confuse with system tid. For example on threads-posix implementation it is simply pthread_t.
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-056-140/+125
|
* mp_threads: rename threads for consistent naming across all of themKacper Michajłow2023-10-271-1/+1
| | | | | | | | I'd like some names to be more descriptive, but to work with 15 chars limit we have to make some sacrifice. Also because of the limit, remove the `mpv/` prefix and prioritize actuall thread name.
* timer: remove MP_START_TIMENRK2023-10-271-2/+2
| | | | | instead require mp_raw_time_ns() to not return 0, which all current implementation already should follow.
* msg: make mp_msg_find_level case insensitiveKacper Michajłow2023-10-271-1/+1
|
* various: sort some standard headersNRK2023-10-202-6/+6
| | | | | | | | | | | | since i was going to fix the include order of stdatomic, might as well sort the surrouding includes in accordance with the project's coding style. some headers can sometime require specific include order. standard library headers usually don't. but mpv might "hack into" the standard headers (e.g pthreads) so that complicates things a bit more. hopefully nothing breaks. if it does, the style guide is to blame.
* various: remove ATOMIC_VAR_INITNRK2023-10-201-1/+1
| | | | | | | | | | | the fallback needed it due to the struct wrapper. but the fallback is now removed so it's no longer needed. as for standard atomics, it was never really needed either, was useless and then made obsolete in C17 and removed in C23. ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/ ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
* osdep: remove atomic.hNRK2023-10-202-2/+2
| | | | | | | replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with explicit _Atomic qualified types. also add missing config.h includes on some files.
* video/mp_image: handle non-power-of-two alignmentNiklas Haas2023-10-191-0/+4
| | | | Needed for odd formats like rgb24.
* common: add mp_lcm helperNiklas Haas2023-10-192-0/+8
|
* common/tags: add mp_tags_move_from_av_dictionary()Claude Heiland-Allen2023-10-182-0/+9
| | | | | | | | | | Abstracts a common pattern, in which the av dictionary is cleared immediately after copying to mp tags, so that additional tags later in the stream get appended to empty tags, instead of being appended to existing tags that were already copied.
* stats: convert timers to nanosecondsDudemanguy2023-10-161-10/+10
|
* command: fix segfault with playlist-{next,prev}-playlistGuido Cella2023-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | This was wrongly assuming that playlist_path is always set for the current playlist entry, but it's only set when a file was added by expanding a playlist. The crash in playlist_get_first_in_next_playlist can be reproduced with mpv foo.mkv foo.zip, playlist-next, playlist-prev, playlist-next-playlist. You need to run playlist-next, playlist-prev first because foo.zip's playlist_path is NULL until you do that, which makes playlist_get_first_in_next_playlist return immediately. The crash in cmd_playlist_next_prev_playlist can be replicated with mpv --loop-playlist foo.zip foo.mkv, running playlist-next until foo.mkv, and playlist-play-next. Again, you need to open foo.zip first or its playlist_path is NULL which skips running strcmp(entry->playlist_path, mpctx->playlist->current->playlist_path). Fixes https://github.com/mpv-player/mpv/issues/12495#issuecomment-1760968608
* command: add playlist-next-playlist and playlist-prev-playlistGuido Cella2023-10-092-0/+72
| | | | | | | | | | | | playlist-prev-playlist goes to the beginning of the previous playlist because this seems more useful and symmetrical to playlist-next-playlist. It does not go to the beginning when the current playlist-path starts with the previous playlist-path, e.g. with mpv --loop-playlist foo/, which expands to foo/{1..9}.zip, the current playlist path foo/1.zip beings with the playlist-path foo/ of {2..9}.zip and thus playlist-prev-playlist goes to 9.zip rather than to 2.zip. Closes #12495.
* loadfile: fix an old wonky playlist heuristicDudemanguy2023-10-051-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2c6a3cb1f27e02b2e66390a2465ab648905a64d0 originally added this struct member and then 1be863afdbe9017aa227234e8525b209fb818224 later added some more logic to loadfile that uses this. There's been more changes since then of course, but bits using playback_short and playback_start have mostly stayed the same. It's a bit strange it's worked this way for so long since it makes an assumption on how long files should be and leads to weird, broken behavior on playlists with shorter videos. The main reason for playlist_short, as far as I can tell, is to deal with some fringe cases with short videos and trying to go back in the playlist. More specifically, if you use --loop=inf on a very short video (say less than 1 second) and try to go back in the playlist, you won't be able to without any of this special logic that deals with it. But the current approach has several side effects like going back multiple items in the playlist instead of just one if the video is less than one second. This is just bad so delete everything related to playlist_short and playlist_start. Instead, let's handle this by keeping track of playlist-prev attempts. Going forward in the playlist doesn't require any special handling since a bad/broken file will just advance to the next one. So it's only going backwards that requires some special consideration. If we're going backwards and the user isn't using force, then mark the playlist entry with a special flag. If the file loads successfully in play_current_file, we can just clear the flag and not worry about it. However if there's a failure, then we set a bool telling play_current_file that it should go back one more item in the playlist if possible and try again. This way, we avoid the previously mentioned --loop=inf edgecase and the user can still attempt to retry previously failed items in the playlist (like a url or such). Fixes #6576, fixes #12548.
* msg: use nanosecond precisionDudemanguy2023-09-291-3/+3
| | | | | | | | | | The timestamps when making a log file is actually dependent on MP_START_TIME. This is a 10 microsecond offset that was added to the timer as an offset. With the nanosecond change, this unit needs to be converted as well so the offset is the same as before. After doing that, we need to change the various mp_time_us calls in msg to mp_time_ns and do the right conversion. This fixes the logs timestamps (i.e. so they aren't negative anymore).
* win32/pthread: define _POSIX_TIMERS to notify they are not supportedKacper Michajłow2023-09-291-2/+1
|
* recorder: fix a couple of memory leaksDudemanguy2023-09-261-7/+16
| | | | Not sure how long these have been around but it leaked on every packet.
* options: remove a few options marked with .deprecation_messageDudemanguy2023-09-213-23/+0
| | | | | | | | | | | A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the options still possibly do something but they have a deprecation message. Most of these are old and have no real usage. The only potentially controversial ones are the removal of --oaffset and --ovoffset which were deprecated years ago and seemingly have no real replacement. There's a cryptic message about --audio-delay but who knows. The less encoding mode code we have, the better so just chuck it.
* options: remove ancient option fallbacks/deprecationDudemanguy2023-09-211-7/+0
| | | | | | | | | | | | | We've got an ungodly amount of OPT_REPLACED and OPT_REMOVED sitting around in the code. This is harmless, but the vast majority of these are ancient. 26f4f18c0629998a9b91e94722d166866d8b80a3 is the last commit that touched the majority of these and of course that only changed how options were declared so all of this stuff was deprecated even before that. No use in keeping these, so just delete them all. As an aside, there was actually a cocoa_opts but it had only a single option which was replaced by something else and empty otherwise. So that entire thing was just simply removed. OPT_REPLACED/OPT_REMOVED declarations that were added in 0.35 or later were kept as is.
* vario